r15758 by fschmid - Added support for Adobe Color Book (.acb) palettes. Currently only RGB and CMYK colors.

scribus-commit scribus-commit at lists.scribus.net
Wed Nov 3 23:45:23 CET 2010


Author: fschmid
Date: Wed Nov  3 22:45:22 2010
New Revision: 15758

URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=15758
Log:
Added support for Adobe Color Book (.acb) palettes. Currently only RGB and CMYK colors.

Modified:
    trunk/Scribus/scribus/colorsetmanager.cpp
    trunk/Scribus/scribus/ui/paintmanager.cpp
    trunk/Scribus/scribus/util.cpp
    trunk/Scribus/scribus/util.h
    trunk/Scribus/scribus/util_color.cpp

Modified: trunk/Scribus/scribus/colorsetmanager.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15758&path=/trunk/Scribus/scribus/colorsetmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/colorsetmanager.cpp (original)
+++ trunk/Scribus/scribus/colorsetmanager.cpp Wed Nov  3 22:45:22 2010
@@ -139,7 +139,7 @@
 void ColorSetManager::searchDir(QString path, QMap<QString, QString> &pList, QTreeWidgetItem* parent)
 {
 	QStringList exts;
-	exts << "aco" << "ai" << "eps" << "gpl" << "skp" << "sla" << "soc" << "xar" << "xml";
+	exts << "acb" << "aco" << "ai" << "eps" << "gpl" << "skp" << "sla" << "soc" << "xar" << "xml";
 	QDir dirs(path, "*", QDir::Name,  QDir::Dirs | QDir::NoDotAndDotDot | QDir::Files | QDir::NoSymLinks);
 	dirs.setSorting(QDir::Name | QDir::DirsFirst);
 	if ((dirs.exists()) && (dirs.count() != 0))

Modified: trunk/Scribus/scribus/ui/paintmanager.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15758&path=/trunk/Scribus/scribus/ui/paintmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/paintmanager.cpp (original)
+++ trunk/Scribus/scribus/ui/paintmanager.cpp Wed Nov  3 22:45:22 2010
@@ -811,7 +811,7 @@
 			QString wdir = dirs->get("colors", ".");
 			QString docexts("*.sla *.sla.gz *.scd *.scd.gz");
 			QString aiepsext(FormatsManager::instance()->extensionListForFormat(FormatsManager::EPS|FormatsManager::PS|FormatsManager::AI, 0));
-			QString ooexts(" *.aco *.skp *.soc *.gpl *.xar *.xml");
+			QString ooexts(" *.acb *.aco *.skp *.soc *.gpl *.xar *.xml");
 			QString filter = tr("All Supported Formats (%1);;Documents (%2);;Other Files (%3);;All Files (*)").arg(docexts+" "+aiepsext+ooexts).arg(docexts).arg(aiepsext+ooexts);
 			CustomFDialog dia(this, wdir, tr("Import Colors"), filter, fdHidePreviewCheckBox);
 			if (dia.exec() == QDialog::Accepted)

Modified: trunk/Scribus/scribus/util.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15758&path=/trunk/Scribus/scribus/util.cpp
==============================================================================
--- trunk/Scribus/scribus/util.cpp (original)
+++ trunk/Scribus/scribus/util.cpp Wed Nov  3 22:45:22 2010
@@ -777,6 +777,21 @@
 	if (ind > -1)
 		box->setCurrentIndex(ind);
 	box->blockSignals(false);
+}
+
+QString readAdobeUniCodeString(QDataStream &s)
+{
+	QString ret = "";
+	quint32 len;
+	s >> len;
+	for (quint32 a = 0; a < len; a++)
+	{
+		quint16 ch;
+		s >> ch;
+		if (ch != 0)
+			ret.append(QChar(ch));
+	}
+	return ret;
 }
 
 QString getDashString(int dashtype, double linewidth)

Modified: trunk/Scribus/scribus/util.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15758&path=/trunk/Scribus/scribus/util.h
==============================================================================
--- trunk/Scribus/scribus/util.h (original)
+++ trunk/Scribus/scribus/util.h Wed Nov  3 22:45:22 2010
@@ -140,6 +140,8 @@
 QString SCRIBUS_API readLinefromDataStream(QDataStream &s);
 void SCRIBUS_API setCurrentComboItem(QComboBox *box, QString text);
 
+QString SCRIBUS_API readAdobeUniCodeString(QDataStream &s);
+
 QString SCRIBUS_API getDashString(int dashtype, double linewidth);
 void    SCRIBUS_API getDashArray(int dashtype, double linewidth, QVector<double> &m_array);
 void    SCRIBUS_API getDashArray(int dashtype, double linewidth, QVector<float> &m_array);

Modified: trunk/Scribus/scribus/util_color.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15758&path=/trunk/Scribus/scribus/util_color.cpp
==============================================================================
--- trunk/Scribus/scribus/util_color.cpp (original)
+++ trunk/Scribus/scribus/util_color.cpp Wed Nov  3 22:45:22 2010
@@ -733,6 +733,95 @@
 					}
 				}
 			}
+			else if (ext == "acb")			// Adobe color book format
+			{
+				QFile fiC(fileName);
+				if (fiC.open(QIODevice::ReadOnly))
+				{
+					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.setColorRGB(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);
+									if (!EditColors.contains(name))
+										EditColors.insert(name, lf);
+								}
+							}
+						}
+					}
+					fiC.close();
+				}
+			}
 			else if (ext == "aco")			// Adobe color swatch format
 			{
 				QFile fiC(fileName);
@@ -756,17 +845,8 @@
 							{
 								quint16 colType;
 								quint16 componentR, componentG, componentB, componentK;
-								quint32 nameLength;
-								QString name = "";
 								ts >> colType >> componentR >> componentG >> componentB >> componentK;
-								ts >> nameLength;
-								for (quint32 a = 0; a < nameLength; a++)
-								{
-									quint16 ch;
-									ts >> ch;
-									if (ch != 0)
-										name.append(QChar(ch));
-								}
+								QString name = readAdobeUniCodeString(ts);
 								if (!name.isEmpty())
 								{
 									bool validColor = false;




More information about the scribus-commit mailing list