r24689 by jghali - Make PageItem::itemName() return a const reference

scribus-commit scribus-commit at lists.scribus.net
Sun Aug 8 21:47:28 UTC 2021


Author: jghali
Date: Sun Aug  8 21:47:28 2021
New Revision: 24689

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24689
Log:
Make PageItem::itemName() return a const reference

Modified:
    trunk/Scribus/scribus/pageitem.h
    trunk/Scribus/scribus/pdflib_core.cpp
    trunk/Scribus/scribus/pslib.cpp

Modified: trunk/Scribus/scribus/pageitem.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24689&path=/trunk/Scribus/scribus/pageitem.h
==============================================================================
--- trunk/Scribus/scribus/pageitem.h	(original)
+++ trunk/Scribus/scribus/pageitem.h	Sun Aug  8 21:47:28 2021
@@ -802,7 +802,7 @@
 	 * of its Qt name.
 	 * See also PageItem::setItemName()
 	 */
-	QString itemName() const { return m_itemName; }
+	const QString& itemName() const { return m_itemName; }
 	/**
 	 * @brief Set name of the item
 	 * @param newName name for the item

Modified: trunk/Scribus/scribus/pdflib_core.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24689&path=/trunk/Scribus/scribus/pdflib_core.cpp
==============================================================================
--- trunk/Scribus/scribus/pdflib_core.cpp	(original)
+++ trunk/Scribus/scribus/pdflib_core.cpp	Sun Aug  8 21:47:28 2021
@@ -1366,6 +1366,13 @@
 static QByteArray sanitizeFontName(QString fn)
 {
 	return Pdf::toPdfDocEncoding(fn.replace( QRegExp("[\\s\\/\\{\\[\\]\\}\\<\\>\\(\\)\\%]"), "_"));
+}
+
+static QString sanitizeItemName(const QString& itemName)
+{
+	QString sanitizedName = itemName;
+	sanitizedName.replace(".", "_");
+	return sanitizedName;
 }
 
 static QList<Pdf::Resource> asColorSpace(const QList<PdfICCD>& iccCSlist)
@@ -4694,7 +4701,7 @@
 						if (ite->Parent == nullptr)
 							radioButtonGroup.groupName = "Page" + Pdf::toPdf(ActPageP->pageNr() + 1);
 						else
-							radioButtonGroup.groupName = Pdf::toPdfDocEncoding(ite->Parent->itemName().replace(".", "_"));
+							radioButtonGroup.groupName = Pdf::toPdfDocEncoding( sanitizeItemName(ite->Parent->itemName()) );
 						pageData.radioButtonGroups.insert(ite->Parent, radioButtonGroup);
 					}
 					PdfRadioButtonGroup& radioButtonGroup = pageData.radioButtonGroups[ite->Parent];
@@ -8796,10 +8803,10 @@
 	PutDoc("/3DD " + Pdf::toPdf(appearanceObj) + " 0 R\n");
 	PutDoc("/3DV " + Pdf::toPdf(viewObj) + " 0 R\n");
 	PutDoc("/3DA <<\n/A /PV\n/TB true\n/NP true\n>>\n");
-	QByteArray onState = Pdf::toName(ite->itemName().replace(".", "_"));
+	QByteArray onState = Pdf::toName( sanitizeItemName(ite->itemName()) );
 	PutDoc("/AS " + onState + "\n");
 	PutDoc("/AP << /N <<\n" + onState + " " + Pdf::toPdf(appearanceObj1) + " 0 R >> >>\n");
-	PutDoc("/Rect [ " + FToStr(x+bleedDisplacementX) + " " + FToStr(y2+bleedDisplacementY) + " " + FToStr(x2+bleedDisplacementX) + " " + FToStr(y+bleedDisplacementY) + " ]\n");
+	PutDoc("/Rect [ " + FToStr(x + bleedDisplacementX) + " " + FToStr(y2 + bleedDisplacementY) + " " + FToStr(x2 + bleedDisplacementX) + " " + FToStr(y + bleedDisplacementY) + " ]\n");
 	PutDoc(">>");
 	writer.endObj(annotationObj);
 	delete tempImageFile;
@@ -8840,7 +8847,7 @@
 		{
 			PageItem* radioKid = radioList[j];
 			if (radioKid->annotation().IsChk())
-				onState = Pdf::toName(radioKid->itemName().replace(".", "_"));
+				onState = Pdf::toName( sanitizeItemName(radioKid->itemName()) );
 		}
 		writer.startObj(parentObject);
 		pageData.AObjects.append(parentObject);
@@ -8936,7 +8943,7 @@
 		PutDoc("/R " + Pdf::toPdf(rot) + " ");
 	}
 	PutDoc(">>\n");
-	QByteArray onState = Pdf::toName(ite->itemName().replace(".", "_"));
+	QByteArray onState = Pdf::toName( sanitizeItemName(ite->itemName()) );
 	if (ite->annotation().IsChk())
 		PutDoc("/AS " + onState + "\n");
 	else
@@ -9046,7 +9053,7 @@
 			bmUtf16 += (cc == QChar(13) ? QChar(10) : cc);
 		}
 	}
-	QByteArray anTitle = Pdf::toPdfDocEncoding(ite->itemName().replace(".", "_"));
+	QByteArray anTitle = Pdf::toPdfDocEncoding( sanitizeItemName(ite->itemName()) );
 	QStringList bmstUtf16 = bmUtf16.split(QChar(10), Qt::SkipEmptyParts);
 	const QByteArray m[] = {"4", "5", "F", "l", "H", "n"};
 	QByteArray ct(m[ite->annotation().ChkStil()]);

Modified: trunk/Scribus/scribus/pslib.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24689&path=/trunk/Scribus/scribus/pslib.cpp
==============================================================================
--- trunk/Scribus/scribus/pslib.cpp	(original)
+++ trunk/Scribus/scribus/pslib.cpp	Sun Aug  8 21:47:28 2021
@@ -239,6 +239,13 @@
 		m_ps->PS_scale(scaleH(), scaleV());
 	m_ps->ProcessItem(m_page, item, m_argh, m_master, true);
 	m_ps->PS_restore();
+}
+
+static QString sanitizeItemName(const QString& itemName)
+{
+	QString sanitizedName = itemName;
+	sanitizedName.replace(".", "_");
+	return sanitizedName;
 }
 
 PSLib::PSLib(ScribusDoc* doc, PrintOptions &options, OutputFormat outputFmt, ColorList *docColors)
@@ -1549,7 +1556,7 @@
 	}
 	if ((item->annotation().Type() < 2) || (item->annotation().Type() > 9))
 		PutStream("/Border [ 0 0 0 ]\n");
-	PutStream("/Title (" + item->itemName().replace(".", "_" ) + ")\n");
+	PutStream("/Title (" + sanitizeItemName(item->itemName()) + ")\n");
 	PutStream("/ANN pdfmark\n");
 }
 




More information about the scribus-commit mailing list