r17335 by jghali - #10595: Imported page, in some case, loses its text frame style

scribus-commit scribus-commit at lists.scribus.net
Sat Feb 25 12:47:48 UTC 2012


Author: jghali
Date: Sat Feb 25 12:47:48 2012
New Revision: 17335

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=17335
Log:
#10595: Imported page, in some case, loses its text frame style

Modified:
    trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
    trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.h
    trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
    trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.h

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17335&path=/trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp Sat Feb 25 12:47:48 2012
@@ -1262,6 +1262,8 @@
 	{
 		if (m_Doc->styleExists(parentStyle))
 			newStyle.setParent(parentStyle);
+		else if (parStyleMap.contains(parentStyle))
+			newStyle.setParent(parStyleMap.value(parentStyle));
 		else
 			newStyle.setParent(CommonStrings::DefaultParagraphStyle);
 	}
@@ -2294,7 +2296,7 @@
 	fixLegacyCharStyle(newStyle);
 	
 	if (impo && ab >= 0 && VorLFound)
-		last->ParaStyle = DoVorl[ab].toInt();
+		last->ParaStyle = legacyStyleMap[ab];
 	else
 		last->ParaStyle = pstylename;
 	// end of legacy stuff
@@ -3054,13 +3056,14 @@
 	itemNextM.clear();
 	itemCountM = 0;
 
-	DoVorl.clear();
-	DoVorl[0] = "0";
-	DoVorl[1] = "1";
-	DoVorl[2] = "2";
-	DoVorl[3] = "3";
-	DoVorl[4] = "4";
-	VorlC = 5;
+	parStyleMap.clear();
+	legacyStyleMap.clear();
+	legacyStyleMap[0] = "0";
+	legacyStyleMap[1] = "1";
+	legacyStyleMap[2] = "2";
+	legacyStyleMap[3] = "3";
+	legacyStyleMap[4] = "4";
+	legacyStyleCount = 5;
 
  	QString f(readSLA(fileName));
 	if (f.isEmpty())
@@ -3378,10 +3381,8 @@
 
 void Scribus134Format::getStyle(ParagraphStyle& style, ScXmlStreamReader& reader, StyleSet<ParagraphStyle> *tempStyles, ScribusDoc* doc, bool fl)
 {
-	bool fou(false);
-	QString tmpf, tmV;
+	bool  found(false);
 	const StyleSet<ParagraphStyle> * docParagraphStyles = tempStyles? tempStyles : & doc->paragraphStyles();
-//	PrefsManager* prefsManager = PrefsManager::instance();
 	readParagraphStyle(doc, reader, style);
 	for (int xx=0; xx<docParagraphStyles->count(); ++xx)
 	{
@@ -3391,37 +3392,35 @@
 			{
 				if (fl)
 				{
-					DoVorl[VorlC] = tmV.setNum(xx);
-					VorlC++;
+					legacyStyleMap[legacyStyleCount] = style.name();
+					legacyStyleCount++;
 				}
-				fou = true;
+				found = true;
 			}
 			else
 			{
 				style.setName("Copy of "+(*docParagraphStyles)[xx].name());
-				fou = false;
+				found = false;
 			}
 			break;
 		}
 	}
