r22395 by jghali -
scribus-commit
scribus-commit at lists.scribus.net
Thu Feb 15 23:32:23 UTC 2018
Author: jghali
Date: Thu Feb 15 23:32:23 2018
New Revision: 22395
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22395
Log:
backport #15149 fix: PDF Bookmarks with page number or page count characters can result in a broken Document
Modified:
branches/Version14x/Scribus/scribus/bookmwin.cpp
branches/Version14x/Scribus/scribus/bookmwin.h
Modified: branches/Version14x/Scribus/scribus/bookmwin.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22395&path=/branches/Version14x/Scribus/scribus/bookmwin.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/bookmwin.cpp (original)
+++ branches/Version14x/Scribus/scribus/bookmwin.cpp Thu Feb 15 23:32:23 2018
@@ -30,25 +30,25 @@
BookMItem::BookMItem(QTreeWidgetItem* parent, struct ScribusDoc::BookMa *Bm)
: QTreeWidgetItem(parent)
{
- SetUp(Bm);
+ Setup(Bm);
}
BookMItem::BookMItem(QTreeWidgetItem* parent, QTreeWidgetItem* after, struct ScribusDoc::BookMa *Bm)
: QTreeWidgetItem(parent, after)
{
- SetUp(Bm);
+ Setup(Bm);
}
BookMItem::BookMItem(QTreeWidget* parent, QTreeWidgetItem* after, struct ScribusDoc::BookMa *Bm)
: QTreeWidgetItem(parent, after)
{
- SetUp(Bm);
+ Setup(Bm);
}
BookMItem::BookMItem(QTreeWidget* parent, struct ScribusDoc::BookMa *Bm)
: QTreeWidgetItem(parent)
{
- SetUp(Bm);
+ Setup(Bm);
}
BookMItem::BookMItem(QTreeWidget* parent, QTreeWidgetItem* after, int nr, PageItem* PObject)
@@ -79,7 +79,7 @@
Pare = 0;
}
-void BookMItem::SetUp(struct ScribusDoc::BookMa *Bm)
+void BookMItem::Setup(struct ScribusDoc::BookMa *Bm)
{
ItemNr = Bm->ItemNr;
PdfObj = 0;
@@ -134,23 +134,45 @@
void BookMView::AddPageItem(PageItem* ite)
{
- QString bm = "";
- QString bm2 = "";
- QString cc;
- for (int d = 0; d < ite->itemText.length(); ++d)
- {
- cc = ite->itemText.text(d);
- if ((cc == QChar(13)) || (cc == QChar(10)))
- break;
- if (cc == QChar(29))
- cc = " ";
- if ((cc == "(") || (cc == ")") || (cc == "\\"))
- bm2 += "\\";
- bm += cc;
- bm2 += cc;
- }
+ QString bm;
+ QString bm2;
+
+ getTextAndTitle(ite, bm, bm2);
AddItem(bm, bm2, ite);
Last = NrItems;
+}
+
+void BookMView::getTextAndTitle(PageItem* item, QString& text, QString& title)
+{
+ QChar ch;
+ QString str;
+
+ text.clear();
+ title.clear();
+
+ const StoryText& itemText = item->itemText;
+ for (int i = 0; i < item->itemText.length(); ++i)
+ {
+ str = item->itemText.text(i);
+ if ((str == SpecialChars::PARSEP) || (str == SpecialChars::LINEBREAK) || (str == QChar(10)))
+ break;
+ if (str == SpecialChars::PAGENUMBER || str == SpecialChars::PAGECOUNT)
+ {
+ str = item->ExpandToken(i);
+ if (str.isEmpty())
+ str = SpecialChars::ZWNBSPACE;
+ }
+ for (int j = 0; j < str.length(); ++j)
+ {
+ ch = str.at(j);
+ if (ch == SpecialChars::OLD_NBSPACE)
+ ch = ' ';
+ if ((ch == '(') || (ch == ')') || (ch == '\\'))
+ title += "\\";
+ text += ch;
+ title += ch;
+ }
+ }
}
void BookMView::setPageItem(QTreeWidgetItem * current, QTreeWidgetItem * /*previous*/)
@@ -277,19 +299,10 @@
void BookMView::ChangeText(PageItem *currItem)
{
BookMItem *ite;
- QString bm = "";
- QString bm2 = "";
- QString cc;
- for (int d = 0; d < currItem->itemText.length(); ++d)
- {
- cc = currItem->itemText.text(d);
- if ((cc == QChar(13)) || (cc == QChar(10)))
- break;
- if ((cc == "(") || (cc == ")") || (cc == "\\"))
- bm2 += "\\";
- bm += cc;
- bm2 += cc;
- }
+ QString bm, bm2;
+
+ getTextAndTitle(currItem, bm, bm2);
+
QTreeWidgetItemIterator it(this);
while (*it)
{
Modified: branches/Version14x/Scribus/scribus/bookmwin.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22395&path=/branches/Version14x/Scribus/scribus/bookmwin.h
==============================================================================
--- branches/Version14x/Scribus/scribus/bookmwin.h (original)
+++ branches/Version14x/Scribus/scribus/bookmwin.h Thu Feb 15 23:32:23 2018
@@ -47,8 +47,10 @@
BookMItem(QTreeWidget* parent, QTreeWidgetItem* after, int nr, PageItem *PObject);
BookMItem(QTreeWidget* parent, int nr, PageItem *PObject);
~BookMItem() {};
- void SetUp(struct ScribusDoc::BookMa *Bm);
+
+ void Setup(struct ScribusDoc::BookMa *Bm);
virtual QString key(int, bool) const;
+
PageItem *PageObject;
int ItemNr;
int PdfObj;
@@ -79,6 +81,7 @@
public:
BookMView(QWidget* parent);
~BookMView() {};
+
void AddItem(QString text, QString Tit, PageItem *PageObject);
void DeleteItem(PageItem *PageObject);
void SetAction(PageItem *currItem, QString Act);
@@ -105,6 +108,7 @@
protected:
void dropEvent(QDropEvent *e);
+ void getTextAndTitle(PageItem* item, QString& text, QString& title);
private slots:
void setPageItem(QTreeWidgetItem * current, QTreeWidgetItem * previous);
More information about the scribus-commit
mailing list