r15360 by jghali - #9285 : copying objects between documents looses colours of frames

scribus-commit scribus-commit at lists.scribus.net
Sun Jul 18 15:10:20 CEST 2010


Revision: 15360
Author: jghali
Date: 2010-07-18T13:02:36.560753Z
Commit message: #9285 : copying objects between documents looses colours of frames

Changeset: 
M  /branches/Version135/Scribus/scribus/serializer.cpp

Diffs:
Index: scribus/serializer.cpp
===================================================================
--- scribus/serializer.cpp	(revision 15359)
+++ scribus/serializer.cpp	(revision 15360)
@@ -124,18 +124,34 @@
 class CollectSingleLine : public MakeAction<CollectSingleLine_body>
 {};
 
+class MergeColors_body : public Action_body
+{
+	void end (const Xml_string& tagname)
+	{
+//		qDebug() << QString("collect %1").arg(tagname);
+		Collection* coll = this->dig->lookup<Collection>("<collection>");
+		ScribusDoc* doc  = this->dig->lookup<ScribusDoc>("<scribusdoc>");
+		doc->PageColors.addColors(coll->colors, false);
+	}
+};
+
+class MergeColors : public MakeAction<MergeColors_body>
+{};
+
 Serializer::Serializer(ScribusDoc& doc) : Digester(), m_Doc(doc)
 {
 	// register desaxe rules for styles, colors and elems
 	addRule("/SCRIBUSFRAGMENT", Factory<Collection>());
 	addRule("/SCRIBUSFRAGMENT", Store<Collection>("<collection>"));
+
+	addRule("/SCRIBUSFRAGMENT/colors", MergeColors());
 	
-	addRule("/SCRIBUSFRAGMENT/color", Factory<ScColor>());
-	addRule("/SCRIBUSFRAGMENT/color", SetAttribute<ScColor, QString>( &ScColor::setNamedColor, "RGB" ));
-	addRule("/SCRIBUSFRAGMENT/color", SetAttribute<ScColor, QString>( &ScColor::setNamedColor, "CMYK" ));
-	addRule("/SCRIBUSFRAGMENT/color", SetAttributeWithConversion<ScColor, bool>( &ScColor::setSpotColor, "Spot", &parseBool ));
-	addRule("/SCRIBUSFRAGMENT/color", SetAttributeWithConversion<ScColor, bool>( &ScColor::setRegistrationColor, "Register", &parseBool ));
-	addRule("/SCRIBUSFRAGMENT/color", CollectColor());
+	addRule("/SCRIBUSFRAGMENT/colors/color", Factory<ScColor>());
+	addRule("/SCRIBUSFRAGMENT/colors/color", SetAttribute<ScColor, QString>( &ScColor::setNamedColor, "RGB" ));
+	addRule("/SCRIBUSFRAGMENT/colors/color", SetAttribute<ScColor, QString>( &ScColor::setNamedColor, "CMYK" ));
+	addRule("/SCRIBUSFRAGMENT/colors/color", SetAttributeWithConversion<ScColor, bool>( &ScColor::setSpotColor, "Spot", &parseBool ));
+	addRule("/SCRIBUSFRAGMENT/colors/color", SetAttributeWithConversion<ScColor, bool>( &ScColor::setRegistrationColor, "Register", &parseBool ));
+	addRule("/SCRIBUSFRAGMENT/colors/color", CollectColor());
 
 	CharStyle::desaxeRules("/SCRIBUSFRAGMENT/", *this);
 	addRule("/SCRIBUSFRAGMENT/charstyle", SetterP<Collection, CharStyle>( & Collection::collectCharStyle ));
@@ -182,6 +198,7 @@
 	ColorList usedColors;
 	doc->getUsedColors(usedColors, false);
 	ColorList::Iterator itc;
+	handler.begin("colors", Xml_attr());
 	for (itc = usedColors.begin(); itc != usedColors.end(); ++itc)
 	{
 		Xml_attr cattr;
@@ -194,6 +211,7 @@
 		cattr["Register"] = toXMLString(doc->PageColors[itc.key()].isRegistrationColor());
 		handler.beginEnd("color", cattr);
 	}
+	handler.end("colors");
 	
 	ResourceCollection lists;
 	for (int i=0; i < doc->Items->count(); ++i)




More information about the scribus-commit mailing list