r24891 by jghali - Refactor PaletteLoader_Swatchbook::importFile() in order to reduce indentation level

scribus-commit scribus-commit at lists.scribus.net
Thu Feb 3 21:14:16 UTC 2022


Author: jghali
Date: Thu Feb  3 21:14:16 2022
New Revision: 24891

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=24891
Log:
Refactor PaletteLoader_Swatchbook::importFile() in order to reduce indentation level

Modified:
    trunk/Scribus/scribus/palettes/paletteloader_swatchbook.cpp

Modified: trunk/Scribus/scribus/palettes/paletteloader_swatchbook.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=24891&path=/trunk/Scribus/scribus/palettes/paletteloader_swatchbook.cpp
==============================================================================
--- trunk/Scribus/scribus/palettes/paletteloader_swatchbook.cpp	(original)
+++ trunk/Scribus/scribus/palettes/paletteloader_swatchbook.cpp	Thu Feb  3 21:14:16 2022
@@ -56,59 +56,60 @@
 	QDomElement docElem = docu.documentElement();
 	for (QDomElement drawPag = docElem.firstChildElement(); !drawPag.isNull(); drawPag = drawPag.nextSiblingElement())
 	{
-		if (drawPag.tagName() == "materials")
+		if (drawPag.tagName() != "materials")
+			continue;
+
+		for (QDomElement spf = drawPag.firstChildElement(); !spf.isNull(); spf = spf.nextSiblingElement() )
 		{
-			for (QDomElement spf = drawPag.firstChildElement(); !spf.isNull(); spf = spf.nextSiblingElement() )
+			if (spf.tagName() != "color")
+				continue;
+
+			bool isSpot = spf.attribute("usage") == "spot";
+			QString colorName ;
+			ScColor tmp;
+			tmp.setRegistrationColor(false);
+			for (QDomElement spp = spf.firstChildElement(); !spp.isNull(); spp = spp.nextSiblingElement() )
 			{
-				if (spf.tagName() == "color")
+				if (spp.tagName() == "metadata")
 				{
-					bool isSpot = spf.attribute("usage") == "spot";
-					QString colorName = "";
-					ScColor tmp;
-					tmp.setRegistrationColor(false);
-					for (QDomElement spp = spf.firstChildElement(); !spp.isNull(); spp = spp.nextSiblingElement() )
+					for (QDomElement spm = spp.firstChildElement(); !spm.isNull(); spm = spm.nextSiblingElement() )
 					{
-						if (spp.tagName() == "metadata")
-						{
-							for (QDomElement spm = spp.firstChildElement(); !spm.isNull(); spm = spm.nextSiblingElement() )
-							{
-								if (spm.tagName() == "dc:identifier")
-									colorName = spm.text();
-							}
-						}
-						else if (spp.tagName() == "values")
-						{
-							QString colorVals = spp.text();
-							ScTextStream CoE(&colorVals, QIODevice::ReadOnly);
-							if (spp.attribute("model") == "Lab")
-							{
-								double inC[3];
-								CoE >> inC[0];
-								CoE >> inC[1];
-								CoE >> inC[2];
-								tmp.setLabColor(inC[0], inC[1], inC[2]);
-								tmp.setSpotColor(isSpot);
-							}
-							else if (spp.attribute("model") == "CMYK")
-							{
-								double c, m, y, k;
-								CoE >> c >> m >> y >> k;
-								tmp.setColorF(c, m, y, k);
-								tmp.setSpotColor(isSpot);
-							}
-							else if (spp.attribute("model") == "RGB")
-							{
-								double r, g, b;
-								CoE >> r >> g >> b;
-								tmp.setRgbColorF(r, g, b);
-								tmp.setSpotColor(false);
-							}
-						}
+						if (spm.tagName() == "dc:identifier")
+							colorName = spm.text();
 					}
-					if (!colorName.isEmpty())
-						m_colors->tryAddColor(colorName, tmp);
+				}
+				else if (spp.tagName() == "values")
+				{
+					QString colorVals = spp.text();
+					ScTextStream CoE(&colorVals, QIODevice::ReadOnly);
+					if (spp.attribute("model") == "Lab")
+					{
+						double inC[3];
+						CoE >> inC[0];
+						CoE >> inC[1];
+						CoE >> inC[2];
+						tmp.setLabColor(inC[0], inC[1], inC[2]);
+						tmp.setSpotColor(isSpot);
+					}
+					else if (spp.attribute("model") == "CMYK")
+					{
+						double c, m, y, k;
+						CoE >> c >> m >> y >> k;
+						tmp.setColorF(c, m, y, k);
+						tmp.setSpotColor(isSpot);
+					}
+					else if (spp.attribute("model") == "RGB")
+					{
+						double r, g, b;
+						CoE >> r >> g >> b;
+						tmp.setRgbColorF(r, g, b);
+						tmp.setSpotColor(false);
+					}
 				}
 			}
+
+			if (!colorName.isEmpty())
+				m_colors->tryAddColor(colorName, tmp);
 		}
 	}
 	




More information about the scribus-commit mailing list