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.
7
#include "scribus134format.h"
8
#include "scribus134formatimpl.h"
10
#include "../../formatidlist.h"
11
#include "commonstrings.h"
12
#include "hyphenator.h"
14
#include "pageitem_latexframe.h"
15
#include "prefsmanager.h"
16
#include "scclocale.h"
18
#include "scpattern.h"
19
#include "scribusdoc.h"
20
#include "scribusview.h"
21
#include "sctextstream.h"
22
#include "sccolorengine.h"
23
#include "scribuscore.h"
24
#include "undomanager.h"
28
#include "util_math.h"
29
#include "util_color.h"
31
#include "scpattern.h"
37
#include <QApplication>
40
// See scplugin.h and pluginmanager.{cpp,h} for detail on what these methods
41
// do. That documentatation is not duplicated here.
42
// Please don't implement the functionality of your plugin here; do that
43
// in scribus134formatimpl.h and scribus134formatimpl.cpp .
45
Scribus134Format::Scribus134Format() :
48
// Set action info in languageChange, so we only have to do
49
// it in one place. This includes registering file formats.
53
Scribus134Format::~Scribus134Format()
58
void Scribus134Format::languageChange()
60
//(Re)register file formats.
65
const QString Scribus134Format::fullTrName() const
67
return QObject::tr("Scribus 1.3.4+ Support");
70
const ScActionPlugin::AboutData* Scribus134Format::getAboutData() const
72
AboutData* about = new AboutData;
74
about->authors = QString::fromUtf8(
75
"Franz Schmid <franz@scribus.info>, "
77
about->shortDescription = tr("Scribus 1.3.4+ File Format Support");
78
about->description = tr("Allows Scribus to read Scribus 1.3.4 and higher formatted files.");
82
about->license = "GPL";
86
void Scribus134Format::deleteAboutData(const AboutData* about) const
92
void Scribus134Format::registerFormats()
95
fmt.trName = tr("Scribus 1.3.4+ Document");
96
fmt.formatId = FORMATID_SLA134IMPORT;
99
fmt.filter = fmt.trName + " (*.sla *.SLA *.sla.gz *.SLA.GZ *.scd *.SCD *.scd.gz *.SCD.GZ)";
100
fmt.nameMatch = QRegExp("\\.(sla|scd)(\\.gz)?", Qt::CaseInsensitive);
101
fmt.mimeTypes = QStringList();
102
fmt.mimeTypes.append("application/x-scribus");
107
bool Scribus134Format::fileSupported(QIODevice* /* file */, const QString & fileName) const
109
QByteArray docBytes("");
110
if(fileName.right(2) == "gz")
112
if (!ScGzFile::readFromFile(fileName, docBytes, 4096))
114
// FIXME: Needs better error return
120
// Not gzip encoded, just load it
121
loadRawText(fileName, docBytes);
123
// if (docBytes.left(16) == "<SCRIBUSUTF8NEW " && docBytes.left(35).contains("Version=\"1.3.4"))
125
QRegExp regExp134("Version=\"1.3.[4-9]");
126
QRegExp regExp140("Version=\"1.4.[0-9]");
127
int startElemPos = docBytes.left(512).indexOf("<SCRIBUSUTF8NEW ");
128
if (startElemPos >= 0)
130
bool is134 = ( regExp134.indexIn(docBytes.mid(startElemPos, 64)) >= 0 );
131
bool is140 = ( regExp140.indexIn(docBytes.mid(startElemPos, 64)) >= 0 );
132
return (is134 || is140);
137
QString Scribus134Format::readSLA(const QString & fileName)
139
QByteArray docBytes("");
140
if(fileName.right(2) == "gz")
142
if (!ScGzFile::readFromFile(fileName, docBytes))
144
// FIXME: Needs better error return
145
return QString::null;
150
// Not gzip encoded, just load it
151
loadRawText(fileName, docBytes);
154
int startElemPos = docBytes.left(512).indexOf("<SCRIBUSUTF8NEW ");
155
if (startElemPos >= 0)
157
QRegExp regExp134("Version=\"1.3.[4-9]");
158
QRegExp regExp140("Version=\"1.4.[0-9]");
159
bool is134 = ( regExp134.indexIn(docBytes.mid(startElemPos, 64)) >= 0 );
160
bool is140 = ( regExp140.indexIn(docBytes.mid(startElemPos, 64)) >= 0 );
162
docText = QString::fromUtf8(docBytes);
163
if (docText.endsWith(QChar(10)) || docText.endsWith(QChar(13)))
164
docText.truncate(docText.length()-1);
166
if (docText.isEmpty())
167
return QString::null;
171
void Scribus134Format::getReplacedFontData(bool & getNewReplacement, QMap<QString,QString> &getReplacedFonts, QList<ScFace> &getDummyScFaces)
173
getNewReplacement=false;
174
getReplacedFonts.clear();
177
bool Scribus134Format::loadFile(const QString & fileName, const FileFormat & /* fmt */, int /* flags */, int /* index */)
179
if (m_Doc==0 || m_AvailableFonts==0)
181
Q_ASSERT(m_Doc==0 || m_AvailableFonts==0);
185
struct ScribusDoc::BookMa bok;
188
bool newVersion = false;
189
QString tmp, tmpf, PgNam, Defont;
190
QMap<int,int> TableID;
191
QList<PageItem*> TableItems;
192
QMap<int,int> TableIDM;
193
QList<PageItem*> TableItemsM;
194
QMap<int,int> TableIDF;
195
QList<PageItem*> TableItemsF;
196
QMap<PageItem*, int> groupID;
197
QMap<PageItem*, int> groupIDM;
198
QMap<PageItem*, int> groupIDF;
212
QDomDocument docu("scridoc");
213
QString f(readSLA(fileName));
219
QString fileDir = QFileInfo(fileName).absolutePath();
220
/* 2004/10/02 - petr vanek - bug #1092 - missing <PAGE> crash Scribus. The check constraint moved into IsScribus()
221
FIXME: I've add test on containig tag PAGE but returning false freezes S. in scribus.cpp need some hack too... */
223
int errorLine, errorColumn;
224
if (!docu.setContent(f, &errorMsg, &errorLine, &errorColumn))
226
setDomParsingError(errorMsg, errorLine, errorColumn);
229
m_Doc->PageColors.clear();
230
m_Doc->Layers.clear();
231
int layerToSetActive=0;
232
ScColor lf = ScColor();
233
QDomElement elem=docu.documentElement();
234
if (elem.tagName() != "SCRIBUSUTF8NEW")
236
if (elem.hasAttribute("Version"))
238
QDomNode DOC=elem.firstChild();
239
if (m_mwProgressBar!=0)
241
m_mwProgressBar->setMaximum(DOC.childNodes().count());
242
m_mwProgressBar->setValue(0);
244
// Stop autosave timer,it will be restarted only if doc has autosave feature is enabled
245
if (m_Doc->autoSaveTimer->isActive())
246
m_Doc->autoSaveTimer->stop();
254
PrefsManager* prefsManager=PrefsManager::instance();
257
QDomElement dc=DOC.toElement();
259
* Attribute von DOCUMENT auslesen
261
//CB Add this in to set this in the file in memory. Its saved, why not load it.
262
//Will of course be replaced by per page settings although we still probably need a document default
263
m_Doc->m_pageSize = dc.attribute("PAGESIZE");
264
m_Doc->PageOri = dc.attribute("ORIENTATION", "0").toInt();
265
m_Doc->FirstPnum = dc.attribute("FIRSTNUM", "1").toInt();
266
m_Doc->currentPageLayout=dc.attribute("BOOK", "0").toInt();
268
if (m_Doc->currentPageLayout == 0)
272
if (dc.attribute("FIRSTLEFT", "0").toInt() == 1)
277
if (DOC.namedItem("PageSets").isNull())
279
m_Doc->pageSets[m_Doc->currentPageLayout].FirstPage = fp;
280
// m_Doc->pageSets[m_Doc->currentPageLayout].GapHorizontal = dc.attribute("GapHorizontal", "0").toDouble();
281
// m_Doc->pageSets[m_Doc->currentPageLayout].GapVertical = 0.0;
282
// m_Doc->pageSets[m_Doc->currentPageLayout].GapBelow = dc.attribute("GapVertical", "40").toDouble();
284
m_Doc->setUsesAutomaticTextFrames(dc.attribute("AUTOTEXT").toInt());
285
m_Doc->PageSp=dc.attribute("AUTOSPALTEN").toInt();
286
m_Doc->PageSpa=ScCLocale::toDoubleC( dc.attribute("ABSTSPALTEN") );
287
m_Doc->setUnitIndex(dc.attribute("UNITS", "0").toInt());
288
m_Doc->toolSettings.defSize=qRound(ScCLocale::toDoubleC(dc.attribute("DSIZE")) * 10);
289
Defont=dc.attribute("DFONT");
290
m_AvailableFonts->findFont(Defont, m_Doc);
291
m_Doc->toolSettings.defFont = Defont;
292
m_Doc->toolSettings.dCols=dc.attribute("DCOL", "1").toInt();
293
m_Doc->toolSettings.dGap=ScCLocale::toDoubleC(dc.attribute("DGAP"), 0.0);
294
m_Doc->documentInfo.setAuthor(dc.attribute("AUTHOR"));
295
m_Doc->documentInfo.setComments(dc.attribute("COMMENTS"));
296
m_Doc->documentInfo.setKeywords(dc.attribute("KEYWORDS",""));
297
m_Doc->documentInfo.setTitle(dc.attribute("TITLE"));
298
m_Doc->documentInfo.setPublisher(dc.attribute("PUBLISHER", ""));
299
m_Doc->documentInfo.setDate(dc.attribute("DOCDATE", ""));
300
m_Doc->documentInfo.setType(dc.attribute("DOCTYPE", ""));
301
m_Doc->documentInfo.setFormat(dc.attribute("DOCFORMAT", ""));
302
m_Doc->documentInfo.setIdent(dc.attribute("DOCIDENT", ""));
303
m_Doc->documentInfo.setSource(dc.attribute("DOCSOURCE", ""));
304
m_Doc->documentInfo.setLangInfo(dc.attribute("DOCLANGINFO", ""));
305
m_Doc->documentInfo.setRelation(dc.attribute("DOCRELATION", ""));
306
m_Doc->documentInfo.setCover(dc.attribute("DOCCOVER", ""));
307
m_Doc->documentInfo.setRights(dc.attribute("DOCRIGHTS", ""));
308
m_Doc->documentInfo.setContrib(dc.attribute("DOCCONTRIB", ""));
309
m_Doc->typographicSettings.valueSuperScript = dc.attribute("VHOCH").toInt();
310
m_Doc->typographicSettings.scalingSuperScript = dc.attribute("VHOCHSC").toInt();
311
m_Doc->typographicSettings.valueSubScript = dc.attribute("VTIEF").toInt();
312
m_Doc->typographicSettings.scalingSubScript = dc.attribute("VTIEFSC").toInt();
313
m_Doc->typographicSettings.valueSmallCaps = dc.attribute("VKAPIT").toInt();
314
m_Doc->typographicSettings.valueBaseGrid = ScCLocale::toDoubleC(dc.attribute("BASEGRID"), 12.0);
315
m_Doc->typographicSettings.offsetBaseGrid = ScCLocale::toDoubleC(dc.attribute("BASEO"), 0.0);
316
m_Doc->typographicSettings.autoLineSpacing = dc.attribute("AUTOL", "20").toInt();
317
m_Doc->typographicSettings.valueUnderlinePos = dc.attribute("UnderlinePos", "-1").toInt();
318
m_Doc->typographicSettings.valueUnderlineWidth = dc.attribute("UnderlineWidth", "-1").toInt();
319
m_Doc->typographicSettings.valueStrikeThruPos = dc.attribute("StrikeThruPos", "-1").toInt();
320
m_Doc->typographicSettings.valueStrikeThruWidth = dc.attribute("StrikeThruWidth", "-1").toInt();
321
m_Doc->GroupCounter = 1/*dc.attribute("GROUPC", "1").toInt()*/;
322
//m_Doc->HasCMS = static_cast<bool>(dc.attribute("HCMS", "0").toInt());
323
m_Doc->CMSSettings.SoftProofOn = static_cast<bool>(dc.attribute("DPSo", "0").toInt());
324
m_Doc->CMSSettings.SoftProofFullOn = static_cast<bool>(dc.attribute("DPSFo", "0").toInt());
325
m_Doc->CMSSettings.CMSinUse = static_cast<bool>(dc.attribute("DPuse", "0").toInt());
326
m_Doc->CMSSettings.GamutCheck = static_cast<bool>(dc.attribute("DPgam", "0").toInt());
327
m_Doc->CMSSettings.BlackPoint = static_cast<bool>(dc.attribute("DPbla", "1").toInt());
328
m_Doc->CMSSettings.DefaultMonitorProfile = dc.attribute("DPMo","");
329
m_Doc->CMSSettings.DefaultPrinterProfile = dc.attribute("DPPr","");
330
m_Doc->CMSSettings.DefaultImageRGBProfile = dc.attribute("DPIn","");
331
m_Doc->CMSSettings.DefaultImageCMYKProfile = dc.attribute("DPInCMYK","");
332
m_Doc->CMSSettings.DefaultSolidColorRGBProfile = dc.attribute("DPIn2","");
333
if (dc.hasAttribute("DPIn3"))
334
m_Doc->CMSSettings.DefaultSolidColorCMYKProfile = dc.attribute("DPIn3","");
336
m_Doc->CMSSettings.DefaultSolidColorCMYKProfile = dc.attribute("DPPr","");
337
//m_Doc->CMSSettings.DefaultIntentPrinter = dc.attribute("DIPr", "0").toInt();
338
//m_Doc->CMSSettings.DefaultIntentMonitor = dc.attribute("DIMo", "1").toInt();
339
m_Doc->CMSSettings.DefaultIntentColors = (eRenderIntent) dc.attribute("DISc", "1").toInt();
340
m_Doc->CMSSettings.DefaultIntentImages = (eRenderIntent) dc.attribute("DIIm", "0").toInt();
341
layerToSetActive=dc.attribute("ALAYER", "0").toInt();
342
m_Doc->Language = dc.attribute("LANGUAGE", "");
343
m_Doc->MinWordLen = dc.attribute("MINWORDLEN", "3").toInt();
344
m_Doc->HyCount = dc.attribute("HYCOUNT", "2").toInt();
345
if (dc.hasAttribute("PAGEWIDTH"))
346
m_Doc->pageWidth=ScCLocale::toDoubleC(dc.attribute("PAGEWIDTH"));
348
m_Doc->pageWidth=ScCLocale::toDoubleC(dc.attribute("PAGEWITH"));
349
m_Doc->pageHeight=ScCLocale::toDoubleC(dc.attribute("PAGEHEIGHT"));
350
m_Doc->pageMargins.Left=qMax(0.0, ScCLocale::toDoubleC(dc.attribute("BORDERLEFT")));
351
m_Doc->pageMargins.Right=qMax(0.0, ScCLocale::toDoubleC(dc.attribute("BORDERRIGHT")));
352
m_Doc->pageMargins.Top=qMax(0.0, ScCLocale::toDoubleC(dc.attribute("BORDERTOP")));
353
m_Doc->pageMargins.Bottom=qMax(0.0, ScCLocale::toDoubleC(dc.attribute("BORDERBOTTOM")));
354
m_Doc->marginPreset = dc.attribute("PRESET", "0").toInt();
355
m_Doc->bleeds.Top = ScCLocale::toDoubleC(dc.attribute("BleedTop"), 0.0);
356
m_Doc->bleeds.Left = ScCLocale::toDoubleC(dc.attribute("BleedLeft"), 0.0);
357
m_Doc->bleeds.Right = ScCLocale::toDoubleC(dc.attribute("BleedRight"), 0.0);
358
m_Doc->bleeds.Bottom = ScCLocale::toDoubleC(dc.attribute("BleedBottom"), 0.0);
359
m_Doc->Automatic = static_cast<bool>(dc.attribute("AUTOMATIC", "1").toInt());
360
m_Doc->AutoCheck = static_cast<bool>(dc.attribute("AUTOCHECK", "0").toInt());
361
m_Doc->GuideLock = static_cast<bool>(dc.attribute("GUIDELOCK", "0").toInt());
362
m_Doc->guidesSettings.minorGrid = ScCLocale::toDoubleC(dc.attribute("MINGRID"), prefsManager->appPrefs.guidesSettings.minorGrid);
363
m_Doc->guidesSettings.majorGrid = ScCLocale::toDoubleC(dc.attribute("MAJGRID"), prefsManager->appPrefs.guidesSettings.majorGrid);
364
m_Doc->guidesSettings.gridShown = static_cast<bool>(dc.attribute("SHOWGRID", "0").toInt());
365
m_Doc->guidesSettings.guidesShown = static_cast<bool>(dc.attribute("SHOWGUIDES", "1").toInt());
366
m_Doc->guidesSettings.colBordersShown = static_cast<bool>(dc.attribute("showcolborders", "0").toInt());
367
m_Doc->guidesSettings.framesShown = static_cast<bool>(dc.attribute("SHOWFRAME", "1").toInt());
368
m_Doc->guidesSettings.layerMarkersShown = static_cast<bool>(dc.attribute("SHOWLAYERM", "0").toInt());
369
m_Doc->guidesSettings.marginsShown = static_cast<bool>(dc.attribute("SHOWMARGIN", "1").toInt());
370
m_Doc->guidesSettings.baseShown = static_cast<bool>(dc.attribute("SHOWBASE", "0").toInt());
371
m_Doc->guidesSettings.showPic = static_cast<bool>(dc.attribute("SHOWPICT", "1").toInt());
372
m_Doc->guidesSettings.linkShown = static_cast<bool>(dc.attribute("SHOWLINK", "0").toInt());
373
m_Doc->guidesSettings.showControls = static_cast<bool>(dc.attribute("SHOWControl", "0").toInt());
374
m_Doc->guidesSettings.rulerMode = static_cast<bool>(dc.attribute("rulerMode", "1").toInt());
375
m_Doc->guidesSettings.rulersShown = static_cast<bool>(dc.attribute("showrulers", "1").toInt());
376
m_Doc->guidesSettings.showBleed = static_cast<bool>(dc.attribute("showBleed", "1").toInt());
377
m_Doc->rulerXoffset = ScCLocale::toDoubleC(dc.attribute("rulerXoffset"), 0.0);
378
m_Doc->rulerYoffset = ScCLocale::toDoubleC(dc.attribute("rulerYoffset"), 0.0);
379
m_Doc->SnapGuides = static_cast<bool>(dc.attribute("SnapToGuides", "0").toInt());
380
m_Doc->useRaster = static_cast<bool>(dc.attribute("SnapToGrid", "0").toInt());
381
m_Doc->toolSettings.polyC = dc.attribute("POLYC", "4").toInt();
382
m_Doc->toolSettings.polyF = ScCLocale::toDoubleC(dc.attribute("POLYF"), 0.5);
383
m_Doc->toolSettings.polyR = ScCLocale::toDoubleC(dc.attribute("POLYR"), 0.0);
384
m_Doc->toolSettings.polyCurvature = ScCLocale::toDoubleC(dc.attribute("POLYCUR"), 0.0);
385
m_Doc->toolSettings.polyFd = dc.attribute("POLYFD", "0").toInt();
386
m_Doc->toolSettings.polyS = static_cast<bool>(dc.attribute("POLYS", "0").toInt());
387
m_Doc->AutoSave = static_cast<bool>(dc.attribute("AutoSave", "0").toInt());
388
m_Doc->AutoSaveTime = dc.attribute("AutoSaveTime", "600000").toInt();
389
m_Doc->scratch.Bottom = ScCLocale::toDoubleC(dc.attribute("ScratchBottom"), 20.0);
390
// FIXME A typo in early 1.3cvs (MAR 05) means we must support loading of
391
// FIXME 'ScatchLeft' for a while too. This can be removed in a few months.
392
if (dc.hasAttribute("ScatchLeft"))
393
m_Doc->scratch.Left = ScCLocale::toDoubleC( dc.attribute("ScatchLeft"), 100.0);
395
m_Doc->scratch.Left = ScCLocale::toDoubleC( dc.attribute("ScratchLeft"), 100.0);
396
m_Doc->scratch.Right = ScCLocale::toDoubleC( dc.attribute("ScratchRight"), 100.0);
397
m_Doc->scratch.Top = ScCLocale::toDoubleC( dc.attribute("ScratchTop"), 20.0);
398
m_Doc->GapHorizontal = ScCLocale::toDoubleC( dc.attribute("GapHorizontal"), -1.0);
399
m_Doc->GapVertical = ScCLocale::toDoubleC( dc.attribute("GapVertical"), -1.0);
400
m_Doc->toolSettings.dStartArrow = dc.attribute("StartArrow", "0").toInt();
401
m_Doc->toolSettings.dEndArrow = dc.attribute("EndArrow", "0").toInt();
402
m_Doc->toolSettings.scaleX = ScCLocale::toDoubleC( dc.attribute("PICTSCX"), 1.0);
403
m_Doc->toolSettings.scaleY = ScCLocale::toDoubleC( dc.attribute("PICTSCY"), 1.0);
404
m_Doc->toolSettings.scaleType = static_cast<bool>(dc.attribute("PSCALE", "1").toInt());
405
m_Doc->toolSettings.aspectRatio = static_cast<bool>(dc.attribute("PASPECT", "0").toInt());
406
m_Doc->toolSettings.lowResType = dc.attribute("HalfRes", "1").toInt();
407
m_Doc->toolSettings.useEmbeddedPath = static_cast<bool>(dc.attribute("EmbeddedPath", "0").toInt());
408
if (dc.hasAttribute("PEN"))
409
m_Doc->toolSettings.dPen = dc.attribute("PEN");
410
if (dc.hasAttribute("BRUSH"))
411
m_Doc->toolSettings.dBrush = dc.attribute("BRUSH");
412
if (dc.hasAttribute("PENLINE"))
413
m_Doc->toolSettings.dPenLine = dc.attribute("PENLINE");
414
if (dc.hasAttribute("PENTEXT"))
415
m_Doc->toolSettings.dPenText = dc.attribute("PENTEXT");
416
if (dc.hasAttribute("StrokeText"))
417
m_Doc->toolSettings.dStrokeText = dc.attribute("StrokeText");
418
m_Doc->toolSettings.dTextBackGround = dc.attribute("TextBackGround", CommonStrings::None);
419
m_Doc->toolSettings.dTextLineColor = dc.attribute("TextLineColor", CommonStrings::None);
420
m_Doc->toolSettings.dTextBackGroundShade = dc.attribute("TextBackGroundShade", "100").toInt();
421
m_Doc->toolSettings.dTextLineShade = dc.attribute("TextLineShade", "100").toInt();
422
m_Doc->toolSettings.dTextPenShade = dc.attribute("TextPenShade", "100").toInt();
423
m_Doc->toolSettings.dTextStrokeShade = dc.attribute("TextStrokeShade", "100").toInt();
424
m_Doc->toolSettings.dLineArt = static_cast<Qt::PenStyle>(dc.attribute("STIL").toInt());
425
m_Doc->toolSettings.dLstyleLine = static_cast<Qt::PenStyle>(dc.attribute("STILLINE").toInt());
426
m_Doc->toolSettings.dWidth = ScCLocale::toDoubleC( dc.attribute("WIDTH"), 0.0);
427
m_Doc->toolSettings.dWidthLine = ScCLocale::toDoubleC( dc.attribute("WIDTHLINE"), 1.0);
428
m_Doc->toolSettings.dShade2 = dc.attribute("PENSHADE", "100").toInt();
429
m_Doc->toolSettings.dShadeLine = dc.attribute("LINESHADE", "100").toInt();
430
m_Doc->toolSettings.dShade = dc.attribute("BRUSHSHADE", "100").toInt();
431
m_Doc->toolSettings.magMin = dc.attribute("MAGMIN", "1").toInt();
432
m_Doc->toolSettings.magMax = dc.attribute("MAGMAX", "3200").toInt();
433
m_Doc->toolSettings.magStep = dc.attribute("MAGSTEP", "200").toInt();
434
m_Doc->toolSettings.dispX = ScCLocale::toDoubleC( dc.attribute("dispX"), 10.0);
435
m_Doc->toolSettings.dispY = ScCLocale::toDoubleC( dc.attribute("dispY"), 10.0);
436
m_Doc->toolSettings.constrain = ScCLocale::toDoubleC( dc.attribute("constrain"), 15.0);
437
//CB Reset doc zoom step value to 200% instead of old values.
438
if (m_Doc->toolSettings.magStep <= 100)
439
m_Doc->toolSettings.magStep = 200;
440
m_Doc->toolSettings.tabFillChar = dc.attribute("TabFill","");
441
m_Doc->toolSettings.dTabWidth= ScCLocale::toDoubleC(dc.attribute("TabWidth"), 36.0);
442
if (dc.hasAttribute("CPICT"))
443
m_Doc->toolSettings.dBrushPict = dc.attribute("CPICT");
444
m_Doc->toolSettings.shadePict = dc.attribute("PICTSHADE", "100").toInt();
445
if (dc.hasAttribute("PAGEC"))
446
m_Doc->papColor = QColor(dc.attribute("PAGEC"));
447
if (dc.hasAttribute("MARGC"))
448
m_Doc->guidesSettings.margColor = QColor(dc.attribute("MARGC"));
449
if (dc.hasAttribute("MINORC"))
450
m_Doc->guidesSettings.minorColor = QColor(dc.attribute("MINORC"));
451
if (dc.hasAttribute("MAJORC"))
452
m_Doc->guidesSettings.majorColor = QColor(dc.attribute("MAJORC"));
453
if (dc.hasAttribute("GuideC"))
454
m_Doc->guidesSettings.guideColor = QColor(dc.attribute("GuideC"));
455
if (dc.hasAttribute("BaseC"))
456
m_Doc->guidesSettings.baseColor = QColor(dc.attribute("BaseC"));
457
m_Doc->marginColored = static_cast<bool>(dc.attribute("RANDF", "0").toInt());
458
m_Doc->guidesSettings.before = static_cast<bool>(dc.attribute("BACKG", "1").toInt());
459
m_Doc->guidesSettings.guideRad = ScCLocale::toDoubleC( dc.attribute("GuideRad"), 10.0);
460
m_Doc->guidesSettings.grabRad = dc.attribute("GRAB", "4").toInt();
461
if (dc.hasAttribute("currentProfile"))
463
m_Doc->checkerProfiles.clear();
464
m_Doc->curCheckProfile = dc.attribute("currentProfile");
467
QDomNode PAGE=DOC.firstChild();
469
while(!PAGE.isNull())
472
if (m_mwProgressBar!=0)
473
m_mwProgressBar->setValue(ObCount);
474
QDomElement pg=PAGE.toElement();
475
if (pg.tagName()=="PageSets")
477
QDomNode PGS = PAGE.firstChild();
478
m_Doc->pageSets.clear();
481
QDomElement PgsAttr = PGS.toElement();
482
if(PgsAttr.tagName() == "Set")
484
struct PageSet pageS;
485
pageS.Name = CommonStrings::untranslatePageSetString(PgsAttr.attribute("Name"));
486
pageS.FirstPage = PgsAttr.attribute("FirstPage", "0").toInt();
487
pageS.Rows = PgsAttr.attribute("Rows", "1").toInt();
488
pageS.Columns = PgsAttr.attribute("Columns", "1").toInt();
489
// pageS.GapHorizontal = ScCLocale::toDoubleC( PgsAttr.attribute("GapHorizontal", "0"));
490
// pageS.GapVertical = ScCLocale::toDoubleC( PgsAttr.attribute("GapVertical", "0"));
491
// pageS.GapBelow = ScCLocale::toDoubleC( PgsAttr.attribute("GapBelow", "0"));
492
pageS.pageNames.clear();
493
QDomNode PGSN = PGS.firstChild();
494
while(!PGSN.isNull())
496
QDomElement PgsAttrN = PGSN.toElement();
497
if(PgsAttrN.tagName() == "PageNames")
498
pageS.pageNames.append(CommonStrings::untranslatePageSetLocString(PgsAttrN.attribute("Name")));
499
PGSN = PGSN.nextSibling();
501
m_Doc->pageSets.append(pageS);
502
if ((m_Doc->pageSets.count()-1 == m_Doc->currentPageLayout) && ((m_Doc->GapHorizontal < 0) && (m_Doc->GapVertical < 0)))
504
m_Doc->GapHorizontal = ScCLocale::toDoubleC( PgsAttr.attribute("GapHorizontal"), 0.0);
505
m_Doc->GapVertical = ScCLocale::toDoubleC( PgsAttr.attribute("GapBelow"), 0.0);
508
PGS = PGS.nextSibling();
511
if (pg.tagName()=="CheckProfile")
513
struct checkerPrefs checkerSettings;
514
checkerSettings.ignoreErrors = static_cast<bool>(pg.attribute("ignoreErrors", "0").toInt());
515
checkerSettings.autoCheck = static_cast<bool>(pg.attribute("autoCheck", "1").toInt());
516
checkerSettings.checkGlyphs = static_cast<bool>(pg.attribute("checkGlyphs", "1").toInt());
517
checkerSettings.checkOrphans = static_cast<bool>(pg.attribute("checkOrphans", "1").toInt());
518
checkerSettings.checkOverflow = static_cast<bool>(pg.attribute("checkOverflow", "1").toInt());
519
checkerSettings.checkPictures = static_cast<bool>(pg.attribute("checkPictures", "1").toInt());
520
checkerSettings.checkResolution = static_cast<bool>(pg.attribute("checkResolution", "1").toInt());
521
checkerSettings.checkTransparency = static_cast<bool>(pg.attribute("checkTransparency", "1").toInt());
522
checkerSettings.minResolution = ScCLocale::toDoubleC( pg.attribute("minResolution"), 72.0);
523
checkerSettings.maxResolution = ScCLocale::toDoubleC( pg.attribute("maxResolution"), 4800.0);
524
checkerSettings.checkAnnotations = static_cast<bool>(pg.attribute("checkAnnotations", "0").toInt());
525
checkerSettings.checkRasterPDF = static_cast<bool>(pg.attribute("checkRasterPDF", "1").toInt());
526
checkerSettings.checkForGIF = static_cast<bool>(pg.attribute("checkForGIF", "1").toInt());
527
checkerSettings.ignoreOffLayers = static_cast<bool>(pg.attribute("ignoreOffLayers", "0").toInt());
528
checkerSettings.checkOffConflictLayers = static_cast<bool>(pg.attribute("checkOffConflictLayers", "0").toInt());
529
m_Doc->checkerProfiles[pg.attribute("Name")] = checkerSettings;
531
// 10/25/2004 pv - None is "reserved" color. cannot be defined in any file...
532
if(pg.tagName()=="COLOR" && pg.attribute("NAME")!=CommonStrings::None)
534
if (pg.hasAttribute("CMYK"))
535
lf.setNamedColor(pg.attribute("CMYK"));
537
lf.fromQColor(QColor(pg.attribute("RGB")));
538
if (pg.hasAttribute("Spot"))
539
lf.setSpotColor(static_cast<bool>(pg.attribute("Spot").toInt()));
541
lf.setSpotColor(false);
542
if (pg.hasAttribute("Register"))
543
lf.setRegistrationColor(static_cast<bool>(pg.attribute("Register").toInt()));
545
lf.setRegistrationColor(false);
546
QString name = pg.attribute("NAME");
547
m_Doc->PageColors.insert((name.isEmpty()) ? lf.name() : name, lf);
549
if(pg.tagName()=="STYLE")
551
readParagraphStyle(vg, pg, *m_AvailableFonts, m_Doc);
552
StyleSet<ParagraphStyle>tmp;
554
m_Doc->redefineStyles(tmp, false);
556
if(pg.tagName()=="CHARSTYLE")
558
readParagraphStyle(vg, pg, *m_AvailableFonts, m_Doc);
559
StyleSet<CharStyle> temp;
560
temp.create(vg.charStyle());
561
m_Doc->redefineCharStyles(temp, false);
563
if(pg.tagName()=="JAVA")
564
m_Doc->JavaScripts[pg.attribute("NAME")] = pg.attribute("SCRIPT");
565
if(pg.tagName()=="LAYERS")
567
int lnr = pg.attribute("NUMMER").toInt();
568
int level = pg.attribute("LEVEL").toInt();
569
ScLayer la( pg.attribute("NAME"), level, lnr);
570
la.isViewable = pg.attribute("SICHTBAR").toInt();
571
la.isPrintable = pg.attribute("DRUCKEN").toInt();
572
la.isEditable = pg.attribute("EDIT", "1").toInt();
573
la.flowControl = pg.attribute("FLOW", "1").toInt();
574
la.transparency = ScCLocale::toDoubleC( pg.attribute("TRANS"), 1.0);
575
la.blendMode = pg.attribute("BLEND", "0").toInt();
576
la.outlineMode = pg.attribute("OUTL", "0").toInt();
577
if (pg.hasAttribute("LAYERC"))
578
la.markerColor = QColor(pg.attribute("LAYERC","#000000"));
579
m_Doc->Layers.append(la);
581
/* if(pg.tagName()=="Bookmark")
583
bok.Title = pg.attribute("Title");
584
bok.Text = pg.attribute("Text");
585
bok.Aktion = pg.attribute("Aktion");
586
bok.ItemNr = pg.attribute("ItemNr").toInt();
587
bok.Seite = pg.attribute("Seite").toInt();
588
bok.Element = pg.attribute("Element").toInt();
589
bok.First = pg.attribute("First").toInt();
590
bok.Last = pg.attribute("Last").toInt();
591
bok.Prev = pg.attribute("Prev").toInt();
592
bok.Next = pg.attribute("Next").toInt();
593
bok.Parent = pg.attribute("Parent").toInt();
594
m_Doc->BookMarks.append(bok);
596
if(pg.tagName()=="MultiLine")
599
QDomNode MuLn = PAGE.firstChild();
600
while(!MuLn.isNull())
602
QDomElement MuL = MuLn.toElement();
603
struct SingleLine sl;
604
sl.Color = MuL.attribute("Color");
605
sl.Dash = MuL.attribute("Dash").toInt();
606
sl.LineEnd = MuL.attribute("LineEnd").toInt();
607
sl.LineJoin = MuL.attribute("LineJoin").toInt();
608
sl.Shade = MuL.attribute("Shade").toInt();
609
sl.Width = ScCLocale::toDoubleC( MuL.attribute("Width"));
610
ml.shortcut = MuL.attribute("Shortcut");
612
MuLn = MuLn.nextSibling();
614
m_Doc->MLineStyles.insert(pg.attribute("Name"), ml);
616
if(pg.tagName()=="Arrows")
618
struct ArrowDesc arrow;
619
arrow.name = pg.attribute("Name");
620
arrow.userArrow = true;
622
QString tmp = pg.attribute("Points");
623
ScTextStream fp(&tmp, QIODevice::ReadOnly);
624
for (uint cx = 0; cx < pg.attribute("NumPoints").toUInt(); ++cx)
628
arrow.points.addPoint(xa, ya);
630
m_Doc->arrowStyles.append(arrow);
632
if(pg.tagName()=="Printer")
634
m_Doc->Print_Options.firstUse = static_cast<bool>(pg.attribute("firstUse").toInt());
635
m_Doc->Print_Options.toFile = static_cast<bool>(pg.attribute("toFile").toInt());
636
m_Doc->Print_Options.useAltPrintCommand = static_cast<bool>(pg.attribute("useAltPrintCommand").toInt());
637
m_Doc->Print_Options.outputSeparations = static_cast<bool>(pg.attribute("outputSeparations").toInt());
638
m_Doc->Print_Options.useSpotColors = static_cast<bool>(pg.attribute("useSpotColors").toInt());
639
m_Doc->Print_Options.useColor = static_cast<bool>(pg.attribute("useColor").toInt());
640
m_Doc->Print_Options.mirrorH = static_cast<bool>(pg.attribute("mirrorH").toInt());
641
m_Doc->Print_Options.mirrorV = static_cast<bool>(pg.attribute("mirrorV").toInt());
642
m_Doc->Print_Options.useICC = static_cast<bool>(pg.attribute("useICC").toInt());
643
m_Doc->Print_Options.doGCR = static_cast<bool>(pg.attribute("doGCR").toInt());
644
m_Doc->Print_Options.doClip = static_cast<bool>(pg.attribute("doClip").toInt());
645
m_Doc->Print_Options.setDevParam = static_cast<bool>(pg.attribute("setDevParam").toInt());
646
m_Doc->Print_Options.useDocBleeds = static_cast<bool>(pg.attribute("useDocBleeds").toInt());
647
m_Doc->Print_Options.cropMarks = static_cast<bool>(pg.attribute("cropMarks").toInt());
648
m_Doc->Print_Options.bleedMarks = static_cast<bool>(pg.attribute("bleedMarks").toInt());
649
m_Doc->Print_Options.registrationMarks = static_cast<bool>(pg.attribute("registrationMarks").toInt());
650
m_Doc->Print_Options.colorMarks = static_cast<bool>(pg.attribute("colorMarks").toInt());
651
m_Doc->Print_Options.includePDFMarks = static_cast<bool>(pg.attribute("includePDFMarks", "1").toInt());
652
if (pg.hasAttribute("PrintEngine"))
653
m_Doc->Print_Options.prnEngine = (PrintEngine) pg.attribute("PrintEngine", "3").toInt();
655
m_Doc->Print_Options.prnEngine = (PrintEngine) pg.attribute("PSLevel", "3").toInt();
656
m_Doc->Print_Options.markOffset = ScCLocale::toDoubleC( pg.attribute("markOffset"));
657
m_Doc->Print_Options.bleeds.Top = ScCLocale::toDoubleC( pg.attribute("BleedTop"));
658
m_Doc->Print_Options.bleeds.Left = ScCLocale::toDoubleC( pg.attribute("BleedLeft"));
659
m_Doc->Print_Options.bleeds.Right = ScCLocale::toDoubleC( pg.attribute("BleedRight"));
660
m_Doc->Print_Options.bleeds.Bottom = ScCLocale::toDoubleC( pg.attribute("BleedBottom"));
661
m_Doc->Print_Options.printer = pg.attribute("printer");
662
m_Doc->Print_Options.filename = pg.attribute("filename");
663
m_Doc->Print_Options.separationName = pg.attribute("separationName");
664
m_Doc->Print_Options.printerCommand = pg.attribute("printerCommand");
665
m_Doc->Print_Options.copies = 1;
666
QDomNode PFO = PAGE.firstChild();
669
QDomElement pdfF = PFO.toElement();
670
if(pdfF.tagName() == "Separation")
671
m_Doc->Print_Options.allSeparations.append(pdfF.attribute("Name"));
672
PFO = PFO.nextSibling();
675
if(pg.tagName()=="PDF")
677
m_Doc->PDF_Options.Articles = static_cast<bool>(pg.attribute("Articles").toInt());
678
m_Doc->PDF_Options.Thumbnails = static_cast<bool>(pg.attribute("Thumbnails").toInt());
679
m_Doc->PDF_Options.Compress = static_cast<bool>(pg.attribute("Compress").toInt());
680
m_Doc->PDF_Options.CompressMethod = (PDFOptions::PDFCompression) pg.attribute("CMethod", "0").toInt();
681
m_Doc->PDF_Options.Quality = pg.attribute("Quality", "0").toInt();
682
m_Doc->PDF_Options.RecalcPic = static_cast<bool>(pg.attribute("RecalcPic").toInt());
683
m_Doc->PDF_Options.Bookmarks = static_cast<bool>(pg.attribute("Bookmarks").toInt());
684
if (pg.hasAttribute("firstUse"))
685
m_Doc->PDF_Options.firstUse = static_cast<bool>(pg.attribute("firstUse").toInt());
687
m_Doc->PDF_Options.firstUse = true;
688
if (pg.hasAttribute("MirrorH"))
689
m_Doc->PDF_Options.MirrorH = static_cast<bool>(pg.attribute("MirrorH").toInt());
691
m_Doc->PDF_Options.MirrorH = false;
692
if (pg.hasAttribute("MirrorV"))
693
m_Doc->PDF_Options.MirrorV = static_cast<bool>(pg.attribute("MirrorV").toInt());
695
m_Doc->PDF_Options.MirrorV = false;
696
if (pg.hasAttribute("RotateDeg"))
697
m_Doc->PDF_Options.RotateDeg = pg.attribute("RotateDeg", "0").toInt();
699
m_Doc->PDF_Options.RotateDeg = 0;
700
if (pg.hasAttribute("Clip"))
701
m_Doc->PDF_Options.doClip = static_cast<bool>(pg.attribute("Clip").toInt());
703
m_Doc->PDF_Options.doClip = false;
704
m_Doc->PDF_Options.PresentMode = static_cast<bool>(pg.attribute("PresentMode").toInt());
705
m_Doc->PDF_Options.PicRes = pg.attribute("PicRes").toInt();
706
// Fixme: check input pdf version
707
m_Doc->PDF_Options.Version = (PDFOptions::PDFVersion)pg.attribute("Version").toInt();
708
m_Doc->PDF_Options.Resolution = pg.attribute("Resolution").toInt();
709
m_Doc->PDF_Options.Binding = pg.attribute("Binding").toInt();
710
m_Doc->PDF_Options.fileName = "";
711
m_Doc->PDF_Options.isGrayscale = static_cast<bool>(pg.attribute("Grayscale", "0").toInt());
712
m_Doc->PDF_Options.UseRGB = static_cast<bool>(pg.attribute("RGBMode", "0").toInt());
713
m_Doc->PDF_Options.UseProfiles = static_cast<bool>(pg.attribute("UseProfiles", "0").toInt());
714
m_Doc->PDF_Options.UseProfiles2 = static_cast<bool>(pg.attribute("UseProfiles2", "0").toInt());
715
m_Doc->PDF_Options.Intent = pg.attribute("Intent", "1").toInt();
716
m_Doc->PDF_Options.Intent2 = pg.attribute("Intent2", "1").toInt();
717
m_Doc->PDF_Options.SolidProf = pg.attribute("SolidP", "");
718
m_Doc->PDF_Options.ImageProf = pg.attribute("ImageP", "");
719
m_Doc->PDF_Options.PrintProf = pg.attribute("PrintP", "");
720
m_Doc->PDF_Options.Info = pg.attribute("InfoString", "");
721
m_Doc->PDF_Options.bleeds.Top = ScCLocale::toDoubleC( pg.attribute("BTop"), 0.0);
722
m_Doc->PDF_Options.bleeds.Left = ScCLocale::toDoubleC( pg.attribute("BLeft"), 0.0);
723
m_Doc->PDF_Options.bleeds.Right = ScCLocale::toDoubleC( pg.attribute("BRight"), 0.0);
724
m_Doc->PDF_Options.bleeds.Bottom = ScCLocale::toDoubleC( pg.attribute("BBottom"), 0.0);
725
m_Doc->PDF_Options.useDocBleeds = static_cast<bool>(pg.attribute("useDocBleeds", "1").toInt());
726
m_Doc->PDF_Options.cropMarks = static_cast<bool>(pg.attribute("cropMarks", "0").toInt());
727
m_Doc->PDF_Options.bleedMarks = static_cast<bool>(pg.attribute("bleedMarks", "0").toInt());
728
m_Doc->PDF_Options.registrationMarks = static_cast<bool>(pg.attribute("registrationMarks", "0").toInt());
729
m_Doc->PDF_Options.colorMarks = static_cast<bool>(pg.attribute("colorMarks", "0").toInt());
730
m_Doc->PDF_Options.docInfoMarks = static_cast<bool>(pg.attribute("docInfoMarks", "0").toInt());
731
m_Doc->PDF_Options.markOffset = ScCLocale::toDoubleC( pg.attribute("markOffset"), 0.0);
732
m_Doc->PDF_Options.EmbeddedI = static_cast<bool>(pg.attribute("ImagePr", "0").toInt());
733
m_Doc->PDF_Options.PassOwner = pg.attribute("PassOwner", "");
734
m_Doc->PDF_Options.PassUser = pg.attribute("PassUser", "");
735
m_Doc->PDF_Options.Permissions = pg.attribute("Permissions", "-4").toInt();
736
m_Doc->PDF_Options.Encrypt = static_cast<bool>(pg.attribute("Encrypt", "0").toInt());
737
m_Doc->PDF_Options.useLayers = static_cast<bool>(pg.attribute("UseLayers", "0").toInt());
738
m_Doc->PDF_Options.UseLPI = static_cast<bool>(pg.attribute("UseLpi", "0").toInt());
739
m_Doc->PDF_Options.UseSpotColors = static_cast<bool>(pg.attribute("UseSpotColors", "1").toInt());
740
m_Doc->PDF_Options.doMultiFile = static_cast<bool>(pg.attribute("doMultiFile", "0").toInt());
741
m_Doc->PDF_Options.displayBookmarks = static_cast<bool>(pg.attribute("displayBookmarks", "0").toInt());
742
m_Doc->PDF_Options.displayFullscreen = static_cast<bool>(pg.attribute("displayFullscreen", "0").toInt());
743
m_Doc->PDF_Options.displayLayers = static_cast<bool>(pg.attribute("displayLayers", "0").toInt());
744
m_Doc->PDF_Options.displayThumbs = static_cast<bool>(pg.attribute("displayThumbs", "0").toInt());
745
m_Doc->PDF_Options.hideMenuBar = static_cast<bool>(pg.attribute("hideMenuBar", "0").toInt());
746
m_Doc->PDF_Options.hideToolBar = static_cast<bool>(pg.attribute("hideToolBar", "0").toInt());
747
m_Doc->PDF_Options.fitWindow = static_cast<bool>(pg.attribute("fitWindow", "0").toInt());
748
m_Doc->PDF_Options.PageLayout = pg.attribute("PageLayout", "0").toInt();
749
m_Doc->PDF_Options.openAction = pg.attribute("openAction", "");
750
QDomNode PFO = PAGE.firstChild();
753
QDomElement pdfF = PFO.toElement();
754
if(pdfF.tagName() == "LPI")
757
lpo.Angle = pdfF.attribute("Angle").toInt();
758
lpo.Frequency = pdfF.attribute("Frequency").toInt();
759
lpo.SpotFunc = pdfF.attribute("SpotFunction").toInt();
760
m_Doc->PDF_Options.LPISettings[pdfF.attribute("Color")] = lpo;
762
if(pdfF.tagName() == "Fonts")
764
if (!m_Doc->PDF_Options.EmbedList.contains(pdfF.attribute("Name")))
765
m_Doc->PDF_Options.EmbedList.append(pdfF.attribute("Name"));
767
if(pdfF.tagName() == "Subset")
769
if (!m_Doc->PDF_Options.SubsetList.contains(pdfF.attribute("Name")))
770
m_Doc->PDF_Options.SubsetList.append(pdfF.attribute("Name"));
772
if(pdfF.tagName() == "Effekte")
774
struct PDFPresentationData ef;
775
ef.pageEffectDuration = pdfF.attribute("pageEffectDuration").toInt();
776
ef.pageViewDuration = pdfF.attribute("pageViewDuration").toInt();
777
ef.effectType = pdfF.attribute("effectType").toInt();
778
ef.Dm = pdfF.attribute("Dm").toInt();
779
ef.M = pdfF.attribute("M").toInt();
780
ef.Di = pdfF.attribute("Di").toInt();
781
m_Doc->PDF_Options.PresentVals.append(ef);
783
PFO = PFO.nextSibling();
786
if(pg.tagName()=="DocItemAttributes")
788
QDomNode DIA = PAGE.firstChild();
789
m_Doc->docItemAttributes.clear();
792
QDomElement itemAttr = DIA.toElement();
793
if(itemAttr.tagName() == "ItemAttribute")
795
ObjectAttribute objattr;
796
objattr.name=itemAttr.attribute("Name");
797
objattr.type=itemAttr.attribute("Type");
798
objattr.value=itemAttr.attribute("Value");
799
objattr.parameter=itemAttr.attribute("Parameter");
800
objattr.relationship=itemAttr.attribute("Relationship");
801
objattr.relationshipto=itemAttr.attribute("RelationshipTo");
802
objattr.autoaddto=itemAttr.attribute("AutoAddTo");
803
m_Doc->docItemAttributes.append(objattr);
805
DIA = DIA.nextSibling();
808
if(pg.tagName()=="TablesOfContents")
810
QDomNode TOC = PAGE.firstChild();
811
m_Doc->docToCSetups.clear();
814
QDomElement tocElem = TOC.toElement();
815
if(tocElem.tagName() == "TableOfContents")
818
tocsetup.name=tocElem.attribute("Name");
819
tocsetup.itemAttrName=tocElem.attribute("ItemAttributeName");
820
tocsetup.frameName=tocElem.attribute("FrameName");
821
tocsetup.listNonPrintingFrames= QVariant(tocElem.attribute("ListNonPrinting")).toBool();
822
tocsetup.textStyle=tocElem.attribute("Style");
823
QString numberPlacement=tocElem.attribute("NumberPlacement");
824
if (numberPlacement=="Beginning")
825
tocsetup.pageLocation=Beginning;
826
if (numberPlacement=="End")
827
tocsetup.pageLocation=End;
828
if (numberPlacement=="NotShown")
829
tocsetup.pageLocation=NotShown;
830
m_Doc->docToCSetups.append(tocsetup);
832
TOC = TOC.nextSibling();
835
if(pg.tagName()=="Sections")
837
QDomNode Section = PAGE.firstChild();
838
while(!Section.isNull())
840
QDomElement sectionElem = Section.toElement();
841
if(sectionElem.tagName() == "Section")
843
struct DocumentSection newSection;
844
newSection.number=sectionElem.attribute("Number").toInt();
845
newSection.name=sectionElem.attribute("Name");
846
newSection.fromindex=sectionElem.attribute("From").toInt();
847
newSection.toindex=sectionElem.attribute("To").toInt();
848
if (sectionElem.attribute("Type")=="Type_1_2_3")
849
newSection.type=Type_1_2_3;
850
if (sectionElem.attribute("Type")=="Type_i_ii_iii")
851
newSection.type=Type_i_ii_iii;
852
if (sectionElem.attribute("Type")=="Type_I_II_III")
853
newSection.type=Type_I_II_III;
854
if (sectionElem.attribute("Type")=="Type_a_b_c")
855
newSection.type=Type_a_b_c;
856
if (sectionElem.attribute("Type")=="Type_A_B_C")
857
newSection.type=Type_A_B_C;
858
if (sectionElem.attribute("Type")=="Type_None")
859
newSection.type=Type_None;
860
newSection.sectionstartindex=sectionElem.attribute("Start").toInt();
861
newSection.reversed=static_cast<bool>(sectionElem.attribute("Reversed").toInt());
862
newSection.active=static_cast<bool>(sectionElem.attribute("Active").toInt());
863
m_Doc->sections.insert(newSection.number, newSection);
865
Section = Section.nextSibling();
868
if (pg.tagName()=="HYPHEN")
870
QDomNode hyelm = pg.firstChild();
871
while(!hyelm.isNull())
873
QDomElement hyElem = hyelm.toElement();
874
if (hyElem.tagName()=="EXCEPTION")
876
QString word = hyElem.attribute("WORD");
877
QString hyph = hyElem.attribute("HYPHENATED");
878
m_Doc->docHyphenator->specialWords.insert(word, hyph);
880
else if (hyElem.tagName()=="IGNORE")
882
QString word = hyElem.attribute("WORD");
883
m_Doc->docHyphenator->ignoredWords.insert(word);
885
hyelm = hyelm.nextSibling();
888
if ((pg.tagName()=="PAGE") || (pg.tagName()=="MASTERPAGE"))
890
a = pg.attribute("NUM").toInt();
892
PgNam = pg.attribute("NAM", "");
893
if (pg.tagName()=="MASTERPAGE" && PgNam.isEmpty())
895
qDebug() << "scribus134format: corrupted masterpage with empty name detected";
896
PAGE=PAGE.nextSibling();
899
//Pgc = m_Doc->pageCount;
900
//AtFl = m_Doc->usesAutomaticTextFrames();
903
//m_Doc->pageCount = Pgc;
904
//m_Doc->Pages = &m_Doc->DocPages;
905
//m_Doc->setUsesAutomaticTextFrames(AtFl);
906
m_Doc->setMasterPageMode(false);
910
//m_Doc->pageCount = 0;
911
//m_Doc->setUsesAutomaticTextFrames(false);
912
//m_Doc->Pages = &m_Doc->MasterPages;
913
m_Doc->setMasterPageMode(true);
915
//CB: Stop calling damn GUI code in loading docs! IT doesnt *look* like
916
//this makes a difference apart from being faster, of course.
917
//ScMW->slotNewPage(a);
918
//Apage = m_Doc->Pages.at(a);
921
Apage = m_Doc->addPage(a);
922
//m_Doc->DocPages = m_Doc->Pages;
923
//++m_Doc->pageCount;
927
Apage = m_Doc->addMasterPage(a, PgNam);
928
//Apage->setPageName(PgNam);
929
//m_Doc->MasterNames[PgNam] = a;
930
//m_Doc->MasterPages = m_Doc->Pages;
931
//m_Doc->pageCount = Pgc;
933
//m_Doc->setUsesAutomaticTextFrames(AtFl);
934
Apage->LeftPg=pg.attribute("LEFT", "0").toInt();
936
Mus = pg.attribute("MNAM","Normal");
937
if (!m_Doc->masterPageMode())
938
Apage->MPageNam = Mus;
940
Apage->MPageNam = "";
941
if (pg.hasAttribute("Size"))
942
Apage->m_pageSize = pg.attribute("Size");
943
if (pg.hasAttribute("Orientation"))
944
Apage->PageOri = pg.attribute("Orientation").toInt();
945
Apage->setXOffset(ScCLocale::toDoubleC(pg.attribute("PAGEXPOS")));
946
Apage->setYOffset(ScCLocale::toDoubleC(pg.attribute("PAGEYPOS")));
947
if (pg.hasAttribute("PAGEWIDTH"))
948
Apage->setWidth(ScCLocale::toDoubleC(pg.attribute("PAGEWIDTH")));
950
Apage->setWidth(ScCLocale::toDoubleC(pg.attribute("PAGEWITH")));
951
Apage->setHeight(ScCLocale::toDoubleC(pg.attribute("PAGEHEIGHT")));
952
Apage->setInitialHeight(Apage->height());
953
Apage->setInitialWidth(Apage->width());
954
Apage->initialMargins.Top = qMax(0.0, ScCLocale::toDoubleC( pg.attribute("BORDERTOP")));
955
Apage->initialMargins.Bottom = qMax(0.0, ScCLocale::toDoubleC(pg.attribute("BORDERBOTTOM")));
956
Apage->initialMargins.Left = qMax(0.0, ScCLocale::toDoubleC(pg.attribute("BORDERLEFT")));
957
Apage->initialMargins.Right = qMax(0.0,ScCLocale::toDoubleC( pg.attribute("BORDERRIGHT")));
958
Apage->marginPreset = pg.attribute("PRESET", "0").toInt();
959
Apage->Margins.Top = Apage->initialMargins.Top;
960
Apage->Margins.Bottom = Apage->initialMargins.Bottom;
961
m_Doc->setMasterPageMode(false);
962
//m_Doc->Pages=&m_Doc->DocPages;
965
Apage->guides.setHorizontalAutoGap(ScCLocale::toDoubleC(pg.attribute("AGhorizontalAutoGap"), 0.0));
966
Apage->guides.setVerticalAutoGap(ScCLocale::toDoubleC(pg.attribute("AGverticalAutoGap"), 0.0));
967
Apage->guides.setHorizontalAutoCount(pg.attribute("AGhorizontalAutoCount", "0").toInt());
968
Apage->guides.setVerticalAutoCount(pg.attribute("AGverticalAutoCount", "0").toInt());
969
Apage->guides.setHorizontalAutoRefer(pg.attribute("AGhorizontalAutoRefer", "0").toInt());
970
Apage->guides.setVerticalAutoRefer(pg.attribute("AGverticalAutoRefer", "0").toInt());
971
GuideManagerIO::readVerticalGuides(pg.attribute("VerticalGuides"),
973
GuideManagerCore::Standard,
974
pg.hasAttribute("NumVGuides"));
975
GuideManagerIO::readHorizontalGuides(pg.attribute("HorizontalGuides"),
977
GuideManagerCore::Standard,
978
pg.hasAttribute("NumHGuides"));
979
GuideManagerIO::readSelection(pg.attribute("AGSelection"), Apage);
981
Apage->guides.addHorizontals(Apage->guides.getAutoHorizontals(Apage), GuideManagerCore::Auto);
982
Apage->guides.addVerticals(Apage->guides.getAutoVerticals(Apage), GuideManagerCore::Auto);
984
if ((pg.tagName()=="PAGEOBJECT") || (pg.tagName()=="MASTEROBJECT") || (pg.tagName()=="FRAMEOBJECT"))
986
if ((pg.tagName()=="PAGEOBJECT") || (pg.tagName()=="FRAMEOBJECT"))
988
//m_Doc->Items = m_Doc->DocItems;
989
//m_Doc->Pages = &m_Doc->DocPages;
990
m_Doc->setMasterPageMode(false);
994
//m_Doc->Items = m_Doc->MasterItems;
995
//m_Doc->Pages = &m_Doc->MasterPages;
996
m_Doc->setMasterPageMode(true);
998
//CB comment out as no longer used int docGc = m_Doc->GroupCounter,
1000
if ((!pg.attribute("OnMasterPage").isEmpty()) && (pg.tagName()=="MASTEROBJECT"))
1002
m_Doc->setCurrentPage(m_Doc->MasterPages.at(m_Doc->MasterNames[pg.attribute("OnMasterPage")]));
1005
/*m_Doc->GroupCounter = 0;*/
1006
Neu = PasteItem(&pg, m_Doc, fileDir, pagenr);
1007
Neu->setRedrawBounding();
1008
if (pg.tagName()=="MASTEROBJECT")
1009
Neu->OwnPage = m_Doc->OnPage(Neu);
1011
Neu->OwnPage = pg.attribute("OwnPage").toInt();
1012
if (pg.tagName()=="PAGEOBJECT")
1013
Neu->OnMasterPage = "";
1014
/*m_Doc->GroupCounter = docGc;*/
1015
tmpf = pg.attribute("IFONT", m_Doc->toolSettings.defFont);
1016
m_AvailableFonts->findFont(tmpf, m_Doc);
1017
QDomNode IT=pg.firstChild();
1018
LastStyles * last = new LastStyles();
1021
QDomElement it=IT.toElement();
1022
if (it.tagName()=="CSTOP")
1024
QString name = it.attribute("NAME");
1025
double ramp = ScCLocale::toDoubleC( it.attribute("RAMP"), 0.0);
1026
int shade = it.attribute("SHADE", "100").toInt();
1027
double opa = ScCLocale::toDoubleC( it.attribute("TRANS"), 1.0);
1028
Neu->fill_gradient.addStop(SetColor(m_Doc, name, shade), ramp, 0.5, opa, name, shade);
1030
if (it.tagName()=="ITEXT")
1031
GetItemText(&it, m_Doc, Neu, last);
1032
else if (it.tagName()=="para")
1034
Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::PARSEP);
1035
ParagraphStyle newStyle;
1036
PrefsManager* prefsManager=PrefsManager::instance();
1037
readParagraphStyle(newStyle, it, prefsManager->appPrefs.AvailFonts, m_Doc);
1038
Neu->itemText.setStyle(Neu->itemText.length()-1, newStyle);
1039
Neu->itemText.setCharStyle(Neu->itemText.length()-1, 1, last->Style);
1041
else if (it.tagName() == "trail")
1043
ParagraphStyle newStyle;
1044
PrefsManager* prefsManager = PrefsManager::instance();
1045
readParagraphStyle(newStyle, it, prefsManager->appPrefs.AvailFonts, m_Doc);
1046
Neu->itemText.setStyle(Neu->itemText.length(), newStyle);
1048
else if (it.tagName()=="tab")
1051
Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::TAB);
1052
GetCStyle(&it, m_Doc, newStyle);
1053
Neu->itemText.setCharStyle(Neu->itemText.length()-1, 1, newStyle);
1054
last->StyleStart = Neu->itemText.length()-1;
1055
last->Style = newStyle;
1057
else if (it.tagName()=="breakline")
1058
Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::LINEBREAK);
1059
else if (it.tagName()=="breakcol")
1060
Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::COLBREAK);
1061
else if (it.tagName()=="breakframe")
1062
Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::FRAMEBREAK);
1063
else if (it.tagName()=="nbhyphen")
1064
Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::NBHYPHEN);
1065
else if (it.tagName()=="nbspace")
1066
Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::NBSPACE);
1067
else if (it.tagName()=="zwnbspace")
1068
Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::ZWNBSPACE);
1069
else if (it.tagName()=="zwspace")
1070
Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::ZWSPACE);
1071
else if (it.tagName()=="var")
1073
if (it.attribute("name") == "pgno")
1074
Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::PAGENUMBER);
1076
Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::PAGECOUNT);
1078
GetCStyle(&it, m_Doc, newStyle);
1079
Neu->itemText.setCharStyle(Neu->itemText.length()-1, 1, newStyle);
1080
last->StyleStart = Neu->itemText.length()-1;
1081
last->Style = newStyle;
1084
//CB PageItemAttributes
1085
if(it.tagName()=="PageItemAttributes")
1087
QDomNode PIA = it.firstChild();
1088
ObjAttrVector pageItemAttributes;
1089
while(!PIA.isNull())
1091
QDomElement itemAttr = PIA.toElement();
1092
if(itemAttr.tagName() == "ItemAttribute")
1094
ObjectAttribute objattr;
1095
objattr.name=itemAttr.attribute("Name");
1096
objattr.type=itemAttr.attribute("Type");
1097
objattr.value=itemAttr.attribute("Value");
1098
objattr.parameter=itemAttr.attribute("Parameter");
1099
objattr.relationship=itemAttr.attribute("Relationship");
1100
objattr.relationshipto=itemAttr.attribute("RelationshipTo");
1101
objattr.autoaddto=itemAttr.attribute("AutoAddTo");
1102
pageItemAttributes.append(objattr);
1104
PIA = PIA.nextSibling();
1106
Neu->setObjectAttributes(&pageItemAttributes);
1108
IT=IT.nextSibling();
1110
if (Neu->asTextFrame())
1114
for (int i=0; i < Neu->itemText.length(); ++i)
1116
dbg += Neu->itemText.text(i,1);
1117
if (Neu->itemText.item(i)->effects() & ScStyle_HyphenationPossible)
1120
qDebug("scribus134format: read itemtext '%s'", dbg.latin1());
1122
if (Neu->asPathText())
1124
Neu->updatePolyClip();
1128
if (Neu->fill_gradient.Stops() == 0)
1130
const ScColor& col1 = m_Doc->PageColors[m_Doc->toolSettings.dBrush];
1131
const ScColor& col2 = m_Doc->PageColors[m_Doc->toolSettings.dPen];
1132
Neu->fill_gradient.addStop(ScColorEngine::getRGBColor(col1, m_Doc), 0.0, 0.5, 1.0, m_Doc->toolSettings.dBrush, 100);
1133
Neu->fill_gradient.addStop(ScColorEngine::getRGBColor(col2, m_Doc), 1.0, 0.5, 1.0, m_Doc->toolSettings.dPen, 100);
1135
// Neu->Language = ScMW->GetLang(pg.attribute("LANGUAGE", m_Doc->Language));
1136
Neu->isAutoText = static_cast<bool>(pg.attribute("AUTOTEXT").toInt());
1137
Neu->isEmbedded = static_cast<bool>(pg.attribute("isInline", "0").toInt());
1138
Neu->gXpos = ScCLocale::toDoubleC( pg.attribute("gXpos"), 0.0);
1139
Neu->gYpos = ScCLocale::toDoubleC( pg.attribute("gYpos"), 0.0);
1140
Neu->gWidth = ScCLocale::toDoubleC( pg.attribute("gWidth"), Neu->width());
1141
Neu->gHeight = ScCLocale::toDoubleC( pg.attribute("gHeight"), Neu->height());
1142
if (Neu->isAutoText)
1143
m_Doc->LastAuto = Neu;
1144
// first of linked chain?
1145
if (pg.tagName()=="PAGEOBJECT")
1147
if (pg.attribute("NEXTITEM").toInt() != -1)
1148
itemNext[Neu->ItemNr] = pg.attribute("NEXTITEM").toInt();
1150
else if (pg.tagName()=="MASTEROBJECT")
1152
if (pg.attribute("NEXTITEM").toInt() != -1)
1153
itemNextM[Neu->ItemNr] = pg.attribute("NEXTITEM").toInt();
1155
/* not sure if we want that...
1156
else if (pg.tagName()=="FRAMEOBJECT")
1158
if (pg.attribute("NEXTITEM").toInt() != -1)
1159
itemNextF[Neu->ItemNr] = pg.attribute("NEXTITEM").toInt();
1162
if (pg.tagName()=="FRAMEOBJECT")
1164
m_Doc->FrameItems.append(m_Doc->Items->takeAt(Neu->ItemNr));
1165
Neu->ItemNr = m_Doc->FrameItems.count()-1;
1167
if (Neu->isTableItem)
1169
if (pg.tagName()=="PAGEOBJECT")
1171
TableItems.append(Neu);
1172
TableID.insert(pg.attribute("OwnLINK", "0").toInt(), Neu->ItemNr);
1174
else if (pg.tagName()=="FRAMEOBJECT")
1176
TableItemsF.append(Neu);
1177
TableIDF.insert(pg.attribute("OwnLINK", "0").toInt(), Neu->ItemNr);
1181
TableItemsM.append(Neu);
1182
TableIDM.insert(pg.attribute("OwnLINK", "0").toInt(), Neu->ItemNr);
1185
Neu->isGroupControl = static_cast<bool>(pg.attribute("isGroupControl", "0").toInt());
1186
if (Neu->isGroupControl)
1188
int groupLastItem = pg.attribute("groupsLastItem", "0").toInt();
1189
if ((Neu->Groups.count() == 0) || (groupLastItem <= 0)) // Sanity check for some broken files created using buggy development versions.
1191
Neu->isGroupControl = false;
1192
Neu->setFillColor("None");
1196
if (pg.tagName()=="PAGEOBJECT")
1197
groupID.insert(Neu, groupLastItem + Neu->ItemNr);
1198
else if (pg.tagName()=="FRAMEOBJECT")
1199
groupIDF.insert(Neu, groupLastItem + Neu->ItemNr);
1201
groupIDM.insert(Neu, groupLastItem + Neu->ItemNr);
1204
m_Doc->setMasterPageMode(false);
1207
PAGE=PAGE.nextSibling();
1209
PAGE=DOC.firstChild();
1210
while(!PAGE.isNull())
1212
QDomElement pg=PAGE.toElement();
1213
if(pg.tagName()=="Bookmark")
1215
int elem = pg.attribute("Element").toInt();
1216
if (elem < m_Doc->Items->count())
1218
bok.Title = pg.attribute("Title");
1219
bok.Text = pg.attribute("Text");
1220
bok.Aktion = pg.attribute("Aktion");
1221
bok.ItemNr = pg.attribute("ItemNr").toInt();
1222
bok.PageObject = m_Doc->Items->at(elem);
1223
bok.First = pg.attribute("First").toInt();
1224
bok.Last = pg.attribute("Last").toInt();
1225
bok.Prev = pg.attribute("Prev").toInt();
1226
bok.Next = pg.attribute("Next").toInt();
1227
bok.Parent = pg.attribute("Parent").toInt();
1228
m_Doc->BookMarks.append(bok);
1231
if(pg.tagName()=="Pattern")
1233
QMap<PageItem*, int> groupID2;
1234
QMap<int,int> TableID2;
1235
QList<PageItem*> TableItems2;
1237
QDomNode pa = PAGE.firstChild();
1238
uint ac = m_Doc->Items->count();
1239
bool savedAlignGrid = m_Doc->useRaster;
1240
bool savedAlignGuides = m_Doc->SnapGuides;
1241
m_Doc->useRaster = false;
1242
m_Doc->SnapGuides = false;
1245
QDomElement pite = pa.toElement();
1246
m_Doc->setMasterPageMode(false);
1247
//int docGc = m_Doc->GroupCounter;
1248
/*m_Doc->GroupCounter = 0;*/
1249
Neu = PasteItem(&pite, m_Doc, fileDir);
1250
Neu->setRedrawBounding();
1251
Neu->OwnPage = pite.attribute("OwnPage").toInt();
1252
Neu->OnMasterPage = "";
1253
/*m_Doc->GroupCounter = docGc;*/
1254
tmpf = pite.attribute("IFONT", m_Doc->toolSettings.defFont);
1255
m_AvailableFonts->findFont(tmpf, m_Doc);
1256
QDomNode IT=pite.firstChild();
1257
LastStyles * last = new LastStyles();
1260
QDomElement it=IT.toElement();
1261
if (it.tagName()=="CSTOP")
1263
QString name = it.attribute("NAME");
1264
double ramp = ScCLocale::toDoubleC( it.attribute("RAMP"), 0.0);
1265
int shade = it.attribute("SHADE", "100").toInt();
1266
double opa = ScCLocale::toDoubleC( it.attribute("TRANS"), 1.0);
1267
Neu->fill_gradient.addStop(SetColor(m_Doc, name, shade), ramp, 0.5, opa, name, shade);
1269
if (it.tagName()=="ITEXT")
1270
GetItemText(&it, m_Doc, Neu, last);
1271
else if (it.tagName()=="para")
1273
Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::PARSEP);
1274
ParagraphStyle newStyle;
1275
PrefsManager* prefsManager=PrefsManager::instance();
1276
readParagraphStyle(newStyle, it, prefsManager->appPrefs.AvailFonts, m_Doc);
1277
Neu->itemText.setStyle(Neu->itemText.length()-1, newStyle);
1278
Neu->itemText.setCharStyle(Neu->itemText.length()-1, 1, last->Style);
1280
else if (it.tagName() == "trail")
1282
ParagraphStyle newStyle;
1283
PrefsManager* prefsManager = PrefsManager::instance();
1284
readParagraphStyle(newStyle, it, prefsManager->appPrefs.AvailFonts, m_Doc);
1285
Neu->itemText.setStyle(Neu->itemText.length(), newStyle);
1287
else if (it.tagName()=="tab")
1290
Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::TAB);
1291
GetCStyle(&it, m_Doc, newStyle);
1292
Neu->itemText.setCharStyle(Neu->itemText.length()-1, 1, newStyle);
1293
last->StyleStart = Neu->itemText.length()-1;
1294
last->Style = newStyle;
1296
else if (it.tagName()=="breakline")
1297
Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::LINEBREAK);
1298
else if (it.tagName()=="breakcol")
1299
Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::COLBREAK);
1300
else if (it.tagName()=="breakframe")
1301
Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::FRAMEBREAK);
1302
else if (it.tagName()=="nbhyphen")
1303
Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::NBHYPHEN);
1304
else if (it.tagName()=="nbspace")
1305
Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::NBSPACE);
1306
else if (it.tagName()=="zwnbspace")
1307
Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::ZWNBSPACE);
1308
else if (it.tagName()=="zwspace")
1309
Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::ZWSPACE);
1310
else if (it.tagName()=="var")
1312
if (it.attribute("name") == "pgno")
1313
Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::PAGENUMBER);
1315
Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::PAGECOUNT);
1317
GetCStyle(&it, m_Doc, newStyle);
1318
Neu->itemText.setCharStyle(Neu->itemText.length()-1, 1, newStyle);
1319
last->StyleStart = Neu->itemText.length()-1;
1320
last->Style = newStyle;
1323
if(it.tagName()=="PageItemAttributes")
1325
QDomNode PIA = it.firstChild();
1326
ObjAttrVector pageItemAttributes;
1327
while(!PIA.isNull())
1329
QDomElement itemAttr = PIA.toElement();
1330
if(itemAttr.tagName() == "ItemAttribute")
1332
ObjectAttribute objattr;
1333
objattr.name=itemAttr.attribute("Name");
1334
objattr.type=itemAttr.attribute("Type");
1335
objattr.value=itemAttr.attribute("Value");
1336
objattr.parameter=itemAttr.attribute("Parameter");
1337
objattr.relationship=itemAttr.attribute("Relationship");
1338
objattr.relationshipto=itemAttr.attribute("RelationshipTo");
1339
objattr.autoaddto=itemAttr.attribute("AutoAddTo");
1340
pageItemAttributes.append(objattr);
1342
PIA = PIA.nextSibling();
1344
Neu->setObjectAttributes(&pageItemAttributes);
1346
IT=IT.nextSibling();
1349
if (Neu->asPathText())
1351
Neu->updatePolyClip();
1354
if (Neu->fill_gradient.Stops() == 0)
1356
const ScColor& col1 = m_Doc->PageColors[m_Doc->toolSettings.dBrush];
1357
const ScColor& col2 = m_Doc->PageColors[m_Doc->toolSettings.dPen];
1358
Neu->fill_gradient.addStop(ScColorEngine::getRGBColor(col1, m_Doc), 0.0, 0.5, 1.0, m_Doc->toolSettings.dBrush, 100);
1359
Neu->fill_gradient.addStop(ScColorEngine::getRGBColor(col2, m_Doc), 1.0, 0.5, 1.0, m_Doc->toolSettings.dPen, 100);
1361
Neu->isAutoText = static_cast<bool>(pite.attribute("AUTOTEXT").toInt());
1362
Neu->isEmbedded = static_cast<bool>(pite.attribute("isInline", "0").toInt());
1363
Neu->gXpos = ScCLocale::toDoubleC( pite.attribute("gXpos"), 0.0);
1364
Neu->gYpos = ScCLocale::toDoubleC( pite.attribute("gYpos"), 0.0);
1365
Neu->gWidth = ScCLocale::toDoubleC( pite.attribute("gWidth"), Neu->width());
1366
Neu->gHeight = ScCLocale::toDoubleC( pite.attribute("gHeight"), Neu->height());
1367
if (Neu->isTableItem)
1369
TableItems2.append(Neu);
1370
TableID2.insert(pite.attribute("OwnLINK", "0").toInt(), Neu->ItemNr);
1372
Neu->isGroupControl = static_cast<bool>(pite.attribute("isGroupControl", "0").toInt());
1373
if (Neu->isGroupControl)
1375
int groupLastItem = pg.attribute("groupsLastItem", "0").toInt();
1376
if ((Neu->Groups.count() == 0) || (groupLastItem <= 0)) // Sanity check for some broken files created using buggy development versions.
1378
Neu->isGroupControl = false;
1379
Neu->setFillColor("None");
1382
groupID2.insert(Neu, pite.attribute("groupsLastItem", "0").toInt()+Neu->ItemNr);
1384
pa = pa.nextSibling();
1386
if (groupID2.count() != 0)
1388
QMap<PageItem*, int>::Iterator it;
1389
for (it = groupID2.begin(); it != groupID2.end(); ++it)
1391
it.key()->groupsLastItem = m_Doc->Items->at(it.value());
1394
if (TableItems2.count() != 0)
1396
for (int ttc = 0; ttc < TableItems2.count(); ++ttc)
1398
PageItem* ta = TableItems2.at(ttc);
1399
if (ta->TopLinkID != -1)
1400
ta->TopLink = m_Doc->Items->at(TableID2[ta->TopLinkID]);
1403
if (ta->LeftLinkID != -1)
1404
ta->LeftLink = m_Doc->Items->at(TableID2[ta->LeftLinkID]);
1407
if (ta->RightLinkID != -1)
1408
ta->RightLink = m_Doc->Items->at(TableID2[ta->RightLinkID]);
1411
if (ta->BottomLinkID != -1)
1412
ta->BottomLink = m_Doc->Items->at(TableID2[ta->BottomLinkID]);
1417
m_Doc->useRaster = savedAlignGrid;
1418
m_Doc->SnapGuides = savedAlignGuides;
1419
uint ae = m_Doc->Items->count();
1421
pat.width = ScCLocale::toDoubleC( pg.attribute("width"), 0.0);
1422
pat.height = ScCLocale::toDoubleC( pg.attribute("height"), 0.0);
1423
pat.scaleX = ScCLocale::toDoubleC( pg.attribute("scaleX"), 0.0);
1424
pat.scaleY = ScCLocale::toDoubleC( pg.attribute("scaleY"), 0.0);
1425
pat.xoffset = ScCLocale::toDoubleC( pg.attribute("xoffset"), 0.0);
1426
pat.yoffset = ScCLocale::toDoubleC( pg.attribute("yoffset"), 0.0);
1429
PageItem* currItem = m_Doc->Items->at(ac);
1430
pat.pattern = currItem->DrawObj_toImage();
1431
pat.pattern = pat.pattern.copy(-pat.xoffset, -pat.yoffset, pat.width, pat.height);
1432
for (uint as = ac; as < ae; ++as)
1434
Neu = m_Doc->Items->takeAt(ac);
1435
Neu->moveBy(pat.xoffset, pat.yoffset, true);
1436
Neu->gXpos += pat.xoffset;
1437
Neu->gYpos += pat.yoffset;
1438
Neu->ItemNr = pat.items.count();
1439
pat.items.append(Neu);
1442
QString patName = pg.attribute("Name");
1443
if (!patName.isEmpty())
1444
m_Doc->docPatterns.insert(patName, pat);
1446
PAGE=PAGE.nextSibling();
1448
DOC=DOC.nextSibling();
1450
if (TableItemsF.count() != 0)
1452
for (int ttc = 0; ttc < TableItemsF.count(); ++ttc)
1454
PageItem* ta = TableItemsF.at(ttc);
1455
if (ta->TopLinkID != -1)
1456
ta->TopLink = m_Doc->FrameItems.at(TableIDF[ta->TopLinkID]);
1459
if (ta->LeftLinkID != -1)
1460
ta->LeftLink = m_Doc->FrameItems.at(TableIDF[ta->LeftLinkID]);
1463
if (ta->RightLinkID != -1)
1464
ta->RightLink = m_Doc->FrameItems.at(TableIDF[ta->RightLinkID]);
1467
if (ta->BottomLinkID != -1)
1468
ta->BottomLink = m_Doc->FrameItems.at(TableIDF[ta->BottomLinkID]);
1473
if (TableItemsM.count() != 0)
1475
for (int ttc = 0; ttc < TableItemsM.count(); ++ttc)
1477
PageItem* ta = TableItemsM.at(ttc);
1478
if (ta->TopLinkID != -1)
1479
ta->TopLink = m_Doc->MasterItems.at(TableIDM[ta->TopLinkID]);
1482
if (ta->LeftLinkID != -1)
1483
ta->LeftLink = m_Doc->MasterItems.at(TableIDM[ta->LeftLinkID]);
1486
if (ta->RightLinkID != -1)
1487
ta->RightLink = m_Doc->MasterItems.at(TableIDM[ta->RightLinkID]);
1490
if (ta->BottomLinkID != -1)
1491
ta->BottomLink = m_Doc->MasterItems.at(TableIDM[ta->BottomLinkID]);
1496
if (TableItems.count() != 0)
1498
for (int ttc = 0; ttc < TableItems.count(); ++ttc)
1500
PageItem* ta = TableItems.at(ttc);
1501
if (ta->TopLinkID != -1)
1502
ta->TopLink = m_Doc->Items->at(TableID[ta->TopLinkID]);
1505
if (ta->LeftLinkID != -1)
1506
ta->LeftLink = m_Doc->Items->at(TableID[ta->LeftLinkID]);
1509
if (ta->RightLinkID != -1)
1510
ta->RightLink = m_Doc->Items->at(TableID[ta->RightLinkID]);
1513
if (ta->BottomLinkID != -1)
1514
ta->BottomLink = m_Doc->Items->at(TableID[ta->BottomLinkID]);
1519
if (groupIDF.count() != 0)
1521
QMap<PageItem*, int>::Iterator it;
1522
for (it = groupIDF.begin(); it != groupIDF.end(); ++it)
1524
it.key()->groupsLastItem = m_Doc->FrameItems.at(it.value());
1527
if (groupID.count() != 0)
1529
QMap<PageItem*, int>::Iterator it;
1530
for (it = groupID.begin(); it != groupID.end(); ++it)
1532
it.key()->groupsLastItem = m_Doc->DocItems.at(it.value());
1535
if (groupIDM.count() != 0)
1537
QMap<PageItem*, int>::Iterator it;
1538
for (it = groupIDM.begin(); it != groupIDM.end(); ++it)
1540
it.key()->groupsLastItem = m_Doc->MasterItems.at(it.value());
1543
m_Doc->setActiveLayer(layerToSetActive);
1544
m_Doc->setMasterPageMode(false);
1545
m_Doc->reformPages();
1547
if (m_Doc->Layers.count() == 0)
1548
m_Doc->Layers.newLayer( QObject::tr("Background") );
1550
// reestablish textframe links
1551
if (itemNext.count() != 0)
1553
QMap<int,int>::Iterator lc;
1554
for (lc = itemNext.begin(); lc != itemNext.end(); ++lc)
1556
if (lc.value() >= 0)
1558
PageItem * Its = m_Doc->DocItems.at(lc.key());
1559
PageItem * Itn = m_Doc->DocItems.at(lc.value());
1560
if (Itn->prevInChain() || Its->nextInChain())
1562
qDebug() << "scribus134format: corruption in linked textframes detected";
1570
if (itemNextM.count() != 0)
1572
QMap<int,int>::Iterator lc;
1573
for (lc = itemNextM.begin(); lc != itemNextM.end(); ++lc)
1575
if (lc.value() >= 0)
1577
PageItem * Its = m_Doc->MasterItems.at(lc.key());
1578
PageItem * Itn = m_Doc->MasterItems.at(lc.value());
1579
if (Itn->prevInChain() || Its->nextInChain())
1581
qDebug() << "scribus134format: corruption in linked textframes detected";
1589
// reestablish first/lastAuto
1590
m_Doc->FirstAuto = m_Doc->LastAuto;
1591
if (m_Doc->LastAuto)
1593
while (m_Doc->LastAuto->nextInChain())
1594
m_Doc->LastAuto = m_Doc->LastAuto->nextInChain();
1595
while (m_Doc->FirstAuto->prevInChain())
1596
m_Doc->FirstAuto = m_Doc->FirstAuto->prevInChain();
1599
// start auto save timer if needed
1600
if (m_Doc->AutoSave && ScCore->usingGUI())
1601
m_Doc->autoSaveTimer->start(m_Doc->AutoSaveTime);
1603
if (m_mwProgressBar!=0)
1604
m_mwProgressBar->setValue(DOC.childNodes().count());
1610
// Low level plugin API
1611
int scribus134format_getPluginAPIVersion()
1613
return PLUGIN_API_VERSION;
1616
ScPlugin* scribus134format_getPlugin()
1618
Scribus134Format* plug = new Scribus134Format();
1623
void scribus134format_freePlugin(ScPlugin* plugin)
1625
Scribus134Format* plug = dynamic_cast<Scribus134Format*>(plugin);
1632
const int NOVALUE = -16000;
1634
void fixLegacyCharStyle(CharStyle& cstyle)
1636
if (! cstyle.font().usable())
1638
if (cstyle.fontSize() <= -16000 / 10)
1639
cstyle.resetFontSize();
1640
// if (cstyle.effects() == 65535)
1641
// cstyle.resetEffects();
1642
if (cstyle.fillColor().isEmpty())
1643
cstyle.resetFillColor();
1644
if (cstyle.fillShade() <= -16000)
1645
cstyle.resetFillShade();
1646
if (cstyle.strokeColor().isEmpty())
1647
cstyle.resetStrokeColor();
1648
if (cstyle.strokeShade() <= -16000)
1649
cstyle.resetStrokeShade();
1650
if (cstyle.shadowXOffset() <= -16000 / 10)
1651
cstyle.resetShadowXOffset();
1652
if (cstyle.shadowYOffset() <= -16000 / 10)
1653
cstyle.resetShadowYOffset();
1654
if (cstyle.outlineWidth() <= -16000 / 10)
1655
cstyle.resetOutlineWidth();
1656
if (cstyle.underlineOffset() <= -16000 / 10)
1657
cstyle.resetUnderlineOffset();
1658
if (cstyle.underlineWidth() <= -16000 / 10)
1659
cstyle.resetUnderlineWidth();
1660
if (cstyle.strikethruOffset() <= -16000 / 10)
1661
cstyle.resetStrikethruOffset();
1662
if (cstyle.strikethruWidth() <= -16000 / 10)
1663
cstyle.resetStrikethruWidth();
1664
if (cstyle.scaleH() <= -16000 / 10)
1665
cstyle.resetScaleH();
1666
if (cstyle.scaleV() <= -16000 / 10)
1667
cstyle.resetScaleV();
1668
if (cstyle.baselineOffset() <= -16000 / 10)
1669
cstyle.resetBaselineOffset();
1670
if (cstyle.tracking() <= -16000 / 10)
1671
cstyle.resetTracking();
1674
void fixLegacyParStyle(ParagraphStyle& pstyle)
1676
if (pstyle.lineSpacing() <= -16000)
1677
pstyle.resetLineSpacing();
1678
if (pstyle.leftMargin() <= -16000)
1679
pstyle.resetLeftMargin();
1680
if (pstyle.rightMargin() <= -16000)
1681
pstyle.resetRightMargin();
1682
if (pstyle.firstIndent() <= -16000)
1683
pstyle.resetFirstIndent();
1684
if (pstyle.alignment() < 0)
1685
pstyle.resetAlignment();
1686
if (pstyle.gapBefore() <= -16000)
1687
pstyle.resetGapBefore();
1688
if (pstyle.gapAfter() <= -16000)
1689
pstyle.resetGapAfter();
1690
if (pstyle.dropCapLines() < 0)
1691
pstyle.resetDropCapLines();
1692
if (pstyle.dropCapOffset() <= -16000)
1693
pstyle.resetDropCapOffset();
1694
fixLegacyCharStyle(pstyle.charStyle());
1700
void Scribus134Format::GetCStyle(const QDomElement *it, ScribusDoc *doc, CharStyle & newStyle)
1702
if (it->hasAttribute("CNAME"))
1703
newStyle.setName(it->attribute("CNAME"));
1704
// The default style attribute must be correctly set before trying to assign a parent
1705
if (newStyle.hasName() && it->hasAttribute("DefaultStyle"))
1706
newStyle.setDefaultStyle(it->attribute("DefaultStyle").toInt());
1707
else if (newStyle.name() == CommonStrings::DefaultCharacterStyle || newStyle.name() == CommonStrings::trDefaultCharacterStyle)
1708
newStyle.setDefaultStyle(true);
1710
newStyle.setDefaultStyle(false);
1711
if (it->hasAttribute("CPARENT"))
1712
newStyle.setParent(it->attribute("CPARENT"));
1713
if (it->hasAttribute("FONT"))
1714
newStyle.setFont(m_AvailableFonts->findFont(it->attribute("FONT"),doc));
1716
if (it->hasAttribute("FONTSIZE"))
1717
newStyle.setFontSize(qRound(ScCLocale::toDoubleC(it->attribute("FONTSIZE")) * 10));
1719
if (it->hasAttribute("FCOLOR"))
1720
newStyle.setFillColor(it->attribute("FCOLOR"));
1722
if (it->hasAttribute("KERN"))
1723
newStyle.setTracking(qRound(ScCLocale::toDoubleC(it->attribute("KERN")) * 10));
1725
if (it->hasAttribute("FSHADE"))
1726
newStyle.setFillShade(it->attribute("FSHADE").toInt());
1728
if (it->hasAttribute("EFFECTS"))
1729
newStyle.setFeatures(static_cast<StyleFlag>(it->attribute("EFFECTS").toInt()).featureList());
1731
if (it->hasAttribute("EFFECT"))
1732
newStyle.setFeatures(static_cast<StyleFlag>(it->attribute("EFFECT").toInt()).featureList());
1734
if (it->hasAttribute("FEATURES"))
1735
newStyle.setFeatures(it->attribute("FEATURES").split( " ", QString::SkipEmptyParts));
1737
if (it->hasAttribute("SCOLOR"))
1738
newStyle.setStrokeColor(it->attribute("SCOLOR", CommonStrings::None));
1740
if (it->hasAttribute("SSHADE"))
1741
newStyle.setStrokeShade(it->attribute("SSHADE").toInt());
1743
if (it->hasAttribute("SCALEH"))
1744
newStyle.setScaleH(qRound(ScCLocale::toDoubleC(it->attribute("SCALEH")) * 10));
1746
if (it->hasAttribute("SCALEV"))
1747
newStyle.setScaleV(qRound(ScCLocale::toDoubleC(it->attribute("SCALEV")) * 10));
1749
if (it->hasAttribute("BASEO"))
1750
newStyle.setBaselineOffset(qRound(ScCLocale::toDoubleC(it->attribute("BASEO")) * 10));
1752
if (it->hasAttribute("TXTSHX"))
1753
newStyle.setShadowXOffset(qRound(ScCLocale::toDoubleC(it->attribute("TXTSHX")) * 10));
1755
if (it->hasAttribute("TXTSHY"))
1756
newStyle.setShadowYOffset(qRound(ScCLocale::toDoubleC(it->attribute("TXTSHY")) * 10));
1758
if (it->hasAttribute("TXTOUT"))
1759
newStyle.setOutlineWidth(qRound(ScCLocale::toDoubleC(it->attribute("TXTOUT")) * 10));
1761
if (it->hasAttribute("TXTULP"))
1762
newStyle.setUnderlineOffset(qRound(ScCLocale::toDoubleC(it->attribute("TXTULP")) * 10));
1764
if (it->hasAttribute("TXTULW"))
1765
newStyle.setUnderlineWidth(qRound(ScCLocale::toDoubleC(it->attribute("TXTULW")) * 10));
1767
if (it->hasAttribute("TXTSTP"))
1768
newStyle.setStrikethruOffset(qRound(ScCLocale::toDoubleC(it->attribute("TXTSTP")) * 10));
1770
if (it->hasAttribute("TXTSTW"))
1771
newStyle.setStrikethruWidth(qRound(ScCLocale::toDoubleC(it->attribute("TXTSTW")) * 10));
1773
if (it->hasAttribute("LANGUAGE"))
1774
newStyle.setLanguage(it->attribute("LANGUAGE"));
1776
if (it->hasAttribute("SHORTCUT"))
1777
newStyle.setShortcut(it->attribute("SHORTCUT"));
1779
if (it->hasAttribute("wordTrack"))
1780
newStyle.setWordTracking(ScCLocale::toDoubleC(it->attribute("wordTrack")));
1784
void Scribus134Format::GetItemText(QDomElement *it, ScribusDoc *doc, PageItem* obj, LastStyles* last, bool impo, bool VorLFound)
1789
GetCStyle(it, doc, newStyle);
1791
if (it->hasAttribute("Unicode"))
1793
tmp2 = QChar(it->attribute("Unicode").toUInt());
1797
tmp2 = it->attribute("CH");
1800
tmp2.replace(QRegExp("\r"), QChar(13));
1801
tmp2.replace(QRegExp("\n"), QChar(13));
1802
tmp2.replace(QRegExp("\t"), QChar(9));
1805
// more legacy stuff:
1807
if (it->hasAttribute("CFONT"))
1808
newStyle.setFont(m_AvailableFonts->findFont(it->attribute("CFONT"), doc));
1810
if (it->hasAttribute("CSIZE"))
1811
newStyle.setFontSize(qRound(ScCLocale::toDoubleC(it->attribute("CSIZE")) * 10));
1813
if (it->hasAttribute("CCOLOR"))
1814
newStyle.setFillColor(it->attribute("CCOLOR"));
1816
if (it->hasAttribute("CEXTRA"))
1817
newStyle.setTracking(qRound(ScCLocale::toDoubleC(it->attribute("CEXTRA")) / ScCLocale::toDoubleC(it->attribute("CSIZE")) * 1000.0));
1818
else if (it->hasAttribute("CKERN"))
1819
newStyle.setTracking(it->attribute("CKERN").toInt());
1821
if (it->hasAttribute("CSHADE"))
1822
newStyle.setFillShade(it->attribute("CSHADE").toInt());
1824
if (it->hasAttribute("CSTYLE"))
1825
newStyle.setFeatures(static_cast<StyleFlag>(it->attribute("CSTYLE").toInt()).featureList());
1827
QString pstylename = it->attribute("PSTYLE", "");
1828
int calign = it->attribute("CALIGN", "-1").toInt();
1830
int ab = it->attribute("CAB", "-1").toInt();
1832
pstylename = doc->paragraphStyles()[ab-5].name();
1840
if (it->hasAttribute("CSTROKE"))
1841
newStyle.setStrokeColor(it->attribute("CSTROKE", CommonStrings::None));
1843
if (it->hasAttribute("CSHADE2"))
1844
newStyle.setStrokeShade(it->attribute("CSHADE2", "100").toInt());
1846
if (it->hasAttribute("CSCALE"))
1847
newStyle.setScaleH(qMin(qMax(qRound(ScCLocale::toDoubleC(it->attribute("CSCALE"), 100.0) * 10), 100), 4000));
1849
if (it->hasAttribute("CSCALEV"))
1850
newStyle.setScaleV(qMin(qMax(qRound(ScCLocale::toDoubleC(it->attribute("CSCALEV"), 100.0) * 10), 100), 4000));
1852
if (it->hasAttribute("CBASE"))
1853
newStyle.setBaselineOffset(qRound(ScCLocale::toDoubleC(it->attribute("CBASE")) * 10));
1855
if (it->hasAttribute("CSHX"))
1856
newStyle.setShadowXOffset(qRound(ScCLocale::toDoubleC(it->attribute("CSHX"), 5.0) * 10));
1858
if (it->hasAttribute("CSHY"))
1859
newStyle.setShadowYOffset(qRound(ScCLocale::toDoubleC(it->attribute("CSHY"), -5.0) * 10));
1861
if (it->hasAttribute("COUT"))
1862
newStyle.setOutlineWidth(qRound(ScCLocale::toDoubleC(it->attribute("COUT"), 1.0) * 10));
1864
if (it->hasAttribute("CULP"))
1865
newStyle.setUnderlineOffset(qRound(ScCLocale::toDoubleC(it->attribute("CULP"), -0.1) * 10));
1867
if (it->hasAttribute("CULW"))
1868
newStyle.setUnderlineWidth(qRound(ScCLocale::toDoubleC(it->attribute("CULW"), -0.1) * 10));
1871
if (it->hasAttribute("CSTP"))
1872
newStyle.setStrikethruOffset(qRound(ScCLocale::toDoubleC(it->attribute("CSTP"), -0.1) * 10));
1874
if (it->hasAttribute("CSTW"))
1875
newStyle.setStrikethruWidth(qRound(ScCLocale::toDoubleC(it->attribute("CSTW"), -0.1) * 10));
1877
fixLegacyCharStyle(newStyle);
1879
if (impo && ab >= 0 && VorLFound)
1880
last->ParaStyle = DoVorl[ab].toInt();
1882
last->ParaStyle = pstylename;
1883
// end of legacy stuff
1885
int iobj = it->attribute("COBJ", "-1").toInt();
1887
for (int cxx=0; cxx<tmp2.length(); ++cxx)
1889
QChar ch = tmp2.at(cxx);
1892
ch = SpecialChars::PARSEP;
1894
ch = SpecialChars::TAB;
1897
int pos = obj->itemText.length();
1898
if (ch == SpecialChars::OBJECT) {
1900
if (iobj < doc->FrameItems.count())
1901
obj->itemText.insertObject(pos, doc->FrameItems.at(iobj));
1903
qDebug() << QString("scribus134format: invalid inline frame used in text object : %1").arg(iobj);
1906
else if (ch == SpecialChars::SHYPHEN && pos > 0)
1908
// qDebug() << QString("scribus134format: SHYPHEN at %1").arg(pos);
1909
ScText* lastItem = obj->itemText.item(pos-1);
1910
// double SHY means user provided SHY, single SHY is automatic one
1911
if (lastItem->effects() & ScStyle_HyphenationPossible)
1913
lastItem->setEffects(lastItem->effects() & ~ScStyle_HyphenationPossible);
1914
obj->itemText.insertChars(pos, QString(ch));
1918
lastItem->setEffects(lastItem->effects() | ScStyle_HyphenationPossible);
1922
obj->itemText.insertChars(pos, QString(ch));
1924
// qDebug() << QString("style at %1: %2 ^ %3 = %4 (%5)").arg(pos).arg((uint)newStyle.effects()).arg((uint)last->Style.effects()).arg((uint)(newStyle.effects() ^ last->Style.effects())).arg(newStyle != last->Style);
1925
if (newStyle != last->Style) // || (newStyle.effects() ^ last->Style.effects()) == ScStyle_HyphenationPossible)
1926
{ // FIXME StyleFlag operator== ignores hyphen flag
1927
// qDebug() << QString("new style at %1: %2 -> %3").arg(pos).arg(last->Style.asString()).arg(newStyle.asString());
1928
obj->itemText.setCharStyle(last->StyleStart, pos-last->StyleStart, last->Style);
1929
last->Style = newStyle;
1930
last->StyleStart = pos;
1932
if (ch == SpecialChars::PARSEP) {
1933
ParagraphStyle pstyle;
1934
// Qt4 if (last->ParaStyle >= 0) {
1935
if (!last->ParaStyle.isEmpty()) {
1936
pstyle.setParent( last->ParaStyle );
1939
pstyle.setAlignment(static_cast<ParagraphStyle::AlignmentType>(calign));
1940
// qDebug() << QString("par style at %1: %2/%3 (%4) calign %5").arg(pos).arg(pstyle.name()).arg(pstyle.parent()).arg(last->ParaStyle).arg(calign);
1941
obj->itemText.applyStyle(pos, pstyle);
1945
obj->itemText.setCharStyle(last->StyleStart, obj->itemText.length()-last->StyleStart, last->Style);
1946
last->StyleStart = obj->itemText.length();
1949
for (int i=0; i < obj->itemText.length(); ++i)
1951
dbg += obj->itemText.text(i,1);
1952
if (obj->itemText.item(i)->effects() & ScStyle_HyphenationPossible)
1955
qDebug("scribus134format: read itemtext %d '%s'", obj->itemText.length(), dbg.latin1());
1957
ParagraphStyle pstyle;
1959
if (!last->ParaStyle.isEmpty()) { // Qt4 >= 0) {
1960
pstyle.setParent( last->ParaStyle );
1961
obj->itemText.applyStyle(obj->itemText.length()-1, pstyle);
1964
pstyle.setAlignment(static_cast<ParagraphStyle::AlignmentType>(calign));
1965
obj->itemText.applyStyle(obj->itemText.length()-1, pstyle);
1971
void Scribus134Format::readParagraphStyle(ParagraphStyle& vg, const QDomElement& pg, SCFonts &avail, ScribusDoc *doc)
1974
vg.setName(pg.attribute("NAME", ""));
1975
// The default style attribute must be correctly set before trying to assign a parent
1976
if (pg.hasAttribute("DefaultStyle"))
1977
vg.setDefaultStyle(pg.attribute("DefaultStyle").toInt());
1978
else if (vg.name() == CommonStrings::DefaultParagraphStyle || vg.name() == CommonStrings::trDefaultParagraphStyle)
1979
vg.setDefaultStyle(true);
1981
vg.setDefaultStyle(false);
1982
QString parentStyle = pg.attribute("PARENT", "");
1983
if (!parentStyle.isEmpty())
1985
if (m_Doc->styleExists(parentStyle))
1986
vg.setParent(parentStyle);
1988
vg.setParent(CommonStrings::DefaultParagraphStyle);
1990
if (pg.hasAttribute("LINESPMode"))
1991
vg.setLineSpacingMode(static_cast<ParagraphStyle::LineSpacingMode>(pg.attribute("LINESPMode").toInt()));
1992
if (pg.hasAttribute("LINESP"))
1993
vg.setLineSpacing(ScCLocale::toDoubleC(pg.attribute("LINESP")));
1994
if (pg.hasAttribute("INDENT"))
1995
vg.setLeftMargin(ScCLocale::toDoubleC(pg.attribute("INDENT")));
1996
if (pg.hasAttribute("RMARGIN"))
1997
vg.setRightMargin(ScCLocale::toDoubleC(pg.attribute("RMARGIN")));
1998
if (pg.hasAttribute("FIRST"))
1999
vg.setFirstIndent(ScCLocale::toDoubleC(pg.attribute("FIRST")));
2000
if (pg.hasAttribute("ALIGN"))
2001
vg.setAlignment(static_cast<ParagraphStyle::AlignmentType>(pg.attribute("ALIGN").toInt()));
2002
if (pg.hasAttribute("VOR"))
2003
vg.setGapBefore(ScCLocale::toDoubleC(pg.attribute("VOR")));
2004
if (pg.hasAttribute("NACH"))
2005
vg.setGapAfter(ScCLocale::toDoubleC(pg.attribute("NACH")));
2006
if (pg.hasAttribute("DROP"))
2007
vg.setHasDropCap(static_cast<bool>(pg.attribute("DROP").toInt()));
2008
if (pg.hasAttribute("DROPLIN"))
2009
vg.setDropCapLines(pg.attribute("DROPLIN").toInt());
2010
if (pg.hasAttribute("DROPDIST"))
2011
vg.setDropCapOffset(ScCLocale::toDoubleC(pg.attribute("DROPDIST")));
2012
if (pg.hasAttribute("PSHORTCUT"))
2013
vg.setShortcut(pg.attribute("PSHORTCUT"));
2015
// vg.tabValues().clear();
2016
if ((pg.hasAttribute("NUMTAB")) && (pg.attribute("NUMTAB", "0").toInt() != 0))
2018
QList<ParagraphStyle::TabRecord> tbs;
2019
ParagraphStyle::TabRecord tb;
2020
QString tmp = pg.attribute("TABS");
2021
ScTextStream tgv(&tmp, QIODevice::ReadOnly);
2023
for (int cxv = 0; cxv < pg.attribute("NUMTAB", "0").toInt(); cxv += 2)
2027
tb.tabPosition = xf2;
2028
tb.tabType = static_cast<int>(xf);
2029
tb.tabFillChar = QChar();
2032
vg.setTabValues(tbs);
2037
QList<ParagraphStyle::TabRecord> tbs;
2038
vg.resetTabValues();
2039
QDomNode IT = pg.firstChild();
2042
QDomElement it = IT.toElement();
2043
if (it.tagName()=="Tabs")
2045
ParagraphStyle::TabRecord tb;
2046
tb.tabPosition = ScCLocale::toDoubleC( it.attribute("Pos"));
2047
tb.tabType = it.attribute("Type").toInt();
2049
tbCh = it.attribute("Fill","");
2051
tb.tabFillChar = QChar();
2053
tb.tabFillChar = tbCh[0];
2056
IT=IT.nextSibling();
2058
if (tbs.count() > 0)
2059
vg.setTabValues(tbs);
2062
if (pg.hasAttribute("OpticalMargins"))
2063
vg.setOpticalMargins(pg.attribute("OpticalMargins").toInt());
2064
if (pg.hasAttribute("HyphenationMode"))
2065
vg.setHyphenationMode(pg.attribute("HyphenationMode").toInt());
2066
if (pg.hasAttribute("MinWordTrack"))
2067
vg.setMinWordTracking(ScCLocale::toDoubleC(pg.attribute("MinWordTrack")));
2068
if (pg.hasAttribute("NormWordTrack"))
2069
vg.charStyle().setWordTracking(ScCLocale::toDoubleC(pg.attribute("NormWordTrack")));
2070
if (pg.hasAttribute("MinGlyphShrink"))
2071
vg.setMinGlyphExtension(ScCLocale::toDoubleC(pg.attribute("MinGlyphShrink")));
2072
if (pg.hasAttribute("MaxGlyphExtend"))
2073
vg.setMaxGlyphExtension(ScCLocale::toDoubleC(pg.attribute("MaxGlyphExtend")));
2075
GetCStyle( &pg, doc, vg.charStyle());
2077
fixLegacyParStyle(vg);
2080
PageItem* Scribus134Format::PasteItem(QDomElement *obj, ScribusDoc *doc, const QString& baseDir, int pagenr)
2082
struct ImageLoadRequest loadingInfo;
2084
PageItem::ItemType pt = static_cast<PageItem::ItemType>(obj->attribute("PTYPE").toInt());
2085
double x = ScCLocale::toDoubleC( obj->attribute("XPOS"));
2086
double y = ScCLocale::toDoubleC( obj->attribute("YPOS"));
2087
double w = ScCLocale::toDoubleC( obj->attribute("WIDTH"));
2088
double h = ScCLocale::toDoubleC( obj->attribute("HEIGHT"));
2089
double pw = ScCLocale::toDoubleC( obj->attribute("PWIDTH"));
2090
double scx = ScCLocale::toDoubleC( obj->attribute("LOCALSCX"));
2091
double scy = ScCLocale::toDoubleC( obj->attribute("LOCALSCY"));
2092
QString Pcolor = obj->attribute("PCOLOR");
2093
if (Pcolor.isEmpty())
2095
QString Pcolor2 = obj->attribute("PCOLOR2");
2096
if (Pcolor2.isEmpty())
2099
PageItem *currItem=NULL;
2107
// OBSOLETE CR 2005-02-06
2108
case PageItem::ItemType1:
2109
z = doc->itemAdd(PageItem::Polygon, PageItem::Ellipse, x, y, w, h, pw, Pcolor, Pcolor2, true);
2110
currItem = doc->Items->at(z);
2112
currItem->OwnPage = pagenr;
2115
case PageItem::ImageFrame:
2116
case PageItem::LatexFrame: /*Everything that is valid for image frames is also valid for latex frames*/
2117
z = doc->itemAdd(pt, PageItem::Unspecified, x, y, w, h, 1, doc->toolSettings.dBrushPict, CommonStrings::None, true);
2118
currItem = doc->Items->at(z);
2119
UndoManager::instance()->setUndoEnabled(false);
2121
currItem->OwnPage = pagenr;
2122
currItem->ScaleType = obj->attribute("SCALETYPE", "1").toInt();
2123
currItem->AspectRatio = obj->attribute("RATIO", "0").toInt();
2124
currItem->setImageXYScale(scx, scy);
2125
currItem->setImageXYOffset(ScCLocale::toDoubleC(obj->attribute("LOCALX")), ScCLocale::toDoubleC(obj->attribute("LOCALY")));
2126
if (currItem->asLatexFrame())
2128
PageItem_LatexFrame *latexitem = currItem->asLatexFrame();
2129
// currItem->PictureIsAvailable = true;
2130
currItem->invalid = true;
2131
IT = obj->firstChild();
2134
QDomElement it = IT.toElement();
2135
if (it.tagName()=="LATEX")
2137
latexitem->setConfigFile(it.attribute("ConfigFile"), true);
2138
latexitem->setDpi(it.attribute("DPI").toInt());
2139
latexitem->setUsePreamble(static_cast<bool>(it.attribute("USE_PREAMBLE").toInt()));
2140
QDomElement property = it.firstChildElement("PROPERTY");
2141
while (!property.isNull())
2143
QString name = property.attribute("name");
2144
QString value = property.attribute("value");
2145
property = property.nextSiblingElement("PROPERTY");
2146
if (name.isEmpty()) continue;
2147
latexitem->editorProperties[name] = value;
2149
QString temp = it.text();
2150
latexitem->setFormula(temp, false);
2153
IT=IT.nextSibling();
2158
bool inlineF = static_cast<bool>(obj->attribute("isInlineImage", "0").toInt());
2159
QString dat = obj->attribute("ImageData", "");
2160
QByteArray inlineImageData;
2161
inlineImageData.append(dat);
2162
QString inlineImageExt = obj->attribute("inlineImageExt", "");
2165
if (inlineImageData.size() > 0)
2167
currItem->tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_XXXXXX." + inlineImageExt);
2168
currItem->tempImageFile->open();
2169
QString fileName = getLongPathName(currItem->tempImageFile->fileName());
2170
currItem->tempImageFile->close();
2171
inlineImageData = qUncompress(QByteArray::fromBase64(inlineImageData));
2172
QFile outFil(fileName);
2173
if (outFil.open(QIODevice::WriteOnly))
2175
outFil.write(inlineImageData);
2177
currItem->isInlineImage = true;
2178
currItem->Pfile = fileName;
2183
currItem->Pfile = Relative2Path(obj->attribute("PFILE"), baseDir);
2185
currItem->IProfile = obj->attribute("PRFILE","");
2186
currItem->EmProfile = obj->attribute("EPROF","");
2187
currItem->IRender = (eRenderIntent) obj->attribute("IRENDER", "1").toInt();
2188
currItem->UseEmbedded = obj->attribute("EMBEDDED", "1").toInt();
2189
currItem->pixm.imgInfo.lowResType = obj->attribute("ImageRes", "1").toInt();
2190
currItem->pixm.imgInfo.actualPageNumber = obj->attribute("Pagenumber", "0").toInt();
2191
IT = obj->firstChild();
2194
QDomElement it = IT.toElement();
2195
if (it.tagName()=="ImageEffect")
2197
struct ImageEffect ef;
2198
ef.effectParameters = it.attribute("Param");
2199
ef.effectCode = it.attribute("Code").toInt();
2200
currItem->effectsInUse.append(ef);
2202
IT=IT.nextSibling();
2204
if (!currItem->Pfile.isEmpty())
2205
doc->loadPict(currItem->Pfile, currItem, false);
2206
currItem->IProfile = obj->attribute("PRFILE","");
2207
currItem->EmProfile = obj->attribute("EPROF","");
2208
currItem->IRender = (eRenderIntent) obj->attribute("IRENDER", "1").toInt();
2209
currItem->UseEmbedded = obj->attribute("EMBEDDED", "1").toInt();
2210
currItem->setImageXYScale(scx, scy);
2211
clPath = obj->attribute("ImageClip", "");
2212
if (currItem->pixm.imgInfo.PDSpathData.contains(clPath))
2214
currItem->imageClip = currItem->pixm.imgInfo.PDSpathData[clPath].copy();
2215
currItem->pixm.imgInfo.usedPath = clPath;
2217
cl.translate(currItem->imageXOffset()*currItem->imageXScale(), currItem->imageYOffset()*currItem->imageYScale());
2218
cl.scale(currItem->imageXScale(), currItem->imageYScale());
2219
currItem->imageClip.map(cl);
2221
currItem->setImageShown(obj->attribute("PICART").toInt());
2222
/* currItem->BBoxX = ScCLocale::toDoubleC( obj->attribute("BBOXX"));
2223
currItem->BBoxH = ScCLocale::toDoubleC( obj->attribute("BBOXH")); */
2224
currItem->setLineWidth(pw);
2225
if (currItem->pixm.imgInfo.layerInfo.count() != 0)
2228
IT = obj->firstChild();
2231
QDomElement it = IT.toElement();
2232
if (it.tagName() == "PSDLayer")
2235
loadingInfo.blend = it.attribute("Blend");
2236
loadingInfo.opacity = it.attribute("Opacity").toInt();
2237
loadingInfo.visible = static_cast<bool>(it.attribute("Visible").toInt());
2238
loadingInfo.useMask = static_cast<bool>(it.attribute("useMask", "1").toInt());
2239
currItem->pixm.imgInfo.RequestProps.insert(it.attribute("Layer").toInt(), loadingInfo);
2241
IT=IT.nextSibling();
2245
currItem->pixm.imgInfo.isRequest = true;
2246
doc->loadPict(currItem->Pfile, currItem, true);
2249
UndoManager::instance()->setUndoEnabled(true);
2251
// OBSOLETE CR 2005-02-06
2252
case PageItem::ItemType3:
2253
z = doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, x, y, w, h, pw, Pcolor, Pcolor2, true);
2254
currItem = doc->Items->at(z);
2256
currItem->OwnPage = pagenr;
2259
case PageItem::PathText:
2260
z = doc->itemAdd(PageItem::PathText, PageItem::Unspecified, x, y, w, h, pw, CommonStrings::None, Pcolor, true);
2261
currItem = doc->Items->at(z);
2263
currItem->OwnPage = pagenr;
2264
//currItem->convertTo(pt);
2266
case PageItem::TextFrame:
2267
z = doc->itemAdd(PageItem::TextFrame, PageItem::Unspecified, x, y, w, h, pw, CommonStrings::None, Pcolor, true);
2268
currItem = doc->Items->at(z);
2270
currItem->OwnPage = pagenr;
2271
//currItem->convertTo(pt);
2273
case PageItem::Line:
2274
z = doc->itemAdd(PageItem::Line, PageItem::Unspecified, x, y, w, h, pw, CommonStrings::None, Pcolor2, true);
2275
currItem = doc->Items->at(z);
2277
currItem->OwnPage = pagenr;
2279
case PageItem::Polygon:
2280
z = doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, x, y, w, h, pw, Pcolor, Pcolor2, true);
2281
currItem = doc->Items->at(z);
2283
currItem->OwnPage = pagenr;
2285
case PageItem::PolyLine:
2286
z = doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, x, y, w, h, pw, Pcolor, Pcolor2, true);
2287
currItem = doc->Items->at(z);
2289
currItem->OwnPage = pagenr;
2291
case PageItem::Multiple:
2296
UndoManager::instance()->setUndoEnabled(false);
2297
currItem->FrameType = obj->attribute("FRTYPE", "0").toInt();
2298
int startArrowIndex = obj->attribute("startArrowIndex", "0").toInt();
2299
if ((startArrowIndex < 0) || (startArrowIndex > static_cast<int>(doc->arrowStyles.size())))
2301
qDebug() << QString("scribus134format: invalid arrow index: %").arg(startArrowIndex);
2302
startArrowIndex = 0;
2304
currItem->setStartArrowIndex(startArrowIndex);
2305
int endArrowIndex = obj->attribute("endArrowIndex", "0").toInt();
2306
if ((endArrowIndex < 0) || (endArrowIndex > static_cast<int>(doc->arrowStyles.size())))
2308
qDebug() << QString("scribus134format: invalid arrow index: %").arg(endArrowIndex);
2311
currItem->setEndArrowIndex(endArrowIndex);
2312
currItem->NamedLStyle = obj->attribute("NAMEDLST", "");
2313
currItem->isBookmark = obj->attribute("BOOKMARK").toInt();
2314
if ((currItem->isBookmark) && (doc->BookMarks.count() == 0))
2316
currItem->setImageFlippedH(obj->attribute("FLIPPEDH").toInt());
2317
currItem->setImageFlippedV(obj->attribute("FLIPPEDV").toInt());
2318
currItem->setCornerRadius(ScCLocale::toDoubleC(obj->attribute("RADRECT"), 0.0));
2319
currItem->ClipEdited = obj->attribute("CLIPEDIT", "0").toInt();
2320
currItem->setFillColor(Pcolor);
2321
currItem->setLineColor(Pcolor2);
2322
currItem->setFillShade(obj->attribute("SHADE").toInt());
2323
currItem->setLineShade(obj->attribute("SHADE2").toInt());
2324
ParagraphStyle pstyle;
2325
if (obj->hasAttribute("LINESP"))
2326
pstyle.setLineSpacing(ScCLocale::toDoubleC(obj->attribute("LINESP")));
2327
if (obj->hasAttribute("LINESPMode"))
2328
pstyle.setLineSpacingMode(static_cast<ParagraphStyle::LineSpacingMode>(obj->attribute("LINESPMode", "0").toInt()));
2329
if (obj->hasAttribute("ALIGN"))
2330
pstyle.setAlignment(static_cast<ParagraphStyle::AlignmentType>(obj->attribute("ALIGN", "0").toInt()));
2331
if (obj->hasAttribute("IFONT"))
2332
pstyle.charStyle().setFont(m_AvailableFonts->findFont(obj->attribute("IFONT"), doc));
2333
if (obj->hasAttribute("ISIZE"))
2334
pstyle.charStyle().setFontSize(qRound(ScCLocale::toDoubleC(obj->attribute("ISIZE")) * 10));
2335
if (obj->hasAttribute("TXTSTROKE"))
2336
pstyle.charStyle().setStrokeColor(obj->attribute("TXTSTROKE"));
2337
if (obj->hasAttribute("TXTFILL"))
2338
pstyle.charStyle().setFillColor(obj->attribute("TXTFILL"));
2339
if (obj->hasAttribute("TXTSTRSH"))
2340
pstyle.charStyle().setStrokeShade(obj->attribute("TXTSTRSH").toInt());
2341
if (obj->hasAttribute("TXTFILLSH"))
2342
pstyle.charStyle().setFillShade(obj->attribute("TXTFILLSH").toInt());
2343
if (obj->hasAttribute("TXTSCALE"))
2344
pstyle.charStyle().setScaleH(qRound(ScCLocale::toDoubleC(obj->attribute("TXTSCALE")) * 10));
2345
if (obj->hasAttribute("TXTSCALEV"))
2346
pstyle.charStyle().setScaleV(qRound(ScCLocale::toDoubleC(obj->attribute("TXTSCALEV")) * 10));
2347
if (obj->hasAttribute("TXTBASE"))
2348
pstyle.charStyle().setBaselineOffset(qRound(ScCLocale::toDoubleC(obj->attribute("TXTBASE")) * 10));
2349
if (obj->hasAttribute("TXTSHX"))
2350
pstyle.charStyle().setShadowXOffset(qRound(ScCLocale::toDoubleC(obj->attribute("TXTSHX")) * 10));
2351
if (obj->hasAttribute("TXTSHY"))
2352
pstyle.charStyle().setShadowYOffset(qRound(ScCLocale::toDoubleC(obj->attribute("TXTSHY")) * 10));
2353
if (obj->hasAttribute("TXTOUT"))
2354
pstyle.charStyle().setOutlineWidth(qRound(ScCLocale::toDoubleC(obj->attribute("TXTOUT")) * 10));
2355
if (obj->hasAttribute("TXTULP"))
2356
pstyle.charStyle().setUnderlineOffset(qRound(ScCLocale::toDoubleC(obj->attribute("TXTULP")) * 10));
2357
if (obj->hasAttribute("TXTULW"))
2358
pstyle.charStyle().setUnderlineWidth(qRound(ScCLocale::toDoubleC(obj->attribute("TXTULW")) * 10));
2359
if (obj->hasAttribute("TXTSTP"))
2360
pstyle.charStyle().setStrikethruOffset(qRound(ScCLocale::toDoubleC(obj->attribute("TXTSTP")) * 10));
2361
if (obj->hasAttribute("TXTSTW"))
2362
pstyle.charStyle().setStrikethruWidth(qRound(ScCLocale::toDoubleC(obj->attribute("TXTSTW")) * 10));
2363
if (obj->hasAttribute("TXTSTYLE"))
2364
pstyle.charStyle().setFeatures(static_cast<StyleFlag>(obj->attribute("TXTSTYLE").toInt()).featureList());
2365
if (obj->hasAttribute("TXTKERN"))
2366
pstyle.charStyle().setTracking(qRound(ScCLocale::toDoubleC(obj->attribute("TXTKERN"), 0.0) * 10));
2367
if (obj->hasAttribute("wordTrack"))
2368
pstyle.charStyle().setWordTracking(ScCLocale::toDoubleC(obj->attribute("wordTrack")));
2369
if (obj->hasAttribute("MinWordTrack"))
2370
pstyle.setMinWordTracking(ScCLocale::toDoubleC(obj->attribute("MinWordTrack")));
2371
if (obj->hasAttribute("MinGlyphShrink"))
2372
pstyle.setMinGlyphExtension(ScCLocale::toDoubleC(obj->attribute("MinGlyphShrink")));
2373
if (obj->hasAttribute("MaxGlyphExtend"))
2374
pstyle.setMaxGlyphExtension(ScCLocale::toDoubleC(obj->attribute("MaxGlyphExtend")));
2375
if (obj->hasAttribute("OpticalMargins"))
2376
pstyle.setOpticalMargins(obj->attribute("OpticalMargins").toInt());
2377
if (obj->hasAttribute("HyphenationMode"))
2378
pstyle.setHyphenationMode(obj->attribute("HyphenationMode").toInt());
2379
if (obj->hasAttribute("leftMargin"))
2380
pstyle.setLeftMargin(ScCLocale::toDoubleC(obj->attribute("leftMargin")));
2381
if (obj->hasAttribute("rightMargin"))
2382
pstyle.setRightMargin(ScCLocale::toDoubleC(obj->attribute("rightMargin")));
2383
if (obj->hasAttribute("firstIndent"))
2384
pstyle.setFirstIndent(ScCLocale::toDoubleC(obj->attribute("firstIndent")));
2385
currItem->itemText.setDefaultStyle(pstyle);
2387
if (obj->hasAttribute("PSTYLE"))
2389
QString pstyleName = obj->attribute("PSTYLE");
2390
if (!pstyleName.isEmpty())
2392
ParagraphStyle defStyle(currItem->itemText.defaultStyle());
2393
defStyle.setParent(pstyleName);
2394
currItem->itemText.setDefaultStyle(defStyle);
2398
currItem->setRotation(ScCLocale::toDoubleC(obj->attribute("ROT")));
2399
currItem->setTextToFrameDist(ScCLocale::toDoubleC(obj->attribute("EXTRA")),
2400
ScCLocale::toDoubleC(obj->attribute("REXTRA"), 1.0),
2401
ScCLocale::toDoubleC(obj->attribute("TEXTRA"), 1.0),
2402
ScCLocale::toDoubleC(obj->attribute("BEXTRA"), 1.0));
2403
currItem->setFirstLineOffset(static_cast<FirstLineOffsetPolicy>(obj->attribute("FLOP").toInt()));
2405
currItem->PLineArt = Qt::PenStyle(obj->attribute("PLINEART").toInt());
2406
currItem->PLineEnd = Qt::PenCapStyle(obj->attribute("PLINEEND", "0").toInt());
2407
currItem->PLineJoin = Qt::PenJoinStyle(obj->attribute("PLINEJOIN", "0").toInt());
2408
currItem->setPrintEnabled(obj->attribute("PRINTABLE").toInt());
2409
currItem->setIsAnnotation(obj->attribute("ANNOTATION", "0").toInt());
2410
currItem->annotation().setType(obj->attribute("ANTYPE", "0").toInt());
2411
QString AnName = obj->attribute("ANNAME","");
2412
if (!AnName.isEmpty())
2414
if (currItem->itemName() == AnName)
2415
currItem->AutoName = true;
2418
currItem->setItemName(AnName);
2419
currItem->AutoName = false;
2423
currItem->annotation().setAction(obj->attribute("ANACTION",""));
2424
currItem->annotation().setE_act(obj->attribute("ANEACT",""));
2425
currItem->annotation().setX_act(obj->attribute("ANXACT",""));
2426
currItem->annotation().setD_act(obj->attribute("ANDACT",""));
2427
currItem->annotation().setFo_act(obj->attribute("ANFOACT",""));
2428
currItem->annotation().setBl_act(obj->attribute("ANBLACT",""));
2429
currItem->annotation().setK_act(obj->attribute("ANKACT",""));
2430
currItem->annotation().setF_act(obj->attribute("ANFACT",""));
2431
currItem->annotation().setV_act(obj->attribute("ANVACT",""));
2432
currItem->annotation().setC_act(obj->attribute("ANCACT",""));
2433
currItem->annotation().setActionType(obj->attribute("ANACTYP", "0").toInt());
2434
currItem->annotation().setExtern(obj->attribute("ANEXTERN",""));
2435
if ((!currItem->annotation().Extern().isEmpty()) && (currItem->annotation().ActionType() != 8))
2436
currItem->annotation().setExtern(Relative2Path(obj->attribute("ANEXTERN","") , baseDir));
2437
currItem->annotation().setZiel(obj->attribute("ANZIEL", "0").toInt());
2438
currItem->annotation().setToolTip(obj->attribute("ANTOOLTIP",""));
2439
currItem->annotation().setRollOver(obj->attribute("ANROLL",""));
2440
currItem->annotation().setDown(obj->attribute("ANDOWN",""));
2441
currItem->annotation().setBwid(obj->attribute("ANBWID", "1").toInt());
2442
currItem->annotation().setBsty(obj->attribute("ANBSTY", "0").toInt());
2443
currItem->annotation().setFeed(obj->attribute("ANFEED", "1").toInt());
2444
currItem->annotation().setFlag(obj->attribute("ANFLAG", "0").toInt());
2445
currItem->annotation().setFont(obj->attribute("ANFONT", "4").toInt());
2446
currItem->annotation().setFormat(obj->attribute("ANFORMAT", "0").toInt());
2447
currItem->annotation().setVis(obj->attribute("ANVIS", "0").toInt());
2448
currItem->annotation().setIsChk(static_cast<bool>(obj->attribute("ANCHK", "0").toInt()));
2449
currItem->annotation().setAAact(static_cast<bool>(obj->attribute("ANAA", "0").toInt()));
2450
currItem->annotation().setHTML(obj->attribute("ANHTML", "0").toInt());
2451
currItem->annotation().setUseIcons(static_cast<bool>(obj->attribute("ANICON", "0").toInt()));
2452
currItem->annotation().setChkStil(obj->attribute("ANCHKS", "0").toInt());
2453
currItem->annotation().setMaxChar(obj->attribute("ANMC", "-1").toInt());
2454
currItem->annotation().setBorderColor(obj->attribute("ANBCOL", CommonStrings::None));
2455
currItem->annotation().setIPlace(obj->attribute("ANPLACE", "1").toInt());
2456
currItem->annotation().setScaleW(obj->attribute("ANSCALE", "0").toInt());
2458
if (currItem->asTextFrame() || currItem->asPathText())
2460
UndoManager::instance()->setUndoEnabled(false);
2461
if (currItem->isAnnotation() && currItem->annotation().UseIcons())
2463
currItem->ScaleType = obj->attribute("SCALETYPE", "1").toInt();
2464
currItem->AspectRatio = obj->attribute("RATIO", "0").toInt();
2465
currItem->setImageXYScale(scx, scy);
2466
currItem->setImageXYOffset(ScCLocale::toDoubleC(obj->attribute("LOCALX")), ScCLocale::toDoubleC(obj->attribute("LOCALY")));
2467
currItem->Pfile = Relative2Path(obj->attribute("PFILE","") , baseDir);
2468
currItem->Pfile2 = Relative2Path(obj->attribute("PFILE2",""), baseDir);
2469
currItem->Pfile3 = Relative2Path(obj->attribute("PFILE3",""), baseDir);
2470
currItem->IProfile = obj->attribute("PRFILE","");
2471
currItem->EmProfile = obj->attribute("EPROF","");
2472
currItem->IRender = (eRenderIntent) obj->attribute("IRENDER", "1").toInt();
2473
currItem->UseEmbedded = obj->attribute("EMBEDDED", "1").toInt();
2474
doc->LoadPict(currItem->Pfile, z);
2475
currItem->setImageXYScale(scx, scy);
2476
currItem->setImageShown(obj->attribute("PICART").toInt());
2477
/* currItem->BBoxX = ScCLocale::toDoubleC( obj->attribute("BBOXX"));
2478
currItem->BBoxH = ScCLocale::toDoubleC( obj->attribute("BBOXH")); */
2480
UndoManager::instance()->setUndoEnabled(true);
2483
currItem->TopLine = static_cast<bool>(obj->attribute("TopLine", "0").toInt());
2484
currItem->LeftLine = static_cast<bool>(obj->attribute("LeftLine", "0").toInt());
2485
currItem->RightLine = static_cast<bool>(obj->attribute("RightLine", "0").toInt());
2486
currItem->BottomLine = static_cast<bool>(obj->attribute("BottomLine", "0").toInt());
2487
currItem->isTableItem = static_cast<bool>(obj->attribute("isTableItem", "0").toInt());
2488
currItem->TopLinkID = obj->attribute("TopLINK", "-1").toInt();
2489
currItem->LeftLinkID = obj->attribute("LeftLINK", "-1").toInt();
2490
currItem->RightLinkID = obj->attribute("RightLINK", "-1").toInt();
2491
currItem->BottomLinkID = obj->attribute("BottomLINK", "-1").toInt();
2492
currItem->PoShow = obj->attribute("PLTSHOW", "0").toInt();
2493
currItem->BaseOffs = ScCLocale::toDoubleC( obj->attribute("BASEOF"), 0.0);
2494
currItem->textPathType = obj->attribute("textPathType", "0").toInt();
2495
currItem->textPathFlipped = static_cast<bool>(obj->attribute("textPathFlipped", "0").toInt());
2496
if ( obj->hasAttribute("TEXTFLOWMODE") )
2497
currItem->setTextFlowMode((PageItem::TextFlowMode) obj->attribute("TEXTFLOWMODE", "0").toInt());
2498
else if ( obj->attribute("TEXTFLOW").toInt() )
2500
if (obj->attribute("TEXTFLOW2", "0").toInt())
2501
currItem->setTextFlowMode(PageItem::TextFlowUsesBoundingBox);
2502
else if (obj->attribute("TEXTFLOW3", "0").toInt())
2503
currItem->setTextFlowMode(PageItem::TextFlowUsesContourLine);
2505
currItem->setTextFlowMode(PageItem::TextFlowUsesFrameShape);
2508
currItem->setTextFlowMode(PageItem::TextFlowDisabled);
2509
currItem->DashOffset = ScCLocale::toDoubleC( obj->attribute("DASHOFF"), 0.0);
2510
currItem->setReversed(static_cast<bool>(obj->attribute("REVERS", "0").toInt()));
2511
currItem->setLocked(static_cast<bool>(obj->attribute("LOCK", "0").toInt()));
2512
currItem->setSizeLocked(static_cast<bool>(obj->attribute("LOCKR", "0").toInt()));
2513
currItem->setFillTransparency(ScCLocale::toDoubleC(obj->attribute("TransValue"), 0.0));
2514
currItem->fillRule = static_cast<bool>(obj->attribute("fillRule", "1").toInt());
2515
currItem->doOverprint = static_cast<bool>(obj->attribute("doOverprint", "0").toInt());
2516
if (obj->hasAttribute("TransValueS"))
2517
currItem->setLineTransparency(ScCLocale::toDoubleC(obj->attribute("TransValueS"), 0.0));
2519
currItem->setLineTransparency(ScCLocale::toDoubleC(obj->attribute("TransValue"), 0.0));
2520
currItem->setFillBlendmode(obj->attribute("TransBlend", "0").toInt());
2521
currItem->setLineBlendmode(obj->attribute("TransBlendS", "0").toInt());
2522
if (obj->attribute("TRANSPARENT", "0").toInt() == 1)
2523
currItem->setFillColor(CommonStrings::None);
2524
currItem->Cols = obj->attribute("COLUMNS", "1").toInt();
2525
currItem->ColGap = ScCLocale::toDoubleC( obj->attribute("COLGAP"), 0.0);
2526
if (obj->attribute("LAYER", "0").toInt() != -1)
2527
currItem->LayerNr = obj->attribute("LAYER", "0").toInt();
2530
if ((obj->hasAttribute("GROUPS")) && (obj->attribute("NUMGROUP", "0").toInt() != 0))
2532
int groupMax = doc->GroupCounter;
2533
QMap<int, int>::ConstIterator gIt;
2534
tmp = obj->attribute("GROUPS");
2535
ScTextStream fg(&tmp, QIODevice::ReadOnly);
2536
currItem->Groups.clear();
2537
for (int cx = 0; cx < obj->attribute("NUMGROUP", "0").toInt(); ++cx)
2540
gIt = groupRemap.find(xi);
2541
if (gIt != groupRemap.end())
2542
currItem->Groups.push(gIt.value());
2545
currItem->Groups.push(groupMax);
2546
groupRemap.insert(xi, groupMax);
2550
doc->GroupCounter = groupMax;
2554
currItem->Groups.clear();
2556
QList<ParagraphStyle::TabRecord> tbs;
2558
if ((obj->hasAttribute("NUMTAB")) && (obj->attribute("NUMTAB", "0").toInt() != 0))
2560
ParagraphStyle::TabRecord tb;
2561
tmp = obj->attribute("TABS");
2562
ScTextStream tgv(&tmp, QIODevice::ReadOnly);
2563
for (int cxv = 0; cxv < obj->attribute("NUMTAB", "0").toInt(); cxv += 2)
2567
tb.tabPosition = xf2;
2568
tb.tabType = static_cast<int>(xf);
2569
tb.tabFillChar = QChar();
2576
IT = obj->firstChild();
2579
QDomElement it = IT.toElement();
2580
if (it.tagName()=="Tabs")
2582
ParagraphStyle::TabRecord tb;
2583
tb.tabPosition = ScCLocale::toDoubleC( it.attribute("Pos"));
2584
tb.tabType = it.attribute("Type").toInt();
2586
tbCh = it.attribute("Fill","");
2588
tb.tabFillChar = QChar();
2590
tb.tabFillChar = tbCh[0];
2593
IT=IT.nextSibling();
2596
if (tbs.count() > 0) {
2597
ParagraphStyle newDefault(currItem->itemText.defaultStyle());
2598
newDefault.setTabValues(tbs);
2599
currItem->itemText.setDefaultStyle(newDefault);
2602
if ((obj->hasAttribute("NUMDASH")) && (obj->attribute("NUMDASH", "0").toInt() != 0))
2604
tmp = obj->attribute("DASHS");
2605
ScTextStream dgv(&tmp, QIODevice::ReadOnly);
2606
currItem->DashValues.clear();
2607
for (int cxv = 0; cxv < obj->attribute("NUMDASH", "0").toInt(); ++cxv)
2610
currItem->DashValues.append(xf);
2615
currItem->DashValues.clear();
2617
if (obj->hasAttribute("NUMPO"))
2619
currItem->PoLine.resize(obj->attribute("NUMPO").toUInt());
2620
tmp = obj->attribute("POCOOR");
2621
ScTextStream fp(&tmp, QIODevice::ReadOnly);
2622
for (uint cx=0; cx<obj->attribute("NUMPO").toUInt(); ++cx)
2626
currItem->PoLine.setPoint(cx, xf, yf);
2630
currItem->PoLine.resize(0);
2632
if (obj->hasAttribute("NUMCO"))
2634
currItem->ContourLine.resize(obj->attribute("NUMCO").toUInt());
2635
tmp = obj->attribute("COCOOR");
2636
ScTextStream fp(&tmp, QIODevice::ReadOnly);
2637
for (uint cx=0; cx<obj->attribute("NUMCO").toUInt(); ++cx)
2641
currItem->ContourLine.setPoint(cx, xf, yf);
2645
currItem->ContourLine = currItem->PoLine.copy();
2646
if (!currItem->asLine())
2647
currItem->Clip = FlattenPath(currItem->PoLine, currItem->Segments);
2650
int ph = static_cast<int>(qMax(1.0, currItem->lineWidth() / 2.0));
2651
currItem->Segments.clear();
2652
currItem->PoLine.resize(0);
2653
currItem->Clip.setPoints(4, -ph,-ph, static_cast<int>(currItem->width()+ph),-ph,
2654
static_cast<int>(currItem->width()+ph),static_cast<int>(currItem->height()+ph),
2655
-ph,static_cast<int>(currItem->height()+ph));
2656
currItem->setHeight(1.0);
2658
if (currItem->asImageFrame())
2659
currItem->AdjustPictScale();
2660
if (currItem->asPathText())
2662
currItem->updatePolyClip();
2663
currItem->Frame = true;
2665
currItem->GrType = obj->attribute("GRTYP", "0").toInt();
2670
if (currItem->GrType != 0)
2672
if (currItem->GrType == 8)
2674
currItem->setPattern(obj->attribute("pattern", ""));
2675
double patternScaleX = ScCLocale::toDoubleC( obj->attribute("pScaleX"), 100.0);
2676
double patternScaleY = ScCLocale::toDoubleC( obj->attribute("pScaleY"), 100.0);
2677
double patternOffsetX = ScCLocale::toDoubleC( obj->attribute("pOffsetX"), 0.0);
2678
double patternOffsetY = ScCLocale::toDoubleC( obj->attribute("pOffsetY"), 0.0);
2679
double patternRotation = ScCLocale::toDoubleC( obj->attribute("pRotation"), 0.0);
2680
currItem->setPatternTransform(patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation);
2684
currItem->GrStartX = ScCLocale::toDoubleC( obj->attribute("GRSTARTX"), 0.0);
2685
currItem->GrStartY = ScCLocale::toDoubleC( obj->attribute("GRSTARTY"), 0.0);
2686
currItem->GrEndX = ScCLocale::toDoubleC( obj->attribute("GRENDX"), 0.0);
2687
currItem->GrEndY = ScCLocale::toDoubleC( obj->attribute("GRENDY"), 0.0);
2688
GrColor = obj->attribute("GRCOLOR","");
2689
if (!GrColor.isEmpty())
2691
GrColor2 = obj->attribute("GRCOLOR2","");
2692
GrShade = obj->attribute("GRSHADE", "100").toInt();
2693
GrShade2 = obj->attribute("GRSHADE2", "100").toInt();
2697
if ((currItem->GrType != 0) && (currItem->GrType != 8))
2699
currItem->fill_gradient.clearStops();
2700
if ((!GrColor.isEmpty()) && (!GrColor2.isEmpty()))
2702
if (currItem->GrType == 5)
2704
if ((GrColor != CommonStrings::None) && (!GrColor.isEmpty()))
2705
currItem->SetQColor(&tmpc, GrColor, GrShade);
2706
currItem->fill_gradient.addStop(tmpc, 0.0, 0.5, 1.0, GrColor, GrShade);
2707
if ((GrColor2 != CommonStrings::None) && (!GrColor2.isEmpty()))
2708
currItem->SetQColor(&tmpc, GrColor2, GrShade2);
2709
currItem->fill_gradient.addStop(tmpc, 1.0, 0.5, 1.0, GrColor2, GrShade2);
2713
if ((GrColor2 != CommonStrings::None) && (!GrColor2.isEmpty()))
2714
currItem->SetQColor(&tmpc, GrColor2, GrShade2);
2715
currItem->fill_gradient.addStop(tmpc, 0.0, 0.5, 1.0, GrColor2, GrShade2);
2716
if ((GrColor != CommonStrings::None) && (!GrColor.isEmpty()))
2717
currItem->SetQColor(&tmpc, GrColor, GrShade);
2718
currItem->fill_gradient.addStop(tmpc, 1.0, 0.5, 1.0, GrColor, GrShade);
2721
// currItem->updateGradientVectors();
2723
UndoManager::instance()->setUndoEnabled(true);
2724
//currItem->setRedrawBounding();
2725
//currItem->OwnPage = view->OnPage(currItem);
2729
bool Scribus134Format::loadPage(const QString & fileName, int pageNumber, bool Mpage, QString renamedPageName)
2731
// qDebug() << QString("loading page %2 from file '%1' from 1.3.x plugin").arg(fileName).arg(pageNumber);
2732
if (m_Doc==0 || m_AvailableFonts==0)
2734
Q_ASSERT(m_Doc==0 || m_AvailableFonts==0);
2738
struct ScribusDoc::BookMa bok;
2751
QString tmp, tmpf, PgNam, Defont;
2752
QMap<int,int> TableID;
2753
QList<PageItem*> TableItems;
2754
QMap<PageItem*, int> groupID;
2755
int a, counter, baseobj;
2756
double pageX = 0, pageY = 0;
2757
bool newVersion = false;
2758
bool VorLFound = false;
2759
QMap<int,int> layerTrans;
2763
uint layerCount=m_Doc->layerCount();
2764
for (uint la2 = 0; la2 < layerCount; ++la2)
2766
maxLayer = qMax(m_Doc->Layers[la2].LNr, maxLayer);
2767
maxLevel = qMax(m_Doc->Layers[la2].Level, maxLevel);
2776
QDomDocument docu("scridoc");
2777
QString f(readSLA(fileName));
2784
int errorLine, errorColumn;
2785
if (!docu.setContent(f, &errorMsg, &errorLine, &errorColumn))
2787
setDomParsingError(errorMsg, errorLine, errorColumn);
2790
QString fileDir = QFileInfo(fileName).absolutePath();
2791
QDomElement elem=docu.documentElement();
2792
if (elem.tagName() != "SCRIBUSUTF8NEW")
2794
if (elem.hasAttribute("Version"))
2796
QDomNode DOC=elem.firstChild();
2797
counter = m_Doc->Items->count();
2799
// PrefsManager* prefsManager=PrefsManager::instance();
2800
while(!DOC.isNull())
2802
QDomElement dc=DOC.toElement();
2803
QDomNode PAGE=DOC.firstChild();
2804
while(!PAGE.isNull())
2806
QDomElement pg=PAGE.toElement();
2807
if(pg.tagName()=="COLOR" && pg.attribute("NAME")!=CommonStrings::None)
2810
if (pg.hasAttribute("CMYK"))
2811
lf.setNamedColor(pg.attribute("CMYK"));
2813
lf.fromQColor(QColor(pg.attribute("RGB")));
2814
if (pg.hasAttribute("Spot"))
2815
lf.setSpotColor(static_cast<bool>(pg.attribute("Spot").toInt()));
2817
lf.setSpotColor(false);
2818
if (pg.hasAttribute("Register"))
2819
lf.setRegistrationColor(static_cast<bool>(pg.attribute("Register").toInt()));
2821
lf.setRegistrationColor(false);
2822
QString name = pg.attribute("NAME");
2823
m_Doc->PageColors.insert((name.isEmpty()) ? lf.name() : name, lf);
2825
if(pg.tagName()=="STYLE")
2827
GetStyle(&pg, &vg, NULL, m_Doc, true);
2830
if(pg.tagName()=="JAVA")
2831
m_Doc->JavaScripts[pg.attribute("NAME")] = pg.attribute("SCRIPT");
2832
if(pg.tagName()=="LAYERS")
2834
int lnr = pg.attribute("NUMMER").toInt();
2835
int level = pg.attribute("LEVEL").toInt();
2836
ScLayer la( pg.attribute("NAME"), level, lnr );
2837
la.isViewable = pg.attribute("SICHTBAR").toInt();
2838
la.isPrintable = pg.attribute("DRUCKEN").toInt();
2839
la.isEditable = pg.attribute("EDIT", "1").toInt();
2840
la.flowControl = pg.attribute("FLOW", "1").toInt();
2841
la.transparency = ScCLocale::toDoubleC( pg.attribute("TRANS"), 1.0);
2842
la.blendMode = pg.attribute("BLEND", "0").toInt();
2843
la.outlineMode = pg.attribute("OUTL", "0").toInt();
2844
if (pg.hasAttribute("LAYERC"))
2845
la.markerColor = QColor(pg.attribute("LAYERC","#000000"));
2846
const ScLayer* la2 = m_Doc->Layers.layerByName(la.Name);
2848
layerTrans.insert(la.LNr, la2->LNr);
2853
layerTrans.insert(la.LNr, maxLayer);
2855
la.Level = maxLevel;
2856
m_Doc->Layers.append(la);
2859
if(pg.tagName()=="MultiLine")
2862
QDomNode MuLn = PAGE.firstChild();
2863
while(!MuLn.isNull())
2865
QDomElement MuL = MuLn.toElement();
2866
struct SingleLine sl;
2867
sl.Color = MuL.attribute("Color");
2868
sl.Dash = MuL.attribute("Dash").toInt();
2869
sl.LineEnd = MuL.attribute("LineEnd").toInt();
2870
sl.LineJoin = MuL.attribute("LineJoin").toInt();
2871
sl.Shade = MuL.attribute("Shade").toInt();
2872
sl.Width = ScCLocale::toDoubleC( MuL.attribute("Width"));
2873
ml.shortcut = MuL.attribute("Shortcut");
2875
MuLn = MuLn.nextSibling();
2877
QString Nam = pg.attribute("Name");
2880
QMap<QString,multiLine>::ConstIterator mlit = m_Doc->MLineStyles.find(Nam2);
2881
if (mlit != m_Doc->MLineStyles.end() && ml != mlit.value())
2883
while (m_Doc->MLineStyles.contains(Nam2))
2885
Nam2 = QObject::tr("Copy #%1 of ").arg(copyC)+Nam;
2889
m_Doc->MLineStyles.insert(Nam2, ml);
2891
if(pg.tagName()=="Arrows")
2893
struct ArrowDesc arrow;
2894
arrow.name = pg.attribute("Name");
2895
arrow.userArrow = true;
2897
QString tmp = pg.attribute("Points");
2898
ScTextStream fp(&tmp, QIODevice::ReadOnly);
2899
for (uint cx = 0; cx < pg.attribute("NumPoints").toUInt(); ++cx)
2903
arrow.points.addPoint(xa, ya);
2905
m_Doc->arrowStyles.append(arrow);
2907
if (((pg.tagName()=="PAGE") || (pg.tagName()=="MASTERPAGE")) && (pg.attribute("NUM").toInt() == pageNumber))
2909
a = m_Doc->currentPage()->pageNr();
2910
Apage = m_Doc->Pages->at(a);
2911
if ((pg.tagName()!="MASTERPAGE") && (Mpage))
2913
PAGE=PAGE.nextSibling();
2918
Apage->LeftPg=pg.attribute("LEFT", "0").toInt();
2920
if (!renamedPageName.isEmpty())
2921
Apage->setPageName(renamedPageName);
2923
Apage->setPageName(pg.attribute("NAM",""));
2925
if (pg.hasAttribute("Size"))
2926
Apage->m_pageSize = pg.attribute("Size");
2927
if (pg.hasAttribute("Orientation"))
2928
Apage->PageOri = pg.attribute("Orientation").toInt();
2929
if (pg.hasAttribute("PAGEWIDTH"))
2930
Apage->setWidth(ScCLocale::toDoubleC(pg.attribute("PAGEWIDTH")));
2932
Apage->setWidth(ScCLocale::toDoubleC(pg.attribute("PAGEWITH")));
2933
Apage->setHeight(ScCLocale::toDoubleC(pg.attribute("PAGEHEIGHT")));
2934
Apage->setInitialHeight(Apage->height());
2935
Apage->setInitialWidth(Apage->width());
2936
Apage->initialMargins.Top = qMax(0.0, ScCLocale::toDoubleC(pg.attribute("BORDERTOP")));
2937
Apage->initialMargins.Bottom = qMax(0.0, ScCLocale::toDoubleC(pg.attribute("BORDERBOTTOM")));
2938
Apage->initialMargins.Left = qMax(0.0, ScCLocale::toDoubleC(pg.attribute("BORDERLEFT")));
2939
Apage->initialMargins.Right = qMax(0.0, ScCLocale::toDoubleC( pg.attribute("BORDERRIGHT")));
2940
Apage->marginPreset = pg.attribute("PRESET", "0").toInt();
2941
Apage->Margins.Top = Apage->initialMargins.Top;
2942
Apage->Margins.Bottom = Apage->initialMargins.Bottom;
2943
pageX = ScCLocale::toDoubleC( pg.attribute("PAGEXPOS"));
2944
pageY = ScCLocale::toDoubleC( pg.attribute("PAGEYPOS"));
2947
Apage->guides.setHorizontalAutoGap(ScCLocale::toDoubleC(pg.attribute("AGhorizontalAutoGap"), 0.0));
2948
Apage->guides.setVerticalAutoGap(ScCLocale::toDoubleC(pg.attribute("AGverticalAutoGap"), 0.0));
2949
Apage->guides.setHorizontalAutoCount(pg.attribute("AGhorizontalAutoCount", "0").toInt());
2950
Apage->guides.setVerticalAutoCount(pg.attribute("AGverticalAutoCount", "0").toInt());
2951
Apage->guides.setHorizontalAutoRefer(pg.attribute("AGhorizontalAutoRefer", "0").toInt());
2952
Apage->guides.setVerticalAutoRefer(pg.attribute("AGverticalAutoRefer", "0").toInt());
2953
GuideManagerIO::readVerticalGuides(pg.attribute("VerticalGuides"),
2955
GuideManagerCore::Standard,
2956
pg.hasAttribute("NumVGuides"));
2957
GuideManagerIO::readHorizontalGuides(pg.attribute("HorizontalGuides"),
2959
GuideManagerCore::Standard,
2960
pg.hasAttribute("NumHGuides"));
2961
GuideManagerIO::readSelection(pg.attribute("AGSelection"), Apage);
2963
Apage->guides.addHorizontals(Apage->guides.getAutoHorizontals(Apage), GuideManagerCore::Auto);
2964
Apage->guides.addVerticals(Apage->guides.getAutoVerticals(Apage), GuideManagerCore::Auto);
2967
if ((pg.tagName()=="PAGEOBJECT") || (pg.tagName()=="MASTEROBJECT") || (pg.tagName()=="FRAMEOBJECT"))
2971
if (pg.tagName() != "MASTEROBJECT")
2973
PAGE=PAGE.nextSibling();
2979
if (pg.tagName() == "MASTEROBJECT")
2981
PAGE=PAGE.nextSibling();
2985
if (pg.attribute("OwnPage").toInt() != pageNumber)
2987
if (pg.tagName()=="PAGEOBJECT")
2988
itemRemap[itemCount++] = -1;
2989
else if (pg.tagName()=="MASTEROBJECT")
2990
itemRemapM[itemCountM++] = -1;
2993
// if (pg.attribute("OwnPage").toInt() == pageNumber)
2995
// first of linked chain?
2996
if (pg.tagName()=="PAGEOBJECT")
2998
itemRemap[itemCount++] = m_Doc->DocItems.count();
2999
if (pg.attribute("NEXTITEM").toInt() != -1)
3000
itemNext[m_Doc->DocItems.count()] = pg.attribute("NEXTITEM").toInt();
3002
else if (pg.tagName()=="MASTEROBJECT")
3004
itemRemapM[itemCountM++] = m_Doc->MasterItems.count();
3005
if (pg.attribute("NEXTITEM").toInt() != -1)
3006
itemNextM[m_Doc->MasterItems.count()] = pg.attribute("NEXTITEM").toInt();
3008
/* not sure if we want that...
3009
else if (pg.tagName()=="FRAMEOBJECT")
3011
itemRemapF[itemCountF++] = m_Doc->FrameItems->count();
3012
if (pg.attribute("NEXTITEM").toInt() != -1)
3013
itemNextF[m_Doc->FrameItems->count()] = pg.attribute("NEXTITEM").toInt();
3015
//int docGc = m_Doc->GroupCounter;
3016
/*m_Doc->GroupCounter = 0;*/
3017
Neu = PasteItem(&pg, m_Doc, fileDir);
3018
Neu->moveBy(-pageX + Apage->xOffset(), - pageY + Apage->yOffset());
3019
Neu->setRedrawBounding();
3020
//CB Must run onpage as we cant use pagetoload if the page has been renamed.
3021
//CB TODO Make this accept a page to place onto.
3022
//Neu->OwnPage = m_Doc->OnPage(Neu);
3023
//Neu->OwnPage = PageToLoad;
3024
Neu->OwnPage = m_Doc->currentPageNumber();
3025
if (pg.tagName()=="PAGEOBJECT")
3026
Neu->OnMasterPage = "";
3027
Neu->LayerNr = layerTrans.value(Neu->LayerNr, Neu->LayerNr);
3028
/*m_Doc->GroupCounter = docGc;*/
3029
tmpf = pg.attribute("IFONT", m_Doc->toolSettings.defFont);
3030
m_AvailableFonts->findFont(tmpf, m_Doc);
3031
QDomNode IT=pg.firstChild();
3032
LastStyles * last = new LastStyles();
3035
QDomElement it=IT.toElement();
3036
if (it.tagName()=="CSTOP")
3038
QString name = it.attribute("NAME");
3039
double ramp = ScCLocale::toDoubleC( it.attribute("RAMP"), 0.0);
3040
int shade = it.attribute("SHADE", "100").toInt();
3041
double opa = ScCLocale::toDoubleC( it.attribute("TRANS"), 1);
3042
Neu->fill_gradient.addStop(SetColor(m_Doc, name, shade), ramp, 0.5, opa, name, shade);
3044
if (it.tagName()=="ITEXT")
3045
GetItemText(&it, m_Doc, Neu, last, true, VorLFound);
3046
else if (it.tagName()=="para")
3048
Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::PARSEP);
3049
ParagraphStyle newStyle;
3050
PrefsManager* prefsManager=PrefsManager::instance();
3051
readParagraphStyle(newStyle, it, prefsManager->appPrefs.AvailFonts, m_Doc);
3052
Neu->itemText.setStyle(Neu->itemText.length()-1, newStyle);
3053
Neu->itemText.setCharStyle(Neu->itemText.length()-1, 1, last->Style);
3055
else if (it.tagName() == "trail")
3057
ParagraphStyle newStyle;
3058
PrefsManager* prefsManager = PrefsManager::instance();
3059
readParagraphStyle(newStyle, it, prefsManager->appPrefs.AvailFonts, m_Doc);
3060
Neu->itemText.setStyle(Neu->itemText.length(), newStyle);
3062
else if (it.tagName()=="tab")
3065
Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::TAB);
3066
GetCStyle(&it, m_Doc, newStyle);
3067
Neu->itemText.setCharStyle(Neu->itemText.length()-1, 1, newStyle);
3068
last->StyleStart = Neu->itemText.length()-1;
3069
last->Style = newStyle;
3071
else if (it.tagName()=="breakline")
3072
Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::LINEBREAK);
3073
else if (it.tagName()=="breakcol")
3074
Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::COLBREAK);
3075
else if (it.tagName()=="breakframe")
3076
Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::FRAMEBREAK);
3077
else if (it.tagName()=="nbhyphen")
3078
Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::NBHYPHEN);
3079
else if (it.tagName()=="nbspace")
3080
Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::NBSPACE);
3081
else if (it.tagName()=="zwnbspace")
3082
Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::ZWNBSPACE);
3083
else if (it.tagName()=="zwspace")
3084
Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::ZWSPACE);
3085
else if (it.tagName()=="var")
3087
if (it.attribute("name") == "pgno")
3088
Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::PAGENUMBER);
3090
Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::PAGECOUNT);
3092
GetCStyle(&it, m_Doc, newStyle);
3093
Neu->itemText.setCharStyle(Neu->itemText.length()-1, 1, newStyle);
3094
last->StyleStart = Neu->itemText.length()-1;
3095
last->Style = newStyle;
3098
if(it.tagName()=="PageItemAttributes")
3100
QDomNode PIA = it.firstChild();
3101
ObjAttrVector pageItemAttributes;
3102
while(!PIA.isNull())
3104
QDomElement itemAttr = PIA.toElement();
3105
if(itemAttr.tagName() == "ItemAttribute")
3107
ObjectAttribute objattr;
3108
objattr.name=itemAttr.attribute("Name");
3109
objattr.type=itemAttr.attribute("Type");
3110
objattr.value=itemAttr.attribute("Value");
3111
objattr.parameter=itemAttr.attribute("Parameter");
3112
objattr.relationship=itemAttr.attribute("Relationship");
3113
objattr.relationshipto=itemAttr.attribute("RelationshipTo");
3114
objattr.autoaddto=itemAttr.attribute("AutoAddTo");
3115
pageItemAttributes.append(objattr);
3117
PIA = PIA.nextSibling();
3119
Neu->setObjectAttributes(&pageItemAttributes);
3121
IT=IT.nextSibling();
3124
if (Neu->asPathText())
3126
Neu->updatePolyClip();
3129
if (Neu->fill_gradient.Stops() == 0)
3131
const ScColor& col1 = m_Doc->PageColors[m_Doc->toolSettings.dBrush];
3132
const ScColor& col2 = m_Doc->PageColors[m_Doc->toolSettings.dPen];
3133
Neu->fill_gradient.addStop(ScColorEngine::getRGBColor(col1, m_Doc), 0.0, 0.5, 1.0, m_Doc->toolSettings.dBrush, 100);
3134
Neu->fill_gradient.addStop(ScColorEngine::getRGBColor(col2, m_Doc), 1.0, 0.5, 1.0, m_Doc->toolSettings.dPen, 100);
3136
// Neu->Language = ScMW->GetLang(pg.attribute("LANGUAGE", m_Doc->Language));
3137
// Neu->Language = m_Doc->Language;
3138
Neu->isAutoText = static_cast<bool>(pg.attribute("AUTOTEXT").toInt());
3139
Neu->isEmbedded = static_cast<bool>(pg.attribute("isInline", "0").toInt());
3140
Neu->gXpos = ScCLocale::toDoubleC( pg.attribute("gXpos"), 0.0);
3141
Neu->gYpos = ScCLocale::toDoubleC( pg.attribute("gYpos"), 0.0);
3143
defaultVal.setNum(Neu->width());
3144
Neu->gWidth = ScCLocale::toDoubleC( pg.attribute("gWidth",defaultVal));
3145
defaultVal.setNum(Neu->height());
3146
Neu->gHeight = ScCLocale::toDoubleC( pg.attribute("gHeight",defaultVal));
3147
if (Neu->isAutoText)
3148
m_Doc->LastAuto = Neu;
3149
if (Neu->isTableItem)
3151
TableItems.append(Neu);
3152
TableID.insert(pg.attribute("OwnLINK", "0").toInt(), Neu->ItemNr);
3154
Neu->isGroupControl = static_cast<bool>(pg.attribute("isGroupControl", "0").toInt());
3155
if (Neu->isGroupControl)
3157
int groupLastItem = pg.attribute("groupsLastItem", "0").toInt();
3158
if ((Neu->Groups.count() == 0) || (groupLastItem <= 0)) // Sanity check for some broken files created using buggy development versions.
3160
Neu->isGroupControl = false;
3161
Neu->setFillColor("None");
3164
groupID.insert(Neu, groupLastItem + Neu->ItemNr);
3166
if (pg.tagName()=="FRAMEOBJECT")
3168
m_Doc->FrameItems.append(m_Doc->Items->takeAt(Neu->ItemNr));
3169
Neu->ItemNr = m_Doc->FrameItems.count()-1;
3174
PAGE=PAGE.nextSibling();
3176
PAGE=DOC.firstChild();
3177
while(!PAGE.isNull())
3179
QDomElement pg=PAGE.toElement();
3180
if(pg.tagName()=="Bookmark")
3182
int elem = pg.attribute("Element").toInt();
3183
if (elem < m_Doc->Items->count())
3185
bok.Title = pg.attribute("Title");
3186
bok.Text = pg.attribute("Text");
3187
bok.Aktion = pg.attribute("Aktion");
3188
bok.ItemNr = pg.attribute("ItemNr").toInt();
3189
bok.PageObject = m_Doc->Items->at(elem);
3190
bok.First = pg.attribute("First").toInt();
3191
bok.Last = pg.attribute("Last").toInt();
3192
bok.Prev = pg.attribute("Prev").toInt();
3193
bok.Next = pg.attribute("Next").toInt();
3194
bok.Parent = pg.attribute("Parent").toInt();
3195
m_Doc->BookMarks.append(bok);
3198
if(pg.tagName()=="Pattern")
3201
QDomNode pa = PAGE.firstChild();
3202
uint ac = m_Doc->Items->count();
3203
bool savedAlignGrid = m_Doc->useRaster;
3204
bool savedAlignGuides = m_Doc->SnapGuides;
3205
m_Doc->useRaster = false;
3206
m_Doc->SnapGuides = false;
3209
QDomElement pite = pa.toElement();
3210
m_Doc->setMasterPageMode(false);
3211
// first of linked chain?
3212
if (pg.tagName()=="PAGEOBJECT")
3214
itemRemap[itemCount++] = m_Doc->DocItems.count();
3215
if (pg.attribute("NEXTITEM").toInt() != -1)
3216
itemNext[m_Doc->DocItems.count()] = pg.attribute("NEXTITEM").toInt();
3218
/* not sure if we want that...
3219
else if (pg.tagName()=="MASTEROBJECT")
3221
itemRemapM[itemCountM++] = m_Doc->MasterItems->count();
3222
if (pg.attribute("NEXTITEM").toInt() != -1)
3223
itemNextM[m_Doc->MasterItems->count()] = pg.attribute("NEXTITEM").toInt();
3225
else if (pg.tagName()=="FRAMEOBJECT")
3227
itemRemapF[itemCountF++] = m_Doc->FrameItems->count();
3228
if (pg.attribute("NEXTITEM").toInt() != -1)
3229
itemNextF[m_Doc->FrameItems->count()] = pg.attribute("NEXTITEM").toInt();
3231
//int docGc = m_Doc->GroupCounter;
3232
/*m_Doc->GroupCounter = 0;*/
3233
Neu = PasteItem(&pite, m_Doc, fileDir);
3234
Neu->setRedrawBounding();
3235
Neu->OwnPage = pite.attribute("OwnPage").toInt();
3236
Neu->OnMasterPage = "";
3237
Neu->LayerNr = layerTrans.value(Neu->LayerNr, Neu->LayerNr);
3238
/*m_Doc->GroupCounter = docGc;*/
3239
tmpf = pite.attribute("IFONT", m_Doc->toolSettings.defFont);
3240
m_AvailableFonts->findFont(tmpf, m_Doc);
3241
QDomNode IT=pite.firstChild();
3242
LastStyles * last = new LastStyles();
3245
QDomElement it=IT.toElement();
3246
if (it.tagName()=="CSTOP")
3248
QString name = it.attribute("NAME");
3249
double ramp = ScCLocale::toDoubleC( it.attribute("RAMP"), 0.0);
3250
int shade = it.attribute("SHADE", "100").toInt();
3251
double opa = ScCLocale::toDoubleC( it.attribute("TRANS"), 1.0);
3252
Neu->fill_gradient.addStop(SetColor(m_Doc, name, shade), ramp, 0.5, opa, name, shade);
3254
if (it.tagName()=="ITEXT")
3255
GetItemText(&it, m_Doc, Neu, last);
3256
if(it.tagName()=="PageItemAttributes")
3258
QDomNode PIA = it.firstChild();
3259
ObjAttrVector pageItemAttributes;
3260
while(!PIA.isNull())
3262
QDomElement itemAttr = PIA.toElement();
3263
if(itemAttr.tagName() == "ItemAttribute")
3265
ObjectAttribute objattr;
3266
objattr.name=itemAttr.attribute("Name");
3267
objattr.type=itemAttr.attribute("Type");
3268
objattr.value=itemAttr.attribute("Value");
3269
objattr.parameter=itemAttr.attribute("Parameter");
3270
objattr.relationship=itemAttr.attribute("Relationship");
3271
objattr.relationshipto=itemAttr.attribute("RelationshipTo");
3272
objattr.autoaddto=itemAttr.attribute("AutoAddTo");
3273
pageItemAttributes.append(objattr);
3275
PIA = PIA.nextSibling();
3277
Neu->setObjectAttributes(&pageItemAttributes);
3279
IT=IT.nextSibling();
3282
if (Neu->asPathText())
3284
Neu->updatePolyClip();
3287
if (Neu->fill_gradient.Stops() == 0)
3289
const ScColor& col1 = m_Doc->PageColors[m_Doc->toolSettings.dBrush];
3290
const ScColor& col2 = m_Doc->PageColors[m_Doc->toolSettings.dPen];
3291
Neu->fill_gradient.addStop(ScColorEngine::getRGBColor(col1, m_Doc), 0.0, 0.5, 1.0, m_Doc->toolSettings.dBrush, 100);
3292
Neu->fill_gradient.addStop(ScColorEngine::getRGBColor(col2, m_Doc), 1.0, 0.5, 1.0, m_Doc->toolSettings.dPen, 100);
3294
Neu->isAutoText = static_cast<bool>(pite.attribute("AUTOTEXT").toInt());
3295
Neu->isEmbedded = static_cast<bool>(pite.attribute("isInline", "0").toInt());
3296
Neu->gXpos = ScCLocale::toDoubleC( pite.attribute("gXpos"), 0.0);
3297
Neu->gYpos = ScCLocale::toDoubleC( pite.attribute("gYpos"), 0.0);
3299
defaultVal.setNum(Neu->width());
3300
Neu->gWidth = ScCLocale::toDoubleC( pite.attribute("gWidth",defaultVal));
3301
defaultVal.setNum(Neu->height());
3302
Neu->gHeight = ScCLocale::toDoubleC( pite.attribute("gHeight",defaultVal));
3303
if (Neu->isTableItem)
3305
TableItems.append(Neu);
3306
TableID.insert(pite.attribute("OwnLINK", "0").toInt(), Neu->ItemNr);
3308
Neu->isGroupControl = static_cast<bool>(pite.attribute("isGroupControl", "0").toInt());
3309
if (Neu->isGroupControl)
3311
if (Neu->Groups.count() == 0) // Sanity check for some broken files created using buggy development versions.
3313
Neu->isGroupControl = false;
3314
Neu->setFillColor("None");
3317
groupID.insert(Neu, pite.attribute("groupsLastItem", "0").toInt()+Neu->ItemNr);
3319
pa = pa.nextSibling();
3321
m_Doc->useRaster = savedAlignGrid;
3322
m_Doc->SnapGuides = savedAlignGuides;
3324
pat.width = ScCLocale::toDoubleC( pg.attribute("width"), 0.0);
3325
pat.height = ScCLocale::toDoubleC( pg.attribute("height"), 0.0);
3326
pat.scaleX = ScCLocale::toDoubleC( pg.attribute("scaleX"), 0.0);
3327
pat.scaleY = ScCLocale::toDoubleC( pg.attribute("scaleY"), 0.0);
3328
uint ae = m_Doc->Items->count();
3331
PageItem* currItem = m_Doc->Items->at(ac);
3332
pat.pattern = currItem->DrawObj_toImage();
3333
for (uint as = ac; as < ae; ++as)
3335
Neu = m_Doc->Items->takeAt(ac);
3336
Neu->ItemNr = pat.items.count();
3337
pat.items.append(Neu);
3340
QString patName = pg.attribute("Name");
3341
if (!patName.isEmpty())
3342
m_Doc->docPatterns.insert(pg.attribute("Name"), pat);
3344
PAGE=PAGE.nextSibling();
3346
DOC=DOC.nextSibling();
3348
if (TableItems.count() != 0)
3350
for (int ttc = 0; ttc < TableItems.count(); ++ttc)
3352
PageItem* ta = TableItems.at(ttc);
3353
if (ta->TopLinkID != -1)
3354
ta->TopLink = m_Doc->Items->at(TableID[ta->TopLinkID]);
3357
if (ta->LeftLinkID != -1)
3358
ta->LeftLink = m_Doc->Items->at(TableID[ta->LeftLinkID]);
3361
if (ta->RightLinkID != -1)
3362
ta->RightLink = m_Doc->Items->at(TableID[ta->RightLinkID]);
3365
if (ta->BottomLinkID != -1)
3366
ta->BottomLink = m_Doc->Items->at(TableID[ta->BottomLinkID]);
3371
if (groupID.count() != 0)
3373
QMap<PageItem*, int>::Iterator it;
3374
for (it = groupID.begin(); it != groupID.end(); ++it)
3376
it.key()->groupsLastItem = m_Doc->Items->at(it.value());
3380
// reestablish textframe links
3381
if (itemNext.count() != 0 && !Mpage)
3383
QMap<int,int>::Iterator lc;
3384
for (lc = itemNext.begin(); lc != itemNext.end(); ++lc)
3386
if (itemRemap[lc.value()] >= 0)
3388
if ((lc.key() < m_Doc->Items->count()) && (itemRemap[lc.value()] < m_Doc->Items->count()))
3390
PageItem * Its = m_Doc->DocItems.at(lc.key());
3391
PageItem * Itn = m_Doc->DocItems.at(itemRemap[lc.value()]);
3392
if (Itn->prevInChain() || Its->nextInChain())
3394
qDebug() << "scribus134format: corruption in linked textframes detected";
3402
else if (itemNextM.count() != 0 && Mpage)
3404
QMap<int,int>::Iterator lc;
3405
for (lc = itemNextM.begin(); lc != itemNextM.end(); ++lc)
3407
if (itemRemapM[lc.value()] >= 0)
3409
if ((lc.key() < m_Doc->MasterItems.count()) && (itemRemapM[lc.value()] < m_Doc->MasterItems.count()))
3411
PageItem * Its = m_Doc->MasterItems.at(lc.key());
3412
PageItem * Itn = m_Doc->MasterItems.at(itemRemapM[lc.value()]);
3413
if (Itn->prevInChain() || Its->nextInChain())
3415
qDebug() << "scribus134format: corruption in linked textframes detected";
3424
// reestablish first/lastAuto
3425
m_Doc->FirstAuto = m_Doc->LastAuto;
3426
if (m_Doc->LastAuto)
3428
while (m_Doc->LastAuto->nextInChain())
3429
m_Doc->LastAuto = m_Doc->LastAuto->nextInChain();
3430
while (m_Doc->FirstAuto->prevInChain())
3431
m_Doc->FirstAuto = m_Doc->FirstAuto->prevInChain();
3437
void Scribus134Format::GetStyle(QDomElement *pg, ParagraphStyle *vg, StyleSet<ParagraphStyle> * tempStyles, ScribusDoc* doc, bool fl)
3441
const StyleSet<ParagraphStyle> * docParagraphStyles = tempStyles? tempStyles : & doc->paragraphStyles();
3442
PrefsManager* prefsManager=PrefsManager::instance();
3443
readParagraphStyle(*vg, *pg, prefsManager->appPrefs.AvailFonts, doc);
3444
for (int xx=0; xx<docParagraphStyles->count(); ++xx)
3446
if (vg->name() == (*docParagraphStyles)[xx].name())
3448
if (vg->equiv((*docParagraphStyles)[xx]))
3452
DoVorl[VorlC] = tmV.setNum(xx);
3459
vg->setName("Copy of "+(*docParagraphStyles)[xx].name());
3467
for (int xx=0; xx< docParagraphStyles->count(); ++xx)
3469
if (vg->equiv((*docParagraphStyles)[xx]) && fl)
3471
vg->setName((*docParagraphStyles)[xx].name());
3475
DoVorl[VorlC] = tmV.setNum(xx);
3485
tempStyles->create(*vg);
3488
StyleSet<ParagraphStyle> tmp;
3490
doc->redefineStyles(tmp, false);
3494
DoVorl[VorlC] = tmV.setNum(docParagraphStyles->count()-1);
3500
bool Scribus134Format::readStyles(const QString& fileName, ScribusDoc* doc, StyleSet<ParagraphStyle> &docParagraphStyles)
3502
ParagraphStyle pstyle;
3503
QDomDocument docu("scridoc");
3504
QString f (readSLA(fileName));
3507
if(!docu.setContent(f))
3509
QDomElement elem=docu.documentElement();
3510
if (elem.tagName() != "SCRIBUSUTF8NEW")
3512
QDomNode DOC=elem.firstChild();
3513
while(!DOC.isNull())
3515
QDomElement dc=DOC.toElement();
3516
QDomNode PAGE=DOC.firstChild();
3517
while(!PAGE.isNull())
3519
QDomElement pg=PAGE.toElement();
3520
if(pg.tagName()=="STYLE")
3523
GetStyle(&pg, &pstyle, &docParagraphStyles, doc, false);
3525
PAGE=PAGE.nextSibling();
3527
DOC=DOC.nextSibling();
3532
bool Scribus134Format::readCharStyles(const QString& fileName, ScribusDoc* doc, StyleSet<CharStyle> &docCharStyles)
3535
QDomDocument docu("scridoc");
3536
QString f (readSLA(fileName));
3539
if(!docu.setContent(f))
3541
QDomElement elem=docu.documentElement();
3542
if (elem.tagName() != "SCRIBUSUTF8NEW")
3544
QDomNode DOC=elem.firstChild();
3545
while(!DOC.isNull())
3547
QDomElement dc=DOC.toElement();
3548
QDomNode PAGE=DOC.firstChild();
3549
while(!PAGE.isNull())
3551
QDomElement pg=PAGE.toElement();
3552
if(pg.tagName()=="CHARSTYLE")
3555
GetCStyle(&pg, doc, cstyle);
3556
docCharStyles.create(cstyle);
3558
PAGE=PAGE.nextSibling();
3560
DOC=DOC.nextSibling();
3565
bool Scribus134Format::readLineStyles(const QString& fileName, QMap<QString,multiLine> *Sty)
3567
QDomDocument docu("scridoc");
3568
QString f(readSLA(fileName));
3571
if(!docu.setContent(f))
3573
QDomElement elem=docu.documentElement();
3574
if (elem.tagName() != "SCRIBUSUTF8NEW")
3576
QDomNode DOC=elem.firstChild();
3577
while(!DOC.isNull())
3579
QDomElement dc=DOC.toElement();
3580
QDomNode PAGE=DOC.firstChild();
3581
while(!PAGE.isNull())
3583
QDomElement pg=PAGE.toElement();
3584
if(pg.tagName()=="MultiLine")
3587
QDomNode MuLn = PAGE.firstChild();
3588
while(!MuLn.isNull())
3590
QDomElement MuL = MuLn.toElement();
3591
struct SingleLine sl;
3592
sl.Color = MuL.attribute("Color");
3593
sl.Dash = MuL.attribute("Dash").toInt();
3594
sl.LineEnd = MuL.attribute("LineEnd").toInt();
3595
sl.LineJoin = MuL.attribute("LineJoin").toInt();
3596
sl.Shade = MuL.attribute("Shade").toInt();
3597
sl.Width = ScCLocale::toDoubleC( MuL.attribute("Width"));
3598
ml.shortcut = MuL.attribute("Shortcut");
3600
MuLn = MuLn.nextSibling();
3602
QString Nam = pg.attribute("Name");
3605
QMap<QString,multiLine>::ConstIterator mlit = Sty->find(Nam2);
3606
if (mlit != Sty->end() && ml != mlit.value())
3608
while (Sty->contains(Nam2))
3610
Nam2 = tr("Copy #%1 of ").arg(copyC)+Nam;
3614
Sty->insert(Nam2, ml);
3616
PAGE=PAGE.nextSibling();
3618
DOC=DOC.nextSibling();
3623
bool Scribus134Format::readColors(const QString& fileName, ColorList & colors)
3625
QString f(readSLA(fileName));
3628
QDomDocument docu("scridoc");
3629
if(!docu.setContent(f))
3632
ScColor lf = ScColor();
3633
QDomElement elem=docu.documentElement();
3634
if (elem.tagName() != "SCRIBUSUTF8NEW")
3636
QDomNode DOC=elem.firstChild();
3637
while(!DOC.isNull())
3639
QDomElement dc=DOC.toElement();
3640
QDomNode PAGE=DOC.firstChild();
3641
while(!PAGE.isNull())
3643
QDomElement pg=PAGE.toElement();
3644
// 10/25/2004 pv - None is "reserved" color. cannot be defined in any file...
3645
if(pg.tagName()=="COLOR" && pg.attribute("NAME")!=CommonStrings::None)
3647
if (pg.hasAttribute("CMYK"))
3648
lf.setNamedColor(pg.attribute("CMYK"));
3650
lf.fromQColor(QColor(pg.attribute("RGB")));
3651
if (pg.hasAttribute("Spot"))
3652
lf.setSpotColor(static_cast<bool>(pg.attribute("Spot").toInt()));
3654
lf.setSpotColor(false);
3655
if (pg.hasAttribute("Register"))
3656
lf.setRegistrationColor(static_cast<bool>(pg.attribute("Register").toInt()));
3658
lf.setRegistrationColor(false);
3659
QString name = pg.attribute("NAME");
3660
colors.insert((name.isEmpty()) ? lf.name() : name, lf);
3662
PAGE=PAGE.nextSibling();
3664
DOC=DOC.nextSibling();
3669
bool Scribus134Format::readPageCount(const QString& fileName, int *num1, int *num2, QStringList & masterPageNames)
3674
QDomDocument docu("scridoc");
3675
QString f(readSLA(fileName));
3678
if(!docu.setContent(f))
3680
QDomElement elem=docu.documentElement();
3681
if (elem.tagName() != "SCRIBUSUTF8NEW")
3683
QDomNode DOC=elem.firstChild();
3684
while(!DOC.isNull())
3686
QDomNode PAGE=DOC.firstChild();
3687
while(!PAGE.isNull())
3689
QDomElement pg=PAGE.toElement();
3690
PgNam = pg.attribute("NAM", "");
3691
if(pg.tagName()=="PAGE")
3693
if(pg.tagName()=="MASTERPAGE")
3696
masterPageNames.append(PgNam);
3698
PAGE=PAGE.nextSibling();
3700
DOC=DOC.nextSibling();