r22413 by jghali -

scribus-commit scribus-commit at lists.scribus.net
Sun Feb 25 19:18:49 UTC 2018


Author: jghali
Date: Sun Feb 25 19:18:49 2018
New Revision: 22413

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=22413
Log:
simplify util_color.cpp importColorsFromFile() by splitting code into different classes

Added:
    trunk/Scribus/scribus/palettes/
    trunk/Scribus/scribus/palettes/paletteloader.cpp
    trunk/Scribus/scribus/palettes/paletteloader.h
    trunk/Scribus/scribus/palettes/paletteloader_adobe_acb.cpp
    trunk/Scribus/scribus/palettes/paletteloader_adobe_acb.h
    trunk/Scribus/scribus/palettes/paletteloader_adobe_aco.cpp
    trunk/Scribus/scribus/palettes/paletteloader_adobe_aco.h
    trunk/Scribus/scribus/palettes/paletteloader_adobe_ase.cpp
    trunk/Scribus/scribus/palettes/paletteloader_adobe_ase.h
    trunk/Scribus/scribus/palettes/paletteloader_autocad_acb.cpp
    trunk/Scribus/scribus/palettes/paletteloader_autocad_acb.h
    trunk/Scribus/scribus/palettes/paletteloader_ps.cpp
    trunk/Scribus/scribus/palettes/paletteloader_ps.h
    trunk/Scribus/scribus/palettes/paletteloader_sk1.cpp
    trunk/Scribus/scribus/palettes/paletteloader_sk1.h
    trunk/Scribus/scribus/palettes/paletteloader_swatchbook.cpp
    trunk/Scribus/scribus/palettes/paletteloader_swatchbook.h
Modified:
    trunk/Scribus/scribus/CMakeLists.txt
    trunk/Scribus/scribus/util_color.cpp
    trunk/Scribus/win32/msvc2012/scribus-main/Scribus.vcxproj
    trunk/Scribus/win32/msvc2012/scribus-main/Scribus.vcxproj.filters
    trunk/Scribus/win32/msvc2015/scribus-main/Scribus.vcxproj
    trunk/Scribus/win32/msvc2015/scribus-main/Scribus.vcxproj.filters

Modified: trunk/Scribus/scribus/CMakeLists.txt
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22413&path=/trunk/Scribus/scribus/CMakeLists.txt
==============================================================================
--- trunk/Scribus/scribus/CMakeLists.txt	(original)
+++ trunk/Scribus/scribus/CMakeLists.txt	Sun Feb 25 19:18:49 2018
@@ -617,8 +617,6 @@
 	docinfo.cpp
 	documentchecker.cpp
 	documentinformation.cpp
-	downloadmanager/scdlmgr.cpp
-	downloadmanager/scdlthread.cpp
 	exif.cpp
 	fileloader.cpp
 	filesearch.cpp
@@ -710,19 +708,6 @@
 	scimagecachemanager.cpp
 	scimagecachewriteaction.cpp
 	scimagestructs.cpp
-	imagedataloaders/scimgdataloader.cpp
-	imagedataloaders/scimgdataloader_gimp.cpp
-	imagedataloaders/scimgdataloader_jpeg.cpp
-	imagedataloaders/scimgdataloader_kra.cpp
-	imagedataloaders/scimgdataloader_ora.cpp
-	imagedataloaders/scimgdataloader_pdf.cpp
-	imagedataloaders/scimgdataloader_pgf.cpp
-	imagedataloaders/scimgdataloader_pict.cpp
-	imagedataloaders/scimgdataloader_ps.cpp
-	imagedataloaders/scimgdataloader_psd.cpp
-	imagedataloaders/scimgdataloader_qt.cpp
-	imagedataloaders/scimgdataloader_tiff.cpp
-	imagedataloaders/scimgdataloader_wpg.cpp
 	sclayer.cpp
 	sclockedfile.cpp
 	scmimedata.cpp
@@ -762,8 +747,6 @@
 	tablecell.cpp
 	tableutils.cpp
 	textwriter.cpp
-	third_party/fparser/fpoptimizer.cc
-	third_party/fparser/fparser.cc
 	tocgenerator.cpp
 	transaction.cpp
 	undogui.cpp
@@ -789,6 +772,31 @@
 	util_text.cpp
 	vgradient.cpp
 	vgradientex.cpp
+	downloadmanager/scdlmgr.cpp
+	downloadmanager/scdlthread.cpp
+	imagedataloaders/scimgdataloader.cpp
+	imagedataloaders/scimgdataloader_gimp.cpp
+	imagedataloaders/scimgdataloader_jpeg.cpp
+	imagedataloaders/scimgdataloader_kra.cpp
+	imagedataloaders/scimgdataloader_ora.cpp
+	imagedataloaders/scimgdataloader_pdf.cpp
+	imagedataloaders/scimgdataloader_pgf.cpp
+	imagedataloaders/scimgdataloader_pict.cpp
+	imagedataloaders/scimgdataloader_ps.cpp
+	imagedataloaders/scimgdataloader_psd.cpp
+	imagedataloaders/scimgdataloader_qt.cpp
+	imagedataloaders/scimgdataloader_tiff.cpp
+	imagedataloaders/scimgdataloader_wpg.cpp
+	palettes/paletteloader.cpp
+	palettes/paletteloader_adobe_acb.cpp
+	palettes/paletteloader_adobe_aco.cpp
+	palettes/paletteloader_adobe_ase.cpp
+	palettes/paletteloader_autocad_acb.cpp
+	palettes/paletteloader_ps.cpp
+	palettes/paletteloader_sk1.cpp
+	palettes/paletteloader_swatchbook.cpp
+	third_party/fparser/fpoptimizer.cc
+	third_party/fparser/fparser.cc
 	ui/about.cpp
 	ui/aboutplugins.cpp
 	ui/adjustcmsdialog.cpp

