r13785 by jghali - #8220 (second round) : make two-byte conversion happening much less often on file load - adapt patch to 134/135 file loader - slight modification to 150 file loader - reduce CharStyle::runFeatures() code by a few lines

scribus-commit scribus-commit at lists.scribus.net
Tue Jul 21 00:45:25 CEST 2009


Revision: 13785
Author: jghali
Date: 2009-07-20T22:43:11.348796Z
Commit message: #8220 (second round) : make two-byte conversion happening much less often on file load
- adapt patch to 134/135 file loader
- slight modification to 150 file loader
- reduce CharStyle::runFeatures() code by a few lines 

Changeset: 
M  /trunk/Scribus/scribus/plugins/fileloader/scribus150format/scribus150format.cpp
M  /trunk/Scribus/scribus/plugins/fileloader/scribus134format/scribus134format.cpp
M  /trunk/Scribus/scribus/styles/charstyle.cpp

Diffs:
Index: scribus/styles/charstyle.cpp
===================================================================
--- scribus/styles/charstyle.cpp	(revision 13784)
+++ scribus/styles/charstyle.cpp	(revision 13785)
@@ -287,106 +287,71 @@
 		{
 			if (parent)
 				runFeatures(parent->features(), dynamic_cast<const CharStyle*>(parent->parentStyle()));
+			continue;
 		}
-		else if (feature == BOLD)
+		int set = feature.startsWith('-') ? 0 : 1;
+		int invert = 1 - set;
+		if (invert)
+			feature = feature.mid(1);
+
+		if (feature == BOLD)
 		{
-			// select bolder font
+			// (de)select bolder font
 		}
 		else if (feature == ITALIC)
 		{
-			// select italic font
+			// (de)select italic font
 		}
 		else if (feature == UNDERLINE)
 		{
-			m_Effects |= ScStyle_Underline;
+			m_Effects &= ~(invert * ScStyle_Underline);
+			m_Effects |= set * ScStyle_Underline;
 		}
 		else if (feature == UNDERLINEWORDS)
 		{
-			m_Effects |= ScStyle_UnderlineWords;
+			m_Effects &= ~(invert * ScStyle_UnderlineWords);
+			m_Effects |= set * ScStyle_UnderlineWords;
 		}
 		else if (feature == STRIKETHROUGH)
 		{
-			m_Effects |= ScStyle_Strikethrough;
+			m_Effects &= ~(invert * ScStyle_Strikethrough);
+			m_Effects |= set * ScStyle_Strikethrough;
 		}
 		else if (feature == SUPERSCRIPT)
 		{
-			m_Effects |= ScStyle_Superscript;
+			m_Effects &= ~(invert * ScStyle_Superscript);
+			m_Effects |= set * ScStyle_Superscript;
 		}
 		else if (feature == SUBSCRIPT)
 		{
-			m_Effects |= ScStyle_Subscript;
+			m_Effects &= ~(invert * ScStyle_Subscript);
+			m_Effects |= set * ScStyle_Subscript;
 		}
 		else if (feature == OUTLINE)
 		{
-			m_Effects |= ScStyle_Outline;
+			m_Effects &= ~(invert * ScStyle_Outline);
+			m_Effects |= set * ScStyle_Outline;
 		}
 		else if (feature == SHADOWED)
 		{
-			m_Effects |= ScStyle_Shadowed;
+			m_Effects &= ~(invert * ScStyle_Shadowed);
+			m_Effects |= set * ScStyle_Shadowed;
 		}
 		else if (feature == ALLCAPS)
 		{
-			m_Effects |= ScStyle_AllCaps;
+			m_Effects &= ~(invert * ScStyle_AllCaps);
+			m_Effects |= set * ScStyle_AllCaps;
 		}
 		else if (feature == SMALLCAPS)
 		{
-			m_Effects |= ScStyle_SmallCaps;
+			m_Effects &= ~(invert * ScStyle_SmallCaps);
+			m_Effects |= set * ScStyle_SmallCaps;
 		}
 		else if (feature == SHYPHEN)
 		{
-			m_Effects |= ScStyle_HyphenationPossible;
+			m_Effects &= ~(invert * ScStyle_HyphenationPossible);
+			m_Effects |= set * ScStyle_HyphenationPossible;
 		}
