r16052 by fschmid - Fixed issues when a patterns uses another pattern, esp. ensure right order of saving the patterns.

scribus-commit scribus-commit at lists.scribus.net
Sat Dec 4 00:16:46 CET 2010


Author: fschmid
Date: Fri Dec  3 23:16:46 2010
New Revision: 16052

URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=16052
Log:
Fixed issues when a patterns uses another pattern, esp. ensure right order of saving the patterns.

Modified:
    trunk/Scribus/scribus/pdflib_core.cpp
    trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
    trunk/Scribus/scribus/plugins/svgexplugin/svgexplugin.cpp
    trunk/Scribus/scribus/pslib.cpp
    trunk/Scribus/scribus/scribus.cpp
    trunk/Scribus/scribus/scribus.h
    trunk/Scribus/scribus/scribusXml.cpp
    trunk/Scribus/scribus/scribusdoc.cpp
    trunk/Scribus/scribus/scribusdoc.h
    trunk/Scribus/scribus/scribusview.cpp

Modified: trunk/Scribus/scribus/pdflib_core.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16052&path=/trunk/Scribus/scribus/pdflib_core.cpp
==============================================================================
--- trunk/Scribus/scribus/pdflib_core.cpp (original)
+++ trunk/Scribus/scribus/pdflib_core.cpp Fri Dec  3 23:16:46 2010
@@ -1016,7 +1016,7 @@
 	{
 		StdFonts.insert("/Helvetica", "");
 	} */
