Rev 18491 | Rev 18906 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5653 | cbradney | 1 | /* |
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. |
||
6 | */ |
||
7 | #include "scribus134format.h" |
||
8 | #include "scribus134formatimpl.h" |
||
9 | |||
10 | #include "../../formatidlist.h" |
||
11 | #include "commonstrings.h" |
||
17798 | craig | 12 | #include "langmgr.h" |
13650 | cbradney | 13 | #include "ui/missing.h" |
13710 | jghali | 14 | #include "hyphenator.h" |
15 | #include "pageitem_latexframe.h" |
||
17417 | fschmid | 16 | #include "pageitem_table.h" |
5653 | cbradney | 17 | #include "prefsmanager.h" |
13473 | pierre | 18 | #include "scclocale.h" |
5653 | cbradney | 19 | #include "scconfig.h" |
13710 | jghali | 20 | #include "sccolorengine.h" |
10607 | mrdocs | 21 | #include "scpattern.h" |
13710 | jghali | 22 | #include "scribuscore.h" |
5653 | cbradney | 23 | #include "scribusdoc.h" |
24 | #include "scribusview.h" |
||
13503 | cbradney | 25 | #include "sctextstream.h" |
13710 | jghali | 26 | #include "scxmlstreamreader.h" |
13853 | jghali | 27 | #include "undomanager.h" |
5653 | cbradney | 28 | #include "units.h" |
29 | #include "util.h" |
||
10203 | cbradney | 30 | #include "util_math.h" |
31 | #include "util_color.h" |
||
13873 | jghali | 32 | #include "util_layer.h" |
8022 | jghali | 33 | #include "scgzfile.h" |
17982 | jghali | 34 | |
35 | #include <QApplication> |
||
36 | #include <QByteArray> |
||
10170 | fschmid | 37 | #include <QCursor> |
11675 | cbradney | 38 | // #include <QDebug> |
10170 | fschmid | 39 | #include <QFileInfo> |
17982 | jghali | 40 | #include <QIODevice> |
9803 | fschmid | 41 | #include <QList> |
17982 | jghali | 42 | #include <QScopedPointer> |
5653 | cbradney | 43 | |
44 | // See scplugin.h and pluginmanager.{cpp,h} for detail on what these methods |
||
45 | // do. That documentatation is not duplicated here. |
||
46 | // Please don't implement the functionality of your plugin here; do that |
||
47 | // in scribus134formatimpl.h and scribus134formatimpl.cpp . |
||
48 | |||
49 | Scribus134Format::Scribus134Format() : |
||
50 | LoadSavePlugin() |
||
51 | { |
||
52 | // Set action info in languageChange, so we only have to do |
||
53 | // it in one place. This includes registering file formats. |
||
18254 | fschmid | 54 | registerFormats(); |
5653 | cbradney | 55 | languageChange(); |
56 | } |
||
57 | |||
58 | Scribus134Format::~Scribus134Format() |
||
59 | { |
||
60 | unregisterAll(); |
||
18254 | fschmid | 61 | } |
5653 | cbradney | 62 | |
63 | void Scribus134Format::languageChange() |
||
64 | { |
||
18254 | fschmid | 65 | FileFormat* fmt = getFormatByID(FORMATID_SLA134IMPORT); |
66 | fmt->trName = tr("Scribus 1.3.4+ Document"); |
||
67 | fmt->filter = fmt->trName + " (*.sla *.SLA *.sla.gz *.SLA.GZ *.scd *.SCD *.scd.gz *.SCD.GZ)"; |
||
5653 | cbradney | 68 | } |
69 | |||
70 | const QString Scribus134Format::fullTrName() const |
||
71 | { |
||
12851 | cbradney | 72 | return QObject::tr("Scribus 1.3.4+ Support"); |
5653 | cbradney | 73 | } |
74 | |||
75 | const ScActionPlugin::AboutData* Scribus134Format::getAboutData() const |
||
76 | { |
||
77 | AboutData* about = new AboutData; |
||
78 | Q_CHECK_PTR(about); |
||
12711 | cbradney | 79 | about->authors = QString::fromUtf8( |
80 | "Franz Schmid <franz@scribus.info>, " |
||
81 | "The Scribus Team"); |
||
82 | about->shortDescription = tr("Scribus 1.3.4+ File Format Support"); |
||
83 | about->description = tr("Allows Scribus to read Scribus 1.3.4 and higher formatted files."); |
||
84 | // about->version |
||
85 | // about->releaseDate |
||
86 | // about->copyright |
||
87 | about->license = "GPL"; |
||
5653 | cbradney | 88 | return about; |
89 | } |
||
90 | |||
91 | void Scribus134Format::deleteAboutData(const AboutData* about) const |
||
92 | { |
||
93 | Q_ASSERT(about); |
||
94 | delete about; |
||
95 | } |
||
96 | |||
97 | void Scribus134Format::registerFormats() |
||
98 | { |
||
99 | FileFormat fmt(this); |
||
12851 | cbradney | 100 | fmt.trName = tr("Scribus 1.3.4+ Document"); |
5653 | cbradney | 101 | fmt.formatId = FORMATID_SLA134IMPORT; |
102 | fmt.load = true; |
||
16160 | fschmid | 103 | fmt.save = false; |
14792 | fschmid | 104 | fmt.colorReading = true; |
5653 | cbradney | 105 | fmt.filter = fmt.trName + " (*.sla *.SLA *.sla.gz *.SLA.GZ *.scd *.SCD *.scd.gz *.SCD.GZ)"; |
106 | fmt.mimeTypes = QStringList(); |
||
107 | fmt.mimeTypes.append("application/x-scribus"); |
||
14792 | fschmid | 108 | fmt.fileExtensions = QStringList() << "sla" << "sla.gz" << "scd" << "scd.gz"; |
5653 | cbradney | 109 | fmt.priority = 64; |
110 | registerFormat(fmt); |
||
111 | } |
||
112 | |||
113 | bool Scribus134Format::fileSupported(QIODevice* /* file */, const QString & fileName) const |
||
114 | { |
||
9535 | fschmid | 115 | QByteArray docBytes(""); |
5653 | cbradney | 116 | if(fileName.right(2) == "gz") |
117 | { |
||
11739 | jghali | 118 | if (!ScGzFile::readFromFile(fileName, docBytes, 4096)) |
5653 | cbradney | 119 | { |
120 | // FIXME: Needs better error return |
||
15482 | craig | 121 | return false; |
5653 | cbradney | 122 | } |
123 | } |
||
124 | else |
||
125 | { |
||
126 | // Not gzip encoded, just load it |
||
127 | loadRawText(fileName, docBytes); |
||
128 | } |
||
7046 | avox | 129 | // if (docBytes.left(16) == "<SCRIBUSUTF8NEW " && docBytes.left(35).contains("Version=\"1.3.4")) |
130 | // return true; |
||
16073 | jghali | 131 | QRegExp regExp134("Version=\"1.3.[4-9]"); |
132 | QRegExp regExp140("Version=\"1.4.[0-9]"); |
||
10593 | fschmid | 133 | int startElemPos = docBytes.left(512).indexOf("<SCRIBUSUTF8NEW "); |
16073 | jghali | 134 | if (startElemPos >= 0) |
135 | { |
||
136 | bool is134 = ( regExp134.indexIn(docBytes.mid(startElemPos, 64)) >= 0 ); |
||
137 | bool is140 = ( regExp140.indexIn(docBytes.mid(startElemPos, 64)) >= 0 ); |
||
138 | return (is134 || is140); |
||
139 | } |
||
140 | return false; |
||
5653 | cbradney | 141 | } |
142 | |||
17982 | jghali | 143 | QIODevice* Scribus134Format::slaReader(const QString & fileName) |
5653 | cbradney | 144 | { |
17982 | jghali | 145 | if (!fileSupported(0, fileName)) |
146 | return NULL; |
||
147 | |||
148 | QIODevice* ioDevice = 0; |
||
5653 | cbradney | 149 | if(fileName.right(2) == "gz") |
150 | { |
||
17982 | jghali | 151 | ioDevice = new ScGzFile(fileName); |
152 | if (!ioDevice->open(QIODevice::ReadOnly)) |
||
5653 | cbradney | 153 | { |
17982 | jghali | 154 | delete ioDevice; |
155 | return NULL; |
||
5653 | cbradney | 156 | } |
157 | } |
||
158 | else |
||
159 | { |
||
17982 | jghali | 160 | ioDevice = new QFile(fileName); |
161 | if (!ioDevice->open(QIODevice::ReadOnly)) |
||
162 | { |
||
163 | delete ioDevice; |
||
164 | return NULL; |
||
165 | } |
||
5653 | cbradney | 166 | } |
17982 | jghali | 167 | return ioDevice; |
5653 | cbradney | 168 | } |
169 | |||
9803 | fschmid | 170 | void Scribus134Format::getReplacedFontData(bool & getNewReplacement, QMap<QString,QString> &getReplacedFonts, QList<ScFace> &getDummyScFaces) |
5653 | cbradney | 171 | { |
8775 | cbradney | 172 | getNewReplacement=false; |
173 | getReplacedFonts.clear(); |
||
5653 | cbradney | 174 | } |
175 | |||
176 | bool Scribus134Format::loadFile(const QString & fileName, const FileFormat & /* fmt */, int /* flags */, int /* index */) |
||
177 | { |
||
178 | if (m_Doc==0 || m_AvailableFonts==0) |
||
179 | { |
||
180 | Q_ASSERT(m_Doc==0 || m_AvailableFonts==0); |
||
181 | return false; |
||
182 | } |
||
183 | ParagraphStyle vg; |
||
184 | struct ScribusDoc::BookMa bok; |
||
13715 | jghali | 185 | QMap<int, ScribusDoc::BookMa> bookmarks; |
13710 | jghali | 186 | |
16943 | fschmid | 187 | QMap<int,PageItem*> TableID; |
188 | QMap<int,PageItem*> TableIDM; |
||
189 | QMap<int,PageItem*> TableIDF; |
||
9856 | fschmid | 190 | QList<PageItem*> TableItems; |
191 | QList<PageItem*> TableItemsM; |
||
192 | QList<PageItem*> TableItemsF; |
||
16105 | fschmid | 193 | // QMap<PageItem*, int> groupID; |
194 | // QMap<PageItem*, int> groupIDM; |
||
195 | // QMap<PageItem*, int> groupIDF; |
||
196 | QStack< QList<PageItem*> > groupStack; |
||
197 | QStack< QList<PageItem*> > groupStackF; |
||
198 | QStack< QList<PageItem*> > groupStackM; |
||
199 | QStack< QList<PageItem*> > groupStackP; |
||
200 | QStack<int> groupStack2; |
||
13710 | jghali | 201 | |
17982 | jghali | 202 | QScopedPointer<QIODevice> ioDevice(slaReader(fileName)); |
203 | if (ioDevice.isNull()) |
||
14395 | jghali | 204 | { |
205 | setFileReadError(); |
||
5653 | cbradney | 206 | return false; |
14395 | jghali | 207 | } |
10593 | fschmid | 208 | QString fileDir = QFileInfo(fileName).absolutePath(); |
13710 | jghali | 209 | int firstPage = 0; |
210 | int layerToSetActive = 0; |
||
211 | |||
5653 | cbradney | 212 | if (m_mwProgressBar!=0) |
213 | { |
||
17982 | jghali | 214 | m_mwProgressBar->setMaximum(ioDevice->size()); |
9953 | cbradney | 215 | m_mwProgressBar->setValue(0); |
5653 | cbradney | 216 | } |
13518 | jghali | 217 | // Stop autosave timer,it will be restarted only if doc has autosave feature is enabled |
218 | if (m_Doc->autoSaveTimer->isActive()) |
||
219 | m_Doc->autoSaveTimer->stop(); |
||
13710 | jghali | 220 | |
221 | groupRemap.clear(); |
||
222 | itemRemap.clear(); |
||
223 | itemNext.clear(); |
||
224 | itemCount = 0; |
||
225 | itemRemapM.clear(); |
||
226 | itemNextM.clear(); |
||
227 | itemCountM = 0; |
||
13715 | jghali | 228 | |
5653 | cbradney | 229 | TableItems.clear(); |
230 | TableID.clear(); |
||
7450 | fschmid | 231 | TableItemsM.clear(); |
232 | TableIDM.clear(); |
||
233 | TableItemsF.clear(); |
||
234 | TableIDF.clear(); |
||
13710 | jghali | 235 | |
236 | m_Doc->GroupCounter = 1; |
||
237 | m_Doc->LastAuto = 0; |
||
238 | m_Doc->PageColors.clear(); |
||
239 | m_Doc->Layers.clear(); |
||
240 | |||
241 | bool firstElement = true; |
||
242 | bool success = true; |
||
243 | bool hasPageSets = false; |
||
244 | int progress = 0; |
||
245 | |||
17982 | jghali | 246 | ScXmlStreamReader reader(ioDevice.data()); |
13710 | jghali | 247 | ScXmlStreamAttributes attrs; |
248 | while(!reader.atEnd() && !reader.hasError()) |
||
5653 | cbradney | 249 | { |
13710 | jghali | 250 | QXmlStreamReader::TokenType tType = reader.readNext(); |
251 | if (tType != QXmlStreamReader::StartElement) |
||
252 | continue; |
||
253 | QStringRef tagName = reader.name(); |
||
254 | attrs = reader.scAttributes(); |
||
255 | |||
256 | if (m_mwProgressBar != 0) |
||
5653 | cbradney | 257 | { |
17982 | jghali | 258 | int newProgress = qRound(ioDevice->pos() / (double) ioDevice->size() * 100); |
13710 | jghali | 259 | if (newProgress != progress) |
260 | { |
||
261 | m_mwProgressBar->setValue(reader.characterOffset()); |
||
262 | progress = newProgress; |
||
263 | } |
||
5653 | cbradney | 264 | } |
13710 | jghali | 265 | |
266 | if (firstElement) |
||
5653 | cbradney | 267 | { |
13710 | jghali | 268 | if (tagName != "SCRIBUSUTF8NEW") |
269 | { |
||
270 | success = false; |
||
271 | break; |
||
272 | } |
||
273 | firstElement = false; |
||
5653 | cbradney | 274 | } |
13710 | jghali | 275 | if (tagName == "DOCUMENT") |
5653 | cbradney | 276 | { |
13710 | jghali | 277 | readDocAttributes(m_Doc, attrs); |
278 | layerToSetActive = attrs.valueAsInt("ALAYER", 0); |
||
15407 | craig | 279 | if (m_Doc->pagePositioning() == 0) |
13710 | jghali | 280 | firstPage = 0; |
281 | else |
||
5653 | cbradney | 282 | { |
13710 | jghali | 283 | if (attrs.valueAsInt("FIRSTLEFT", 0) == 1) |
284 | firstPage = 0; |
||
285 | else |
||
286 | firstPage = 1; |
||
5653 | cbradney | 287 | } |
13710 | jghali | 288 | if (attrs.hasAttribute("currentProfile")) |
5653 | cbradney | 289 | { |
14971 | cbradney | 290 | m_Doc->clearCheckerProfiles(); |
291 | m_Doc->setCurCheckProfile(attrs.valueAsString("currentProfile")); |
||
5653 | cbradney | 292 | } |
13710 | jghali | 293 | } |
294 | if (tagName == "CheckProfile") |
||
295 | { |
||
296 | success = readCheckProfile(m_Doc, attrs); |
||
297 | if (!success) break; |
||
298 | } |
||
299 | if (tagName == "PageSets") |
||
300 | { |
||
301 | success = readPageSets(m_Doc, reader); |
||
302 | if (!success) break; |
||
303 | hasPageSets = true; |
||
304 | } |
||
305 | // 10/25/2004 pv - None is "reserved" color. cannot be defined in any file... |
||
306 | if (tagName == "COLOR" && attrs.valueAsString("NAME") != CommonStrings::None) |
||
307 | { |
||
308 | success = readColor(m_Doc->PageColors, attrs); |
||
309 | if (!success) break; |
||
310 | } |
||
311 | if (tagName == "STYLE") |
||
312 | { |
||
16531 | jghali | 313 | readParagraphStyle(m_Doc, reader, vg); |
13710 | jghali | 314 | StyleSet<ParagraphStyle>tmp; |
315 | tmp.create(vg); |
||
316 | m_Doc->redefineStyles(tmp, false); |
||
317 | } |
||
318 | if (tagName == "CHARSTYLE") |
||
319 | { |
||
16531 | jghali | 320 | CharStyle cstyle; |
16534 | jghali | 321 | ScXmlStreamAttributes attrs = reader.scAttributes(); |
322 | readNamedCharacterStyleAttrs(m_Doc, attrs, cstyle); |
||
13710 | jghali | 323 | StyleSet<CharStyle> temp; |
16531 | jghali | 324 | temp.create(cstyle); |
13710 | jghali | 325 | m_Doc->redefineCharStyles(temp, false); |
326 | } |
||
327 | if (tagName == "JAVA") |
||
328 | { |
||
329 | QString name = attrs.valueAsString("NAME"); |
||
330 | if (!name.isEmpty()) |
||
331 | m_Doc->JavaScripts[name] = attrs.valueAsString("SCRIPT"); |
||
332 | } |
||
333 | if (tagName == "LAYERS") |
||
334 | { |
||
335 | ScLayer newLayer; |
||
336 | readLayers(newLayer, attrs); |
||
337 | m_Doc->Layers.append(newLayer); |
||
338 | } |
||
339 | if (tagName == "Arrows") |
||
340 | { |
||
341 | success = readArrows(m_Doc, attrs); |
||
342 | if (!success) break; |
||
343 | } |
||
344 | if (tagName == "MultiLine") |
||
345 | { |
||
346 | multiLine ml; |
||
347 | QString mlName = attrs.valueAsString("Name"); |
||
348 | success = readMultiline(ml, reader); |
||
349 | if (!success) break; |
||
350 | if (!mlName.isEmpty()) |
||
5653 | cbradney | 351 | { |
13710 | jghali | 352 | m_Doc->MLineStyles.insert(mlName, ml); |
5653 | cbradney | 353 | } |
13710 | jghali | 354 | } |
355 | if (tagName == "Bookmark") |
||
356 | { |
||
13715 | jghali | 357 | int bmElem = 0; |
13710 | jghali | 358 | struct ScribusDoc::BookMa bookmark; |
13715 | jghali | 359 | success = readBookMark(bookmark, bmElem, attrs); |
13710 | jghali | 360 | if (!success) break; |
13715 | jghali | 361 | bookmarks.insert(bmElem, bookmark); |
13710 | jghali | 362 | } |
363 | if (tagName == "PDF") |
||
364 | { |
||
365 | success = readPDFOptions(m_Doc, reader); |
||
366 | if (!success) break; |
||
367 | } |
||
368 | if (tagName == "Printer") |
||
369 | { |
||
370 | success = readPrinterOptions(m_Doc, reader); |
||
371 | if (!success) break; |
||
372 | } |
||
373 | if (tagName == "DocItemAttributes") |
||
374 | { |
||
375 | success = readDocItemAttributes(m_Doc, reader); |
||
376 | if (!success) break; |
||
377 | } |
||
378 | if (tagName == "TablesOfContents") |
||
379 | { |
||
380 | success = readTableOfContents(m_Doc, reader); |
||
381 | if (!success) break; |
||
382 | } |
||
383 | if (tagName == "Sections") |
||
384 | { |
||
385 | success = readSections(m_Doc, reader); |
||
386 | if (!success) break; |
||
387 | } |
||
388 | if (tagName == "HYPHEN") |
||
389 | { |
||
390 | success = readHyphen(m_Doc, reader); |
||
391 | if (!success) break; |
||
392 | } |
||
393 | if (tagName == "PAGE" || tagName == "MASTERPAGE") |
||
394 | { |
||
395 | success = readPage(m_Doc, reader); |
||
396 | if (!success) break; |
||
397 | } |
||
398 | if (tagName == "PAGEOBJECT" || tagName == "MASTEROBJECT" || tagName == "FRAMEOBJECT") |
||
399 | { |
||
400 | ItemInfo itemInfo; |
||
401 | success = readObject(m_Doc, reader, itemInfo, fileDir, false); |
||
402 | if (!success) break; |
||
403 | |||
404 | // first of linked chain? |
||
405 | if (tagName == "PAGEOBJECT") |
||
5653 | cbradney | 406 | { |
13710 | jghali | 407 | if (itemInfo.nextItem != -1) |
17532 | jghali | 408 | itemNext[itemInfo.ownNr] = itemInfo.nextItem; |
5653 | cbradney | 409 | } |
13710 | jghali | 410 | else if (tagName == "MASTEROBJECT") |
7000 | avox | 411 | { |
13710 | jghali | 412 | if (itemInfo.nextItem != -1) |
17532 | jghali | 413 | itemNextM[itemInfo.ownNr] = itemInfo.nextItem; |
7000 | avox | 414 | } |
13710 | jghali | 415 | /* not sure if we want that... |
416 | else if (tagName == "FRAMEOBJECT") |
||
5653 | cbradney | 417 | { |
13710 | jghali | 418 | if (itemInfo.nextItem != -1) |
419 | itemNextF[itemInfo.item->ItemNr] = itemInfo.nextItem; |
||
420 | }*/ |
||
421 | |||
422 | if (itemInfo.item->isTableItem) |
||
5653 | cbradney | 423 | { |
13710 | jghali | 424 | if (tagName == "PAGEOBJECT") |
5653 | cbradney | 425 | { |
13710 | jghali | 426 | TableItems.append(itemInfo.item); |
16943 | fschmid | 427 | TableID.insert(itemInfo.ownLink, itemInfo.item); |
5653 | cbradney | 428 | } |
13710 | jghali | 429 | else if (tagName == "FRAMEOBJECT") |
5653 | cbradney | 430 | { |
13710 | jghali | 431 | TableItemsF.append(itemInfo.item); |
16943 | fschmid | 432 | TableIDF.insert(itemInfo.ownLink, itemInfo.item); |
5653 | cbradney | 433 | } |
10947 | jghali | 434 | else |
7104 | fschmid | 435 | { |
13710 | jghali | 436 | TableItemsM.append(itemInfo.item); |
16943 | fschmid | 437 | TableIDM.insert(itemInfo.ownLink, itemInfo.item); |
7104 | fschmid | 438 | } |
439 | } |
||
16105 | fschmid | 440 | if (groupStack.count() > 0) |
5653 | cbradney | 441 | { |
16105 | fschmid | 442 | groupStack.top().append(itemInfo.item); |
16943 | fschmid | 443 | while (static_cast<int>(itemInfo.ownNr) == groupStack2.top()) |
16105 | fschmid | 444 | { |
445 | if (tagName == "PAGEOBJECT") |
||
446 | groupStackP.push(groupStack.pop()); |
||
447 | else if (tagName == "FRAMEOBJECT") |
||
448 | groupStackF.push(groupStack.pop()); |
||
449 | else |
||
450 | groupStackM.push(groupStack.pop()); |
||
451 | groupStack2.pop(); |
||
16233 | fschmid | 452 | if (groupStack2.count() == 0) |
453 | break; |
||
16105 | fschmid | 454 | } |
455 | } |
||
16113 | fschmid | 456 | if (itemInfo.isGroupFlag) |
16105 | fschmid | 457 | { |
458 | QList<PageItem*> GroupItems; |
||
459 | GroupItems.append(itemInfo.item); |
||
460 | groupStack.push(GroupItems); |
||
16943 | fschmid | 461 | groupStack2.push(itemInfo.groupLastItem + itemInfo.ownNr); |
16105 | fschmid | 462 | } |
13710 | jghali | 463 | } |
464 | if (tagName == "Pattern") |
||
465 | { |
||
466 | success = readPattern(m_Doc, reader, fileDir); |
||
467 | if (!success) break; |
||
468 | } |
||
469 | } |
||
5653 | cbradney | 470 | |
13710 | jghali | 471 | if (reader.hasError()) |
14392 | jghali | 472 | { |
473 | setDomParsingError(reader.errorString(), reader.lineNumber(), reader.columnNumber()); |
||
13710 | jghali | 474 | return false; |
14392 | jghali | 475 | } |
7994 | avox | 476 | |
13715 | jghali | 477 | QMap<int, ScribusDoc::BookMa>::Iterator it; |
478 | for (it = bookmarks.begin(); it != bookmarks.end(); ++it) |
||
13710 | jghali | 479 | { |
13715 | jghali | 480 | int elem = it.key(); |
13710 | jghali | 481 | if (elem < m_Doc->Items->count()) |
5653 | cbradney | 482 | { |
13715 | jghali | 483 | ScribusDoc::BookMa bookmark = it.value(); |
484 | bookmark.PageObject = m_Doc->Items->at(elem); |
||
485 | m_Doc->BookMarks.append( bookmark ); |
||
5653 | cbradney | 486 | } |
487 | } |
||
13710 | jghali | 488 | |
7450 | fschmid | 489 | if (TableItemsF.count() != 0) |
490 | { |
||
9856 | fschmid | 491 | for (int ttc = 0; ttc < TableItemsF.count(); ++ttc) |
7450 | fschmid | 492 | { |
493 | PageItem* ta = TableItemsF.at(ttc); |
||
494 | if (ta->TopLinkID != -1) |
||
16943 | fschmid | 495 | ta->TopLink = TableIDF[ta->TopLinkID]; |
7450 | fschmid | 496 | else |
497 | ta->TopLink = 0; |
||
498 | if (ta->LeftLinkID != -1) |
||
16943 | fschmid | 499 | ta->LeftLink = TableIDF[ta->LeftLinkID]; |
7450 | fschmid | 500 | else |
501 | ta->LeftLink = 0; |
||
502 | if (ta->RightLinkID != -1) |
||
16943 | fschmid | 503 | ta->RightLink = TableIDF[ta->RightLinkID]; |
7450 | fschmid | 504 | else |
505 | ta->RightLink = 0; |
||
506 | if (ta->BottomLinkID != -1) |
||
16943 | fschmid | 507 | ta->BottomLink = TableIDF[ta->BottomLinkID]; |
7450 | fschmid | 508 | else |
509 | ta->BottomLink = 0; |
||
510 | } |
||
511 | } |
||
512 | if (TableItemsM.count() != 0) |
||
513 | { |
||
9856 | fschmid | 514 | for (int ttc = 0; ttc < TableItemsM.count(); ++ttc) |
7450 | fschmid | 515 | { |
516 | PageItem* ta = TableItemsM.at(ttc); |
||
517 | if (ta->TopLinkID != -1) |
||
16943 | fschmid | 518 | ta->TopLink = TableIDM[ta->TopLinkID]; |
7450 | fschmid | 519 | else |
520 | ta->TopLink = 0; |
||
521 | if (ta->LeftLinkID != -1) |
||
16943 | fschmid | 522 | ta->LeftLink = TableIDM[ta->LeftLinkID]; |
7450 | fschmid | 523 | else |
524 | ta->LeftLink = 0; |
||
525 | if (ta->RightLinkID != -1) |
||
16943 | fschmid | 526 | ta->RightLink = TableIDM[ta->RightLinkID]; |
7450 | fschmid | 527 | else |
528 | ta->RightLink = 0; |
||
529 | if (ta->BottomLinkID != -1) |
||
16943 | fschmid | 530 | ta->BottomLink = TableIDM[ta->BottomLinkID]; |
7450 | fschmid | 531 | else |
532 | ta->BottomLink = 0; |
||
533 | } |
||
534 | } |
||
5653 | cbradney | 535 | if (TableItems.count() != 0) |
536 | { |
||
9856 | fschmid | 537 | for (int ttc = 0; ttc < TableItems.count(); ++ttc) |
5653 | cbradney | 538 | { |
539 | PageItem* ta = TableItems.at(ttc); |
||
540 | if (ta->TopLinkID != -1) |
||
16943 | fschmid | 541 | ta->TopLink = TableID[ta->TopLinkID]; |
5653 | cbradney | 542 | else |
543 | ta->TopLink = 0; |
||
544 | if (ta->LeftLinkID != -1) |
||
16943 | fschmid | 545 | ta->LeftLink = TableID[ta->LeftLinkID]; |
5653 | cbradney | 546 | else |
547 | ta->LeftLink = 0; |
||
548 | if (ta->RightLinkID != -1) |
||
16943 | fschmid | 549 | ta->RightLink = TableID[ta->RightLinkID]; |
5653 | cbradney | 550 | else |
551 | ta->RightLink = 0; |
||
552 | if (ta->BottomLinkID != -1) |
||
16943 | fschmid | 553 | ta->BottomLink = TableID[ta->BottomLinkID]; |
5653 | cbradney | 554 | else |
555 | ta->BottomLink = 0; |
||
556 | } |
||
557 | } |
||
13710 | jghali | 558 | //CB Add this in to set this in the file in memory. Its saved, why not load it. |
559 | //Will of course be replaced by per page settings although we still probably need a document default |
||
560 | if (!hasPageSets) |
||
561 | { |
||
15407 | craig | 562 | m_Doc->setPageSetFirstPage(m_Doc->pagePositioning(), firstPage); |
13710 | jghali | 563 | } |
13873 | jghali | 564 | |
5653 | cbradney | 565 | m_Doc->setMasterPageMode(false); |
566 | m_Doc->reformPages(); |
||
17338 | jghali | 567 | m_Doc->refreshGuides(); |
5653 | cbradney | 568 | |
16697 | jghali | 569 | // #9969 : Some old long doc may have page owner somewhat broken |
570 | m_Doc->fixItemPageOwner(); |
||
571 | |||
13873 | jghali | 572 | handleOldLayerBehavior(m_Doc); |
5653 | cbradney | 573 | if (m_Doc->Layers.count() == 0) |
13873 | jghali | 574 | { |
575 | ScLayer* nl = m_Doc->Layers.newLayer( QObject::tr("Background") ); |
||
576 | nl->flowControl = false; |
||
13875 | jghali | 577 | layerToSetActive = nl->ID; |
13873 | jghali | 578 | } |
579 | m_Doc->setActiveLayer(layerToSetActive); |
||
18394 | fschmid | 580 | if (!EffVal.isEmpty()) |
581 | { |
||
582 | for (int pdoE = 0; pdoE < EffVal.count(); ++pdoE) |
||
583 | { |
||
584 | if (pdoE < m_Doc->Pages->count()) |
||
585 | m_Doc->Pages->at(pdoE)->PresentVals = EffVal[pdoE]; |
||
586 | } |
||
587 | } |
||
7994 | avox | 588 | |
589 | // reestablish textframe links |
||
590 | if (itemNext.count() != 0) |
||
5653 | cbradney | 591 | { |
7994 | avox | 592 | QMap<int,int>::Iterator lc; |
593 | for (lc = itemNext.begin(); lc != itemNext.end(); ++lc) |
||
5653 | cbradney | 594 | { |
10427 | cbradney | 595 | if (lc.value() >= 0) |
5653 | cbradney | 596 | { |
7994 | avox | 597 | PageItem * Its = m_Doc->DocItems.at(lc.key()); |
10427 | cbradney | 598 | PageItem * Itn = m_Doc->DocItems.at(lc.value()); |
16589 | jghali | 599 | if (!Its->testLinkCandidate(Itn)) |
7994 | avox | 600 | { |
13085 | jghali | 601 | qDebug() << "scribus134format: corruption in linked textframes detected"; |
7994 | avox | 602 | continue; |
603 | } |
||
604 | Its->link(Itn); |
||
5653 | cbradney | 605 | } |
606 | } |
||
607 | } |
||
7994 | avox | 608 | |
609 | if (itemNextM.count() != 0) |
||
7805 | fschmid | 610 | { |
7994 | avox | 611 | QMap<int,int>::Iterator lc; |
612 | for (lc = itemNextM.begin(); lc != itemNextM.end(); ++lc) |
||
7805 | fschmid | 613 | { |
10427 | cbradney | 614 | if (lc.value() >= 0) |
7805 | fschmid | 615 | { |
7994 | avox | 616 | PageItem * Its = m_Doc->MasterItems.at(lc.key()); |
10427 | cbradney | 617 | PageItem * Itn = m_Doc->MasterItems.at(lc.value()); |
16589 | jghali | 618 | if (!Its->testLinkCandidate(Itn)) |
7994 | avox | 619 | { |
13085 | jghali | 620 | qDebug() << "scribus134format: corruption in linked textframes detected"; |
7994 | avox | 621 | continue; |
622 | } |
||
623 | Its->link(Itn); |
||
7805 | fschmid | 624 | } |
625 | } |
||
626 | } |
||
16105 | fschmid | 627 | if (groupStackP.count() > 0) |
628 | { |
||
629 | while (groupStackP.count() > 0) |
||
630 | { |
||
17417 | fschmid | 631 | bool isTableIt = false; |
16105 | fschmid | 632 | QList<PageItem*> gpL = groupStackP.pop(); |
633 | PageItem* gItem = gpL.takeFirst(); |
||
634 | for (int id = 0; id < gpL.count(); id++) |
||
635 | { |
||
636 | PageItem* cItem = gpL.at(id); |
||
17417 | fschmid | 637 | isTableIt = cItem->isTableItem; |
16105 | fschmid | 638 | cItem->gXpos = cItem->xPos() - gItem->xPos(); |
639 | cItem->gYpos = cItem->yPos() - gItem->yPos(); |
||
16943 | fschmid | 640 | cItem->Parent = gItem; |
16105 | fschmid | 641 | if (gItem->rotation() != 0) |
642 | { |
||
643 | QTransform ma; |
||
644 | ma.rotate(-gItem->rotation()); |
||
645 | FPoint n = FPoint(cItem->gXpos, cItem->gYpos); |
||
646 | cItem->gXpos = ma.m11() * n.x() + ma.m21() * n.y() + ma.dx(); |
||
647 | cItem->gYpos = ma.m22() * n.y() + ma.m12() * n.x() + ma.dy(); |
||
648 | cItem->setRotation(cItem->rotation() - gItem->rotation()); |
||
649 | } |
||
650 | m_Doc->DocItems.removeOne(cItem); |
||
651 | } |
||
18282 | jghali | 652 | bool converted = false; |
17417 | fschmid | 653 | if (isTableIt) |
18282 | jghali | 654 | converted = convertOldTable(m_Doc, gItem, gpL, &groupStackP, &m_Doc->DocItems); |
655 | if (!converted) |
||
17417 | fschmid | 656 | gItem->groupItemList = gpL; |
16105 | fschmid | 657 | } |
658 | } |
||
659 | if (groupStackF.count() > 0) |
||
660 | { |
||
661 | while (groupStackF.count() > 0) |
||
662 | { |
||
17417 | fschmid | 663 | bool isTableIt = false; |
16105 | fschmid | 664 | QList<PageItem*> gpL = groupStackF.pop(); |
665 | PageItem* gItem = gpL.takeFirst(); |
||
666 | for (int id = 0; id < gpL.count(); id++) |
||
667 | { |
||
668 | PageItem* cItem = gpL.at(id); |
||
17417 | fschmid | 669 | isTableIt = cItem->isTableItem; |
16105 | fschmid | 670 | cItem->gXpos = cItem->xPos() - gItem->xPos(); |
671 | cItem->gYpos = cItem->yPos() - gItem->yPos(); |
||
16943 | fschmid | 672 | cItem->Parent = gItem; |
16105 | fschmid | 673 | if (gItem->rotation() != 0) |
674 | { |
||
675 | QTransform ma; |
||
676 | ma.rotate(-gItem->rotation()); |
||
677 | FPoint n = FPoint(cItem->gXpos, cItem->gYpos); |
||
678 | cItem->gXpos = ma.m11() * n.x() + ma.m21() * n.y() + ma.dx(); |
||
679 | cItem->gYpos = ma.m22() * n.y() + ma.m12() * n.x() + ma.dy(); |
||
680 | cItem->setRotation(cItem->rotation() - gItem->rotation()); |
||
681 | } |
||
17407 | fschmid | 682 | m_Doc->FrameItems.remove(m_Doc->FrameItems.key(cItem)); |
16105 | fschmid | 683 | } |
18282 | jghali | 684 | bool converted = false; |
17417 | fschmid | 685 | if (isTableIt) |
18282 | jghali | 686 | converted = convertOldTable(m_Doc, gItem, gpL, &groupStackF, NULL); |
687 | if (!converted) |
||
17417 | fschmid | 688 | gItem->groupItemList = gpL; |
16105 | fschmid | 689 | } |
690 | } |
||
691 | if (groupStackM.count() > 0) |
||
692 | { |
||
693 | while (groupStackM.count() > 0) |
||
694 | { |
||
17417 | fschmid | 695 | bool isTableIt = false; |
16105 | fschmid | 696 | QList<PageItem*> gpL = groupStackM.pop(); |
697 | PageItem* gItem = gpL.takeFirst(); |
||
698 | for (int id = 0; id < gpL.count(); id++) |
||
699 | { |
||
700 | PageItem* cItem = gpL.at(id); |
||
17417 | fschmid | 701 | isTableIt = cItem->isTableItem; |
16105 | fschmid | 702 | cItem->gXpos = cItem->xPos() - gItem->xPos(); |
703 | cItem->gYpos = cItem->yPos() - gItem->yPos(); |
||
16943 | fschmid | 704 | cItem->Parent = gItem; |
16105 | fschmid | 705 | if (gItem->rotation() != 0) |
706 | { |
||
707 | QTransform ma; |
||
708 | ma.rotate(-gItem->rotation()); |
||
709 | FPoint n = FPoint(cItem->gXpos, cItem->gYpos); |
||
710 | cItem->gXpos = ma.m11() * n.x() + ma.m21() * n.y() + ma.dx(); |
||
711 | cItem->gYpos = ma.m22() * n.y() + ma.m12() * n.x() + ma.dy(); |
||
712 | cItem->setRotation(cItem->rotation() - gItem->rotation()); |
||
713 | } |
||
714 | m_Doc->MasterItems.removeOne(cItem); |
||
715 | } |
||
18282 | jghali | 716 | bool converted = false; |
17417 | fschmid | 717 | if (isTableIt) |
18282 | jghali | 718 | converted = convertOldTable(m_Doc, gItem, gpL, &groupStackM, &m_Doc->MasterItems); |
719 | if (!converted) |
||
17417 | fschmid | 720 | gItem->groupItemList = gpL; |
16105 | fschmid | 721 | } |
722 | } |
||
7994 | avox | 723 | |
724 | // reestablish first/lastAuto |
||
725 | m_Doc->FirstAuto = m_Doc->LastAuto; |
||
726 | if (m_Doc->LastAuto) |
||
727 | { |
||
728 | while (m_Doc->LastAuto->nextInChain()) |
||
729 | m_Doc->LastAuto = m_Doc->LastAuto->nextInChain(); |
||
730 | while (m_Doc->FirstAuto->prevInChain()) |
||
731 | m_Doc->FirstAuto = m_Doc->FirstAuto->prevInChain(); |
||
732 | } |
||
13518 | jghali | 733 | |
734 | // start auto save timer if needed |
||
14925 | cbradney | 735 | if (m_Doc->autoSave() && ScCore->usingGUI()) |
17797 | fschmid | 736 | m_Doc->restartAutoSaveTimer(); |
737 | // m_Doc->autoSaveTimer->start(m_Doc->autoSaveTime()); |
||
7994 | avox | 738 | |
5653 | cbradney | 739 | if (m_mwProgressBar!=0) |
13710 | jghali | 740 | m_mwProgressBar->setValue(reader.characterOffset()); |
5653 | cbradney | 741 | return true; |
742 | // return false; |
||
743 | } |
||
744 | |||
745 | // Low level plugin API |
||
746 | int scribus134format_getPluginAPIVersion() |
||
747 | { |
||
748 | return PLUGIN_API_VERSION; |
||
749 | } |
||
750 | |||
751 | ScPlugin* scribus134format_getPlugin() |
||
752 | { |
||
753 | Scribus134Format* plug = new Scribus134Format(); |
||
754 | Q_CHECK_PTR(plug); |
||
755 | return plug; |
||
756 | } |
||
757 | |||
758 | void scribus134format_freePlugin(ScPlugin* plugin) |
||
759 | { |
||
760 | Scribus134Format* plug = dynamic_cast<Scribus134Format*>(plugin); |
||
761 | Q_ASSERT(plug); |
||
762 | delete plug; |
||
763 | } |
||
764 | |||
765 | |||
6733 | avox | 766 | namespace { |
7000 | avox | 767 | const int NOVALUE = -16000; |
6733 | avox | 768 | |
769 | void fixLegacyCharStyle(CharStyle& cstyle) |
||
770 | { |
||
771 | if (! cstyle.font().usable()) |
||
772 | cstyle.resetFont(); |
||
773 | if (cstyle.fontSize() <= -16000 / 10) |
||
774 | cstyle.resetFontSize(); |
||
9607 | avox | 775 | // if (cstyle.effects() == 65535) |
776 | // cstyle.resetEffects(); |
||
6733 | avox | 777 | if (cstyle.fillColor().isEmpty()) |
778 | cstyle.resetFillColor(); |
||
779 | if (cstyle.fillShade() <= -16000) |
||
780 | cstyle.resetFillShade(); |
||
781 | if (cstyle.strokeColor().isEmpty()) |
||
782 | cstyle.resetStrokeColor(); |
||
783 | if (cstyle.strokeShade() <= -16000) |
||
784 | cstyle.resetStrokeShade(); |
||
785 | if (cstyle.shadowXOffset() <= -16000 / 10) |
||
786 | cstyle.resetShadowXOffset(); |
||
787 | if (cstyle.shadowYOffset() <= -16000 / 10) |
||
788 | cstyle.resetShadowYOffset(); |
||
789 | if (cstyle.outlineWidth() <= -16000 / 10) |
||
790 | cstyle.resetOutlineWidth(); |
||
791 | if (cstyle.underlineOffset() <= -16000 / 10) |
||
792 | cstyle.resetUnderlineOffset(); |
||
793 | if (cstyle.underlineWidth() <= -16000 / 10) |
||
794 | cstyle.resetUnderlineWidth(); |
||
795 | if (cstyle.strikethruOffset() <= -16000 / 10) |
||
796 | cstyle.resetStrikethruOffset(); |
||
797 | if (cstyle.strikethruWidth() <= -16000 / 10) |
||
798 | cstyle.resetStrikethruWidth(); |
||
799 | if (cstyle.scaleH() <= -16000 / 10) |
||
800 | cstyle.resetScaleH(); |
||
801 | if (cstyle.scaleV() <= -16000 / 10) |
||
802 | cstyle.resetScaleV(); |
||
803 | if (cstyle.baselineOffset() <= -16000 / 10) |
||
804 | cstyle.resetBaselineOffset(); |
||
805 | if (cstyle.tracking() <= -16000 / 10) |
||
806 | cstyle.resetTracking(); |
||
807 | } |
||
808 | |||
809 | void fixLegacyParStyle(ParagraphStyle& pstyle) |
||
810 | { |
||
7000 | avox | 811 | if (pstyle.lineSpacing() <= -16000) |
812 | pstyle.resetLineSpacing(); |
||
6733 | avox | 813 | if (pstyle.leftMargin() <= -16000) |
814 | pstyle.resetLeftMargin(); |
||
815 | if (pstyle.rightMargin() <= -16000) |
||
816 | pstyle.resetRightMargin(); |
||
817 | if (pstyle.firstIndent() <= -16000) |
||
818 | pstyle.resetFirstIndent(); |
||
819 | if (pstyle.alignment() < 0) |
||
820 | pstyle.resetAlignment(); |
||
821 | if (pstyle.gapBefore() <= -16000) |
||
822 | pstyle.resetGapBefore(); |
||
823 | if (pstyle.gapAfter() <= -16000) |
||
824 | pstyle.resetGapAfter(); |
||
825 | if (pstyle.dropCapLines() < 0) |
||
826 | pstyle.resetDropCapLines(); |
||
18047 | craig | 827 | if (pstyle.parEffectOffset() <= -16000) |
828 | pstyle.resetParEffectOffset(); |
||
6733 | avox | 829 | fixLegacyCharStyle(pstyle.charStyle()); |
830 | } |
||
831 | |||
832 | }// namespace |
||
833 | |||
13710 | jghali | 834 | void Scribus134Format::readDocAttributes(ScribusDoc* doc, ScXmlStreamAttributes& attrs) |
835 | { |
||
14991 | cbradney | 836 | m_Doc->setPageSize(attrs.valueAsString("PAGESIZE")); |
837 | m_Doc->setPageOrientation(attrs.valueAsInt("ORIENTATION", 0)); |
||
13710 | jghali | 838 | m_Doc->FirstPnum = attrs.valueAsInt("FIRSTNUM", 1); |
15407 | craig | 839 | m_Doc->setPagePositioning(attrs.valueAsInt("BOOK", 0)); |
6733 | avox | 840 | |
13710 | jghali | 841 | m_Doc->setUsesAutomaticTextFrames( attrs.valueAsInt("AUTOTEXT") ); |
842 | m_Doc->PageSp = attrs.valueAsInt("AUTOSPALTEN"); |
||
843 | m_Doc->PageSpa = attrs.valueAsDouble("ABSTSPALTEN"); |
||
844 | m_Doc->setUnitIndex( attrs.valueAsInt("UNITS", 0) ); |
||
845 | |||
14924 | cbradney | 846 | m_Doc->setHyphLanguage(attrs.valueAsString("LANGUAGE", "")); |
847 | m_Doc->setHyphMinimumWordLength(attrs.valueAsInt("MINWORDLEN", 3)); |
||
848 | m_Doc->setHyphConsecutiveLines(attrs.valueAsInt("HYCOUNT", 2)); |
||
13710 | jghali | 849 | |
850 | if (attrs.hasAttribute("PAGEWIDTH")) |
||
14991 | cbradney | 851 | m_Doc->setPageWidth(attrs.valueAsDouble("PAGEWIDTH")); |
13710 | jghali | 852 | else |
14991 | cbradney | 853 | m_Doc->setPageWidth(attrs.valueAsDouble("PAGEWITH")); |
854 | m_Doc->setPageHeight(attrs.valueAsDouble("PAGEHEIGHT")); |
||
14994 | cbradney | 855 | m_Doc->margins()->Left = qMax(0.0, attrs.valueAsDouble("BORDERLEFT")); |
856 | m_Doc->margins()->Right = qMax(0.0, attrs.valueAsDouble("BORDERRIGHT")); |
||
857 | m_Doc->margins()->Top = qMax(0.0, attrs.valueAsDouble("BORDERTOP")); |
||
858 | m_Doc->margins()->Bottom= qMax(0.0, attrs.valueAsDouble("BORDERBOTTOM")); |
||
14992 | cbradney | 859 | m_Doc->setMarginPreset(attrs.valueAsInt("PRESET", 0)); |
860 | m_Doc->bleeds()->Top = attrs.valueAsDouble("BleedTop", 0.0); |
||
861 | m_Doc->bleeds()->Left = attrs.valueAsDouble("BleedLeft", 0.0); |
||
862 | m_Doc->bleeds()->Right = attrs.valueAsDouble("BleedRight", 0.0); |
||
863 | m_Doc->bleeds()->Bottom = attrs.valueAsDouble("BleedBottom", 0.0); |
||
14924 | cbradney | 864 | m_Doc->setHyphAutomatic(attrs.valueAsBool("AUTOMATIC", true)); |
865 | m_Doc->setHyphAutoCheck(attrs.valueAsBool("AUTOCHECK", false)); |
||
13710 | jghali | 866 | m_Doc->GuideLock = attrs.valueAsBool("GUIDELOCK", false); |
867 | |||
868 | m_Doc->rulerXoffset = attrs.valueAsDouble("rulerXoffset", 0.0); |
||
869 | m_Doc->rulerYoffset = attrs.valueAsDouble("rulerYoffset", 0.0); |
||
870 | m_Doc->SnapGuides = attrs.valueAsBool("SnapToGuides", false); |
||
18027 | jghali | 871 | m_Doc->SnapGrid = attrs.valueAsBool("SnapToGrid", false); |
13710 | jghali | 872 | |
14925 | cbradney | 873 | m_Doc->setAutoSave(attrs.valueAsBool("AutoSave", false)); |
874 | m_Doc->setAutoSaveTime(attrs.valueAsInt("AutoSaveTime", 600000)); |
||
14924 | cbradney | 875 | |
876 | double leftScratch; |
||
13710 | jghali | 877 | // FIXME A typo in early 1.3cvs (MAR 05) means we must support loading of |
878 | // FIXME 'ScatchLeft' for a while too. This can be removed in a few months. |
||
879 | if (attrs.hasAttribute("ScatchLeft")) |
||
14924 | cbradney | 880 | leftScratch = attrs.valueAsDouble("ScatchLeft", 100.0); |
13710 | jghali | 881 | else |
14924 | cbradney | 882 | leftScratch = attrs.valueAsDouble("ScratchLeft", 100.0); |
883 | m_Doc->scratch()->set(attrs.valueAsDouble("ScratchTop", 20.0), leftScratch, |
||
884 | attrs.valueAsDouble("ScratchBottom", 20.0),attrs.valueAsDouble("ScratchRight", 100.0)); |
||
885 | m_Doc->setPageGapHorizontal(attrs.valueAsDouble("GapHorizontal", -1.0)); |
||
886 | m_Doc->setPageGapVertical(attrs.valueAsDouble("GapVertical", -1.0)); |
||
13710 | jghali | 887 | |
888 | if (attrs.hasAttribute("PAGEC")) |
||
14924 | cbradney | 889 | m_Doc->setPaperColor(QColor(attrs.valueAsString("PAGEC"))); |
13710 | jghali | 890 | |
14971 | cbradney | 891 | m_Doc->setMarginColored(attrs.valueAsBool("RANDF", false)); |
13710 | jghali | 892 | |
893 | readCMSSettings(doc, attrs); |
||
894 | readDocumentInfo(doc, attrs); |
||
895 | readGuideSettings(doc, attrs); |
||
896 | readToolSettings(doc, attrs); |
||
897 | readTypographicSettings(doc, attrs); |
||
898 | } |
||
899 | |||
900 | void Scribus134Format::readCMSSettings(ScribusDoc* doc, ScXmlStreamAttributes& attrs) |
||
6864 | avox | 901 | { |
15001 | cbradney | 902 | doc->cmsSettings().SoftProofOn = attrs.valueAsBool("DPSo", false); |
903 | doc->cmsSettings().SoftProofFullOn = attrs.valueAsBool("DPSFo", false); |
||
904 | doc->cmsSettings().CMSinUse = attrs.valueAsBool("DPuse", false); |
||
905 | doc->cmsSettings().GamutCheck = attrs.valueAsBool("DPgam", false); |
||
906 | doc->cmsSettings().BlackPoint = attrs.valueAsBool("DPbla", true); |
||
907 | doc->cmsSettings().DefaultMonitorProfile = attrs.valueAsString("DPMo",""); |
||
908 | doc->cmsSettings().DefaultPrinterProfile = attrs.valueAsString("DPPr",""); |
||
909 | doc->cmsSettings().DefaultImageRGBProfile = attrs.valueAsString("DPIn",""); |
||
910 | doc->cmsSettings().DefaultImageCMYKProfile = attrs.valueAsString("DPInCMYK",""); |
||
911 | doc->cmsSettings().DefaultSolidColorRGBProfile = attrs.valueAsString("DPIn2",""); |
||
13710 | jghali | 912 | if (attrs.hasAttribute("DPIn3")) |
15001 | cbradney | 913 | doc->cmsSettings().DefaultSolidColorCMYKProfile = attrs.valueAsString("DPIn3",""); |
13710 | jghali | 914 | else |
15001 | cbradney | 915 | doc->cmsSettings().DefaultSolidColorCMYKProfile = attrs.valueAsString("DPPr",""); |
916 | doc->cmsSettings().DefaultIntentColors = (eRenderIntent) attrs.valueAsInt("DISc", 1); |
||
917 | doc->cmsSettings().DefaultIntentImages = (eRenderIntent) attrs.valueAsInt("DIIm", 0); |
||
13710 | jghali | 918 | } |
919 | |||
920 | void Scribus134Format::readDocumentInfo(ScribusDoc* doc, ScXmlStreamAttributes& attrs) |
||
921 | { |
||
15037 | cbradney | 922 | DocumentInformation di; |
923 | di.setAuthor(attrs.valueAsString("AUTHOR")); |
||
924 | di.setComments(attrs.valueAsString("COMMENTS")); |
||
925 | di.setKeywords(attrs.valueAsString("KEYWORDS","")); |
||
926 | di.setTitle(attrs.valueAsString("TITLE")); |
||
927 | di.setSubject(attrs.valueAsString("SUBJECT")); |
||
928 | di.setPublisher(attrs.valueAsString("PUBLISHER", "")); |
||
929 | di.setDate(attrs.valueAsString("DOCDATE", "")); |
||
930 | di.setType(attrs.valueAsString("DOCTYPE", "")); |
||
931 | di.setFormat(attrs.valueAsString("DOCFORMAT", "")); |
||
932 | di.setIdent(attrs.valueAsString("DOCIDENT", "")); |
||
933 | di.setSource(attrs.valueAsString("DOCSOURCE", "")); |
||
934 | di.setLangInfo(attrs.valueAsString("DOCLANGINFO", "")); |
||
935 | di.setRelation(attrs.valueAsString("DOCRELATION", "")); |
||
936 | di.setCover(attrs.valueAsString("DOCCOVER", "")); |
||
937 | di.setRights(attrs.valueAsString("DOCRIGHTS", "")); |
||
938 | di.setContrib(attrs.valueAsString("DOCCONTRIB", "")); |
||
939 | doc->setDocumentInfo(di); |
||
13710 | jghali | 940 | } |
941 | |||
942 | void Scribus134Format::readGuideSettings(ScribusDoc* doc, ScXmlStreamAttributes& attrs) |
||
943 | { |
||
944 | PrefsManager* prefsManager = PrefsManager::instance(); |
||
14932 | cbradney | 945 | doc->guidesPrefs().minorGridSpacing = attrs.valueAsDouble("MINGRID", prefsManager->appPrefs.guidesPrefs.minorGridSpacing); |
946 | doc->guidesPrefs().majorGridSpacing = attrs.valueAsDouble("MAJGRID", prefsManager->appPrefs.guidesPrefs.majorGridSpacing); |
||
947 | doc->guidesPrefs().gridShown = attrs.valueAsBool("SHOWGRID", false); |
||
948 | doc->guidesPrefs().guidesShown =attrs.valueAsBool("SHOWGUIDES", true); |
||
949 | doc->guidesPrefs().colBordersShown = attrs.valueAsBool("showcolborders", false); |
||
950 | doc->guidesPrefs().framesShown = attrs.valueAsBool("SHOWFRAME", true); |
||
951 | doc->guidesPrefs().layerMarkersShown = attrs.valueAsBool("SHOWLAYERM", false); |
||
952 | doc->guidesPrefs().marginsShown = attrs.valueAsBool("SHOWMARGIN", true); |
||
953 | doc->guidesPrefs().baselineGridShown = attrs.valueAsBool("SHOWBASE", false); |
||
954 | doc->guidesPrefs().showPic = attrs.valueAsBool("SHOWPICT", true); |
||
955 | doc->guidesPrefs().linkShown = attrs.valueAsBool("SHOWLINK", false); |
||
956 | doc->guidesPrefs().showControls = attrs.valueAsBool("SHOWControl", false); |
||
957 | doc->guidesPrefs().rulerMode = attrs.valueAsBool("rulerMode", true); |
||
958 | doc->guidesPrefs().rulersShown = attrs.valueAsBool("showrulers", true); |
||
959 | doc->guidesPrefs().showBleed = attrs.valueAsBool("showBleed", true); |
||
13710 | jghali | 960 | if (attrs.hasAttribute("MARGC")) |
14932 | cbradney | 961 | doc->guidesPrefs().marginColor = QColor(attrs.valueAsString("MARGC")); |
13710 | jghali | 962 | if (attrs.hasAttribute("MINORC")) |
14932 | cbradney | 963 | doc->guidesPrefs().minorGridColor = QColor(attrs.valueAsString("MINORC")); |
13710 | jghali | 964 | if (attrs.hasAttribute("MAJORC")) |
14932 | cbradney | 965 | doc->guidesPrefs().majorGridColor = QColor(attrs.valueAsString("MAJORC")); |
13710 | jghali | 966 | if (attrs.hasAttribute("GuideC")) |
14932 | cbradney | 967 | doc->guidesPrefs().guideColor = QColor(attrs.valueAsString("GuideC")); |
13710 | jghali | 968 | if (attrs.hasAttribute("BaseC")) |
14932 | cbradney | 969 | doc->guidesPrefs().baselineGridColor = QColor(attrs.valueAsString("BaseC")); |
16990 | fschmid | 970 | doc->guidesPrefs().renderStackOrder.clear(); |
971 | if (attrs.valueAsBool("BACKG", true)) |
||
972 | doc->guidesPrefs().renderStackOrder << 0 << 1 << 2 << 3 << 4; |
||
973 | else |
||
974 | doc->guidesPrefs().renderStackOrder << 4 << 0 << 1 << 2 << 3; |
||
16992 | fschmid | 975 | doc->guidesPrefs().gridType = 0; |
14932 | cbradney | 976 | doc->guidesPrefs().guideRad = attrs.valueAsDouble("GuideRad", 10.0); |
977 | doc->guidesPrefs().grabRadius = attrs.valueAsInt("GRAB", 4); |
||
13710 | jghali | 978 | } |
979 | |||
980 | void Scribus134Format::readToolSettings(ScribusDoc* doc, ScXmlStreamAttributes& attrs) |
||
981 | { |
||
13996 | cbradney | 982 | QString textFont = attrs.valueAsString("DFONT"); |
983 | m_AvailableFonts->findFont(textFont, doc); |
||
13710 | jghali | 984 | |
14932 | cbradney | 985 | doc->itemToolPrefs().textFont = textFont; |
986 | doc->itemToolPrefs().textSize = qRound(attrs.valueAsDouble("DSIZE", 12.0) * 10); |
||
987 | doc->itemToolPrefs().textColumns = attrs.valueAsInt("DCOL", 1); |
||
988 | doc->itemToolPrefs().textColumnGap = attrs.valueAsDouble("DGAP", 0.0); |
||
13710 | jghali | 989 | |
14932 | cbradney | 990 | doc->itemToolPrefs().polyCorners = attrs.valueAsInt("POLYC", 4); |
991 | doc->itemToolPrefs().polyFactor = attrs.valueAsDouble("POLYF", 0.5); |
||
992 | doc->itemToolPrefs().polyRotation = attrs.valueAsDouble("POLYR", 0.0); |
||
993 | doc->itemToolPrefs().polyCurvature = attrs.valueAsDouble("POLYCUR", 0.0); |
||
994 | doc->itemToolPrefs().polyUseFactor = attrs.valueAsBool("POLYS", false); |
||
13710 | jghali | 995 | |
14932 | cbradney | 996 | doc->itemToolPrefs().lineStartArrow = attrs.valueAsInt("StartArrow", 0); |
997 | doc->itemToolPrefs().lineEndArrow = attrs.valueAsInt("EndArrow", 0); |
||
998 | doc->itemToolPrefs().imageScaleX = attrs.valueAsDouble("PICTSCX", 1.0); |
||
999 | doc->itemToolPrefs().imageScaleY = attrs.valueAsDouble("PICTSCY", 1.0); |
||
1000 | doc->itemToolPrefs().imageScaleType = attrs.valueAsBool("PSCALE", true); |
||
1001 | doc->itemToolPrefs().imageAspectRatio = attrs.valueAsBool("PASPECT", false); |
||
1002 | doc->itemToolPrefs().imageLowResType = attrs.valueAsInt("HalfRes", 1); |
||
1003 | doc->itemToolPrefs().imageUseEmbeddedPath = attrs.valueAsBool("EmbeddedPath", false); |
||
13710 | jghali | 1004 | if (attrs.hasAttribute("PEN")) |
14932 | cbradney | 1005 | doc->itemToolPrefs().shapeLineColor = attrs.valueAsString("PEN"); |
13710 | jghali | 1006 | if (attrs.hasAttribute("BRUSH")) |
14932 | cbradney | 1007 | doc->itemToolPrefs().shapeFillColor = attrs.valueAsString("BRUSH"); |
13710 | jghali | 1008 | if (attrs.hasAttribute("PENLINE")) |
14932 | cbradney | 1009 | doc->itemToolPrefs().lineColor = attrs.valueAsString("PENLINE"); |
13710 | jghali | 1010 | if (attrs.hasAttribute("PENTEXT")) |
14932 | cbradney | 1011 | doc->itemToolPrefs().textColor = attrs.valueAsString("PENTEXT"); |
13710 | jghali | 1012 | if (attrs.hasAttribute("StrokeText")) |
14932 | cbradney | 1013 | doc->itemToolPrefs().textStrokeColor = attrs.valueAsString("StrokeText"); |
1014 | doc->itemToolPrefs().textFillColor = attrs.valueAsString("TextBackGround", CommonStrings::None); |
||
1015 | doc->itemToolPrefs().textLineColor = attrs.valueAsString("TextLineColor", CommonStrings::None); |
||
1016 | doc->itemToolPrefs().textFillColorShade =attrs.valueAsInt("TextBackGroundShade", 100); |
||
1017 | doc->itemToolPrefs().textLineColorShade = attrs.valueAsInt("TextLineShade", 100); |
||
1018 | doc->itemToolPrefs().textShade = attrs.valueAsInt("TextPenShade", 100); |
||
1019 | doc->itemToolPrefs().textStrokeShade = attrs.valueAsInt("TextStrokeShade", 100); |
||
1020 | doc->itemToolPrefs().shapeLineStyle = static_cast<Qt::PenStyle>(attrs.valueAsInt("STIL")); |
||
1021 | doc->itemToolPrefs().lineStyle = static_cast<Qt::PenStyle>(attrs.valueAsInt("STILLINE")); |
||
1022 | doc->itemToolPrefs().shapeLineWidth = attrs.valueAsDouble("WIDTH", 0.0); |
||
1023 | doc->itemToolPrefs().lineWidth = attrs.valueAsDouble("WIDTHLINE", 1.0); |
||
1024 | doc->itemToolPrefs().shapeLineColorShade = attrs.valueAsInt("PENSHADE", 100); |
||
1025 | doc->itemToolPrefs().lineColor = attrs.valueAsInt("LINESHADE", 100); |
||
1026 | doc->itemToolPrefs().shapeFillColorShade = attrs.valueAsInt("BRUSHSHADE", 100); |
||
1027 | doc->opToolPrefs().dispX = attrs.valueAsDouble("dispX", 10.0); |
||
1028 | doc->opToolPrefs().dispY = attrs.valueAsDouble("dispY", 10.0); |
||
1029 | doc->opToolPrefs().constrain = attrs.valueAsDouble("constrain", 15.0); |
||
1030 | doc->itemToolPrefs().textTabFillChar = attrs.valueAsString("TabFill",""); |
||
1031 | doc->itemToolPrefs().textTabWidth = attrs.valueAsDouble("TabWidth", 36.0); |
||
13710 | jghali | 1032 | if (attrs.hasAttribute("CPICT")) |
14932 | cbradney | 1033 | doc->itemToolPrefs().imageFillColor = attrs.valueAsString("CPICT"); |
1034 | doc->itemToolPrefs().imageFillColorShade = attrs.valueAsInt("PICTSHADE", 100); |
||
13710 | jghali | 1035 | } |
1036 | |||
1037 | void Scribus134Format::readTypographicSettings(ScribusDoc* doc, ScXmlStreamAttributes& attrs) |
||
1038 | { |
||
14932 | cbradney | 1039 | doc->typographicPrefs().valueSuperScript = attrs.valueAsInt("VHOCH"); |
1040 | doc->typographicPrefs().scalingSuperScript = attrs.valueAsInt("VHOCHSC"); |
||
1041 | doc->typographicPrefs().valueSubScript = attrs.valueAsInt("VTIEF"); |
||
1042 | doc->typographicPrefs().scalingSubScript = attrs.valueAsInt("VTIEFSC"); |
||
1043 | doc->typographicPrefs().valueSmallCaps = attrs.valueAsInt("VKAPIT"); |
||
1044 | doc->guidesPrefs().valueBaselineGrid = attrs.valueAsDouble("BASEGRID", 12.0); |
||
1045 | doc->guidesPrefs().offsetBaselineGrid = attrs.valueAsDouble("BASEO", 0.0); |
||
17223 | jghali | 1046 | // #9621 : autolinespacing is now express as a percentage of the font height |
1047 | // It was not working in regualer text frame in 1.3.4+, so set it to the default value |
||
1048 | doc->typographicPrefs().autoLineSpacing = 100 /*attrs.valueAsInt("AUTOL", 20)*/; |
||
14932 | cbradney | 1049 | doc->typographicPrefs().valueUnderlinePos = attrs.valueAsInt("UnderlinePos", -1); |
1050 | doc->typographicPrefs().valueUnderlineWidth = attrs.valueAsInt("UnderlineWidth", -1); |
||
1051 | doc->typographicPrefs().valueStrikeThruPos = attrs.valueAsInt("StrikeThruPos", -1); |
||
1052 | doc->typographicPrefs().valueStrikeThruWidth = attrs.valueAsInt("StrikeThruWidth", -1); |
||
13710 | jghali | 1053 | } |
1054 | |||
1055 | bool Scribus134Format::readPageSets(ScribusDoc* doc, ScXmlStreamReader& reader) |
||
1056 | { |
||
1057 | struct PageSet pageS; |
||
1058 | ScXmlStreamAttributes attrs; |
||
1059 | |||
14924 | cbradney | 1060 | doc->clearPageSets(); |
13710 | jghali | 1061 | while(!reader.atEnd() && !reader.hasError()) |
1062 | { |
||
13713 | jghali | 1063 | reader.readNext(); |
13710 | jghali | 1064 | QStringRef tagName = reader.name(); |
1065 | if(reader.isStartElement()) |
||
1066 | attrs = reader.attributes(); |
||
1067 | if (reader.isEndElement() && tagName == "PageSets") |
||
1068 | break; |
||
1069 | if(reader.isStartElement() && tagName == "Set") |
||
1070 | { |
||
1071 | ScXmlStreamAttributes attrs = reader.scAttributes(); |
||
1072 | pageS.Name = CommonStrings::untranslatePageSetString(attrs.valueAsString("Name")); |
||
1073 | pageS.FirstPage = attrs.valueAsInt("FirstPage", 0); |
||
1074 | pageS.Rows = attrs.valueAsInt("Rows", 1); |
||
1075 | pageS.Columns = attrs.valueAsInt("Columns", 1); |
||
1076 | // pageS.GapHorizontal = attrs.valueAsDouble("GapHorizontal", 0); |
||
1077 | // pageS.GapVertical = attrs.valueAsDouble("GapVertical", 0); |
||
1078 | // pageS.GapBelow = attrs.valueAsDouble("GapBelow", 0); |
||
1079 | pageS.pageNames.clear(); |
||
1080 | } |
||
1081 | if(reader.isEndElement() && tagName == "Set") |
||
1082 | { |
||
14924 | cbradney | 1083 | //->Prefs doc->pageSets.append(pageS); |
1084 | doc->appendToPageSets(pageS); |
||
15407 | craig | 1085 | if ((doc->pageSets().count()-1 == doc->pagePositioning()) && ((doc->pageGapHorizontal() < 0) && (doc->pageGapVertical() < 0))) |
13710 | jghali | 1086 | { |
14924 | cbradney | 1087 | doc->setPageGapHorizontal(attrs.valueAsDouble("GapHorizontal", 0.0)); |
1088 | doc->setPageGapVertical(attrs.valueAsDouble("GapBelow", 0.0)); |
||
13710 | jghali | 1089 | } |
1090 | } |
||
1091 | if (reader.isStartElement() && tagName == "PageNames") |
||
1092 | pageS.pageNames.append(CommonStrings::untranslatePageSetLocString(attrs.valueAsString("Name"))); |
||
1093 | } |
||
1094 | return !reader.hasError(); |
||
1095 | } |
||
1096 | |||
1097 | bool Scribus134Format::readCheckProfile(ScribusDoc* doc, ScXmlStreamAttributes& attrs) |
||
1098 | { |
||
13889 | cbradney | 1099 | struct CheckerPrefs checkerSettings; |
13710 | jghali | 1100 | QString profileName = attrs.valueAsString("Name"); |
1101 | if (profileName.isEmpty()) |
||
1102 | return true; |
||
1103 | checkerSettings.ignoreErrors = attrs.valueAsBool("ignoreErrors", false); |
||
1104 | checkerSettings.autoCheck = attrs.valueAsBool("autoCheck", true); |
||
1105 | checkerSettings.checkGlyphs = attrs.valueAsBool("checkGlyphs", true); |
||
1106 | checkerSettings.checkOrphans = attrs.valueAsBool("checkOrphans", true); |
||
1107 | checkerSettings.checkOverflow = attrs.valueAsBool("checkOverflow", true); |
||
1108 | checkerSettings.checkPictures = attrs.valueAsBool("checkPictures", true); |
||
16357 | petr | 1109 | checkerSettings.checkPartFilledImageFrames = attrs.valueAsBool("checkPartFilledImageFrames", false); |
13710 | jghali | 1110 | checkerSettings.checkResolution = attrs.valueAsBool("checkResolution", true); |
1111 | checkerSettings.checkTransparency = attrs.valueAsBool("checkTransparency", true); |
||
1112 | checkerSettings.minResolution = attrs.valueAsDouble("minResolution", 72.0); |
||
1113 | checkerSettings.maxResolution = attrs.valueAsDouble("maxResolution", 4800.0); |
||
1114 | checkerSettings.checkAnnotations = attrs.valueAsBool("checkAnnotations", false); |
||
1115 | checkerSettings.checkRasterPDF = attrs.valueAsBool("checkRasterPDF", true); |
||
1116 | checkerSettings.checkForGIF = attrs.valueAsBool("checkForGIF", true); |
||
1117 | checkerSettings.ignoreOffLayers = attrs.valueAsBool("ignoreOffLayers", false); |
||
14544 | cbradney | 1118 | checkerSettings.checkOffConflictLayers = attrs.valueAsBool("checkOffConflictLayers", false); |
18410 | jghali | 1119 | checkerSettings.checkNotCMYKOrSpot = attrs.valueAsBool("checkNotCMYKOrSpot", false); |
1120 | checkerSettings.checkDeviceColorsAndOutputIntent = attrs.valueAsBool("checkDeviceColorsAndOutputIntent", false); |
||
1121 | checkerSettings.checkFontNotEmbedded = attrs.valueAsBool("checkFontNotEmbedded", false); |
||
1122 | checkerSettings.checkFontIsOpenType = attrs.valueAsBool("checkFontIsOpenType", false); |
||
18490 | craig | 1123 | checkerSettings.checkAppliedMasterDifferentSide = attrs.valueAsBool("checkAppliedMasterDifferentSide", true); |
18491 | craig | 1124 | checkerSettings.checkEmptyTextFrames = attrs.valueAsBool("checkEmptyTextFrames", true); |
14971 | cbradney | 1125 | doc->set1CheckerProfile(profileName, checkerSettings); |
13710 | jghali | 1126 | return true; |
1127 | } |
||
1128 | |||
1129 | bool Scribus134Format::readColor(ColorList& colors, ScXmlStreamAttributes& attrs) |
||
1130 | { |
||
1131 | ScColor color; |
||
1132 | if (attrs.hasAttribute("CMYK")) |
||
1133 | color.setNamedColor(attrs.valueAsString("CMYK")); |
||
1134 | else |
||
1135 | color.fromQColor(QColor(attrs.valueAsString("RGB"))); |
||
1136 | color.setSpotColor( attrs.valueAsBool("Spot", false) ); |
||
1137 | color.setRegistrationColor( attrs.valueAsBool("Register", false) ); |
||
1138 | QString name = attrs.valueAsString("NAME"); |
||
1139 | colors.insert((name.isEmpty()) ? color.name() : name, color); |
||
1140 | return true; |
||
1141 | } |
||
1142 | |||
1143 | void Scribus134Format::readCharacterStyleAttrs(ScribusDoc *doc, ScXmlStreamAttributes& attrs, CharStyle & newStyle) |
||
1144 | { |
||
13785 | jghali | 1145 | static const QString CPARENT("CPARENT"); |
1146 | if (attrs.hasAttribute(CPARENT)) |
||
1147 | newStyle.setParent(attrs.valueAsString(CPARENT)); |
||
1148 | |||
1149 | static const QString FONT("FONT"); |
||
1150 | if (attrs.hasAttribute(FONT)) |
||
1151 | newStyle.setFont(m_AvailableFonts->findFont(attrs.valueAsString(FONT), doc)); |
||
6864 | avox | 1152 | |
13785 | jghali | 1153 | static const QString FONTSIZE("FONTSIZE"); |
1154 | if (attrs.hasAttribute(FONTSIZE)) |
||
1155 | newStyle.setFontSize(qRound(attrs.valueAsDouble(FONTSIZE) * 10)); |
||
6864 | avox | 1156 | |
13785 | jghali | 1157 | static const QString FCOLOR("FCOLOR"); |
1158 | if (attrs.hasAttribute(FCOLOR)) |
||
1159 | newStyle.setFillColor(attrs.valueAsString(FCOLOR)); |
||
6864 | avox | 1160 | |
13785 | jghali | 1161 | static const QString KERN("KERN"); |
1162 | if (attrs.hasAttribute(KERN)) |
||
1163 | newStyle.setTracking(qRound(attrs.valueAsDouble(KERN) * 10)); |
||
6864 | avox | 1164 | |
13785 | jghali | 1165 | static const QString FSHADE("FSHADE"); |
1166 | if (attrs.hasAttribute(FSHADE)) |
||
1167 | newStyle.setFillShade(attrs.valueAsInt(FSHADE)); |
||
6864 | avox | 1168 | |
13785 | jghali | 1169 | static const QString EFFECTS("EFFECTS"); |
1170 | if (attrs.hasAttribute(EFFECTS)) |
||
1171 | newStyle.setFeatures(static_cast<StyleFlag>(attrs.valueAsInt(EFFECTS)).featureList()); |
||
6864 | avox | 1172 | |
13785 | jghali | 1173 | static const QString EFFECT("EFFECT"); |
1174 | if (attrs.hasAttribute(EFFECT)) |
||
1175 | newStyle.setFeatures(static_cast<StyleFlag>(attrs.valueAsInt(EFFECT)).featureList()); |
||
8427 | avox | 1176 | |
13785 | jghali | 1177 | static const QString FEATURES("FEATURES"); |
1178 | if (attrs.hasAttribute(FEATURES)) |
||
1179 | newStyle.setFeatures(attrs.valueAsString(FEATURES).split( " ", QString::SkipEmptyParts)); |
||
9607 | avox | 1180 | |
13785 | jghali | 1181 | static const QString SCOLOR("SCOLOR"); |
1182 | if (attrs.hasAttribute(SCOLOR)) |
||
1183 | newStyle.setStrokeColor(attrs.valueAsString(SCOLOR, CommonStrings::None)); |
||
6864 | avox | 1184 | |
13785 | jghali | 1185 | static const QString SSHADE("SSHADE"); |
1186 | if (attrs.hasAttribute(SSHADE)) |
||
1187 | newStyle.setStrokeShade(attrs.valueAsInt(SSHADE)); |
||
6864 | avox | 1188 | |
13785 | jghali | 1189 | static const QString SCALEH("SCALEH"); |
1190 | if (attrs.hasAttribute(SCALEH)) |
||
1191 | newStyle.setScaleH(qRound(attrs.valueAsDouble(SCALEH) * 10)); |
||
6864 | avox | 1192 | |
13785 | jghali | 1193 | static const QString SCALEV("SCALEV"); |
1194 | if (attrs.hasAttribute(SCALEV)) |
||
1195 | newStyle.setScaleV(qRound(attrs.valueAsDouble(SCALEV) * 10)); |
||
6864 | avox | 1196 | |
13785 | jghali | 1197 | static const QString BASEO("BASEO"); |
1198 | if (attrs.hasAttribute(BASEO)) |
||
1199 | newStyle.setBaselineOffset(qRound(attrs.valueAsDouble(BASEO) * 10)); |
||
6864 | avox | 1200 | |
13785 | jghali | 1201 | static const QString TXTSHX("TXTSHX"); |
1202 | if (attrs.hasAttribute(TXTSHX)) |
||
1203 | newStyle.setShadowXOffset(qRound(attrs.valueAsDouble(TXTSHX) * 10)); |
||
6864 | avox | 1204 | |
13785 | jghali | 1205 | static const QString TXTSHY("TXTSHY"); |
1206 | if (attrs.hasAttribute(TXTSHY)) |
||
1207 | newStyle.setShadowYOffset(qRound(attrs.valueAsDouble(TXTSHY) * 10)); |
||
6864 | avox | 1208 | |
13785 | jghali | 1209 | static const QString TXTOUT("TXTOUT"); |
1210 | if (attrs.hasAttribute(TXTOUT)) |
||
1211 | newStyle.setOutlineWidth(qRound(attrs.valueAsDouble(TXTOUT) * 10)); |
||
6864 | avox | 1212 | |
13785 | jghali | 1213 | static const QString TXTULP("TXTULP"); |
1214 | if (attrs.hasAttribute(TXTULP)) |
||
1215 | newStyle.setUnderlineOffset(qRound(attrs.valueAsDouble(TXTULP) * 10)); |
||
6864 | avox | 1216 | |
13785 | jghali | 1217 | static const QString TXTULW("TXTULW"); |
1218 | if (attrs.hasAttribute(TXTULW)) |
||
1219 | newStyle.setUnderlineWidth(qRound(attrs.valueAsDouble(TXTULW) * 10)); |
||
6864 | avox | 1220 | |
13785 | jghali | 1221 | static const QString TXTSTP("TXTSTP"); |
1222 | if (attrs.hasAttribute(TXTSTP)) |
||
1223 | newStyle.setStrikethruOffset(qRound(attrs.valueAsDouble(TXTSTP) * 10)); |
||
6864 | avox | 1224 | |
13785 | jghali | 1225 | static const QString TXTSTW("TXTSTW"); |
1226 | if (attrs.hasAttribute(TXTSTW)) |
||
1227 | newStyle.setStrikethruWidth(qRound(attrs.valueAsDouble(TXTSTW) * 10)); |
||
6733 | avox | 1228 | |
15316 | jghali | 1229 | static const QString LANGUAGE("LANGUAGE"); |
1230 | if (attrs.hasAttribute(LANGUAGE)) |
||
17798 | craig | 1231 | { |
1232 | QString l(attrs.valueAsString(LANGUAGE)); |
||
1233 | if (LanguageManager::instance()->langTableIndex(l)!=-1) |
||
1234 | newStyle.setLanguage(l); //new style storage |
||
1235 | else |
||
1236 | { //old style storage |
||
1237 | QString lnew=LanguageManager::instance()->getAbbrevFromLang(l, true, false); |
||
1238 | if (lnew.isEmpty()) |
||
1239 | lnew=LanguageManager::instance()->getAbbrevFromLang(l, false, false); |
||
1240 | newStyle.setLanguage(lnew); |
||
1241 | } |
||
1242 | } |
||
15316 | jghali | 1243 | |
13785 | jghali | 1244 | static const QString SHORTCUT("SHORTCUT"); |
1245 | if (attrs.hasAttribute(SHORTCUT)) |
||
1246 | newStyle.setShortcut(attrs.valueAsString(SHORTCUT)); |
||
7752 | tsoots | 1247 | |
13785 | jghali | 1248 | static const QString WORDTRACK("wordTrack"); |
1249 | if (attrs.hasAttribute(WORDTRACK)) |
||
1250 | newStyle.setWordTracking(attrs.valueAsDouble(WORDTRACK)); |
||
13710 | jghali | 1251 | } |
8931 | cbradney | 1252 | |
16448 | jghali | 1253 | void Scribus134Format::readNamedCharacterStyleAttrs(ScribusDoc *doc, ScXmlStreamAttributes& attrs, CharStyle & newStyle) |
1254 | { |
||
1255 | static const QString CNAME("CNAME"); |
||
1256 | if (attrs.hasAttribute(CNAME)) |
||
1257 | newStyle.setName(attrs.valueAsString(CNAME)); |
||
1258 | |||
1259 | // The default style attribute must be correctly set before trying to assign a parent |
||
1260 | static const QString DEFAULTSTYLE("DefaultStyle"); |
||
1261 | if (newStyle.hasName() && attrs.hasAttribute(DEFAULTSTYLE)) |
||
1262 | newStyle.setDefaultStyle(attrs.valueAsInt(DEFAULTSTYLE)); |
||
1263 | else if (newStyle.name() == CommonStrings::DefaultCharacterStyle || newStyle.name() == CommonStrings::trDefaultCharacterStyle) |
||
1264 | newStyle.setDefaultStyle(true); |
||
1265 | else |
||
1266 | newStyle.setDefaultStyle(false); |
||
1267 | |||
1268 | readCharacterStyleAttrs(doc, attrs, newStyle); |
||
16692 | jghali | 1269 | |
1270 | // Check that a style is not its own parent |
||
1271 | QString parentStyle = newStyle.parent(); |
||
1272 | if (parentStyle == newStyle.name()) |
||
1273 | newStyle.setParent(QString()); |
||
16448 | jghali | 1274 | } |
1275 | |||
16531 | jghali | 1276 | void Scribus134Format::readParagraphStyle(ScribusDoc *doc, ScXmlStreamReader& reader, ParagraphStyle& newStyle) |
13710 | jghali | 1277 | { |
1278 | ScXmlStreamAttributes attrs = reader.scAttributes(); |
||
6864 | avox | 1279 | |
13710 | jghali | 1280 | newStyle.erase(); |
1281 | newStyle.setName(attrs.valueAsString("NAME", "")); |
||
1282 | // The default style attribute must be correctly set before trying to assign a parent |
||
13785 | jghali | 1283 | static const QString DEFAULTSTYLE("DefaultStyle"); |
1284 | if (attrs.hasAttribute(DEFAULTSTYLE)) |
||
1285 | newStyle.setDefaultStyle(attrs.valueAsInt(DEFAULTSTYLE)); |
||
13710 | jghali | 1286 | else if (newStyle.name() == CommonStrings::DefaultParagraphStyle || newStyle.name() == CommonStrings::trDefaultParagraphStyle) |
1287 | newStyle.setDefaultStyle(true); |
||
1288 | else |
||
1289 | newStyle.setDefaultStyle(false); |
||
16692 | jghali | 1290 | |
16386 | fschmid | 1291 | QString parentStyle = attrs.valueAsString("PARENT", ""); |
16692 | jghali | 1292 | if (!parentStyle.isEmpty() && (parentStyle != newStyle.name())) |
16386 | fschmid | 1293 | { |
1294 | if (m_Doc->styleExists(parentStyle)) |
||
1295 | newStyle.setParent(parentStyle); |
||
17335 | jghali | 1296 | else if (parStyleMap.contains(parentStyle)) |
1297 | newStyle.setParent(parStyleMap.value(parentStyle)); |
||
16386 | fschmid | 1298 | else |
1299 | newStyle.setParent(CommonStrings::DefaultParagraphStyle); |
||
1300 | } |
||
13785 | jghali | 1301 | |
1302 | static const QString LINESPMode("LINESPMode"); |
||
1303 | if (attrs.hasAttribute(LINESPMode)) |
||
1304 | newStyle.setLineSpacingMode(static_cast<ParagraphStyle::LineSpacingMode>(attrs.valueAsInt(LINESPMode))); |
||
1305 | |||
1306 | static const QString LINESP("LINESP"); |
||
1307 | if (attrs.hasAttribute(LINESP)) |
||
1308 | newStyle.setLineSpacing(attrs.valueAsDouble(LINESP)); |
||
1309 | |||
1310 | static const QString INDENT("INDENT"); |
||
1311 | if (attrs.hasAttribute(INDENT)) |
||
1312 | newStyle.setLeftMargin(attrs.valueAsDouble(INDENT)); |
||
1313 | |||
1314 | static const QString RMARGIN("RMARGIN"); |
||
1315 | if (attrs.hasAttribute(RMARGIN)) |
||
1316 | newStyle.setRightMargin(attrs.valueAsDouble(RMARGIN)); |
||
1317 | |||
1318 | static const QString FIRST("FIRST"); |
||
1319 | if (attrs.hasAttribute(FIRST)) |
||
1320 | newStyle.setFirstIndent(attrs.valueAsDouble(FIRST)); |
||
1321 | |||
1322 | static const QString ALIGN("ALIGN"); |
||
1323 | if (attrs.hasAttribute(ALIGN)) |
||
1324 | newStyle.setAlignment(static_cast<ParagraphStyle::AlignmentType>(attrs.valueAsInt(ALIGN))); |
||
1325 | |||
1326 | static const QString VOR("VOR"); |
||
1327 | if (attrs.hasAttribute(VOR)) |
||
1328 | newStyle.setGapBefore(attrs.valueAsDouble(VOR)); |
||
1329 | |||
1330 | static const QString NACH("NACH"); |
||
1331 | if (attrs.hasAttribute(NACH)) |
||
1332 | newStyle.setGapAfter(attrs.valueAsDouble(NACH)); |
||
1333 | |||
1334 | static const QString DROP("DROP"); |
||
1335 | if (attrs.hasAttribute(DROP)) |
||
1336 | newStyle.setHasDropCap(static_cast<bool>(attrs.valueAsInt(DROP))); |
||
1337 | |||
1338 | static const QString DROPLIN("DROPLIN"); |
||
1339 | if (attrs.hasAttribute(DROPLIN)) |
||
1340 | newStyle.setDropCapLines(attrs.valueAsInt(DROPLIN)); |
||
1341 | |||
1342 | static const QString DROPDIST("DROPDIST"); |
||
1343 | if (attrs.hasAttribute(DROPDIST)) |
||
18047 | craig | 1344 | newStyle.setParEffectOffset(attrs.valueAsDouble(DROPDIST)); |
13785 | jghali | 1345 | |
1346 | static const QString PSHORTCUT("PSHORTCUT"); |
||
1347 | if (attrs.hasAttribute(PSHORTCUT)) |
||
1348 | newStyle.setShortcut(attrs.valueAsString(PSHORTCUT)); |
||
13710 | jghali | 1349 | |
13785 | jghali | 1350 | static const QString OpticalMargins("OpticalMargins"); |
1351 | if (attrs.hasAttribute(OpticalMargins)) |
||
1352 | newStyle.setOpticalMargins(attrs.valueAsInt(OpticalMargins)); |
||
1353 | |||
1354 | static const QString HyphenationMode("HyphenationMode"); |
||
1355 | if (attrs.hasAttribute(HyphenationMode)) |
||
1356 | newStyle.setHyphenationMode(attrs.valueAsInt(HyphenationMode)); |
||
1357 | |||
1358 | static const QString MinWordTrack("MinWordTrack"); |
||
1359 | if (attrs.hasAttribute(MinWordTrack)) |
||
1360 | newStyle.setMinWordTracking(attrs.valueAsDouble(MinWordTrack)); |
||
1361 | |||
1362 | static const QString NormWordTrack("NormWordTrack"); |
||
1363 | if (attrs.hasAttribute(NormWordTrack)) |
||
1364 | newStyle.charStyle().setWordTracking(attrs.valueAsDouble(NormWordTrack)); |
||
1365 | |||
1366 | static const QString MinGlyphShrink("MinGlyphShrink"); |
||
1367 | if (attrs.hasAttribute(MinGlyphShrink)) |
||
1368 | newStyle.setMinGlyphExtension(attrs.valueAsDouble(MinGlyphShrink)); |
||
1369 | |||
1370 | static const QString MaxGlyphExtend("MaxGlyphExtend"); |
||
1371 | if (attrs.hasAttribute(MaxGlyphExtend)) |
||
1372 | newStyle.setMaxGlyphExtension(attrs.valueAsDouble(MaxGlyphExtend)); |
||
13710 | jghali | 1373 | |
1374 | readCharacterStyleAttrs( doc, attrs, newStyle.charStyle()); |
||
1375 | |||
1376 | // newStyle.tabValues().clear(); |
||
1377 | int numTabs = attrs.valueAsInt("NUMTAB", 0); |
||
1378 | if (numTabs > 0) |
||
1379 | { |
||
1380 | QList<ParagraphStyle::TabRecord> tbs; |
||
1381 | ParagraphStyle::TabRecord tb; |
||
1382 | QString tmp = attrs.valueAsString("TABS"); |
||
1383 | ScTextStream tgv(&tmp, QIODevice::ReadOnly); |
||
1384 | double xf, xf2; |
||
1385 | for (int cxv = 0; cxv < numTabs; cxv += 2) |
||
1386 | { |
||
1387 | tgv >> xf; |
||
1388 | tgv >> xf2; |
||
1389 | tb.tabPosition = xf2; |
||
1390 | tb.tabType = static_cast<int>(xf); |
||
1391 | tb.tabFillChar = QChar(); |
||
1392 | tbs.append(tb); |
||
1393 | } |
||
1394 | newStyle.setTabValues(tbs); |
||
1395 | tmp = ""; |
||
1396 | } |
||
1397 | else |
||
1398 | { |
||
1399 | QList<ParagraphStyle::TabRecord> tbs; |
||
1400 | newStyle.resetTabValues(); |
||
1401 | QStringRef thisTagName = reader.name(); |
||
1402 | while (!reader.atEnd() && !reader.hasError()) |
||
1403 | { |
||
13713 | jghali | 1404 | reader.readNext(); |
13710 | jghali | 1405 | if (reader.isEndElement() && reader.name() == thisTagName) |
1406 | break; |
||
1407 | if (reader.isStartElement() && reader.name() == "Tabs") |
||
1408 | { |
||
1409 | ParagraphStyle::TabRecord tb; |
||
1410 | ScXmlStreamAttributes attrs2 = reader.scAttributes(); |
||
1411 | tb.tabPosition = attrs2.valueAsDouble("Pos"); |
||
1412 | tb.tabType = attrs2.valueAsInt("Type"); |
||
1413 | QString tbCh = attrs2.valueAsString("Fill",""); |
||
1414 | tb.tabFillChar = tbCh.isEmpty() ? QChar() : tbCh[0]; |
||
1415 | tbs.append(tb); |
||
1416 | } |
||
1417 | } |
||
1418 | if (tbs.count() > 0) |
||
1419 | newStyle.setTabValues(tbs); |
||
1420 | } |
||
1421 | |||
1422 | fixLegacyParStyle(newStyle); |
||
1423 | } |
||
1424 | |||
1425 | void Scribus134Format::readLayers(ScLayer& layer, ScXmlStreamAttributes& attrs) |
||
5653 | cbradney | 1426 | { |
13875 | jghali | 1427 | int lId = attrs.valueAsInt("NUMMER"); |
13710 | jghali | 1428 | int level = attrs.valueAsInt("LEVEL"); |
13875 | jghali | 1429 | layer = ScLayer( attrs.valueAsString("NAME"), level, lId); |
13710 | jghali | 1430 | layer.isViewable = attrs.valueAsInt("SICHTBAR"); |
1431 | layer.isPrintable = attrs.valueAsInt("DRUCKEN"); |
||
1432 | layer.isEditable = attrs.valueAsInt("EDIT", 1); |
||
1433 | layer.flowControl = attrs.valueAsInt("FLOW", 1); |
||
1434 | layer.transparency = attrs.valueAsDouble("TRANS", 1.0); |
||
1435 | layer.blendMode = attrs.valueAsInt("BLEND", 0); |
||
1436 | layer.outlineMode = attrs.valueAsInt("OUTL", 0); |
||
1437 | if (attrs.hasAttribute("LAYERC")) |
||
1438 | layer.markerColor = QColor(attrs.valueAsString("LAYERC","#000000")); |
||
1439 | } |
||
1440 | |||
1441 | bool Scribus134Format::readArrows(ScribusDoc* doc, ScXmlStreamAttributes& attrs) |
||
1442 | { |
||
1443 | double xa, ya; |
||
1444 | struct ArrowDesc arrow; |
||
1445 | arrow.name = attrs.valueAsString("Name"); |
||
1446 | arrow.userArrow = true; |
||
1447 | QString tmp = attrs.valueAsString("Points"); |
||
1448 | ScTextStream fp(&tmp, QIODevice::ReadOnly); |
||
1449 | unsigned int numPoints = attrs.valueAsUInt("NumPoints"); |
||
1450 | for (uint cx = 0; cx < numPoints; ++cx) |
||
1451 | { |
||
1452 | fp >> xa; |
||
1453 | fp >> ya; |
||
1454 | arrow.points.addPoint(xa, ya); |
||
1455 | } |
||
14969 | cbradney | 1456 | doc->appendToArrowStyles(arrow); |
13710 | jghali | 1457 | return true; |
1458 | } |
||
1459 | |||
1460 | bool Scribus134Format::readMultiline(multiLine& ml, ScXmlStreamReader& reader) |
||
1461 | { |
||
1462 | ml = multiLine(); |
||
1463 | ScXmlStreamAttributes rattrs = reader.scAttributes(); |
||
1464 | QStringRef tagName = reader.name(); |
||
1465 | while(!reader.atEnd() && !reader.hasError()) |
||
1466 | { |
||
1467 | ScXmlStreamReader::TokenType tType = reader.readNext(); |
||
1468 | if (tType == ScXmlStreamReader::EndElement && reader.name() == tagName) |
||
1469 | break; |
||
1470 | if (tType == ScXmlStreamReader::StartElement && reader.name() == "SubLine") |
||
1471 | { |
||
1472 | struct SingleLine sl; |
||
1473 | ScXmlStreamAttributes attrs = reader.scAttributes(); |
||
1474 | sl.Color = attrs.valueAsString("Color"); |
||
1475 | sl.Dash = attrs.valueAsInt("Dash"); |
||
1476 | sl.LineEnd = attrs.valueAsInt("LineEnd"); |
||
1477 | sl.LineJoin = attrs.valueAsInt("LineJoin"); |
||
1478 | sl.Shade = attrs.valueAsInt("Shade"); |
||
1479 | sl.Width = attrs.valueAsDouble("Width"); |
||
1480 | ml.shortcut = attrs.valueAsString("Shortcut"); |
||
1481 | ml.push_back(sl); |
||
1482 | } |
||
1483 | } |
||
1484 | return !reader.hasError(); |
||
1485 | } |
||
1486 | |||
13715 | jghali | 1487 | bool Scribus134Format::readBookMark(ScribusDoc::BookMa& bookmark, int& elem, ScXmlStreamAttributes& attrs) |
13710 | jghali | 1488 | { |
13715 | jghali | 1489 | elem = attrs.valueAsInt("Element"); |
1490 | bookmark.PageObject = NULL; |
||
13710 | jghali | 1491 | bookmark.Title = attrs.valueAsString("Title"); |
1492 | bookmark.Text = attrs.valueAsString("Text"); |
||
1493 | bookmark.Aktion = attrs.valueAsString("Aktion"); |
||
1494 | bookmark.ItemNr = attrs.valueAsInt("ItemNr"); |
||
1495 | bookmark.First = attrs.valueAsInt("First"); |
||
1496 | bookmark.Last = attrs.valueAsInt("Last"); |
||
1497 | bookmark.Prev = attrs.valueAsInt("Prev"); |
||
1498 | bookmark.Next = attrs.valueAsInt("Next"); |
||
1499 | bookmark.Parent = attrs.valueAsInt("Parent"); |
||
1500 | return true; |
||
1501 | } |
||
1502 | |||
1503 | bool Scribus134Format::readPDFOptions(ScribusDoc* doc, ScXmlStreamReader& reader) |
||
1504 | { |
||
1505 | ScXmlStreamAttributes attrs = reader.scAttributes(); |
||
1506 | |||
14925 | cbradney | 1507 | doc->pdfOptions().firstUse = attrs.valueAsBool("firstUse", true); |
1508 | doc->pdfOptions().Articles = attrs.valueAsBool("Articles"); |
||
1509 | doc->pdfOptions().Thumbnails = attrs.valueAsBool("Thumbnails"); |
||
1510 | doc->pdfOptions().Compress = attrs.valueAsBool("Compress"); |
||
1511 | doc->pdfOptions().CompressMethod = (PDFOptions::PDFCompression)attrs.valueAsInt("CMethod", 0); |
||
1512 | doc->pdfOptions().Quality = attrs.valueAsInt("Quality", 0); |
||
1513 | doc->pdfOptions().RecalcPic = attrs.valueAsBool("RecalcPic"); |
||
18412 | jghali | 1514 | doc->pdfOptions().embedPDF = attrs.valueAsBool("EmbedPDF", false); |
14925 | cbradney | 1515 | doc->pdfOptions().Bookmarks = attrs.valueAsBool("Bookmarks"); |
1516 | doc->pdfOptions().MirrorH = attrs.valueAsBool("MirrorH", false); |
||
1517 | doc->pdfOptions().MirrorV = attrs.valueAsBool("MirrorV", false); |
||
1518 | doc->pdfOptions().RotateDeg = attrs.valueAsInt("RotateDeg", 0); |
||
1519 | doc->pdfOptions().doClip = attrs.valueAsBool("Clip", false); |
||
1520 | doc->pdfOptions().PresentMode = attrs.valueAsBool("PresentMode"); |
||
1521 | doc->pdfOptions().PicRes = attrs.valueAsInt("PicRes"); |
||
13710 | jghali | 1522 | // Fixme: check input pdf version |
14925 | cbradney | 1523 | doc->pdfOptions().Version = (PDFOptions::PDFVersion) attrs.valueAsInt("Version"); |
1524 | doc->pdfOptions().Resolution = attrs.valueAsInt("Resolution"); |
||
1525 | doc->pdfOptions().Binding = attrs.valueAsInt("Binding"); |
||
1526 | doc->pdfOptions().fileName = ""; |
||
1527 | doc->pdfOptions().isGrayscale = attrs.valueAsBool("Grayscale", false); |
||
1528 | doc->pdfOptions().UseRGB = attrs.valueAsBool("RGBMode", false); |
||
1529 | doc->pdfOptions().UseProfiles = attrs.valueAsBool("UseProfiles", false); |
||
1530 | doc->pdfOptions().UseProfiles2 = attrs.valueAsBool("UseProfiles2", false); |
||
1531 | doc->pdfOptions().Intent = attrs.valueAsInt("Intent", 1); |
||
1532 | doc->pdfOptions().Intent2 = attrs.valueAsInt("Intent2", 1); |
||
1533 | doc->pdfOptions().SolidProf = attrs.valueAsString("SolidP", ""); |
||
1534 | doc->pdfOptions().ImageProf = attrs.valueAsString("ImageP", ""); |
||
1535 | doc->pdfOptions().PrintProf = attrs.valueAsString("PrintP", ""); |
||
1536 | doc->pdfOptions().Info = attrs.valueAsString("InfoString", ""); |
||
1537 | doc->pdfOptions().bleeds.Top = attrs.valueAsDouble("BTop", 0.0); |
||
1538 | doc->pdfOptions().bleeds.Left = attrs.valueAsDouble("BLeft", 0.0); |
||
1539 | doc->pdfOptions().bleeds.Right = attrs.valueAsDouble("BRight", 0.0); |
||
1540 | doc->pdfOptions().bleeds.Bottom = attrs.valueAsDouble("BBottom", 0.0); |
||
1541 | doc->pdfOptions().useDocBleeds = attrs.valueAsBool("useDocBleeds", true); |
||
1542 | doc->pdfOptions().cropMarks = attrs.valueAsBool("cropMarks", false); |
||
1543 | doc->pdfOptions().bleedMarks = attrs.valueAsBool("bleedMarks", false); |
||
1544 | doc->pdfOptions().registrationMarks = attrs.valueAsBool("registrationMarks", false); |
||
1545 | doc->pdfOptions().colorMarks = attrs.valueAsBool("colorMarks", false); |
||
1546 | doc->pdfOptions().docInfoMarks = attrs.valueAsBool("docInfoMarks", false); |
||
17401 | jghali | 1547 | doc->pdfOptions().markLength = attrs.valueAsDouble("markLength", 0.0); |
14925 | cbradney | 1548 | doc->pdfOptions().markOffset = attrs.valueAsDouble("markOffset", 0.0); |
1549 | doc->pdfOptions().EmbeddedI = attrs.valueAsBool("ImagePr", false); |
||
1550 | doc->pdfOptions().PassOwner = attrs.valueAsString("PassOwner", ""); |
||
1551 | doc->pdfOptions().PassUser = attrs.valueAsString("PassUser", ""); |
||
1552 | doc->pdfOptions().Permissions = attrs.valueAsInt("Permissions", -4); |
||
1553 | doc->pdfOptions().Encrypt = attrs.valueAsBool("Encrypt", false); |
||
1554 | doc->pdfOptions().useLayers = attrs.valueAsBool("UseLayers", false); |
||
1555 | doc->pdfOptions().UseLPI = attrs.valueAsBool("UseLpi", false); |
||
1556 | doc->pdfOptions().UseSpotColors = attrs.valueAsBool("UseSpotColors", true); |
||
1557 | doc->pdfOptions().doMultiFile = attrs.valueAsBool("doMultiFile", false); |
||
1558 | doc->pdfOptions().displayBookmarks = attrs.valueAsBool("displayBookmarks", false); |
||
1559 | doc->pdfOptions().displayFullscreen = attrs.valueAsBool("displayFullscreen", false); |
||
1560 | doc->pdfOptions().displayLayers = attrs.valueAsBool("displayLayers", false); |
||
1561 | doc->pdfOptions().displayThumbs = attrs.valueAsBool("displayThumbs", false); |
||
1562 | doc->pdfOptions().hideMenuBar = attrs.valueAsBool("hideMenuBar", false); |
||
1563 | doc->pdfOptions().hideToolBar = attrs.valueAsBool("hideToolBar", false); |
||
1564 | doc->pdfOptions().fitWindow = attrs.valueAsBool("fitWindow", false); |
||
1565 | doc->pdfOptions().PageLayout = attrs.valueAsInt("PageLayout", 0); |
||
1566 | doc->pdfOptions().openAction = attrs.valueAsString("openAction", ""); |
||
13710 | jghali | 1567 | |
1568 | QStringRef tagName = reader.name(); |
||
1569 | while(!reader.atEnd() && !reader.hasError()) |
||
1570 | { |
||
13713 | jghali | 1571 | reader.readNext(); |
13715 | jghali | 1572 | if (reader.isEndElement() && (reader.name() == tagName)) |
13710 | jghali | 1573 | break; |
1574 | if (!reader.isStartElement()) |
||
1575 | continue; |
||
1576 | QStringRef tName = reader.name(); |
||
1577 | attrs = reader.scAttributes(); |
||
1578 | if(tName == "LPI") |
||
1579 | { |
||
1580 | struct LPIData lpo; |
||
1581 | lpo.Angle = attrs.valueAsInt("Angle"); |
||
1582 | lpo.Frequency = attrs.valueAsInt("Frequency"); |
||
1583 | lpo.SpotFunc = attrs.valueAsInt("SpotFunction"); |
||
14925 | cbradney | 1584 | doc->pdfOptions().LPISettings[attrs.valueAsString("Color")] = lpo; |
13710 | jghali | 1585 | } |
1586 | if(tName == "Fonts") |
||
1587 | { |
||
1588 | QString fname = attrs.valueAsString("Name"); |
||
14925 | cbradney | 1589 | if (!doc->pdfOptions().EmbedList.contains(fname)) |
1590 | doc->pdfOptions().EmbedList.append(fname); |
||
13710 | jghali | 1591 | } |
1592 | if(tName == "Subset") |
||
1593 | { |
||
1594 | QString sname = attrs.valueAsString("Name"); |
||
14925 | cbradney | 1595 | if (!doc->pdfOptions().SubsetList.contains(sname)) |
1596 | doc->pdfOptions().SubsetList.append(sname); |
||
13710 | jghali | 1597 | } |
1598 | if(tName == "Effekte") |
||
1599 | { |
||
1600 | struct PDFPresentationData ef; |
||
1601 | ef.pageEffectDuration = attrs.valueAsInt("pageEffectDuration"); |
||
1602 | ef.pageViewDuration = attrs.valueAsInt("pageViewDuration"); |
||
1603 | ef.effectType = attrs.valueAsInt("effectType"); |
||
1604 | ef.Dm = attrs.valueAsInt("Dm"); |
||
1605 | ef.M = attrs.valueAsInt("M"); |
||
1606 | ef.Di = attrs.valueAsInt("Di"); |
||
18394 | fschmid | 1607 | EffVal.append(ef); |
13710 | jghali | 1608 | } |
1609 | } |
||
1610 | return !reader.hasError(); |
||
1611 | } |
||
1612 | |||
1613 | bool Scribus134Format::readPrinterOptions(ScribusDoc* doc, ScXmlStreamReader& reader) |
||
1614 | { |
||
1615 | ScXmlStreamAttributes attrs = reader.scAttributes(); |
||
1616 | doc->Print_Options.firstUse = attrs.valueAsBool("firstUse"); |
||
1617 | doc->Print_Options.toFile = attrs.valueAsBool("toFile"); |
||
1618 | doc->Print_Options.useAltPrintCommand = attrs.valueAsBool("useAltPrintCommand"); |
||
1619 | doc->Print_Options.outputSeparations = attrs.valueAsBool("outputSeparations"); |
||
1620 | doc->Print_Options.useSpotColors = attrs.valueAsBool("useSpotColors"); |
||
1621 | doc->Print_Options.useColor = attrs.valueAsBool("useColor"); |
||
1622 | doc->Print_Options.mirrorH = attrs.valueAsBool("mirrorH"); |
||
1623 | doc->Print_Options.mirrorV = attrs.valueAsBool("mirrorV"); |
||
1624 | doc->Print_Options.useICC = attrs.valueAsBool("useICC"); |
||
1625 | doc->Print_Options.doGCR = attrs.valueAsBool("doGCR"); |
||
1626 | doc->Print_Options.doClip = attrs.valueAsBool("doClip"); |
||
1627 | doc->Print_Options.setDevParam = attrs.valueAsBool("setDevParam"); |
||
1628 | doc->Print_Options.useDocBleeds = attrs.valueAsBool("useDocBleeds"); |
||
1629 | doc->Print_Options.cropMarks = attrs.valueAsBool("cropMarks"); |
||
1630 | doc->Print_Options.bleedMarks = attrs.valueAsBool("bleedMarks"); |
||
1631 | doc->Print_Options.registrationMarks = attrs.valueAsBool("registrationMarks"); |
||
1632 | doc->Print_Options.colorMarks = attrs.valueAsBool("colorMarks"); |
||
1633 | doc->Print_Options.includePDFMarks = attrs.valueAsBool("includePDFMarks", "1"); |
||
1634 | if (attrs.hasAttribute("PrintEngine")) |
||
1635 | doc->Print_Options.prnEngine = (PrintEngine) attrs.valueAsInt("PrintEngine", 3); |
||
1636 | else |
||
1637 | doc->Print_Options.prnEngine = (PrintEngine) attrs.valueAsInt("PSLevel", 3); |
||
17401 | jghali | 1638 | doc->Print_Options.markLength = attrs.valueAsDouble("markLength"); |
13710 | jghali | 1639 | doc->Print_Options.markOffset = attrs.valueAsDouble("markOffset"); |
1640 | doc->Print_Options.bleeds.Top = attrs.valueAsDouble("BleedTop"); |
||
1641 | doc->Print_Options.bleeds.Left = attrs.valueAsDouble("BleedLeft"); |
||
1642 | doc->Print_Options.bleeds.Right = attrs.valueAsDouble("BleedRight"); |
||
1643 | doc->Print_Options.bleeds.Bottom = attrs.valueAsDouble("BleedBottom"); |
||
1644 | doc->Print_Options.printer = attrs.valueAsString("printer"); |
||
1645 | doc->Print_Options.filename = attrs.valueAsString("filename"); |
||
1646 | doc->Print_Options.separationName = attrs.valueAsString("separationName"); |
||
1647 | doc->Print_Options.printerCommand = attrs.valueAsString("printerCommand"); |
||
1648 | doc->Print_Options.copies = 1; |
||
1649 | |||
1650 | QStringRef tagName = reader.name(); |
||
1651 | while(!reader.atEnd() && !reader.hasError()) |
||
1652 | { |
||
1653 | ScXmlStreamReader::TokenType tType = reader.readNext(); |
||
1654 | QStringRef tName = reader.name(); |
||
1655 | if (tType == ScXmlStreamReader::StartElement && tName == "Separation") |
||
1656 | doc->Print_Options.allSeparations.append(reader.attributes().value("Name").toString()); |
||
1657 | if (tType == ScXmlStreamReader::EndElement && tName == tagName) |
||
1658 | break; |
||
1659 | } |
||
1660 | return !reader.hasError(); |
||
1661 | } |
||
1662 | |||
1663 | bool Scribus134Format::readDocItemAttributes(ScribusDoc *doc, ScXmlStreamReader& reader) |
||
1664 | { |
||
1665 | QStringRef tagName = reader.name(); |
||
14927 | cbradney | 1666 | doc->clearItemAttributes(); |
13710 | jghali | 1667 | while(!reader.atEnd() && !reader.hasError()) |
1668 | { |
||
13713 | jghali | 1669 | reader.readNext(); |
13710 | jghali | 1670 | if (reader.isEndElement() && reader.name() == tagName) |
1671 | break; |
||
1672 | if(reader.isStartElement() && reader.name() == "ItemAttribute") |
||
1673 | { |
||
1674 | ScXmlStreamAttributes attrs = reader.scAttributes(); |
||
1675 | ObjectAttribute objattr; |
||
1676 | objattr.name = attrs.valueAsString("Name"); |
||
1677 | objattr.type = attrs.valueAsString("Type"); |
||
1678 | objattr.value = attrs.valueAsString("Value"); |
||
1679 | objattr.parameter = attrs.valueAsString("Parameter"); |
||
1680 | objattr.relationship = attrs.valueAsString("Relationship"); |
||
1681 | objattr.relationshipto = attrs.valueAsString("RelationshipTo"); |
||
1682 | objattr.autoaddto = attrs.valueAsString("AutoAddTo"); |
||
14927 | cbradney | 1683 | doc->appendToItemAttributes(objattr); |
13710 | jghali | 1684 | } |
1685 | } |
||
1686 | return !reader.hasError(); |
||
1687 | } |
||
1688 | |||
1689 | bool Scribus134Format::readTableOfContents(ScribusDoc* doc, ScXmlStreamReader& reader) |
||
1690 | { |
||
1691 | QStringRef tagName = reader.name(); |
||
14927 | cbradney | 1692 | m_Doc->clearTocSetups(); |
13710 | jghali | 1693 | while(!reader.atEnd() && !reader.hasError()) |
1694 | { |
||
13713 | jghali | 1695 | reader.readNext(); |
13710 | jghali | 1696 | if (reader.isEndElement() && reader.name() == tagName) |
1697 | break; |
||
1698 | if(reader.isStartElement() && reader.name() == "TableOfContents") |
||
1699 | { |
||
1700 | ScXmlStreamAttributes attrs = reader.scAttributes(); |
||
1701 | ToCSetup tocsetup; |
||
1702 | tocsetup.name = attrs.valueAsString("Name"); |
||
1703 | tocsetup.itemAttrName = attrs.valueAsString("ItemAttributeName"); |
||
1704 | tocsetup.frameName = attrs.valueAsString("FrameName"); |
||
1705 | tocsetup.textStyle = attrs.valueAsString("Style"); |
||
1706 | tocsetup.listNonPrintingFrames = QVariant(attrs.valueAsString("ListNonPrinting")).toBool(); |
||
1707 | QString numberPlacement = attrs.valueAsString("NumberPlacement"); |
||
1708 | if (numberPlacement == "Beginning") |
||
1709 | tocsetup.pageLocation = Beginning; |
||
1710 | if (numberPlacement == "End") |
||
1711 | tocsetup.pageLocation = End; |
||
1712 | if (numberPlacement == "NotShown") |
||
1713 | tocsetup.pageLocation = NotShown; |
||
14927 | cbradney | 1714 | doc->appendToTocSetups(tocsetup); |
13710 | jghali | 1715 | } |
1716 | } |
||
1717 | return !reader.hasError(); |
||
1718 | } |
||
1719 | |||
1720 | bool Scribus134Format::readSections(ScribusDoc* doc, ScXmlStreamReader& reader) |
||
1721 | { |
||
1722 | QStringRef tagName = reader.name(); |
||
1723 | while(!reader.atEnd() && !reader.hasError()) |
||
1724 | { |
||
13713 | jghali | 1725 | reader.readNext(); |
13710 | jghali | 1726 | if (reader.isEndElement() && reader.name() == tagName) |
1727 | break; |
||
1728 | if (reader.isStartElement() && reader.name() == "Section") |
||
1729 | { |
||
1730 | ScXmlStreamAttributes attrs = reader.scAttributes(); |
||
1731 | struct DocumentSection newSection; |
||
1732 | newSection.number = attrs.valueAsInt("Number"); |
||
1733 | newSection.name = attrs.valueAsString("Name"); |
||
1734 | newSection.fromindex = attrs.valueAsInt("From"); |
||
1735 | newSection.toindex = attrs.valueAsInt("To"); |
||
1736 | QString type = attrs.valueAsString("Type"); |
||
1737 | if (type == "Type_1_2_3") |
||
1738 | newSection.type=Type_1_2_3; |
||
1739 | if (type == "Type_i_ii_iii") |
||
1740 | newSection.type=Type_i_ii_iii; |
||
1741 | if (type == "Type_I_II_III") |
||
1742 | newSection.type=Type_I_II_III; |
||
1743 | if (type == "Type_a_b_c") |
||
1744 | newSection.type=Type_a_b_c; |
||
1745 | if (type == "Type_A_B_C") |
||
1746 | newSection.type=Type_A_B_C; |
||
1747 | if (type == "Type_None") |
||
1748 | newSection.type=Type_None; |
||
1749 | newSection.sectionstartindex = attrs.valueAsInt("Start"); |
||
1750 | newSection.reversed = attrs.valueAsBool("Reversed"); |
||
1751 | newSection.active = attrs.valueAsBool("Active"); |
||
16697 | jghali | 1752 | newSection.pageNumberWidth = 0; |
15037 | cbradney | 1753 | doc->sections().insert(newSection.number, newSection); |
13710 | jghali | 1754 | } |
1755 | } |
||
1756 | return !reader.hasError(); |
||
1757 | } |
||
1758 | |||
1759 | bool Scribus134Format::readHyphen(ScribusDoc *doc, ScXmlStreamReader& reader) |
||
1760 | { |
||
1761 | QStringRef tagName = reader.name(); |
||
1762 | while(!reader.atEnd() && !reader.hasError()) |
||
1763 | { |
||
13713 | jghali | 1764 | reader.readNext(); |
13710 | jghali | 1765 | if (reader.isEndElement() && reader.name() == tagName) |
1766 | break; |
||
1767 | if (reader.isStartElement() && reader.name() == "EXCEPTION") |
||
1768 | { |
||
1769 | ScXmlStreamAttributes attrs = reader.scAttributes(); |
||
1770 | QString word = attrs.valueAsString("WORD"); |
||
1771 | QString hyph = attrs.valueAsString("HYPHENATED"); |
||
1772 | doc->docHyphenator->specialWords.insert(word, hyph); |
||
1773 | } |
||
1774 | else if (reader.isStartElement() && reader.name() == "IGNORE") |
||
1775 | { |
||
1776 | ScXmlStreamAttributes attrs = reader.scAttributes(); |
||
1777 | QString word = attrs.valueAsString("WORD"); |
||
1778 | doc->docHyphenator->ignoredWords.insert(word); |
||
1779 | } |
||
1780 | } |
||
1781 | return !reader.hasError(); |
||
1782 | } |
||
1783 | |||
1784 | bool Scribus134Format::readPage(ScribusDoc* doc, ScXmlStreamReader& reader) |
||
1785 | { |
||
1786 | QStringRef tagName = reader.name(); |
||
1787 | |||
1788 | ScXmlStreamAttributes attrs = reader.scAttributes(); |
||
1789 | int pageNum = attrs.valueAsInt("NUM"); |
||
1790 | QString pageName = attrs.valueAsString("NAM", ""); |
||
1791 | if (tagName == "MASTERPAGE" && pageName.isEmpty()) |
||
1792 | { |
||
1793 | qDebug() << "scribus134format: corrupted masterpage with empty name detected"; |
||
1794 | return true; |
||
1795 | } |
||
1796 | m_Doc->setMasterPageMode(!pageName.isEmpty()); |
||
16729 | fschmid | 1797 | ScPage* newPage = pageName.isEmpty() ? doc->addPage(pageNum) : doc->addMasterPage(pageNum, pageName); |
13710 | jghali | 1798 | |
1799 | newPage->LeftPg = attrs.valueAsInt("LEFT", 0); |
||
1800 | QString mpName = attrs.valueAsString("MNAM", "Normal"); |
||
1801 | newPage->MPageNam = m_Doc->masterPageMode() ? QString("") : mpName; |
||
1802 | if (attrs.hasAttribute("Size")) |
||
1803 | newPage->m_pageSize = attrs.valueAsString("Size"); |
||
1804 | if (attrs.hasAttribute("Orientation")) |
||
13731 | cbradney | 1805 | newPage->setOrientation(attrs.valueAsInt("Orientation")); |
13710 | jghali | 1806 | newPage->setXOffset(attrs.valueAsDouble("PAGEXPOS")); |
1807 | newPage->setYOffset(attrs.valueAsDouble("PAGEYPOS")); |
||
1808 | if (attrs.hasAttribute("PAGEWIDTH")) |
||
1809 | newPage->setWidth(attrs.valueAsDouble("PAGEWIDTH")); |
||
1810 | else |
||
1811 | newPage->setWidth(attrs.valueAsDouble("PAGEWITH")); |
||
1812 | newPage->setHeight(attrs.valueAsDouble("PAGEHEIGHT")); |
||
1813 | newPage->setInitialHeight(newPage->height()); |
||
1814 | newPage->setInitialWidth(newPage->width()); |
||
1815 | newPage->initialMargins.Top = qMax(0.0, attrs.valueAsDouble("BORDERTOP")); |
||
1816 | newPage->initialMargins.Bottom = qMax(0.0, attrs.valueAsDouble("BORDERBOTTOM")); |
||
1817 | newPage->initialMargins.Left = qMax(0.0, attrs.valueAsDouble("BORDERLEFT")); |
||
1818 | newPage->initialMargins.Right = qMax(0.0, attrs.valueAsDouble("BORDERRIGHT")); |
||
1819 | newPage->marginPreset = attrs.valueAsInt("PRESET", 0); |
||
1820 | newPage->Margins.Top = newPage->initialMargins.Top; |
||
1821 | newPage->Margins.Bottom = newPage->initialMargins.Bottom; |
||
1822 | m_Doc->setMasterPageMode(false); |
||
1823 | //m_Doc->Pages=&m_Doc->DocPages; |
||
1824 | // guides reading |
||
1825 | newPage->guides.setHorizontalAutoGap( attrs.valueAsDouble("AGhorizontalAutoGap", 0.0)); |
||
1826 | newPage->guides.setVerticalAutoGap ( attrs.valueAsDouble("AGverticalAutoGap", 0.0)); |
||
1827 | newPage->guides.setHorizontalAutoCount( attrs.valueAsInt("AGhorizontalAutoCount", 0) ); |
||
1828 | newPage->guides.setVerticalAutoCount ( attrs.valueAsInt("AGverticalAutoCount", 0) ); |
||
1829 | newPage->guides.setHorizontalAutoRefer( attrs.valueAsInt("AGhorizontalAutoRefer", 0) ); |
||
1830 | newPage->guides.setVerticalAutoRefer ( attrs.valueAsInt("AGverticalAutoRefer", 0) ); |
||
1831 | GuideManagerIO::readVerticalGuides(attrs.valueAsString("VerticalGuides"), |
||
1832 | newPage, |
||
1833 | GuideManagerCore::Standard, |
||
1834 | attrs.hasAttribute("NumVGuides")); |
||
1835 | GuideManagerIO::readHorizontalGuides(attrs.valueAsString("HorizontalGuides"), |
||
1836 | newPage, |
||
1837 | GuideManagerCore::Standard, |
||
1838 | attrs.hasAttribute("NumHGuides")); |
||
1839 | GuideManagerIO::readSelection(attrs.valueAsString("AGSelection"), newPage); |
||
14733 | jghali | 1840 | |
1841 | newPage->guides.addHorizontals(newPage->guides.getAutoHorizontals(newPage), GuideManagerCore::Auto); |
||
1842 | newPage->guides.addVerticals(newPage->guides.getAutoVerticals(newPage), GuideManagerCore::Auto); |
||
13710 | jghali | 1843 | return true; |
1844 | } |
||
1845 | |||
1846 | bool Scribus134Format::readObject(ScribusDoc* doc, ScXmlStreamReader& reader, ItemInfo& info, const QString& baseDir, bool loadPage) |
||
1847 | { |
||
1848 | QStringRef tagName = reader.name(); |
||
1849 | ScXmlStreamAttributes attrs = reader.scAttributes(); |
||
1850 | |||
1851 | if (!loadPage) |
||
1852 | { |
||
13888 | jghali | 1853 | if (tagName == "PAGEOBJECT" || tagName =="FRAMEOBJECT" || tagName =="PatternItem") |
13710 | jghali | 1854 | doc->setMasterPageMode(false); |
1855 | else |
||
1856 | doc->setMasterPageMode(true); |
||
1857 | } |
||
13713 | jghali | 1858 | int pagenr = -1; |
13710 | jghali | 1859 | if ((!attrs.value("OnMasterPage").isEmpty()) && (tagName == "MASTEROBJECT")) |
1860 | { |
||
1861 | doc->setCurrentPage(doc->MasterPages.at(doc->MasterNames[attrs.valueAsString("OnMasterPage")])); |
||
1862 | pagenr = -2; |
||
1863 | } |
||
1864 | |||
1865 | PageItem* newItem = pasteItem(doc, attrs, baseDir, pagenr); |
||
1866 | newItem->setRedrawBounding(); |
||
1867 | if (tagName == "MASTEROBJECT") |
||
1868 | newItem->OwnPage = doc->OnPage(newItem); |
||
1869 | else |
||
1870 | newItem->OwnPage = attrs.valueAsInt("OwnPage"); |
||
1871 | if (tagName == "PAGEOBJECT") |
||
1872 | newItem->OnMasterPage = ""; |
||
14932 | cbradney | 1873 | QString tmpf = attrs.valueAsString("IFONT", doc->itemToolPrefs().textFont); |
13710 | jghali | 1874 | m_AvailableFonts->findFont(tmpf, doc); |
1875 | |||
1876 | // newItem->Language = ScMW->GetLang(pg.attribute("LANGUAGE", doc->Language)); |
||
1877 | newItem->isAutoText = attrs.valueAsBool("AUTOTEXT", false); |
||
1878 | newItem->isEmbedded = attrs.valueAsBool("isInline", false); |
||
1879 | newItem->gXpos = attrs.valueAsDouble("gXpos", 0.0); |
||
1880 | newItem->gYpos = attrs.valueAsDouble("gYpos", 0.0); |
||
1881 | newItem->gWidth = attrs.valueAsDouble("gWidth", newItem->width()); |
||
1882 | newItem->gHeight = attrs.valueAsDouble("gHeight", newItem->height()); |
||
1883 | if (newItem->isAutoText) |
||
1884 | doc->LastAuto = newItem; |
||
1885 | |||
1886 | if (tagName == "FRAMEOBJECT") |
||
1887 | { |
||
17407 | fschmid | 1888 | doc->addToInlineFrames(doc->Items->takeAt(doc->Items->indexOf(newItem))); |
18363 | fschmid | 1889 | newItem->LayerID = doc->firstLayerID(); |
13710 | jghali | 1890 | } |
1891 | |||
1892 | info.item = newItem; |
||
1893 | info.nextItem = attrs.valueAsInt("NEXTITEM", -1); |
||
1894 | info.ownLink = newItem->isTableItem ? attrs.valueAsInt("OwnLINK", 0) : 0; |
||
1895 | info.groupLastItem = 0; |
||
16943 | fschmid | 1896 | info.ownNr = doc->Items->indexOf(newItem); |
13710 | jghali | 1897 | |
16113 | fschmid | 1898 | info.isGroupFlag = attrs.valueAsBool("isGroupControl", 0); |
1899 | if (info.isGroupFlag) |
||
1900 | info.groupLastItem = attrs.valueAsInt("groupsLastItem", 0); |
||
13710 | jghali | 1901 | |
14450 | fschmid | 1902 | bool layerFound = false; |
13710 | jghali | 1903 | struct ImageLoadRequest loadingInfo; |
1904 | QList<ParagraphStyle::TabRecord> tabValues; |
||
1905 | |||
1906 | LastStyles * lastStyle = new LastStyles(); |
||
1907 | while(!reader.atEnd() && !reader.hasError()) |
||
1908 | { |
||
1909 | ScXmlStreamReader::TokenType tType = reader.readNext(); |
||
1910 | if (reader.isEndElement() && tagName == reader.name()) |
||
1911 | break; |
||
1912 | if (tType != ScXmlStreamReader::StartElement) |
||
1913 | continue; |
||
1914 | QStringRef tName = reader.name(); |
||
1915 | ScXmlStreamAttributes tAtt = reader.scAttributes(); |
||
1916 | if (tName == "CSTOP") |
||
1917 | { |
||
1918 | QString name = tAtt.valueAsString("NAME"); |
||
1919 | double ramp = tAtt.valueAsDouble("RAMP", 0.0); |
||
1920 | int shade = tAtt.valueAsInt("SHADE", 100); |
||
1921 | double opa = tAtt.valueAsDouble("TRANS", 1.0); |
||
1922 | newItem->fill_gradient.addStop(SetColor(doc, name, shade), ramp, 0.5, opa, name, shade); |
||
1923 | } |
||
1924 | |||
1925 | if (tName == "ITEXT") |
||
1926 | readItemText(newItem, tAtt, lastStyle); |
||
1927 | else if (tName == "para") |
||
1928 | { |
||
1929 | newItem->itemText.insertChars(newItem->itemText.length(), SpecialChars::PARSEP); |
||
1930 | ParagraphStyle newStyle; |
||
16729 | fschmid | 1931 | // PrefsManager* prefsManager = PrefsManager::instance(); |
16531 | jghali | 1932 | readParagraphStyle(doc, reader, newStyle); |
13710 | jghali | 1933 | newItem->itemText.setStyle(newItem->itemText.length()-1, newStyle); |
1934 | newItem->itemText.setCharStyle(newItem->itemText.length()-1, 1, lastStyle->Style); |
||
1935 | } |
||
14483 | jghali | 1936 | else if (tName == "trail") |
1937 | { |
||
1938 | ParagraphStyle newStyle; |
||
16729 | fschmid | 1939 | // PrefsManager* prefsManager = PrefsManager::instance(); |
16531 | jghali | 1940 | readParagraphStyle(doc, reader, newStyle); |
14483 | jghali | 1941 | newItem->itemText.setStyle(newItem->itemText.length(), newStyle); |
1942 | } |
||
13710 | jghali | 1943 | else if (tName == "tab") |
13971 | jghali | 1944 | { |
1945 | CharStyle newStyle; |
||
13710 | jghali | 1946 | newItem->itemText.insertChars(newItem->itemText.length(), SpecialChars::TAB); |
13971 | jghali | 1947 | readCharacterStyleAttrs(doc, tAtt, newStyle); |
1948 | newItem->itemText.setCharStyle(newItem->itemText.length( |