r16931 by fschmid - Better saving of weld item references.

scribus-commit scribus-commit at lists.scribus.net
Mon Oct 24 21:24:12 UTC 2011


Author: fschmid
Date: Mon Oct 24 21:24:12 2011
New Revision: 16931

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=16931
Log:
Better saving of weld item references.

Modified:
    trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
    trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16931&path=/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp Mon Oct 24 21:24:12 2011
@@ -192,12 +192,8 @@
 	QList<PageItem*> TableItems;
 	QList<PageItem*> TableItemsM;
 	QList<PageItem*> TableItemsF;
-	QMap<int,int> WeldID;
-	QMap<int,int> WeldIDM;
-	QMap<int,int> WeldIDF;
+	QMap<int,PageItem*> WeldID;
 	QList<PageItem*> WeldItems;
-	QList<PageItem*> WeldItemsM;
-	QList<PageItem*> WeldItemsF;
 	QStack< QList<PageItem*> > groupStack;
 	QStack< QList<PageItem*> > groupStackF;
 	QStack< QList<PageItem*> > groupStackM;
@@ -223,10 +219,6 @@
 	TableIDF.clear();
 	WeldItems.clear();
 	WeldID.clear();
-	WeldItemsM.clear();
-	WeldIDM.clear();
-	WeldItemsF.clear();
-	WeldIDF.clear();
 
 	bool firstElement = true;
 	bool success = true;
@@ -332,7 +324,7 @@
 				if (tagName == "ITEM")
 				{
 					WeldItems.append(itemInfo.item);
-					WeldID.insert(itemInfo.ownWeld, itemInfo.item->ItemNr);
+					WeldID.insert(itemInfo.ownWeld, itemInfo.item);
 				}
 			}
 			if (groupStack.count() > 0)
@@ -441,40 +433,13 @@
 	}
 	if (WeldItems.count() != 0)
 	{
-//		QList<PageItem*> docList = m_Doc->getAllItems(*m_Doc->Items);
 		for (int ttc = 0; ttc < WeldItems.count(); ++ttc)
 		{
 			PageItem* ta = WeldItems.at(ttc);
 			for (int i = 0 ; i < ta->weldList.count(); i++)
 			{
 				PageItem::weldingInfo wInf = ta->weldList.at(i);
-				ta->weldList[i].weldItem = m_Doc->Items->at(WeldID[wInf.weldID]);
-			}
-		}
-	}
-	if (WeldItemsM.count() != 0)
-	{
-//		QList<PageItem*> docList = m_Doc->getAllItems(m_Doc->MasterItems);
-		for (int ttc = 0; ttc < WeldItemsM.count(); ++ttc)
-		{
-			PageItem* ta = WeldItemsM.at(ttc);
-			for (int i = 0 ; i < ta->weldList.count(); i++)
-			{
-				PageItem::weldingInfo wInf = ta->weldList.at(i);
-				ta->weldList[i].weldItem = m_Doc->MasterItems.at(WeldIDM[wInf.weldID]);
-			}
-		}
-	}
-	if (WeldItemsF.count() != 0)
-	{
-//		QList<PageItem*> docList = m_Doc->getAllItems(m_Doc->FrameItems);
-		for (int ttc = 0; ttc < WeldItemsF.count(); ++ttc)
-		{
-			PageItem* ta = WeldItemsF.at(ttc);
-			for (int i = 0 ; i < ta->weldList.count(); i++)
-			{
-				PageItem::weldingInfo wInf = ta->weldList.at(i);
-				ta->weldList[i].weldItem = m_Doc->FrameItems.at(WeldIDF[wInf.weldID]);
+				ta->weldList[i].weldItem = WeldID[wInf.weldID];
 			}
 		}
 	}
@@ -595,12 +560,12 @@
 	QList<PageItem*> TableItems;
 	QList<PageItem*> TableItemsM;
 	QList<PageItem*> TableItemsF;