-	QStringList patterns = doc.getUsedPatterns();
+	QStringList patterns = doc.getPatternDependencyList(doc.getUsedPatterns());
 	for (int c = 0; c < patterns.count(); ++c)
 	{
 		ScPattern pa = doc.docPatterns[patterns[c]];

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format_save.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16052&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 Fri Dec  3 23:16:46 2010
@@ -913,12 +913,12 @@
 
 void Scribus150Format::writePatterns(ScXmlStreamWriter & docu, const QString& baseDir) 
 {
-	QMap<QString, ScPattern>::Iterator itPat;
-	for (itPat = m_Doc->docPatterns.begin(); itPat != m_Doc->docPatterns.end(); ++itPat)
+	QStringList patterns = m_Doc->getPatternDependencyList(m_Doc->docPatterns.keys());
+	for (int a = 0; a < patterns.count(); a++)
 	{
 		docu.writeStartElement("Pattern");
-		docu.writeAttribute("Name",itPat.key());
-		ScPattern pa = itPat.value();
+		docu.writeAttribute("Name", patterns[a]);
+		ScPattern pa = m_Doc->docPatterns[patterns[a]];
 		docu.writeAttribute("width", pa.width);
 		docu.writeAttribute("height", pa.height);
 		docu.writeAttribute("scaleX", pa.scaleX);

Modified: trunk/Scribus/scribus/plugins/svgexplugin/svgexplugin.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16052&path=/trunk/Scribus/scribus/plugins/svgexplugin/svgexplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/svgexplugin/svgexplugin.cpp (original)
+++ trunk/Scribus/scribus/plugins/svgexplugin/svgexplugin.cpp Fri Dec  3 23:16:46 2010
@@ -1945,7 +1945,7 @@
 
 void SVGExPlug::writeBasePatterns()
 {
-	QStringList patterns = m_Doc->getUsedPatterns();
+	QStringList patterns = m_Doc->getPatternDependencyList(m_Doc->getUsedPatterns());
 	for (int c = 0; c < patterns.count(); ++c)
 	{
 		QStack<PageItem*> groupStack;

Modified: trunk/Scribus/scribus/pslib.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16052&path=/trunk/Scribus/scribus/pslib.cpp
==============================================================================
--- trunk/Scribus/scribus/pslib.cpp (original)
+++ trunk/Scribus/scribus/pslib.cpp Fri Dec  3 23:16:46 2010
@@ -463,7 +463,7 @@
 		PutStream(GrayCalc);
 	Optimization optim = optimization;
 	optimization = OptimizeSize;
-	QStringList patterns = m_Doc->getUsedPatterns();
+	QStringList patterns = m_Doc->getPatternDependencyList(m_Doc->getUsedPatterns());
 	for (int c = 0; c < patterns.count(); ++c)
 	{
 		ScPattern pa = m_Doc->docPatterns[patterns[c]];

Modified: trunk/Scribus/scribus/scribus.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16052&path=/trunk/Scribus/scribus/scribus.cpp
==============================================================================
--- trunk/Scribus/scribus/scribus.cpp (original)
+++ trunk/Scribus/scribus/scribus.cpp Fri Dec  3 23:16:46 2010
@@ -8567,7 +8567,7 @@
 		scrActions["toolsPDFAnnot3D"]->setEnabled(false);
 #endif
 		pagePalette->enablePalette(false);
-		QStringList patterns2Del;
+		patternsDependingOnThis.clear();
 		QStringList mainPatterns = doc->docPatterns.keys();
 		for (int a = 0; a < mainPatterns.count(); a++)
 		{
@@ -8576,20 +8576,19 @@
 				QStringList subPatterns;
 				subPatterns = doc->getUsedPatternsHelper(mainPatterns[a], subPatterns);
 				if (subPatterns.contains(temp))
-					patterns2Del.append(mainPatterns[a]);
-			}
-		}
-		patterns2Del.append(temp);
-		symbolPalette->editingStart(patterns2Del);
-		propertiesPalette->Cpal->hideEditedPatterns(patterns2Del);
-		propertiesPalette->Tpal->hideEditedPatterns(patterns2Del);
+					patternsDependingOnThis.prepend(mainPatterns[a]);
+			}
+		}
+		patternsDependingOnThis.prepend(temp);
+		symbolPalette->editingStart(patternsDependingOnThis);
+		propertiesPalette->Cpal->hideEditedPatterns(patternsDependingOnThis);
+		propertiesPalette->Tpal->hideEditedPatterns(patternsDependingOnThis);
 		updateActiveWindowCaption( tr("Editing Symbol: %1").arg(temp));
 	}
 }
 
 void ScribusMainWindow::editSymbolEnd()
 {
-	view->setScale(storedViewScale);
 	view->hideSymbolPage();
 	slotSelect();
 	scrActions["editMasterPages"]->setEnabled(true);
@@ -8629,6 +8628,7 @@
 #endif
 	pagePalette->enablePalette(true);
 	pagePalette->rebuildMasters();
+	view->setScale(storedViewScale);
 	doc->setCurrentPage(doc->DocPages.at(storedPageNum));
 	view->setContentsPos(static_cast<int>(storedViewXCoor * storedViewScale), static_cast<int>(storedViewYCoor * storedViewScale));
 	view->DrawNew();

Modified: trunk/Scribus/scribus/scribus.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16052&path=/trunk/Scribus/scribus/scribus.h
==============================================================================
--- trunk/Scribus/scribus/scribus.h (original)
+++ trunk/Scribus/scribus/scribus.h Fri Dec  3 23:16:46 2010
@@ -252,6 +252,7 @@
 	ScMWMenuManager* scrMenuMgr;
 	ActionManager* actionManager;
 	QStringList RecentDocs;
+	QStringList patternsDependingOnThis;
 
 public slots:
 	void languageChange();

Modified: trunk/Scribus/scribus/scribusXml.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16052&path=/trunk/Scribus/scribus/scribusXml.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusXml.cpp (original)
+++ trunk/Scribus/scribus/scribusXml.cpp Fri Dec  3 23:16:46 2010
@@ -2450,7 +2450,7 @@
 			}
 		}
 	}
