r15750 by fschmid - Added support for Adobe Color Swatch (.aco) palettes.

scribus-commit scribus-commit at lists.scribus.net
Wed Nov 3 21:02:16 CET 2010


Author: fschmid
Date: Wed Nov  3 20:02:16 2010
New Revision: 15750

URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=15750
Log:
Added support for Adobe Color Swatch (.aco) palettes.

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

Modified: trunk/Scribus/scribus/colorsetmanager.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15750&path=/trunk/Scribus/scribus/colorsetmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/colorsetmanager.cpp (original)
+++ trunk/Scribus/scribus/colorsetmanager.cpp Wed Nov  3 20:02:16 2010
@@ -139,7 +139,7 @@
 void ColorSetManager::searchDir(QString path, QMap<QString, QString> &pList, QTreeWidgetItem* parent)
 {
 	QStringList exts;
-	exts << "ai" << "eps" << "gpl" << "skp" << "sla" << "soc" << "xar" << "xml";
+	exts << "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=15750&path=/trunk/Scribus/scribus/ui/paintmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/paintmanager.cpp (original)
+++ trunk/Scribus/scribus/ui/paintmanager.cpp Wed Nov  3 20:02:16 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(" *.skp *.soc *.gpl *.xar *.xml");
+			QString ooexts(" *.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_color.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15750&path=/trunk/Scribus/scribus/util_color.cpp
==============================================================================
--- trunk/Scribus/scribus/util_color.cpp (original)
+++ trunk/Scribus/scribus/util_color.cpp Wed Nov  3 20:02:16 2010
@@ -731,6 +731,82 @@
 								EditColors.insert(it.key(), it.value());
 						}
 					}
+				}
+			}
+			else if (ext == "aco")			// Adobe color swatch format
+			{
+				QFile fiC(fileName);
+				if (fiC.open(QIODevice::ReadOnly))
+				{
+					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;
+						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;
+								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));
+								}
+								if (!name.isEmpty())
+								{
+									bool validColor = false;
+									if (colType == 0)			// RBG
+									{
+										lf.setColorRGB(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.setColorRGB(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);
+										if (!EditColors.contains(name))
+											EditColors.insert(name, lf);
+									}
+								}
+							}
+						}
+					}
+					fiC.close();
 				}
 			}
 			else if (ext == "skp")			// Sk1 palette




More information about the scribus-commit mailing list