r21361 by jghali -
scribus-commit
scribus-commit at lists.scribus.net
Tue May 31 22:20:22 UTC 2016
Author: jghali
Date: Tue May 31 22:20:22 2016
New Revision: 21361
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=21361
Log:
#14117: When printing pages with page numbers at bottom some of the page numbers don't print correctly
Modified:
trunk/Scribus/scribus/scribusdoc.cpp
Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=21361&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Tue May 31 22:20:22 2016
@@ -4536,8 +4536,108 @@
if (!it->isTextFrame() && !it->isPathText())
return;
+ // This works pretty well except for the case of page numbers and al. placed on masterpages
+ // where layout may depend on the page where the masterpage item is placed
UsedGlyphsPainter p(Really);
it->textLayout.render(&p);
+
+ // Process page numbers and page count special characters
+ FPointArray gly;
+ QChar chstr;
+
+ int start = it->isTextFrame() ? it->firstInFrame() : 0;
+ int stop = it->isTextFrame() ? it->lastInFrame() + 1 : it->itemText.length();
+ for (int e = start; e < stop; ++e)
+ {
+ const ScFace* font = &it->itemText.charStyle(e).font();
+ QString fontName = font->replacementName();
+ if (!Really.contains(fontName) )
+ {
+ if (!fontName.isEmpty())
+ Really.insert(fontName, QMap<uint, FPointArray>());
+ }
+ uint chr = it->itemText.text(e).unicode();
+ if ((chr == 30) || (chr == 23))
+ {
+ //Our page number collection string
+ QString pageNumberText;
+ if (chr == 30)
+ {//ch == SpecialChars::PAGENUMBER
+ if (e > 0 && it->itemText.text(e-1) == SpecialChars::PAGENUMBER)
+ pageNumberText = SpecialChars::ZWNBSPACE;
+ else if (lc!=0) //If not on a master page just get the page number for the page and the text
+ {
+ pageNumberText = QString("%1").arg(getSectionPageNumberForPageIndex(it->OwnPage),
+ getSectionPageNumberWidthForPageIndex(it->OwnPage),
+ getSectionPageNumberFillCharForPageIndex(it->OwnPage));
+ }
+ else
+ {
+ //Else, for a page number in a text frame on a master page we must scan
+ //all pages to see which ones use this page and get their page numbers.
+ //We only add each character of the pages' page number text if its nothing
+ //already in the pageNumberText variable. No need to add glyphs twice.
+ QString newText;
+ uint docPageCount = DocPages.count();
+ for (uint a = 0; a < docPageCount; ++a)
+ {
+ if (DocPages.at(a)->MPageNam == it->OnMasterPage)
+ {
+ newText = QString("%1").arg(getSectionPageNumberForPageIndex(a),
+ getSectionPageNumberWidthForPageIndex(a),
+ getSectionPageNumberFillCharForPageIndex(a));
+ for (int nti = 0; nti < newText.length(); ++nti)
+ if (pageNumberText.indexOf(newText[nti]) == -1)
+ pageNumberText += newText[nti];
+ }
+ }
+ }
+ }
+ else
+ {//ch == SpecialChars::PAGECOUNT
+ if (lc!=0)
+ {
+ int key = getSectionKeyForPageIndex(it->OwnPage);
+ if (key == -1)
+ pageNumberText = "";
+ else
+ pageNumberText = QString("%1").arg(getStringFromSequence(m_docPrefsData.docSectionMap[key].type, m_docPrefsData.docSectionMap[key].toindex - m_docPrefsData.docSectionMap[key].fromindex + 1));
+ }
+ else
+ {
+ QString newText;
+ uint docPageCount = DocPages.count();
+ for (uint a = 0; a < docPageCount; ++a)
+ {
+ if (DocPages.at(a)->MPageNam == it->OnMasterPage)
+ {
+ int key = getSectionKeyForPageIndex(a);
+ if (key == -1)
+ newText = "";
+ else
+ newText = QString("%1").arg(getStringFromSequence(m_docPrefsData.docSectionMap[key].type, m_docPrefsData.docSectionMap[key].toindex - m_docPrefsData.docSectionMap[key].fromindex + 1));
+ for (int nti = 0; nti < newText.length(); ++nti)
+ if (pageNumberText.indexOf(newText[nti]) == -1)
+ pageNumberText += newText[nti];
+ }
+ }
+ }
+ }
+ //Now scan and add any glyphs used in page numbers
+ for (int pnti = 0; pnti < pageNumberText.length(); ++pnti)
+ {
+ uint chr = pageNumberText[pnti].unicode();
+ if (font->canRender(chr))
+ {
+ uint gl = font->char2CMap(pageNumberText[pnti]);
+ FPointArray gly(font->glyphOutline(gl));
+ if (!fontName.isEmpty())
+ Really[fontName].insert(gl, gly);
+ }
+ }
+ continue;
+ }
+ }
}
More information about the scribus-commit
mailing list