-		else if (feature.startsWith("-"))
-		{
-			QString no_feature = feature.mid(1);
-			if (no_feature == BOLD)
-			{
-				// deselect bolder font
-			}
-			else if (no_feature == ITALIC)
-			{
-				// deselect italic font
-			}
-			else if (no_feature == UNDERLINE)
-			{
-				m_Effects &= ~ScStyle_Underline;
-			}
-			else if (no_feature == UNDERLINEWORDS)
-			{
-				m_Effects &= ~ScStyle_UnderlineWords;
-			}
-			else if (no_feature == STRIKETHROUGH)
-			{
-				m_Effects &= ~ScStyle_Strikethrough;
-			}
-			else if (no_feature == SUPERSCRIPT)
-			{
-				m_Effects &= ~ScStyle_Superscript;
-			}
-			else if (no_feature == SUBSCRIPT)
-			{
-				m_Effects &= ~ScStyle_Subscript;
-			}
-			else if (no_feature == OUTLINE)
-			{
-				m_Effects &= ~ScStyle_Outline;
-			}
-			else if (no_feature == SHADOWED)
-			{
-				m_Effects &= ~ScStyle_Shadowed;
-			}
-			else if (no_feature == ALLCAPS)
-			{
-				m_Effects &= ~ScStyle_AllCaps;
-			}
-			else if (no_feature == SMALLCAPS)
-			{
-				m_Effects &= ~ScStyle_SmallCaps;
-			}
-			else {
-				qDebug("CharStyle: unknown feature: %s", feature.toLocal8Bit().constData());
-			}
-		}
 		else {
 			qDebug("CharStyle: unknown feature: %s", feature.toLocal8Bit().constData());
 		}
@@ -531,3 +496,5 @@
 #include "charstyle.attrdefs.cxx"
 #undef ATTRDEF		
 }
