r16447 by jghali - #9839: Crash when copying text frame from old doc

scribus-commit scribus-commit at lists.scribus.net
Sun Mar 13 20:59:26 CET 2011


Author: jghali
Date: Sun Mar 13 19:59:26 2011
New Revision: 16447

URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=16447
Log:
#9839: Crash when copying text frame from old doc
Do not read attributes specific to named character styles when reading anonymous charstyles

Modified:
    branches/Version135/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
    branches/Version135/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.h

Modified: branches/Version135/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16447&path=/branches/Version135/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
==============================================================================
--- branches/Version135/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp (original)
+++ branches/Version135/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp Sun Mar 13 19:59:26 2011
@@ -1699,6 +1699,81 @@
 
 void Scribus134Format::GetCStyle(const QDomElement *it, ScribusDoc *doc, CharStyle & newStyle)
 {
+	if (it->hasAttribute("CPARENT"))
+		newStyle.setParent(it->attribute("CPARENT"));
+
+	if (it->hasAttribute("FONT"))
+		newStyle.setFont(m_AvailableFonts->findFont(it->attribute("FONT"),doc));
+	
+	if (it->hasAttribute("FONTSIZE"))
+		newStyle.setFontSize(qRound(ScCLocale::toDoubleC(it->attribute("FONTSIZE")) * 10));
+	
+	if (it->hasAttribute("FCOLOR"))
+		newStyle.setFillColor(it->attribute("FCOLOR"));
+	
+	if (it->hasAttribute("KERN"))
+		newStyle.setTracking(qRound(ScCLocale::toDoubleC(it->attribute("KERN")) * 10));
+	
+	if (it->hasAttribute("FSHADE"))
+		newStyle.setFillShade(it->attribute("FSHADE").toInt());
+	
+	if (it->hasAttribute("EFFECTS"))
+		newStyle.setFeatures(static_cast<StyleFlag>(it->attribute("EFFECTS").toInt()).featureList());
+	
+	if (it->hasAttribute("EFFECT"))
+		newStyle.setFeatures(static_cast<StyleFlag>(it->attribute("EFFECT").toInt()).featureList());
+	
+	if (it->hasAttribute("FEATURES"))
+		newStyle.setFeatures(it->attribute("FEATURES").split( " ", QString::SkipEmptyParts));
+	
+	if (it->hasAttribute("SCOLOR"))
+		newStyle.setStrokeColor(it->attribute("SCOLOR", CommonStrings::None));
+	
+	if (it->hasAttribute("SSHADE"))
+		newStyle.setStrokeShade(it->attribute("SSHADE").toInt());
+	
+	if (it->hasAttribute("SCALEH"))
+		newStyle.setScaleH(qRound(ScCLocale::toDoubleC(it->attribute("SCALEH")) * 10));
+	
+	if (it->hasAttribute("SCALEV"))
+		newStyle.setScaleV(qRound(ScCLocale::toDoubleC(it->attribute("SCALEV")) * 10));
+	
+	if (it->hasAttribute("BASEO"))
+		newStyle.setBaselineOffset(qRound(ScCLocale::toDoubleC(it->attribute("BASEO")) * 10));
+	
+	if (it->hasAttribute("TXTSHX"))
+		newStyle.setShadowXOffset(qRound(ScCLocale::toDoubleC(it->attribute("TXTSHX")) * 10));
+	
+	if (it->hasAttribute("TXTSHY"))
+		newStyle.setShadowYOffset(qRound(ScCLocale::toDoubleC(it->attribute("TXTSHY")) * 10));
+	
+	if (it->hasAttribute("TXTOUT"))
+		newStyle.setOutlineWidth(qRound(ScCLocale::toDoubleC(it->attribute("TXTOUT")) * 10));
+	
+	if (it->hasAttribute("TXTULP"))
+		newStyle.setUnderlineOffset(qRound(ScCLocale::toDoubleC(it->attribute("TXTULP")) * 10));
+	
+	if (it->hasAttribute("TXTULW"))
+		newStyle.setUnderlineWidth(qRound(ScCLocale::toDoubleC(it->attribute("TXTULW")) * 10));
+	
+	if (it->hasAttribute("TXTSTP"))
+		newStyle.setStrikethruOffset(qRound(ScCLocale::toDoubleC(it->attribute("TXTSTP")) * 10));
+	
+	if (it->hasAttribute("TXTSTW"))
+		newStyle.setStrikethruWidth(qRound(ScCLocale::toDoubleC(it->attribute("TXTSTW")) * 10));
+
+	if (it->hasAttribute("LANGUAGE"))
+		newStyle.setLanguage(it->attribute("LANGUAGE"));
+
+	if (it->hasAttribute("SHORTCUT"))
+		newStyle.setShortcut(it->attribute("SHORTCUT"));
+
+	if (it->hasAttribute("wordTrack"))
+		newStyle.setWordTracking(ScCLocale::toDoubleC(it->attribute("wordTrack")));
+}	
+
+void Scribus134Format::GetNamedCStyle(const QDomElement *it, ScribusDoc *doc, CharStyle & newStyle)
+{
 	if (it->hasAttribute("CNAME"))
 		newStyle.setName(it->attribute("CNAME"));
 	// The default style attribute must be correctly set before trying to assign a parent
@@ -1708,78 +1783,9 @@
 		newStyle.setDefaultStyle(true);
 	else
 		newStyle.setDefaultStyle(false);
-	if (it->hasAttribute("CPARENT"))
-		newStyle.setParent(it->attribute("CPARENT"));
-	if (it->hasAttribute("FONT"))
-		newStyle.setFont(m_AvailableFonts->findFont(it->attribute("FONT"),doc));
-	
-	if (it->hasAttribute("FONTSIZE"))
-		newStyle.setFontSize(qRound(ScCLocale::toDoubleC(it->attribute("FONTSIZE")) * 10));
-	
-	if (it->hasAttribute("FCOLOR"))
-		newStyle.setFillColor(it->attribute("FCOLOR"));
-	
-	if (it->hasAttribute("KERN"))
-		newStyle.setTracking(qRound(ScCLocale::toDoubleC(it->attribute("KERN")) * 10));
-	
-	if (it->hasAttribute("FSHADE"))
-		newStyle.setFillShade(it->attribute("FSHADE").toInt());
-	
-	if (it->hasAttribute("EFFECTS"))
-		newStyle.setFeatures(static_cast<StyleFlag>(it->attribute("EFFECTS").toInt()).featureList());
-	
-	if (it->hasAttribute("EFFECT"))
-		newStyle.setFeatures(static_cast<StyleFlag>(it->attribute("EFFECT").toInt()).featureList());
-	
-	if (it->hasAttribute("FEATURES"))
-		newStyle.setFeatures(it->attribute("FEATURES").split( " ", QString::SkipEmptyParts));
-	
-	if (it->hasAttribute("SCOLOR"))
-		newStyle.setStrokeColor(it->attribute("SCOLOR", CommonStrings::None));
-	
-	if (it->hasAttribute("SSHADE"))
-		newStyle.setStrokeShade(it->attribute("SSHADE").toInt());
-	
-	if (it->hasAttribute("SCALEH"))
-		newStyle.setScaleH(qRound(ScCLocale::toDoubleC(it->attribute("SCALEH")) * 10));
-	
-	if (it->hasAttribute("SCALEV"))
-		newStyle.setScaleV(qRound(ScCLocale::toDoubleC(it->attribute("SCALEV")) * 10));
-	
-	if (it->hasAttribute("BASEO"))
-		newStyle.setBaselineOffset(qRound(ScCLocale::toDoubleC(it->attribute("BASEO")) * 10));
-	
-	if (it->hasAttribute("TXTSHX"))
-		newStyle.setShadowXOffset(qRound(ScCLocale::toDoubleC(it->attribute("TXTSHX")) * 10));
-	
-	if (it->hasAttribute("TXTSHY"))
-		newStyle.setShadowYOffset(qRound(ScCLocale::toDoubleC(it->attribute("TXTSHY")) * 10));
-	
-	if (it->hasAttribute("TXTOUT"))
-		newStyle.setOutlineWidth(qRound(ScCLocale::toDoubleC(it->attribute("TXTOUT")) * 10));
-	
-	if (it->hasAttribute("TXTULP"))
-		newStyle.setUnderlineOffset(qRound(ScCLocale::toDoubleC(it->attribute("TXTULP")) * 10));
-	
-	if (it->hasAttribute("TXTULW"))
-		newStyle.setUnderlineWidth(qRound(ScCLocale::toDoubleC(it->attribute("TXTULW")) * 10));
-	
-	if (it->hasAttribute("TXTSTP"))
-		newStyle.setStrikethruOffset(qRound(ScCLocale::toDoubleC(it->attribute("TXTSTP")) * 10));
-	
-	if (it->hasAttribute("TXTSTW"))
-		newStyle.setStrikethruWidth(qRound(ScCLocale::toDoubleC(it->attribute("TXTSTW")) * 10));
-
-	if (it->hasAttribute("LANGUAGE"))
-		newStyle.setLanguage(it->attribute("LANGUAGE"));
-
-	if (it->hasAttribute("SHORTCUT"))
-		newStyle.setShortcut(it->attribute("SHORTCUT"));
-
-	if (it->hasAttribute("wordTrack"))
-		newStyle.setWordTracking(ScCLocale::toDoubleC(it->attribute("wordTrack")));
-
-}	
+
+	GetCStyle(it, doc, newStyle);
+}
 
 void Scribus134Format::GetItemText(QDomElement *it, ScribusDoc *doc, PageItem* obj, LastStyles* last, bool impo, bool VorLFound)
 {
@@ -3552,7 +3558,7 @@
 			if(pg.tagName()=="CHARSTYLE")
 			{
 				cstyle.erase();
-				GetCStyle(&pg, doc, cstyle);
+				GetNamedCStyle(&pg, doc, cstyle);
 				docCharStyles.create(cstyle);
 			}
 			PAGE=PAGE.nextSibling();

Modified: branches/Version135/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=16447&path=/branches/Version135/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.h
==============================================================================
--- branches/Version135/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.h (original)
+++ branches/Version135/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.h Sun Mar 13 19:59:26 2011
@@ -60,6 +60,7 @@
 		//Scribus Doc vars, not plugin vars
 		void GetItemText(QDomElement *it, ScribusDoc *doc, PageItem* obj, LastStyles* last, bool impo=false, bool VorLFound=false);
 		void GetCStyle(const QDomElement *it, ScribusDoc *doc, CharStyle & newStyle);
+		void GetNamedCStyle(const QDomElement *it, ScribusDoc *doc, CharStyle & newStyle);
 		void readParagraphStyle(ParagraphStyle& vg, const QDomElement& pg, SCFonts &avail, ScribusDoc *doc);
 		PageItem* PasteItem(QDomElement *obj, ScribusDoc *doc, const QString& baseDir, int pagenr = -2 /* currentPage*/);
 		void GetStyle(QDomElement *pg, ParagraphStyle *vg, StyleSet<ParagraphStyle> *docParagraphStyles, ScribusDoc* doc, bool fl);




More information about the scribus-commit mailing list