-	QMap<int,int> WeldID;
-	QMap<int,int> WeldIDM;
-	QMap<int,int> WeldIDF;
+	QMap<int,PageItem*> WeldID;
+//	QMap<int,PageItem*> WeldIDM;
+//	QMap<int,PageItem*> WeldIDF;
 	QList<PageItem*> WeldItems;
-	QList<PageItem*> WeldItemsM;
-	QList<PageItem*> WeldItemsF;
+//	QList<PageItem*> WeldItemsM;
+//	QList<PageItem*> WeldItemsF;
 	QStack< QList<PageItem*> > groupStack;
 	QStack< QList<PageItem*> > groupStackF;
 	QStack< QList<PageItem*> > groupStackM;
@@ -641,10 +606,10 @@
 	TableIDF.clear();
 	WeldItems.clear();
 	WeldID.clear();
-	WeldItemsM.clear();
-	WeldIDM.clear();
-	WeldItemsF.clear();
-	WeldIDF.clear();
+//	WeldItemsM.clear();
+//	WeldIDM.clear();
+//	WeldItemsF.clear();
+//	WeldIDF.clear();
 
 	m_Doc->GroupCounter = 1;
 	m_Doc->LastAuto = 0;
@@ -761,21 +726,8 @@
 			}
 			if (itemInfo.isWeldFlag)
 			{
-				if (tagName == "PAGEOBJECT")
-				{
-					WeldItems.append(itemInfo.item);
-					WeldID.insert(itemInfo.ownWeld, itemInfo.item->ItemNr);
-				}
-				else if (tagName == "FRAMEOBJECT")
-				{
-					WeldItemsF.append(itemInfo.item);
-					WeldIDF.insert(itemInfo.ownWeld, itemInfo.item->ItemNr);
-				}
-				else
-				{
-					WeldItemsM.append(itemInfo.item);
-					WeldIDM.insert(itemInfo.ownWeld, itemInfo.item->ItemNr);
-				}
+				WeldItems.append(itemInfo.item);
+				WeldID.insert(itemInfo.ownWeld, itemInfo.item);
 			}
 			if (groupStack.count() > 0)
 			{
@@ -884,40 +836,13 @@
 	}
 	if (WeldItems.count() != 0)
 	{
-	//	QList<PageItem*> docList = m_Doc->getAllItems(*m_Doc->Items);
 		for (int ttc = 0; ttc < WeldItems.count(); ++ttc)
 		{
 			PageItem* ta = WeldItems.at(ttc);
 			for (int i = 0 ; i < ta->weldList.count(); i++)
 			{
 				PageItem::weldingInfo wInf = ta->weldList.at(i);
-				ta->weldList[i].weldItem = m_Doc->Items->at(WeldID[wInf.weldID]);
-			}
-		}
-	}
-	if (WeldItemsM.count() != 0)
-	{
-	//	QList<PageItem*> docList = m_Doc->getAllItems(m_Doc->MasterItems);
-		for (int ttc = 0; ttc < WeldItemsM.count(); ++ttc)
-		{
-			PageItem* ta = WeldItemsM.at(ttc);
-			for (int i = 0 ; i < ta->weldList.count(); i++)
-			{
-				PageItem::weldingInfo wInf = ta->weldList.at(i);
-				ta->weldList[i].weldItem = m_Doc->MasterItems.at(WeldIDM[wInf.weldID]);
-			}
-		}
-	}
-	if (WeldItemsF.count() != 0)
-	{
-	//	QList<PageItem*> docList = m_Doc->getAllItems(m_Doc->FrameItems);
-		for (int ttc = 0; ttc < WeldItemsF.count(); ++ttc)
-		{
-			PageItem* ta = WeldItemsF.at(ttc);
-			for (int i = 0 ; i < ta->weldList.count(); i++)
-			{
-				PageItem::weldingInfo wInf = ta->weldList.at(i);
-				ta->weldList[i].weldItem = m_Doc->FrameItems.at(WeldIDF[wInf.weldID]);
+				ta->weldList[i].weldItem = WeldID[wInf.weldID];
 			}
 		}
 	}