-	QStringList patterns = doc->getUsedPatternsSelection(selection);
+	QStringList patterns = doc->getPatternDependencyList(doc->getUsedPatternsSelection(selection));
 	for (int c = 0; c < patterns.count(); ++c)
 	{
 		ScPattern& pa = doc->docPatterns[patterns[c]];

Modified: trunk/Scribus/scribus/scribusdoc.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16052&path=/trunk/Scribus/scribus/scribusdoc.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.cpp (original)
+++ trunk/Scribus/scribus/scribusdoc.cpp Fri Dec  3 23:16:46 2010
@@ -2835,11 +2835,23 @@
 				results.append(FrameItems.at(c)->patternMask());
 		}
 	}
-	for (int c = 0; c < results.count(); ++c)
-	{
-		QStringList pats = getUsedPatternsHelper(results[c], results);
-		if (!pats.isEmpty())
-			results += pats;
+	for (QMap<QString, ScPattern>::Iterator it = docPatterns.begin(); it != docPatterns.end(); ++it)
+	{
+		for (int c = 0; c < it.value().items.count(); ++c)
+		{
+			if ((it.value().items.at(c)->GrType == 8) || (it.value().items.at(c)->itemType() == PageItem::Symbol))
+			{
+				const QString& patName = it.value().items.at(c)->pattern();
+				if (!patName.isEmpty() && !results.contains(patName))
+					results.append(patName);
+			}
+			const QString& pat2 = it.value().items.at(c)->strokePattern();
+			if (!pat2.isEmpty() && !results.contains(pat2))
+				results.append(pat2);
+			const QString& pat3 = it.value().items.at(c)->patternMask();
+			if (!pat3.isEmpty() && !results.contains(pat3))
+				results.append(pat3);
+		}
 	}
 	return results;
 }
@@ -2867,13 +2879,20 @@
 			if (!pat3.isEmpty() && !results.contains(pat3))
 				results.append(currItem->patternMask());
 		}
+		QStringList results2 = results;
 		for (int c = 0; c < results.count(); ++c)
 		{
-			QStringList pats = getUsedPatternsHelper(results[c], results);
+			QStringList pats = getUsedPatternsHelper(results[c], results2);
 			if (!pats.isEmpty())
-				results += pats;
-		}
-		return results;
+			{
+				for (int cc = 0; cc < pats.count(); cc++)
+				{
+					if (!results2.contains(pats[cc]))
+						results2.append(pats[cc]);
+				}
+			}
+		}
+		return results2;
 	}
 	else
 		return QStringList();
@@ -2881,6 +2900,8 @@
 
 QStringList ScribusDoc::getUsedPatternsHelper(QString pattern, QStringList &results)
 {
+	if (!docPatterns.contains(pattern))
+		return QStringList();
 	ScPattern *pat = &docPatterns[pattern];
 	QStringList pats;
 	pats.clear();
@@ -2901,11 +2922,54 @@
 	}
 	if (!pats.isEmpty())
 	{
-		results = pats;
+		results += pats;
 		for (int c = 0; c < pats.count(); ++c)
 		{
-			getUsedPatternsHelper(pats[c], results);
-		}
+			QStringList pp = getUsedPatternsHelper(pats[c], results);
+			if (!pp.isEmpty())
+			{
+				for (int cc = 0; cc < pp.count(); cc++)
+				{
+					if (!results.contains(pp[cc]))
+						results.append(pp[cc]);
+				}
+			}
+		}
+	}
+	return results;
+}
+
+QStringList ScribusDoc::getPatternDependencyList(QStringList used)
+{
+	QStringList results;
+	QStringList pp;
+	QStringList pats = used;
+	QStack<QStringList> patternStack;
+	patternStack.push(pats);
+	while (!pats.isEmpty())
+	{
+		for (int c = 0; c < pats.count(); ++c)
+		{
+			pp = getUsedPatternsHelper(pats[c], results);
+			if (!pp.isEmpty())
+				results += pp;
+		}
+		pats = results;
+		results.clear();
+		if (!pats.isEmpty())
+			patternStack.push(pats);
+	}
+	results.clear();
+	while (patternStack.count() != 0)
+	{
+		pp = patternStack.pop();
+		for (int c = 0; c < pp.count(); c++)
+		{
+			if (!results.contains(pp[c]))
+				results.append(pp[c]);
+		}
+		if (patternStack.count() == 0)
+			break;
 	}
 	return results;
 }