+
+//kate: replace-tabs 0;
Index: scribus/plugins/fileloader/scribus150format/scribus150format.cpp
===================================================================
--- scribus/plugins/fileloader/scribus150format/scribus150format.cpp	(revision 13784)
+++ scribus/plugins/fileloader/scribus150format/scribus150format.cpp	(revision 13785)
@@ -1007,11 +1007,14 @@
 
 void Scribus150Format::readCharacterStyleAttrs(ScribusDoc *doc, ScXmlStreamAttributes& attrs, CharStyle & newStyle)
 {
-	if (attrs.hasAttribute("CNAME"))
-		newStyle.setName(attrs.valueAsString("CNAME"));
+	static const QString CNAME("CNAME");
+	if (attrs.hasAttribute(CNAME))
+		newStyle.setName(attrs.valueAsString(CNAME));
+
 	// The default style attribute must be correctly set before trying to assign a parent
-	if (newStyle.hasName() && attrs.hasAttribute("DefaultStyle"))
-		newStyle.setDefaultStyle(attrs.valueAsInt("DefaultStyle"));
+	static const QString DEFAULTSTYLE("DefaultStyle");
+	if (newStyle.hasName() && attrs.hasAttribute(DEFAULTSTYLE))
+		newStyle.setDefaultStyle(attrs.valueAsInt(DEFAULTSTYLE));
 	else if (newStyle.name() == CommonStrings::DefaultCharacterStyle || newStyle.name() == CommonStrings::trDefaultCharacterStyle)
 		newStyle.setDefaultStyle(true);
 	else
@@ -1117,8 +1120,9 @@
 	newStyle.erase();
 	newStyle.setName(attrs.valueAsString("NAME", ""));
 	// The default style attribute must be correctly set before trying to assign a parent
-	if (attrs.hasAttribute("DefaultStyle"))
-		newStyle.setDefaultStyle(attrs.valueAsInt("DefaultStyle"));
+	static const QString DEFAULTSTYLE("DefaultStyle");
+	if (attrs.hasAttribute(DEFAULTSTYLE))
+		newStyle.setDefaultStyle(attrs.valueAsInt(DEFAULTSTYLE));
 	else if (newStyle.name() == CommonStrings::DefaultParagraphStyle || newStyle.name() == CommonStrings::trDefaultParagraphStyle)
 		newStyle.setDefaultStyle(true);
 	else
@@ -1983,7 +1987,7 @@
 	
 	readCharacterStyleAttrs(doc, attrs, newStyle);
 
-	if (attrs.hasAttribute("Unicode"))
+	if (attrs.hasAttribute(QLatin1String("Unicode")))
 	{
 		tmp2 = QChar(attrs.valueAsInt("Unicode"));
 	}
Index: scribus/plugins/fileloader/scribus134format/scribus134format.cpp
===================================================================
--- scribus/plugins/fileloader/scribus134format/scribus134format.cpp	(revision 13784)
+++ scribus/plugins/fileloader/scribus134format/scribus134format.cpp	(revision 13785)
@@ -1009,82 +1009,110 @@
 
 void Scribus134Format::readCharacterStyleAttrs(ScribusDoc *doc, ScXmlStreamAttributes& attrs, CharStyle & newStyle)
 {
-	if (attrs.hasAttribute("CNAME"))
-		newStyle.setName(attrs.valueAsString("CNAME"));
+	static const QString CNAME("CNAME");
+	if (attrs.hasAttribute(CNAME))
+		newStyle.setName(attrs.valueAsString(CNAME));
+
 	// The default style attribute must be correctly set before trying to assign a parent
-	if (newStyle.hasName() && attrs.hasAttribute("DefaultStyle"))
-		newStyle.setDefaultStyle(attrs.valueAsInt("DefaultStyle"));
+	static const QString DEFAULTSTYLE("DefaultStyle");
+	if (newStyle.hasName() && attrs.hasAttribute(DEFAULTSTYLE))
+		newStyle.setDefaultStyle(attrs.valueAsInt(DEFAULTSTYLE));
 	else if (newStyle.name() == CommonStrings::DefaultCharacterStyle || newStyle.name() == CommonStrings::trDefaultCharacterStyle)
 		newStyle.setDefaultStyle(true);
 	else
 		newStyle.setDefaultStyle(false);
-	if (attrs.hasAttribute("CPARENT"))
-		newStyle.setParent(attrs.valueAsString("CPARENT"));
-	if (attrs.hasAttribute("FONT"))
-		newStyle.setFont(m_AvailableFonts->findFont(attrs.valueAsString("FONT"), doc));
+
+	static const QString CPARENT("CPARENT");
+	if (attrs.hasAttribute(CPARENT))
+		newStyle.setParent(attrs.valueAsString(CPARENT));
+
+	static const QString FONT("FONT");
+	if (attrs.hasAttribute(FONT))
+		newStyle.setFont(m_AvailableFonts->findFont(attrs.valueAsString(FONT), doc));
 	
-	if (attrs.hasAttribute("FONTSIZE"))
-		newStyle.setFontSize(qRound(attrs.valueAsDouble("FONTSIZE") * 10));
+	static const QString FONTSIZE("FONTSIZE");
+	if (attrs.hasAttribute(FONTSIZE))
+		newStyle.setFontSize(qRound(attrs.valueAsDouble(FONTSIZE) * 10));
 	
-	if (attrs.hasAttribute("FCOLOR"))
-		newStyle.setFillColor(attrs.valueAsString("FCOLOR"));
+	static const QString FCOLOR("FCOLOR");
+	if (attrs.hasAttribute(FCOLOR))
+		newStyle.setFillColor(attrs.valueAsString(FCOLOR));
 	
-	if (attrs.hasAttribute("KERN"))
-		newStyle.setTracking(qRound(attrs.valueAsDouble("KERN") * 10));
+	static const QString KERN("KERN");
+	if (attrs.hasAttribute(KERN))
+		newStyle.setTracking(qRound(attrs.valueAsDouble(KERN) * 10));
 	
-	if (attrs.hasAttribute("FSHADE"))
-		newStyle.setFillShade(attrs.valueAsInt("FSHADE"));
+	static const QString FSHADE("FSHADE");
+	if (attrs.hasAttribute(FSHADE))
+		newStyle.setFillShade(attrs.valueAsInt(FSHADE));
 	
-	if (attrs.hasAttribute("EFFECTS"))
-		newStyle.setFeatures(static_cast<StyleFlag>(attrs.valueAsInt("EFFECTS")).featureList());
+	static const QString EFFECTS("EFFECTS");
+	if (attrs.hasAttribute(EFFECTS))
+		newStyle.setFeatures(static_cast<StyleFlag>(attrs.valueAsInt(EFFECTS)).featureList());
 	
-	if (attrs.hasAttribute("EFFECT"))
-		newStyle.setFeatures(static_cast<StyleFlag>(attrs.valueAsInt("EFFECT")).featureList());
+	static const QString EFFECT("EFFECT");
+	if (attrs.hasAttribute(EFFECT))
+		newStyle.setFeatures(static_cast<StyleFlag>(attrs.valueAsInt(EFFECT)).featureList());
 	
-	if (attrs.hasAttribute("FEATURES"))
-		newStyle.setFeatures(attrs.valueAsString("FEATURES").split( " ", QString::SkipEmptyParts));
+	static const QString FEATURES("FEATURES");
+	if (attrs.hasAttribute(FEATURES))
+		newStyle.setFeatures(attrs.valueAsString(FEATURES).split( " ", QString::SkipEmptyParts));
 	
-	if (attrs.hasAttribute("SCOLOR"))
-		newStyle.setStrokeColor(attrs.valueAsString("SCOLOR", CommonStrings::None));
+	static const QString SCOLOR("SCOLOR");
+	if (attrs.hasAttribute(SCOLOR))
+		newStyle.setStrokeColor(attrs.valueAsString(SCOLOR, CommonStrings::None));
 	
-	if (attrs.hasAttribute("SSHADE"))
-		newStyle.setStrokeShade(attrs.valueAsInt("SSHADE"));
+	static const QString SSHADE("SSHADE");
+	if (attrs.hasAttribute(SSHADE))
+		newStyle.setStrokeShade(attrs.valueAsInt(SSHADE));
 	
-	if (attrs.hasAttribute("SCALEH"))
-		newStyle.setScaleH(qRound(attrs.valueAsDouble("SCALEH") * 10));
+	static const QString SCALEH("SCALEH");
+	if (attrs.hasAttribute(SCALEH))
+		newStyle.setScaleH(qRound(attrs.valueAsDouble(SCALEH) * 10));
 	
-	if (attrs.hasAttribute("SCALEV"))
-		newStyle.setScaleV(qRound(attrs.valueAsDouble("SCALEV") * 10));
+	static const QString SCALEV("SCALEV");
+	if (attrs.hasAttribute(SCALEV))
+		newStyle.setScaleV(qRound(attrs.valueAsDouble(SCALEV) * 10));
 	
-	if (attrs.hasAttribute("BASEO"))
-		newStyle.setBaselineOffset(qRound(attrs.valueAsDouble("BASEO") * 10));
+	static const QString BASEO("BASEO");
+	if (attrs.hasAttribute(BASEO))
+		newStyle.setBaselineOffset(qRound(attrs.valueAsDouble(BASEO) * 10));
 	
-	if (attrs.hasAttribute("TXTSHX"))
-		newStyle.setShadowXOffset(qRound(attrs.valueAsDouble("TXTSHX") * 10));
+	static const QString TXTSHX("TXTSHX");
+	if (attrs.hasAttribute(TXTSHX))
+		newStyle.setShadowXOffset(qRound(attrs.valueAsDouble(TXTSHX) * 10));
 	
-	if (attrs.hasAttribute("TXTSHY"))
-		newStyle.setShadowYOffset(qRound(attrs.valueAsDouble("TXTSHY") * 10));
+	static const QString TXTSHY("TXTSHY");
+	if (attrs.hasAttribute(TXTSHY))
+		newStyle.setShadowYOffset(qRound(attrs.valueAsDouble(TXTSHY) * 10));
 	
-	if (attrs.hasAttribute("TXTOUT"))
-		newStyle.setOutlineWidth(qRound(attrs.valueAsDouble("TXTOUT") * 10));
+	static const QString TXTOUT("TXTOUT");
+	if (attrs.hasAttribute(TXTOUT))
+		newStyle.setOutlineWidth(qRound(attrs.valueAsDouble(TXTOUT) * 10));
 	
-	if (attrs.hasAttribute("TXTULP"))
-		newStyle.setUnderlineOffset(qRound(attrs.valueAsDouble("TXTULP") * 10));
+	static const QString TXTULP("TXTULP");
+	if (attrs.hasAttribute(TXTULP))
+		newStyle.setUnderlineOffset(qRound(attrs.valueAsDouble(TXTULP) * 10));
 	
-	if (attrs.hasAttribute("TXTULW"))
-		newStyle.setUnderlineWidth(qRound(attrs.valueAsDouble("TXTULW") * 10));
+	static const QString TXTULW("TXTULW");
+	if (attrs.hasAttribute(TXTULW))
+		newStyle.setUnderlineWidth(qRound(attrs.valueAsDouble(TXTULW) * 10));
 	
-	if (attrs.hasAttribute("TXTSTP"))
-		newStyle.setStrikethruOffset(qRound(attrs.valueAsDouble("TXTSTP") * 10));
+	static const QString TXTSTP("TXTSTP");
+	if (attrs.hasAttribute(TXTSTP))
+		newStyle.setStrikethruOffset(qRound(attrs.valueAsDouble(TXTSTP) * 10));
 	
-	if (attrs.hasAttribute("TXTSTW"))
-		newStyle.setStrikethruWidth(qRound(attrs.valueAsDouble("TXTSTW") * 10));
+	static const QString TXTSTW("TXTSTW");
+	if (attrs.hasAttribute(TXTSTW))
+		newStyle.setStrikethruWidth(qRound(attrs.valueAsDouble(TXTSTW) * 10));
 
-	if (attrs.hasAttribute("SHORTCUT"))
-		newStyle.setShortcut(attrs.valueAsString("SHORTCUT"));
+	static const QString SHORTCUT("SHORTCUT");
+	if (attrs.hasAttribute(SHORTCUT))
+		newStyle.setShortcut(attrs.valueAsString(SHORTCUT));
 
-	if (attrs.hasAttribute("wordTrack"))
-		newStyle.setWordTracking(attrs.valueAsDouble("wordTrack"));
+	static const QString WORDTRACK("wordTrack");
+	if (attrs.hasAttribute(WORDTRACK))
+		newStyle.setWordTracking(attrs.valueAsDouble(WORDTRACK));
 }
 
 void Scribus134Format::readParagraphStyle(ScribusDoc *doc, ScXmlStreamReader& reader, ParagraphStyle& newStyle, SCFonts &fonts)
@@ -1094,50 +1122,86 @@
 	newStyle.erase();
 	newStyle.setName(attrs.valueAsString("NAME", ""));
 	// The default style attribute must be correctly set before trying to assign a parent
-	if (attrs.hasAttribute("DefaultStyle"))
-		newStyle.setDefaultStyle(attrs.valueAsInt("DefaultStyle"));
+	static const QString DEFAULTSTYLE("DefaultStyle");
+	if (attrs.hasAttribute(DEFAULTSTYLE))
+		newStyle.setDefaultStyle(attrs.valueAsInt(DEFAULTSTYLE));
 	else if (newStyle.name() == CommonStrings::DefaultParagraphStyle || newStyle.name() == CommonStrings::trDefaultParagraphStyle)
 		newStyle.setDefaultStyle(true);
 	else
 		newStyle.setDefaultStyle(false);
 	newStyle.setParent(attrs.valueAsString("PARENT", ""));
-	if (attrs.hasAttribute("LINESPMode"))
-		newStyle.setLineSpacingMode(static_cast<ParagraphStyle::LineSpacingMode>(attrs.valueAsInt("LINESPMode")));
-	if (attrs.hasAttribute("LINESP"))
-		newStyle.setLineSpacing(attrs.valueAsDouble("LINESP"));
-	if (attrs.hasAttribute("INDENT"))
-		newStyle.setLeftMargin(attrs.valueAsDouble("INDENT"));
-	if (attrs.hasAttribute("RMARGIN"))
-		newStyle.setRightMargin(attrs.valueAsDouble("RMARGIN"));
-	if (attrs.hasAttribute("FIRST"))
-		newStyle.setFirstIndent(attrs.valueAsDouble("FIRST"));
-	if (attrs.hasAttribute("ALIGN"))
-		newStyle.setAlignment(static_cast<ParagraphStyle::AlignmentType>(attrs.valueAsInt("ALIGN")));
-	if (attrs.hasAttribute("VOR"))
-		newStyle.setGapBefore(attrs.valueAsDouble("VOR"));
-	if (attrs.hasAttribute("NACH"))
-		newStyle.setGapAfter(attrs.valueAsDouble("NACH"));
-	if (attrs.hasAttribute("DROP"))
-		newStyle.setHasDropCap(static_cast<bool>(attrs.valueAsInt("DROP")));
-	if (attrs.hasAttribute("DROPLIN"))
-		newStyle.setDropCapLines(attrs.valueAsInt("DROPLIN"));
-	if (attrs.hasAttribute("DROPDIST"))
-		newStyle.setDropCapOffset(attrs.valueAsDouble("DROPDIST"));
-	if (attrs.hasAttribute("PSHORTCUT"))
-		newStyle.setShortcut(attrs.valueAsString("PSHORTCUT"));
+
+	static const QString LINESPMode("LINESPMode");
+	if (attrs.hasAttribute(LINESPMode))
+		newStyle.setLineSpacingMode(static_cast<ParagraphStyle::LineSpacingMode>(attrs.valueAsInt(LINESPMode)));
+
+	static const QString LINESP("LINESP");
+	if (attrs.hasAttribute(LINESP))
+		newStyle.setLineSpacing(attrs.valueAsDouble(LINESP));
+
+	static const QString INDENT("INDENT");
+	if (attrs.hasAttribute(INDENT))
+		newStyle.setLeftMargin(attrs.valueAsDouble(INDENT));
+
+	static const QString RMARGIN("RMARGIN");
+	if (attrs.hasAttribute(RMARGIN))
+		newStyle.setRightMargin(attrs.valueAsDouble(RMARGIN));
+
+	static const QString FIRST("FIRST");
+	if (attrs.hasAttribute(FIRST))
+		newStyle.setFirstIndent(attrs.valueAsDouble(FIRST));
+
+	static const QString ALIGN("ALIGN");
+	if (attrs.hasAttribute(ALIGN))
+		newStyle.setAlignment(static_cast<ParagraphStyle::AlignmentType>(attrs.valueAsInt(ALIGN)));
+
+	static const QString VOR("VOR");
+	if (attrs.hasAttribute(VOR))
+		newStyle.setGapBefore(attrs.valueAsDouble(VOR));
+
+	static const QString NACH("NACH");
+	if (attrs.hasAttribute(NACH))
+		newStyle.setGapAfter(attrs.valueAsDouble(NACH));
+
+	static const QString DROP("DROP");
+	if (attrs.hasAttribute(DROP))
+		newStyle.setHasDropCap(static_cast<bool>(attrs.valueAsInt(DROP)));
+
+	static const QString DROPLIN("DROPLIN");
+	if (attrs.hasAttribute(DROPLIN))
+		newStyle.setDropCapLines(attrs.valueAsInt(DROPLIN));
+
+	static const QString DROPDIST("DROPDIST");
+	if (attrs.hasAttribute(DROPDIST))
+		newStyle.setDropCapOffset(attrs.valueAsDouble(DROPDIST));
+
+	static const QString PSHORTCUT("PSHORTCUT");
+	if (attrs.hasAttribute(PSHORTCUT))
+		newStyle.setShortcut(attrs.valueAsString(PSHORTCUT));
 	
-	if (attrs.hasAttribute("OpticalMargins"))
-		newStyle.setOpticalMargins(attrs.valueAsInt("OpticalMargins"));
-	if (attrs.hasAttribute("HyphenationMode"))
-		newStyle.setHyphenationMode(attrs.valueAsInt("HyphenationMode"));
-	if (attrs.hasAttribute("MinWordTrack"))
-		newStyle.setMinWordTracking(attrs.valueAsDouble("MinWordTrack"));
-	if (attrs.hasAttribute("NormWordTrack"))
-		newStyle.charStyle().setWordTracking(attrs.valueAsDouble("NormWordTrack"));
-	if (attrs.hasAttribute("MinGlyphShrink"))
-		newStyle.setMinGlyphExtension(attrs.valueAsDouble("MinGlyphShrink"));
-	if (attrs.hasAttribute("MaxGlyphExtend"))
-		newStyle.setMaxGlyphExtension(attrs.valueAsDouble("MaxGlyphExtend"));
+	static const QString OpticalMargins("OpticalMargins");
+	if (attrs.hasAttribute(OpticalMargins))
+		newStyle.setOpticalMargins(attrs.valueAsInt(OpticalMargins));
+
+	static const QString HyphenationMode("HyphenationMode");
+	if (attrs.hasAttribute(HyphenationMode))
+		newStyle.setHyphenationMode(attrs.valueAsInt(HyphenationMode));
+
+	static const QString MinWordTrack("MinWordTrack");
+	if (attrs.hasAttribute(MinWordTrack))
+		newStyle.setMinWordTracking(attrs.valueAsDouble(MinWordTrack));
+
+	static const QString NormWordTrack("NormWordTrack");
+	if (attrs.hasAttribute(NormWordTrack))
+		newStyle.charStyle().setWordTracking(attrs.valueAsDouble(NormWordTrack));
+
+	static const QString MinGlyphShrink("MinGlyphShrink");
+	if (attrs.hasAttribute(MinGlyphShrink))
+		newStyle.setMinGlyphExtension(attrs.valueAsDouble(MinGlyphShrink));
+
+	static const QString MaxGlyphExtend("MaxGlyphExtend");
+	if (attrs.hasAttribute(MaxGlyphExtend))
+		newStyle.setMaxGlyphExtension(attrs.valueAsDouble(MaxGlyphExtend));
 	
 	readCharacterStyleAttrs( doc, attrs, newStyle.charStyle());
 
@@ -1941,7 +2005,7 @@
 	
 	readCharacterStyleAttrs(doc, attrs, newStyle);
 
-	if (attrs.hasAttribute("Unicode"))
+	if (attrs.hasAttribute(QLatin1String("Unicode")))
 	{
 		tmp2 = QChar(attrs.valueAsInt("Unicode"));
 	}
@@ -1956,26 +2020,31 @@
 	}
 	
 	// more legacy stuff:
