r22673 by jghali - #15419: small refactoring for scribusXml

scribus-commit scribus-commit at lists.scribus.net
Fri Sep 7 19:47:52 UTC 2018


Author: jghali
Date: Fri Sep  7 19:47:52 2018
New Revision: 22673

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22673
Log:
#15419: small refactoring for scribusXml

Modified:
    trunk/Scribus/scribus/scribusXml.cpp
    trunk/Scribus/scribus/scribusXml.h

Modified: trunk/Scribus/scribus/scribusXml.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22673&path=/trunk/Scribus/scribus/scribusXml.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusXml.cpp	(original)
+++ trunk/Scribus/scribus/scribusXml.cpp	Fri Sep  7 19:47:52 2018
@@ -160,14 +160,9 @@
 	PageItem *item;
 	QString documentStr = "";
 	item = selection->itemAt(0);
-	QList<PageItem*> emG;
-	QMap<int, PageItem*> emMap;
-	emG.clear();
-	for (int cor = 0; cor < selection->count(); ++cor)
-	{
-		emMap.insert(doc->Items->indexOf(selection->itemAt(cor)), selection->itemAt(cor));
-	}
-	emG = emMap.values();
+
+	auto items = getItemsFromSelection(doc, selection);
+
 	double selectionWidth = 0;
 	double selectionHeight = 0;
 	if (selection->isMultipleSelection())
@@ -198,9 +193,9 @@
 	retImg.fill( qRgba(0, 0, 0, 0) );
 	ScPainter *painter = new ScPainter(&retImg, retImg.width(), retImg.height(), 1, 0);
 	painter->setZoomFactor(scaleI);
-	for (int em = 0; em < emG.count(); ++em)
-	{
-		PageItem* embedded = emG.at(em);
+	for (int em = 0; em < items.count(); ++em)
+	{
+		PageItem* embedded = items.at(em);
 		painter->save();
 		painter->translate(-xp, -yp);
 		embedded->invalid = true;
@@ -234,3 +229,13 @@
 	md->setScribusElem(WriteElem(doc, selection));
 	return md;
 }
+
+QList<PageItem*> ScriXmlDoc::getItemsFromSelection(ScribusDoc *doc, Selection* selection)
+{
+	QMap<int, PageItem*> items;
+
+	const QList<PageItem*> selectedItems = selection->items();
+	for (auto item : selectedItems)
+		items.insert(doc->Items->indexOf(item), item);
+	return items.values();
+}

Modified: trunk/Scribus/scribus/scribusXml.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22673&path=/trunk/Scribus/scribus/scribusXml.h
==============================================================================
--- trunk/Scribus/scribus/scribusXml.h	(original)
+++ trunk/Scribus/scribus/scribusXml.h	Fri Sep  7 19:47:52 2018
@@ -53,9 +53,12 @@
 	
 	static QString WriteElem(ScribusDoc *doc, Selection *selection);
 	static ScElemMimeData* WriteToMimeData(ScribusDoc *doc, Selection *selection);
+
+private:
+	static QList<PageItem*> getItemsFromSelection(ScribusDoc *doc, Selection* selection);
 };
 
-#endif // _SCRIBUS_CONFIG_
+#endif
 
 
 




More information about the scribus-commit mailing list