@@ -2945,11 +3009,18 @@
 				results.append(FrameItems.at(c)->strokePattern());
 		}
 	}
-	for (int c = 0; c < results.count(); ++c)
-	{
-		QStringList pats = getUsedSymbolsHelper(results[c], results);
-		if (!pats.isEmpty())
-			results += pats;
+	for (QMap<QString, ScPattern>::Iterator it = docPatterns.begin(); it != docPatterns.end(); ++it)
+	{
+		for (int c = 0; c < it.value().items.count(); ++c)
+		{
+			if ((!results.contains(it.value().items.at(c)->pattern())) && (it.value().items.at(c)->itemType() == PageItem::Symbol) && (!it.value().items.at(c)->pattern().isEmpty()))
+				results.append(it.value().items.at(c)->pattern());
+			if ((!it.value().items.at(c)->strokePattern().isEmpty()) && (it.value().items.at(c)->patternStrokePath))
+			{
+				if (!results.contains(it.value().items.at(c)->strokePattern()))
+					results.append(it.value().items.at(c)->strokePattern());
+			}
+		}
 	}
 	return results;
 }
@@ -5503,6 +5574,16 @@
 		docPatterns[currentEditedSymbol].pattern = currItem->DrawObj_toImage();
 		docPatterns[currentEditedSymbol].width = currItem->gWidth;
 		docPatterns[currentEditedSymbol].height = currItem->gHeight;
+		if (m_ScMW->patternsDependingOnThis.count() > 1)
+		{
+			for (int a = 1; a < m_ScMW->patternsDependingOnThis.count(); a++)
+			{
+				Items = &docPatterns[m_ScMW->patternsDependingOnThis[a]].items;
+				renumberItemsInListOrder();
+				currItem = Items->at(0);
+				docPatterns[m_ScMW->patternsDependingOnThis[a]].pattern = currItem->DrawObj_toImage();
+			}
+		}
 		if (masterPageMode())
 		{
 			Pages = &MasterPages;

Modified: trunk/Scribus/scribus/scribusdoc.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16052&path=/trunk/Scribus/scribus/scribusdoc.h
==============================================================================
--- trunk/Scribus/scribus/scribusdoc.h (original)
+++ trunk/Scribus/scribus/scribusdoc.h Fri Dec  3 23:16:46 2010
@@ -622,6 +622,7 @@
 	QStringList getUsedPatterns();
 	QStringList getUsedPatternsSelection(Selection* customSelection);
 	QStringList getUsedPatternsHelper(QString pattern, QStringList &results);
+	QStringList getPatternDependencyList(QStringList used);
 	/*!
 	* @brief Builds a QStringList of the symbols used within the document
 	*/

Modified: trunk/Scribus/scribus/scribusview.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16052&path=/trunk/Scribus/scribus/scribusview.cpp
==============================================================================
--- trunk/Scribus/scribus/scribusview.cpp (original)
+++ trunk/Scribus/scribus/scribusview.cpp Fri Dec  3 23:16:46 2010
@@ -2903,10 +2903,12 @@
 
 void ScribusView::hideSymbolPage()
 {
+	updatesOn(false);
 	Deselect(true);
 	if (Doc->symbolEditMode())
 		this->requestMode(modeNormal);
 	Doc->setSymbolEditMode(false);
+	updatesOn(true);
 	Doc->setCurrentPage(Doc->Pages->at(0));
 	pageSelector->setEnabled(true);
 	resizeContents(qRound((Doc->maxCanvasCoordinate.x() - Doc->minCanvasCoordinate.x()) * m_canvas->scale()), qRound((Doc->maxCanvasCoordinate.y() - Doc->minCanvasCoordinate.y()) * m_canvas->scale()));




More information about the scribus-commit mailing list