+	static const QString CFONT("CFONT");
+	if (attrs.hasAttribute(CFONT))
+		newStyle.setFont(m_AvailableFonts->findFont(attrs.valueAsString(CFONT), doc));
 	
-	if (attrs.hasAttribute("CFONT"))
-		newStyle.setFont(m_AvailableFonts->findFont(attrs.valueAsString("CFONT"), doc));
+	static const QString CSIZE("CSIZE");
+	if (attrs.hasAttribute(CSIZE))
+		newStyle.setFontSize(qRound(attrs.valueAsDouble(CSIZE) * 10));
 	
-	if (attrs.hasAttribute("CSIZE"))
-		newStyle.setFontSize(qRound(attrs.valueAsDouble("CSIZE") * 10));
+	static const QString CCOLOR("CCOLOR");
+	if (attrs.hasAttribute(CCOLOR))
+		newStyle.setFillColor(attrs.valueAsString(CCOLOR));
 	
-	if (attrs.hasAttribute("CCOLOR"))
-		newStyle.setFillColor(attrs.valueAsString("CCOLOR"));
-	
-	if (attrs.hasAttribute("CEXTRA"))
-		newStyle.setTracking(qRound(attrs.valueAsDouble("CEXTRA") / attrs.valueAsDouble("CSIZE") * 1000.0));
-	else if (attrs.hasAttribute("CKERN"))
+	static const QString CEXTRA("CEXTRA");
+	if (attrs.hasAttribute(CEXTRA))
+		newStyle.setTracking(qRound(attrs.valueAsDouble(CEXTRA) / attrs.valueAsDouble(CSIZE) * 1000.0));
+	else if (attrs.hasAttribute(QLatin1String("CKERN")))
 		newStyle.setTracking(attrs.valueAsInt("CKERN"));
 	
