Rev 4084 | Rev 4201 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1525 | cbradney | 1 | #include <qdom.h> |
506 | fschmid | 2 | #include <qfile.h> |
3 | #include <qfileinfo.h> |
||
517 | fschmid | 4 | #include <qtl.h> |
5 | #include <qcursor.h> |
||
6 | #include <qregexp.h> |
||
7 | #include <qdir.h> |
||
8 | #include <qtextcodec.h> |
||
1525 | cbradney | 9 | #include <qcheckbox.h> |
3650 | cbradney | 10 | #include <qmessagebox.h> |
11 | #include <qprogressbar.h> |
||
517 | fschmid | 12 | #include <cstdlib> |
13 | #include <cmath> |
||
14 | #include <qtextstream.h> |
||
3650 | cbradney | 15 | |
16 | #include "commonstrings.h" |
||
838 | cbradney | 17 | #include "fileloader.h" |
3827 | cbradney | 18 | #include "fileloader.moc" |
3650 | cbradney | 19 | #include "fontreplacedialog.h" |
517 | fschmid | 20 | #include "missing.h" |
3670 | cbradney | 21 | #include "page.h" |
1549 | subik | 22 | #include "pluginmanager.h" |
2445 | cbradney | 23 | #include "pagestructs.h" |
2688 | craig | 24 | #include "scconfig.h" |
3650 | cbradney | 25 | #include "scribus.h" |
26 | #include "scribusXml.h" |
||
27 | #include "units.h" |
||
3696 | craig | 28 | #include "loadsaveplugin.h" |
3650 | cbradney | 29 | |
4024 | craig | 30 | // We need to include the headers for the plugins we support until we start |
31 | // using LoadSavePlugin to pick them for us. We only use these headers to |
||
32 | // get the format IDs, NOTHING ELSE. |
||
33 | #include "plugins/svgimplugin/svgplugin.h" |
||
34 | #include "plugins/psimport/importpsplugin.h" |
||
35 | #include "plugins/fileloader/oodraw/oodrawimp.h" |
||
36 | |||
506 | fschmid | 37 | #ifdef HAVE_LIBZ |
38 | #include <zlib.h> |
||
39 | #endif |
||
2531 | craig | 40 | #include "util.h" |
2834 | cbradney | 41 | #include "prefsmanager.h" |
506 | fschmid | 42 | |
43 | /*! |
||
3644 | craig | 44 | \fn FileLoader::FileLoader(QString fileName) |
506 | fschmid | 45 | \author Franz Schmid |
46 | \date |
||
47 | \brief Constructor, sets the variable "FileName" to the input parameter fileName |
||
48 | \param QString fileName |
||
49 | \retval None |
||
50 | */ |
||
3644 | craig | 51 | FileLoader::FileLoader(const QString & fileName) : |
4024 | craig | 52 | QObject(0, "FileLoader"), |
53 | FileName(fileName), |
||
54 | FileType(-1), |
||
55 | formatPS(LoadSavePlugin::getFormatById(FORMATID_PSIMPORT)), |
||
56 | formatSVG(LoadSavePlugin::getFormatById(FORMATID_SVGIMPORT)), |
||
57 | formatSXD(LoadSavePlugin::getFormatById(FORMATID_SXDIMPORT)), |
||
58 | formatODG(LoadSavePlugin::getFormatById(FORMATID_ODGIMPORT)), |
||
59 | prefsManager(PrefsManager::instance()) |
||
506 | fschmid | 60 | { |
61 | } |
||
62 | |||
3644 | craig | 63 | // FIXME: This static method is here as a temporary transitional |
64 | // measure during the process of converting to file loader plugins. |
||
65 | const QString FileLoader::getLoadFilterString() |
||
66 | { |
||
3696 | craig | 67 | /* |
3644 | craig | 68 | PluginManager& pluginManager(PluginManager::instance()); |
69 | QString formats; |
||
70 | #ifdef HAVE_LIBZ |
||
71 | formats += tr("Documents (*.sla *.sla.gz *.scd *.scd.gz);;"); |
||
72 | #else |
||
73 | formats += tr("Documents (*.sla *.scd);;"); |
||
74 | #endif |
||
75 | if (pluginManager.DLLexists("importps")) |
||
76 | formats += tr("PostScript Files (*.eps *.EPS *.ps *.PS);;"); |
||
77 | if (pluginManager.DLLexists("svgimplugin")) |
||
78 | #ifdef HAVE_LIBZ |
||
79 | formats += tr("SVG Images (*.svg *.svgz);;"); |
||
80 | #else |
||
81 | formats += tr("SVG Images (*.svg);;"); |
||
82 | #endif |
||
83 | if (pluginManager.DLLexists("oodrawimp")) |
||
84 | formats += tr("OpenOffice.org Draw (*.sxd);;"); |
||
85 | formats += tr("All Files (*)"); |
||
86 | return formats; |
||
3696 | craig | 87 | */ |
88 | return LoadSavePlugin::fileDialogLoadFilter().join(";;"); |
||
3644 | craig | 89 | } |
90 | |||
506 | fschmid | 91 | /*! |
92 | \fn int FileLoader::TestFile() |
||
93 | \author Franz Schmid |
||
94 | \date |
||
95 | \brief Tests if the file "FileName" exists and determines the type of the file. |
||
96 | \param None |
||
97 | \retval int -1 if the file doesn't exist or any other error has occured, 0 for the old Format, 1 for the new Format, 2 for EPS and PS files, 3 for SVG files and 4 for PDF files |
||
98 | */ |
||
99 | int FileLoader::TestFile() |
||
100 | { |
||
101 | QFileInfo fi = QFileInfo(FileName); |
||
102 | int ret = -1; |
||
103 | if (!fi.exists()) |
||
104 | ret = -1; |
||
105 | QString ext = fi.extension(true).lower(); |
||
550 | fschmid | 106 | if ((ext.endsWith("sla.gz")) || (ext.endsWith("sla")) || (ext.endsWith("scd.gz")) || (ext.endsWith("scd"))) |
506 | fschmid | 107 | ret = CheckScribus(); |
4024 | craig | 108 | else if (((ext.endsWith("ps")) || (ext.endsWith("eps"))) && (formatPS)) |
506 | fschmid | 109 | ret = 2; |
4024 | craig | 110 | else if (((ext.endsWith("svg")) || (ext.endsWith("svgz"))) && (formatSVG)) |
506 | fschmid | 111 | ret = 3; |
4024 | craig | 112 | else if ((ext.endsWith("sxd")) && (formatSXD)) |
541 | fschmid | 113 | ret = 5; |
4024 | craig | 114 | else if ((ext.endsWith("odg")) && (formatODG)) |
115 | ret = 6; |
||
506 | fschmid | 116 | /* if (ext == "pdf") |
117 | ret = 4; */ |
||
118 | FileType = ret; |
||
119 | return ret; |
||
120 | } |
||
121 | |||
122 | /*! |
||
123 | \fn int FileLoader::CheckScribus() |
||
124 | \author Franz Schmid |
||
125 | \date |
||
126 | \brief Checks which Scribus fileformat the File in FileName has. |
||
127 | \param None |
||
128 | \retval 0 for old Scribus files, 1 for Scribus files created by Scribus 1.3 and above |
||
129 | */ |
||
130 | int FileLoader::CheckScribus() |
||
131 | { |
||
132 | int ret = -1; |
||
3646 | craig | 133 | QString fText(readSLA(FileName)); |
2877 | cbradney | 134 | if (fText.isEmpty()) |
506 | fschmid | 135 | return ret; |
2680 | cbradney | 136 | if ((fText.startsWith("<SCRIBUSUTF8NEW")) && (fText.contains("<PAGE ", true) != 0)) |
517 | fschmid | 137 | return 1; |
2680 | cbradney | 138 | if ((fText.startsWith("<SCRIBUS")) && (fText.contains("<PAGE ", true) != 0)) |
506 | fschmid | 139 | return 0; |
140 | return ret; |
||
141 | } |
||
142 | |||
143 | /*! |
||
3646 | craig | 144 | \fn QString FileLoader::readSLA(QString fileName) |
506 | fschmid | 145 | \author Franz Schmid |
146 | \date |
||
3646 | craig | 147 | \brief Auxiliary function loads the file "fileName" into a QString, taking care of any encoding issues |
506 | fschmid | 148 | \param QString fileName |
3646 | craig | 149 | \retval QString Contents of the file |
150 | |||
151 | Note that this method will use the system text encoding when loading .sla / |
||
152 | .scd files from before the conversion to utf-8 storage. There is presently no |
||
153 | override for the encoding used. |
||
506 | fschmid | 154 | */ |
3646 | craig | 155 | QString FileLoader::readSLA(const QString & fileName) |
506 | fschmid | 156 | { |
3646 | craig | 157 | QCString docBytes(""); |
506 | fschmid | 158 | if(fileName.right(2) == "gz") |
159 | { |
||
3646 | craig | 160 | #ifdef HAVE_LIBZ |
3968 | craig | 161 | static const int gzipExpansionFactor=8; |
162 | // The file is gzip encoded and we can load gzip files. |
||
3646 | craig | 163 | /** |
164 | * added to support gz docs |
||
165 | * 2.7.2002 C.Toepp |
||
166 | * <c.toepp@gmx.de> |
||
167 | */ |
||
3968 | craig | 168 | // Set up to read the gzip file |
506 | fschmid | 169 | gzFile gzDoc; |
170 | int i; |
||
171 | gzDoc = gzopen(fileName.latin1(),"rb"); |
||
172 | if(gzDoc == NULL) |
||
3968 | craig | 173 | { |
174 | // FIXME: Needs better error return |
||
506 | fschmid | 175 | return ""; |
3968 | craig | 176 | } |
177 | // Allocate a buffer of a multiple of the compressed size of the file |
||
178 | // as a starting point for loading. We'll expand this buffer by powers |
||
179 | // of two if we run out of space. |
||
180 | const QFileInfo fi(fileName); |
||
181 | uint bufSize = fi.size()*gzipExpansionFactor; |
||
182 | docBytes = QCString(bufSize); |
||
183 | char* buf = docBytes.data(); |
||
184 | uint bytesRead = 0; |
||
185 | // While there's free space, read into the buffer.... |
||
186 | while ((i = gzread(gzDoc,buf,bufSize-bytesRead-1)) > 0) |
||
506 | fschmid | 187 | { |
3968 | craig | 188 | // Ensure the string is null-terminated and move the |
189 | // write pointer to the current position. |
||
190 | buf[i]=0; |
||
191 | buf+=i; |
||
192 | bytesRead += i; |
||
193 | // And check that there's free space to work with, expanding the |
||
194 | // buffer if there's not. |
||
195 | if (bufSize - bytesRead < 4096) |
||
196 | { |
||
197 | bufSize *= 2; |
||
198 | docBytes.resize(bufSize); |
||
199 | buf = docBytes.data() + bytesRead; |
||
200 | } |
||
506 | fschmid | 201 | } |
202 | gzclose(gzDoc); |
||
3646 | craig | 203 | #else |
204 | // The file is gzip encoded but we can't load gzip files. |
||
205 | // Leave `f' empty, since we have no way to |
||
206 | // report a failure condition from here. |
||
207 | #endif |
||
506 | fschmid | 208 | } |
209 | else |
||
3968 | craig | 210 | { |
3646 | craig | 211 | // Not gzip encoded, just load it |
212 | loadRawText(fileName, docBytes); |
||
3968 | craig | 213 | } |
3646 | craig | 214 | QString docText(""); |
215 | if (docBytes.left(12) == "<SCRIBUSUTF8") |
||
216 | docText = QString::fromUtf8(docBytes); |
||
217 | else if (docBytes.left(8) == "<SCRIBUS") |
||
218 | docText = QString::fromLocal8Bit(docBytes); |
||
219 | if (docText.endsWith(QChar(10)) || docText.endsWith(QChar(13))) |
||
220 | docText.truncate(docText.length()-1); |
||
221 | return docText; |
||
506 | fschmid | 222 | } |
223 | |||
3644 | craig | 224 | bool FileLoader::LoadPage(int PageToLoad, bool Mpage) |
3197 | fschmid | 225 | { |
226 | bool ret = false; |
||
227 | newReplacement = false; |
||
228 | ReplacedFonts.clear(); |
||
229 | dummyFois.clear(); |
||
230 | dummyFois.setAutoDelete(true); |
||
231 | switch (FileType) |
||
232 | { |
||
233 | case 0: |
||
234 | { |
||
235 | ScriXmlDoc *ss = new ScriXmlDoc(); |
||
236 | ss->ReplacedFonts.clear(); |
||
237 | ss->newReplacement = false; |
||
238 | ss->dummyFois.clear(); |
||
4026 | craig | 239 | ret = ss->ReadPage(FileName, prefsManager->appPrefs.AvailFonts, ScMW->doc, ScMW->view, PageToLoad, Mpage); |
3197 | fschmid | 240 | ReplacedFonts = ss->ReplacedFonts; |
241 | newReplacement = ss->newReplacement; |
||
242 | dummyFois = ss->dummyFois; |
||
243 | delete ss; |
||
244 | } |
||
245 | break; |
||
246 | case 1: |
||
4026 | craig | 247 | ret = ReadPage(FileName, prefsManager->appPrefs.AvailFonts, ScMW->doc, PageToLoad, Mpage); |
3197 | fschmid | 248 | break; |
249 | default: |
||
250 | ret = false; |
||
251 | break; |
||
252 | } |
||
253 | if (ReplacedFonts.count() != 0) |
||
254 | { |
||
255 | if ((prefsManager->appPrefs.askBeforeSubstituite) || (newReplacement)) |
||
256 | { |
||
257 | qApp->setOverrideCursor(QCursor(Qt::arrowCursor), true); |
||
258 | FontReplaceDialog *dia = new FontReplaceDialog(0, &ReplacedFonts); |
||
259 | if (dia->exec()) |
||
260 | { |
||
261 | QMap<QString,QString>::Iterator itfsu; |
||
262 | for (itfsu = ReplacedFonts.begin(); itfsu != ReplacedFonts.end(); ++itfsu) |
||
263 | { |
||
264 | if (dia->stickyReplacements->isChecked()) |
||
265 | prefsManager->appPrefs.GFontSub[itfsu.key()] = itfsu.data(); |
||
266 | } |
||
267 | delete dia; |
||
268 | } |
||
269 | else |
||
270 | { |
||
271 | delete dia; |
||
272 | return false; |
||
273 | } |
||
274 | } |
||
4026 | craig | 275 | for (uint d = 0; d < ScMW->doc->MasterItems.count(); ++d) |
3197 | fschmid | 276 | { |
4026 | craig | 277 | PageItem *it = ScMW->doc->MasterItems.at(d); |
4073 | cbradney | 278 | if ((!ScMW->doc->UsedFonts.contains(it->font())) && (!it->font().isEmpty())) |
279 | it->setFont(ReplacedFonts[it->font()]); |
||
3625 | avox | 280 | if ((it->asTextFrame()) || (it->asPathText())) |
3197 | fschmid | 281 | { |
282 | for (uint e = 0; e < it->itemText.count(); ++e) |
||
283 | { |
||
4026 | craig | 284 | if (!ScMW->doc->UsedFonts.contains(it->itemText.at(e)->cfont->scName())) |
285 | it->itemText.at(e)->cfont = (*ScMW->doc->AllFonts)[ReplacedFonts[it->itemText.at(e)->cfont->scName()]]; |
||
3197 | fschmid | 286 | } |
287 | } |
||
288 | } |
||
4026 | craig | 289 | for (uint d = 0; d < ScMW->doc->DocItems.count(); ++d) |
3197 | fschmid | 290 | { |
4026 | craig | 291 | PageItem *it = ScMW->doc->DocItems.at(d); |
4073 | cbradney | 292 | if ((!ScMW->doc->UsedFonts.contains(it->font())) && (!it->font().isEmpty())) |
293 | it->setFont(ReplacedFonts[it->font()]); |
||
3625 | avox | 294 | if ((it->asTextFrame()) || (it->asPathText())) |
3197 | fschmid | 295 | { |
296 | for (uint e = 0; e < it->itemText.count(); ++e) |
||
297 | { |
||
4026 | craig | 298 | if (!ScMW->doc->UsedFonts.contains(it->itemText.at(e)->cfont->scName())) |
299 | it->itemText.at(e)->cfont = (*ScMW->doc->AllFonts)[ReplacedFonts[it->itemText.at(e)->cfont->scName()]]; |
||
3197 | fschmid | 300 | } |
301 | } |
||
302 | } |
||
4026 | craig | 303 | for (uint d = 0; d < ScMW->doc->FrameItems.count(); ++d) |
3197 | fschmid | 304 | { |
4026 | craig | 305 | PageItem *it = ScMW->doc->FrameItems.at(d); |
4073 | cbradney | 306 | if ((!ScMW->doc->UsedFonts.contains(it->font())) && (!it->font().isEmpty())) |
307 | it->setFont(ReplacedFonts[it->font()]); |
||
3625 | avox | 308 | if ((it->asTextFrame()) || (it->asPathText())) |
3197 | fschmid | 309 | { |
310 | for (uint e = 0; e < it->itemText.count(); ++e) |
||
311 | { |
||
4026 | craig | 312 | if (!ScMW->doc->UsedFonts.contains(it->itemText.at(e)->cfont->scName())) |
313 | it->itemText.at(e)->cfont = (*ScMW->doc->AllFonts)[ReplacedFonts[it->itemText.at(e)->cfont->scName()]]; |
||
3197 | fschmid | 314 | } |
315 | } |
||
316 | } |
||
4026 | craig | 317 | for (uint a = 0; a < ScMW->doc->docParagraphStyles.count(); ++a) |
3197 | fschmid | 318 | { |
4026 | craig | 319 | if ((!ScMW->doc->UsedFonts.contains(ScMW->doc->docParagraphStyles[a].Font)) && (!ScMW->doc->docParagraphStyles[a].Font.isEmpty())) |
320 | ScMW->doc->docParagraphStyles[a].Font = ReplacedFonts[ScMW->doc->docParagraphStyles[a].Font]; |
||
3197 | fschmid | 321 | } |
322 | QMap<QString,QString>::Iterator itfsu; |
||
323 | for (itfsu = ReplacedFonts.begin(); itfsu != ReplacedFonts.end(); ++itfsu) |
||
324 | { |
||
4026 | craig | 325 | if (!ScMW->doc->UsedFonts.contains(itfsu.data())) |
3197 | fschmid | 326 | { |
3544 | avox | 327 | // QFont fo = prefsManager->appPrefs.AvailFonts[itfsu.data()]->Font; |
4026 | craig | 328 | // fo.setPointSize(qRound(ScMW->doc->toolSettings.defSize / 10.0)); |
329 | ScMW->doc->AddFont(itfsu.data(), qRound(ScMW->doc->toolSettings.defSize / 10.0)); |
||
3197 | fschmid | 330 | } |
331 | } |
||
332 | if (prefsManager->appPrefs.askBeforeSubstituite) |
||
333 | ReplacedFonts.clear(); |
||
334 | dummyFois.clear(); |
||
335 | } |
||
336 | return ret; |
||
337 | } |
||
338 | |||
506 | fschmid | 339 | /*! |
3644 | craig | 340 | \fn bool FileLoader::LoadFile() |
506 | fschmid | 341 | \author Franz Schmid |
342 | \date |
||
343 | \brief Loads the file "FileName" as a Scribus document |
||
344 | \retval bool true when loading is succsessful, false otherwise |
||
345 | */ |
||
3644 | craig | 346 | bool FileLoader::LoadFile() |
506 | fschmid | 347 | { |
348 | bool ret = false; |
||
1468 | fschmid | 349 | newReplacement = false; |
4026 | craig | 350 | ScMW->doc->guidesSettings.marginsShown = prefsManager->appPrefs.guidesSettings.marginsShown; |
351 | ScMW->doc->guidesSettings.framesShown = prefsManager->appPrefs.guidesSettings.framesShown; |
||
352 | ScMW->doc->guidesSettings.gridShown = prefsManager->appPrefs.guidesSettings.gridShown; |
||
353 | ScMW->doc->guidesSettings.guidesShown = prefsManager->appPrefs.guidesSettings.guidesShown; |
||
354 | ScMW->doc->guidesSettings.baseShown = prefsManager->appPrefs.guidesSettings.baseShown; |
||
355 | ScMW->doc->guidesSettings.linkShown = prefsManager->appPrefs.guidesSettings.linkShown; |
||
356 | ScMW->doc->toolSettings.polyC = prefsManager->appPrefs.toolSettings.polyC; |
||
357 | ScMW->doc->toolSettings.polyF = prefsManager->appPrefs.toolSettings.polyF; |
||
358 | ScMW->doc->toolSettings.polyR = prefsManager->appPrefs.toolSettings.polyR; |
||
359 | ScMW->doc->toolSettings.polyFd = prefsManager->appPrefs.toolSettings.polyFd; |
||
360 | ScMW->doc->toolSettings.polyS = prefsManager->appPrefs.toolSettings.polyS; |
||
361 | ScMW->doc->AutoSave = prefsManager->appPrefs.AutoSave; |
||
362 | ScMW->doc->AutoSaveTime = prefsManager->appPrefs.AutoSaveTime; |
||
1428 | fschmid | 363 | ReplacedFonts.clear(); |
1789 | fschmid | 364 | dummyFois.clear(); |
365 | dummyFois.setAutoDelete(true); |
||
506 | fschmid | 366 | switch (FileType) |
367 | { |
||
368 | case 0: |
||
369 | { |
||
370 | ScriXmlDoc *ss = new ScriXmlDoc(); |
||
3648 | cbradney | 371 | //CB: WTF? We use a slot to make the new pages? hello! |
4026 | craig | 372 | //QObject::connect(ss, SIGNAL(NewPage(int)), ScMW, SLOT(slotNewPage(int))); |
1166 | fschmid | 373 | ss->ReplacedFonts.clear(); |
1468 | fschmid | 374 | ss->newReplacement = false; |
1789 | fschmid | 375 | ss->dummyFois.clear(); |
4026 | craig | 376 | ret = ss->ReadDoc(FileName, prefsManager->appPrefs.AvailFonts, ScMW->doc, ScMW->view, ScMW->mainWindowProgressBar); |
377 | //QObject::disconnect(ss, SIGNAL(NewPage(int)), ScMW, SLOT(slotNewPage(int))); |
||
1166 | fschmid | 378 | ReplacedFonts = ss->ReplacedFonts; |
1468 | fschmid | 379 | newReplacement = ss->newReplacement; |
1789 | fschmid | 380 | dummyFois = ss->dummyFois; |
506 | fschmid | 381 | delete ss; |
382 | } |
||
383 | break; |
||
517 | fschmid | 384 | case 1: |
4026 | craig | 385 | ret = ReadDoc(FileName, prefsManager->appPrefs.AvailFonts, ScMW->doc, ScMW->mainWindowProgressBar); |
517 | fschmid | 386 | break; |
506 | fschmid | 387 | case 2: |
4024 | craig | 388 | ret = formatPS->loadFile(FileName); |
506 | fschmid | 389 | break; |
390 | case 3: |
||
4024 | craig | 391 | ret = formatSVG->loadFile(FileName); |
506 | fschmid | 392 | break; |
541 | fschmid | 393 | case 5: |
4024 | craig | 394 | ret = formatSXD->loadFile(FileName); |
541 | fschmid | 395 | break; |
4024 | craig | 396 | case 6: |
397 | ret = formatODG->loadFile(FileName); |
||
398 | break; |
||
506 | fschmid | 399 | default: |
400 | ret = false; |
||
401 | break; |
||
402 | } |
||
403 | return ret; |
||
404 | } |
||
517 | fschmid | 405 | |
3657 | cbradney | 406 | bool FileLoader::ReadPage(const QString & fileName, SCFonts &avail, ScribusDoc *doc, int PageToLoad, bool Mpage) |
3197 | fschmid | 407 | { |
408 | struct ParagraphStyle vg; |
||
409 | struct Layer la; |
||
410 | struct ScribusDoc::BookMa bok; |
||
411 | PageItem *Neu; |
||
412 | Page* Apage; |
||
413 | LFrames.clear(); |
||
3646 | craig | 414 | QString tmV, tmp, tmpf, tmp2, tmp3, tmp4, PgNam, Defont, tmf; |
3197 | fschmid | 415 | QFont fo; |
416 | QMap<int,int> TableID; |
||
417 | QPtrList<PageItem> TableItems; |
||
418 | int a, counter, baseobj; |
||
419 | double xf, pageX, pageY; |
||
420 | bool newVersion = false; |
||
421 | bool VorLFound = false; |
||
422 | QMap<int,int> layerTrans; |
||
423 | int maxLayer = 0; |
||
424 | int maxLevel = 0; |
||
425 | layerTrans.clear(); |
||
426 | uint layerCount=doc->layerCount(); |
||
427 | for (uint la2 = 0; la2 < layerCount; ++la2) |
||
428 | { |
||
429 | maxLayer = QMAX(doc->Layers[la2].LNr, maxLayer); |
||
430 | maxLevel = QMAX(doc->Layers[la2].Level, maxLevel); |
||
431 | } |
||
432 | DoVorl.clear(); |
||
433 | DoVorl[0] = "0"; |
||
434 | DoVorl[1] = "1"; |
||
435 | DoVorl[2] = "2"; |
||
436 | DoVorl[3] = "3"; |
||
437 | DoVorl[4] = "4"; |
||
438 | VorlC = 5; |
||
439 | QDomDocument docu("scridoc"); |
||
3646 | craig | 440 | QString f(readSLA(fileName)); |
3197 | fschmid | 441 | if (f.isEmpty()) |
442 | return false; |
||
443 | if(!docu.setContent(f)) |
||
444 | return false; |
||
445 | ScColor lf = ScColor(); |
||
446 | QDomElement elem=docu.documentElement(); |
||
447 | if (elem.tagName() != "SCRIBUSUTF8NEW") |
||
448 | return false; |
||
449 | if (elem.hasAttribute("Version")) |
||
450 | newVersion = true; |
||
451 | QDomNode DOC=elem.firstChild(); |
||
3727 | cbradney | 452 | counter = doc->Items->count(); |
3197 | fschmid | 453 | baseobj = counter; |
454 | while(!DOC.isNull()) |
||
455 | { |
||
456 | QDomElement dc=DOC.toElement(); |
||
457 | QDomNode PAGE=DOC.firstChild(); |
||
458 | while(!PAGE.isNull()) |
||
459 | { |
||
460 | QDomElement pg=PAGE.toElement(); |
||
461 | if(pg.tagName()=="COLOR" && pg.attribute("NAME")!="None") |
||
462 | { |
||
463 | if (pg.hasAttribute("CMYK")) |
||
464 | lf.setNamedColor(pg.attribute("CMYK")); |
||
465 | else |
||
466 | lf.fromQColor(QColor(pg.attribute("RGB"))); |
||
467 | if (pg.hasAttribute("Spot")) |
||
4026 | craig | 468 | lf.setSpotColor(static_cast<bool>(pg.attribute("Spot").toInt())); |
3197 | fschmid | 469 | else |
470 | lf.setSpotColor(false); |
||
471 | if (pg.hasAttribute("Register")) |
||
4026 | craig | 472 | lf.setRegistrationColor(static_cast<bool>(pg.attribute("Register").toInt())); |
3197 | fschmid | 473 | else |
474 | lf.setRegistrationColor(false); |
||
475 | doc->PageColors[pg.attribute("NAME")] = lf; |
||
476 | } |
||
477 | if(pg.tagName()=="STYLE") |
||
478 | { |
||
479 | GetStyle(&pg, &vg, doc->docParagraphStyles, doc, true); |
||
480 | VorLFound = true; |
||
481 | } |
||
482 | if(pg.tagName()=="JAVA") |
||
483 | doc->JavaScripts[pg.attribute("NAME")] = pg.attribute("SCRIPT"); |
||
484 | if(pg.tagName()=="LAYERS") |
||
485 | { |
||
4026 | craig | 486 | la.LNr = pg.attribute("NUMMER").toInt(); |
487 | la.Level = pg.attribute("LEVEL").toInt(); |
||
3197 | fschmid | 488 | la.Name = pg.attribute("NAME"); |
4026 | craig | 489 | la.isViewable = pg.attribute("SICHTBAR").toInt(); |
490 | la.isPrintable = pg.attribute("DRUCKEN").toInt(); |
||
3197 | fschmid | 491 | bool laex = false; |
492 | uint layerCount=doc->layerCount(); |
||
493 | for (uint la2 = 0; la2 < layerCount; ++la2) |
||
494 | { |
||
495 | if (doc->Layers[la2].Name == la.Name) |
||
496 | { |
||
497 | laex = true; |
||
498 | layerTrans.insert(la.LNr, doc->Layers[la2].LNr); |
||
499 | } |
||
500 | } |
||
501 | if (!laex) |
||
502 | { |
||
503 | maxLayer++; |
||
504 | maxLevel++; |
||
505 | layerTrans.insert(la.LNr, maxLayer); |
||
506 | la.LNr = maxLayer; |
||
507 | la.Level = maxLevel; |
||
508 | doc->Layers.append(la); |
||
509 | } |
||
510 | } |
||
511 | if(pg.tagName()=="Bookmark") |
||
512 | { |
||
513 | bok.Title = pg.attribute("Title"); |
||
514 | bok.Text = pg.attribute("Text"); |
||
515 | bok.Aktion = pg.attribute("Aktion"); |
||
4026 | craig | 516 | bok.ItemNr = pg.attribute("ItemNr").toInt(); |
517 | bok.Seite = pg.attribute("Seite").toInt(); |
||
518 | bok.Element = pg.attribute("Element").toInt(); |
||
519 | bok.First = pg.attribute("First").toInt(); |
||
520 | bok.Last = pg.attribute("Last").toInt(); |
||
521 | bok.Prev = pg.attribute("Prev").toInt(); |
||
522 | bok.Next = pg.attribute("Next").toInt(); |
||
523 | bok.Parent = pg.attribute("Parent").toInt(); |
||
3197 | fschmid | 524 | doc->BookMarks.append(bok); |
525 | } |
||
526 | if(pg.tagName()=="MultiLine") |
||
527 | { |
||
528 | multiLine ml; |
||
529 | QDomNode MuLn = PAGE.firstChild(); |
||
530 | while(!MuLn.isNull()) |
||
531 | { |
||
532 | QDomElement MuL = MuLn.toElement(); |
||
533 | struct SingleLine sl; |
||
534 | sl.Color = MuL.attribute("Color"); |
||
4026 | craig | 535 | sl.Dash = MuL.attribute("Dash").toInt(); |
536 | sl.LineEnd = MuL.attribute("LineEnd").toInt(); |
||
537 | sl.LineJoin = MuL.attribute("LineJoin").toInt(); |
||
538 | sl.Shade = MuL.attribute("Shade").toInt(); |
||
539 | sl.Width = MuL.attribute("Width").toDouble(); |
||
3197 | fschmid | 540 | ml.push_back(sl); |
541 | MuLn = MuLn.nextSibling(); |
||
542 | } |
||
543 | QString Nam = pg.attribute("Name"); |
||
544 | QString Nam2 = Nam; |
||
545 | int copyC = 1; |
||
546 | while (doc->MLineStyles.contains(Nam2)) |
||
547 | { |
||
548 | Nam2 = QObject::tr("Copy #%1 of ").arg(copyC)+Nam; |
||
549 | copyC++; |
||
550 | } |
||
551 | doc->MLineStyles.insert(Nam2, ml); |
||
552 | } |
||
553 | if(pg.tagName()=="Arrows") |
||
554 | { |
||
555 | struct ArrowDesc arrow; |
||
556 | arrow.name = pg.attribute("Name"); |
||
557 | arrow.userArrow = true; |
||
558 | double xa, ya; |
||
559 | QString tmp = pg.attribute("Points"); |
||
560 | QTextStream fp(&tmp, IO_ReadOnly); |
||
561 | for (uint cx = 0; cx < pg.attribute("NumPoints").toUInt(); ++cx) |
||
562 | { |
||
563 | fp >> xa; |
||
564 | fp >> ya; |
||
565 | arrow.points.addPoint(xa, ya); |
||
566 | } |
||
567 | doc->arrowStyles.append(arrow); |
||
568 | } |
||
4026 | craig | 569 | if (((pg.tagName()=="PAGE") || (pg.tagName()=="MASTERPAGE")) && (pg.attribute("NUM").toInt() == PageToLoad)) |
3197 | fschmid | 570 | { |
3200 | cbradney | 571 | a = doc->currentPage->pageNr(); |
3724 | cbradney | 572 | Apage = doc->Pages->at(a); |
3197 | fschmid | 573 | if ((pg.tagName()!="MASTERPAGE") && (Mpage)) |
574 | { |
||
575 | PAGE=PAGE.nextSibling(); |
||
576 | continue; |
||
577 | } |
||
578 | if (Mpage) |
||
579 | { |
||
4026 | craig | 580 | Apage->LeftPg=pg.attribute("LEFT", "0").toInt(); |
3197 | fschmid | 581 | Apage->setPageName(pg.attribute("NAM","")); |
582 | } |
||
583 | if (pg.hasAttribute("Size")) |
||
584 | Apage->PageSize = pg.attribute("Size"); |
||
585 | if (pg.hasAttribute("Orientation")) |
||
4026 | craig | 586 | Apage->PageOri = pg.attribute("Orientation").toInt(); |
3197 | fschmid | 587 | if (pg.hasAttribute("PAGEWIDTH")) |
4026 | craig | 588 | Apage->setWidth(pg.attribute("PAGEWIDTH").toDouble()); |
3197 | fschmid | 589 | else |
4026 | craig | 590 | Apage->setWidth(pg.attribute("PAGEWITH").toDouble()); |
591 | Apage->setHeight(pg.attribute("PAGEHEIGHT").toDouble()); |
||
3200 | cbradney | 592 | Apage->setInitialHeight(Apage->height()); |
593 | Apage->setInitialWidth(Apage->width()); |
||
4026 | craig | 594 | Apage->initialMargins.Top = pg.attribute("BORDERTOP").toDouble(); |
595 | Apage->initialMargins.Bottom = pg.attribute("BORDERBOTTOM").toDouble(); |
||
596 | Apage->initialMargins.Left = pg.attribute("BORDERLEFT").toDouble(); |
||
597 | Apage->initialMargins.Right = pg.attribute("BORDERRIGHT").toDouble(); |
||
3197 | fschmid | 598 | Apage->Margins.Top = Apage->initialMargins.Top; |
599 | Apage->Margins.Bottom = Apage->initialMargins.Bottom; |
||
4026 | craig | 600 | pageX = pg.attribute("PAGEXPOS").toDouble(); |
601 | pageY = pg.attribute("PAGEYPOS").toDouble(); |
||
602 | if ((pg.hasAttribute("NumVGuides")) && (pg.attribute("NumVGuides", "0").toInt() != 0)) |
||
3197 | fschmid | 603 | { |
604 | tmp = pg.attribute("VerticalGuides"); |
||
605 | QTextStream fgv(&tmp, IO_ReadOnly); |
||
606 | Apage->YGuides.clear(); |
||
4026 | craig | 607 | for (int cxv = 0; cxv < pg.attribute("NumVGuides", "0").toInt(); ++cxv) |
3197 | fschmid | 608 | { |
609 | fgv >> xf; |
||
610 | Apage->YGuides.append(xf); |
||
611 | } |
||
612 | qHeapSort(Apage->YGuides); |
||
613 | tmp = ""; |
||
614 | } |
||
4026 | craig | 615 | if ((pg.hasAttribute("NumHGuides")) && (pg.attribute("NumHGuides", "0").toInt() != 0)) |
3197 | fschmid | 616 | { |
617 | tmp = pg.attribute("HorizontalGuides"); |
||
618 | QTextStream fgh(&tmp, IO_ReadOnly); |
||
619 | Apage->XGuides.clear(); |
||
4026 | craig | 620 | for (int cxh = 0; cxh < pg.attribute("NumHGuides", "0").toInt(); ++cxh) |
3197 | fschmid | 621 | { |
622 | fgh >> xf; |
||
623 | Apage->XGuides.append(xf); |
||
624 | } |
||
625 | qHeapSort(Apage->XGuides); |
||
626 | tmp = ""; |
||
627 | } |
||
628 | } |
||
629 | if ((pg.tagName()=="PAGEOBJECT") || (pg.tagName()=="MASTEROBJECT") || (pg.tagName()=="FRAMEOBJECT")) |
||
630 | { |
||
631 | if ((pg.tagName()!="MASTEROBJECT") && (Mpage)) |
||
632 | { |
||
633 | PAGE=PAGE.nextSibling(); |
||
634 | continue; |
||
635 | } |
||
4026 | craig | 636 | if (pg.attribute("OwnPage").toInt() == PageToLoad) |
3197 | fschmid | 637 | { |
4026 | craig | 638 | if (pg.attribute("NEXTITEM").toInt() != -1) |
3197 | fschmid | 639 | { |
4026 | craig | 640 | if (pg.attribute("BACKITEM").toInt() == -1) |
3727 | cbradney | 641 | LFrames.append(doc->Items->count()); |
3197 | fschmid | 642 | } |
643 | int docGc = doc->GroupCounter; |
||
644 | doc->GroupCounter = 0; |
||
3657 | cbradney | 645 | Neu = PasteItem(&pg, doc); |
3934 | cbradney | 646 | Neu->moveBy(-pageX + Apage->xOffset(), - pageY + Apage->yOffset()); |
3656 | cbradney | 647 | //view->setRedrawBounding(Neu); |
648 | Neu->setRedrawBounding(); |
||
649 | //Neu->OwnPage = view->OnPage(Neu); |
||
650 | Neu->OwnPage = PageToLoad; |
||
3197 | fschmid | 651 | if (pg.tagName()=="PAGEOBJECT") |
652 | Neu->OnMasterPage = ""; |
||
653 | doc->GroupCounter = docGc; |
||
654 | tmpf = pg.attribute("IFONT", doc->toolSettings.defFont); |
||
655 | if ((!avail.find(tmpf)) || (!avail[tmpf]->UseFont)) |
||
656 | { |
||
3650 | cbradney | 657 | if ((!prefsManager->appPrefs.GFontSub.contains(tmpf)) || (!avail[prefsManager->appPrefs.GFontSub[tmpf]]->UseFont)) |
3197 | fschmid | 658 | { |
659 | newReplacement = true; |
||
3650 | cbradney | 660 | ReplacedFonts.insert(tmpf, prefsManager->appPrefs.toolSettings.defFont); |
3197 | fschmid | 661 | } |
662 | else |
||
3650 | cbradney | 663 | ReplacedFonts.insert(tmpf, prefsManager->appPrefs.GFontSub[tmpf]); |
3197 | fschmid | 664 | } |
665 | else |
||
666 | { |
||
667 | if (!doc->UsedFonts.contains(tmpf)) |
||
668 | { |
||
3544 | avox | 669 | // QFont fo = avail[tmpf]->Font; |
670 | // fo.setPointSize(qRound(doc->toolSettings.defSize / 10.0)); |
||
671 | doc->AddFont(tmpf, qRound(doc->toolSettings.defSize / 10.0)); |
||
3197 | fschmid | 672 | } |
673 | } |
||
4073 | cbradney | 674 | Neu->setFont(tmpf); |
3197 | fschmid | 675 | QDomNode IT=pg.firstChild(); |
676 | while(!IT.isNull()) |
||
677 | { |
||
678 | QDomElement it=IT.toElement(); |
||
679 | if (it.tagName()=="CSTOP") |
||
680 | { |
||
681 | QString name = it.attribute("NAME"); |
||
4026 | craig | 682 | double ramp = it.attribute("RAMP", "0.0").toDouble(); |
683 | int shade = it.attribute("SHADE", "100").toInt(); |
||
684 | double opa = it.attribute("TRANS", "1").toDouble(); |
||
3197 | fschmid | 685 | Neu->fill_gradient.addStop(SetColor(doc, name, shade), ramp, 0.5, opa, name, shade); |
686 | } |
||
687 | if (it.tagName()=="ITEXT") |
||
688 | GetItemText(&it, doc, Neu, true, VorLFound); |
||
689 | if(it.tagName()=="PageItemAttributes") |
||
690 | { |
||
691 | QDomNode PIA = it.firstChild(); |
||
692 | ObjAttrVector pageItemAttributes; |
||
693 | while(!PIA.isNull()) |
||
694 | { |
||
695 | QDomElement itemAttr = PIA.toElement(); |
||
696 | if(itemAttr.tagName() == "ItemAttribute") |
||
697 | { |
||
698 | ObjectAttribute objattr; |
||
699 | objattr.name=itemAttr.attribute("Name"); |
||
700 | objattr.type=itemAttr.attribute("Type"); |
||
701 | objattr.value=itemAttr.attribute("Value"); |
||
702 | objattr.parameter=itemAttr.attribute("Parameter"); |
||
703 | objattr.relationship=itemAttr.attribute("Relationship"); |
||
704 | objattr.relationshipto=itemAttr.attribute("RelationshipTo"); |
||
705 | objattr.autoaddto=itemAttr.attribute("AutoAddTo"); |
||
706 | pageItemAttributes.append(objattr); |
||
707 | } |
||
708 | PIA = PIA.nextSibling(); |
||
709 | } |
||
710 | Neu->setObjectAttributes(&pageItemAttributes); |
||
711 | } |
||
712 | IT=IT.nextSibling(); |
||
713 | } |
||
714 | if (Neu->fill_gradient.Stops() == 0) |
||
715 | { |
||
716 | Neu->fill_gradient.addStop(doc->PageColors[doc->toolSettings.dBrush].getRGBColor(), 0.0, 0.5, 1.0, doc->toolSettings.dBrush, 100); |
||
717 | Neu->fill_gradient.addStop(doc->PageColors[doc->toolSettings.dPen].getRGBColor(), 1.0, 0.5, 1.0, doc->toolSettings.dPen, 100); |
||
718 | } |
||
4026 | craig | 719 | // Neu->Language = ScMW->GetLang(pg.attribute("LANGUAGE", doc->Language)); |
3197 | fschmid | 720 | Neu->Language = doc->Language; |
4026 | craig | 721 | Neu->isAutoText = static_cast<bool>(pg.attribute("AUTOTEXT").toInt()); |
722 | Neu->isEmbedded = static_cast<bool>(pg.attribute("isInline", "0").toInt()); |
||
723 | Neu->gXpos = pg.attribute("gXpos", "0.0").toDouble(); |
||
724 | Neu->gYpos = pg.attribute("gYpos", "0.0").toDouble(); |
||
3197 | fschmid | 725 | QString defaultVal; |
3934 | cbradney | 726 | defaultVal.setNum(Neu->width()); |
4026 | craig | 727 | Neu->gWidth = pg.attribute("gWidth",defaultVal).toDouble(); |
3934 | cbradney | 728 | defaultVal.setNum(Neu->height()); |
4026 | craig | 729 | Neu->gHeight = pg.attribute("gHeight",defaultVal).toDouble(); |
3197 | fschmid | 730 | if (Neu->LineSpMode == 3) |
731 | { |
||
732 | doc->docParagraphStyles[0].BaseAdj = true; |
||
733 | Neu->LineSp = doc->typographicSettings.valueBaseGrid-1; |
||
734 | } |
||
735 | if (Neu->isAutoText) |
||
736 | doc->LastAuto = Neu; |
||
4026 | craig | 737 | Neu->NextIt = baseobj + pg.attribute("NEXTITEM").toInt(); |
3197 | fschmid | 738 | if (Neu->isTableItem) |
739 | { |
||
740 | TableItems.append(Neu); |
||
4026 | craig | 741 | TableID.insert(pg.attribute("OwnLINK", "0").toInt(), Neu->ItemNr); |
3197 | fschmid | 742 | } |
743 | if (pg.tagName()=="FRAMEOBJECT") |
||
744 | { |
||
3727 | cbradney | 745 | doc->FrameItems.append(doc->Items->take(Neu->ItemNr)); |
3197 | fschmid | 746 | Neu->ItemNr = doc->FrameItems.count()-1; |
747 | } |
||
748 | } |
||
749 | counter++; |
||
750 | } |
||
751 | PAGE=PAGE.nextSibling(); |
||
752 | } |
||
753 | DOC=DOC.nextSibling(); |
||
754 | } |
||
755 | if (TableItems.count() != 0) |
||
756 | { |
||
757 | for (uint ttc = 0; ttc < TableItems.count(); ++ttc) |
||
758 | { |
||
759 | PageItem* ta = TableItems.at(ttc); |
||
760 | if (ta->TopLinkID != -1) |
||
3727 | cbradney | 761 | ta->TopLink = doc->Items->at(TableID[ta->TopLinkID]); |
3197 | fschmid | 762 | else |
763 | ta->TopLink = 0; |
||
764 | if (ta->LeftLinkID != -1) |
||
3727 | cbradney | 765 | ta->LeftLink = doc->Items->at(TableID[ta->LeftLinkID]); |
3197 | fschmid | 766 | else |
767 | ta->LeftLink = 0; |
||
768 | if (ta->RightLinkID != -1) |
||
3727 | cbradney | 769 | ta->RightLink = doc->Items->at(TableID[ta->RightLinkID]); |
3197 | fschmid | 770 | else |
771 | ta->RightLink = 0; |
||
772 | if (ta->BottomLinkID != -1) |
||
3727 | cbradney | 773 | ta->BottomLink = doc->Items->at(TableID[ta->BottomLinkID]); |
3197 | fschmid | 774 | else |
775 | ta->BottomLink = 0; |
||
776 | } |
||
777 | } |
||
778 | if (LFrames.count() != 0) |
||
779 | { |
||
780 | PageItem *Its; |
||
781 | PageItem *Itn; |
||
782 | PageItem *Itr; |
||
783 | QValueList<int>::Iterator lc; |
||
784 | for (lc = LFrames.begin(); lc != LFrames.end(); ++lc) |
||
785 | { |
||
3727 | cbradney | 786 | Its = doc->Items->at((*lc)); |
3197 | fschmid | 787 | Itr = Its; |
788 | Its->BackBox = 0; |
||
789 | while (Its->NextIt != -1) |
||
790 | { |
||
3727 | cbradney | 791 | if (Its->NextIt < static_cast<int>(doc->Items->count())) |
3197 | fschmid | 792 | { |
3727 | cbradney | 793 | Itn = doc->Items->at(Its->NextIt); |
3197 | fschmid | 794 | Its->NextBox = Itn; |
795 | Itn->BackBox = Its; |
||
796 | Its = Itn; |
||
797 | } |
||
798 | else |
||
799 | Its->NextIt = -1; |
||
800 | } |
||
801 | Its->NextBox = 0; |
||
802 | } |
||
803 | } |
||
804 | return true; |
||
805 | } |
||
806 | |||
3657 | cbradney | 807 | bool FileLoader::ReadDoc(const QString & fileName, SCFonts &avail, ScribusDoc *doc, QProgressBar *dia2) |
517 | fschmid | 808 | { |
1065 | cbradney | 809 | struct ParagraphStyle vg; |
517 | fschmid | 810 | struct Layer la; |
811 | struct ScribusDoc::BookMa bok; |
||
3757 | cbradney | 812 | int counter;//, Pgc; |
813 | //bool AtFl; |
||
517 | fschmid | 814 | bool newVersion = false; |
815 | QString tmp, tmpf, tmp2, tmp3, tmp4, PgNam, Defont, tmf; |
||
816 | QFont fo; |
||
817 | QMap<int,int> TableID; |
||
818 | QPtrList<PageItem> TableItems; |
||
1779 | fschmid | 819 | int a; |
2282 | fschmid | 820 | double xf, xf2; |
517 | fschmid | 821 | PageItem *Neu; |
822 | Page* Apage; |
||
823 | LFrames.clear(); |
||
824 | QDomDocument docu("scridoc"); |
||
3646 | craig | 825 | QString f(readSLA(fileName)); |
517 | fschmid | 826 | /* 2004/10/02 - petr vanek - bug #1092 - missing <PAGE> crash Scribus. The check constraint moved into IsScribus() |
2680 | cbradney | 827 | FIXME: I've add test on containig tag PAGE but returning false freezes S. in scribus.cpp need some hack too... */ |
517 | fschmid | 828 | if (!docu.setContent(f)) |
829 | return false; |
||
1549 | subik | 830 | doc->PageColors.clear(); |
517 | fschmid | 831 | doc->Layers.clear(); |
3855 | cbradney | 832 | int layerToSetActive=0; |
2886 | fschmid | 833 | ScColor lf = ScColor(); |
517 | fschmid | 834 | QDomElement elem=docu.documentElement(); |
835 | if (elem.tagName() != "SCRIBUSUTF8NEW") |
||
836 | return false; |
||
837 | if (elem.hasAttribute("Version")) |
||
838 | newVersion = true; |
||
839 | QDomNode DOC=elem.firstChild(); |
||
840 | dia2->setTotalSteps(DOC.childNodes().count()); |
||
841 | dia2->setProgress(0); |
||
842 | int ObCount = 0; |
||
843 | TableItems.clear(); |
||
844 | TableID.clear(); |
||
845 | while(!DOC.isNull()) |
||
846 | { |
||
847 | QDomElement dc=DOC.toElement(); |
||
848 | /* |
||
849 | * Attribute von DOCUMENT auslesen |
||
850 | */ |
||
1542 | cbradney | 851 | //CB Add this in to set this in the file in memory. Its saved, why not load it. |
852 | //Will of course be replaced by per page settings although we still probably need a document default |
||
853 | doc->PageSize = dc.attribute("PAGESIZE"); |
||
4026 | craig | 854 | doc->PageOri = dc.attribute("ORIENTATION", "0").toInt(); |
855 | doc->FirstPnum = dc.attribute("FIRSTNUM", "1").toInt(); |
||
856 | doc->currentPageLayout=dc.attribute("BOOK", "0").toInt(); |
||
3016 | fschmid | 857 | int fp; |
3035 | fschmid | 858 | if (doc->currentPageLayout == 0) |
859 | fp = 0; |
||
2912 | fschmid | 860 | else |
861 | { |
||
4026 | craig | 862 | if (dc.attribute("FIRSTLEFT", "0").toInt() == 1) |
3016 | fschmid | 863 | fp = 0; |
2912 | fschmid | 864 | else |
3035 | fschmid | 865 | fp = 1; |
2912 | fschmid | 866 | } |
3016 | fschmid | 867 | if (DOC.namedItem("PageSets").isNull()) |
868 | { |
||
3032 | fschmid | 869 | doc->pageSets[doc->currentPageLayout].FirstPage = fp; |
4026 | craig | 870 | doc->pageSets[doc->currentPageLayout].GapHorizontal = dc.attribute("GapHorizontal", "0").toDouble(); |
3032 | fschmid | 871 | doc->pageSets[doc->currentPageLayout].GapVertical = 0.0; |
4026 | craig | 872 | doc->pageSets[doc->currentPageLayout].GapBelow = dc.attribute("GapVertical", "40").toDouble(); |
3016 | fschmid | 873 | } |
4026 | craig | 874 | doc->setUsesAutomaticTextFrames(dc.attribute("AUTOTEXT").toInt()); |
875 | doc->PageSp=dc.attribute("AUTOSPALTEN").toInt(); |
||
876 | doc->PageSpa=dc.attribute("ABSTSPALTEN").toDouble(); |
||
877 | doc->setUnitIndex(dc.attribute("UNITS", "0").toInt()); |
||
878 | doc->toolSettings.defSize=qRound(dc.attribute("DSIZE").toDouble() * 10); |
||
517 | fschmid | 879 | Defont=dc.attribute("DFONT"); |
1428 | fschmid | 880 | if ((!avail.find(Defont)) || (!avail[Defont]->UseFont)) |
517 | fschmid | 881 | { |
3650 | cbradney | 882 | ReplacedFonts.insert(Defont, prefsManager->appPrefs.toolSettings.defFont); |
883 | Defont = prefsManager->appPrefs.toolSettings.defFont; |
||
517 | fschmid | 884 | } |
885 | else |
||
1428 | fschmid | 886 | { |
3544 | avox | 887 | // QFont fo = avail[Defont]->Font; |
888 | // fo.setPointSize(qRound(doc->toolSettings.defSize / 10.0)); |
||
889 | doc->AddFont(Defont, qRound(doc->toolSettings.defSize / 10.0)); |
||
1428 | fschmid | 890 | } |
1194 | fschmid | 891 | doc->toolSettings.defFont = Defont; |
4026 | craig | 892 | doc->toolSettings.dCols=dc.attribute("DCOL", "1").toInt(); |
893 | doc->toolSettings.dGap=dc.attribute("DGAP", "0.0").toDouble(); |
||
2024 | cbradney | 894 | doc->documentInfo.setAuthor(dc.attribute("AUTHOR")); |
895 | doc->documentInfo.setComments(dc.attribute("COMMENTS")); |
||
896 | doc->documentInfo.setKeywords(dc.attribute("KEYWORDS","")); |
||
897 | doc->documentInfo.setTitle(dc.attribute("TITLE")); |
||
898 | doc->documentInfo.setPublisher(dc.attribute("PUBLISHER", "")); |
||
899 | doc->documentInfo.setDate(dc.attribute("DOCDATE", "")); |
||
900 | doc->documentInfo.setType(dc.attribute("DOCTYPE", "")); |
||
901 | doc->documentInfo.setFormat(dc.attribute("DOCFORMAT", "")); |
||
902 | doc->documentInfo.setIdent(dc.attribute("DOCIDENT", "")); |
||
903 | doc->documentInfo.setSource(dc.attribute("DOCSOURCE", "")); |
||
904 | doc->documentInfo.setLangInfo(dc.attribute("DOCLANGINFO", "")); |
||
905 | doc->documentInfo.setRelation(dc.attribute("DOCRELATION", "")); |
||
906 | doc->documentInfo.setCover(dc.attribute("DOCCOVER", "")); |
||
907 | doc->documentInfo.setRights(dc.attribute("DOCRIGHTS", "")); |
||
908 | doc->documentInfo.setContrib(dc.attribute("DOCCONTRIB", "")); |
||
4026 | craig | 909 | doc->typographicSettings.valueSuperScript = dc.attribute("VHOCH").toInt(); |
910 | doc->typographicSettings.scalingSuperScript = dc.attribute("VHOCHSC").toInt(); |
||
911 | doc->typographicSettings.valueSubScript = dc.attribute("VTIEF").toInt(); |
||
912 | doc->typographicSettings.scalingSubScript = dc.attribute("VTIEFSC").toInt(); |
||
913 | doc->typographicSettings.valueSmallCaps = dc.attribute("VKAPIT").toInt(); |
||
914 | doc->typographicSettings.valueBaseGrid = dc.attribute("BASEGRID", "12").toDouble(); |
||
915 | doc->typographicSettings.offsetBaseGrid = dc.attribute("BASEO", "0").toDouble(); |
||
916 | doc->typographicSettings.autoLineSpacing = dc.attribute("AUTOL", "20").toInt(); |
||
917 | doc->typographicSettings.valueUnderlinePos = dc.attribute("UnderlinePos", "-1").toInt(); |
||
918 | doc->typographicSettings.valueUnderlineWidth = dc.attribute("UnderlineWidth", "-1").toInt(); |
||
919 | doc->typographicSettings.valueStrikeThruPos = dc.attribute("StrikeThruPos", "-1").toInt(); |
||
920 | doc->typographicSettings.valueStrikeThruWidth = dc.attribute("StrikeThruWidth", "-1").toInt(); |
||
921 | doc->GroupCounter=dc.attribute("GROUPC", "1").toInt(); |
||
922 | doc->HasCMS = static_cast<bool>(dc.attribute("HCMS", "0").toInt()); |
||
923 | doc->CMSSettings.SoftProofOn = static_cast<bool>(dc.attribute("DPSo", "0").toInt()); |
||
924 | doc->CMSSettings.CMSinUse = static_cast<bool>(dc.attribute("DPuse", "0").toInt()); |
||
925 | doc->CMSSettings.GamutCheck = static_cast<bool>(dc.attribute("DPgam", "0").toInt()); |
||
926 | doc->CMSSettings.BlackPoint = static_cast<bool>(dc.attribute("DPbla", "1").toInt()); |
||
517 | fschmid | 927 | doc->CMSSettings.DefaultMonitorProfile = dc.attribute("DPMo",""); |
928 | doc->CMSSettings.DefaultPrinterProfile = dc.attribute("DPPr",""); |
||
2984 | fschmid | 929 | doc->CMSSettings.DefaultImageRGBProfile = dc.attribute("DPIn",""); |
930 | doc->CMSSettings.DefaultImageCMYKProfile = dc.attribute("DPInCMYK",""); |
||
931 | doc->CMSSettings.DefaultSolidColorProfile = dc.attribute("DPIn2",""); |
||
4026 | craig | 932 | doc->CMSSettings.DefaultIntentPrinter = dc.attribute("DIPr", "0").toInt(); |
933 | doc->CMSSettings.DefaultIntentMonitor = dc.attribute("DIMo", "1").toInt(); |
||
934 | doc->CMSSettings.DefaultIntentImages = dc.attribute("DIMo2", "1").toInt(); |
||
935 | layerToSetActive=dc.attribute("ALAYER", "0").toInt(); |
||
517 | fschmid | 936 | doc->Language = dc.attribute("LANGUAGE", ""); |
4026 | craig | 937 | doc->MinWordLen = dc.attribute("MINWORDLEN", "3").toInt(); |
938 | doc->HyCount = dc.attribute("HYCOUNT", "2").toInt(); |
||
2305 | cbradney | 939 | if (dc.hasAttribute("PAGEWIDTH")) |
4026 | craig | 940 | doc->pageWidth=dc.attribute("PAGEWIDTH").toDouble(); |
2305 | cbradney | 941 | else |
4026 | craig | 942 | doc->pageWidth=dc.attribute("PAGEWITH").toDouble(); |
943 | doc->pageHeight=dc.attribute("PAGEHEIGHT").toDouble(); |
||
944 | doc->pageMargins.Left=dc.attribute("BORDERLEFT").toDouble(); |
||
945 | doc->pageMargins.Right=dc.attribute("BORDERRIGHT").toDouble(); |
||
946 | doc->pageMargins.Top=dc.attribute("BORDERTOP").toDouble(); |
||
947 | doc->pageMargins.Bottom=dc.attribute("BORDERBOTTOM").toDouble(); |
||
948 | doc->Automatic = static_cast<bool>(dc.attribute("AUTOMATIC", "1").toInt()); |
||
949 | doc->AutoCheck = static_cast<bool>(dc.attribute("AUTOCHECK", "0").toInt()); |
||
950 | doc->GuideLock = static_cast<bool>(dc.attribute("GUIDELOCK", "0").toInt()); |
||
951 | doc->guidesSettings.minorGrid = dc.attribute("MINGRID", tmp.setNum(prefsManager->appPrefs.guidesSettings.minorGrid)).toDouble(); |
||
952 | doc->guidesSettings.majorGrid = dc.attribute("MAJGRID", tmp.setNum(prefsManager->appPrefs.guidesSettings.majorGrid)).toDouble(); |
||
953 | doc->guidesSettings.gridShown = static_cast<bool>(dc.attribute("SHOWGRID", "0").toInt()); |
||
954 | doc->guidesSettings.guidesShown = static_cast<bool>(dc.attribute("SHOWGUIDES", "1").toInt()); |
||
955 | doc->guidesSettings.framesShown = static_cast<bool>(dc.attribute("SHOWFRAME", "1").toInt()); |
||
956 | doc->guidesSettings.marginsShown = static_cast<bool>(dc.attribute("SHOWMARGIN", "1").toInt()); |
||
957 | doc->guidesSettings.baseShown = static_cast<bool>(dc.attribute("SHOWBASE", "0").toInt()); |
||
958 | doc->guidesSettings.showPic = static_cast<bool>(dc.attribute("SHOWPICT", "1").toInt()); |
||
959 | doc->guidesSettings.linkShown = static_cast<bool>(dc.attribute("SHOWLINK", "0").toInt()); |
||
960 | doc->guidesSettings.showControls = static_cast<bool>(dc.attribute("SHOWControl", "0").toInt()); |
||
961 | doc->guidesSettings.rulerMode = static_cast<bool>(dc.attribute("rulerMode", "1").toInt()); |
||
962 | doc->rulerXoffset = dc.attribute("rulerXoffset", "0").toDouble(); |
||
963 | doc->rulerYoffset =dc.attribute("rulerYoffset", "0").toDouble(); |
||
964 | doc->SnapGuides = static_cast<bool>(dc.attribute("SnapToGuides", "0").toInt()); |
||
965 | doc->useRaster = static_cast<bool>(dc.attribute("SnapToGrid", "0").toInt()); |
||
966 | doc->toolSettings.polyC = dc.attribute("POLYC", "4").toInt(); |
||
967 | doc->toolSettings.polyF = dc.attribute("POLYF", "0.5").toDouble(); |
||
968 | doc->toolSettings.polyR = dc.attribute("POLYR", "0").toDouble(); |
||
969 | doc->toolSettings.polyFd = dc.attribute("POLYFD", "0").toInt(); |
||
970 | doc->toolSettings.polyS = static_cast<bool>(dc.attribute("POLYS", "0").toInt()); |
||
971 | doc->AutoSave = static_cast<bool>(dc.attribute("AutoSave", "0").toInt()); |
||
972 | doc->AutoSaveTime = dc.attribute("AutoSaveTime", "600000").toInt(); |
||
973 | doc->ScratchBottom = dc.attribute("ScratchBottom", "20").toDouble(); |
||
1719 | craig | 974 | // FIXME A typo in early 1.3cvs (MAR 05) means we must support loading of |
975 | // FIXME 'ScatchLeft' for a while too. This can be removed in a few months. |
||
976 | if (dc.hasAttribute("ScatchLeft")) |
||
4026 | craig | 977 | doc->ScratchLeft = dc.attribute("ScatchLeft", "100").toDouble(); |
1719 | craig | 978 | else |
4026 | craig | 979 | doc->ScratchLeft = dc.attribute("ScratchLeft", "100").toDouble(); |
980 | doc->ScratchRight = dc.attribute("ScratchRight", "100").toDouble(); |
||
981 | doc->ScratchTop = dc.attribute("ScratchTop", "20").toDouble(); |
||
982 | doc->toolSettings.dStartArrow = dc.attribute("StartArrow", "0").toInt(); |
||
983 | doc->toolSettings.dEndArrow = dc.attribute("EndArrow", "0").toInt(); |
||
984 | doc->toolSettings.scaleX = dc.attribute("PICTSCX", "1").toDouble(); |
||
985 | doc->toolSettings.scaleY = dc.attribute("PICTSCY", "1").toDouble(); |
||
986 | doc->toolSettings.scaleType = static_cast<bool>(dc.attribute("PSCALE", "1").toInt()); |
||
987 | doc->toolSettings.aspectRatio = static_cast<bool>(dc.attribute("PASPECT", "0").toInt()); |
||
988 | doc->toolSettings.lowResType = dc.attribute("HalfRes", "1").toInt(); |
||
989 | doc->toolSettings.useEmbeddedPath = static_cast<bool>(dc.attribute("EmbeddedPath", "0").toInt()); |
||
745 | fschmid | 990 | if (dc.hasAttribute("PEN")) |
1194 | fschmid | 991 | doc->toolSettings.dPen = dc.attribute("PEN"); |
745 | fschmid | 992 | if (dc.hasAttribute("BRUSH")) |
1194 | fschmid | 993 | doc->toolSettings.dBrush = dc.attribute("BRUSH"); |
745 | fschmid | 994 | if (dc.hasAttribute("PENLINE")) |
1194 | fschmid | 995 | doc->toolSettings.dPenLine = dc.attribute("PENLINE"); |
745 | fschmid | 996 | if (dc.hasAttribute("PENTEXT")) |
1194 | fschmid | 997 | doc->toolSettings.dPenText = dc.attribute("PENTEXT"); |
745 | fschmid | 998 | if (dc.hasAttribute("StrokeText")) |
1194 | fschmid | 999 | doc->toolSettings.dStrokeText = dc.attribute("StrokeText"); |
3093 | fschmid | 1000 | doc->toolSettings.dTextBackGround = dc.attribute("TextBackGround", "None"); |
1001 | doc->toolSettings.dTextLineColor = dc.attribute("TextLineColor", "None"); |
||
4026 | craig | 1002 | doc->toolSettings.dTextBackGroundShade = dc.attribute("TextBackGroundShade", "100").toInt(); |
1003 | doc->toolSettings.dTextLineShade = dc.attribute("TextLineShade", "100").toInt(); |
||
1004 | doc->toolSettings.dTextPenShade = dc.attribute("TextPenShade", "100").toInt(); |
||
1005 | doc->toolSettings.dTextStrokeShade = dc.attribute("TextStrokeShade", "100").toInt(); |
||
1006 | doc->toolSettings.dLineArt = static_cast<Qt::PenStyle>(dc.attribute("STIL").toInt()); |
||
1007 | doc->toolSettings.dLstyleLine = static_cast<Qt::PenStyle>(dc.attribute("STILLINE").toInt()); |
||
1008 | doc->toolSettings.dWidth = dc.attribute("WIDTH", "1").toDouble(); |
||
1009 | doc->toolSettings.dWidthLine = dc.attribute("WIDTHLINE", "1").toDouble(); |
||
1010 | doc->toolSettings.dShade2 = dc.attribute("PENSHADE", "100").toInt(); |
||
1011 | doc->toolSettings.dShadeLine = dc.attribute("LINESHADE", "100").toInt(); |
||
1012 | doc->toolSettings.dShade = dc.attribute("BRUSHSHADE", "100").toInt(); |
||
1013 | doc->toolSettings.magMin = dc.attribute("MAGMIN", "10").toInt(); |
||
1014 | doc->toolSettings.magMax = dc.attribute("MAGMAX", "3200").toInt(); |
||
1015 | doc->toolSettings.magStep = dc.attribute("MAGSTEP", "25").toInt(); |
||
2219 | fschmid | 1016 | doc->toolSettings.tabFillChar = dc.attribute("TabFill",""); |
4026 | craig | 1017 | doc->toolSettings.dTabWidth=dc.attribute("TabWidth", "36.0").toDouble(); |
745 | fschmid | 1018 | if (dc.hasAttribute("CPICT")) |
1194 | fschmid | 1019 | doc->toolSettings.dBrushPict = dc.attribute("CPICT"); |
4026 | craig | 1020 | doc->toolSettings.shadePict = dc.attribute("PICTSHADE", "100").toInt(); |
745 | fschmid | 1021 | if (dc.hasAttribute("PAGEC")) |
1022 | doc->papColor = QColor(dc.attribute("PAGEC")); |
||
1023 | if (dc.hasAttribute("MARGC")) |
||
879 | fschmid | 1024 | doc->guidesSettings.margColor = QColor(dc.attribute("MARGC")); |
745 | fschmid | 1025 | if (dc.hasAttribute("MINORC")) |
879 | fschmid | 1026 | doc->guidesSettings.minorColor = QColor(dc.attribute("MINORC")); |
745 | fschmid | 1027 | if (dc.hasAttribute("MAJORC")) |
879 | fschmid | 1028 | doc->guidesSettings.majorColor = QColor(dc.attribute("MAJORC")); |
745 | fschmid | 1029 | if (dc.hasAttribute("GuideC")) |
879 | fschmid | 1030 | doc->guidesSettings.guideColor = QColor(dc.attribute("GuideC")); |
745 | fschmid | 1031 | if (dc.hasAttribute("BaseC")) |
879 | fschmid | 1032 | doc->guidesSettings.baseColor = QColor(dc.attribute("BaseC")); |
4026 | craig | 1033 | doc->marginColored = static_cast<bool>(dc.attribute("RANDF", "0").toInt()); |
1034 | doc->guidesSettings.before = static_cast<bool>(dc.attribute("BACKG", "1").toInt()); |
||
1035 | doc->guidesSettings.guideRad = dc.attribute("GuideRad", "10").toDouble(); |
||
1036 | doc->guidesSettings.grabRad = dc.attribute("GRAB", "4").toInt(); |
||
1261 | fschmid | 1037 | if (dc.hasAttribute("currentProfile")) |
1284 | fschmid | 1038 | { |
1039 | doc->checkerProfiles.clear(); |
||
1261 | fschmid | 1040 | doc->curCheckProfile = dc.attribute("currentProfile"); |
1284 | fschmid | 1041 | } |
1016 | fschmid | 1042 | doc->LastAuto = 0; |
517 | fschmid | 1043 | QDomNode PAGE=DOC.firstChild(); |
1044 | counter = 0; |
||
1045 | while(!PAGE.isNull()) |
||
1046 | { |
||
1047 | ObCount++; |
||
1048 | dia2->setProgress(ObCount); |
||
1049 | QDomElement pg=PAGE.toElement(); |
||
3016 | fschmid | 1050 | if (pg.tagName()=="PageSets") |
1051 | { |
||
1052 | QDomNode PGS = PAGE.firstChild(); |
||
1053 | doc->pageSets.clear(); |
||
1054 | while(!PGS.isNull()) |
||
1055 | { |
||
1056 | QDomElement PgsAttr = PGS.toElement(); |
||
1057 | if(PgsAttr.tagName() == "Set") |
||
1058 | { |
||
1059 | struct PageSet pageS; |
||
1060 | pageS.Name = PgsAttr.attribute("Name"); |
||
4026 | craig | 1061 | pageS.FirstPage = PgsAttr.attribute("FirstPage", "0").toInt(); |
1062 | pageS.Rows = PgsAttr.attribute("Rows", "1").toInt(); |
||
1063 | pageS.Columns = PgsAttr.attribute("Columns", "1").toInt(); |
||
1064 | pageS.GapHorizontal = PgsAttr.attribute("GapHorizontal", "0").toDouble(); |
||
1065 | pageS.GapVertical = PgsAttr.attribute("GapVertical", "0").toDouble(); |
||
1066 | pageS.GapBelow = PgsAttr.attribute("GapBelow", "0").toDouble(); |
||
3026 | fschmid | 1067 | pageS.pageNames.clear(); |
1068 | QDomNode PGSN = PGS.firstChild(); |
||
1069 | while(!PGSN.isNull()) |
||
1070 | { |
||
1071 | QDomElement PgsAttrN = PGSN.toElement(); |
||
1072 | if(PgsAttrN.tagName() == "PageNames") |
||
1073 | pageS.pageNames.append(PgsAttrN.attribute("Name")); |
||
1074 | PGSN = PGSN.nextSibling(); |
||
1075 | } |
||
3016 | fschmid | 1076 | doc->pageSets.append(pageS); |
1077 | } |
||
1078 | PGS = PGS.nextSibling(); |
||
1079 | } |
||
1080 | } |
||
1261 | fschmid | 1081 | if (pg.tagName()=="CheckProfile") |
1082 | { |
||
1083 | struct checkerPrefs checkerSettings; |
||
4026 | craig | 1084 | checkerSettings.ignoreErrors = static_cast<bool>(pg.attribute("ignoreErrors", "0").toInt()); |
1085 | checkerSettings.autoCheck = static_cast<bool>(pg.attribute("autoCheck", "1").toInt()); |
||
1086 | checkerSettings.checkGlyphs = static_cast<bool>(pg.attribute("checkGlyphs", "1").toInt()); |
||
1087 | checkerSettings.checkOrphans = static_cast<bool>(pg.attribute("checkOrphans", "1").toInt()); |
||
1088 | checkerSettings.checkOverflow = static_cast<bool>(pg.attribute("checkOverflow", "1").toInt()); |
||
1089 | checkerSettings.checkPictures = static_cast<bool>(pg.attribute("checkPictures", "1").toInt()); |
||
1090 | checkerSettings.checkResolution = static_cast<bool>(pg.attribute("checkResolution", "1").toInt()); |
||
1091 | checkerSettings.checkTransparency = static_cast<bool>(pg.attribute("checkTransparency", "1").toInt()); |
||
1092 | checkerSettings.minResolution = pg.attribute("minResolution", "72").toDouble(); |
||
1093 | checkerSettings.checkAnnotations = static_cast<bool>(pg.attribute("checkAnnotations", "0").toInt()); |
||
1094 | checkerSettings.checkRasterPDF = static_cast<bool>(pg.attribute("checkRasterPDF", "1").toInt()); |
||
1261 | fschmid | 1095 | doc->checkerProfiles[pg.attribute("Name")] = checkerSettings; |
1096 | } |
||
517 | fschmid | 1097 | // 10/25/2004 pv - None is "reserved" color. cannot be defined in any file... |
1098 | if(pg.tagName()=="COLOR" && pg.attribute("NAME")!="None") |
||
1099 | { |
||
1100 | if (pg.hasAttribute("CMYK")) |
||
1101 | lf.setNamedColor(pg.attribute("CMYK")); |
||
1102 | else |
||
1103 | lf.fromQColor(QColor(pg.attribute("RGB"))); |
||
3051 | fschmid | 1104 | if (pg.hasAttribute("Spot")) |
4026 | craig | 1105 | lf.setSpotColor(static_cast<bool>(pg.attribute("Spot").toInt())); |
3051 | fschmid | 1106 | else |
1107 | lf.setSpotColor(false); |
||
3060 | fschmid | 1108 | if (pg.hasAttribute("Register")) |
4026 | craig | 1109 | lf.setRegistrationColor(static_cast<bool>(pg.attribute("Register").toInt())); |
3060 | fschmid | 1110 | else |
1111 | lf.setRegistrationColor(false); |
||
517 | fschmid | 1112 | doc->PageColors[pg.attribute("NAME")] = lf; |
1113 | } |
||
1114 | if(pg.tagName()=="STYLE") |
||
1115 | { |
||
1116 | vg.Vname = pg.attribute("NAME"); |
||
4026 | craig | 1117 | vg.LineSpaMode = pg.attribute("LINESPMode", "0").toInt(); |
1118 | vg.LineSpa = pg.attribute("LINESP").toDouble(); |
||
1119 | vg.Indent = pg.attribute("INDENT", "0").toDouble(); |
||
1120 | vg.First = pg.attribute("FIRST", "0").toDouble(); |
||
1121 | vg.textAlignment = pg.attribute("ALIGN").toInt(); |
||
1122 | vg.gapBefore = pg.attribute("VOR", "0").toDouble(); |
||
1123 | vg.gapAfter = pg.attribute("NACH", "0").toDouble(); |
||
1194 | fschmid | 1124 | tmpf = pg.attribute("FONT", doc->toolSettings.defFont); |
1428 | fschmid | 1125 | if ((!avail.find(tmpf)) || (!avail[tmpf]->UseFont)) |
1126 | { |
||
3650 | cbradney | 1127 | if ((!prefsManager->appPrefs.GFontSub.contains(tmpf)) || (!avail[prefsManager->appPrefs.GFontSub[tmpf]]->UseFont)) |
1468 | fschmid | 1128 | { |
1129 | newReplacement = true; |
||
3650 | cbradney | 1130 | ReplacedFonts.insert(tmpf, prefsManager->appPrefs.toolSettings.defFont); |
1468 | fschmid | 1131 | } |
1428 | fschmid | 1132 | else |
3650 | cbradney | 1133 | ReplacedFonts.insert(tmpf, prefsManager->appPrefs.GFontSub[tmpf]); |
1428 | fschmid | 1134 | } |
517 | fschmid | 1135 | else |
1428 | fschmid | 1136 | { |
1786 | fschmid | 1137 | if (!doc->UsedFonts.contains(tmpf)) |
1138 | { |
||
3544 | avox | 1139 | // QFont fo = avail[tmpf]->Font; |
1140 | // fo.setPointSize(qRound(doc->toolSettings.defSize / 10.0)); |
||
1141 | doc->AddFont(tmpf, qRound(doc->toolSettings.defSize / 10.0)); |
||
1786 | fschmid | 1142 | } |
1428 | fschmid | 1143 | } |
517 | fschmid | 1144 | vg.Font = tmpf; |
4026 | craig | 1145 | vg.FontSize = qRound(pg.attribute("FONTSIZE", "12").toDouble() * 10.0); |
1146 | vg.Drop = static_cast<bool>(pg.attribute("DROP", "0").toInt()); |
||
1147 | vg.DropLin = pg.attribute("DROPLIN", "2").toInt(); |
||
1148 | vg.DropDist = pg.attribute("DROPDIST", "0").toDouble(); |
||
1149 | vg.FontEffect = pg.attribute("EFFECT", "0").toInt(); |
||
1194 | fschmid | 1150 | vg.FColor = pg.attribute("FCOLOR", doc->toolSettings.dBrush); |
4026 | craig | 1151 | vg.FShade = pg.attribute("FSHADE", "100").toInt(); |
1194 | fschmid | 1152 | vg.SColor = pg.attribute("SCOLOR", doc->toolSettings.dPen); |
4026 | craig | 1153 | vg.SShade = pg.attribute("SSHADE", "100").toInt(); |
1154 | vg.BaseAdj = static_cast<bool>(pg.attribute("BASE", "0").toInt()); |
||
1155 | vg.txtShadowX=qRound(pg.attribute("TXTSHX", "5").toDouble() * 10); |
||
1156 | vg.txtShadowY=qRound(pg.attribute("TXTSHY", "-5").toDouble() * 10); |
||
1157 | vg.txtOutline=qRound(pg.attribute("TXTOUT", "1").toDouble() * 10); |
||
1158 | vg.txtUnderPos=qRound(pg.attribute("TXTULP", "-0.1").toDouble() * 10); |
||
1159 | vg.txtUnderWidth=qRound(pg.attribute("TXTULW", "-0.1").toDouble() * 10); |
||
1160 | vg.txtStrikePos=qRound(pg.attribute("TXTSTP", "-0.1").toDouble() * 10); |
||
1161 | vg.txtStrikeWidth=qRound(pg.attribute("TXTSTW", "-0.1").toDouble() * 10); |
||
1162 | vg.scaleH = qRound(pg.attribute("SCALEH", "100").toDouble() * 10); |
||
1163 | vg.scaleV = qRound(pg.attribute("SCALEV", "100").toDouble() * 10); |
||
1164 | vg.baseOff = qRound(pg.attribute("BASEO", "0").toDouble() * 10); |
||
1165 | vg.kernVal = qRound(pg.attribute("KERN", "0").toDouble() * 10); |
||
2282 | fschmid | 1166 | vg.TabValues.clear(); |
4026 | craig | 1167 | if ((pg.hasAttribute("NUMTAB")) && (pg.attribute("NUMTAB", "0").toInt() != 0)) |
517 | fschmid | 1168 | { |
2282 | fschmid | 1169 | struct PageItem::TabRecord tb; |
517 | fschmid | 1170 | tmp = pg.attribute("TABS"); |
1171 | QTextStream tgv(&tmp, IO_ReadOnly); |
||
4026 | craig | 1172 | for (int cxv = 0; cxv < pg.attribute("NUMTAB", "0").toInt(); cxv += 2) |
517 | fschmid | 1173 | { |
1174 | tgv >> xf; |
||
2282 | fschmid | 1175 | tgv >> xf2; |
1176 | tb.tabPosition = xf2; |
||
1177 | tb.tabType = static_cast<int>(xf); |
||
1178 | tb.tabFillChar = QChar(); |
||
1179 | vg.TabValues.append(tb); |
||
517 | fschmid | 1180 | } |
1181 | tmp = ""; |
||
1182 | } |
||
1183 | else |
||
2282 | fschmid | 1184 | { |
1185 | QDomNode IT = pg.firstChild(); |
||
1186 | while(!IT.isNull()) |
||
1187 | { |
||
1188 | QDomElement it = IT.toElement(); |
||
1189 | if (it.tagName()=="Tabs") |
||
1190 | { |
||
1191 | struct PageItem::TabRecord tb; |
||
4026 | craig | 1192 | tb.tabPosition = it.attribute("Pos").toDouble(); |
1193 | tb.tabType = it.attribute("Type").toInt(); |
||
2282 | fschmid | 1194 | QString tbCh = ""; |
1195 | tbCh = it.attribute("Fill",""); |
||
2877 | cbradney | 1196 | if (tbCh.isEmpty()) |
2282 | fschmid | 1197 | tb.tabFillChar = QChar(); |
1198 | else |
||
1199 | tb.tabFillChar = tbCh[0]; |
||
1200 | vg.TabValues.append(tb); |
||
1201 | } |
||
1202 | IT=IT.nextSibling(); |
||
1203 | } |
||
1204 | } |
||
1065 | cbradney | 1205 | doc->docParagraphStyles.append(vg); |
517 | fschmid | 1206 | } |
1207 | if(pg.tagName()=="JAVA") |
||
1208 | doc->JavaScripts[pg.attribute("NAME")] = pg.attribute("SCRIPT"); |
||
1209 | if(pg.tagName()=="LAYERS") |
||
1210 | { |
||
4026 | craig | 1211 | la.LNr = pg.attribute("NUMMER").toInt(); |
1212 | la.Level = pg.attribute("LEVEL").toInt(); |
||
517 | fschmid | 1213 | la.Name = pg.attribute("NAME"); |
4026 | craig | 1214 | la.isViewable = pg.attribute("SICHTBAR").toInt(); |
1215 | la.isPrintable = pg.attribute("DRUCKEN").toInt(); |
||
517 | fschmid | 1216 | doc->Layers.append(la); |
1217 | } |
||
1218 | if(pg.tagName()=="Bookmark") |
||
1219 | { |
||
1220 | bok.Title = pg.attribute("Title"); |
||
1221 | bok.Text = pg.attribute("Text"); |
||
1222 | bok.Aktion = pg.attribute("Aktion"); |
||
4026 | craig | 1223 | bok.ItemNr = pg.attribute("ItemNr").toInt(); |
1224 | bok.Seite = pg.attribute("Seite").toInt(); |
||
1225 | bok.Element = pg.attribute("Element").toInt(); |
||
1226 | bok.First = pg.attribute("First").toInt(); |
||
1227 | bok.Last = pg.attribute("Last").toInt(); |
||
1228 | bok.Prev = pg.attribute("Prev").toInt(); |
||
1229 | bok.Next = pg.attribute("Next").toInt(); |
||
1230 | bok.Parent = pg.attribute("Parent").toInt(); |
||
517 | fschmid | 1231 | doc->BookMarks.append(bok); |
1232 | } |
||
1233 | if(pg.tagName()=="MultiLine") |
||
1234 | { |
||
1235 | multiLine ml; |
||
1236 | QDomNode MuLn = PAGE.firstChild(); |
||
1237 | while(!MuLn.isNull()) |
||
1238 | { |
||
1239 | QDomElement MuL = MuLn.toElement(); |
||
1065 | cbradney | 1240 | struct SingleLine sl; |
517 | fschmid | 1241 | sl.Color = MuL.attribute("Color"); |
4026 | craig | 1242 | sl.Dash = MuL.attribute("Dash").toInt(); |
1243 | sl.LineEnd = MuL.attribute("LineEnd").toInt(); |
||
1244 | sl.LineJoin = MuL.attribute("LineJoin").toInt(); |
||
1245 | sl.Shade = MuL.attribute("Shade").toInt(); |
||
1246 | sl.Width = MuL.attribute("Width").toDouble(); |
||
517 | fschmid | 1247 | ml.push_back(sl); |
1248 | MuLn = MuLn.nextSibling(); |
||
1249 | } |
||
1250 | doc->MLineStyles.insert(pg.attribute("Name"), ml); |
||
1251 | } |
||
741 | fschmid | 1252 | if(pg.tagName()=="Arrows") |
1253 | { |
||
1065 | cbradney | 1254 | struct ArrowDesc arrow; |
760 | fschmid | 1255 | arrow.name = pg.attribute("Name"); |
776 | fschmid | 1256 | arrow.userArrow = true; |
741 | fschmid | 1257 | double xa, ya; |
1258 | QString tmp = pg.attribute("Points"); |
||
1259 | QTextStream fp(&tmp, IO_ReadOnly); |
||
1260 | for (uint cx = 0; cx < pg.attribute("NumPoints").toUInt(); ++cx) |
||
1261 | { |
||
1262 | fp >> xa; |
||
1263 | fp >> ya; |
||
760 | fschmid | 1264 | arrow.points.addPoint(xa, ya); |
741 | fschmid | 1265 | } |
1266 | doc->arrowStyles.append(arrow); |
||
1267 | } |
||
1642 | cbradney | 1268 | if(pg.tagName()=="PDF") |
1269 | { |
||
4026 | craig | 1270 | doc->PDF_Options.Articles = static_cast<bool>(pg.attribute("Articles").toInt()); |
1271 | doc->PDF_Options.Thumbnails = static_cast<bool>(pg.attribute("Thumbnails").toInt()); |
||
1272 | doc->PDF_Options.Compress = static_cast<bool>(pg.attribute("Compress").toInt()); |
||
1273 | doc->PDF_Options.CompressMethod = pg.attribute("CMethod", "0").toInt(); |
||
1274 | doc->PDF_Options.Quality = pg.attribute("Quality", "0").toInt(); |
||
1275 | doc->PDF_Options.RecalcPic = static_cast<bool>(pg.attribute("RecalcPic").toInt()); |
||
1276 | doc->PDF_Options.Bookmarks = static_cast<bool>(pg.attribute("Bookmarks").toInt()); |
||
1642 | cbradney | 1277 | if (pg.hasAttribute("MirrorH")) |
4026 | craig | 1278 | doc->PDF_Options.MirrorH = static_cast<bool>(pg.attribute("MirrorH").toInt()); |
1642 | cbradney | 1279 | else |
1280 | doc->PDF_Options.MirrorH = false; |
||
1281 | if (pg.hasAttribute("MirrorV")) |
||
4026 | craig | 1282 | doc->PDF_Options.MirrorV = static_cast<bool>(pg.attribute("MirrorV").toInt()); |
1642 | cbradney | 1283 | else |
1284 | doc->PDF_Options.MirrorV = false; |
||
1285 | if (pg.hasAttribute("RotateDeg")) |
||
4026 | craig | 1286 | doc->PDF_Options.RotateDeg = pg.attribute("RotateDeg", "0").toInt(); |
1642 | cbradney | 1287 | else |
1288 | doc->PDF_Options.RotateDeg = 0; |
||
4026 | craig | 1289 | doc->PDF_Options.PresentMode = static_cast<bool>(pg.attribute("PresentMode").toInt()); |
1290 | doc->PDF_Options.PicRes = pg.attribute("PicRes").toInt(); |
||
1973 | craig | 1291 | // Fixme: check input pdf version |
4026 | craig | 1292 | doc->PDF_Options.Version = (PDFOptions::PDFVersion)pg.attribute("Version").toInt(); |
1293 | doc->PDF_Options.Resolution = pg.attribute("Resolution").toInt(); |
||
1294 | doc->PDF_Options.Binding = pg.attribute("Binding").toInt(); |
||
1642 | cbradney | 1295 | doc->PDF_Options.Datei = ""; |
4026 | craig | 1296 | doc->PDF_Options.isGrayscale = static_cast<bool>(pg.attribute("Grayscale", "0").toInt()); |
1297 | doc->PDF_Options.UseRGB = static_cast<bool>(pg.attribute("RGBMode", "0").toInt()); |
||
1298 | doc->PDF_Options.UseProfiles = static_cast<bool>(pg.attribute("UseProfiles", "0").toInt()); |
||
1299 | doc->PDF_Options.UseProfiles2 = static_cast<bool>(pg.attribute("UseProfiles2", "0").toInt()); |
||
1300 | doc->PDF_Options.Intent = pg.attribute("Intent", "1").toInt(); |
||
1301 | doc->PDF_Options.Intent2 = pg.attribute("Intent2", "1").toInt(); |
||
1642 | cbradney | 1302 | doc->PDF_Options.SolidProf = pg.attribute("SolidP", ""); |
1303 | doc->PDF_Options.ImageProf = pg.attribute("ImageP", ""); |
||
1304 | doc->PDF_Options.PrintProf = pg.attribute("PrintP", ""); |
||
1305 | doc->PDF_Options.Info = pg.attribute("InfoString", ""); |
||
4026 | craig | 1306 | doc->PDF_Options.BleedTop = pg.attribute("BTop", "0").toDouble(); |
1307 | doc->PDF_Options.BleedLeft = pg.attribute("BLeft", "0").toDouble(); |
||
1308 | doc->PDF_Options.BleedRight = pg.attribute("BRight", "0").toDouble(); |
||
1309 | doc->PDF_Options.BleedBottom = pg.attribute("BBottom", "0").toDouble(); |
||
1310 | doc->PDF_Options.EmbeddedI = static_cast<bool>(pg.attribute("ImagePr", "0").toInt()); |
||
1642 | cbradney | 1311 | doc->PDF_Options.PassOwner = pg.attribute("PassOwner", ""); |
1312 | doc->PDF_Options.PassUser = pg.attribute("PassUser", ""); |
||
4026 | craig | 1313 | doc->PDF_Options.Permissions = pg.attribute("Permissions", "-4").toInt(); |
1314 | doc->PDF_Options.Encrypt = static_cast<bool>(pg.attribute("Encrypt", "0").toInt()); |
||
1315 | doc->PDF_Options.useLayers = static_cast<bool>(pg.attribute("UseLayers", "0").toInt()); |
||
1316 | doc->PDF_Options.UseLPI = static_cast<bool>(pg.attribute("UseLpi", "0").toInt()); |
||
1317 | doc->PDF_Options.UseSpotColors = static_cast<bool>(dc.attribute("UseSpotColors", "1").toInt()); |
||
1318 | doc->PDF_Options.doMultiFile = static_cast<bool>(dc.attribute("doMultiFile", "0").toInt()); |
||
4197 | fschmid | 1319 | doc->PDF_Options.displayBookmarks = static_cast<bool>(dc.attribute("displayBookmarks", "0").toInt()); |
1320 | doc->PDF_Options.displayFullscreen = static_cast<bool>(dc.attribute("displayFullscreen", "0").toInt()); |
||
1321 | doc->PDF_Options.displayLayers = static_cast<bool>(dc.attribute("displayLayers", "0").toInt()); |
||
1322 | doc->PDF_Options.displayThumbs = static_cast<bool>(dc.attribute("displayThumbs", "0").toInt()); |
||
1323 | doc->PDF_Options.PageLayout = dc.attribute("PageLayout", "0").toInt(); |
||
1324 | doc->PDF_Options.openAction = dc.attribute("openAction", ""); |
||
1642 | cbradney | 1325 | QDomNode PFO = PAGE.firstChild(); |
1326 | while(!PFO.isNull()) |
||
1327 | { |
||
1328 | QDomElement pdfF = PFO.toElement(); |
||
1329 | if(pdfF.tagName() == "LPI") |
||
1330 | { |
||
1331 | struct LPIData lpo; |
||
4026 | craig | 1332 | lpo.Angle = pdfF.attribute("Angle").toInt(); |
1333 | lpo.Frequency = pdfF.attribute("Frequency").toInt(); |
||
1334 | lpo.SpotFunc = pdfF.attribute("SpotFunction").toInt(); |
||
1642 | cbradney | 1335 | doc->PDF_Options.LPISettings[pdfF.attribute("Color")] = lpo; |
1336 | } |
||
1337 | if(pdfF.tagName() == "Fonts") |
||
1338 | { |
||
1339 | if (!doc->PDF_Options.EmbedList.contains(pdfF.attribute("Name"))) |
||
1340 | doc->PDF_Options.EmbedList.append(pdfF.attribute("Name")); |
||
1341 | } |
||
1342 | if(pdfF.tagName() == "Subset") |
||
1343 | { |
||
1344 | if (!doc->PDF_Options.SubsetList.contains(pdfF.attribute("Name"))) |
||
1345 | doc->PDF_Options.SubsetList.append(pdfF.attribute("Name")); |
||
1346 | } |
||
1347 | if(pdfF.tagName() == "Effekte") |
||
1348 | { |
||
1349 | struct PDFPresentationData ef; |
||
4026 | craig | 1350 | ef.pageEffectDuration = pdfF.attribute("pageEffectDuration").toInt(); |
1351 | ef.pageViewDuration = pdfF.attribute("pageViewDuration").toInt(); |
||
1352 | ef.effectType = pdfF.attribute("effectType").toInt(); |
||
1353 | ef.Dm = pdfF.attribute("Dm").toInt(); |
||
1354 | ef.M = pdfF.attribute("M").toInt(); |
||
1355 | ef.Di = pdfF.attribute("Di").toInt(); |
||
1642 | cbradney | 1356 | doc->PDF_Options.PresentVals.append(ef); |
1357 | } |
||
1358 | PFO = PFO.nextSibling(); |
||
1359 | } |
||
1360 | } |
||
1361 | if(pg.tagName()=="DocItemAttributes") |
||
1362 | { |
||
1363 | QDomNode DIA = PAGE.firstChild(); |
||
1364 | doc->docItemAttributes.clear(); |
||
1365 | while(!DIA.isNull()) |
||
1366 | { |
||
1367 | QDomElement itemAttr = DIA.toElement(); |
||
1368 | if(itemAttr.tagName() == "ItemAttribute") |
||
1369 | { |
||
1370 | ObjectAttribute objattr; |
||
1371 | objattr.name=itemAttr.attribute("Name"); |
||
1372 | objattr.type=itemAttr.attribute("Type"); |
||
1373 | objattr.value=itemAttr.attribute("Value"); |
||
1374 | objattr.parameter=itemAttr.attribute("Parameter"); |
||
1654 | cbradney | 1375 | objattr.relationship=itemAttr.attribute("Relationship"); |
1376 | objattr.relationshipto=itemAttr.attribute("RelationshipTo"); |
||
1377 | objattr.autoaddto=itemAttr.attribute("AutoAddTo"); |
||
1649 | cbradney | 1378 | doc->docItemAttributes.append(objattr); |
1642 | cbradney | 1379 | } |
1380 | DIA = DIA.nextSibling(); |
||
1381 | } |
||
1382 | } |
||
1694 | cbradney | 1383 | if(pg.tagName()=="TablesOfContents") |
1384 | { |
||
1385 | QDomNode TOC = PAGE.firstChild(); |
||
1386 | doc->docToCSetups.clear(); |
||
1387 | while(!TOC.isNull()) |
||
1388 | { |
||
1389 | QDomElement tocElem = TOC.toElement(); |
||
1390 | if(tocElem.tagName() == "TableOfContents") |
||
1391 | { |
||
1392 | ToCSetup tocsetup; |
||
1393 | tocsetup.name=tocElem.attribute("Name"); |
||
1394 | tocsetup.itemAttrName=tocElem.attribute("ItemAttributeName"); |
||
1395 | tocsetup.frameName=tocElem.attribute("FrameName"); |
||
2449 | cbradney | 1396 | tocsetup.listNonPrintingFrames=tocElem.attribute("ListNonPrinting"); |
2445 | cbradney | 1397 | tocsetup.textStyle=tocElem.attribute("Style"); |
1398 | QString numberPlacement=tocElem.attribute("NumberPlacement"); |
||
1399 | if (numberPlacement=="Beginning") |
||
1400 | tocsetup.pageLocation=Beginning; |
||
1401 | if (numberPlacement=="End") |
||
1402 | tocsetup.pageLocation=End; |
||
1403 | if (numberPlacement=="NotShown") |
||
1404 | tocsetup.pageLocation=NotShown; |
||
1694 | cbradney | 1405 | doc->docToCSetups.append(tocsetup); |
1406 | } |
||
1407 | TOC = TOC.nextSibling(); |
||
1408 | } |
||
1409 | } |
||
3757 | cbradney | 1410 | if(pg.tagName()=="Sections") |
1411 | { |
||
1412 | QDomNode Section = PAGE.firstChild(); |
||
1413 | while(!Section.isNull()) |
||
1414 | { |
||
1415 | QDomElement sectionElem = Section.toElement(); |
||
1416 | if(sectionElem.tagName() == "Section") |
||
1417 | { |
||
1418 | struct DocumentSection newSection; |
||
4026 | craig | 1419 | newSection.number=sectionElem.attribute("Number").toInt(); |
3757 | cbradney | 1420 | newSection.name=sectionElem.attribute("Name"); |
4026 | craig | 1421 | newSection.fromindex=sectionElem.attribute("From").toInt(); |
1422 | newSection.toindex=sectionElem.attribute("To").toInt(); |
||
3757 | cbradney | 1423 | if (sectionElem.attribute("Type")=="Type_1_2_3") |
1424 | newSection.type=Type_1_2_3; |
||
1425 | if (sectionElem.attribute("Type")=="Type_i_ii_iii") |
||
1426 | newSection.type=Type_i_ii_iii; |
||
1427 | if (sectionElem.attribute("Type")=="Type_I_II_III") |
||
1428 | newSection.type=Type_I_II_III; |
||
1429 | if (sectionElem.attribute("Type")=="Type_a_b_c") |
||
1430 | newSection.type=Type_a_b_c; |
||
1431 | if (sectionElem.attribute("Type")=="Type_A_B_C") |
||
1432 | newSection.type=Type_A_B_C; |
||
4026 | craig | 1433 | newSection.sectionstartindex=sectionElem.attribute("Start").toInt(); |
1434 | newSection.reversed=static_cast<bool>(sectionElem.attribute("Reversed").toInt()); |
||
1435 | newSection.active=static_cast<bool>(sectionElem.attribute("Active").toInt()); |
||
3757 | cbradney | 1436 | doc->sections.insert(newSection.number, newSection); |
1437 | } |
||
1438 | Section = Section.nextSibling(); |
||
1439 | } |
||
1440 | } |
||
517 | fschmid | 1441 | if ((pg.tagName()=="PAGE") || (pg.tagName()=="MASTERPAGE")) |
1442 | { |
||
4026 | craig | 1443 | a = pg.attribute("NUM").toInt(); |
517 | fschmid | 1444 | PgNam = ""; |
1445 | PgNam = pg.attribute("NAM", ""); |
||
3757 | cbradney | 1446 | //Pgc = doc->pageCount; |
1447 | //AtFl = doc->usesAutomaticTextFrames(); |
||
2877 | cbradney | 1448 | if (PgNam.isEmpty()) |
517 | fschmid | 1449 | { |
3757 | cbradney | 1450 | //doc->pageCount = Pgc; |
3724 | cbradney | 1451 | //doc->Pages = &doc->DocPages; |
3757 | cbradney | 1452 | //doc->setUsesAutomaticTextFrames(AtFl); |
3724 | cbradney | 1453 | doc->setMasterPageMode(false); |
517 | fschmid | 1454 | } |
1455 | else |
||
1456 | { |
||
3757 | cbradney | 1457 | //doc->pageCount = 0; |
1458 | //doc->setUsesAutomaticTextFrames(false); |
||
3724 | cbradney | 1459 | //doc->Pages = &doc->MasterPages; |
1460 | doc->setMasterPageMode(true); |
||
517 | fschmid | 1461 | } |
3648 | cbradney | 1462 | //CB: Stop calling damn GUI code in loading docs! IT doesnt *look* like |
1463 | //this makes a difference apart from being faster, of course. |
||
4026 | craig | 1464 | //ScMW->slotNewPage(a); |
3648 | cbradney | 1465 | //Apage = doc->Pages.at(a); |
2877 | cbradney | 1466 | if (PgNam.isEmpty()) |
2109 | fschmid | 1467 | { |
3757 | cbradney | 1468 | Apage = doc->addPage(a); |
3724 | cbradney | 1469 | //doc->DocPages = doc->Pages; |
4069 | craig | 1470 | //++doc->pageCount; |
2109 | fschmid | 1471 | } |
517 | fschmid | 1472 | else |
1473 | { |
||
3757 | cbradney | 1474 | Apage = doc->addMasterPage(a, PgNam); |
1475 | //Apage->setPageName(PgNam); |
||
1476 | //doc->MasterNames[PgNam] = a; |
||
3724 | cbradney | 1477 | //doc->MasterPages = doc->Pages; |
3757 | cbradney | 1478 | //doc->pageCount = Pgc; |
517 | fschmid | 1479 | } |
3757 | cbradney | 1480 | //doc->setUsesAutomaticTextFrames(AtFl); |
4026 | craig | 1481 | Apage->LeftPg=pg.attribute("LEFT", "0").toInt(); |
517 | fschmid | 1482 | QString Mus = ""; |
1483 | Mus = pg.attribute("MNAM","Normal"); |
||
3724 | cbradney | 1484 | if (!doc->masterPageMode()) |
517 | fschmid | 1485 | Apage->MPageNam = Mus; |
1486 | else |
||
1487 | Apage->MPageNam = ""; |
||
2880 | fschmid | 1488 | if (pg.hasAttribute("Size")) |
1489 | Apage->PageSize = pg.attribute("Size"); |
||
1490 | if (pg.hasAttribute("Orientation")) |
||
4026 | craig | 1491 | Apage->PageOri = pg.attribute("Orientation").toInt(); |
1492 | Apage->setXOffset(pg.attribute("PAGEXPOS").toDouble()); |
||
1493 | Apage->setYOffset(pg.attribute("PAGEYPOS").toDouble()); |
||
2305 | cbradney | 1494 | if (pg.hasAttribute("PAGEWIDTH")) |
4026 | craig | 1495 | Apage->setWidth(pg.attribute("PAGEWIDTH").toDouble()); |
2305 | cbradney | 1496 | else |
4026 | craig | 1497 | Apage->setWidth(pg.attribute("PAGEWITH").toDouble()); |
1498 | Apage->setHeight(pg.attribute("PAGEHEIGHT").toDouble()); |
||
3200 | cbradney | 1499 | Apage->setInitialHeight(Apage->height()); |
1500 | Apage->setInitialWidth(Apage->width()); |
||
4026 | craig | 1501 | Apage->initialMargins.Top = pg.attribute("BORDERTOP").toDouble(); |
1502 | Apage->initialMargins.Bottom = pg.attribute("BORDERBOTTOM").toDouble(); |
||
1503 | Apage->initialMargins.Left = pg.attribute("BORDERLEFT").toDouble(); |
||
1504 | Apage->initialMargins.Right = pg.attribute("BORDERRIGHT").toDouble(); |
||
2777 | fschmid | 1505 | Apage->Margins.Top = Apage->initialMargins.Top; |
1506 | Apage->Margins.Bottom = Apage->initialMargins.Bottom; |
||
3724 | cbradney | 1507 | doc->setMasterPageMode(false); |
1508 | //doc->Pages=&doc->DocPages; |
||
4026 | craig | 1509 | if ((pg.hasAttribute("NumVGuides")) && (pg.attribute("NumVGuides", "0").toInt() != 0)) |
517 | fschmid | 1510 | { |
1511 | tmp = pg.attribute("VerticalGuides"); |
||
1512 | QTextStream fgv(&tmp, IO_ReadOnly); |
||
1513 | Apage->YGuides.clear(); |
||
4026 | craig | 1514 | for (int cxv = 0; cxv < pg.attribute("NumVGuides", "0").toInt(); ++cxv) |
517 | fschmid | 1515 | { |
1516 | fgv >> xf; |
||
1517 | Apage->YGuides.append(xf); |
||
1518 | } |
||
1519 | qHeapSort(Apage->YGuides); |
||
1520 | tmp = ""; |
||
1521 | } |
||
1522 | else |
||
1523 | Apage->YGuides.clear(); |
||
4026 | craig | 1524 | if ((pg.hasAttribute("NumHGuides")) && (pg.attribute("NumHGuides", "0").toInt() != 0)) |
517 | fschmid | 1525 | { |
1526 | tmp = pg.attribute("HorizontalGuides"); |
||
1527 | QTextStream fgh(&tmp, IO_ReadOnly); |
||
1528 | Apage->XGuides.clear(); |
||
4026 | craig | 1529 | for (int cxh = 0; cxh < pg.attribute("NumHGuides", "0").toInt(); ++cxh) |
517 | fschmid | 1530 | { |
1531 | fgh >> xf; |
||
1532 | Apage->XGuides.append(xf); |
||
1533 | } |
||
1534 | qHeapSort(Apage->XGuides); |
||
1535 | tmp = ""; |
||
1536 | } |
||
1537 | else |
||
1538 | Apage->XGuides.clear(); |
||
1800 | cbradney | 1539 | } |
2447 | fschmid | 1540 | if ((pg.tagName()=="PAGEOBJECT") || (pg.tagName()=="MASTEROBJECT") || (pg.tagName()=="FRAMEOBJECT")) |
517 | fschmid | 1541 | { |
2447 | fschmid | 1542 | if ((pg.tagName()=="PAGEOBJECT") || (pg.tagName()=="FRAMEOBJECT")) |
522 | fschmid | 1543 | { |
3727 | cbradney | 1544 | //doc->Items = doc->DocItems; |
3724 | cbradney | 1545 | //doc->Pages = &doc->DocPages; |
1546 | doc->setMasterPageMode(false); |
||
522 | fschmid | 1547 | } |
517 | fschmid | 1548 | else |
522 | fschmid | 1549 | { |
3727 | cbradney | 1550 | //doc->Items = doc->MasterItems; |
3724 | cbradney | 1551 | //doc->Pages = &doc->MasterPages; |
1552 | doc->setMasterPageMode(true); |
||
522 | fschmid | 1553 | } |
2877 | cbradney | 1554 | if ((!pg.attribute("OnMasterPage").isEmpty()) && (pg.tagName()=="MASTEROBJECT")) |
1065 | cbradney | 1555 | doc->currentPage = doc->MasterPages.at(doc->MasterNames[pg.attribute("OnMasterPage")]); |
4026 | craig | 1556 | if ((pg.attribute("NEXTITEM").toInt() != -1) || (static_cast<bool>(pg.attribute("AUTOTEXT").toInt()))) |
517 | fschmid | 1557 | { |
4026 | craig | 1558 | if (pg.attribute("BACKITEM").toInt() == -1) |
3727 | cbradney | 1559 | LFrames.append(doc->Items->count()); |
517 | fschmid | 1560 | } |
1779 | fschmid | 1561 | int docGc = doc->GroupCounter; |
1562 | doc->GroupCounter = 0; |
||
3657 | cbradney | 1563 | Neu = PasteItem(&pg, doc); |
1564 | Neu->setRedrawBounding(); |
||
1565 | Neu->OwnPage = pg.attribute("OwnPage").toInt(); |
||
1786 | fschmid | 1566 | if (pg.tagName()=="PAGEOBJECT") |
1567 | Neu->OnMasterPage = ""; |
||
1779 | fschmid | 1568 | doc->GroupCounter = docGc; |
1194 | fschmid | 1569 | tmpf = pg.attribute("IFONT", doc->toolSettings.defFont); |
1428 | fschmid | 1570 | if ((!avail.find(tmpf)) || (!avail[tmpf]->UseFont)) |
1571 | { |
||
3650 | cbradney | 1572 | if ((!prefsManager->appPrefs.GFontSub.contains(tmpf)) || (!avail[prefsManager->appPrefs.GFontSub[tmpf]]->UseFont)) |
1468 | fschmid | 1573 | { |
1574 | newReplacement = true; |
||
3650 | cbradney | 1575 | ReplacedFonts.insert(tmpf, prefsManager->appPrefs.toolSettings.defFont); |
1468 | fschmid | 1576 | } |
1428 | fschmid | 1577 | else |
3650 | cbradney | 1578 | ReplacedFonts.insert(tmpf, prefsManager->appPrefs.GFontSub[tmpf]); |
1428 | fschmid | 1579 | } |
517 | fschmid | 1580 | else |
1428 | fschmid | 1581 | { |
1786 | fschmid | 1582 | if (!doc->UsedFonts.contains(tmpf)) |
1583 | { |
||
3544 | avox | 1584 | // QFont fo = avail[tmpf]->Font; |
1585 | // fo.setPointSize(qRound(doc->toolSettings.defSize / 10.0)); |
||
1586 | doc->AddFont(tmpf, qRound(doc->toolSettings.defSize / 10.0)); |
||
1786 | fschmid | 1587 | } |
1428 | fschmid | 1588 | } |
4073 | cbradney | 1589 | Neu->setFont(tmpf); |
517 | fschmid | 1590 | QDomNode IT=pg.firstChild(); |
1591 | while(!IT.isNull()) |
||
1592 | { |
||
1593 | QDomElement it=IT.toElement(); |
||
1594 | if (it.tagName()=="CSTOP") |
||
1595 | { |
||
1596 | QString name = it.attribute("NAME"); |
||
4026 | craig | 1597 | double ramp = it.attribute("RAMP", "0.0").toDouble(); |
1598 | int shade = it.attribute("SHADE", "100").toInt(); |
||
1599 | double opa = it.attribute("TRANS", "1").toDouble(); |
||
1779 | fschmid | 1600 | Neu->fill_gradient.addStop(SetColor(doc, name, shade), ramp, 0.5, opa, name, shade); |
517 | fschmid | 1601 | } |
1602 | if (it.tagName()=="ITEXT") |
||
2834 | cbradney | 1603 | GetItemText(&it, doc, Neu); |
1655 | cbradney | 1604 | |
1605 | //CB PageItemAttributes |
||
1606 | if(it.tagName()=="PageItemAttributes") |
||
1607 | { |
||
1608 | QDomNode PIA = it.firstChild(); |
||
1609 | ObjAttrVector pageItemAttributes; |
||
1610 | while(!PIA.isNull()) |
||
1611 | { |
||
1612 | QDomElement itemAttr = PIA.toElement(); |
||
1613 | if(itemAttr.tagName() == "ItemAttribute") |
||
1614 | { |
||
1615 | ObjectAttribute objattr; |
||
1616 | objattr.name=itemAttr.attribute("Name"); |
||
1617 | objattr.type=itemAttr.attribute("Type"); |
||
1618 | objattr.value=itemAttr.attribute("Value"); |
||
1619 | objattr.parameter=itemAttr.attribute("Parameter"); |
||
1620 | objattr.relationship=itemAttr.attribute("Relationship"); |
||
1621 | objattr.relationshipto=itemAttr.attribute("RelationshipTo"); |
||
1622 | objattr.autoaddto=itemAttr.attribute("AutoAddTo"); |
||
1623 | pageItemAttributes.append(objattr); |
||
1624 | } |
||
1625 | PIA = PIA.nextSibling(); |
||
1626 | } |
||
1779 | fschmid | 1627 | Neu->setObjectAttributes(&pageItemAttributes); |
1655 | cbradney | 1628 | } |
517 | fschmid | 1629 | IT=IT.nextSibling(); |
1630 | } |
||
2179 | fschmid | 1631 | if (Neu->fill_gradient.Stops() == 0) |
517 | fschmid | 1632 | { |
2179 | fschmid | 1633 | Neu->fill_gradient.addStop(doc->PageColors[doc->toolSettings.dBrush].getRGBColor(), 0.0, 0.5, 1.0, doc->toolSettings.dBrush, 100); |
1634 | Neu->fill_gradient.addStop(doc->PageColors[doc->toolSettings.dPen].getRGBColor(), 1.0, 0.5, 1.0, doc->toolSettings.dPen, 100); |
||
517 | fschmid | 1635 | } |
4026 | craig | 1636 | Neu->Language = ScMW->GetLang(pg.attribute("LANGUAGE", doc->Language)); |
1637 | Neu->isAutoText = static_cast<bool>(pg.attribute("AUTOTEXT").toInt()); |
||
1638 | Neu->isEmbedded = static_cast<bool>(pg.attribute("isInline", "0").toInt()); |
||
1639 | Neu->gXpos = pg.attribute("gXpos", "0.0").toDouble(); |
||
1640 | Neu->gYpos = pg.attribute("gYpos", "0.0").toDouble(); |
||
2955 | fschmid | 1641 | QString defaultVal; |
3934 | cbradney | 1642 | defaultVal.setNum(Neu->width()); |
4026 | craig | 1643 | Neu->gWidth = pg.attribute("gWidth",defaultVal).toDouble(); |
3934 | cbradney | 1644 | defaultVal.setNum(Neu->height()); |
4026 | craig | 1645 | Neu->gHeight = pg.attribute("gHeight",defaultVal).toDouble(); |
2309 | fschmid | 1646 | if (Neu->LineSpMode == 3) |
1647 | { |
||
1648 | doc->docParagraphStyles[0].BaseAdj = true; |
||
2889 | cbradney | 1649 | Neu->LineSp = doc->typographicSettings.valueBaseGrid-1; |
2309 | fschmid | 1650 | } |
517 | fschmid | 1651 | if (Neu->isAutoText) |
1652 | doc->LastAuto = Neu; |
||
4026 | craig | 1653 | Neu->NextIt = pg.attribute("NEXTITEM").toInt(); |
517 | fschmid | 1654 | if (Neu->isTableItem) |
1655 | { |
||
1656 | TableItems.append(Neu); |
||
4026 | craig | 1657 | TableID.insert(pg.attribute("OwnLINK", "0").toInt(), Neu->ItemNr); |
517 | fschmid | 1658 | } |
2447 | fschmid | 1659 | if (pg.tagName()=="FRAMEOBJECT") |
522 | fschmid | 1660 | { |
3727 | cbradney | 1661 | doc->FrameItems.append(doc->Items->take(Neu->ItemNr)); |
2447 | fschmid | 1662 | Neu->ItemNr = doc->FrameItems.count()-1; |
1663 | } |
||
3727 | cbradney | 1664 | /* |
2447 | fschmid | 1665 | if ((pg.tagName()=="PAGEOBJECT") || (pg.tagName()=="FRAMEOBJECT")) |
1666 | { |
||
3727 | cbradney | 1667 | //doc->DocItems = doc->Items; |
3724 | cbradney | 1668 | //doc->DocPages = doc->Pages; |
522 | fschmid | 1669 | } |
517 | fschmid | 1670 | else |
522 | fschmid | 1671 | { |
3727 | cbradney | 1672 | //doc->MasterItems = doc->Items; |
3724 | cbradney | 1673 | //doc->MasterPages = doc->Pages; |
522 | fschmid | 1674 | } |
3727 | cbradney | 1675 | */ |
3724 | cbradney | 1676 | doc->setMasterPageMode( |