r20162 by fschmid - Part of Bug #13121: added reading support for .ase files.

scribus-commit scribus-commit at lists.scribus.net
Wed Jun 10 20:18:11 UTC 2015


Author: fschmid
Date: Wed Jun 10 20:18:11 2015
New Revision: 20162

URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=20162
Log:
Part of Bug #13121: added reading support for .ase files.

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.net/websvn/diff.php?repname=Scribus&rev=20162&path=/trunk/Scribus/scribus/colorsetmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/colorsetmanager.cpp (original)
+++ trunk/Scribus/scribus/colorsetmanager.cpp Wed Jun 10 20:18:11 2015
@@ -153,7 +153,7 @@
 void ColorSetManager::searchDir(QString path, QMap<QString, QString> &pList, QTreeWidgetItem* parent)
 {
 	QStringList exts;
-	exts << "acb" << "aco" << "ai" << "eps" << "gpl" << "skp" << "sla" << "soc" << "xar" << "xml" << "sbz";
+	exts << "acb" << "aco" << "ai" << "ase" << "eps" << "gpl" << "skp" << "sla" << "soc" << "xar" << "xml" << "sbz";
 	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.net/websvn/diff.php?repname=Scribus&rev=20162&path=/trunk/Scribus/scribus/ui/paintmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/paintmanager.cpp (original)
+++ trunk/Scribus/scribus/ui/paintmanager.cpp Wed Jun 10 20:18:11 2015
@@ -1055,7 +1055,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(" *.acb *.aco *.skp *.soc *.gpl *.xml *.sbz");
+			QString ooexts(" *.acb *.aco *.ase *.skp *.soc *.gpl *.xml *.sbz");
 			ooexts += extra;
 			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);

Modified: trunk/Scribus/scribus/util.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20162&path=/trunk/Scribus/scribus/util.cpp
==============================================================================
--- trunk/Scribus/scribus/util.cpp (original)
+++ trunk/Scribus/scribus/util.cpp Wed Jun 10 20:18:11 2015
@@ -781,6 +781,21 @@
 	quint32 len;
 	s >> len;
 	for (quint32 i = 0; i < len; i++)
+	{
+		quint16 ch;
+		s >> ch;
+		if (ch != 0)
+			ret.append(QChar(ch));
+	}
+	return ret;
+}
+
+QString readAdobeUniCodeString16(QDataStream &s)
+{
+	QString ret = "";
+	quint16 len;
+	s >> len;
+	for (quint16 i = 0; i < len; i++)
 	{
 		quint16 ch;
 		s >> ch;

Modified: trunk/Scribus/scribus/util.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20162&path=/trunk/Scribus/scribus/util.h
==============================================================================
--- trunk/Scribus/scribus/util.h (original)
+++ trunk/Scribus/scribus/util.h Wed Jun 10 20:18:11 2015
@@ -134,6 +134,7 @@
 void SCRIBUS_API setCurrentComboItem(QComboBox *box, QString text);
 
 QString SCRIBUS_API readAdobeUniCodeString(QDataStream &s);
+QString SCRIBUS_API readAdobeUniCodeString16(QDataStream &s);
 
 QString SCRIBUS_API getDashString(int dashtype, double linewidth);
 void    SCRIBUS_API getDashArray(int dashtype, double linewidth, QVector<double> &dashArray);

Modified: trunk/Scribus/scribus/util_color.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=20162&path=/trunk/Scribus/scribus/util_color.cpp
==============================================================================
--- trunk/Scribus/scribus/util_color.cpp (original)
+++ trunk/Scribus/scribus/util_color.cpp Wed Jun 10 20:18:11 2015
@@ -1022,6 +1022,107 @@
 					fiC.close();
 				}
 			}
+			else if (ext == "ase")			// Adobe swatch exchange format
+			{
+				QFile fiC(fileName);
+				if (fiC.open(QIODevice::ReadOnly))
+				{
+					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.setColorRGB(qRound(255 * r), qRound(255 * g), qRound(255 * b));
+									lf.setSpotColor(spotMode == 2);
+									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.setColor(qRound(255 * c), qRound(255 * m), qRound(255 * y), qRound(255 * k));
+									lf.setSpotColor(spotMode == 2);
+									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.setColor(0, 0, 0, qRound(255 * g));
+									lf.setSpotColor(spotMode == 2);
+									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.setColor(L * 100.0, a, b);
+									lf.setSpotColor(spotMode == 2);
+									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();
+				}
+			}
 			else if (ext == "skp")			// Sk1 palette
 			{
 				QFile fiC(fileName);
@@ -1198,8 +1299,15 @@
 							{
 								if (pg.hasAttribute("CMYK"))
 									lf.setNamedColor(pg.attribute("CMYK"));
+								else if (pg.hasAttribute("RGB"))
+									lf.fromQColor(QColor(pg.attribute("RGB")));
 								else
-									lf.fromQColor(QColor(pg.attribute("RGB")));
+								{
+									double L = pg.attribute("L", "0").toDouble();
+									double a = pg.attribute("A", "0").toDouble();
+									double b = pg.attribute("B", "0").toDouble();
+									lf.setColor(L, a, b);
+								}
 								if (pg.hasAttribute("Spot"))
 									lf.setSpotColor(static_cast<bool>(pg.attribute("Spot").toInt()));
 								else




More information about the scribus-commit mailing list