-	if (attrs.hasAttribute("CSHADE"))
-		newStyle.setFillShade(attrs.valueAsInt("CSHADE"));
+	static const QString CSHADE("CSHADE");
+	if (attrs.hasAttribute(CSHADE))
+		newStyle.setFillShade(attrs.valueAsInt(CSHADE));
 	
-	if (attrs.hasAttribute("CSTYLE"))
-		newStyle.setFeatures(static_cast<StyleFlag>(attrs.valueAsInt("CSTYLE")).featureList());
+	static const QString CSTYLE("CSTYLE");
+	if (attrs.hasAttribute(CSTYLE))
+		newStyle.setFeatures(static_cast<StyleFlag>(attrs.valueAsInt(CSTYLE)).featureList());
 
 	QString pstylename = attrs.valueAsString("PSTYLE", "");
 	int calign = attrs.valueAsInt("CALIGN", -1);		
@@ -1990,41 +2059,53 @@
 		calign = ab;
 	}
 	
-	if (attrs.hasAttribute("CSTROKE"))
-		newStyle.setStrokeColor(attrs.valueAsString("CSTROKE", CommonStrings::None));
+	static const QString CSTROKE("CSTROKE");
+	if (attrs.hasAttribute(CSTROKE))
+		newStyle.setStrokeColor(attrs.valueAsString(CSTROKE, CommonStrings::None));
 	
