2
For general Scribus (>=1.3.2) copyright and licensing information please refer
3
to the COPYING file provided with the program. Following this notice may exist
4
a copyright and/or license notice that predates the release of Scribus 1.3.2
5
for which a new license (GPL+exception) is in place.
17
#include <QTemporaryFile>
25
#include "commonstrings.h"
26
#include "customfdialog.h"
28
#include "loadsaveplugin.h"
30
#include "multiprogressdialog.h"
31
#include "prefscontext.h"
32
#include "prefsfile.h"
33
#include "prefsmanager.h"
34
#include "prefsmanager.h"
35
#include "prefstable.h"
36
#include "propertiespalette.h"
38
#include "sccolorengine.h"
40
#include "scclocale.h"
41
#include "scmimedata.h"
43
#include "scpattern.h"
45
#include "scribusXml.h"
46
#include "scribuscore.h"
47
#include "scribusdoc.h"
48
#include "sctextstream.h"
49
#include "selection.h"
50
#include "text/specialchars.h"
51
#include "undomanager.h"
53
#include "util_color.h"
54
#include "util_file.h"
55
#include "util_formats.h"
56
#include "util_icon.h"
57
#include "util_math.h"
61
#include <podofo/podofo.h>
64
extern SCRIBUS_API ScribusQApp * ScQApp;
66
AIPlug::AIPlug(ScribusDoc* doc, int flags)
68
tmpSel=new Selection(this, false);
70
interactive = (flags & LoadSavePlugin::lfInteractive);
71
progressDialog = NULL;
74
bool AIPlug::import(QString fNameIn, const TransactionSettings& trSettings, int flags, bool showProgress)
76
QString fName = fNameIn;
78
interactive = (flags & LoadSavePlugin::lfInteractive);
79
importerFlags = flags;
85
QFileInfo fi = QFileInfo(fName);
86
// QString ext = fi.suffix().toLower();
87
if ( !ScCore->usingGUI() )
93
/* Check if the file is an old style AI or one of the newer PDF wrapped ones */
95
if (fT.open(QIODevice::ReadOnly))
97
QByteArray tempBuf(9, ' ');
98
fT.read(tempBuf.data(), 8);
100
if (tempBuf.startsWith("%PDF"))
102
QFileInfo bF2(fName);
103
QString tmpFile = ScPaths::getTempFileDir()+ "/"+bF2.baseName()+"_tmp.ai";
104
if (!extractFromPDF(fName, tmpFile))
111
if (fT2.open(QIODevice::ReadOnly))
113
QByteArray tempBuf(25, ' ');
114
fT2.read(tempBuf.data(), 20);
116
/* Illustrator CS files might be compressed
117
the compressed Data starts right after the "%AI12_CompressedData" comment
118
Compression is a simple zlib compression */
119
if (tempBuf.startsWith("%AI12_CompressedData"))
120
decompressAIData(fName);
124
ScribusMainWindow* mw=(m_Doc==0) ? ScCore->primaryMainWindow() : m_Doc->scMW();
125
progressDialog = new MultiProgressDialog( tr("Importing: %1").arg(fi.fileName()), CommonStrings::tr_Cancel, mw );
126
QStringList barNames, barTexts;
128
barTexts << tr("Analyzing File:");
129
QList<bool> barsNumeric;
130
barsNumeric << false;
131
progressDialog->addExtraProgressBars(barNames, barTexts, barsNumeric);
132
progressDialog->setOverallTotalSteps(3);
133
progressDialog->setOverallProgress(0);
134
progressDialog->setProgress("GI", 0);
135
progressDialog->show();
136
connect(progressDialog, SIGNAL(canceled()), this, SLOT(cancelRequested()));
137
qApp->processEvents();
140
progressDialog = NULL;
141
/* Set default Page to size defined in Preferences */
144
b = PrefsManager::instance()->appPrefs.PageWidth;
145
h = PrefsManager::instance()->appPrefs.PageHeight;
148
progressDialog->setOverallProgress(1);
149
qApp->processEvents();
151
parseHeader(fName, x, y, b, h);
158
if (!interactive || (flags & LoadSavePlugin::lfInsertPage))
160
m_Doc->setPage(b-x, h-y, 0, 0, 0, 0, 0, 0, false, false);
162
m_Doc->view()->addPage(0, true);
168
if (!m_Doc || (flags & LoadSavePlugin::lfCreateDoc))
170
m_Doc=ScCore->primaryMainWindow()->doFileNew(b-x, h-y, 0, 0, 0, 0, 0, 0, false, false, 0, false, 0, 1, "Custom", true);
171
ScCore->primaryMainWindow()->HaveNewDoc();
177
if (flags & LoadSavePlugin::lfCreateDoc)
179
m_Doc->documentInfo.setAuthor(docCreator);
180
m_Doc->documentInfo.setPublisher(docOrganisation);
181
m_Doc->documentInfo.setTitle(docTitle);
182
m_Doc->documentInfo.setDate(docDate+" "+docTime);
184
if ((!ret) && (interactive))
186
baseX = m_Doc->currentPage()->xOffset();
187
baseY = m_Doc->currentPage()->yOffset();
189
if ((ret) || (!interactive))
195
m_Doc->m_pageSize = "Custom";
197
ColorList::Iterator it;
198
for (it = CustColors.begin(); it != CustColors.end(); ++it)
200
if (!m_Doc->PageColors.contains(it.key()))
201
m_Doc->PageColors.insert(it.key(), it.value());
204
FPoint minSize = m_Doc->minCanvasCoordinate;
205
FPoint maxSize = m_Doc->maxCanvasCoordinate;
206
FPoint cOrigin = m_Doc->view()->canvasOrigin();
207
m_Doc->setLoading(true);
208
m_Doc->DoDrawing = false;
209
m_Doc->view()->updatesOn(false);
210
m_Doc->scMW()->setScriptRunning(true);
211
qApp->changeOverrideCursor(QCursor(Qt::WaitCursor));
212
QString CurDirP = QDir::currentPath();
213
QDir::setCurrent(fi.path());
217
QDir::setCurrent(CurDirP);
218
if ((Elements.count() > 1) && (!(importerFlags & LoadSavePlugin::lfCreateDoc)))
222
if (Elements.at(0)->Groups.count() != 0)
223
firstElem = Elements.at(0)->Groups.top();
224
for (int bx = 0; bx < Elements.count(); ++bx)
226
PageItem* bxi = Elements.at(bx);
227
if (bxi->Groups.count() != 0)
229
if (bxi->Groups.top() != firstElem)
237
double minx = 99999.9;
238
double miny = 99999.9;
239
double maxx = -99999.9;
240
double maxy = -99999.9;
241
uint lowestItem = 999999;
242
uint highestItem = 0;
243
for (int a = 0; a < Elements.count(); ++a)
245
Elements.at(a)->Groups.push(m_Doc->GroupCounter);
246
PageItem* currItem = Elements.at(a);
247
lowestItem = qMin(lowestItem, currItem->ItemNr);
248
highestItem = qMax(highestItem, currItem->ItemNr);
249
double x1, x2, y1, y2;
250
currItem->getVisualBoundingRect(&x1, &y1, &x2, &y2);
251
minx = qMin(minx, x1);
252
miny = qMin(miny, y1);
253
maxx = qMax(maxx, x2);
254
maxy = qMax(maxy, y2);
258
double gw = maxx - minx;
259
double gh = maxy - miny;
260
PageItem *high = m_Doc->Items->at(highestItem);
261
int z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, gx, gy, gw, gh, 0, m_Doc->toolSettings.dBrush, m_Doc->toolSettings.dPen, true);
262
PageItem *neu = m_Doc->Items->takeAt(z);
263
m_Doc->Items->insert(lowestItem, neu);
264
neu->Groups.push(m_Doc->GroupCounter);
265
neu->setItemName( tr("Group%1").arg(neu->Groups.top()));
266
neu->isGroupControl = true;
267
neu->groupsLastItem = high;
268
neu->setTextFlowMode(PageItem::TextFlowDisabled);
269
for (int a = 0; a < m_Doc->Items->count(); ++a)
271
m_Doc->Items->at(a)->ItemNr = a;
273
Elements.prepend(neu);
274
m_Doc->GroupCounter++;
277
m_Doc->DoDrawing = true;
278
m_Doc->scMW()->setScriptRunning(false);
279
m_Doc->setLoading(false);
280
qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
281
if ((Elements.count() > 0) && (!ret) && (interactive))
283
if (flags & LoadSavePlugin::lfScripted)
285
bool loadF = m_Doc->isLoading();
286
m_Doc->setLoading(false);
288
m_Doc->setLoading(loadF);
289
m_Doc->m_Selection->delaySignalsOn();
290
for (int dre=0; dre<Elements.count(); ++dre)
292
m_Doc->m_Selection->addItem(Elements.at(dre), true);
294
m_Doc->m_Selection->delaySignalsOff();
295
m_Doc->m_Selection->setGroupRect();
296
m_Doc->view()->updatesOn(true);
301
m_Doc->DraggedElem = 0;
302
m_Doc->DragElements.clear();
303
m_Doc->m_Selection->delaySignalsOn();
304
for (int dre=0; dre<Elements.count(); ++dre)
306
m_Doc->DragElements.append(Elements.at(dre)->ItemNr);
307
tmpSel->addItem(Elements.at(dre), true);
309
tmpSel->setGroupRect();
310
ScriXmlDoc *ss = new ScriXmlDoc();
311
ScElemMimeData* md = new ScElemMimeData();
312
md->setScribusElem(ss->WriteElem(m_Doc, m_Doc->view(), tmpSel));
316
m_Doc->itemSelection_DeleteItem(tmpSel);
318
qDebug("aiimport: leaving items on page");
320
m_Doc->view()->updatesOn(true);
321
m_Doc->m_Selection->delaySignalsOff();
322
// We must copy the TransationSettings object as it is owned
323
// by handleObjectImport method afterwards
324
TransactionSettings* transacSettings = new TransactionSettings(trSettings);
325
m_Doc->view()->handleObjectImport(md, transacSettings);
326
m_Doc->DragP = false;
327
m_Doc->DraggedElem = 0;
328
m_Doc->DragElements.clear();
334
m_Doc->reformPages();
335
m_Doc->view()->updatesOn(true);
341
QDir::setCurrent(CurDirP);
342
m_Doc->DoDrawing = true;
343
m_Doc->scMW()->setScriptRunning(false);
344
m_Doc->view()->updatesOn(true);
345
qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
348
m_Doc->setLoading(false);
349
//CB If we have a gui we must refresh it if we have used the progressbar
350
if ((showProgress) && (!interactive))
351
m_Doc->view()->DrawNew();
353
QFile::remove(fName);
360
delete progressDialog;
364
bool AIPlug::extractFromPDF(QString infile, QString outfile)
369
outf.open(QIODevice::WriteOnly);
372
PoDoFo::PdfError::EnableDebug( false );
373
#if (PODOFO_VERSION == 0 && PODOFO_MINOR > 6)
374
PoDoFo::PdfError::EnableLogging( false );
376
#if (PODOFO_VERSION == 0 && PODOFO_MINOR == 5 && PODOFO_REVISION == 99) || PODOFO_MINOR > 5
377
PoDoFo::PdfMemDocument doc( infile.toLocal8Bit().data() );
379
PoDoFo::PdfDocument doc( infile.toLocal8Bit().data() );
381
PoDoFo::PdfPage *curPage = doc.GetPage(0);
384
PoDoFo::PdfObject *piece = curPage->GetObject()->GetIndirectKey("PieceInfo");
387
PoDoFo::PdfObject *illy = piece->GetIndirectKey("Illustrator");
390
PoDoFo::PdfObject *priv = illy->GetIndirectKey("Private");
394
PoDoFo::PdfObject *numBl = priv->GetIndirectKey("NumBlock");
396
num = numBl->GetNumber() + 1;
399
QString name = "AIPrivateData%1";
400
QString Key = name.arg(1);
401
PoDoFo::PdfObject *data = priv->GetIndirectKey(PoDoFo::PdfName(Key.toUtf8().data()));
404
name = "AIPDFPrivateData%1";
406
data = priv->GetIndirectKey(PoDoFo::PdfName(Key.toUtf8().data()));
413
data = priv->GetIndirectKey(PoDoFo::PdfName(Key.toUtf8().data()));
414
PoDoFo::PdfStream const *stream = data->GetStream();
416
#if (PODOFO_MAJOR == 0 && PODOFO_MINOR >= 8)
417
PoDoFo::pdf_long bLen = 0;
418
#elif defined(pdf_long)
423
stream->GetFilteredCopy(&Buffer, &bLen);
424
outf.write(Buffer, bLen);
429
for (int a = 2; a < num; a++)
432
data = priv->GetIndirectKey(PoDoFo::PdfName(Key.toUtf8().data()));
435
PoDoFo::PdfStream const *stream = data->GetStream();
437
#if (PODOFO_MAJOR == 0 && PODOFO_MINOR >= 8)
438
PoDoFo::pdf_long bLen = 0;
439
#elif defined(pdf_long)
444
stream->GetFilteredCopy(&Buffer, &bLen);
445
outf.write(Buffer, bLen);
456
catch (PoDoFo::PdfError& e)
459
qDebug("Scribus caught and handled the following exception from PoDoFo while processing a PDF format ai file:\n----\n");
461
qDebug("----\nThe ai file could not be imported.\n");
462
QFile::remove(outfile);
469
bool AIPlug::decompressAIData(QString &fName)
471
QString f2 = fName+"_decom.ai";
472
FILE *source = fopen(fName.toLocal8Bit().constData(), "rb");
473
fseek(source, 20, SEEK_SET);
474
FILE *dest = fopen(f2.toLocal8Bit().constData(), "wb");
480
strm.zalloc = Z_NULL;
482
strm.opaque = Z_NULL;
484
strm.next_in = Z_NULL;
485
ret = inflateInit(&strm);
490
strm.avail_in = fread(in, 1, 4096, source);
493
(void)inflateEnd(&strm);
496
if (strm.avail_in == 0)
498
strm.next_in = (Bytef*)in;
501
strm.avail_out = 4096;
502
strm.next_out = (Bytef*)out;
503
ret = inflate(&strm, Z_NO_FLUSH);
504
assert(ret != Z_STREAM_ERROR);
511
(void)inflateEnd(&strm);
514
have = 4096 - strm.avail_out;
515
if (fwrite(out, 1, have, dest) != have || ferror(dest))
517
(void)inflateEnd(&strm);
521
while (strm.avail_out == 0);
523
while (ret != Z_STREAM_END);
524
(void)inflateEnd(&strm);
529
QFileInfo bF2(fName);
530
QString tmpFile = ScPaths::getTempFileDir()+ "/"+bF2.baseName()+"_tmp.ai";
531
moveFile(f2, tmpFile);
537
QFile::remove(fName);
543
bool AIPlug::parseHeader(QString fName, double &x, double &y, double &b, double &h)
545
QString tmp, BBox, tmp2, FarNam;
547
// double c, m, yc, k;
550
if (f.open(QIODevice::ReadOnly))
552
/* Try to find Bounding Box */
556
tmp = readLinefromDataStream(ts);
557
if (tmp.startsWith("%%BoundingBox:"))
560
BBox = tmp.remove("%%BoundingBox:");
564
if (tmp.startsWith("%%BoundingBox"))
567
BBox = tmp.remove("%%BoundingBox");
570
if (tmp.startsWith("%%HiResBoundingBox:"))
573
BBox = tmp.remove("%%HiResBoundingBox:");
575
if (tmp.startsWith("%%For"))
577
QStringList res = getStrings(tmp);
581
docOrganisation = res[1];
584
if (tmp.startsWith("%%CreationDate:"))
586
QStringList res = getStrings(tmp);
594
docDate = tmp.remove("%%CreationDate: ");
598
if (tmp.startsWith("%%Title"))
600
QStringList res = getStrings(tmp);
604
if (tmp.startsWith("%%EndComments"))
610
QStringList bb = BBox.split(" ", QString::SkipEmptyParts);
613
x = ScCLocale::toDoubleC(bb[0]);
614
y = ScCLocale::toDoubleC(bb[1]);
615
b = ScCLocale::toDoubleC(bb[2]);
616
h = ScCLocale::toDoubleC(bb[3]);
619
importColorsFromFile(fName, CustColors);
624
QString AIPlug::removeAIPrefix(QString comment)
627
if (comment.startsWith("%AI"))
629
int an = comment.indexOf("_");
630
tmp = comment.remove(0, an+1);
637
QString AIPlug::parseColor(QString data)
639
QString ret = CommonStrings::None;
644
ColorList::Iterator it;
645
ScTextStream Code(&data, QIODevice::ReadOnly);
651
int Cc = qRound(c * 255);
652
int Mc = qRound(m * 255);
653
int Yc = qRound(y * 255);
654
int Kc = qRound(k * 255);
656
tmp.setColor(Cc, Mc, Yc, Kc);
657
for (it = m_Doc->PageColors.begin(); it != m_Doc->PageColors.end(); ++it)
659
if (it.value().getColorModel() == colorModelCMYK)
661
it.value().getCMYK(&hC, &hM, &hY, &hK);
662
if ((Cc == hC) && (Mc == hM) && (Yc == hY) && (Kc == hK))
672
tmp.setSpotColor(false);
673
tmp.setRegistrationColor(false);
674
QString namPrefix = "FromAI";
675
m_Doc->PageColors.insert(namPrefix+tmp.name(), tmp);
676
// importedColors.append(namPrefix+tmp.name());
677
ret = namPrefix+tmp.name();
682
QString AIPlug::parseColorGray(QString data)
684
QString ret = CommonStrings::None;
689
ColorList::Iterator it;
690
ScTextStream Code(&data, QIODevice::ReadOnly);
693
int Kc = 255 - qRound(k * 255);
695
tmp.setColor(0, 0, 0, Kc);
696
for (it = m_Doc->PageColors.begin(); it != m_Doc->PageColors.end(); ++it)
698
if (it.value().getColorModel() == colorModelCMYK)
700
it.value().getCMYK(&hC, &hM, &hY, &hK);
701
if ((hC == 0) && (hM == 0) && (hY == 0) && (Kc == hK))
711
tmp.setSpotColor(false);
712
tmp.setRegistrationColor(false);
713
QString namPrefix = "FromAI";
714
m_Doc->PageColors.insert(namPrefix+tmp.name(), tmp);
715
// importedColors.append(namPrefix+tmp.name());
716
ret = namPrefix+tmp.name();
721
QString AIPlug::parseColorRGB(QString data)
723
QString ret = CommonStrings::None;
728
ColorList::Iterator it;
729
ScTextStream Code(&data, QIODevice::ReadOnly);
734
int Rc = qRound(r * 255);
735
int Gc = qRound(g * 255);
736
int Bc = qRound(b * 255);
738
tmp.setColorRGB(Rc, Gc, Bc);
739
for (it = m_Doc->PageColors.begin(); it != m_Doc->PageColors.end(); ++it)
741
if (it.value().getColorModel() == colorModelRGB)
743
it.value().getRGB(&hR, &hG, &hB);
744
if ((Rc == hR) && (Gc == hG) && (Bc == hB))
754
tmp.setSpotColor(false);
755
tmp.setRegistrationColor(false);
756
QString namPrefix = "FromAI";
757
m_Doc->PageColors.insert(namPrefix+tmp.name(), tmp);
758
// importedColors.append(namPrefix+tmp.name());
759
ret = namPrefix+tmp.name();
764
QString AIPlug::parseCustomColor(QString data, double &shade)
766
QString ret = CommonStrings::None;
769
double c, m, y, k, sh;
771
ColorList::Iterator it;
772
ScTextStream Code(&data, QIODevice::ReadOnly);
779
int an = data.indexOf("(");
780
int en = data.lastIndexOf(")");
781
QString FarNam = data.mid(an+1, en-an-1);
783
QString FarSha = data.mid(en+1, data.size() - en);
784
ScTextStream Val(&FarSha, QIODevice::ReadOnly);
786
shade = (1.0 - sh) * 100.0;
787
int Cc = qRound(c * 255);
788
int Mc = qRound(m * 255);
789
int Yc = qRound(y * 255);
790
int Kc = qRound(k * 255);
792
tmp.setColor(Cc, Mc, Yc, Kc);
793
for (it = m_Doc->PageColors.begin(); it != m_Doc->PageColors.end(); ++it)
795
if (it.value().getColorModel() == colorModelCMYK)
797
it.value().getCMYK(&hC, &hM, &hY, &hK);
798
if ((Cc == hC) && (Mc == hM) && (Yc == hY) && (Kc == hK))
808
tmp.setSpotColor(true);
809
tmp.setRegistrationColor(false);
810
m_Doc->PageColors.insert(FarNam, tmp);
811
// importedColors.append(FarNam);
817
QString AIPlug::parseCustomColorX(QString data, double &shade, QString type)
819
QString ret = CommonStrings::None;
822
double c, m, y, k, sh, r, g, b;
824
ColorList::Iterator it;
825
ScTextStream Code(&data, QIODevice::ReadOnly);
832
int Rc = qRound(r * 255);
833
int Gc = qRound(g * 255);
834
int Bc = qRound(b * 255);
836
tmp.setColorRGB(Rc, Gc, Bc);
837
for (it = m_Doc->PageColors.begin(); it != m_Doc->PageColors.end(); ++it)
839
if (it.value().getColorModel() == colorModelRGB)
841
it.value().getRGB(&hR, &hG, &hB);
842
if ((Rc == hR) && (Gc == hG) && (Bc == hB))
857
int Cc = qRound(c * 255);
858
int Mc = qRound(m * 255);
859
int Yc = qRound(y * 255);
860
int Kc = qRound(k * 255);
862
tmp.setColor(Cc, Mc, Yc, Kc);
863
for (it = m_Doc->PageColors.begin(); it != m_Doc->PageColors.end(); ++it)
865
if (it.value().getColorModel() == colorModelCMYK)
867
it.value().getCMYK(&hC, &hM, &hY, &hK);
868
if ((Cc == hC) && (Mc == hM) && (Yc == hY) && (Kc == hK))
878
int an = data.indexOf("(");
879
int en = data.lastIndexOf(")");
880
QString FarNam = data.mid(an+1, en-an-1);
882
QString FarSha = data.mid(en+1, data.size() - en);
883
ScTextStream Val(&FarSha, QIODevice::ReadOnly);
885
shade = (1.0 - sh) * 100.0;
889
tmp.setSpotColor(true);
890
tmp.setRegistrationColor(false);
891
m_Doc->PageColors.insert(FarNam, tmp);
892
// importedColors.append(FarNam);
898
QStringList AIPlug::getStrings(QString data)
908
for (int a = 0; a < data.count(); a++)
922
int code = tmp3.toInt(&ok, 8);
933
tmp = SpecialChars::PARSEP;
963
void AIPlug::getCommands(QString data, QStringList &commands)
971
for (int a = 0; a < data.count(); a++)
1014
if (commandList.contains(tmp2))
1016
commands.append(tmp3);
1025
if (!tmp2.isEmpty())
1028
commands.append(tmp3);
1032
void AIPlug::processData(QString data)
1034
double x, y, x1, y1, x2, y2;
1037
QString command = "";
1040
getCommands(data, da);
1041
for (int a = 0; a < da.count(); a++)
1044
if (((Cdata.startsWith("%")) || (Cdata.startsWith(" %"))) && (!meshMode))
1046
QStringList da2 = Cdata.split(" ", QString::SkipEmptyParts);
1047
if (da2.count() == 0)
1049
command = da2[da2.count()-1];
1050
/* Start Path construction commands */
1053
ScTextStream ts2(&Cdata, QIODevice::ReadOnly);
1055
Coords.svgMoveTo(x - docX, docHeight - (y - docY));
1056
currentPoint = FPoint(x - docX, docHeight - (y - docY));
1058
else if ((command == "L") || (command == "l"))
1060
ScTextStream ts2(&Cdata, QIODevice::ReadOnly);
1062
Coords.svgLineTo(x - docX, docHeight - (y - docY));
1063
currentPoint = FPoint(x - docX, docHeight - (y - docY));
1065
else if ((command == "C") || (command == "c"))
1067
ScTextStream ts2(&Cdata, QIODevice::ReadOnly);
1068
ts2 >> x >> y >> x1 >> y1 >> x2 >> y2;
1069
Coords.svgCurveToCubic(x - docX, docHeight - (y - docY),
1070
x1 - docX, docHeight - (y1 - docY),
1071
x2 - docX, docHeight - (y2 - docY));
1072
currentPoint = FPoint(x2 - docX, docHeight - (y2 - docY));
1074
else if ((command == "Y") || (command == "y"))
1076
ScTextStream ts2(&Cdata, QIODevice::ReadOnly);
1077
ts2 >> x1 >> y1 >> x2 >> y2;
1078
Coords.svgCurveToCubic(currentPoint.x(), currentPoint.y(),
1079
x1 - docX, docHeight - (y1 - docY),
1080
x2 - docX, docHeight - (y2 - docY));
1081
currentPoint = FPoint(x2 - docX, docHeight - (y2 - docY));
1083
else if ((command == "V") || (command == "v"))
1085
ScTextStream ts2(&Cdata, QIODevice::ReadOnly);
1086
ts2 >> x >> y >> x2 >> y2;
1087
Coords.svgCurveToCubic(x - docX, docHeight - (y - docY),
1088
currentPoint.x(), currentPoint.y(),
1089
x2 - docX, docHeight - (y2 - docY));
1090
currentPoint = FPoint(x2 - docX, docHeight - (y2 - docY));
1092
/* End Path construction commands */
1093
/* Start Object creation commands */
1094
else if ((command == "b") || (command == "B") || (command == "f") || (command == "F") || (command == "s") || (command == "S"))
1096
if (Coords.size() > 3)
1098
if ((!WasU) || ((WasU) && (FirstU)))
1100
if ((command == "B") || (command == "F") || (command == "S"))
1103
z = m_Doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, baseX, baseY, 10, 10, LineW, CurrColorFill, CommonStrings::None, true);
1104
else if (command == "B")
1105
z = m_Doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, baseX, baseY, 10, 10, LineW, CurrColorFill, CurrColorStroke, true);
1107
z = m_Doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, baseX, baseY, 10, 10, LineW, CommonStrings::None, CurrColorStroke, true);
1112
z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, baseX, baseY, 10, 10, LineW, CurrColorFill, CommonStrings::None, true);
1113
else if (command == "b")
1114
z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, baseX, baseY, 10, 10, LineW, CurrColorFill, CurrColorStroke, true);
1116
z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, baseX, baseY, 10, 10, LineW, CommonStrings::None, CurrColorStroke, true);
1118
ite = m_Doc->Items->at(z);
1119
ite->PoLine = Coords.copy();
1120
ite->PoLine.translate(m_Doc->currentPage()->xOffset(), m_Doc->currentPage()->yOffset());
1121
ite->ClipEdited = true;
1123
ite->setFillShade(CurrFillShade);
1124
ite->setLineShade(CurrStrokeShade);
1125
ite->setFillEvenOdd(fillRule);
1126
ite->setFillTransparency(1.0 - Opacity);
1127
ite->setLineTransparency(1.0 - Opacity);
1128
// ite->setFillBlendmode(blendMode);
1129
// ite->setLineBlendmode(blendMode);
1130
if (!currentPatternName.isEmpty())
1132
ite->setPattern(currentPatternName);
1133
ite->setPatternTransform(currentPatternXScale * 100, currentPatternYScale * 100, currentPatternX, currentPatternY, currentPatternRotation);
1135
currentPatternName = "";
1137
ite->setLineEnd(CapStyle);
1138
ite->setLineJoin(JoinStyle);
1139
if (importerFlags & LoadSavePlugin::lfCreateDoc)
1140
ite->setLocked(itemLocked);
1143
FPoint wh = getMaxClipF(&ite->PoLine);
1144
ite->setWidthHeight(wh.x(),wh.y());
1145
ite->setTextFlowMode(PageItem::TextFlowDisabled);
1146
m_Doc->AdjustItemSize(ite);
1149
PatternElements.append(ite);
1151
Elements.append(ite);
1152
if (groupStack.count() != 0)
1153
groupStack.top().append(ite);
1158
ite = m_Doc->Items->at(m_Doc->Items->count()-1);
1159
ite->PoLine.setMarker();
1160
Coords.translate(m_Doc->currentPage()->xOffset(), m_Doc->currentPage()->yOffset());
1161
ite->PoLine.putPoints(ite->PoLine.size(), Coords.size(), Coords);
1166
itemRendered = true;
1169
else if (command == "*u")
1174
else if (command == "*U")
1177
ite = m_Doc->Items->at(m_Doc->Items->count()-1);
1178
FPoint wh = getMaxClipF(&ite->PoLine);
1179
ite->setWidthHeight(wh.x(),wh.y());
1180
m_Doc->AdjustItemSize(ite);
1182
else if ((command == "u") || (command == "q"))
1184
QList<PageItem*> gElements;
1185
groupStack.push(gElements);
1187
else if ((command == "U") || (command == "Q"))
1189
if (groupStack.count() != 0)
1191
QList<PageItem*> gElements = groupStack.pop();
1193
if (gElements.count() > 0)
1195
for (int dre = 0; dre < gElements.count(); ++dre)
1197
tmpSel->addItem(gElements.at(dre), true);
1199
m_Doc->itemSelection_GroupObjects(false, false, tmpSel);
1200
ite = tmpSel->itemAt(0);
1201
if ((clipCoords.size() > 4) && (command == "Q"))
1203
ite = tmpSel->itemAt(0);
1204
clipCoords.translate(m_Doc->currentPage()->xOffset()-ite->xPos(), m_Doc->currentPage()->yOffset()-ite->yPos());
1205
ite->PoLine = clipCoords.copy();
1206
ite->PoLine.translate(baseX, baseY);
1209
PatternElements.append(ite);
1211
Elements.append(ite);
1213
if (groupStack.count() != 0)
1215
for (int as = 0; as < tmpSel->count(); ++as)
1217
groupStack.top().append(tmpSel->itemAt(as));
1224
clipCoords.resize(0);
1225
clipCoords.svgInit();
1228
else if (command == "W")
1230
if (clipCoords.size() > 0)
1231
clipCoords.setMarker();
1232
clipCoords.putPoints(clipCoords.size(), Coords.size(), Coords);
1234
/* End Object construction commands */
1235
/* Start Graphics state commands */
1236
else if (command == "A")
1238
ScTextStream ts2(&Cdata, QIODevice::ReadOnly);
1245
else if (command == "w")
1247
ScTextStream ts2(&Cdata, QIODevice::ReadOnly);
1250
else if (command == "j")
1252
ScTextStream ts2(&Cdata, QIODevice::ReadOnly);
1255
JoinStyle = Qt::MiterJoin;
1256
else if (tmpInt == 1)
1257
JoinStyle = Qt::RoundJoin;
1258
else if (tmpInt == 1)
1259
JoinStyle = Qt::BevelJoin;
1261
else if (command == "J")
1263
ScTextStream ts2(&Cdata, QIODevice::ReadOnly);
1266
CapStyle = Qt::FlatCap;
1267
else if (tmpInt == 1)
1268
CapStyle = Qt::RoundCap;
1269
else if (tmpInt == 1)
1270
CapStyle = Qt::SquareCap;
1272
/* undocumented Command Xy
1273
- has up to 5 Parameters
1274
- first Parameter might be the Blendmode
1275
- second Parameter is the Opacity
1277
else if (command == "Xy")
1279
ScTextStream ts2(&Cdata, QIODevice::ReadOnly);
1280
ts2 >> blendMode >> Opacity;
1282
else if (command == "XR")
1284
ScTextStream ts2(&Cdata, QIODevice::ReadOnly);
1291
else if (command == "Bb")
1293
gradientMode = true;
1295
itemRendered = false;
1296
startMatrix = QMatrix();
1297
endMatrix = QMatrix();
1299
else if (command == "Xm")
1301
ScTextStream gVals(&Cdata, QIODevice::ReadOnly);
1302
double m1, m2, m3, m4, m5, m6;
1303
gVals >> m1 >> m2 >> m3 >> m4 >> m5 >> m6;
1304
startMatrix.translate(m5, -m6);
1305
endMatrix.scale(m1, m4);
1308
else if (command == "Bm")
1310
if (m_gradients[currentGradientName].type() == 1)
1312
ScTextStream gVals(&Cdata, QIODevice::ReadOnly);
1313
double m1, m2, m3, m4, m5, m6;
1314
gVals >> m1 >> m2 >> m3 >> m4 >> m5 >> m6;
1315
startMatrix.translate(m5, -m6);
1316
// endMatrix.scale(m1, m4);
1317
endMatrix *= QMatrix(m1, m2, m3, m4, 0, 0);
1318
// endMatrix = QMatrix(m1, m2, m3, m4, m5, m6);
1322
else if (command == "BB")
1326
gradientMode = false;
1327
ite = m_Doc->Items->at(m_Doc->Items->count()-1);
1328
ite->fill_gradient = m_gradients[currentGradientName];
1329
if (ite->fill_gradient.type() == 0)
1334
m1.translate(currentGradientOrigin.x() - ite->xPos(), currentGradientOrigin.y() - ite->yPos());
1335
m1.translate(m_Doc->currentPage()->xOffset(), m_Doc->currentPage()->yOffset());
1336
m1.rotate(-currentGradientAngle);
1337
ite->GrStartX = currentGradientOrigin.x() - ite->xPos() + m_Doc->currentPage()->xOffset();
1338
ite->GrStartY = currentGradientOrigin.y() - ite->yPos() + m_Doc->currentPage()->yOffset();
1339
QPointF target = m1.map(QPointF(currentGradientLenght, 0.0));
1340
ite->GrEndX = target.x();
1341
ite->GrEndY = target.y();
1344
QPointF newS = startMatrix.map(QPointF(ite->GrStartX, ite->GrStartY));
1345
ite->GrStartX = newS.x();
1346
ite->GrStartY = newS.y();
1348
// m2.translate(ite->GrStartX, ite->GrStartY);
1349
m2.rotate(-currentGradientAngle);
1351
QPointF target = m2.map(QPointF(currentGradientLenght, 0.0));
1352
ite->GrEndX = target.x();
1353
ite->GrEndY = target.y();
1357
currentGradientMatrix = QMatrix();
1358
currentGradientOrigin = QPointF(0.0, 0.0);
1359
currentGradientAngle = 0.0;
1360
currentGradientLenght = 1.0;
1361
itemRendered = false;
1363
else if (command == "Bg")
1365
int an = Cdata.indexOf("(");
1366
int en = Cdata.lastIndexOf(")");
1367
currentGradientName = Cdata.mid(an+1, en-an-1);
1368
currentGradientName.remove("\\");
1369
QString tmpS = Cdata.mid(en+1, Cdata.size() - en);
1370
ScTextStream gVals(&tmpS, QIODevice::ReadOnly);
1371
double xOrig, yOrig, m1, m2, m3, m4, m5, m6;
1372
gVals >> xOrig >> yOrig >> currentGradientAngle >> currentGradientLenght >> m1 >> m2 >> m3 >> m4 >> m5 >> m6;
1373
currentGradientOrigin = QPointF(xOrig - docX, docHeight - (yOrig - docY));
1374
currentGradientMatrix = QMatrix(m1, m2, m3, m4, m5, m6);
1376
/* End Graphics state commands */
1377
/* Start Color commands */
1378
else if ((command == "G") || (command == "g"))
1381
CurrColorStroke = parseColorGray(Cdata);
1383
CurrColorFill = parseColorGray(Cdata);
1385
else if ((command == "K") || (command == "k"))
1388
CurrColorStroke = parseColor(Cdata);
1390
CurrColorFill = parseColor(Cdata);
1392
else if ((command == "XA") || (command == "Xa"))
1394
QString Xdata = da2[da2.count()-4] + " " + da2[da2.count()-3] + " " + da2[da2.count()-2];
1395
if (command == "XA")
1396
CurrColorStroke = parseColorRGB(Xdata);
1398
CurrColorFill = parseColorRGB(Xdata);
1400
else if ((command == "XX") || (command == "Xx") || (command == "Xk"))
1402
if (command == "XX")
1403
CurrColorStroke = parseCustomColorX(Cdata, CurrStrokeShade, da2[da2.count()-2]);
1405
CurrColorFill = parseCustomColorX(Cdata, CurrFillShade, da2[da2.count()-2]);
1407
else if ((command == "X") || (command == "x"))
1410
CurrColorStroke = parseCustomColor(Cdata, CurrStrokeShade);
1412
CurrColorFill = parseCustomColor(Cdata, CurrFillShade);
1414
else if (command == "p")
1416
int an = Cdata.indexOf("(");
1417
int en = Cdata.lastIndexOf(")");
1418
currentPatternName = Cdata.mid(an+1, en-an-1);
1419
currentPatternName.remove("\\");
1420
currentPatternName = currentPatternName.trimmed().simplified().replace(" ", "_");
1421
QString tmpS = Cdata.mid(en+1, Cdata.size() - en);
1422
ScTextStream gVals(&tmpS, QIODevice::ReadOnly);
1423
gVals >> currentPatternX >> currentPatternY >> currentPatternXScale >> currentPatternYScale >> currentPatternRotation;
1425
else if (command == "X!")
1427
if (Cdata.contains("/Mesh"))
1429
QList<PageItem*> gElements;
1430
groupStack.push(gElements);
1432
meshNodeCounter = 0;
1438
// meshBoundingPath = QPainterPath();
1440
if (Cdata.contains("/End"))
1443
if (groupStack.count() != 0)
1445
QList<PageItem*> gElements = groupStack.pop();
1447
if (gElements.count() > 0)
1449
for (int dre = 0; dre < gElements.count(); ++dre)
1451
tmpSel->addItem(gElements.at(dre), true);
1453
m_Doc->itemSelection_GroupObjects(false, false, tmpSel);
1454
ite = tmpSel->itemAt(0);
1455
/* if (!meshBoundingPath.isEmpty())
1457
ite = tmpSel->itemAt(0);
1458
clipCoords.fromQPainterPath(meshBoundingPath);
1459
clipCoords.translate(m_Doc->currentPage()->xOffset()-ite->xPos(), m_Doc->currentPage()->yOffset()-ite->yPos());
1460
ite->PoLine = clipCoords.copy();
1461
ite->PoLine.translate(baseX, baseY);
1464
PatternElements.append(ite);
1466
Elements.append(ite);
1468
if (groupStack.count() != 0)
1470
for (int as = 0; as < tmpSel->count(); ++as)
1472
groupStack.top().append(tmpSel->itemAt(as));
1479
else if (command == "X#")
1481
int an = Cdata.indexOf("_");
1482
QString cmdLine = Cdata.remove(0, an+1);
1483
an = cmdLine.lastIndexOf("/");
1484
QString tmpS = cmdLine.mid(an+1, Cdata.size());
1485
ScTextStream mVals(&tmpS, QIODevice::ReadOnly);
1490
int ans = cmdLine.indexOf("[");
1491
int ens = cmdLine.lastIndexOf("]");
1492
QString sizeVals = cmdLine.mid(ans+1, ens-ans-1);
1493
ScTextStream mVals2(&sizeVals, QIODevice::ReadOnly);
1494
mVals2 >> meshXSize >> meshYSize;
1498
int ans = cmdLine.indexOf("[");
1499
int ens = cmdLine.lastIndexOf("]");
1500
QString posVals = cmdLine.mid(ans+1, ens-ans-1);
1501
ScTextStream mVals3(&posVals, QIODevice::ReadOnly);
1502
mVals3 >> currentMeshXPos >> currentMeshYPos;
1510
if (Cdata.contains("CMYK"))
1512
else if (Cdata.contains("RGB"))
1518
ColorList::Iterator it;
1519
int Cc = qRound((accumColorC / 4.0) * 255);
1520
int Mc = qRound((accumColorM / 4.0) * 255);
1521
int Yc = qRound((accumColorY / 4.0) * 255);
1522
int Kc = qRound((accumColorK / 4.0) * 255);
1525
if (meshColorMode == 0)
1527
tmpColor.setColor(Cc, Mc, Yc, Kc);
1528
for (it = m_Doc->PageColors.begin(); it != m_Doc->PageColors.end(); ++it)
1530
if (it.value().getColorModel() == colorModelCMYK)
1532
it.value().getCMYK(&hC, &hM, &hY, &hK);
1533
if ((Cc == hC) && (Mc == hM) && (Yc == hY) && (Kc == hK))
1535
CurrColorFill = it.key();
1544
tmpColor.setColorRGB(Cc, Mc, Yc);
1545
for (it = m_Doc->PageColors.begin(); it != m_Doc->PageColors.end(); ++it)
1547
if (it.value().getColorModel() == colorModelRGB)
1549
it.value().getRGB(&hC, &hM, &hY);
1550
if ((Cc == hC) && (Mc == hM) && (Yc == hY))
1552
CurrColorFill = it.key();
1561
tmpColor.setSpotColor(false);
1562
tmpColor.setRegistrationColor(false);
1563
QString namPrefix = "FromAI";
1564
m_Doc->PageColors.insert(namPrefix+tmpColor.name(), tmpColor);
1565
CurrColorFill = namPrefix+tmpColor.name();
1567
meshNodeCounter = 0;
1570
Coords.svgMoveTo(meshNode1PointX, meshNode1PointY);
1571
Coords.svgCurveToCubic(meshNode1Control2X, meshNode1Control2Y, meshNode2Control1X, meshNode2Control1Y, meshNode2PointX, meshNode2PointY);
1572
Coords.svgCurveToCubic(meshNode2Control2X, meshNode2Control2Y, meshNode3Control1X, meshNode3Control1Y, meshNode3PointX, meshNode3PointY);
1573
Coords.svgCurveToCubic(meshNode3Control2X, meshNode3Control2Y, meshNode4Control1X, meshNode4Control1Y, meshNode4PointX, meshNode4PointY);
1574
Coords.svgCurveToCubic(meshNode4Control2X, meshNode4Control2Y, meshNode1Control1X, meshNode1Control1Y, meshNode1PointX, meshNode1PointY);
1575
z = m_Doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, baseX, baseY, 10, 10, 0, CurrColorFill, CurrColorFill, true);
1576
ite = m_Doc->Items->at(z);
1577
ite->PoLine = Coords.copy();
1578
// QPainterPath tmpPath = Coords.toQPainterPath(true);
1579
// meshBoundingPath = meshBoundingPath.united(tmpPath);
1580
ite->PoLine.translate(m_Doc->currentPage()->xOffset(), m_Doc->currentPage()->yOffset());
1581
ite->ClipEdited = true;
1583
ite->setFillShade(CurrFillShade);
1584
ite->setLineShade(CurrFillShade);
1585
ite->setFillEvenOdd(fillRule);
1586
ite->setFillTransparency(1.0 - Opacity);
1587
ite->setLineTransparency(1.0 - Opacity);
1588
ite->setLineEnd(CapStyle);
1589
ite->setLineJoin(JoinStyle);
1590
if (importerFlags & LoadSavePlugin::lfCreateDoc)
1591
ite->setLocked(itemLocked);
1592
FPoint wh = getMaxClipF(&ite->PoLine);
1593
ite->setWidthHeight(wh.x(),wh.y());
1594
ite->setTextFlowMode(PageItem::TextFlowDisabled);
1595
m_Doc->AdjustItemSize(ite);
1597
PatternElements.append(ite);
1599
Elements.append(ite);
1600
if (groupStack.count() != 0)
1601
groupStack.top().append(ite);
1607
double cVal, mVal, yVal, kVal, coorX1, coorY1, coorX2, coorY2, coorX3, coorY3;
1610
int ans = cmdLine.indexOf("[");
1611
int ens = cmdLine.lastIndexOf("]");
1612
QString nodeVals = cmdLine.mid(ans+1, ens-ans-1);
1613
ScTextStream mVals4(&nodeVals, QIODevice::ReadOnly);
1615
if (meshColorMode == 0)
1616
mVals4 >> cVal >> mVal >> yVal >> kVal >> coorX1 >> coorY1 >> coorX2 >> coorY2 >> dummy >> coorX3 >> coorY3;
1618
mVals4 >> cVal >> mVal >> yVal >> coorX1 >> coorY1 >> coorX2 >> coorY2 >> dummy >> coorX3 >> coorY3;
1619
accumColorC += cVal;
1620
accumColorM += mVal;
1621
accumColorY += yVal;
1622
accumColorK += kVal;
1623
if (meshNodeCounter == 1)
1625
meshNode1PointX = coorX1 - docX;
1626
meshNode1PointY = docHeight - (coorY1 - docY);
1627
meshNode1Control2X = coorX2 - docX;
1628
meshNode1Control2Y = docHeight - (coorY2 - docY);
1629
meshNode1Control1X = coorX3 - docX;
1630
meshNode1Control1Y = docHeight - (coorY3 - docY);
1632
if (meshNodeCounter == 2)
1634
meshNode2PointX = coorX1 - docX;
1635
meshNode2PointY = docHeight - (coorY1 - docY);
1636
meshNode2Control2X = coorX2 - docX;
1637
meshNode2Control2Y = docHeight - (coorY2 - docY);
1638
meshNode2Control1X = coorX3 - docX;
1639
meshNode2Control1Y = docHeight - (coorY3 - docY);
1641
if (meshNodeCounter == 3)
1643
meshNode3PointX = coorX1 - docX;
1644
meshNode3PointY = docHeight - (coorY1 - docY);
1645
meshNode3Control2X = coorX2 - docX;
1646
meshNode3Control2Y = docHeight - (coorY2 - docY);
1647
meshNode3Control1X = coorX3 - docX;
1648
meshNode3Control1Y = docHeight - (coorY3 - docY);
1650
if (meshNodeCounter == 4)
1652
meshNode4PointX = coorX1 - docX;
1653
meshNode4PointY = docHeight - (coorY1 - docY);
1654
meshNode4Control2X = coorX2 - docX;
1655
meshNode4Control2Y = docHeight - (coorY2 - docY);
1656
meshNode4Control1X = coorX3 - docX;
1657
meshNode4Control1Y = docHeight - (coorY3 - docY);
1661
/* End Color commands */
1662
/* Start Layer commands */
1663
else if (command == "Lb")
1665
if (importerFlags & LoadSavePlugin::lfCreateDoc)
1667
int visible, preview, enabled, printing, dummy, rc, gc, bc;
1668
ScTextStream ts2(&Cdata, QIODevice::ReadOnly);
1669
ts2 >> visible >> preview >> enabled >> printing >> dummy >> dummy >> dummy >> rc >> gc >> bc;
1671
currentLayer = m_Doc->addLayer("Layer", true);
1672
m_Doc->setLayerVisible(currentLayer, static_cast<bool>(visible));
1673
m_Doc->setLayerOutline(currentLayer, static_cast<bool>(!preview));
1674
m_Doc->setLayerLocked(currentLayer, static_cast<bool>(!enabled));
1675
m_Doc->setLayerPrintable(currentLayer, static_cast<bool>(printing));
1676
m_Doc->setLayerMarker(currentLayer, QColor(rc, gc, bc));
1682
else if (command == "LB")
1687
else if (command == "Ln")
1689
if (importerFlags & LoadSavePlugin::lfCreateDoc)
1691
int an = Cdata.indexOf("(");
1692
int en = Cdata.lastIndexOf(")");
1693
QString LayerNam = Cdata.mid(an+1, en-an-1);
1694
LayerNam.remove("\\");
1695
m_Doc->changeLayerName(currentLayer, LayerNam);
1698
/* End Layer commands */
1699
/* Start Text commands */
1700
else if (command == "To")
1702
ScTextStream ts2(&Cdata, QIODevice::ReadOnly);
1705
textMatrix = QMatrix();
1710
startCurrentTextRange = 0;
1711
endCurrentTextRange = 0;
1715
else if (command == "Tp")
1717
ScTextStream gVals(&Cdata, QIODevice::ReadOnly);
1718
double m1, m2, m3, m4, m5, m6;
1719
gVals >> m1 >> m2 >> m3 >> m4 >> m5 >> m6;
1720
textMatrix = QMatrix(m1, m2, m3, m4, m5, m6);
1722
else if (command == "Tx") // || (command == "TX"))
1724
QStringList res = getStrings(Cdata);
1725
if (res.count() > 0)
1727
QString tex = res[0];
1729
startCurrentTextRange = textData.length();
1730
for (int tt = 0; tt < tex.length(); ++tt)
1733
QString ch = tex.mid(tt,1);
1734
nstyle.setFont((*m_Doc->AllFonts)[textFont]);
1735
nstyle.setFontSize(textSize);
1736
nstyle.setFillColor(CurrColorFill);
1737
nstyle.setTracking(textKern);
1738
nstyle.setFillShade(100);
1739
nstyle.setStrokeColor(CurrColorStroke);
1740
nstyle.setStrokeShade(100);
1741
nstyle.setScaleH(textScaleH);
1742
nstyle.setScaleV(textScaleV);
1743
nstyle.setBaselineOffset(0);
1744
nstyle.setShadowXOffset(50);
1745
nstyle.setShadowYOffset(-50);
1746
nstyle.setOutlineWidth(10);
1747
nstyle.setUnderlineOffset(-1);
1748
nstyle.setUnderlineWidth(-1);
1749
nstyle.setStrikethruOffset(-1);
1750
nstyle.setStrikethruWidth(-1);
1751
nstyle.setFeatures(StyleFlag(ScStyle_Default).featureList());
1752
int pot = textData.length();
1753
textData.insertChars(pot, ch);
1754
textData.applyCharStyle(pot, 1, nstyle);
1755
tempW += nstyle.font().realCharWidth(ch[0], nstyle.fontSize() / 10.0)+1;
1756
tempH = qMax(tempH, nstyle.font().height(nstyle.fontSize() / 10.0) + 2.0);
1757
maxWidth = qMax(tempW, maxWidth);
1758
maxHeight = qMax(tempH, maxHeight);
1759
if ((ch == SpecialChars::PARSEP) || (ch == SpecialChars::LINEBREAK))
1761
maxHeight += nstyle.font().height(nstyle.fontSize() / 10.0);
1764
endCurrentTextRange = pot;
1768
else if (command == "Tk")
1772
ScTextStream gVals(&Cdata, QIODevice::ReadOnly);
1773
gVals >> flag >> val;
1776
double oldval = textData.charStyle(startCurrentTextRange).tracking();
1777
CharStyle nstyle = textData.charStyle(startCurrentTextRange);
1778
nstyle.setTracking(oldval + val);
1779
textData.applyCharStyle(startCurrentTextRange, 1, nstyle);
1781
else if (command == "Tc")
1783
ScTextStream gVals(&Cdata, QIODevice::ReadOnly);
1787
else if (command == "Tz")
1789
ScTextStream gVals(&Cdata, QIODevice::ReadOnly);
1790
gVals >> textScaleH >> textScaleV;
1794
else if (command == "T*")
1797
QString ch = SpecialChars::LINEBREAK;
1798
nstyle.setFont((*m_Doc->AllFonts)[textFont]);
1799
nstyle.setFontSize(textSize);
1800
nstyle.setFillColor(CurrColorFill);
1801
nstyle.setTracking(textKern);
1802
nstyle.setFillShade(100);
1803
nstyle.setStrokeColor(CurrColorStroke);
1804
nstyle.setStrokeShade(100);
1805
nstyle.setScaleH(textScaleH);
1806
nstyle.setScaleV(textScaleV);
1807
nstyle.setBaselineOffset(0);
1808
nstyle.setShadowXOffset(50);
1809
nstyle.setShadowYOffset(-50);
1810
nstyle.setOutlineWidth(10);
1811
nstyle.setUnderlineOffset(-1);
1812
nstyle.setUnderlineWidth(-1);
1813
nstyle.setStrikethruOffset(-1);
1814
nstyle.setStrikethruWidth(-1);
1815
nstyle.setFeatures(StyleFlag(ScStyle_Default).featureList());
1816
int pot = textData.length();
1817
textData.insertChars(pot, ch);
1818
textData.applyCharStyle(pot, 1, nstyle);
1819
maxHeight += nstyle.font().height(nstyle.fontSize() / 10.0) + 2.0;
1822
else if (command == "Tf")
1824
ScTextStream gVals(&Cdata, QIODevice::ReadOnly);
1825
gVals >> textFont >> textSize;
1826
textFont.remove(0, 2);
1827
QString family = textFont;
1829
family.replace( QRegExp( "'" ) , QChar( ' ' ) );
1830
textFont = m_Doc->toolSettings.defFont;
1832
SCFontsIterator it(PrefsManager::instance()->appPrefs.AvailFonts);
1833
for ( ; it.hasNext(); it.next())
1836
QString fn = it.current().scName();
1837
int pos = fn.indexOf(" ");
1849
if (!PrefsManager::instance()->appPrefs.GFontSub.contains(family))
1851
qApp->changeOverrideCursor(QCursor(Qt::ArrowCursor));
1852
MissingFont *dia = new MissingFont(0, family, m_Doc);
1854
QString tmpf = dia->getReplacementFont();
1856
qApp->changeOverrideCursor(QCursor(Qt::WaitCursor));
1857
PrefsManager::instance()->appPrefs.GFontSub[family] = tmpf;
1860
textFont = PrefsManager::instance()->appPrefs.GFontSub[family];
1864
else if (command == "TO")
1866
if (textData.length() > 0)
1868
if (!((textData.length() == 1) && (textData.text(0) == SpecialChars::PARSEP)))
1870
QPointF pos = QPointF(textMatrix.dx(), textMatrix.dy());
1871
pos += QPointF(m_Doc->currentPage()->xOffset(), -m_Doc->currentPage()->yOffset());
1872
pos += QPointF(0.0, textSize / 10.0 + 2.0);
1873
z = m_Doc->itemAdd(PageItem::TextFrame, PageItem::Unspecified, pos.x() - docX, docHeight - (pos.y() - docY), 10, 10, 0, CommonStrings::None, CommonStrings::None, true);
1874
ite = m_Doc->Items->at(z);
1875
ite->setTextToFrameDist(0.0, 0.0, 0.0, 0.0);
1876
ite->itemText.append(textData);
1877
double xpos = ite->xPos();
1878
double ypos = ite->yPos();
1879
ite->setWidthHeight(qMax(ite->width(), maxWidth), qMax(ite->height(), maxHeight));
1880
double xoffset = 0.0, yoffset = 0.0;
1881
double rotation = getRotationFromMatrix(textMatrix, 0.0);
1882
if (rotation != 0.0)
1884
double temp = textSize / 10.0 + 2.0;
1885
xoffset = sin(rotation) * temp;
1886
yoffset = cos(rotation) * temp;
1888
ite->setXPos(xpos + xoffset);
1889
ite->setYPos(ypos + yoffset);
1890
ite->setRotation(rotation * 180 / M_PI);
1891
ite->SetRectFrame();
1892
m_Doc->setRedrawBounding(ite);
1893
ite->Clip = FlattenPath(ite->PoLine, ite->Segments);
1894
ite->setTextFlowMode(PageItem::TextFlowDisabled);
1895
ite->setFillShade(CurrFillShade);
1896
ite->setLineShade(CurrStrokeShade);
1897
ite->setFillEvenOdd(fillRule);
1898
ite->setFillTransparency(1.0 - Opacity);
1899
ite->setLineTransparency(1.0 - Opacity);
1900
ite->setLineEnd(CapStyle);
1901
ite->setLineJoin(JoinStyle);
1902
if (importerFlags & LoadSavePlugin::lfCreateDoc)
1903
ite->setLocked(itemLocked);
1905
PatternElements.append(ite);
1907
Elements.append(ite);
1908
if (groupStack.count() != 0)
1909
groupStack.top().append(ite);
1913
/* End Text commands */
1914
/* Start special Commands */
1915
else if (command == "*")
1920
else if ((command == "N") || (command == "n"))
1925
else if (command == "[")
1929
int an = Cdata.indexOf("(");
1930
int en = Cdata.lastIndexOf(")");
1931
if ((an != -1) && (en != -1))
1934
currentPatternDefName = Cdata.mid(an+1, en-an-1);
1935
currentPatternDefName.remove("\\");
1936
currentPatternDefName = currentPatternDefName.trimmed().simplified().replace(" ", "_");
1937
QString tmpS = Cdata.mid(en+1, Cdata.size() - en);
1938
ScTextStream gVals(&tmpS, QIODevice::ReadOnly);
1939
gVals >> patternX1 >> patternY1 >> patternX2 >> patternY2;
1942
/* End special Commands */
1943
/* Skip everything else */
1949
void AIPlug::processGradientData(QString data)
1951
QString command = "";
1954
getCommands(data, da);
1955
for (int a = 0; a < da.count(); a++)
1958
QStringList da2 = Cdata.split(" ", QString::SkipEmptyParts);
1959
command = da2[da2.count()-1];
1960
if (command == "Bd")
1962
QString tmpS = Cdata;
1963
int an = Cdata.indexOf("(");
1964
int en = Cdata.lastIndexOf(")");
1965
currentGradientName = Cdata.mid(an+1, en-an-1);
1966
currentGradientName.remove("\\");
1967
if (da2[da2.count()-3] == "0")
1968
currentGradient = VGradient(VGradient::linear);
1970
currentGradient = VGradient(VGradient::radial);
1971
currentGradient.clearStops();
1973
else if ((command == "%_Bs") || (command == "%_BS"))
1975
QString stopName = "";
1976
double stop = ScCLocale::toDoubleC(da2[da2.count()-2]) / 100.0;
1977
double colorShade = 100.0;
1978
int colortype = da2[da2.count()-4].toInt();
1981
stopName = parseColorGray(Cdata);
1982
const ScColor& gradC = m_Doc->PageColors[stopName];
1983
currentGradient.addStop( ScColorEngine::getRGBColor(gradC, m_Doc), stop, 0.5, 1.0, stopName, 100 );
1985
else if (colortype == 1)
1987
stopName = parseColor(Cdata);
1988
const ScColor& gradC = m_Doc->PageColors[stopName];
1989
currentGradient.addStop( ScColorEngine::getRGBColor(gradC, m_Doc), stop, 0.5, 1.0, stopName, 100 );
1991
else if (colortype == 2)
1993
stopName = parseColor(Cdata);
1994
const ScColor& gradC = m_Doc->PageColors[stopName];
1995
currentGradient.addStop( ScColorEngine::getRGBColor(gradC, m_Doc), stop, 0.5, 1.0, stopName, 100 );
1997
else if (colortype == 3)
1999
stopName = parseCustomColor(Cdata, colorShade);
2000
const ScColor& gradC = m_Doc->PageColors[stopName];
2001
currentGradient.addStop( ScColorEngine::getRGBColor(gradC, m_Doc), stop, 0.5, 1.0, stopName, qRound(colorShade));
2003
else if (colortype == 4)
2005
stopName = parseCustomColorX(Cdata, colorShade, "0");
2006
const ScColor& gradC = m_Doc->PageColors[stopName];
2007
currentGradient.addStop( ScColorEngine::getRGBColor(gradC, m_Doc), stop, 0.5, 1.0, stopName, qRound(colorShade));
2010
else if (command == "BD")
2012
m_gradients.insert(currentGradientName, currentGradient);
2013
currentGradient = VGradient(VGradient::linear);
2014
currentGradient.clearStops();
2015
currentGradient.setRepeatMethod( VGradient::none );
2016
currentGradientName = "";
2021
void AIPlug::processPattern(QDataStream &ts)
2024
QString tmpData = "";
2027
tmp = removeAIPrefix(readLinefromDataStream(ts));
2030
if (tmp == "EndPattern")
2033
if (PatternElements.count() > 0)
2035
for (int dre = 0; dre < PatternElements.count(); ++dre)
2037
tmpSel->addItem(PatternElements.at(dre), true);
2039
if (PatternElements.count() > 1)
2040
m_Doc->itemSelection_GroupObjects(false, false, tmpSel);
2041
ScPattern pat = ScPattern();
2043
PageItem* currItem = tmpSel->itemAt(0);
2044
currItem->setItemName(currentPatternDefName);
2045
currItem->AutoName = false;
2046
m_Doc->DoDrawing = true;
2047
QImage tmpImg = currItem->DrawObj_toImage();
2048
QImage retImg = QImage(qRound(patternX2 - patternX1), qRound(patternY2 - patternY1), QImage::Format_ARGB32);
2049
retImg.fill( qRgba(255, 255, 255, 0) );
2052
if (PatternElements.count() > 1)
2053
p.drawImage(qRound(-patternX1), qRound(-patternY1), tmpImg);
2055
p.drawImage(0, 0, tmpImg);
2057
pat.pattern = retImg;
2058
// pat.pattern = currItem->DrawObj_toImage();
2059
m_Doc->DoDrawing = false;
2060
// pat.width = currItem->gWidth;
2061
// pat.height = currItem->gHeight;
2062
pat.width = patternX2 - patternX1;
2063
pat.height = patternY2 - patternY1;
2064
pat.xoffset = -patternX1;
2065
pat.yoffset = -patternY1;
2066
for (int as = 0; as < tmpSel->count(); ++as)
2068
PageItem* Neu = tmpSel->itemAt(as);
2069
Neu->moveBy(-patternX1, -patternY1, true);
2070
Neu->gXpos -= patternX1;
2071
Neu->gYpos -= patternY1;
2072
pat.items.append(Neu);
2074
m_Doc->itemSelection_DeleteItem(tmpSel);
2075
m_Doc->addPattern(currentPatternDefName, pat);
2077
PatternElements.clear();
2078
currentPatternDefName = "";
2081
else if (tmp.startsWith("Tile"))
2083
else if (tmp.contains(") @"))
2086
tmpData.remove(") @");
2087
processData(tmpData);
2090
else if (tmp.contains(") &"))
2093
tmpData.remove(") &");
2094
processData(tmpData);
2099
if (tmp.startsWith("("))
2104
else if (tmp == "EndPattern")
2106
PatternElements.clear();
2107
currentPatternDefName = "";
2113
patternMode = false;
2116
void AIPlug::processRaster(QDataStream &ts)
2118
double m1, m2, m3, m4, m5, m6, x1, y1, x2, y2, dummy;
2119
int w, h, type, alpha, bin, bits;
2121
QString cumulated = "";
2124
tmp = readLinefromDataStream(ts);
2125
if (tmp.startsWith("%"))
2130
cumulated += " " + tmp;
2134
getCommands(cumulated, da);
2135
Cdata = da[da.count()-1];
2136
ScTextStream gVals(&Cdata, QIODevice::ReadOnly);
2137
gVals >> m1 >> m2 >> m3 >> m4 >> m5 >> m6 >> x1 >> y1 >> x2 >> y2 >> w >> h >> bits >> type >> alpha >> dummy >> bin;
2138
// qDebug() << QString("Matrix: %1 %2 %3 %4 %5 %6").arg(m1).arg(m2).arg(m3).arg(m4).arg(m5).arg(m6);
2139
// qDebug() << QString("Bounds: %1 %2 %3 %4").arg(x1).arg(y1).arg(x2).arg(y2);
2140
// qDebug() << QString("Size: %1 %2").arg(w).arg(h);
2141
// qDebug() << QString("Bits: %1").arg(bits);
2142
// qDebug() << QString("Typ: %1").arg(type);
2143
// qDebug() << QString("Alpha-Channels: %1").arg(alpha);
2144
// qDebug() << QString("Encoding: %1").arg(bin);
2145
uint dataSize = w * h * (type + alpha);
2146
uint alphaData = w * h * type;
2150
if (tmp.startsWith("%%BeginData"))
2153
ScTextStream gVals2(&tmp, QIODevice::ReadOnly);
2154
tmp = readLinefromDataStream(ts);
2157
psdata.resize(dataSize);
2162
m_image.create(w, 1, 5);
2164
m_image.create(w, 1, 4);
2169
m_image.create(w, 1, 4);
2171
m_image.create(w, 1, 3);
2174
if (bin == 0) // 0 = ASCII encoded data
2176
uint dataPointer = 0;
2180
tmp = readLinefromDataStream(ts);
2182
if (tmp.startsWith("%AI5_EndRaster"))
2184
for (int a = 1; a < tmp.length(); a += 2)
2187
ushort data = tmp.mid(a, 2).toUShort(&ok, 16);
2188
psdata[dataPointer++] = data;
2194
psdata.resize(dataSize);
2195
ts.readRawData(psdata.data(), dataSize);
2197
QMatrix imgMatrix = QMatrix(m1, m2, m3, m4, m5, m6);
2198
QPointF pos = QPointF(imgMatrix.dx(), imgMatrix.dy());
2199
pos += QPointF(m_Doc->currentPage()->xOffset(), -m_Doc->currentPage()->yOffset());
2200
pos += QPointF(baseX, -baseY);
2201
int z = m_Doc->itemAdd(PageItem::ImageFrame, PageItem::Unspecified, pos.x() - docX, docHeight - (pos.y() - docY), 10, 10, 0, CurrColorFill, CurrColorStroke, true);
2202
PageItem* ite = m_Doc->Items->at(z);
2203
ite->setWidthHeight(w * m1, h * m4);
2204
double rotation = getRotationFromMatrix(imgMatrix, 0.0);
2205
ite->setRotation(rotation * 180 / M_PI);
2206
ite->SetRectFrame();
2207
m_Doc->setRedrawBounding(ite);
2208
ite->Clip = FlattenPath(ite->PoLine, ite->Segments);
2209
ite->setTextFlowMode(PageItem::TextFlowDisabled);
2210
ite->setFillShade(CurrFillShade);
2211
ite->setLineShade(CurrStrokeShade);
2212
ite->setFillEvenOdd(fillRule);
2213
ite->setFillTransparency(1.0 - Opacity);
2214
ite->setLineTransparency(1.0 - Opacity);
2215
ite->setLineEnd(CapStyle);
2216
ite->setLineJoin(JoinStyle);
2219
ite->tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_ai_XXXXXX.tif");
2220
ite->tempImageFile->open();
2221
QString imgName = getLongPathName(ite->tempImageFile->fileName());
2222
ite->tempImageFile->close();
2223
ite->isInlineImage = true;
2224
TIFF* tif = TIFFOpen(imgName.toLocal8Bit().data(), "w");
2227
TIFFSetField(tif, TIFFTAG_IMAGEWIDTH, w);
2228
TIFFSetField(tif, TIFFTAG_IMAGELENGTH, h);
2229
TIFFSetField(tif, TIFFTAG_BITSPERSAMPLE, 8);
2230
TIFFSetField(tif, TIFFTAG_SAMPLESPERPIXEL, m_image.channels());
2231
TIFFSetField(tif, TIFFTAG_PLANARCONFIG, PLANARCONFIG_CONTIG);
2233
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_SEPARATED);
2235
TIFFSetField(tif, TIFFTAG_PHOTOMETRIC, PHOTOMETRIC_RGB);
2236
TIFFSetField(tif, TIFFTAG_COMPRESSION, COMPRESSION_LZW);
2237
for (int y = 0; y < h; ++y)
2239
p = m_image.scanLine( 0 );
2240
for (int xh = 0; xh < m_image.width(); ++xh )
2242
p[0] = psdata[yCount++];
2245
p[1] = psdata[yCount++];
2246
p[2] = psdata[yCount++];
2248
p[3] = psdata[yCount++];
2258
p[4] = psdata[alphaData++];
2260
p[3] = psdata[alphaData++];
2262
p += m_image.channels();
2264
TIFFWriteScanline(tif, m_image.scanLine(0), y);
2268
m_Doc->LoadPict(imgName, z);
2269
if (ite->PictureIsAvailable)
2270
ite->setImageXYScale(ite->width() / ite->pixm.width(), ite->height() / ite->pixm.height());
2271
if (importerFlags & LoadSavePlugin::lfCreateDoc)
2272
ite->setLocked(itemLocked);
2274
PatternElements.append(ite);
2276
Elements.append(ite);
2277
if (groupStack.count() != 0)
2278
groupStack.top().append(ite);
2281
void AIPlug::processComment(QDataStream &ts, QString comment)
2283
QString tmp = removeAIPrefix(comment);
2284
if (tmp.startsWith("Begin_NonPrinting"))
2288
tmp = removeAIPrefix(readLinefromDataStream(ts));
2289
if (tmp.startsWith("BeginGradient"))
2293
tmp = removeAIPrefix(readLinefromDataStream(ts));
2294
if (tmp.startsWith("EndGradient"))
2297
processGradientData(tmp);
2300
if (tmp.startsWith("BeginPattern:"))
2302
if (tmp.startsWith("End_NonPrinting"))
2304
progressDialog->setProgress("GI", ts.device()->pos());
2305
qApp->processEvents();
2308
else if (tmp.startsWith("BeginPattern:"))
2310
else if (tmp.startsWith("BeginGradient"))
2314
tmp = removeAIPrefix(readLinefromDataStream(ts));
2315
if (tmp.startsWith("EndGradient"))
2318
processGradientData(tmp);
2319
progressDialog->setProgress("GI", ts.device()->pos());
2320
qApp->processEvents();
2323
else if (tmp.startsWith("BeginPalette"))
2327
tmp = removeAIPrefix(readLinefromDataStream(ts));
2328
if (tmp.startsWith("EndPalette"))
2330
progressDialog->setProgress("GI", ts.device()->pos());
2331
qApp->processEvents();
2334
else if (tmp.startsWith("BeginSymbol"))
2338
tmp = removeAIPrefix(readLinefromDataStream(ts));
2339
if (tmp.startsWith("EndSymbol"))
2341
progressDialog->setProgress("GI", ts.device()->pos());
2342
qApp->processEvents();
2345
else if (tmp.startsWith("BeginDocumentData"))
2349
tmp = removeAIPrefix(readLinefromDataStream(ts));
2350
if (tmp.startsWith("EndDocumentData"))
2352
progressDialog->setProgress("GI", ts.device()->pos());
2353
qApp->processEvents();
2356
else if (tmp.startsWith("%%BeginProlog"))
2360
tmp = removeAIPrefix(readLinefromDataStream(ts));
2361
if (tmp.startsWith("%%EndProlog"))
2363
progressDialog->setProgress("GI", ts.device()->pos());
2364
qApp->processEvents();
2367
else if (tmp.startsWith("%%BeginData"))
2371
tmp = removeAIPrefix(readLinefromDataStream(ts));
2372
if (tmp.startsWith("%%EndData"))
2374
progressDialog->setProgress("GI", ts.device()->pos());
2375
qApp->processEvents();
2378
else if (tmp.startsWith("%%BeginCrops"))
2382
tmp = removeAIPrefix(readLinefromDataStream(ts));
2383
if (tmp.startsWith("%%EndCrops"))
2385
progressDialog->setProgress("GI", ts.device()->pos());
2386
qApp->processEvents();
2389
else if (tmp.startsWith("BeginRaster"))
2392
progressDialog->setProgress("GI", ts.device()->pos());
2393
qApp->processEvents();
2395
else if (tmp.startsWith("BeginLayer"))
2399
tmp = removeAIPrefix(readLinefromDataStream(ts));
2400
if (tmp.startsWith("BeginRaster"))
2405
if (tmp.startsWith("EndLayer"))
2409
progressDialog->setProgress("GI", ts.device()->pos());
2410
qApp->processEvents();
2415
bool AIPlug::convert(QString fn)
2421
CurrColorFill = "White";
2422
CurrFillShade = 100.0;
2423
CurrColorStroke = "Black";
2424
CurrStrokeShade = 100.0;
2425
JoinStyle = Qt::MiterJoin;
2426
CapStyle = Qt::FlatCap;
2427
DashPattern.clear();
2433
patternMode = false;
2442
clipCoords.resize(0);
2443
clipCoords.svgInit();
2444
currentPoint = FPoint(0.0, 0.0);
2446
currentGradient = VGradient(VGradient::linear);
2447
currentGradient.clearStops();
2448
currentGradient.setRepeatMethod( VGradient::none );
2449
currentGradientName = "";
2450
currentGradientMatrix = QMatrix();
2451
currentGradientOrigin = QPointF(0.0, 0.0);
2452
currentGradientAngle = 0.0;
2453
currentGradientLenght = 1.0;
2454
currentPatternName = "";
2455
currentPatternX = 0.0;
2456
currentPatternY = 0.0;
2457
currentPatternXScale = 1.0;
2458
currentPatternYScale = 1.0;
2459
currentPatternRotation = 0.0;
2460
QList<PageItem*> gElements;
2461
groupStack.push(gElements);
2462
commandList << "m" << "l" << "L" << "c" << "C" << "v" << "V" << "y" << "Y"; // Path construction
2463
commandList << "b" << "B" << "f" << "F" << "s" << "S" << "*u" << "*U"; // Object creation
2464
commandList << "u" << "U" << "W" << "q" << "Q"; // Object creation
2465
commandList << "A" << "w" << "j" << "J" << "Xy" << "XR"; // Graphic state
2466
commandList << "k" << "K" << "Xa" << "XA" << "x" << "X" << "XX" << "Xx"; // Color commands
2467
commandList << "Xk" << "g" << "G" << "p"; // Color commands
2468
commandList << "Ln" << "Lb" << "LB"; // Layer commands
2469
commandList << "Bd" << "BD" << "%_Bs" << "Bg" << "Bb" << "BB" << "Bm" << "Xm"; // Gradient commands
2470
commandList << "To" << "TO" << "Tf" << "Tp" << "Tx" << "TX" << "T*" << "Tk"; // Text commands
2471
commandList << "Tc" << "Tz"; // Text commands
2472
commandList << "XI" << "XG" << "Xh"; // Image commands
2473
commandList << "n" << "N" << "*" << "["; // Special commands
2474
commandList << "X!" << "X#"; // Mesh commands
2475
commandList << "M" << "d" << "D" << "E"; // unimplemented
2476
commandList << "h" << "H" << "i" << "I" << "Np" << "O"; // unimplemented
2477
commandList << "P" << "R"; // unimplemented
2478
commandList << "XI" << "XF" << "XG" << "XT" << "Z" << "`" << "~" << "_" << "@"; // unimplemented
2479
commandList << "&" << "*w" << "*W" << "Ap" << "Ar"; // unimplemented
2482
progressDialog->setOverallProgress(2);
2483
progressDialog->setLabel("GI", tr("Generating Items"));
2484
qApp->processEvents();
2487
if (f.open(QIODevice::ReadOnly))
2489
int fSize = (int) f.size();
2492
progressDialog->setTotalSteps("GI", fSize);
2493
qApp->processEvents();
2498
tmp = readLinefromDataStream(ts);
2499
if (tmp.startsWith("%"))
2500
processComment(ts, tmp);
2503
progressDialog->setProgress("GI", ts.device()->pos());
2504
qApp->processEvents();
2508
progressDialog->close();