r15717 by fschmid - Added reading of colours from Xara files.
scribus-commit
scribus-commit at lists.scribus.net
Mon Nov 1 10:07:00 CET 2010
Author: fschmid
Date: Mon Nov 1 09:07:00 2010
New Revision: 15717
URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=15717
Log:
Added reading of colours from Xara files.
Modified:
trunk/Scribus/scribus/colorsetmanager.cpp
trunk/Scribus/scribus/plugins/import/xar/importxar.cpp
trunk/Scribus/scribus/plugins/import/xar/importxar.h
trunk/Scribus/scribus/plugins/import/xar/importxarplugin.cpp
trunk/Scribus/scribus/plugins/import/xar/importxarplugin.h
trunk/Scribus/scribus/ui/paintmanager.cpp
Modified: trunk/Scribus/scribus/colorsetmanager.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15717&path=/trunk/Scribus/scribus/colorsetmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/colorsetmanager.cpp (original)
+++ trunk/Scribus/scribus/colorsetmanager.cpp Mon Nov 1 09:07:00 2010
@@ -139,7 +139,7 @@
void ColorSetManager::searchDir(QString path, QMap<QString, QString> &pList, QTreeWidgetItem* parent)
{
QStringList exts;
- exts << "xml" << "gpl" << "eps" << "ai" << "skp" << "sla" << "soc";
+ exts << "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/plugins/import/xar/importxar.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15717&path=/trunk/Scribus/scribus/plugins/import/xar/importxar.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/xar/importxar.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/xar/importxar.cpp Mon Nov 1 09:07:00 2010
@@ -64,6 +64,93 @@
m_Doc=doc;
importerFlags = flags;
interactive = (flags & LoadSavePlugin::lfInteractive);
+}
+
+bool XarPlug::readColors(const QString& fNameIn, ColorList &colors)
+{
+ progressDialog = NULL;
+ QString fName = fNameIn;
+ bool success = false;
+ importedColors.clear();
+ QFile f(fName);
+ if (f.open(QIODevice::ReadOnly))
+ {
+ QDataStream ts(&f);
+ ts.setByteOrder(QDataStream::LittleEndian);
+ quint32 id;
+ ts >> id;
+ if (id != 0x41524158)
+ return false;
+ ts >> id;
+ if (id != 0x0A0DA3A3)
+ return false;
+ m_Doc = new ScribusDoc();
+ m_Doc->setup(0, 1, 1, 1, 1, "Custom", "Custom");
+ m_Doc->setPage(docWidth, docHeight, 0, 0, 0, 0, 0, 0, false, false);
+ m_Doc->addPage(0);
+ m_Doc->setGUI(false, ScCore->primaryMainWindow(), 0);
+ m_Doc->setLoading(true);
+ m_Doc->DoDrawing = false;
+ m_Doc->scMW()->setScriptRunning(true);
+ m_Doc->PageColors.clear();
+ while (!ts.atEnd())
+ {
+ quint32 opCode, dataLen;
+ ts >> opCode;
+ ts >> dataLen;
+ if (opCode == 30)
+ {
+ ts.skipRawData(dataLen);
+ quint64 pos = ts.device()->pos();
+ QtIOCompressor compressor(ts.device(), 6, 1);
+ compressor.setStreamFormat(QtIOCompressor::RawZipFormat);
+ compressor.open(QIODevice::ReadOnly);
+ QDataStream tsc(&compressor);
+ tsc.setByteOrder(QDataStream::LittleEndian);
+ tsc.device()->seek(pos);
+ while (!tsc.atEnd())
+ {
+ tsc >> opCode;
+ tsc >> dataLen;
+ recordCounter++;
+ if (opCode == 31)
+ {
+ tsc.skipRawData(dataLen);
+ break;
+ }
+ else if (opCode == 51)
+ handleComplexColor(tsc);
+ else
+ tsc.skipRawData(dataLen);
+ }
+ ts.skipRawData(dataLen+1);
+ }
+ else
+ {
+ if (opCode == 51)
+ handleComplexColor(ts);
+ else
+ ts.skipRawData(dataLen);
+ }
+ }
+ f.close();
+ if (m_Doc->PageColors.count() != 0)
+ {
+ ColorList::Iterator it;
+ for (it = m_Doc->PageColors.begin(); it != m_Doc->PageColors.end(); ++it)
+ {
+ if (!it.key().startsWith("FromXara"))
+ {
+ success = true;
+ colors.insert(it.key(), it.value());
+ }
+ }
+ }
+ m_Doc->scMW()->setScriptRunning(false);
+ m_Doc->setLoading(false);
+ delete m_Doc;
+ }
+ return success;
}
QImage XarPlug::readThumbnail(QString fName)
Modified: trunk/Scribus/scribus/plugins/import/xar/importxar.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15717&path=/trunk/Scribus/scribus/plugins/import/xar/importxar.h
==============================================================================
--- trunk/Scribus/scribus/plugins/import/xar/importxar.h (original)
+++ trunk/Scribus/scribus/plugins/import/xar/importxar.h Mon Nov 1 09:07:00 2010
@@ -252,6 +252,7 @@
*/
bool import(QString fn, const TransactionSettings& trSettings, int flags, bool showProgress = true);
QImage readThumbnail(QString fn);
+ bool readColors(const QString& fileName, ColorList & colors);
private:
void parseHeader(QString fName, double &x, double &y, double &b, double &h);
Modified: trunk/Scribus/scribus/plugins/import/xar/importxarplugin.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15717&path=/trunk/Scribus/scribus/plugins/import/xar/importxarplugin.cpp
==============================================================================
--- trunk/Scribus/scribus/plugins/import/xar/importxarplugin.cpp (original)
+++ trunk/Scribus/scribus/plugins/import/xar/importxarplugin.cpp Mon Nov 1 09:07:00 2010
@@ -94,6 +94,7 @@
fmt.load = true;
fmt.save = false;
fmt.thumb = true;
+ fmt.colorReading = true;
fmt.mimeTypes = QStringList(); // MIME types
fmt.priority = 64; // Priority
registerFormat(fmt);
@@ -176,3 +177,23 @@
delete dia;
return ret;
}
+
+bool ImportXarPlugin::readColors(const QString& fileName, ColorList &colors)
+{
+ bool wasUndo = false;
+ if( fileName.isEmpty() )
+ return false;
+ if (UndoManager::undoEnabled())
+ {
+ UndoManager::instance()->setUndoEnabled(false);
+ wasUndo = true;
+ }
+ m_Doc = NULL;
+ XarPlug *dia = new XarPlug(m_Doc, lfCreateThumbnail);
+ Q_CHECK_PTR(dia);
+ bool ret = dia->readColors(fileName, colors);
+ if (wasUndo)
+ UndoManager::instance()->setUndoEnabled(true);
+ delete dia;
+ return ret;
+}
Modified: trunk/Scribus/scribus/plugins/import/xar/importxarplugin.h
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15717&path=/trunk/Scribus/scribus/plugins/import/xar/importxarplugin.h
==============================================================================
--- trunk/Scribus/scribus/plugins/import/xar/importxarplugin.h (original)
+++ trunk/Scribus/scribus/plugins/import/xar/importxarplugin.h Mon Nov 1 09:07:00 2010
@@ -34,6 +34,7 @@
virtual bool fileSupported(QIODevice* file, const QString & fileName=QString::null) const;
virtual bool loadFile(const QString & fileName, const FileFormat & fmt, int flags, int index = 0);
virtual QImage readThumbnail(const QString& fileName);
+ virtual bool readColors(const QString& fileName, ColorList & colors);
virtual void addToMainWindowMenu(ScribusMainWindow *) {};
public slots:
Modified: trunk/Scribus/scribus/ui/paintmanager.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15717&path=/trunk/Scribus/scribus/ui/paintmanager.cpp
==============================================================================
--- trunk/Scribus/scribus/ui/paintmanager.cpp (original)
+++ trunk/Scribus/scribus/ui/paintmanager.cpp Mon Nov 1 09:07:00 2010
@@ -135,7 +135,6 @@
connect(okButton, SIGNAL(clicked()), this, SLOT(leaveDialog()));
connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
connect(SaveColSet, SIGNAL(clicked()), this, SLOT(saveDefaults()));
-// connect(LoadColSet, SIGNAL(activated(const QString &)), this, SLOT(loadDefaults(const QString&)));
connect(LoadColSet, SIGNAL(activated(QTreeWidgetItem*)), this, SLOT(loadDefaults(QTreeWidgetItem*)));
}
@@ -812,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 *.xml");
+ QString ooexts(" *.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)
More information about the scribus-commit
mailing list