Modified: trunk/Scribus/scribus/util_color.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22413&path=/trunk/Scribus/scribus/util_color.cpp
==============================================================================
--- trunk/Scribus/scribus/util_color.cpp	(original)
+++ trunk/Scribus/scribus/util_color.cpp	Sun Feb 25 19:18:49 2018
@@ -28,6 +28,13 @@
 #include "fileloader.h"
 #include "iconmanager.h"
 #include "loadsaveplugin.h"
+#include "palettes/paletteloader_adobe_acb.h"
+#include "palettes/paletteloader_adobe_aco.h"
+#include "palettes/paletteloader_adobe_ase.h"
+#include "palettes/paletteloader_autocad_acb.h"
+#include "palettes/paletteloader_ps.h"
+#include "palettes/paletteloader_sk1.h"
+#include "palettes/paletteloader_swatchbook.h"
 #include "plugins/formatidlist.h"
 #include "scclocale.h"
 #include "sccolorengine.h"
@@ -35,7 +42,6 @@
 #include "scpixmapcache.h"
 #include "scribusdoc.h"
 #include "sctextstream.h"
-#include "third_party/zip/scribus_zip.h"
 #include "util.h"
 #include "util_color.h"
 #include "util_formats.h"
@@ -47,30 +53,30 @@
 {
 	int r, g, b;
 	bool found = false;
-	if( colName.isEmpty() || colName == CommonStrings::None || !doc->PageColors.contains(colName))
+	if (colName.isEmpty() || colName == CommonStrings::None || !doc->PageColors.contains(colName))
 		return;
 
 	const ScColor& scCol1(doc->PageColors[colName]);
 	
-	if( (shade == 100) || (scCol1.getColorModel() != colorModelRGB) )
+	if ((shade == 100) || (scCol1.getColorModel() != colorModelRGB) )
 		return;
 	scCol1.getRGB(&r, &g, &b);
 	QColor col1 = getOldColorShade(r, g, b, shade), col2;
 	ColorList::Iterator it, itEnd = doc->PageColors.end();
-	for( it = doc->PageColors.begin(); it != itEnd; it++)
-	{
-		if ( it.value().getColorModel() == colorModelRGB )
+	for (it = doc->PageColors.begin(); it != itEnd; it++)
+	{
+		if (it.value().getColorModel() == colorModelRGB)
 		{
 			it.value().getRGB(&r, &g, &b);
 			col2.setRgb(r, g, b);
-			if( col1 == col2 )
+			if (col1 == col2)
 			{
 				found = true;
 				break;
 			}
 		}
 	}
-	if(!found)
+	if (!found)
 	{
 		ScColor tmp;
 		tmp.fromQColor(col1);
@@ -507,19 +513,19 @@
 	FPoint p0,p1,p2,p3;
 	double c0,c1,c2,c3;
 	double val = 0.5;
-	if(curve.size() == 0)
+	if (curve.size() == 0)
 		return 0.5;
 	// First find curve segment
 	p = curve.point(0);
-	if(x < p.x())
+	if (x < p.x())
 		return p.y();
 	p = curve.point(curve.size()-1);
-	if(x >= p.x())
+	if (x >= p.x())
 		return p.y();
 	int cc = 0;
 	// Find the four control points (two on each side of x)
 	p = curve.point(0);
-	while(x >= p.x())
+	while (x >= p.x())
 	{
 		cc++;
 		p = curve.point(cc);
@@ -555,9 +561,9 @@
 		c1 = p2.y() - c3 - c2 - c0;
 		val = ((c0*t + c1)*t + c2)*t + c3;
 	}
-	if(val < 0.0)
+	if (val < 0.0)
 		val = 0.0;
-	if(val > 1.0)
+	if (val > 1.0)
 		val = 1.0;
 	return val;
 }
@@ -632,113 +638,9 @@
 	QString ext = fi.suffix().toLower();
 	if (extensionIndicatesEPSorPS(ext))
 	{
-		QString tmp, FarNam;
-		double c, m, y, k;
-		ScColor cc;
-		QFile f(fileName);
-		if (f.open(QIODevice::ReadOnly))
-		{
-			bool isAtend = false;
-			QDataStream ts(&f);
-			while (!ts.atEnd())
-			{
-				tmp = readLineFromDataStream(ts);
-				if ((tmp.startsWith("%%CMYKCustomColor")) || (tmp.startsWith("%%CMYKProcessColor")))
-				{
-					if (tmp.contains("(atend)"))
-						isAtend = true;
-					else
-					{
-						if (tmp.startsWith("%%CMYKCustomColor"))
-							tmp = tmp.remove(0,18);
-						else if (tmp.startsWith("%%CMYKProcessColor"))
-							tmp = tmp.remove(0,19);
-						ScTextStream ts2(&tmp, QIODevice::ReadOnly);
-						ts2 >> c >> m >> y >> k;
-						FarNam = ts2.readAll();
-						FarNam = FarNam.trimmed();
-						FarNam = FarNam.remove(0,1);
-						FarNam = FarNam.remove(FarNam.length()-1,1);
-						FarNam = FarNam.simplified();
-						cc = ScColor(qRound(255 * c), qRound(255 * m), qRound(255 * y), qRound(255 * k));
-						cc.setSpotColor(true);
-						if (!FarNam.isEmpty())
-							EditColors.tryAddColor(FarNam, cc);
-						while (!ts.atEnd())
-						{
-							quint64 oldPos = ts.device()->pos();
-							tmp = readLineFromDataStream(ts);
-							if (!tmp.startsWith("%%+"))
-							{
-								ts.device()->seek(oldPos);
-								break;
-							}
-							tmp = tmp.remove(0,3);
-							ScTextStream ts2(&tmp, QIODevice::ReadOnly);
-							ts2 >> c >> m >> y >> k;
-							FarNam = ts2.readAll();
-							FarNam = FarNam.trimmed();
-							FarNam = FarNam.remove(0,1);
-							FarNam = FarNam.remove(FarNam.length()-1,1);
-							FarNam = FarNam.simplified();
-							cc = ScColor(qRound(255 * c), qRound(255 * m), qRound(255 * y), qRound(255 * k));
-							cc.setSpotColor(true);
-							if (!FarNam.isEmpty())
-								EditColors.tryAddColor(FarNam, cc);
-						}
-					}
-				}
-				if ((tmp.startsWith("%%RGBCustomColor")) || (tmp.startsWith("%%RGBProcessColor")))
-				{
-					if (tmp.contains("(atend)"))
-						isAtend = true;
-					else
-					{
-						if (tmp.startsWith("%%RGBCustomColor"))
-							tmp = tmp.remove(0,17);
-						else if (tmp.startsWith("%%RGBProcessColor"))
-							tmp = tmp.remove(0,18);
-						ScTextStream ts2(&tmp, QIODevice::ReadOnly);
-						ts2 >> c >> m >> y;
-						FarNam = ts2.readAll();
-						FarNam = FarNam.trimmed();
-						FarNam = FarNam.remove(0,1);
-						FarNam = FarNam.remove(FarNam.length()-1,1);
-						FarNam = FarNam.simplified();
-						cc = ScColor(qRound(255 * c), qRound(255 * m), qRound(255 * y));
-						if (!FarNam.isEmpty())
-							EditColors.tryAddColor(FarNam, cc);
-						while (!ts.atEnd())
-						{
-							quint64 oldPos = ts.device()->pos();
-							tmp = readLineFromDataStream(ts);
-							if (!tmp.startsWith("%%+"))
-							{
-								ts.device()->seek(oldPos);
-								break;
-							}
-							tmp = tmp.remove(0,3);
-							ScTextStream ts2(&tmp, QIODevice::ReadOnly);
-							ts2 >> c >> m >> y;
-							FarNam = ts2.readAll();
-							FarNam = FarNam.trimmed();
-							FarNam = FarNam.remove(0,1);
-							FarNam = FarNam.remove(FarNam.length()-1,1);
-							FarNam = FarNam.simplified();
-							cc = ScColor(qRound(255 * c), qRound(255 * m), qRound(255 * y));
-							if (!FarNam.isEmpty())
-								EditColors.tryAddColor(FarNam, cc);
-						}
-					}
-				}
-				if (tmp.startsWith("%%EndComments"))
-				{
-					if (!isAtend)
-						break;
-				}
-			}
-			f.close();
-		}
+		PaletteLoader_PS psPalLoader;
+		psPalLoader.setupTargets(&EditColors, dialogGradients);
+		return psPalLoader.importFile(fileName, merge);
 	}
 	else
 	{
@@ -763,511 +665,60 @@
 		}
 		if (ext == "acb")			// Adobe color book format
 		{
-			QFile fiC(fileName);
-			if (fiC.open(QIODevice::ReadOnly))
+			PaletteLoader_Adobe_acb adobePalLoader;
+			if (adobePalLoader.isFileSupported(fileName))
 			{
-				ScColor lf = ScColor();
-				quint16 vers = 0;
-				quint32 signature;
-				QDataStream ts(&fiC);
-				ts.setByteOrder(QDataStream::BigEndian);
-				ts >> signature;
-				ts >> vers;
-				if ((signature == 0x38424342) && (vers == 1))
-				{
-					quint16 vendor, numcolors, colType;
-					ts >> vendor;
-//					QString title		= readAdobeUniCodeString(ts);
-//					QString prefix		= readAdobeUniCodeString(ts);
-//					QString postfix		= readAdobeUniCodeString(ts);
-//					QString description	= readAdobeUniCodeString(ts);
-					ts >> numcolors;
-					ts.skipRawData(4);
-					ts >> colType;
-					for (quint16 cc = 0; cc < numcolors; cc++)
-					{
-						QString name = readAdobeUniCodeString(ts);
-						if (vendor == 3000)
-							name.prepend("ANPA");
-						else if (vendor == 3001)
-							name.prepend("Focoltone");
-						else if (vendor == 3002)
-							name.prepend("PantoneCoated");
-						else if (vendor == 3003)
-							name.prepend("PantoneProcess");
-						else if (vendor == 3004)
-							name.prepend("PantoneProSlim");
-						else if (vendor == 3005)
-							name.prepend("PantoneUncoated");
-						else if (vendor == 3006)
-							name.prepend("Toyo");
-						else if (vendor == 3007)
-							name.prepend("Trumatch");
-						else if (vendor == 3008)
-							name.prepend("HKSE");
-						else if (vendor == 3009)
-							name.prepend("HKSK");
-						else if (vendor == 3010)
-							name.prepend("HKSN");
-						else if (vendor == 3011)
-							name.prepend("HKSZ");
-						else if (vendor == 3012)
-							name.prepend("DIC");
-						else if (vendor == 3020)
-							name.prepend("PantonePastelCoated");
-						else if (vendor == 3021)
-							name.prepend("PantonePastelUncoated");
-						else if (vendor == 3022)
-							name.prepend("PantoneMetallic");
-						ts.skipRawData(6);
-						quint8 componentR, componentG, componentB, componentK;
-						ts >> componentR >> componentG >> componentB;
-						if (colType == 2)
-							ts >> componentK;
-						if (!name.isEmpty())
-						{
-							bool validColor = false;
-							if (colType == 0)			// RBG
-							{
-								lf.setRgbColor(componentR, componentG, componentB);
-								validColor = true;
-							}
-							else if (colType == 2)		// CMYK
-							{
-								lf.setColor(255 - componentR, 255 - componentG, 255 - componentB, 255 - componentK);
-								validColor = true;
-							}
-							if (validColor)
-							{
-								lf.setSpotColor(false);
-								lf.setRegistrationColor(false);
-								EditColors.tryAddColor(name, lf);
-							}
-						}
-					}
-					fiC.close();
-				}
-				else					// try AutoCAD XML format
-				{
-					fiC.close();
-					QByteArray docBytes("");
-					loadRawText(fileName, docBytes);
-					QString docText("");
-					docText = QString::fromUtf8(docBytes);
-					QDomDocument docu("scridoc");
-					if (!docu.setContent(docText))
-						return false;
-					QDomElement elem = docu.documentElement();
-					QDomNode PAGE = elem.firstChild();
-					while(!PAGE.isNull())
-					{
-						QDomElement pg = PAGE.toElement();
-						if (pg.tagName() == "colorPage")
-						{
-							QDomNode colNode = pg.firstChild();
-							while(!colNode.isNull())
-							{
-								QDomElement cg = colNode.toElement();
-								if (cg.tagName() == "colorEntry")
-								{
-									int r (0), g(0), b(0);
-									QString colorName = "";
-									QDomNode colEntry = cg.firstChild();
-									while(!colEntry.isNull())
-									{
-										QDomElement cc = colEntry.toElement();
-										if (cc.tagName() == "colorName")
-											colorName = cc.text();
-										else if (cc.tagName() == "RGB8")
-										{
-											QDomNode colVal = cc.firstChild();
-											while(!colVal.isNull())
-											{
-												QDomElement cv = colVal.toElement();
-												if (cv.tagName() == "red")
-													r = cv.text().toInt();
-												else if (cv.tagName() == "green")
-													g = cv.text().toInt();
-												else if (cv.tagName() == "blue")
-													b = cv.text().toInt();
-												colVal = colVal.nextSibling();
-											}
-										}
-										colEntry = colEntry.nextSibling();
-									}
-									if (!colorName.isEmpty())
-									{
-										lf.setRgbColor(r, g, b);
-										lf.setSpotColor(false);
-										lf.setRegistrationColor(false);
-										EditColors.tryAddColor(colorName, lf);
-									}
-								}
-								colNode = colNode.nextSibling();
-							}
-						}
-						PAGE = PAGE.nextSibling();
-					}
-				}
+				adobePalLoader.setupTargets(&EditColors, dialogGradients);
+				return adobePalLoader.importFile(fileName, merge);
 			}
+
+			PaletteLoader_Autocad_acb autocadPalLoder;
+			if (autocadPalLoder.isFileSupported(fileName))
+			{
+				autocadPalLoder.setupTargets(&EditColors, dialogGradients);
+				return autocadPalLoder.importFile(fileName, merge);
+			}
+			return false;
 		}
 		else if (ext == "aco")			// Adobe color swatch format
 		{
-			QFile fiC(fileName);
-			if (fiC.open(QIODevice::ReadOnly))
+			PaletteLoader_Adobe_aco adobePalLoader;
+			if (adobePalLoader.isFileSupported(fileName))
 			{
-				ScColor lf = ScColor();
-				QDataStream ts(&fiC);
-				ts.setByteOrder(QDataStream::BigEndian);
-				quint16 vers = 0;
-				ts >> vers;
-				if (vers == 1)
-				{
-					quint16 count1 = 0;
-					quint16 count2 = 0;
-					ts >> count1;
-					qint64 pos = ts.device()->pos();
-					if (pos + count1 * 10 < fiC.size())
-					{
-						ts.skipRawData(count1 * 10);
-						ts >> vers >> count2;
-						if ((vers == 2) && (count1 == count2))
-						{
-							for (quint16 cc = 0; cc < count2; cc++)
-							{
-								quint16 colType;
-								quint16 componentR, componentG, componentB, componentK;
-								ts >> colType >> componentR >> componentG >> componentB >> componentK;
-								QString name = readAdobeUniCodeString(ts);
-								if (!name.isEmpty())
-								{
-									bool validColor = false;
-									if (colType == 0)			// RBG
-									{
-										lf.setRgbColor(componentR >> 8, componentG >> 8, componentB >> 8);
-										validColor = true;
-									}
-									else if (colType == 1)		// HSB
-									{
-										uchar hc, sc, bc;
-										hc = componentR >> 8;
-										sc = componentG >> 8;
-										bc = componentB >> 8;
-										HSVTORGB(hc, sc, bc);
-										lf.setRgbColor(hc, sc, bc);
-										validColor = true;
-									}
-									else if (colType == 2)		// CMYK
-									{
-										lf.setColor(255 - (componentR >> 8), 255 - (componentG >> 8), 255 - (componentB >> 8), 255 - (componentK >> 8));
-										validColor = true;
-									}
-									else if (colType == 8)		// Grayscale
-									{
-										lf.setColor(0, 0, 0, qRound((componentK / 10000.0) * 255));
-										validColor = true;
-									}
-									if (validColor)
-									{
-										lf.setSpotColor(false);
-										lf.setRegistrationColor(false);
-										EditColors.tryAddColor(name, lf);
-									}
-								}
-							}
-						}
-					}
-					else
-					{
-						QFileInfo fiCinf(fileName);
-						QString baseName = fiCinf.baseName();
-						baseName.replace(" ", "_");
-						for (quint16 cc = 0; cc < count1; cc++)
-						{
-							quint16 colType;
-							quint16 componentR, componentG, componentB, componentK;
-							ts >> colType >> componentR >> componentG >> componentB >> componentK;
-							bool validColor = false;
-							if (colType == 0)			// RBG
-							{
-								lf.setRgbColor(componentR >> 8, componentG >> 8, componentB >> 8);
-								validColor = true;
-							}
-							else if (colType == 1)		// HSB
-							{
-								uchar hc, sc, bc;
-								hc = componentR >> 8;
-								sc = componentG >> 8;
-								bc = componentB >> 8;
-								HSVTORGB(hc, sc, bc);
-								lf.setRgbColor(hc, sc, bc);
-								validColor = true;
-							}
-							else if (colType == 2)		// CMYK
-							{
-								lf.setColor(255 - (componentR >> 8), 255 - (componentG >> 8), 255 - (componentB >> 8), 255 - (componentK >> 8));
-								validColor = true;
-							}
-							else if (colType == 8)		// Grayscale
-							{
-								lf.setColor(0, 0, 0, qRound((componentK / 10000.0) * 255));
-								validColor = true;
-							}
-							if (validColor)
-							{
-								lf.setSpotColor(false);
-								lf.setRegistrationColor(false);
-								QString name = baseName+lf.name().toUpper();
-								EditColors.tryAddColor(name, lf);
-							}
-						}
-					}
-				}
-				fiC.close();
+				adobePalLoader.setupTargets(&EditColors, dialogGradients);
+				return adobePalLoader.importFile(fileName, merge);
 			}
+			return false;
 		}
 		else if (ext == "ase")			// Adobe swatch exchange format
 		{
-			QFile fiC(fileName);
-			if (fiC.open(QIODevice::ReadOnly))
+			PaletteLoader_Adobe_ase adobePalLoader;
+			if (adobePalLoader.isFileSupported(fileName))
 			{
-				ScColor lf = ScColor();
-				QDataStream ts(&fiC);
-				ts.setByteOrder(QDataStream::BigEndian);
-				ts.setFloatingPointPrecision(QDataStream::SinglePrecision);
-				quint16 vers1 = 0;
-				quint16 vers2 = 0;
-				quint32 signature;
-				ts >> signature;
-				ts >> vers1 >> vers2;
-				if ((signature == 0x41534546) && (vers1 == 1) && (vers2 == 0))
-				{
-					QString blockName;
-					quint32 numBlocks;
-					ts >> numBlocks;
-					for (quint32 n = 0; n < numBlocks; n++)
-					{
-						quint16 blockType;
-						quint32 blockLen;
-						ts >> blockType;
-						ts >> blockLen;
-						if (blockType == 0xC001)
-							blockName = readAdobeUniCodeString16(ts);
-						else if (blockType == 0x0001)
-						{
-							if (blockName.isEmpty())
-								blockName = fi.baseName();
-							QString Cname = readAdobeUniCodeString16(ts);
-							quint32 clrType;
-							quint16 spotMode;
-							ts >> clrType;
-							if (clrType == 0x52474220)		// RGB
-							{
-								float r, g, b;
-								ts >> r >> g >> b;
-								ts >> spotMode;
-								lf.setRgbColorF(r, g, b);
-								lf.setSpotColor(spotMode == 1);
-								lf.setRegistrationColor(false);
-								if (Cname.isEmpty())
-								{
-									Cname = blockName + QString("#%1%2%3").arg(qRound(255 * r),2,16,QChar('0')).arg(qRound(255 * g),2,16,QChar('0')).arg(qRound(255 * b),2,16,QChar('0')).toUpper();
-									Cname.replace(" ","_");
-								}
-								EditColors.tryAddColor(Cname, lf);
-							}
-							else if (clrType == 0x434D594B)	// CMYK
-							{
-								float c, m, y, k;
-								ts >> c >> m >> y >> k;
-								ts >> spotMode;
-								lf.setColorF(c, m, y, k);
-								lf.setSpotColor(spotMode == 1);
-								lf.setRegistrationColor(false);
-								if (Cname.isEmpty())
-								{
-									Cname = blockName + QString("#%1%2%3%4").arg(qRound(255 * c),2,16,QChar('0')).arg(qRound(255 * m),2,16,QChar('0')).arg(qRound(255 * y),2,16,QChar('0')).arg(qRound(255 * k),2,16,QChar('0')).toUpper();
-									Cname.replace(" ","_");
-								}
-								EditColors.tryAddColor(Cname, lf);
-							}
-							else if (clrType == 0x47726179)	// Gray
-							{
-								float g;
-								ts >> g;
-								ts >> spotMode;
-								lf.setColorF(0, 0, 0, g);
-								lf.setSpotColor(spotMode == 1);
-								lf.setRegistrationColor(false);
-								if (Cname.isEmpty())
-								{
-									Cname = blockName + QString("#000000%1").arg(qRound(255 * g),2,16,QChar('0')).toUpper();
-									Cname.replace(" ","_");
-								}
-								EditColors.tryAddColor(Cname, lf);
-							}
-							else if (clrType == 0x4C414220) // Lab
-							{
-								float L, a, b;
-								ts >> L >> a >> b;
-								ts >> spotMode;
-								lf.setLabColor(L * 100.0, a, b);
-								lf.setSpotColor(spotMode == 1);
-								lf.setRegistrationColor(false);
-								if (Cname.isEmpty())
-								{
-									Cname = blockName + QString("_%1_%2_%3").arg(qRound(L * 100)).arg(qRound(a)).arg(qRound(b));
-									Cname.replace(" ","_");
-								}
-								EditColors.tryAddColor(Cname, lf);
-							}
-						}
-					}
-				}
-				fiC.close();
+				adobePalLoader.setupTargets(&EditColors, dialogGradients);
+				return adobePalLoader.importFile(fileName, merge);
 			}
+			return false;
 		}
 		else if (ext == "skp")			// Sk1 palette
 		{
-			QFile fiC(fileName);
-			if (fiC.open(QIODevice::ReadOnly))
+			PaletteLoader_sK1 sk1PalLoader;
+			if (sk1PalLoader.isFileSupported(fileName))
 			{
-				bool isCMYK = false;
-				QByteArray docBytes("");
-				loadRawText(fileName, docBytes);
-				QString docText("");
-				docText = QString::fromUtf8(docBytes);
-				QDomDocument docu("scridoc");
-				docu.setContent(docText);
-				ScColor lf = ScColor();
-				QDomElement elem = docu.documentElement();
-				QDomNode PAGE = elem.firstChild();
-				while(!PAGE.isNull())
-				{
-					QDomElement pg = PAGE.toElement();
-					if(pg.tagName() == "description")
-					{
-						if (pg.attribute("type", "") == "CMYK")
-							isCMYK = true;
-					}
-					if(pg.tagName() == "color")
-					{
-						QString Cname;
-						if (isCMYK)
-						{
-							double c, m, y, k;
-							c = pg.attribute("c", "0").toDouble();
-							m = pg.attribute("m", "0").toDouble();
-							y = pg.attribute("y", "0").toDouble();
-							k = pg.attribute("k", "0").toDouble();
-							Cname = pg.attribute("name", "");
-							if (!Cname.isEmpty())
-							{
-								lf.setColorF(c, m, y, k);
-								lf.setSpotColor(false);
-								lf.setRegistrationColor(false);
-								EditColors.tryAddColor(Cname, lf);
-							}
-						}
-						else
-						{
-							double r, g, b;
-							r = pg.attribute("r", "0").toDouble();
-							g = pg.attribute("g", "0").toDouble();
-							b = pg.attribute("b", "0").toDouble();
-							Cname = pg.attribute("name", "");
-							if (!Cname.isEmpty())
-							{
-								lf.setRgbColorF(r, g, b);
-								lf.setSpotColor(false);
-								lf.setRegistrationColor(false);
-								EditColors.tryAddColor(Cname, lf);
-							}
-						}
-					}
-					PAGE=PAGE.nextSibling();
-				}
+				sk1PalLoader.setupTargets(&EditColors, dialogGradients);
+				return sk1PalLoader.importFile(fileName, merge);
 			}
-			fiC.close();
+			return false;
 		}
 		else if (ext == "sbz")
 		{
-			ScZipHandler *uz = new ScZipHandler();
-			if (uz->open(fileName))
+			PaletteLoader_Swatchbook swatchbookLoader;
+			if (swatchbookLoader.isFileSupported(fileName))
 			{
-				if (uz->contains("swatchbook.xml"))
-				{
-					QByteArray docBytes;
-					if (uz->read("swatchbook.xml", docBytes))
-					{
-						QString docText("");
-						docText = QString::fromUtf8(docBytes);
-						QDomDocument docu("scridoc");
-						if (docu.setContent(docText))
-						{
-							QDomElement docElem = docu.documentElement();
-							for(QDomElement drawPag = docElem.firstChildElement(); !drawPag.isNull(); drawPag = drawPag.nextSiblingElement())
-							{
-								if (drawPag.tagName() == "materials")
-								{
-									for(QDomElement spf = drawPag.firstChildElement(); !spf.isNull(); spf = spf.nextSiblingElement() )
-									{
-										if (spf.tagName() == "color")
-										{
-											bool isSpot = spf.attribute("usage") == "spot";
-											QString colorName = "";
-											ScColor tmp;
-											tmp.setRegistrationColor(false);
-											for(QDomElement spp = spf.firstChildElement(); !spp.isNull(); spp = spp.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 (!colorName.isEmpty())
-												EditColors.tryAddColor(colorName, tmp);
-										}
-									}
-								}
-							}
-						}
-					}
-				}
+				swatchbookLoader.setupTargets(&EditColors, dialogGradients);
+				return swatchbookLoader.importFile(fileName, merge);
 			}
-			delete uz;
+			return false;
 		}
 		else							// try for OpenOffice, Viva and our own format
 		{
@@ -1355,7 +806,7 @@
 								VGradient gra = VGradient(VGradient::linear);
 								gra.clearStops();
 								QDomNode grad = pg.firstChild();
-								while(!grad.isNull())
+								while (!grad.isNull())
 								{
 									QDomElement stop = grad.toElement();
 									QString name = stop.attribute("NAME");
@@ -1404,7 +855,7 @@
 							if (pg.attribute("type") == "cmyk")
 							{
 								QDomNode colNode = pg.firstChild();
-								while(!colNode.isNull())
+								while (!colNode.isNull())
 								{
 									QDomElement colVal = colNode.toElement();
 									if (colVal.tagName() == "cyan")
@@ -1426,7 +877,7 @@
 							else if (pg.attribute("type") == "rgb")
 							{
 								QDomNode colNode = pg.firstChild();
-								while(!colNode.isNull())
+								while (!colNode.isNull())
 								{
 									QDomElement colVal = colNode.toElement();
 									if (colVal.tagName() == "red")

Modified: trunk/Scribus/win32/msvc2012/scribus-main/Scribus.vcxproj
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22413&path=/trunk/Scribus/win32/msvc2012/scribus-main/Scribus.vcxproj
==============================================================================
--- trunk/Scribus/win32/msvc2012/scribus-main/Scribus.vcxproj	(original)
+++ trunk/Scribus/win32/msvc2012/scribus-main/Scribus.vcxproj	Sun Feb 25 19:18:49 2018
@@ -324,6 +324,14 @@
     <ClInclude Include="..\..\..\scribus\imagedataloaders\scimgdataloader_ora.h" />
     <moc Include="..\..\..\scribus\selectionrubberband.h" />
     <ClInclude Include="..\..\..\scribus\nodeeditcontext.h" />
+    <ClInclude Include="..\..\..\scribus\palettes\paletteloader.h" />
+    <ClInclude Include="..\..\..\scribus\palettes\paletteloader_adobe_acb.h" />
+    <ClInclude Include="..\..\..\scribus\palettes\paletteloader_adobe_aco.h" />
+    <ClInclude Include="..\..\..\scribus\palettes\paletteloader_adobe_ase.h" />
+    <ClInclude Include="..\..\..\scribus\palettes\paletteloader_autocad_acb.h" />
+    <ClInclude Include="..\..\..\scribus\palettes\paletteloader_ps.h" />
+    <ClInclude Include="..\..\..\scribus\palettes\paletteloader_sk1.h" />
+    <ClInclude Include="..\..\..\scribus\palettes\paletteloader_swatchbook.h" />
     <ClInclude Include="..\..\..\scribus\pdfstructs.h" />
     <ClInclude Include="..\..\..\scribus\pdfwriter.h" />
     <ClInclude Include="..\..\..\scribus\styles\cellstyle.h" />
@@ -839,6 +847,14 @@
     <ClCompile Include="..\..\..\scribus\imagedataloaders\scimgdataloader_kra.cpp" />
     <ClCompile Include="..\..\..\scribus\marks.cpp" />
     <ClCompile Include="..\..\..\scribus\nodeeditcontext.cpp" />
+    <ClCompile Include="..\..\..\scribus\palettes\paletteloader.cpp" />
+    <ClCompile Include="..\..\..\scribus\palettes\paletteloader_adobe_acb.cpp" />
+    <ClCompile Include="..\..\..\scribus\palettes\paletteloader_adobe_aco.cpp" />
+    <ClCompile Include="..\..\..\scribus\palettes\paletteloader_adobe_ase.cpp" />
+    <ClCompile Include="..\..\..\scribus\palettes\paletteloader_autocad_acb.cpp" />
+    <ClCompile Include="..\..\..\scribus\palettes\paletteloader_ps.cpp" />
+    <ClCompile Include="..\..\..\scribus\palettes\paletteloader_sk1.cpp" />
+    <ClCompile Include="..\..\..\scribus\palettes\paletteloader_swatchbook.cpp" />
     <ClCompile Include="..\..\..\scribus\pdfwriter.cpp" />
     <ClCompile Include="..\..\..\scribus\qtiocompressor.cpp" />
     <ClCompile Include="..\..\..\scribus\imagedataloaders\scimgdataloader_ora.cpp" />

Modified: trunk/Scribus/win32/msvc2012/scribus-main/Scribus.vcxproj.filters
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22413&path=/trunk/Scribus/win32/msvc2012/scribus-main/Scribus.vcxproj.filters
==============================================================================
--- trunk/Scribus/win32/msvc2012/scribus-main/Scribus.vcxproj.filters	(original)
+++ trunk/Scribus/win32/msvc2012/scribus-main/Scribus.vcxproj.filters	Sun Feb 25 19:18:49 2018
@@ -737,6 +737,30 @@
     <ClInclude Include="..\..\..\scribus\colormgmt\scspectralvaluesconvertor.h">
       <Filter>colorMgmt</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\..\scribus\palettes\paletteloader.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\..\scribus\palettes\paletteloader_ps.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\..\scribus\palettes\paletteloader_adobe_acb.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\..\scribus\palettes\paletteloader_autocad_acb.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\..\scribus\palettes\paletteloader_adobe_aco.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\..\scribus\palettes\paletteloader_adobe_ase.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\..\scribus\palettes\paletteloader_sk1.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\..\scribus\palettes\paletteloader_swatchbook.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\..\scribus\desaxe\digester.cpp">
@@ -2355,6 +2379,30 @@
     </ClCompile>
     <ClCompile Include="..\..\..\scribus\colormgmt\scspectralvaluesconvertor.cpp">
       <Filter>colorMgmt</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\..\scribus\palettes\paletteloader.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\..\scribus\palettes\paletteloader_ps.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\..\scribus\palettes\paletteloader_adobe_acb.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\..\scribus\palettes\paletteloader_autocad_acb.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\..\scribus\palettes\paletteloader_adobe_aco.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\..\scribus\palettes\paletteloader_adobe_ase.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\..\scribus\palettes\paletteloader_sk1.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\..\scribus\palettes\paletteloader_swatchbook.cpp">
+      <Filter>Source Files</Filter>
     </ClCompile>
   </ItemGroup>
   <ItemGroup>

Modified: trunk/Scribus/win32/msvc2015/scribus-main/Scribus.vcxproj
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22413&path=/trunk/Scribus/win32/msvc2015/scribus-main/Scribus.vcxproj
==============================================================================
--- trunk/Scribus/win32/msvc2015/scribus-main/Scribus.vcxproj	(original)
+++ trunk/Scribus/win32/msvc2015/scribus-main/Scribus.vcxproj	Sun Feb 25 19:18:49 2018
@@ -324,6 +324,14 @@
     <ClInclude Include="..\..\..\scribus\imagedataloaders\scimgdataloader_ora.h" />
     <moc Include="..\..\..\scribus\selectionrubberband.h" />
     <ClInclude Include="..\..\..\scribus\nodeeditcontext.h" />
+    <ClInclude Include="..\..\..\scribus\palettes\paletteloader.h" />
+    <ClInclude Include="..\..\..\scribus\palettes\paletteloader_adobe_acb.h" />
+    <ClInclude Include="..\..\..\scribus\palettes\paletteloader_adobe_aco.h" />
+    <ClInclude Include="..\..\..\scribus\palettes\paletteloader_adobe_ase.h" />
+    <ClInclude Include="..\..\..\scribus\palettes\paletteloader_autocad_acb.h" />
+    <ClInclude Include="..\..\..\scribus\palettes\paletteloader_ps.h" />
+    <ClInclude Include="..\..\..\scribus\palettes\paletteloader_sk1.h" />
+    <ClInclude Include="..\..\..\scribus\palettes\paletteloader_swatchbook.h" />
     <ClInclude Include="..\..\..\scribus\pdfstructs.h" />
     <ClInclude Include="..\..\..\scribus\pdfwriter.h" />
     <ClInclude Include="..\..\..\scribus\styles\cellstyle.h" />
@@ -839,6 +847,14 @@
     <ClCompile Include="..\..\..\scribus\imagedataloaders\scimgdataloader_kra.cpp" />
     <ClCompile Include="..\..\..\scribus\marks.cpp" />
     <ClCompile Include="..\..\..\scribus\nodeeditcontext.cpp" />
+    <ClCompile Include="..\..\..\scribus\palettes\paletteloader.cpp" />
+    <ClCompile Include="..\..\..\scribus\palettes\paletteloader_adobe_acb.cpp" />
+    <ClCompile Include="..\..\..\scribus\palettes\paletteloader_adobe_aco.cpp" />
+    <ClCompile Include="..\..\..\scribus\palettes\paletteloader_adobe_ase.cpp" />
+    <ClCompile Include="..\..\..\scribus\palettes\paletteloader_autocad_acb.cpp" />
+    <ClCompile Include="..\..\..\scribus\palettes\paletteloader_ps.cpp" />
+    <ClCompile Include="..\..\..\scribus\palettes\paletteloader_sk1.cpp" />
+    <ClCompile Include="..\..\..\scribus\palettes\paletteloader_swatchbook.cpp" />
     <ClCompile Include="..\..\..\scribus\pdfwriter.cpp" />
     <ClCompile Include="..\..\..\scribus\qtiocompressor.cpp" />
     <ClCompile Include="..\..\..\scribus\imagedataloaders\scimgdataloader_ora.cpp" />

Modified: trunk/Scribus/win32/msvc2015/scribus-main/Scribus.vcxproj.filters
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=22413&path=/trunk/Scribus/win32/msvc2015/scribus-main/Scribus.vcxproj.filters
==============================================================================
--- trunk/Scribus/win32/msvc2015/scribus-main/Scribus.vcxproj.filters	(original)
+++ trunk/Scribus/win32/msvc2015/scribus-main/Scribus.vcxproj.filters	Sun Feb 25 19:18:49 2018
@@ -737,6 +737,30 @@
     <ClInclude Include="..\..\..\scribus\colormgmt\scspectralvaluesconvertor.h">
       <Filter>colorMgmt</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\..\scribus\palettes\paletteloader.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\..\scribus\palettes\paletteloader_ps.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\..\scribus\palettes\paletteloader_adobe_acb.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\..\scribus\palettes\paletteloader_autocad_acb.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\..\scribus\palettes\paletteloader_adobe_aco.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\..\scribus\palettes\paletteloader_adobe_ase.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\..\scribus\palettes\paletteloader_sk1.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
+    <ClInclude Include="..\..\..\scribus\palettes\paletteloader_swatchbook.h">
+      <Filter>Header Files</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="..\..\..\scribus\desaxe\digester.cpp">
@@ -2355,6 +2379,30 @@
     </ClCompile>
     <ClCompile Include="..\..\..\scribus\colormgmt\scspectralvaluesconvertor.cpp">
       <Filter>colorMgmt</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\..\scribus\palettes\paletteloader.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\..\scribus\palettes\paletteloader_ps.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\..\scribus\palettes\paletteloader_adobe_acb.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\..\scribus\palettes\paletteloader_autocad_acb.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\..\scribus\palettes\paletteloader_adobe_aco.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\..\scribus\palettes\paletteloader_adobe_ase.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\..\scribus\palettes\paletteloader_sk1.cpp">
+      <Filter>Source Files</Filter>
+    </ClCompile>
+    <ClCompile Include="..\..\..\scribus\palettes\paletteloader_swatchbook.cpp">
+      <Filter>Source Files</Filter>
     </ClCompile>
   </ItemGroup>
   <ItemGroup>




More information about the scribus-commit mailing list