r17753 by jghali - suppress unnecessary big if() block in checkItemForFonts() function

scribus-commit scribus-commit at lists.scribus.net
Fri Aug 3 23:15:43 UTC 2012


Author: jghali
Date: Fri Aug  3 23:15:43 2012
New Revision: 17753

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17753
Log:
suppress unnecessary big if() block in checkItemForFonts() function

Modified:
    trunk/Scribus/scribus/scribusdoc.cpp

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17753&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Fri Aug  3 23:15:43 2012
@@ -3965,169 +3965,170 @@
 {
 	FPointArray gly;
 	QChar chstr;
-	if ((it->itemType() == PageItem::TextFrame) || (it->itemType() == PageItem::PathText))
-	{
-		/* May be needed for fixing #10371 completely
-		if (it->isAnnotation())
-		{
-			int annotType  = it->annotation().Type();
-			bool mustEmbed = ((annotType >= 2) && (annotType <= 6) && (annotType != 4));
-			if (mustEmbed && (!Really.contains(it->itemText.defaultStyle().charStyle().font().replacementName())))
-			{
-				Really.insert(it->itemText.defaultStyle().charStyle().font().replacementName(), QMap<uint, FPointArray>());
-			}
-		}*/
-		int start = it->isTextFrame() ? it->firstInFrame() : 0;
-		int stop  = it->isTextFrame() ? it->lastInFrame() + 1 : it->itemText.length();
-		for (int e = start; e < stop; ++e)
-		{
-			if (! Really.contains(it->itemText.charStyle(e).font().replacementName()) )
-			{
+
+	if (!it->isTextFrame() && !it->isPathText())
+		return;
+
+	/* May be needed for fixing #10371 completely
+	if (it->isAnnotation())
+	{
+		int annotType  = it->annotation().Type();
+		bool mustEmbed = ((annotType >= 2) && (annotType <= 6) && (annotType != 4));
+		if (mustEmbed && (!Really.contains(it->itemText.defaultStyle().charStyle().font().replacementName())))
+		{
+			Really.insert(it->itemText.defaultStyle().charStyle().font().replacementName(), QMap<uint, FPointArray>());
+		}
+	}*/
+	int start = it->isTextFrame() ? it->firstInFrame() : 0;
+	int stop  = it->isTextFrame() ? it->lastInFrame() + 1 : it->itemText.length();
+	for (int e = start; e < stop; ++e)
+	{
+		if (! Really.contains(it->itemText.charStyle(e).font().replacementName()) )
+		{
+			if (!it->itemText.charStyle(e).font().replacementName().isEmpty())
+				Really.insert(it->itemText.charStyle(e).font().replacementName(), QMap<uint, FPointArray>());
+		}
+		uint chr = it->itemText.text(e).unicode();
+		if ((chr == 13) || (chr == 32) || ((chr >= 26) && (chr <= 29)))
+			continue;
+		if (chr == 9)
+		{
+			for (int t1 = 0; t1 < it->itemText.paragraphStyle(e).tabValues().count(); t1++)
+			{
+				if (it->itemText.paragraphStyle(e).tabValues()[t1].tabFillChar.isNull())
+					continue;
+				chstr = it->itemText.paragraphStyle(e).tabValues()[t1].tabFillChar;
+				if ((it->itemText.charStyle(e).effects() & ScStyle_SmallCaps) || (it->itemText.charStyle(e).effects() & ScStyle_AllCaps))
+				{
+					if (chstr.toUpper() != chstr)
+						chstr = chstr.toUpper();
+				}
+				chr = chstr.unicode();
+				uint gl = it->itemText.charStyle(e).font().char2CMap(chstr);
+				gly = it->itemText.charStyle(e).font().glyphOutline(gl);
 				if (!it->itemText.charStyle(e).font().replacementName().isEmpty())
-					Really.insert(it->itemText.charStyle(e).font().replacementName(), QMap<uint, FPointArray>());
-			}
-			uint chr = it->itemText.text(e).unicode();
-			if ((chr == 13) || (chr == 32) || ((chr >= 26) && (chr <= 29)))
-				continue;
-			if (chr == 9)
-			{
-				for (int t1 = 0; t1 < it->itemText.paragraphStyle(e).tabValues().count(); t1++)
+					Really[it->itemText.charStyle(e).font().replacementName()].insert(gl, gly);
+			}
+			for (int t1 = 0; t1 < it->itemText.defaultStyle().tabValues().count(); t1++)
+			{
+				if (it->itemText.defaultStyle().tabValues()[t1].tabFillChar.isNull())
+					continue;
+				chstr = it->itemText.defaultStyle().tabValues()[t1].tabFillChar;
+				if ((it->itemText.charStyle(e).effects() & ScStyle_SmallCaps) || (it->itemText.charStyle(e).effects() & ScStyle_AllCaps))
 				{
-					if (it->itemText.paragraphStyle(e).tabValues()[t1].tabFillChar.isNull())
-						continue;
-					chstr = it->itemText.paragraphStyle(e).tabValues()[t1].tabFillChar;
-					if ((it->itemText.charStyle(e).effects() & ScStyle_SmallCaps) || (it->itemText.charStyle(e).effects() & ScStyle_AllCaps))
+					if (chstr.toUpper() != chstr)
+						chstr = chstr.toUpper();
+				}
+				chr = chstr.unicode();
+				uint gl = it->itemText.charStyle(e).font().char2CMap(chstr);
+				gly = it->itemText.charStyle(e).font().glyphOutline(gl);
+				if (!it->itemText.charStyle(e).font().replacementName().isEmpty())
+					Really[it->itemText.charStyle(e).font().replacementName()].insert(gl, gly);
+			}
+			continue;
+		}
+		if ((chr == 30) || (chr == 23))
+		{
+			//Our page number collection string
+			QString pageNumberText(QString::null);
+			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=getSectionPageNumberForPageIndex(it->OwnPage);
+					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 (chstr.toUpper() != chstr)
-							chstr = chstr.toUpper();
+						if (DocPages.at(a)->MPageNam == it->OnMasterPage)
+						{
+//								newText=getSectionPageNumberForPageIndex(a);
+							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];
+						}
 					}
-					chr = chstr.unicode();
-					uint gl = it->itemText.charStyle(e).font().char2CMap(chstr);
-					gly = it->itemText.charStyle(e).font().glyphOutline(gl);
+				}
+			}
+			else
+			{//ch == SpecialChars::PAGECOUNT
+				if (lc!=0)
+				{
+					int key = getSectionKeyForPageIndex(it->OwnPage);
+					if (key == -1)
+						pageNumberText = "";
+					else
+						pageNumberText = QString("%1").arg(getStringFromSequence(docPrefsData.docSectionMap[key].type, docPrefsData.docSectionMap[key].toindex - 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(docPrefsData.docSectionMap[key].type, docPrefsData.docSectionMap[key].toindex - 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 (it->itemText.charStyle(e).font().canRender(chr))
+				{
+					uint gl = it->itemText.charStyle(e).font().char2CMap(pageNumberText[pnti]);
+					FPointArray gly(it->itemText.charStyle(e).font().glyphOutline(gl));
 					if (!it->itemText.charStyle(e).font().replacementName().isEmpty())
 						Really[it->itemText.charStyle(e).font().replacementName()].insert(gl, gly);
 				}
-				for (int t1 = 0; t1 < it->itemText.defaultStyle().tabValues().count(); t1++)
-				{
-					if (it->itemText.defaultStyle().tabValues()[t1].tabFillChar.isNull())
-						continue;
-					chstr = it->itemText.defaultStyle().tabValues()[t1].tabFillChar;
-					if ((it->itemText.charStyle(e).effects() & ScStyle_SmallCaps) || (it->itemText.charStyle(e).effects() & ScStyle_AllCaps))
-					{
-						if (chstr.toUpper() != chstr)
-							chstr = chstr.toUpper();
-					}
-					chr = chstr.unicode();
-					uint gl = it->itemText.charStyle(e).font().char2CMap(chstr);
-					gly = it->itemText.charStyle(e).font().glyphOutline(gl);
-					if (!it->itemText.charStyle(e).font().replacementName().isEmpty())
-						Really[it->itemText.charStyle(e).font().replacementName()].insert(gl, gly);
-				}
-				continue;
-			}
-			if ((chr == 30) || (chr == 23))
-			{
-				//Our page number collection string
-				QString pageNumberText(QString::null);
-				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=getSectionPageNumberForPageIndex(it->OwnPage);
-						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=getSectionPageNumberForPageIndex(a);
-								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(docPrefsData.docSectionMap[key].type, docPrefsData.docSectionMap[key].toindex - 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(docPrefsData.docSectionMap[key].type, docPrefsData.docSectionMap[key].toindex - 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 (it->itemText.charStyle(e).font().canRender(chr))
-					{
-						uint gl = it->itemText.charStyle(e).font().char2CMap(pageNumberText[pnti]);
-						FPointArray gly(it->itemText.charStyle(e).font().glyphOutline(gl));
-						if (!it->itemText.charStyle(e).font().replacementName().isEmpty())
-							Really[it->itemText.charStyle(e).font().replacementName()].insert(gl, gly);
-					}
-				}
-				continue;
-			}
-			if (it->itemText.charStyle(e).effects() & ScStyle_SoftHyphenVisible)
-			{
-				uint gl = it->itemText.charStyle(e).font().char2CMap(QChar('-'));
-				FPointArray gly(it->itemText.charStyle(e).font().glyphOutline(gl));
-				if (!it->itemText.charStyle(e).font().replacementName().isEmpty())
-					Really[it->itemText.charStyle(e).font().replacementName()].insert(gl, gly);
-			}
-			if ((it->itemText.charStyle(e).effects() & ScStyle_SmallCaps) || (it->itemText.charStyle(e).effects() & ScStyle_AllCaps))
-			{
-				chstr = it->itemText.text(e);
-				if (chstr.toUpper() != chstr)
-					chstr = chstr.toUpper();
-				chr = chstr.unicode();
-			}
-			if (it->itemText.charStyle(e).font().canRender(chr))
-			{
-				uint gl = it->itemText.charStyle(e).font().char2CMap(chr);
-				gly = it->itemText.charStyle(e).font().glyphOutline(gl);
-				if (!it->itemText.charStyle(e).font().replacementName().isEmpty())
-					Really[it->itemText.charStyle(e).font().replacementName()].insert(gl, gly);
-			}
+			}
+			continue;
+		}
+		if (it->itemText.charStyle(e).effects() & ScStyle_SoftHyphenVisible)
+		{
+			uint gl = it->itemText.charStyle(e).font().char2CMap(QChar('-'));
+			FPointArray gly(it->itemText.charStyle(e).font().glyphOutline(gl));
+			if (!it->itemText.charStyle(e).font().replacementName().isEmpty())
+				Really[it->itemText.charStyle(e).font().replacementName()].insert(gl, gly);
+		}
+		if ((it->itemText.charStyle(e).effects() & ScStyle_SmallCaps) || (it->itemText.charStyle(e).effects() & ScStyle_AllCaps))
+		{
+			chstr = it->itemText.text(e);
+			if (chstr.toUpper() != chstr)
+				chstr = chstr.toUpper();
+			chr = chstr.unicode();
+		}
+		if (it->itemText.charStyle(e).font().canRender(chr))
+		{
+			uint gl = it->itemText.charStyle(e).font().char2CMap(chr);
+			gly = it->itemText.charStyle(e).font().glyphOutline(gl);
+			if (!it->itemText.charStyle(e).font().replacementName().isEmpty())
+				Really[it->itemText.charStyle(e).font().replacementName()].insert(gl, gly);
 		}
 	}
 }




More information about the scribus-commit mailing list