@@ -1068,12 +993,8 @@
 	QList<PageItem*> TableItems;
 	QList<PageItem*> TableItemsM;
 	QList<PageItem*> TableItemsF;
-	QMap<int,int> WeldID;
-	QMap<int,int> WeldIDM;
-	QMap<int,int> WeldIDF;
+	QMap<int,PageItem*> WeldID;
 	QList<PageItem*> WeldItems;
-	QList<PageItem*> WeldItemsM;
-	QList<PageItem*> WeldItemsF;
 	QStack< QList<PageItem*> > groupStack;
 	QStack< QList<PageItem*> > groupStackF;
 	QStack< QList<PageItem*> > groupStackM;
@@ -1117,10 +1038,6 @@
 	TableIDF.clear();
 	WeldItems.clear();
 	WeldID.clear();
-	WeldItemsM.clear();
-	WeldIDM.clear();
-	WeldItemsF.clear();
-	WeldIDF.clear();
 
 	m_Doc->GroupCounter = 1;
 	m_Doc->LastAuto = 0;
@@ -1343,21 +1260,8 @@
 			}
 			if (itemInfo.isWeldFlag)
 			{
-				if (tagName == "PAGEOBJECT")
-				{
-					WeldItems.append(itemInfo.item);
-					WeldID.insert(itemInfo.ownWeld, itemInfo.item->ItemNr);
-				}
-				else if (tagName == "FRAMEOBJECT")
-				{
-					WeldItemsF.append(itemInfo.item);
-					WeldIDF.insert(itemInfo.ownWeld, itemInfo.item->ItemNr);
-				}
-				else
-				{
-					WeldItemsM.append(itemInfo.item);
-					WeldIDM.insert(itemInfo.ownWeld, itemInfo.item->ItemNr);
-				}
+				WeldItems.append(itemInfo.item);
+				WeldID.insert(itemInfo.ownWeld, itemInfo.item);
 			}
 			if (groupStack.count() > 0)
 			{
@@ -1480,40 +1384,13 @@
 	}
 	if (WeldItems.count() != 0)
 	{
-	//	QList<PageItem*> docList = m_Doc->getAllItems(*m_Doc->Items);
 		for (int ttc = 0; ttc < WeldItems.count(); ++ttc)
 		{
 			PageItem* ta = WeldItems.at(ttc);
 			for (int i = 0 ; i < ta->weldList.count(); i++)
 			{
 				PageItem::weldingInfo wInf = ta->weldList.at(i);
-				ta->weldList[i].weldItem = m_Doc->Items->at(WeldID[wInf.weldID]);
-			}
-		}
-	}
-	if (WeldItemsM.count() != 0)
-	{
-	//	QList<PageItem*> docList = m_Doc->getAllItems(m_Doc->MasterItems);
-		for (int ttc = 0; ttc < WeldItemsM.count(); ++ttc)
-		{
-			PageItem* ta = WeldItemsM.at(ttc);
-			for (int i = 0 ; i < ta->weldList.count(); i++)
-			{
-				PageItem::weldingInfo wInf = ta->weldList.at(i);
-				ta->weldList[i].weldItem = m_Doc->MasterItems.at(WeldIDM[wInf.weldID]);
-			}
-		}
-	}
-	if (WeldItemsF.count() != 0)
-	{
-	//	QList<PageItem*> docList = m_Doc->getAllItems(m_Doc->FrameItems);
-		for (int ttc = 0; ttc < WeldItemsF.count(); ++ttc)
-		{
-			PageItem* ta = WeldItemsF.at(ttc);
-			for (int i = 0 ; i < ta->weldList.count(); i++)
-			{
-				PageItem::weldingInfo wInf = ta->weldList.at(i);
-				ta->weldList[i].weldItem = m_Doc->FrameItems.at(WeldIDF[wInf.weldID]);
+				ta->weldList[i].weldItem = WeldID[wInf.weldID];
 			}
 		}
 	}