-	if (attrs.hasAttribute("CSHADE2"))
-		newStyle.setStrokeShade(attrs.valueAsInt("CSHADE2", 100));
+	static const QString CSHADE2("CSHADE2");
+	if (attrs.hasAttribute(CSHADE2))
+		newStyle.setStrokeShade(attrs.valueAsInt(CSHADE2, 100));
 	
-	if (attrs.hasAttribute("CSCALE"))
-		newStyle.setScaleH(qMin(qMax(qRound(attrs.valueAsDouble("CSCALE", 100.0) * 10), 100), 4000));
+	static const QString CSCALE("CSCALE");
+	if (attrs.hasAttribute(CSCALE))
+		newStyle.setScaleH(qMin(qMax(qRound(attrs.valueAsDouble(CSCALE, 100.0) * 10), 100), 4000));
 	
-	if (attrs.hasAttribute("CSCALEV"))
-		newStyle.setScaleV(qMin(qMax(qRound(attrs.valueAsDouble("CSCALEV", 100.0) * 10), 100), 4000));
+	static const QString CSCALEV("CSCALEV");
+	if (attrs.hasAttribute(CSCALEV))
+		newStyle.setScaleV(qMin(qMax(qRound(attrs.valueAsDouble(CSCALEV, 100.0) * 10), 100), 4000));
 	
