r14587 by fschmid - XAR and PICT Importers: remove created colors and patterns when import fails.

scribus-commit scribus-commit at lists.scribus.net
Mon Feb 1 07:40:54 CET 2010


Revision: 14587
Author: fschmid
Date: 2010-01-28T11:32:56.109542Z
Commit message: XAR and PICT Importers: remove created colors and patterns when import fails.

Changeset: 
M  /trunk/Scribus/scribus/plugins/import/xar/importxar.cpp
M  /trunk/Scribus/scribus/plugins/import/xar/importxar.h
M  /trunk/Scribus/scribus/plugins/import/pct/importpct.cpp
M  /trunk/Scribus/scribus/plugins/import/pct/importpct.h

Diffs:
Index: scribus/plugins/import/pct/importpct.cpp
===================================================================
--- scribus/plugins/import/pct/importpct.cpp	(revision 14586)
+++ scribus/plugins/import/pct/importpct.cpp	(revision 14587)
@@ -259,6 +259,20 @@
 				delete ss;
 				m_Doc->itemSelection_DeleteItem(tmpSel);
 				m_Doc->view()->updatesOn(true);
+				if (importedColors.count() != 0)
+				{
+					for (int cd = 0; cd < importedColors.count(); cd++)
+					{
+						m_Doc->PageColors.remove(importedColors[cd]);
+					}
+				}
+				if (importedPatterns.count() != 0)
+				{
+					for (int cd = 0; cd < importedPatterns.count(); cd++)
+					{
+						m_Doc->docPatterns.remove(importedPatterns[cd]);
+					}
+				}
 				m_Doc->m_Selection->delaySignalsOff();
 				// We must copy the TransationSettings object as it is owned
 				// by handleObjectImport method afterwards
@@ -345,6 +359,7 @@
 	postscriptMode = false;
 	textIsPostScript = false;
 	importedColors.clear();
+	importedPatterns.clear();
 	QList<PageItem*> gElements;
 	groupStack.push(gElements);
 	currentItemNr = 0;
@@ -411,6 +426,13 @@
 					m_Doc->PageColors.remove(importedColors[cd]);
 				}
 			}
+			if (importedPatterns.count() != 0)
+			{
+				for (int cd = 0; cd < importedPatterns.count(); cd++)
+				{
+					m_Doc->docPatterns.remove(importedPatterns[cd]);
+				}
+			}
 		}
 		f.close();
 	}
@@ -2117,6 +2139,7 @@
 		patternName = "Pattern_"+newItem->itemName();
 		patternName = patternName.trimmed().simplified().replace(" ", "_");
 		m_Doc->addPattern(patternName, pat);
+		importedPatterns.append(patternName);
 		patternMap.insert(patNa, patternName);
 	}
 	else
Index: scribus/plugins/import/pct/importpct.h
===================================================================
--- scribus/plugins/import/pct/importpct.h	(revision 14586)
+++ scribus/plugins/import/pct/importpct.h	(revision 14587)
@@ -113,6 +113,7 @@
 	int currRectType;
 	QRect lastImageRect;
 	QStringList importedColors;
+	QStringList importedPatterns;
 	QPoint ovalSize;
 	QMap<int, QString> fontMap;
 	int currentTextSize;
Index: scribus/plugins/import/xar/importxar.cpp
===================================================================
--- scribus/plugins/import/xar/importxar.cpp	(revision 14586)
+++ scribus/plugins/import/xar/importxar.cpp	(revision 14587)
@@ -264,6 +264,20 @@
 				delete ss;
 				m_Doc->itemSelection_DeleteItem(tmpSel);
 				m_Doc->view()->updatesOn(true);
+				if (importedColors.count() != 0)
+				{
+					for (int cd = 0; cd < importedColors.count(); cd++)
+					{
+						m_Doc->PageColors.remove(importedColors[cd]);
+					}
+				}
+				if (importedPatterns.count() != 0)
+				{
+					for (int cd = 0; cd < importedPatterns.count(); cd++)
+					{
+						m_Doc->docPatterns.remove(importedPatterns[cd]);
+					}
+				}
 				m_Doc->m_Selection->delaySignalsOff();
 				// We must copy the TransationSettings object as it is owned
 				// by handleObjectImport method afterwards
@@ -332,6 +346,7 @@
 	Coords.svgInit();
 	imageData.resize(0);
 	importedColors.clear();
+	importedPatterns.clear();
 	firstLayer = true;
 	inTextLine = false;
 	inTextBlock = false;
@@ -435,6 +450,13 @@
 					m_Doc->PageColors.remove(importedColors[cd]);
 				}
 			}
+			if (importedPatterns.count() != 0)
+			{
+				for (int cd = 0; cd < importedPatterns.count(); cd++)
+				{
+					m_Doc->docPatterns.remove(importedPatterns[cd]);
+				}
+			}
 		}
 		f.close();
 	}
@@ -1676,6 +1698,7 @@
 		QString patternName = patternRef[bref]+"_"+newItem->itemName();
 		patternName = patternName.trimmed().simplified().replace(" ", "_");
 		m_Doc->addPattern(patternName, pat);
+		importedPatterns.append(patternName);
 		gc->maskPattern = patternName;
 		gc->patternMaskScaleX = distX / pat.width * 100;
 		gc->patternMaskScaleY = distY / pat.height * 100;
@@ -2259,6 +2282,7 @@
 		QString patternName = patternRef[bref]+"_"+newItem->itemName();
 		patternName = patternName.trimmed().simplified().replace(" ", "_");
 		m_Doc->addPattern(patternName, pat);
+		importedPatterns.append(patternName);
 		gc->fillPattern = patternName;
 		gc->patternScaleX = distX / pat.width * 100;
 		gc->patternScaleY = distY / pat.height * 100;
@@ -2408,6 +2432,7 @@
 		QString patternName = "Pattern_"+newItem->itemName();
 		patternName = patternName.trimmed().simplified().replace(" ", "_");
 		m_Doc->addPattern(patternName, pat);
+		importedPatterns.append(patternName);
 		patternRef.insert(recordCounter, patternName);
 	}
 }
@@ -3210,6 +3235,7 @@
 					QString patternName = "Pattern_"+groupItem->itemName();
 					patternName = patternName.trimmed().simplified().replace(" ", "_");
 					m_Doc->addPattern(patternName, pat);
+					importedPatterns.append(patternName);
 					m_Doc->DoDrawing = false;
 					brushRef.insert(gg.idNr, patternName);
 				}
Index: scribus/plugins/import/xar/importxar.h
===================================================================
--- scribus/plugins/import/xar/importxar.h	(revision 14586)
+++ scribus/plugins/import/xar/importxar.h	(revision 14587)
@@ -402,6 +402,7 @@
 	QStack<XarStyle*>	m_gc;
 	QString activeLayer;
 	QStringList importedColors;
+	QStringList importedPatterns;
 	FPointArray clipCoords;
 	FPointArray Coords;
 	FPointArray textPath;




More information about the scribus-commit mailing list