-	if (!fou)
-	{
-		for (int xx=0; xx< docParagraphStyles->count(); ++xx)
-		{
-			if (style.equiv((*docParagraphStyles)[xx]) && fl)
-			{
+	if (!found && fl)
+	{
+		for (int xx=0; xx < docParagraphStyles->count(); ++xx)
+		{
+			if (style.equiv((*docParagraphStyles)[xx]))
+			{
+				parStyleMap[style.name()] = (*docParagraphStyles)[xx].name();
 				style.setName((*docParagraphStyles)[xx].name());
-				fou = true;
-// 				if (fl)
-				{
-					DoVorl[VorlC] = tmV.setNum(xx);
-					VorlC++;
-				}
+				legacyStyleMap[legacyStyleCount] = style.name();
+				legacyStyleCount++;
+				found = true;
 				break;
 			}
 		}
 	}
-	if (!fou)
+	if (!found)
 	{
 		if (tempStyles)
 			tempStyles->create(style);
@@ -3433,8 +3432,8 @@
 		}
 		if (fl)
 		{
-			DoVorl[VorlC] = tmV.setNum(docParagraphStyles->count()-1);
-			VorlC++;
+			legacyStyleMap[legacyStyleCount] = style.name();
+			legacyStyleCount++;
 		}
 	}
 }

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17335&path=/trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.h
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.h (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.h Sat Feb 25 12:47:48 2012
@@ -113,34 +113,11 @@
 		bool readTableOfContents(ScribusDoc* doc, ScXmlStreamReader& reader);
 
 		PageItem* pasteItem(ScribusDoc *doc, ScXmlStreamAttributes& attrs, const QString& baseDir, int pagenr = -2 /* currentPage*/);
-/*
-		void writeCheckerProfiles(ScXmlStreamWriter& docu);
-		void writeLinestyles(ScXmlStreamWriter& docu);
-		void writeJavascripts(ScXmlStreamWriter& docu);
-		void writeBookmarks(ScXmlStreamWriter& docu);
-		void writeColors(ScXmlStreamWriter& docu);
-		void writeHyphenatorLists(ScXmlStreamWriter& docu);
-		void writePStyles(ScXmlStreamWriter& docu);
-		void writeCStyles(ScXmlStreamWriter& docu);
-		void putPStyle(ScXmlStreamWriter& docu, const ParagraphStyle & style, const QString &nodeName);
-		void putCStylePT(ScXmlStreamWriter& docu, const CharStyle & style);
-		void putCStyle(ScXmlStreamWriter& docu, const CharStyle & style);
-		void putNamedCStyle(ScXmlStreamWriter& docu, const CharStyle & style);
-		void writeITEXTs(ScribusDoc *doc, ScXmlStreamWriter&, PageItem* item);
-		void writeLayers(ScXmlStreamWriter& docu);
-		void writePrintOptions(ScXmlStreamWriter& docu);
-		void writePdfOptions(ScXmlStreamWriter& docu);
-		void writeDocItemAttributes(ScXmlStreamWriter& docu);
-		void writeTOC(ScXmlStreamWriter& docu);
-		void writePageSets(ScXmlStreamWriter& docu);
-		void writeSections(ScXmlStreamWriter& docu);
-		void writePatterns(ScXmlStreamWriter& docu, const QString& baseDir);
-		void writeContent(ScXmlStreamWriter& docu, const QString& baseDir);
-
-		void WritePages(ScribusDoc *doc, ScXmlStreamWriter& docu, QProgressBar *dia2, uint maxC, bool master);
-		void WriteObjects(ScribusDoc *doc, ScXmlStreamWriter& docu, const QString& baseDir, QProgressBar *dia2, uint maxC, ItemSelection master, QList<PageItem*> *items = 0);
-		void SetItemProps(ScXmlStreamWriter& docu, PageItem* item, const QString& baseDir, bool newFormat);
-*/
+		
+		QMap<QString, QString> parStyleMap;
+		QMap<uint, QString> legacyStyleMap;
+		uint legacyStyleCount;
+		
 		QMap<int, int> groupRemap;
 		QMap<int, int> itemRemap;
 		QMap<int, int> itemNext;
@@ -149,8 +126,6 @@
 
 		int itemCount;
 		int itemCountM;
-		QMap<uint,QString> DoVorl;
-		uint VorlC;
 };
 
 extern "C" PLUGIN_API int scribus134format_getPluginAPIVersion();

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17335&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 Sat Feb 25 12:47:48 2012
@@ -2377,6 +2377,8 @@
 	{
 		if (m_Doc->styleExists(parentStyle))
 			newStyle.setParent(parentStyle);
+		else if (parStyleMap.contains(parentStyle))
+			newStyle.setParent(parStyleMap.value(parentStyle));
 		else
 			newStyle.setParent(CommonStrings::DefaultParagraphStyle);
 	}
@@ -5091,6 +5093,8 @@
 		maxLevel = qMax(m_Doc->Layers[la2].Level, maxLevel);
 	}
 
+	parStyleMap.clear();
+
 	itemRemap.clear();
 	itemNext.clear();
 	itemCount = 0;
@@ -5579,8 +5583,7 @@
 
 void Scribus150Format::getStyle(ParagraphStyle& style, ScXmlStreamReader& reader, StyleSet<ParagraphStyle> *tempStyles, ScribusDoc* doc, bool fl)
 {
-	bool fou(false);
-	QString tmpf, tmV;
+	bool  found(false);
 	const StyleSet<ParagraphStyle> * docParagraphStyles = tempStyles? tempStyles : & doc->paragraphStyles();
 	//UNUSED: PrefsManager* prefsManager = PrefsManager::instance();
 	readParagraphStyle(doc, reader, style);
@@ -5590,29 +5593,30 @@
 		{
 			if (style.equiv((*docParagraphStyles)[xx]))
 			{
-				fou = true;
+				found = true;
 			}
 			else
 			{
 				style.setName("Copy of "+(*docParagraphStyles)[xx].name());
-				fou = false;
+				found = false;
 			}
 			break;
 		}
 	}
-	if (!fou && fl)
+	if (!found && fl)
 	{
 		for (int xx=0; xx< docParagraphStyles->count(); ++xx)
 		{
 			if (style.equiv((*docParagraphStyles)[xx]))
 			{
+				parStyleMap[style.name()] = (*docParagraphStyles)[xx].name();
 				style.setName((*docParagraphStyles)[xx].name());
-				fou = true;
+				found = true;
 				break;
 			}
 		}
 	}
-	if (!fou)
+	if (!found)
 	{
 		if (tempStyles)
 			tempStyles->create(style);

Modified: trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=17335&path=/trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.h
==============================================================================
--- trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.h (original)
+++ trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.h Sat Feb 25 12:47:48 2012
@@ -160,6 +160,8 @@
 		void WriteObjects(ScribusDoc *doc, ScXmlStreamWriter& docu, const QString& baseDir, QProgressBar *dia2, uint maxC, ItemSelection master, QList<PageItem*> *items = 0);
 		void SetItemProps(ScXmlStreamWriter& docu, PageItem* item, const QString& baseDir, bool newFormat);
 
+		QMap<QString, QString> parStyleMap;
+		
 		QMap<int, int> itemRemap;
 		QMap<int, int> itemNext;
 		QMap<int, int> itemRemapF;




More information about the scribus-commit mailing list