-	if (attrs.hasAttribute("CBASE"))
-		newStyle.setBaselineOffset(qRound(attrs.valueAsDouble("CBASE") * 10));
+	static const QString CBASE("CBASE");
+	if (attrs.hasAttribute(CBASE))
+		newStyle.setBaselineOffset(qRound(attrs.valueAsDouble(CBASE) * 10));
 	
-	if (attrs.hasAttribute("CSHX"))
-		newStyle.setShadowXOffset(qRound(attrs.valueAsDouble("CSHX", 5.0) * 10));
+	static const QString CSHX("CSHX");
+	if (attrs.hasAttribute(CSHX))
+		newStyle.setShadowXOffset(qRound(attrs.valueAsDouble(CSHX, 5.0) * 10));
 	
-	if (attrs.hasAttribute("CSHY"))
-		newStyle.setShadowYOffset(qRound(attrs.valueAsDouble("CSHY", -5.0) * 10));
+	static const QString CSHY("CSHY");
+	if (attrs.hasAttribute(CSHY))
+		newStyle.setShadowYOffset(qRound(attrs.valueAsDouble(CSHY, -5.0) * 10));
 	
-	if (attrs.hasAttribute("COUT"))
-		newStyle.setOutlineWidth(qRound(attrs.valueAsDouble("COUT", 1.0) * 10));
+	static const QString COUT("CSHY");
+	if (attrs.hasAttribute(COUT))
+		newStyle.setOutlineWidth(qRound(attrs.valueAsDouble(COUT, 1.0) * 10));
 	