@@ -3204,7 +3081,7 @@
 	QStack<int> groupStack2;
 	QMap<int,int> TableID2;
 	QList<PageItem*> TableItems2;
-	QMap<int,int> WeldID;
+	QMap<int,PageItem*> WeldID;
 	QList<PageItem*> WeldItems;
 
 	pat.setDoc(doc);
@@ -3251,7 +3128,7 @@
 		if (itemInfo.isWeldFlag)
 		{
 			WeldItems.append(itemInfo.item);
-			WeldID.insert(itemInfo.ownWeld, itemInfo.item->ItemNr);
+			WeldID.insert(itemInfo.ownWeld, itemInfo.item);
 		}
 		if (groupStack.count() > 0)
 		{
@@ -3304,14 +3181,13 @@
 	}
 	if (WeldItems.count() != 0)
 	{
-	//	QList<PageItem*> docList = m_Doc->getAllItems(*m_Doc->Items);
 		for (int ttc = 0; ttc < WeldItems.count(); ++ttc)
 		{
 			PageItem* ta = WeldItems.at(ttc);
 			for (int i = 0 ; i < ta->weldList.count(); i++)
 			{
 				PageItem::weldingInfo wInf = ta->weldList.at(i);
-				ta->weldList[i].weldItem = m_Doc->Items->at(WeldID[wInf.weldID]);
+				ta->weldList[i].weldItem = WeldID[wInf.weldID];
 			}
 		}
 	}
@@ -4337,7 +4213,7 @@
 	QString tmp;
 	QMap<int,int> TableID;
 	QList<PageItem*> TableItems;
-	QMap<int,int> WeldID;
+	QMap<int,PageItem*> WeldID;
 	QList<PageItem*> WeldItems;
 	QStack< QList<PageItem*> > groupStack;
 	QStack< QList<PageItem*> > groupStackF;
@@ -4576,7 +4452,7 @@
 				if (itemInfo.isWeldFlag)
 				{
 					WeldItems.append(itemInfo.item);
-					WeldID.insert(itemInfo.ownWeld, itemInfo.item->ItemNr);
+					WeldID.insert(itemInfo.ownWeld, itemInfo.item);
 				}
 				if (tagName == "FRAMEOBJECT")
 				{
@@ -4660,7 +4536,7 @@
 			for (int i = 0 ; i < ta->weldList.count(); i++)
 			{
 				PageItem::weldingInfo wInf = ta->weldList.at(i);
-				ta->weldList[i].weldItem = m_Doc->Items->at(WeldID[wInf.weldID]);
+				ta->weldList[i].weldItem = WeldID[wInf.weldID];
 			}
 		}
 	}

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=16931&path=/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp Mon Oct 24 21:24:12 2011
@@ -1864,12 +1864,12 @@
 		if (item->isWelded())
 		{
 			docu.writeAttribute("isWeldItem", 1);
-			docu.writeAttribute("WeldSource", item->ItemNr);
+			docu.writeAttribute("WeldSource", item->uniqueNr);
 			for (int i = 0 ; i <  item->weldList.count(); i++)
 			{
 				PageItem::weldingInfo wInf = item->weldList.at(i);
 				docu.writeEmptyElement("WeldEntry");
-				docu.writeAttribute("Target", wInf.weldItem->ItemNr);
+				docu.writeAttribute("Target", wInf.weldItem->uniqueNr);
 				docu.writeAttribute("WX", wInf.weldPoint.x());
 				docu.writeAttribute("WY", wInf.weldPoint.y());
 			}




More information about the scribus-commit mailing list