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