-	if (attrs.hasAttribute("CULP"))
-		newStyle.setUnderlineOffset(qRound(attrs.valueAsDouble("CULP", -0.1) * 10));
+	static const QString CULP("CULP");
+	if (attrs.hasAttribute(CULP))
+		newStyle.setUnderlineOffset(qRound(attrs.valueAsDouble(CULP, -0.1) * 10));
 	
-	if (attrs.hasAttribute("CULW"))
-		newStyle.setUnderlineWidth(qRound(attrs.valueAsDouble("CULW", -0.1) * 10));
+	static const QString CULW("CULW");
+	if (attrs.hasAttribute(CULW))
+		newStyle.setUnderlineWidth(qRound(attrs.valueAsDouble(CULW, -0.1) * 10));
 	
-	if (attrs.hasAttribute("CSTP"))
-		newStyle.setStrikethruOffset(qRound(attrs.valueAsDouble("CSTP", -0.1) * 10));
+	static const QString CSTP("CSTP");
+	if (attrs.hasAttribute(CSTP))
+		newStyle.setStrikethruOffset(qRound(attrs.valueAsDouble(CSTP, -0.1) * 10));
 	
-	if (attrs.hasAttribute("CSTW"))
-		newStyle.setStrikethruWidth(qRound(attrs.valueAsDouble("CSTW", -0.1) * 10));
+	static const QString CSTW("CSTW");
+	if (attrs.hasAttribute(CSTW))
+		newStyle.setStrikethruWidth(qRound(attrs.valueAsDouble(CSTW, -0.1) * 10));
 	
 	fixLegacyCharStyle(newStyle);
 	




More information about the scribus-commit mailing list