Rev 6747 | Rev 6846 | 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 "scribus134format.moc" |
||
9 | #include "scribus134formatimpl.h" |
||
10 | |||
11 | #include "../../formatidlist.h" |
||
12 | #include "commonstrings.h" |
||
13 | #include "missing.h" |
||
14 | #include "prefsmanager.h" |
||
15 | #include "scconfig.h" |
||
16 | #include "scribusdoc.h" |
||
17 | #include "scribusview.h" |
||
18 | |||
19 | #include "units.h" |
||
20 | #include "util.h" |
||
6125 | cbradney | 21 | #include "colorutil.h" |
5653 | cbradney | 22 | #ifdef HAVE_LIBZ |
23 | #include <zlib.h> |
||
24 | #endif |
||
25 | #include <qcursor.h> |
||
26 | #include <qfileinfo.h> |
||
27 | #include <qvaluelist.h> |
||
28 | |||
29 | |||
30 | // See scplugin.h and pluginmanager.{cpp,h} for detail on what these methods |
||
31 | // do. That documentatation is not duplicated here. |
||
32 | // Please don't implement the functionality of your plugin here; do that |
||
33 | // in scribus134formatimpl.h and scribus134formatimpl.cpp . |
||
34 | |||
35 | Scribus134Format::Scribus134Format() : |
||
36 | LoadSavePlugin() |
||
37 | { |
||
38 | // Set action info in languageChange, so we only have to do |
||
39 | // it in one place. This includes registering file formats. |
||
40 | languageChange(); |
||
41 | } |
||
42 | |||
43 | Scribus134Format::~Scribus134Format() |
||
44 | { |
||
45 | unregisterAll(); |
||
46 | }; |
||
47 | |||
48 | void Scribus134Format::languageChange() |
||
49 | { |
||
50 | //(Re)register file formats. |
||
51 | unregisterAll(); |
||
52 | registerFormats(); |
||
53 | } |
||
54 | |||
55 | const QString Scribus134Format::fullTrName() const |
||
56 | { |
||
57 | return QObject::tr("Scribus 1.3.4 Support"); |
||
58 | } |
||
59 | |||
60 | const ScActionPlugin::AboutData* Scribus134Format::getAboutData() const |
||
61 | { |
||
62 | AboutData* about = new AboutData; |
||
63 | Q_CHECK_PTR(about); |
||
64 | return about; |
||
65 | } |
||
66 | |||
67 | void Scribus134Format::deleteAboutData(const AboutData* about) const |
||
68 | { |
||
69 | Q_ASSERT(about); |
||
70 | delete about; |
||
71 | } |
||
72 | |||
73 | void Scribus134Format::registerFormats() |
||
74 | { |
||
75 | FileFormat fmt(this); |
||
76 | fmt.trName = tr("Scribus 1.3.4 Document"); |
||
77 | fmt.formatId = FORMATID_SLA134IMPORT; |
||
78 | fmt.load = true; |
||
79 | fmt.save = true; |
||
80 | #ifdef HAVE_LIBZ |
||
81 | fmt.filter = fmt.trName + " (*.sla *.SLA *.sla.gz *.SLA.GZ *.scd *.SCD *.scd.gz *.SCD.GZ)"; |
||
82 | fmt.nameMatch = QRegExp("\\.(sla|scd)(\\.gz)?", false); |
||
83 | #else |
||
84 | fmt.filter = fmt.trName + " (*.sla *.SLA *.scd *.SCD)"; |
||
85 | fmt.nameMatch = QRegExp("\\.(sla|scd)", false); |
||
86 | #endif |
||
87 | fmt.mimeTypes = QStringList(); |
||
88 | fmt.mimeTypes.append("application/x-scribus"); |
||
89 | fmt.priority = 64; |
||
90 | registerFormat(fmt); |
||
91 | } |
||
92 | |||
93 | bool Scribus134Format::fileSupported(QIODevice* /* file */, const QString & fileName) const |
||
94 | { |
||
95 | QCString docBytes(""); |
||
96 | if(fileName.right(2) == "gz") |
||
97 | { |
||
98 | #ifdef HAVE_LIBZ |
||
99 | static const int gzipExpansionFactor=8; |
||
100 | // The file is gzip encoded and we can load gzip files. |
||
101 | // Set up to read the gzip file |
||
102 | gzFile gzDoc; |
||
103 | int i; |
||
104 | gzDoc = gzopen(fileName.latin1(),"rb"); |
||
105 | if(gzDoc == NULL) |
||
106 | { |
||
107 | // FIXME: Needs better error return |
||
108 | return ""; |
||
109 | } |
||
110 | // Allocate a buffer of a multiple of the compressed size of the file |
||
111 | // as a starting point for loading. We'll expand this buffer by powers |
||
112 | // of two if we run out of space. |
||
113 | const QFileInfo fi(fileName); |
||
114 | uint bufSize = QMIN(4096, fi.size()*gzipExpansionFactor); |
||
115 | docBytes = QCString(bufSize); |
||
116 | char* buf = docBytes.data(); |
||
117 | uint bytesRead = 0; |
||
118 | // While there's free space, read into the buffer.... |
||
119 | while (bytesRead<4096 && (i = gzread(gzDoc,buf,bufSize-bytesRead-1)) > 0) |
||
120 | { |
||
121 | // Ensure the string is null-terminated and move the |
||
122 | // write pointer to the current position. |
||
123 | buf[i]=0; |
||
124 | buf+=i; |
||
125 | bytesRead += i; |
||
126 | // And check that there's free space to work with, expanding the |
||
127 | // buffer if there's not. |
||
128 | if (bufSize - bytesRead < 4096) |
||
129 | { |
||
130 | bufSize *= 2; |
||
131 | docBytes.resize(bufSize); |
||
132 | buf = docBytes.data() + bytesRead; |
||
133 | } |
||
134 | } |
||
135 | gzclose(gzDoc); |
||
136 | #else |
||
137 | // The file is gzip encoded but we can't load gzip files. |
||
138 | // Leave `f' empty, since we have no way to |
||
139 | // report a failure condition from here. |
||
140 | return false; |
||
141 | #endif |
||
142 | } |
||
143 | else |
||
144 | { |
||
145 | // Not gzip encoded, just load it |
||
146 | loadRawText(fileName, docBytes); |
||
147 | } |
||
148 | if (docBytes.left(16) == "<SCRIBUSUTF8NEW " && docBytes.left(35).contains("Version=\"1.3.4")) |
||
149 | return true; |
||
150 | return false; |
||
151 | } |
||
152 | |||
153 | QString Scribus134Format::readSLA(const QString & fileName) |
||
154 | { |
||
155 | QCString docBytes(""); |
||
156 | if(fileName.right(2) == "gz") |
||
157 | { |
||
158 | #ifdef HAVE_LIBZ |
||
159 | static const int gzipExpansionFactor=8; |
||
160 | // The file is gzip encoded and we can load gzip files. |
||
161 | // Set up to read the gzip file |
||
162 | gzFile gzDoc; |
||
163 | int i; |
||
164 | gzDoc = gzopen(fileName.latin1(),"rb"); |
||
165 | if(gzDoc == NULL) |
||
166 | { |
||
167 | // FIXME: Needs better error return |
||
168 | return ""; |
||
169 | } |
||
170 | // Allocate a buffer of a multiple of the compressed size of the file |
||
171 | // as a starting point for loading. We'll expand this buffer by powers |
||
172 | // of two if we run out of space. |
||
173 | const QFileInfo fi(fileName); |
||
174 | uint bufSize = fi.size()*gzipExpansionFactor; |
||
175 | docBytes = QCString(bufSize); |
||
176 | char* buf = docBytes.data(); |
||
177 | uint bytesRead = 0; |
||
178 | // While there's free space, read into the buffer.... |
||
179 | while ((i = gzread(gzDoc,buf,bufSize-bytesRead-1)) > 0) |
||
180 | { |
||
181 | // Ensure the string is null-terminated and move the |
||
182 | // write pointer to the current position. |
||
183 | buf[i]=0; |
||
184 | buf+=i; |
||
185 | bytesRead += i; |
||
186 | // And check that there's free space to work with, expanding the |
||
187 | // buffer if there's not. |
||
188 | if (bufSize - bytesRead < 4096) |
||
189 | { |
||
190 | bufSize *= 2; |
||
191 | docBytes.resize(bufSize); |
||
192 | buf = docBytes.data() + bytesRead; |
||
193 | } |
||
194 | } |
||
195 | gzclose(gzDoc); |
||
196 | #else |
||
197 | // The file is gzip encoded but we can't load gzip files. |
||
198 | // Leave `f' empty, since we have no way to |
||
199 | // report a failure condition from here. |
||
200 | return false; |
||
201 | #endif |
||
202 | } |
||
203 | else |
||
204 | { |
||
205 | // Not gzip encoded, just load it |
||
206 | loadRawText(fileName, docBytes); |
||
207 | } |
||
208 | QString docText(""); |
||
209 | if (docBytes.left(16) == "<SCRIBUSUTF8NEW " && docBytes.left(35).contains("Version=\"1.3.4")) |
||
210 | docText = QString::fromUtf8(docBytes); |
||
211 | else |
||
212 | return QString::null; |
||
213 | if (docText.endsWith(QChar(10)) || docText.endsWith(QChar(13))) |
||
214 | docText.truncate(docText.length()-1); |
||
215 | return docText; |
||
216 | } |
||
217 | |||
5980 | avox | 218 | void Scribus134Format::getReplacedFontData(bool & getNewReplacement, QMap<QString,QString> &getReplacedFonts, QValueList<ScFace> &getDummyScFaces) |
5653 | cbradney | 219 | { |
220 | getNewReplacement=newReplacement; |
||
221 | getReplacedFonts=ReplacedFonts; |
||
6733 | avox | 222 | // getDummyScFaces=dummyScFaces; |
5653 | cbradney | 223 | } |
224 | |||
225 | bool Scribus134Format::loadFile(const QString & fileName, const FileFormat & /* fmt */, int /* flags */, int /* index */) |
||
226 | { |
||
227 | if (m_Doc==0 || m_AvailableFonts==0) |
||
228 | { |
||
229 | Q_ASSERT(m_Doc==0 || m_AvailableFonts==0); |
||
230 | return false; |
||
231 | } |
||
232 | ReplacedFonts.clear(); |
||
233 | newReplacement = false; |
||
5980 | avox | 234 | dummyScFaces.clear(); |
5653 | cbradney | 235 | ParagraphStyle vg; |
236 | struct Layer la; |
||
237 | struct ScribusDoc::BookMa bok; |
||
238 | int counter;//, Pgc; |
||
239 | //bool AtFl; |
||
240 | bool newVersion = false; |
||
241 | QString tmp, tmpf, tmp2, tmp3, tmp4, PgNam, Defont, tmf; |
||
242 | QFont fo; |
||
243 | QMap<int,int> TableID; |
||
244 | QPtrList<PageItem> TableItems; |
||
6451 | fschmid | 245 | QMap<PageItem*, int> groupID; |
5653 | cbradney | 246 | int a; |
247 | PageItem *Neu; |
||
248 | Page* Apage; |
||
249 | LFrames.clear(); |
||
250 | QDomDocument docu("scridoc"); |
||
251 | QString f(readSLA(fileName)); |
||
252 | if (f.isEmpty()) |
||
253 | return false; |
||
254 | /* 2004/10/02 - petr vanek - bug #1092 - missing <PAGE> crash Scribus. The check constraint moved into IsScribus() |
||
255 | FIXME: I've add test on containig tag PAGE but returning false freezes S. in scribus.cpp need some hack too... */ |
||
256 | if (!docu.setContent(f)) |
||
257 | return false; |
||
258 | m_Doc->PageColors.clear(); |
||
259 | m_Doc->Layers.clear(); |
||
260 | int layerToSetActive=0; |
||
261 | ScColor lf = ScColor(); |
||
262 | QDomElement elem=docu.documentElement(); |
||
263 | if (elem.tagName() != "SCRIBUSUTF8NEW") |
||
264 | return false; |
||
265 | if (elem.hasAttribute("Version")) |
||
266 | newVersion = true; |
||
267 | QDomNode DOC=elem.firstChild(); |
||
268 | if (m_mwProgressBar!=0) |
||
269 | { |
||
270 | m_mwProgressBar->setTotalSteps(DOC.childNodes().count()); |
||
271 | m_mwProgressBar->setProgress(0); |
||
272 | } |
||
273 | int ObCount = 0; |
||
274 | TableItems.clear(); |
||
275 | TableID.clear(); |
||
276 | PrefsManager* prefsManager=PrefsManager::instance(); |
||
277 | while(!DOC.isNull()) |
||
278 | { |
||
279 | QDomElement dc=DOC.toElement(); |
||
280 | /* |
||
281 | * Attribute von DOCUMENT auslesen |
||
282 | */ |
||
283 | //CB Add this in to set this in the file in memory. Its saved, why not load it. |
||
284 | //Will of course be replaced by per page settings although we still probably need a document default |
||
5789 | cbradney | 285 | m_Doc->m_pageSize = dc.attribute("PAGESIZE"); |
5653 | cbradney | 286 | m_Doc->PageOri = dc.attribute("ORIENTATION", "0").toInt(); |
287 | m_Doc->FirstPnum = dc.attribute("FIRSTNUM", "1").toInt(); |
||
288 | m_Doc->currentPageLayout=dc.attribute("BOOK", "0").toInt(); |
||
289 | int fp; |
||
290 | if (m_Doc->currentPageLayout == 0) |
||
291 | fp = 0; |
||
292 | else |
||
293 | { |
||
294 | if (dc.attribute("FIRSTLEFT", "0").toInt() == 1) |
||
295 | fp = 0; |
||
296 | else |
||
297 | fp = 1; |
||
298 | } |
||
299 | if (DOC.namedItem("PageSets").isNull()) |
||
300 | { |
||
301 | m_Doc->pageSets[m_Doc->currentPageLayout].FirstPage = fp; |
||
302 | m_Doc->pageSets[m_Doc->currentPageLayout].GapHorizontal = dc.attribute("GapHorizontal", "0").toDouble(); |
||
303 | m_Doc->pageSets[m_Doc->currentPageLayout].GapVertical = 0.0; |
||
304 | m_Doc->pageSets[m_Doc->currentPageLayout].GapBelow = dc.attribute("GapVertical", "40").toDouble(); |
||
305 | } |
||
306 | m_Doc->setUsesAutomaticTextFrames(dc.attribute("AUTOTEXT").toInt()); |
||
307 | m_Doc->PageSp=dc.attribute("AUTOSPALTEN").toInt(); |
||
308 | m_Doc->PageSpa=dc.attribute("ABSTSPALTEN").toDouble(); |
||
309 | m_Doc->setUnitIndex(dc.attribute("UNITS", "0").toInt()); |
||
310 | m_Doc->toolSettings.defSize=qRound(dc.attribute("DSIZE").toDouble() * 10); |
||
311 | Defont=dc.attribute("DFONT"); |
||
5980 | avox | 312 | if ((!m_AvailableFonts->contains(Defont)) || (!(*m_AvailableFonts)[Defont].usable())) |
5653 | cbradney | 313 | { |
314 | ReplacedFonts.insert(Defont, prefsManager->appPrefs.toolSettings.defFont); |
||
315 | Defont = prefsManager->appPrefs.toolSettings.defFont; |
||
316 | } |
||
317 | else |
||
318 | { |
||
319 | // QFont fo = avail[Defont]->Font; |
||
320 | // fo.setPointSize(qRound(m_Doc->toolSettings.defSize / 10.0)); |
||
321 | m_Doc->AddFont(Defont, qRound(m_Doc->toolSettings.defSize / 10.0)); |
||
322 | } |
||
323 | m_Doc->toolSettings.defFont = Defont; |
||
324 | m_Doc->toolSettings.dCols=dc.attribute("DCOL", "1").toInt(); |
||
325 | m_Doc->toolSettings.dGap=dc.attribute("DGAP", "0.0").toDouble(); |
||
326 | m_Doc->documentInfo.setAuthor(dc.attribute("AUTHOR")); |
||
327 | m_Doc->documentInfo.setComments(dc.attribute("COMMENTS")); |
||
328 | m_Doc->documentInfo.setKeywords(dc.attribute("KEYWORDS","")); |
||
329 | m_Doc->documentInfo.setTitle(dc.attribute("TITLE")); |
||
330 | m_Doc->documentInfo.setPublisher(dc.attribute("PUBLISHER", "")); |
||
331 | m_Doc->documentInfo.setDate(dc.attribute("DOCDATE", "")); |
||
332 | m_Doc->documentInfo.setType(dc.attribute("DOCTYPE", "")); |
||
333 | m_Doc->documentInfo.setFormat(dc.attribute("DOCFORMAT", "")); |
||
334 | m_Doc->documentInfo.setIdent(dc.attribute("DOCIDENT", "")); |
||
335 | m_Doc->documentInfo.setSource(dc.attribute("DOCSOURCE", "")); |
||
336 | m_Doc->documentInfo.setLangInfo(dc.attribute("DOCLANGINFO", "")); |
||
337 | m_Doc->documentInfo.setRelation(dc.attribute("DOCRELATION", "")); |
||
338 | m_Doc->documentInfo.setCover(dc.attribute("DOCCOVER", "")); |
||
339 | m_Doc->documentInfo.setRights(dc.attribute("DOCRIGHTS", "")); |
||
340 | m_Doc->documentInfo.setContrib(dc.attribute("DOCCONTRIB", "")); |
||
341 | m_Doc->typographicSettings.valueSuperScript = dc.attribute("VHOCH").toInt(); |
||
342 | m_Doc->typographicSettings.scalingSuperScript = dc.attribute("VHOCHSC").toInt(); |
||
343 | m_Doc->typographicSettings.valueSubScript = dc.attribute("VTIEF").toInt(); |
||
344 | m_Doc->typographicSettings.scalingSubScript = dc.attribute("VTIEFSC").toInt(); |
||
345 | m_Doc->typographicSettings.valueSmallCaps = dc.attribute("VKAPIT").toInt(); |
||
346 | m_Doc->typographicSettings.valueBaseGrid = dc.attribute("BASEGRID", "12").toDouble(); |
||
347 | m_Doc->typographicSettings.offsetBaseGrid = dc.attribute("BASEO", "0").toDouble(); |
||
348 | m_Doc->typographicSettings.autoLineSpacing = dc.attribute("AUTOL", "20").toInt(); |
||
349 | m_Doc->typographicSettings.valueUnderlinePos = dc.attribute("UnderlinePos", "-1").toInt(); |
||
350 | m_Doc->typographicSettings.valueUnderlineWidth = dc.attribute("UnderlineWidth", "-1").toInt(); |
||
351 | m_Doc->typographicSettings.valueStrikeThruPos = dc.attribute("StrikeThruPos", "-1").toInt(); |
||
352 | m_Doc->typographicSettings.valueStrikeThruWidth = dc.attribute("StrikeThruWidth", "-1").toInt(); |
||
353 | m_Doc->GroupCounter=dc.attribute("GROUPC", "1").toInt(); |
||
5880 | jghali | 354 | //m_Doc->HasCMS = static_cast<bool>(dc.attribute("HCMS", "0").toInt()); |
5653 | cbradney | 355 | m_Doc->CMSSettings.SoftProofOn = static_cast<bool>(dc.attribute("DPSo", "0").toInt()); |
356 | m_Doc->CMSSettings.SoftProofFullOn = static_cast<bool>(dc.attribute("DPSFo", "0").toInt()); |
||
357 | m_Doc->CMSSettings.CMSinUse = static_cast<bool>(dc.attribute("DPuse", "0").toInt()); |
||
358 | m_Doc->CMSSettings.GamutCheck = static_cast<bool>(dc.attribute("DPgam", "0").toInt()); |
||
359 | m_Doc->CMSSettings.BlackPoint = static_cast<bool>(dc.attribute("DPbla", "1").toInt()); |
||
360 | m_Doc->CMSSettings.DefaultMonitorProfile = dc.attribute("DPMo",""); |
||
361 | m_Doc->CMSSettings.DefaultPrinterProfile = dc.attribute("DPPr",""); |
||
362 | m_Doc->CMSSettings.DefaultImageRGBProfile = dc.attribute("DPIn",""); |
||
363 | m_Doc->CMSSettings.DefaultImageCMYKProfile = dc.attribute("DPInCMYK",""); |
||
364 | m_Doc->CMSSettings.DefaultSolidColorRGBProfile = dc.attribute("DPIn2",""); |
||
365 | if (dc.hasAttribute("DPIn3")) |
||
366 | m_Doc->CMSSettings.DefaultSolidColorCMYKProfile = dc.attribute("DPIn3",""); |
||
367 | else |
||
368 | m_Doc->CMSSettings.DefaultSolidColorCMYKProfile = dc.attribute("DPPr",""); |
||
369 | //m_Doc->CMSSettings.DefaultIntentPrinter = dc.attribute("DIPr", "0").toInt(); |
||
370 | //m_Doc->CMSSettings.DefaultIntentMonitor = dc.attribute("DIMo", "1").toInt(); |
||
371 | m_Doc->CMSSettings.DefaultIntentColors = dc.attribute("DISc", "1").toInt(); |
||
372 | m_Doc->CMSSettings.DefaultIntentImages = dc.attribute("DIIm", "0").toInt(); |
||
373 | layerToSetActive=dc.attribute("ALAYER", "0").toInt(); |
||
374 | m_Doc->Language = dc.attribute("LANGUAGE", ""); |
||
375 | m_Doc->MinWordLen = dc.attribute("MINWORDLEN", "3").toInt(); |
||
376 | m_Doc->HyCount = dc.attribute("HYCOUNT", "2").toInt(); |
||
377 | if (dc.hasAttribute("PAGEWIDTH")) |
||
378 | m_Doc->pageWidth=dc.attribute("PAGEWIDTH").toDouble(); |
||
379 | else |
||
380 | m_Doc->pageWidth=dc.attribute("PAGEWITH").toDouble(); |
||
381 | m_Doc->pageHeight=dc.attribute("PAGEHEIGHT").toDouble(); |
||
382 | m_Doc->pageMargins.Left=QMAX(0.0, dc.attribute("BORDERLEFT").toDouble()); |
||
383 | m_Doc->pageMargins.Right=QMAX(0.0, dc.attribute("BORDERRIGHT").toDouble()); |
||
384 | m_Doc->pageMargins.Top=QMAX(0.0, dc.attribute("BORDERTOP").toDouble()); |
||
385 | m_Doc->pageMargins.Bottom=QMAX(0.0, dc.attribute("BORDERBOTTOM").toDouble()); |
||
386 | m_Doc->Automatic = static_cast<bool>(dc.attribute("AUTOMATIC", "1").toInt()); |
||
387 | m_Doc->AutoCheck = static_cast<bool>(dc.attribute("AUTOCHECK", "0").toInt()); |
||
388 | m_Doc->GuideLock = static_cast<bool>(dc.attribute("GUIDELOCK", "0").toInt()); |
||
389 | m_Doc->guidesSettings.minorGrid = dc.attribute("MINGRID", tmp.setNum(prefsManager->appPrefs.guidesSettings.minorGrid)).toDouble(); |
||
390 | m_Doc->guidesSettings.majorGrid = dc.attribute("MAJGRID", tmp.setNum(prefsManager->appPrefs.guidesSettings.majorGrid)).toDouble(); |
||
391 | m_Doc->guidesSettings.gridShown = static_cast<bool>(dc.attribute("SHOWGRID", "0").toInt()); |
||
392 | m_Doc->guidesSettings.guidesShown = static_cast<bool>(dc.attribute("SHOWGUIDES", "1").toInt()); |
||
393 | m_Doc->guidesSettings.colBordersShown = static_cast<bool>(dc.attribute("showcolborders", "0").toInt()); |
||
394 | m_Doc->guidesSettings.framesShown = static_cast<bool>(dc.attribute("SHOWFRAME", "1").toInt()); |
||
395 | m_Doc->guidesSettings.layerMarkersShown = static_cast<bool>(dc.attribute("SHOWLAYERM", "0").toInt()); |
||
396 | m_Doc->guidesSettings.marginsShown = static_cast<bool>(dc.attribute("SHOWMARGIN", "1").toInt()); |
||
397 | m_Doc->guidesSettings.baseShown = static_cast<bool>(dc.attribute("SHOWBASE", "0").toInt()); |
||
398 | m_Doc->guidesSettings.showPic = static_cast<bool>(dc.attribute("SHOWPICT", "1").toInt()); |
||
399 | m_Doc->guidesSettings.linkShown = static_cast<bool>(dc.attribute("SHOWLINK", "0").toInt()); |
||
400 | m_Doc->guidesSettings.showControls = static_cast<bool>(dc.attribute("SHOWControl", "0").toInt()); |
||
401 | m_Doc->guidesSettings.rulerMode = static_cast<bool>(dc.attribute("rulerMode", "1").toInt()); |
||
402 | m_Doc->guidesSettings.rulersShown = static_cast<bool>(dc.attribute("showrulers", "1").toInt()); |
||
403 | m_Doc->rulerXoffset = dc.attribute("rulerXoffset", "0").toDouble(); |
||
404 | m_Doc->rulerYoffset =dc.attribute("rulerYoffset", "0").toDouble(); |
||
405 | m_Doc->SnapGuides = static_cast<bool>(dc.attribute("SnapToGuides", "0").toInt()); |
||
406 | m_Doc->useRaster = static_cast<bool>(dc.attribute("SnapToGrid", "0").toInt()); |
||
407 | m_Doc->toolSettings.polyC = dc.attribute("POLYC", "4").toInt(); |
||
408 | m_Doc->toolSettings.polyF = dc.attribute("POLYF", "0.5").toDouble(); |
||
409 | m_Doc->toolSettings.polyR = dc.attribute("POLYR", "0").toDouble(); |
||
410 | m_Doc->toolSettings.polyFd = dc.attribute("POLYFD", "0").toInt(); |
||
411 | m_Doc->toolSettings.polyS = static_cast<bool>(dc.attribute("POLYS", "0").toInt()); |
||
412 | m_Doc->AutoSave = static_cast<bool>(dc.attribute("AutoSave", "0").toInt()); |
||
413 | m_Doc->AutoSaveTime = dc.attribute("AutoSaveTime", "600000").toInt(); |
||
414 | m_Doc->ScratchBottom = dc.attribute("ScratchBottom", "20").toDouble(); |
||
415 | // FIXME A typo in early 1.3cvs (MAR 05) means we must support loading of |
||
416 | // FIXME 'ScatchLeft' for a while too. This can be removed in a few months. |
||
417 | if (dc.hasAttribute("ScatchLeft")) |
||
418 | m_Doc->ScratchLeft = dc.attribute("ScatchLeft", "100").toDouble(); |
||
419 | else |
||
420 | m_Doc->ScratchLeft = dc.attribute("ScratchLeft", "100").toDouble(); |
||
421 | m_Doc->ScratchRight = dc.attribute("ScratchRight", "100").toDouble(); |
||
422 | m_Doc->ScratchTop = dc.attribute("ScratchTop", "20").toDouble(); |
||
423 | m_Doc->toolSettings.dStartArrow = dc.attribute("StartArrow", "0").toInt(); |
||
424 | m_Doc->toolSettings.dEndArrow = dc.attribute("EndArrow", "0").toInt(); |
||
425 | m_Doc->toolSettings.scaleX = dc.attribute("PICTSCX", "1").toDouble(); |
||
426 | m_Doc->toolSettings.scaleY = dc.attribute("PICTSCY", "1").toDouble(); |
||
427 | m_Doc->toolSettings.scaleType = static_cast<bool>(dc.attribute("PSCALE", "1").toInt()); |
||
428 | m_Doc->toolSettings.aspectRatio = static_cast<bool>(dc.attribute("PASPECT", "0").toInt()); |
||
429 | m_Doc->toolSettings.lowResType = dc.attribute("HalfRes", "1").toInt(); |
||
430 | m_Doc->toolSettings.useEmbeddedPath = static_cast<bool>(dc.attribute("EmbeddedPath", "0").toInt()); |
||
431 | if (dc.hasAttribute("PEN")) |
||
432 | m_Doc->toolSettings.dPen = dc.attribute("PEN"); |
||
433 | if (dc.hasAttribute("BRUSH")) |
||
434 | m_Doc->toolSettings.dBrush = dc.attribute("BRUSH"); |
||
435 | if (dc.hasAttribute("PENLINE")) |
||
436 | m_Doc->toolSettings.dPenLine = dc.attribute("PENLINE"); |
||
437 | if (dc.hasAttribute("PENTEXT")) |
||
438 | m_Doc->toolSettings.dPenText = dc.attribute("PENTEXT"); |
||
439 | if (dc.hasAttribute("StrokeText")) |
||
440 | m_Doc->toolSettings.dStrokeText = dc.attribute("StrokeText"); |
||
441 | m_Doc->toolSettings.dTextBackGround = dc.attribute("TextBackGround", CommonStrings::None); |
||
442 | m_Doc->toolSettings.dTextLineColor = dc.attribute("TextLineColor", CommonStrings::None); |
||
443 | m_Doc->toolSettings.dTextBackGroundShade = dc.attribute("TextBackGroundShade", "100").toInt(); |
||
444 | m_Doc->toolSettings.dTextLineShade = dc.attribute("TextLineShade", "100").toInt(); |
||
445 | m_Doc->toolSettings.dTextPenShade = dc.attribute("TextPenShade", "100").toInt(); |
||
446 | m_Doc->toolSettings.dTextStrokeShade = dc.attribute("TextStrokeShade", "100").toInt(); |
||
447 | m_Doc->toolSettings.dLineArt = static_cast<Qt::PenStyle>(dc.attribute("STIL").toInt()); |
||
448 | m_Doc->toolSettings.dLstyleLine = static_cast<Qt::PenStyle>(dc.attribute("STILLINE").toInt()); |
||
449 | m_Doc->toolSettings.dWidth = dc.attribute("WIDTH", "1").toDouble(); |
||
450 | m_Doc->toolSettings.dWidthLine = dc.attribute("WIDTHLINE", "1").toDouble(); |
||
451 | m_Doc->toolSettings.dShade2 = dc.attribute("PENSHADE", "100").toInt(); |
||
452 | m_Doc->toolSettings.dShadeLine = dc.attribute("LINESHADE", "100").toInt(); |
||
453 | m_Doc->toolSettings.dShade = dc.attribute("BRUSHSHADE", "100").toInt(); |
||
454 | m_Doc->toolSettings.magMin = dc.attribute("MAGMIN", "10").toInt(); |
||
455 | m_Doc->toolSettings.magMax = dc.attribute("MAGMAX", "3200").toInt(); |
||
456 | m_Doc->toolSettings.magStep = dc.attribute("MAGSTEP", "200").toInt(); |
||
6606 | fschmid | 457 | m_Doc->toolSettings.dispX = dc.attribute("dispX", "10").toDouble(); |
458 | m_Doc->toolSettings.dispY = dc.attribute("dispY", "10").toDouble(); |
||
6618 | fschmid | 459 | m_Doc->toolSettings.constrain = dc.attribute("constrain", "15").toDouble(); |
5653 | cbradney | 460 | //CB Reset doc zoom step value to 200% instead of old values. |
461 | if (m_Doc->toolSettings.magStep<100) |
||
462 | m_Doc->toolSettings.magStep=200; |
||
463 | m_Doc->toolSettings.tabFillChar = dc.attribute("TabFill",""); |
||
464 | m_Doc->toolSettings.dTabWidth=dc.attribute("TabWidth", "36.0").toDouble(); |
||
465 | if (dc.hasAttribute("CPICT")) |
||
466 | m_Doc->toolSettings.dBrushPict = dc.attribute("CPICT"); |
||
467 | m_Doc->toolSettings.shadePict = dc.attribute("PICTSHADE", "100").toInt(); |
||
468 | if (dc.hasAttribute("PAGEC")) |
||
469 | m_Doc->papColor = QColor(dc.attribute("PAGEC")); |
||
470 | if (dc.hasAttribute("MARGC")) |
||
471 | m_Doc->guidesSettings.margColor = QColor(dc.attribute("MARGC")); |
||
472 | if (dc.hasAttribute("MINORC")) |
||
473 | m_Doc->guidesSettings.minorColor = QColor(dc.attribute("MINORC")); |
||
474 | if (dc.hasAttribute("MAJORC")) |
||
475 | m_Doc->guidesSettings.majorColor = QColor(dc.attribute("MAJORC")); |
||
476 | if (dc.hasAttribute("GuideC")) |
||
477 | m_Doc->guidesSettings.guideColor = QColor(dc.attribute("GuideC")); |
||
478 | if (dc.hasAttribute("BaseC")) |
||
479 | m_Doc->guidesSettings.baseColor = QColor(dc.attribute("BaseC")); |
||
480 | m_Doc->marginColored = static_cast<bool>(dc.attribute("RANDF", "0").toInt()); |
||
481 | m_Doc->guidesSettings.before = static_cast<bool>(dc.attribute("BACKG", "1").toInt()); |
||
482 | m_Doc->guidesSettings.guideRad = dc.attribute("GuideRad", "10").toDouble(); |
||
483 | m_Doc->guidesSettings.grabRad = dc.attribute("GRAB", "4").toInt(); |
||
484 | if (dc.hasAttribute("currentProfile")) |
||
485 | { |
||
486 | m_Doc->checkerProfiles.clear(); |
||
487 | m_Doc->curCheckProfile = dc.attribute("currentProfile"); |
||
488 | } |
||
489 | m_Doc->LastAuto = 0; |
||
490 | QDomNode PAGE=DOC.firstChild(); |
||
491 | counter = 0; |
||
492 | while(!PAGE.isNull()) |
||
493 | { |
||
494 | ObCount++; |
||
495 | if (m_mwProgressBar!=0) |
||
496 | m_mwProgressBar->setProgress(ObCount); |
||
497 | QDomElement pg=PAGE.toElement(); |
||
498 | if (pg.tagName()=="PageSets") |
||
499 | { |
||
500 | QDomNode PGS = PAGE.firstChild(); |
||
501 | m_Doc->pageSets.clear(); |
||
502 | while(!PGS.isNull()) |
||
503 | { |
||
504 | QDomElement PgsAttr = PGS.toElement(); |
||
505 | if(PgsAttr.tagName() == "Set") |
||
506 | { |
||
507 | struct PageSet pageS; |
||
508 | pageS.Name = CommonStrings::untranslatePageSetString(PgsAttr.attribute("Name")); |
||
509 | pageS.FirstPage = PgsAttr.attribute("FirstPage", "0").toInt(); |
||
510 | pageS.Rows = PgsAttr.attribute("Rows", "1").toInt(); |
||
511 | pageS.Columns = PgsAttr.attribute("Columns", "1").toInt(); |
||
512 | pageS.GapHorizontal = PgsAttr.attribute("GapHorizontal", "0").toDouble(); |
||
513 | pageS.GapVertical = PgsAttr.attribute("GapVertical", "0").toDouble(); |
||
514 | pageS.GapBelow = PgsAttr.attribute("GapBelow", "0").toDouble(); |
||
515 | pageS.pageNames.clear(); |
||
516 | QDomNode PGSN = PGS.firstChild(); |
||
517 | while(!PGSN.isNull()) |
||
518 | { |
||
519 | QDomElement PgsAttrN = PGSN.toElement(); |
||
520 | if(PgsAttrN.tagName() == "PageNames") |
||
521 | pageS.pageNames.append(CommonStrings::untranslatePageSetLocString(PgsAttrN.attribute("Name"))); |
||
522 | PGSN = PGSN.nextSibling(); |
||
523 | } |
||
524 | m_Doc->pageSets.append(pageS); |
||
525 | } |
||
526 | PGS = PGS.nextSibling(); |
||
527 | } |
||
528 | } |
||
529 | if (pg.tagName()=="CheckProfile") |
||
530 | { |
||
531 | struct checkerPrefs checkerSettings; |
||
532 | checkerSettings.ignoreErrors = static_cast<bool>(pg.attribute("ignoreErrors", "0").toInt()); |
||
533 | checkerSettings.autoCheck = static_cast<bool>(pg.attribute("autoCheck", "1").toInt()); |
||
534 | checkerSettings.checkGlyphs = static_cast<bool>(pg.attribute("checkGlyphs", "1").toInt()); |
||
535 | checkerSettings.checkOrphans = static_cast<bool>(pg.attribute("checkOrphans", "1").toInt()); |
||
536 | checkerSettings.checkOverflow = static_cast<bool>(pg.attribute("checkOverflow", "1").toInt()); |
||
537 | checkerSettings.checkPictures = static_cast<bool>(pg.attribute("checkPictures", "1").toInt()); |
||
538 | checkerSettings.checkResolution = static_cast<bool>(pg.attribute("checkResolution", "1").toInt()); |
||
539 | checkerSettings.checkTransparency = static_cast<bool>(pg.attribute("checkTransparency", "1").toInt()); |
||
540 | checkerSettings.minResolution = pg.attribute("minResolution", "72").toDouble(); |
||
541 | checkerSettings.maxResolution = pg.attribute("maxResolution", "4800").toDouble(); |
||
542 | checkerSettings.checkAnnotations = static_cast<bool>(pg.attribute("checkAnnotations", "0").toInt()); |
||
543 | checkerSettings.checkRasterPDF = static_cast<bool>(pg.attribute("checkRasterPDF", "1").toInt()); |
||
544 | checkerSettings.checkForGIF = static_cast<bool>(pg.attribute("checkForGIF", "1").toInt()); |
||
6619 | fschmid | 545 | checkerSettings.ignoreOffLayers = static_cast<bool>(pg.attribute("ignoreOffLayers", "0").toInt()); |
5653 | cbradney | 546 | m_Doc->checkerProfiles[pg.attribute("Name")] = checkerSettings; |
547 | } |
||
548 | // 10/25/2004 pv - None is "reserved" color. cannot be defined in any file... |
||
549 | if(pg.tagName()=="COLOR" && pg.attribute("NAME")!=CommonStrings::None) |
||
550 | { |
||
551 | if (pg.hasAttribute("CMYK")) |
||
552 | lf.setNamedColor(pg.attribute("CMYK")); |
||
553 | else |
||
554 | lf.fromQColor(QColor(pg.attribute("RGB"))); |
||
555 | if (pg.hasAttribute("Spot")) |
||
556 | lf.setSpotColor(static_cast<bool>(pg.attribute("Spot").toInt())); |
||
557 | else |
||
558 | lf.setSpotColor(false); |
||
559 | if (pg.hasAttribute("Register")) |
||
560 | lf.setRegistrationColor(static_cast<bool>(pg.attribute("Register").toInt())); |
||
561 | else |
||
562 | lf.setRegistrationColor(false); |
||
5880 | jghali | 563 | m_Doc->PageColors.insert(pg.attribute("NAME"), lf); |
5653 | cbradney | 564 | } |
565 | if(pg.tagName()=="STYLE") |
||
566 | { |
||
567 | readParagraphStyle(vg, pg, *m_AvailableFonts, m_Doc); |
||
6733 | avox | 568 | m_Doc->docParagraphStyles.create(vg); |
5653 | cbradney | 569 | } |
570 | if(pg.tagName()=="JAVA") |
||
571 | m_Doc->JavaScripts[pg.attribute("NAME")] = pg.attribute("SCRIPT"); |
||
572 | if(pg.tagName()=="LAYERS") |
||
573 | { |
||
574 | la.LNr = pg.attribute("NUMMER").toInt(); |
||
575 | la.Level = pg.attribute("LEVEL").toInt(); |
||
576 | la.Name = pg.attribute("NAME"); |
||
577 | la.isViewable = pg.attribute("SICHTBAR").toInt(); |
||
578 | la.isPrintable = pg.attribute("DRUCKEN").toInt(); |
||
579 | la.isEditable = pg.attribute("EDIT", "1").toInt(); |
||
580 | la.flowControl = pg.attribute("FLOW", "1").toInt(); |
||
581 | la.transparency = pg.attribute("TRANS", "1").toDouble(); |
||
582 | la.blendMode = pg.attribute("BLEND", "0").toInt(); |
||
583 | la.outlineMode = pg.attribute("OUTL", "0").toInt(); |
||
584 | if (pg.hasAttribute("LAYERC")) |
||
585 | la.markerColor = QColor(pg.attribute("LAYERC","#000000")); |
||
586 | else |
||
587 | { |
||
588 | QColor marker; |
||
589 | switch (la.LNr % 7) |
||
590 | { |
||
591 | case 0: |
||
592 | marker = Qt::black; |
||
593 | break; |
||
594 | case 1: |
||
595 | marker = Qt::red; |
||
596 | break; |
||
597 | case 2: |
||
598 | marker = Qt::green; |
||
599 | break; |
||
600 | case 3: |
||
601 | marker = Qt::blue; |
||
602 | break; |
||
603 | case 4: |
||
604 | marker = Qt::cyan; |
||
605 | break; |
||
606 | case 5: |
||
607 | marker = Qt::magenta; |
||
608 | break; |
||
609 | case 6: |
||
610 | marker = Qt::yellow;; |
||
611 | break; |
||
612 | } |
||
613 | la.markerColor = marker; |
||
614 | } |
||
615 | m_Doc->Layers.append(la); |
||
616 | } |
||
617 | /* if(pg.tagName()=="Bookmark") |
||
618 | { |
||
619 | bok.Title = pg.attribute("Title"); |
||
620 | bok.Text = pg.attribute("Text"); |
||
621 | bok.Aktion = pg.attribute("Aktion"); |
||
622 | bok.ItemNr = pg.attribute("ItemNr").toInt(); |
||
623 | bok.Seite = pg.attribute("Seite").toInt(); |
||
624 | bok.Element = pg.attribute("Element").toInt(); |
||
625 | bok.First = pg.attribute("First").toInt(); |
||
626 | bok.Last = pg.attribute("Last").toInt(); |
||
627 | bok.Prev = pg.attribute("Prev").toInt(); |
||
628 | bok.Next = pg.attribute("Next").toInt(); |
||
629 | bok.Parent = pg.attribute("Parent").toInt(); |
||
630 | m_Doc->BookMarks.append(bok); |
||
631 | } */ |
||
632 | if(pg.tagName()=="MultiLine") |
||
633 | { |
||
634 | multiLine ml; |
||
635 | QDomNode MuLn = PAGE.firstChild(); |
||
636 | while(!MuLn.isNull()) |
||
637 | { |
||
638 | QDomElement MuL = MuLn.toElement(); |
||
639 | struct SingleLine sl; |
||
640 | sl.Color = MuL.attribute("Color"); |
||
641 | sl.Dash = MuL.attribute("Dash").toInt(); |
||
642 | sl.LineEnd = MuL.attribute("LineEnd").toInt(); |
||
643 | sl.LineJoin = MuL.attribute("LineJoin").toInt(); |
||
644 | sl.Shade = MuL.attribute("Shade").toInt(); |
||
645 | sl.Width = MuL.attribute("Width").toDouble(); |
||
646 | ml.push_back(sl); |
||
647 | MuLn = MuLn.nextSibling(); |
||
648 | } |
||
649 | m_Doc->MLineStyles.insert(pg.attribute("Name"), ml); |
||
650 | } |
||
651 | if(pg.tagName()=="Arrows") |
||
652 | { |
||
653 | struct ArrowDesc arrow; |
||
654 | arrow.name = pg.attribute("Name"); |
||
655 | arrow.userArrow = true; |
||
656 | double xa, ya; |
||
657 | QString tmp = pg.attribute("Points"); |
||
658 | QTextStream fp(&tmp, IO_ReadOnly); |
||
659 | for (uint cx = 0; cx < pg.attribute("NumPoints").toUInt(); ++cx) |
||
660 | { |
||
661 | fp >> xa; |
||
662 | fp >> ya; |
||
663 | arrow.points.addPoint(xa, ya); |
||
664 | } |
||
665 | m_Doc->arrowStyles.append(arrow); |
||
666 | } |
||
667 | if(pg.tagName()=="PDF") |
||
668 | { |
||
669 | m_Doc->PDF_Options.Articles = static_cast<bool>(pg.attribute("Articles").toInt()); |
||
670 | m_Doc->PDF_Options.Thumbnails = static_cast<bool>(pg.attribute("Thumbnails").toInt()); |
||
671 | m_Doc->PDF_Options.Compress = static_cast<bool>(pg.attribute("Compress").toInt()); |
||
672 | m_Doc->PDF_Options.CompressMethod = pg.attribute("CMethod", "0").toInt(); |
||
673 | m_Doc->PDF_Options.Quality = pg.attribute("Quality", "0").toInt(); |
||
674 | m_Doc->PDF_Options.RecalcPic = static_cast<bool>(pg.attribute("RecalcPic").toInt()); |
||
675 | m_Doc->PDF_Options.Bookmarks = static_cast<bool>(pg.attribute("Bookmarks").toInt()); |
||
6493 | fschmid | 676 | if (pg.hasAttribute("firstUse")) |
677 | m_Doc->PDF_Options.firstUse = static_cast<bool>(pg.attribute("firstUse").toInt()); |
||
678 | else |
||
679 | m_Doc->PDF_Options.firstUse = true; |
||
5653 | cbradney | 680 | if (pg.hasAttribute("MirrorH")) |
681 | m_Doc->PDF_Options.MirrorH = static_cast<bool>(pg.attribute("MirrorH").toInt()); |
||
682 | else |
||
683 | m_Doc->PDF_Options.MirrorH = false; |
||
684 | if (pg.hasAttribute("MirrorV")) |
||
685 | m_Doc->PDF_Options.MirrorV = static_cast<bool>(pg.attribute("MirrorV").toInt()); |
||
686 | else |
||
687 | m_Doc->PDF_Options.MirrorV = false; |
||
688 | if (pg.hasAttribute("RotateDeg")) |
||
689 | m_Doc->PDF_Options.RotateDeg = pg.attribute("RotateDeg", "0").toInt(); |
||
690 | else |
||
691 | m_Doc->PDF_Options.RotateDeg = 0; |
||
692 | if (pg.hasAttribute("Clip")) |
||
693 | m_Doc->PDF_Options.doClip = static_cast<bool>(pg.attribute("Clip").toInt()); |
||
694 | else |
||
695 | m_Doc->PDF_Options.doClip = false; |
||
696 | m_Doc->PDF_Options.PresentMode = static_cast<bool>(pg.attribute("PresentMode").toInt()); |
||
697 | m_Doc->PDF_Options.PicRes = pg.attribute("PicRes").toInt(); |
||
698 | // Fixme: check input pdf version |
||
699 | m_Doc->PDF_Options.Version = (PDFOptions::PDFVersion)pg.attribute("Version").toInt(); |
||
700 | m_Doc->PDF_Options.Resolution = pg.attribute("Resolution").toInt(); |
||
701 | m_Doc->PDF_Options.Binding = pg.attribute("Binding").toInt(); |
||
702 | m_Doc->PDF_Options.Datei = ""; |
||
703 | m_Doc->PDF_Options.isGrayscale = static_cast<bool>(pg.attribute("Grayscale", "0").toInt()); |
||
704 | m_Doc->PDF_Options.UseRGB = static_cast<bool>(pg.attribute("RGBMode", "0").toInt()); |
||
705 | m_Doc->PDF_Options.UseProfiles = static_cast<bool>(pg.attribute("UseProfiles", "0").toInt()); |
||
706 | m_Doc->PDF_Options.UseProfiles2 = static_cast<bool>(pg.attribute("UseProfiles2", "0").toInt()); |
||
707 | m_Doc->PDF_Options.Intent = pg.attribute("Intent", "1").toInt(); |
||
708 | m_Doc->PDF_Options.Intent2 = pg.attribute("Intent2", "1").toInt(); |
||
709 | m_Doc->PDF_Options.SolidProf = pg.attribute("SolidP", ""); |
||
710 | m_Doc->PDF_Options.ImageProf = pg.attribute("ImageP", ""); |
||
711 | m_Doc->PDF_Options.PrintProf = pg.attribute("PrintP", ""); |
||
712 | m_Doc->PDF_Options.Info = pg.attribute("InfoString", ""); |
||
713 | m_Doc->PDF_Options.BleedTop = pg.attribute("BTop", "0").toDouble(); |
||
714 | m_Doc->PDF_Options.BleedLeft = pg.attribute("BLeft", "0").toDouble(); |
||
715 | m_Doc->PDF_Options.BleedRight = pg.attribute("BRight", "0").toDouble(); |
||
716 | m_Doc->PDF_Options.BleedBottom = pg.attribute("BBottom", "0").toDouble(); |
||
717 | m_Doc->PDF_Options.EmbeddedI = static_cast<bool>(pg.attribute("ImagePr", "0").toInt()); |
||
718 | m_Doc->PDF_Options.PassOwner = pg.attribute("PassOwner", ""); |
||
719 | m_Doc->PDF_Options.PassUser = pg.attribute("PassUser", ""); |
||
720 | m_Doc->PDF_Options.Permissions = pg.attribute("Permissions", "-4").toInt(); |
||
721 | m_Doc->PDF_Options.Encrypt = static_cast<bool>(pg.attribute("Encrypt", "0").toInt()); |
||
722 | m_Doc->PDF_Options.useLayers = static_cast<bool>(pg.attribute("UseLayers", "0").toInt()); |
||
723 | m_Doc->PDF_Options.UseLPI = static_cast<bool>(pg.attribute("UseLpi", "0").toInt()); |
||
724 | m_Doc->PDF_Options.UseSpotColors = static_cast<bool>(pg.attribute("UseSpotColors", "1").toInt()); |
||
725 | m_Doc->PDF_Options.doOverprint = static_cast<bool>(pg.attribute("doOverprint", "0").toInt()); |
||
726 | m_Doc->PDF_Options.doMultiFile = static_cast<bool>(pg.attribute("doMultiFile", "0").toInt()); |
||
727 | m_Doc->PDF_Options.displayBookmarks = static_cast<bool>(pg.attribute("displayBookmarks", "0").toInt()); |
||
728 | m_Doc->PDF_Options.displayFullscreen = static_cast<bool>(pg.attribute("displayFullscreen", "0").toInt()); |
||
729 | m_Doc->PDF_Options.displayLayers = static_cast<bool>(pg.attribute("displayLayers", "0").toInt()); |
||
730 | m_Doc->PDF_Options.displayThumbs = static_cast<bool>(pg.attribute("displayThumbs", "0").toInt()); |
||
731 | m_Doc->PDF_Options.hideMenuBar = static_cast<bool>(pg.attribute("hideMenuBar", "0").toInt()); |
||
732 | m_Doc->PDF_Options.hideToolBar = static_cast<bool>(pg.attribute("hideToolBar", "0").toInt()); |
||
733 | m_Doc->PDF_Options.fitWindow = static_cast<bool>(pg.attribute("fitWindow", "0").toInt()); |
||
734 | m_Doc->PDF_Options.PageLayout = pg.attribute("PageLayout", "0").toInt(); |
||
735 | m_Doc->PDF_Options.openAction = pg.attribute("openAction", ""); |
||
736 | QDomNode PFO = PAGE.firstChild(); |
||
737 | while(!PFO.isNull()) |
||
738 | { |
||
739 | QDomElement pdfF = PFO.toElement(); |
||
740 | if(pdfF.tagName() == "LPI") |
||
741 | { |
||
742 | struct LPIData lpo; |
||
743 | lpo.Angle = pdfF.attribute("Angle").toInt(); |
||
744 | lpo.Frequency = pdfF.attribute("Frequency").toInt(); |
||
745 | lpo.SpotFunc = pdfF.attribute("SpotFunction").toInt(); |
||
746 | m_Doc->PDF_Options.LPISettings[pdfF.attribute("Color")] = lpo; |
||
747 | } |
||
748 | if(pdfF.tagName() == "Fonts") |
||
749 | { |
||
750 | if (!m_Doc->PDF_Options.EmbedList.contains(pdfF.attribute("Name"))) |
||
751 | m_Doc->PDF_Options.EmbedList.append(pdfF.attribute("Name")); |
||
752 | } |
||
753 | if(pdfF.tagName() == "Subset") |
||
754 | { |
||
755 | if (!m_Doc->PDF_Options.SubsetList.contains(pdfF.attribute("Name"))) |
||
756 | m_Doc->PDF_Options.SubsetList.append(pdfF.attribute("Name")); |
||
757 | } |
||
758 | if(pdfF.tagName() == "Effekte") |
||
759 | { |
||
760 | struct PDFPresentationData ef; |
||
761 | ef.pageEffectDuration = pdfF.attribute("pageEffectDuration").toInt(); |
||
762 | ef.pageViewDuration = pdfF.attribute("pageViewDuration").toInt(); |
||
763 | ef.effectType = pdfF.attribute("effectType").toInt(); |
||
764 | ef.Dm = pdfF.attribute("Dm").toInt(); |
||
765 | ef.M = pdfF.attribute("M").toInt(); |
||
766 | ef.Di = pdfF.attribute("Di").toInt(); |
||
767 | m_Doc->PDF_Options.PresentVals.append(ef); |
||
768 | } |
||
769 | PFO = PFO.nextSibling(); |
||
770 | } |
||
771 | } |
||
772 | if(pg.tagName()=="DocItemAttributes") |
||
773 | { |
||
774 | QDomNode DIA = PAGE.firstChild(); |
||
775 | m_Doc->docItemAttributes.clear(); |
||
776 | while(!DIA.isNull()) |
||
777 | { |
||
778 | QDomElement itemAttr = DIA.toElement(); |
||
779 | if(itemAttr.tagName() == "ItemAttribute") |
||
780 | { |
||
781 | ObjectAttribute objattr; |
||
782 | objattr.name=itemAttr.attribute("Name"); |
||
783 | objattr.type=itemAttr.attribute("Type"); |
||
784 | objattr.value=itemAttr.attribute("Value"); |
||
785 | objattr.parameter=itemAttr.attribute("Parameter"); |
||
786 | objattr.relationship=itemAttr.attribute("Relationship"); |
||
787 | objattr.relationshipto=itemAttr.attribute("RelationshipTo"); |
||
788 | objattr.autoaddto=itemAttr.attribute("AutoAddTo"); |
||
789 | m_Doc->docItemAttributes.append(objattr); |
||
790 | } |
||
791 | DIA = DIA.nextSibling(); |
||
792 | } |
||
793 | } |
||
794 | if(pg.tagName()=="TablesOfContents") |
||
795 | { |
||
796 | QDomNode TOC = PAGE.firstChild(); |
||
797 | m_Doc->docToCSetups.clear(); |
||
798 | while(!TOC.isNull()) |
||
799 | { |
||
800 | QDomElement tocElem = TOC.toElement(); |
||
801 | if(tocElem.tagName() == "TableOfContents") |
||
802 | { |
||
803 | ToCSetup tocsetup; |
||
804 | tocsetup.name=tocElem.attribute("Name"); |
||
805 | tocsetup.itemAttrName=tocElem.attribute("ItemAttributeName"); |
||
806 | tocsetup.frameName=tocElem.attribute("FrameName"); |
||
807 | tocsetup.listNonPrintingFrames=tocElem.attribute("ListNonPrinting"); |
||
808 | tocsetup.textStyle=tocElem.attribute("Style"); |
||
809 | QString numberPlacement=tocElem.attribute("NumberPlacement"); |
||
810 | if (numberPlacement=="Beginning") |
||
811 | tocsetup.pageLocation=Beginning; |
||
812 | if (numberPlacement=="End") |
||
813 | tocsetup.pageLocation=End; |
||
814 | if (numberPlacement=="NotShown") |
||
815 | tocsetup.pageLocation=NotShown; |
||
816 | m_Doc->docToCSetups.append(tocsetup); |
||
817 | } |
||
818 | TOC = TOC.nextSibling(); |
||
819 | } |
||
820 | } |
||
821 | if(pg.tagName()=="Sections") |
||
822 | { |
||
823 | QDomNode Section = PAGE.firstChild(); |
||
824 | while(!Section.isNull()) |
||
825 | { |
||
826 | QDomElement sectionElem = Section.toElement(); |
||
827 | if(sectionElem.tagName() == "Section") |
||
828 | { |
||
829 | struct DocumentSection newSection; |
||
830 | newSection.number=sectionElem.attribute("Number").toInt(); |
||
831 | newSection.name=sectionElem.attribute("Name"); |
||
832 | newSection.fromindex=sectionElem.attribute("From").toInt(); |
||
833 | newSection.toindex=sectionElem.attribute("To").toInt(); |
||
834 | if (sectionElem.attribute("Type")=="Type_1_2_3") |
||
835 | newSection.type=Type_1_2_3; |
||
836 | if (sectionElem.attribute("Type")=="Type_i_ii_iii") |
||
837 | newSection.type=Type_i_ii_iii; |
||
838 | if (sectionElem.attribute("Type")=="Type_I_II_III") |
||
839 | newSection.type=Type_I_II_III; |
||
840 | if (sectionElem.attribute("Type")=="Type_a_b_c") |
||
841 | newSection.type=Type_a_b_c; |
||
842 | if (sectionElem.attribute("Type")=="Type_A_B_C") |
||
843 | newSection.type=Type_A_B_C; |
||
844 | newSection.sectionstartindex=sectionElem.attribute("Start").toInt(); |
||
845 | newSection.reversed=static_cast<bool>(sectionElem.attribute("Reversed").toInt()); |
||
846 | newSection.active=static_cast<bool>(sectionElem.attribute("Active").toInt()); |
||
847 | m_Doc->sections.insert(newSection.number, newSection); |
||
848 | } |
||
849 | Section = Section.nextSibling(); |
||
850 | } |
||
851 | } |
||
852 | if ((pg.tagName()=="PAGE") || (pg.tagName()=="MASTERPAGE")) |
||
853 | { |
||
854 | a = pg.attribute("NUM").toInt(); |
||
855 | PgNam = ""; |
||
856 | PgNam = pg.attribute("NAM", ""); |
||
857 | //Pgc = m_Doc->pageCount; |
||
858 | //AtFl = m_Doc->usesAutomaticTextFrames(); |
||
859 | if (PgNam.isEmpty()) |
||
860 | { |
||
861 | //m_Doc->pageCount = Pgc; |
||
862 | //m_Doc->Pages = &m_Doc->DocPages; |
||
863 | //m_Doc->setUsesAutomaticTextFrames(AtFl); |
||
864 | m_Doc->setMasterPageMode(false); |
||
865 | } |
||
866 | else |
||
867 | { |
||
868 | //m_Doc->pageCount = 0; |
||
869 | //m_Doc->setUsesAutomaticTextFrames(false); |
||
870 | //m_Doc->Pages = &m_Doc->MasterPages; |
||
871 | m_Doc->setMasterPageMode(true); |
||
872 | } |
||
873 | //CB: Stop calling damn GUI code in loading docs! IT doesnt *look* like |
||
874 | //this makes a difference apart from being faster, of course. |
||
875 | //ScMW->slotNewPage(a); |
||
876 | //Apage = m_Doc->Pages.at(a); |
||
877 | if (PgNam.isEmpty()) |
||
878 | { |
||
879 | Apage = m_Doc->addPage(a); |
||
880 | //m_Doc->DocPages = m_Doc->Pages; |
||
881 | //++m_Doc->pageCount; |
||
882 | } |
||
883 | else |
||
884 | { |
||
885 | Apage = m_Doc->addMasterPage(a, PgNam); |
||
886 | //Apage->setPageName(PgNam); |
||
887 | //m_Doc->MasterNames[PgNam] = a; |
||
888 | //m_Doc->MasterPages = m_Doc->Pages; |
||
889 | //m_Doc->pageCount = Pgc; |
||
890 | } |
||
891 | //m_Doc->setUsesAutomaticTextFrames(AtFl); |
||
892 | Apage->LeftPg=pg.attribute("LEFT", "0").toInt(); |
||
893 | QString Mus = ""; |
||
894 | Mus = pg.attribute("MNAM","Normal"); |
||
895 | if (!m_Doc->masterPageMode()) |
||
896 | Apage->MPageNam = Mus; |
||
897 | else |
||
898 | Apage->MPageNam = ""; |
||
899 | if (pg.hasAttribute("Size")) |
||
5789 | cbradney | 900 | Apage->m_pageSize = pg.attribute("Size"); |
5653 | cbradney | 901 | if (pg.hasAttribute("Orientation")) |
902 | Apage->PageOri = pg.attribute("Orientation").toInt(); |
||
903 | Apage->setXOffset(pg.attribute("PAGEXPOS").toDouble()); |
||
904 | Apage->setYOffset(pg.attribute("PAGEYPOS").toDouble()); |
||
905 | if (pg.hasAttribute("PAGEWIDTH")) |
||
906 | Apage->setWidth(pg.attribute("PAGEWIDTH").toDouble()); |
||
907 | else |
||
908 | Apage->setWidth(pg.attribute("PAGEWITH").toDouble()); |
||
909 | Apage->setHeight(pg.attribute("PAGEHEIGHT").toDouble()); |
||
910 | Apage->setInitialHeight(Apage->height()); |
||
911 | Apage->setInitialWidth(Apage->width()); |
||
912 | Apage->initialMargins.Top = QMAX(0.0, pg.attribute("BORDERTOP").toDouble()); |
||
913 | Apage->initialMargins.Bottom = QMAX(0.0, pg.attribute("BORDERBOTTOM").toDouble()); |
||
914 | Apage->initialMargins.Left = QMAX(0.0, pg.attribute("BORDERLEFT").toDouble()); |
||
915 | Apage->initialMargins.Right = QMAX(0.0, pg.attribute("BORDERRIGHT").toDouble()); |
||
916 | Apage->Margins.Top = Apage->initialMargins.Top; |
||
917 | Apage->Margins.Bottom = Apage->initialMargins.Bottom; |
||
918 | m_Doc->setMasterPageMode(false); |
||
919 | //m_Doc->Pages=&m_Doc->DocPages; |
||
920 | // guides reading |
||
921 | tmp = ""; |
||
6027 | subik | 922 | Apage->guides.setHorizontalAutoGap(pg.attribute("AGhorizontalAutoGap", "0.0").toDouble()); |
923 | Apage->guides.setVerticalAutoGap(pg.attribute("AGverticalAutoGap", "0.0").toDouble()); |
||
924 | Apage->guides.setHorizontalAutoCount(pg.attribute("AGhorizontalAutoCount", "0").toInt()); |
||
925 | Apage->guides.setVerticalAutoCount(pg.attribute("AGverticalAutoCount", "0").toInt()); |
||
6747 | subik | 926 | Apage->guides.setHorizontalAutoRefer(pg.attribute("AGhorizontalAutoRefer", "0").toInt()); |
927 | Apage->guides.setVerticalAutoRefer(pg.attribute("AGverticalAutoRefer", "0").toInt()); |
||
5653 | cbradney | 928 | GuideManagerCore::readVerticalGuides(pg.attribute("VerticalGuides"), |
929 | Apage, |
||
930 | GuideManagerCore::Standard, |
||
931 | pg.hasAttribute("NumVGuides")); |
||
932 | GuideManagerCore::readHorizontalGuides(pg.attribute("HorizontalGuides"), |
||
933 | Apage, |
||
934 | GuideManagerCore::Standard, |
||
935 | pg.hasAttribute("NumHGuides")); |
||
936 | } |
||
937 | if ((pg.tagName()=="PAGEOBJECT") || (pg.tagName()=="MASTEROBJECT") || (pg.tagName()=="FRAMEOBJECT")) |
||
938 | { |
||
939 | if ((pg.tagName()=="PAGEOBJECT") || (pg.tagName()=="FRAMEOBJECT")) |
||
940 | { |
||
941 | //m_Doc->Items = m_Doc->DocItems; |
||
942 | //m_Doc->Pages = &m_Doc->DocPages; |
||
943 | m_Doc->setMasterPageMode(false); |
||
944 | } |
||
945 | else |
||
946 | { |
||
947 | //m_Doc->Items = m_Doc->MasterItems; |
||
948 | //m_Doc->Pages = &m_Doc->MasterPages; |
||
949 | m_Doc->setMasterPageMode(true); |
||
950 | } |
||
951 | if ((!pg.attribute("OnMasterPage").isEmpty()) && (pg.tagName()=="MASTEROBJECT")) |
||
952 | m_Doc->setCurrentPage(m_Doc->MasterPages.at(m_Doc->MasterNames[pg.attribute("OnMasterPage")])); |
||
953 | if ((pg.attribute("NEXTITEM").toInt() != -1) || (static_cast<bool>(pg.attribute("AUTOTEXT").toInt()))) |
||
954 | { |
||
955 | if (pg.attribute("BACKITEM").toInt() == -1) |
||
956 | LFrames.append(m_Doc->Items->count()); |
||
957 | } |
||
958 | int docGc = m_Doc->GroupCounter; |
||
959 | m_Doc->GroupCounter = 0; |
||
960 | Neu = PasteItem(&pg, m_Doc); |
||
961 | Neu->setRedrawBounding(); |
||
962 | if (pg.tagName()=="MASTEROBJECT") |
||
963 | Neu->OwnPage = m_Doc->OnPage(Neu); |
||
964 | else |
||
965 | Neu->OwnPage = pg.attribute("OwnPage").toInt(); |
||
966 | if (pg.tagName()=="PAGEOBJECT") |
||
967 | Neu->OnMasterPage = ""; |
||
968 | m_Doc->GroupCounter = docGc; |
||
969 | tmpf = pg.attribute("IFONT", m_Doc->toolSettings.defFont); |
||
5980 | avox | 970 | if ((!m_AvailableFonts->contains(tmpf)) || (!(*m_AvailableFonts)[tmpf].usable())) |
5653 | cbradney | 971 | { |
5980 | avox | 972 | if ((!prefsManager->appPrefs.GFontSub.contains(tmpf)) || (!(*m_AvailableFonts)[prefsManager->appPrefs.GFontSub[tmpf]].usable())) |
5653 | cbradney | 973 | { |
974 | newReplacement = true; |
||
975 | ReplacedFonts.insert(tmpf, prefsManager->appPrefs.toolSettings.defFont); |
||
976 | } |
||
977 | else |
||
978 | ReplacedFonts.insert(tmpf, prefsManager->appPrefs.GFontSub[tmpf]); |
||
979 | } |
||
980 | else |
||
981 | { |
||
982 | if (!m_Doc->UsedFonts.contains(tmpf)) |
||
983 | { |
||
984 | // QFont fo = avail[tmpf]->Font; |
||
985 | // fo.setPointSize(qRound(m_Doc->toolSettings.defSize / 10.0)); |
||
986 | m_Doc->AddFont(tmpf, qRound(m_Doc->toolSettings.defSize / 10.0)); |
||
987 | } |
||
988 | } |
||
989 | QDomNode IT=pg.firstChild(); |
||
990 | LastStyles * last = new LastStyles(); |
||
991 | while(!IT.isNull()) |
||
992 | { |
||
993 | QDomElement it=IT.toElement(); |
||
994 | if (it.tagName()=="CSTOP") |
||
995 | { |
||
996 | QString name = it.attribute("NAME"); |
||
997 | double ramp = it.attribute("RAMP", "0.0").toDouble(); |
||
998 | int shade = it.attribute("SHADE", "100").toInt(); |
||
999 | double opa = it.attribute("TRANS", "1").toDouble(); |
||
1000 | Neu->fill_gradient.addStop(SetColor(m_Doc, name, shade), ramp, 0.5, opa, name, shade); |
||
1001 | } |
||
1002 | if (it.tagName()=="ITEXT") |
||
1003 | GetItemText(&it, m_Doc, Neu, last); |
||
1004 | |||
1005 | //CB PageItemAttributes |
||
1006 | if(it.tagName()=="PageItemAttributes") |
||
1007 | { |
||
1008 | QDomNode PIA = it.firstChild(); |
||
1009 | ObjAttrVector pageItemAttributes; |
||
1010 | while(!PIA.isNull()) |
||
1011 | { |
||
1012 | QDomElement itemAttr = PIA.toElement(); |
||
1013 | if(itemAttr.tagName() == "ItemAttribute") |
||
1014 | { |
||
1015 | ObjectAttribute objattr; |
||
1016 | objattr.name=itemAttr.attribute("Name"); |
||
1017 | objattr.type=itemAttr.attribute("Type"); |
||
1018 | objattr.value=itemAttr.attribute("Value"); |
||
1019 | objattr.parameter=itemAttr.attribute("Parameter"); |
||
1020 | objattr.relationship=itemAttr.attribute("Relationship"); |
||
1021 | objattr.relationshipto=itemAttr.attribute("RelationshipTo"); |
||
1022 | objattr.autoaddto=itemAttr.attribute("AutoAddTo"); |
||
1023 | pageItemAttributes.append(objattr); |
||
1024 | } |
||
1025 | PIA = PIA.nextSibling(); |
||
1026 | } |
||
1027 | Neu->setObjectAttributes(&pageItemAttributes); |
||
1028 | } |
||
1029 | IT=IT.nextSibling(); |
||
1030 | } |
||
1031 | delete last; |
||
1032 | if (Neu->fill_gradient.Stops() == 0) |
||
1033 | { |
||
1034 | Neu->fill_gradient.addStop(m_Doc->PageColors[m_Doc->toolSettings.dBrush].getRGBColor(), 0.0, 0.5, 1.0, m_Doc->toolSettings.dBrush, 100); |
||
1035 | Neu->fill_gradient.addStop(m_Doc->PageColors[m_Doc->toolSettings.dPen].getRGBColor(), 1.0, 0.5, 1.0, m_Doc->toolSettings.dPen, 100); |
||
1036 | } |
||
1037 | // Neu->Language = ScMW->GetLang(pg.attribute("LANGUAGE", m_Doc->Language)); |
||
1038 | Neu->isAutoText = static_cast<bool>(pg.attribute("AUTOTEXT").toInt()); |
||
1039 | Neu->isEmbedded = static_cast<bool>(pg.attribute("isInline", "0").toInt()); |
||
1040 | Neu->gXpos = pg.attribute("gXpos", "0.0").toDouble(); |
||
1041 | Neu->gYpos = pg.attribute("gYpos", "0.0").toDouble(); |
||
1042 | QString defaultVal; |
||
1043 | defaultVal.setNum(Neu->width()); |
||
1044 | Neu->gWidth = pg.attribute("gWidth",defaultVal).toDouble(); |
||
1045 | defaultVal.setNum(Neu->height()); |
||
1046 | Neu->gHeight = pg.attribute("gHeight",defaultVal).toDouble(); |
||
6733 | avox | 1047 | /* if (Neu->lineSpacingMode() == 3) |
5653 | cbradney | 1048 | { |
1049 | m_Doc->docParagraphStyles[0].setUseBaselineGrid(true); |
||
1050 | Neu->setLineSpacing(m_Doc->typographicSettings.valueBaseGrid-1); |
||
1051 | } |
||
6733 | avox | 1052 | */ |
1053 | if (Neu->isAutoText) |
||
5653 | cbradney | 1054 | m_Doc->LastAuto = Neu; |
1055 | Neu->NextIt = pg.attribute("NEXTITEM").toInt(); |
||
1056 | if (Neu->isTableItem) |
||
1057 | { |
||
1058 | TableItems.append(Neu); |
||
1059 | TableID.insert(pg.attribute("OwnLINK", "0").toInt(), Neu->ItemNr); |
||
1060 | } |
||
6451 | fschmid | 1061 | Neu->isGroupControl = static_cast<bool>(pg.attribute("isGroupControl", "0").toInt()); |
1062 | if (Neu->isGroupControl) |
||
1063 | groupID.insert(Neu, pg.attribute("groupsLastItem", "0").toInt()+Neu->ItemNr); |
||
5653 | cbradney | 1064 | if (pg.tagName()=="FRAMEOBJECT") |
1065 | { |
||
1066 | m_Doc->FrameItems.append(m_Doc->Items->take(Neu->ItemNr)); |
||
1067 | Neu->ItemNr = m_Doc->FrameItems.count()-1; |
||
1068 | } |
||
1069 | /* |
||
1070 | if ((pg.tagName()=="PAGEOBJECT") || (pg.tagName()=="FRAMEOBJECT")) |
||
1071 | { |
||
1072 | //m_Doc->DocItems = m_Doc->Items; |
||
1073 | //m_Doc->DocPages = m_Doc->Pages; |
||
1074 | } |
||
1075 | else |
||
1076 | { |
||
1077 | //m_Doc->MasterItems = m_Doc->Items; |
||
1078 | //m_Doc->MasterPages = m_Doc->Pages; |
||
1079 | } |
||
1080 | */ |
||
1081 | m_Doc->setMasterPageMode(false); |
||
1082 | //m_Doc->Pages=&m_Doc->DocPages; |
||
1083 | counter++; |
||
1084 | } |
||
1085 | PAGE=PAGE.nextSibling(); |
||
1086 | } |
||
1087 | PAGE=DOC.firstChild(); |
||
1088 | while(!PAGE.isNull()) |
||
1089 | { |
||
1090 | QDomElement pg=PAGE.toElement(); |
||
1091 | if(pg.tagName()=="Bookmark") |
||
1092 | { |
||
6573 | fschmid | 1093 | uint elem = pg.attribute("Element").toInt(); |
1094 | if (elem < m_Doc->Items->count()) |
||
1095 | { |
||
1096 | bok.Title = pg.attribute("Title"); |
||
1097 | bok.Text = pg.attribute("Text"); |
||
1098 | bok.Aktion = pg.attribute("Aktion"); |
||
1099 | bok.ItemNr = pg.attribute("ItemNr").toInt(); |
||
1100 | bok.PageObject = m_Doc->Items->at(elem); |
||
1101 | bok.First = pg.attribute("First").toInt(); |
||
1102 | bok.Last = pg.attribute("Last").toInt(); |
||
1103 | bok.Prev = pg.attribute("Prev").toInt(); |
||
1104 | bok.Next = pg.attribute("Next").toInt(); |
||
1105 | bok.Parent = pg.attribute("Parent").toInt(); |
||
1106 | m_Doc->BookMarks.append(bok); |
||
1107 | } |
||
5653 | cbradney | 1108 | } |
6380 | fschmid | 1109 | if(pg.tagName()=="Pattern") |
1110 | { |
||
1111 | ScPattern pat; |
||
1112 | QDomNode pa = PAGE.firstChild(); |
||
1113 | uint ac = m_Doc->Items->count(); |
||
6381 | fschmid | 1114 | bool savedAlignGrid = m_Doc->useRaster; |
1115 | bool savedAlignGuides = m_Doc->SnapGuides; |
||
1116 | m_Doc->useRaster = false; |
||
1117 | m_Doc->SnapGuides = false; |
||
6380 | fschmid | 1118 | while(!pa.isNull()) |
1119 | { |
||
1120 | QDomElement pite = pa.toElement(); |
||
1121 | m_Doc->setMasterPageMode(false); |
||
1122 | if ((pite.attribute("NEXTITEM").toInt() != -1) || (static_cast<bool>(pite.attribute("AUTOTEXT").toInt()))) |
||
1123 | { |
||
1124 | if (pite.attribute("BACKITEM").toInt() == -1) |
||
1125 | LFrames.append(m_Doc->Items->count()); |
||
1126 | } |
||
1127 | int docGc = m_Doc->GroupCounter; |
||
1128 | m_Doc->GroupCounter = 0; |
||
1129 | Neu = PasteItem(&pite, m_Doc); |
||
1130 | Neu->setRedrawBounding(); |
||
1131 | Neu->OwnPage = pite.attribute("OwnPage").toInt(); |
||
1132 | Neu->OnMasterPage = ""; |
||
1133 | m_Doc->GroupCounter = docGc; |
||
1134 | tmpf = pite.attribute("IFONT", m_Doc->toolSettings.defFont); |
||
1135 | if ((!m_AvailableFonts->contains(tmpf)) || (!(*m_AvailableFonts)[tmpf].usable())) |
||
1136 | { |
||
1137 | if ((!prefsManager->appPrefs.GFontSub.contains(tmpf)) || (!(*m_AvailableFonts)[prefsManager->appPrefs.GFontSub[tmpf]].usable())) |
||
1138 | { |
||
1139 | newReplacement = true; |
||
1140 | ReplacedFonts.insert(tmpf, prefsManager->appPrefs.toolSettings.defFont); |
||
1141 | } |
||
1142 | else |
||
1143 | ReplacedFonts.insert(tmpf, prefsManager->appPrefs.GFontSub[tmpf]); |
||
1144 | } |
||
1145 | else |
||
1146 | { |
||
1147 | if (!m_Doc->UsedFonts.contains(tmpf)) |
||
1148 | m_Doc->AddFont(tmpf, qRound(m_Doc->toolSettings.defSize / 10.0)); |
||
1149 | } |
||
1150 | QDomNode IT=pite.firstChild(); |
||
1151 | LastStyles * last = new LastStyles(); |
||
1152 | while(!IT.isNull()) |
||
1153 | { |
||
1154 | QDomElement it=IT.toElement(); |
||
1155 | if (it.tagName()=="CSTOP") |
||
1156 | { |
||
1157 | QString name = it.attribute("NAME"); |
||
1158 | double ramp = it.attribute("RAMP", "0.0").toDouble(); |
||
1159 | int shade = it.attribute("SHADE", "100").toInt(); |
||
1160 | double opa = it.attribute("TRANS", "1").toDouble(); |
||
1161 | Neu->fill_gradient.addStop(SetColor(m_Doc, name, shade), ramp, 0.5, opa, name, shade); |
||
1162 | } |
||
1163 | if (it.tagName()=="ITEXT") |
||
1164 | GetItemText(&it, m_Doc, Neu, last); |
||
1165 | if(it.tagName()=="PageItemAttributes") |
||
1166 | { |
||
1167 | QDomNode PIA = it.firstChild(); |
||
1168 | ObjAttrVector pageItemAttributes; |
||
1169 | while(!PIA.isNull()) |
||
1170 | { |
||
1171 | QDomElement itemAttr = PIA.toElement(); |
||
1172 | if(itemAttr.tagName() == "ItemAttribute") |
||
1173 | { |
||
1174 | ObjectAttribute objattr; |
||
1175 | objattr.name=itemAttr.attribute("Name"); |
||
1176 | objattr.type=itemAttr.attribute("Type"); |
||
1177 | objattr.value=itemAttr.attribute("Value"); |
||
1178 | objattr.parameter=itemAttr.attribute("Parameter"); |
||
1179 | objattr.relationship=itemAttr.attribute("Relationship"); |
||
1180 | objattr.relationshipto=itemAttr.attribute("RelationshipTo"); |
||
1181 | objattr.autoaddto=itemAttr.attribute("AutoAddTo"); |
||
1182 | pageItemAttributes.append(objattr); |
||
1183 | } |
||
1184 | PIA = PIA.nextSibling(); |
||
1185 | } |
||
1186 | Neu->setObjectAttributes(&pageItemAttributes); |
||
1187 | } |
||
1188 | IT=IT.nextSibling(); |
||
1189 | } |
||
1190 | delete last; |
||
1191 | if (Neu->fill_gradient.Stops() == 0) |
||
1192 | { |
||
1193 | Neu->fill_gradient.addStop(m_Doc->PageColors[m_Doc->toolSettings.dBrush].getRGBColor(), 0.0, 0.5, 1.0, m_Doc->toolSettings.dBrush, 100); |
||
1194 | Neu->fill_gradient.addStop(m_Doc->PageColors[m_Doc->toolSettings.dPen].getRGBColor(), 1.0, 0.5, 1.0, m_Doc->toolSettings.dPen, 100); |
||
1195 | } |
||
1196 | Neu->isAutoText = static_cast<bool>(pite.attribute("AUTOTEXT").toInt()); |
||
1197 | Neu->isEmbedded = static_cast<bool>(pite.attribute("isInline", "0").toInt()); |
||
1198 | Neu->gXpos = pite.attribute("gXpos", "0.0").toDouble(); |
||
1199 | Neu->gYpos = pite.attribute("gYpos", "0.0").toDouble(); |
||
1200 | QString defaultVal; |
||
1201 | defaultVal.setNum(Neu->width()); |
||
1202 | Neu->gWidth = pite.attribute("gWidth",defaultVal).toDouble(); |
||
1203 | defaultVal.setNum(Neu->height()); |
||
1204 | Neu->gHeight = pite.attribute("gHeight",defaultVal).toDouble(); |
||
1205 | Neu->NextIt = pite.attribute("NEXTITEM").toInt(); |
||
1206 | if (Neu->isTableItem) |
||
1207 | { |
||
1208 | TableItems.append(Neu); |
||
1209 | TableID.insert(pite.attribute("OwnLINK", "0").toInt(), Neu->ItemNr); |
||
1210 | } |
||
6451 | fschmid | 1211 | Neu->isGroupControl = static_cast<bool>(pite.attribute("isGroupControl", "0").toInt()); |
1212 | if (Neu->isGroupControl) |
||
1213 | groupID.insert(Neu, pite.attribute("groupsLastItem", "0").toInt()+Neu->ItemNr); |
||
6380 | fschmid | 1214 | pa = pa.nextSibling(); |
1215 | } |
||
6381 | fschmid | 1216 | m_Doc->useRaster = savedAlignGrid; |
1217 | m_Doc->SnapGuides = savedAlignGuides; |
||
6380 | fschmid | 1218 | uint ae = m_Doc->Items->count(); |
1219 | pat.setDoc(m_Doc); |
||
1220 | PageItem* currItem = m_Doc->Items->at(ac); |
||
1221 | pat.pattern = currItem->DrawObj_toImage(); |
||
1222 | for (uint as = ac; as < ae; ++as) |
||
1223 | { |
||
1224 | Neu = m_Doc->Items->take(ac); |
||
1225 | Neu->ItemNr = pat.items.count(); |
||
1226 | pat.items.append(Neu); |
||
1227 | } |
||
1228 | pat.width = pg.attribute("width", "0").toDouble(); |
||
1229 | pat.height = pg.attribute("height", "0").toDouble(); |
||
6416 | fschmid | 1230 | pat.scaleX = pg.attribute("scaleX", "0").toDouble(); |
1231 | pat.scaleY = pg.attribute("scaleY", "0").toDouble(); |
||
6380 | fschmid | 1232 | m_Doc->docPatterns.insert(pg.attribute("Name"), pat); |
1233 | } |
||
5653 | cbradney | 1234 | PAGE=PAGE.nextSibling(); |
1235 | } |
||
1236 | DOC=DOC.nextSibling(); |
||
1237 | } |
||
1238 | if (TableItems.count() != 0) |
||
1239 | { |
||
1240 | for (uint ttc = 0; ttc < TableItems.count(); ++ttc) |
||
1241 | { |
||
1242 | PageItem* ta = TableItems.at(ttc); |
||
1243 | if (ta->TopLinkID != -1) |
||
1244 | ta->TopLink = m_Doc->Items->at(TableID[ta->TopLinkID]); |
||
1245 | else |
||
1246 | ta->TopLink = 0; |
||
1247 | if (ta->LeftLinkID != -1) |
||
1248 | ta->LeftLink = m_Doc->Items->at(TableID[ta->LeftLinkID]); |
||
1249 | else |
||
1250 | ta->LeftLink = 0; |
||
1251 | if (ta->RightLinkID != -1) |
||
1252 | ta->RightLink = m_Doc->Items->at(TableID[ta->RightLinkID]); |
||
1253 | else |
||
1254 | ta->RightLink = 0; |
||
1255 | if (ta->BottomLinkID != -1) |
||
1256 | ta->BottomLink = m_Doc->Items->at(TableID[ta->BottomLinkID]); |
||
1257 | else |
||
1258 | ta->BottomLink = 0; |
||
1259 | } |
||
1260 | } |
||
6451 | fschmid | 1261 | if (groupID.count() != 0) |
1262 | { |
||
1263 | QMap<PageItem*, int>::Iterator it; |
||
1264 | for (it = groupID.begin(); it != groupID.end(); ++it) |
||
1265 | { |
||
1266 | it.key()->groupsLastItem = m_Doc->Items->at(it.data()); |
||
1267 | } |
||
1268 | } |
||
5653 | cbradney | 1269 | m_Doc->setActiveLayer(layerToSetActive); |
1270 | m_Doc->setMasterPageMode(false); |
||
1271 | m_Doc->reformPages(); |
||
1272 | |||
1273 | if (m_Doc->Layers.count() == 0) |
||
1274 | { |
||
1275 | la.LNr = 0; |
||
1276 | la.Level = 0; |
||
1277 | la.Name = QObject::tr("Background"); |
||
1278 | la.isViewable = true; |
||
1279 | la.isPrintable = true; |
||
1280 | la.isEditable = true; |
||
1281 | la.flowControl = true; |
||
1282 | la.transparency = 1.0; |
||
1283 | la.blendMode = 0; |
||
1284 | la.markerColor = QColor(0, 0, 0); |
||
1285 | la.outlineMode = false; |
||
1286 | m_Doc->Layers.append(la); |
||
1287 | } |
||
1288 | if (LFrames.count() != 0) |
||
1289 | { |
||
1290 | PageItem *Its; |
||
1291 | PageItem *Itn; |
||
1292 | PageItem *Itr; |
||
1293 | QValueList<int>::Iterator lc; |
||
1294 | for (lc = LFrames.begin(); lc != LFrames.end(); ++lc) |
||
1295 | { |
||
1296 | Its = m_Doc->Items->at((*lc)); |
||
1297 | Itr = Its; |
||
1298 | Its->BackBox = 0; |
||
1299 | if (Its->isAutoText) |
||
1300 | m_Doc->FirstAuto = Its; |
||
1301 | while (Its->NextIt != -1) |
||
1302 | { |
||
1303 | Itn = m_Doc->Items->at(Its->NextIt); |
||
1304 | Its->NextBox = Itn; |
||
1305 | Itn->BackBox = Its; |
||
5732 | avox | 1306 | Its->itemText.append(Itn->itemText); |
1307 | Itn->itemText = Its->itemText; |
||
5653 | cbradney | 1308 | Its = Itn; |
1309 | } |
||
1310 | Its->NextBox = 0; |
||
1311 | } |
||
1312 | } |
||
1313 | if (m_mwProgressBar!=0) |
||
1314 | m_mwProgressBar->setProgress(DOC.childNodes().count()); |
||
1315 | return true; |
||
1316 | // return false; |
||
1317 | } |
||
1318 | |||
1319 | |||
1320 | // Low level plugin API |
||
1321 | int scribus134format_getPluginAPIVersion() |
||
1322 | { |
||
1323 | return PLUGIN_API_VERSION; |
||
1324 | } |
||
1325 | |||
1326 | ScPlugin* scribus134format_getPlugin() |
||
1327 | { |
||
1328 | Scribus134Format* plug = new Scribus134Format(); |
||
1329 | Q_CHECK_PTR(plug); |
||
1330 | return plug; |
||
1331 | } |
||
1332 | |||
1333 | void scribus134format_freePlugin(ScPlugin* plugin) |
||
1334 | { |
||
1335 | Scribus134Format* plug = dynamic_cast<Scribus134Format*>(plugin); |
||
1336 | Q_ASSERT(plug); |
||
1337 | delete plug; |
||
1338 | } |
||
1339 | |||
1340 | |||
6733 | avox | 1341 | namespace { |
1342 | const int NOVLAUE = -16000; |
||
1343 | |||
1344 | void fixLegacyCharStyle(CharStyle& cstyle) |
||
1345 | { |
||
1346 | if (! cstyle.font().usable()) |
||
1347 | cstyle.resetFont(); |
||
1348 | if (cstyle.fontSize() <= -16000 / 10) |
||
1349 | cstyle.resetFontSize(); |
||
1350 | if (cstyle.fontSize() == 65535) |
||
1351 | cstyle.resetEffects(); |
||
1352 | if (cstyle.fillColor().isEmpty()) |
||
1353 | cstyle.resetFillColor(); |
||
1354 | if (cstyle.fillShade() <= -16000) |
||
1355 | cstyle.resetFillShade(); |
||
1356 | if (cstyle.strokeColor().isEmpty()) |
||
1357 | cstyle.resetStrokeColor(); |
||
1358 | if (cstyle.strokeShade() <= -16000) |
||
1359 | cstyle.resetStrokeShade(); |
||
1360 | if (cstyle.shadowXOffset() <= -16000 / 10) |
||
1361 | cstyle.resetShadowXOffset(); |
||
1362 | if (cstyle.shadowYOffset() <= -16000 / 10) |
||
1363 | cstyle.resetShadowYOffset(); |
||
1364 | if (cstyle.outlineWidth() <= -16000 / 10) |
||
1365 | cstyle.resetOutlineWidth(); |
||
1366 | if (cstyle.underlineOffset() <= -16000 / 10) |
||
1367 | cstyle.resetUnderlineOffset(); |
||
1368 | if (cstyle.underlineWidth() <= -16000 / 10) |
||
1369 | cstyle.resetUnderlineWidth(); |
||
1370 | if (cstyle.strikethruOffset() <= -16000 / 10) |
||
1371 | cstyle.resetStrikethruOffset(); |
||
1372 | if (cstyle.strikethruWidth() <= -16000 / 10) |
||
1373 | cstyle.resetStrikethruWidth(); |
||
1374 | if (cstyle.scaleH() <= -16000 / 10) |
||
1375 | cstyle.resetScaleH(); |
||
1376 | if (cstyle.scaleV() <= -16000 / 10) |
||
1377 | cstyle.resetScaleV(); |
||
1378 | if (cstyle.baselineOffset() <= -16000 / 10) |
||
1379 | cstyle.resetBaselineOffset(); |
||
1380 | if (cstyle.tracking() <= -16000 / 10) |
||
1381 | cstyle.resetTracking(); |
||
1382 | } |
||
1383 | |||
1384 | void fixLegacyParStyle(ParagraphStyle& pstyle) |
||
1385 | { |
||
1386 | pstyle.resetLineSpacing(); |
||
1387 | if (pstyle.leftMargin() <= -16000) |
||
1388 | pstyle.resetLeftMargin(); |
||
1389 | if (pstyle.rightMargin() <= -16000) |
||
1390 | pstyle.resetRightMargin(); |
||
1391 | if (pstyle.firstIndent() <= -16000) |
||
1392 | pstyle.resetFirstIndent(); |
||
1393 | if (pstyle.alignment() < 0) |
||
1394 | pstyle.resetAlignment(); |
||
1395 | if (pstyle.gapBefore() <= -16000) |
||
1396 | pstyle.resetGapBefore(); |
||
1397 | if (pstyle.gapAfter() <= -16000) |
||
1398 | pstyle.resetGapAfter(); |
||
1399 | if (pstyle.dropCapLines() < 0) |
||
1400 | pstyle.resetDropCapLines(); |
||
1401 | if (pstyle.dropCapOffset() <= -16000) |
||
1402 | pstyle.resetDropCapOffset(); |
||
1403 | fixLegacyCharStyle(pstyle.charStyle()); |
||
1404 | } |
||
1405 | |||
1406 | }// namespace |
||
1407 | |||
1408 | |||
1409 | |||
5653 | cbradney | 1410 | void Scribus134Format::GetItemText(QDomElement *it, ScribusDoc *doc, PageItem* obj, LastStyles* last, bool impo, bool VorLFound) |
1411 | { |
||
5980 | avox | 1412 | ScFace dummy = ScFace::none(); |
5653 | cbradney | 1413 | bool unknown = false; |
1414 | QString tmp2, tmpf; |
||
6733 | avox | 1415 | CharStyle newStyle; |
5653 | cbradney | 1416 | tmp2 = it->attribute("CH"); |
1417 | tmp2.replace(QRegExp("\r"), QChar(13)); |
||
1418 | tmp2.replace(QRegExp("\n"), QChar(13)); |
||
1419 | tmp2.replace(QRegExp("\t"), QChar(9)); |
||
1420 | tmpf = it->attribute("CFONT", doc->toolSettings.defFont); |
||
1421 | PrefsManager* prefsManager=PrefsManager::instance(); |
||
5980 | avox | 1422 | if ((!prefsManager->appPrefs.AvailFonts.contains(tmpf)) || (!prefsManager->appPrefs.AvailFonts[tmpf].usable())) |
5653 | cbradney | 1423 | { |
6733 | avox | 1424 | /* bool isThere = false; |
5980 | avox | 1425 | for (uint dl = 0; dl < dummyScFaces.count(); ++dl) |
5653 | cbradney | 1426 | { |
5980 | avox | 1427 | if ((*dummyScFaces.at(dl)).scName() == tmpf) |
5653 | cbradney | 1428 | { |
1429 | isThere = true; |
||
5980 | avox | 1430 | dummy = *dummyScFaces.at(dl); |
5653 | cbradney | 1431 | break; |
1432 | } |
||
1433 | } |
||
1434 | if (!isThere) |
||
1435 | { |
||
5980 | avox | 1436 | // dummy = ScFace(tmpf, "", tmpf, "", "", 1, false); |
1437 | dummyScFaces.append(dummy); |
||
5653 | cbradney | 1438 | } |
6733 | avox | 1439 | */ |
5653 | cbradney | 1440 | unknown = true; |
5980 | avox | 1441 | if ((!prefsManager->appPrefs.GFontSub.contains(tmpf)) || (!prefsManager->appPrefs.AvailFonts[prefsManager->appPrefs.GFontSub[tmpf]].usable())) |
5653 | cbradney | 1442 | { |
1443 | newReplacement = true; |
||
6733 | avox | 1444 | dummy = prefsManager->appPrefs.AvailFonts[ReplacedFonts[tmpf]].mkReplacementFor(tmpf, doc->DocName); |
1445 | prefsManager->appPrefs.AvailFonts.insert(tmpf, dummy); |
||
5653 | cbradney | 1446 | ReplacedFonts.insert(tmpf, prefsManager->appPrefs.toolSettings.defFont); |
1447 | } |
||
1448 | else |
||
1449 | ReplacedFonts.insert(tmpf, prefsManager->appPrefs.GFontSub[tmpf]); |
||
1450 | } |
||
1451 | else |
||
1452 | { |
||
1453 | if (!doc->UsedFonts.contains(tmpf)) |
||
1454 | { |
||
1455 | doc->AddFont(tmpf, qRound(doc->toolSettings.defSize / 10.0)); |
||
1456 | } |
||
1457 | } |
||
6733 | avox | 1458 | if (! tmpf.isEmpty() ) |
1459 | newStyle.setFont((*doc->AllFonts)[tmpf]); |
||
1460 | |||
1461 | if (it->hasAttribute("CSIZE")) |
||
1462 | newStyle.setFontSize(qRound(it->attribute("CSIZE").toDouble() * 10)); |
||
1463 | |||
1464 | if (it->hasAttribute("CCOLOR")) |
||
1465 | newStyle.setFillColor(it->attribute("CCOLOR")); |
||
1466 | |||
5653 | cbradney | 1467 | if (it->hasAttribute("CEXTRA")) |
6733 | avox | 1468 | newStyle.setTracking(qRound(it->attribute("CEXTRA").toDouble() / it->attribute("CSIZE").toDouble() * 1000.0)); |
1469 | else if (it->hasAttribute("CKERN")) |
||
1470 | newStyle.setTracking(it->attribute("CKERN").toInt()); |
||
1471 | |||
1472 | |||
1473 | if (it->hasAttribute("CSHADE")) |
||
1474 | newStyle.setFillShade(it->attribute("CSHADE").toInt()); |
||
1475 | |||
1476 | if (it->hasAttribute("CSTYLE")) |
||
1477 | newStyle.setEffects(static_cast<StyleFlag>(it->attribute("CSTYLE").toInt())); |
||
1478 | |||
1479 | QString pstylename = it->attribute("PSTYLE", ""); |
||
1480 | int calign = it->attribute("CALIGN", "-1").toInt(); |
||
1481 | |||
1482 | int ab = it->attribute("CAB", "-1").toInt(); |
||
1483 | if (ab >= 5) { |
||
1484 | pstylename = doc->docParagraphStyles[ab-5].name(); |
||
1485 | calign = -1; |
||
1486 | } |
||
1487 | else if (ab >= 0) { |
||
1488 | pstylename = ""; |
||
1489 | calign = ab; |
||
1490 | } |
||
1491 | |||
1492 | if (it->hasAttribute("CSTROKE")) |
||
1493 | newStyle.setStrokeColor(it->attribute("CSTROKE", CommonStrings::None)); |
||
1494 | |||
1495 | if (it->hasAttribute("CSHADE2")) |
||
1496 | newStyle.setStrokeShade(it->attribute("CSHADE2", "100").toInt()); |
||
1497 | |||
1498 | if (it->hasAttribute("CSCALE")) |
||
1499 | newStyle.setScaleH(QMIN(QMAX(qRound(it->attribute("CSCALE", "100").toDouble() * 10), 100), 4000)); |
||
1500 | |||
1501 | if (it->hasAttribute("CSCALEV")) |
||
1502 | newStyle.setScaleV(QMIN(QMAX(qRound(it->attribute("CSCALEV", "100").toDouble() * 10), 100), 4000)); |
||
1503 | |||
1504 | if (it->hasAttribute("CBASE")) |
||
1505 | newStyle.setBaselineOffset(qRound(it->attribute("CBASE", "0").toDouble() * 10)); |
||
1506 | |||
1507 | if (it->hasAttribute("CSHX")) |
||
1508 | newStyle.setShadowXOffset(qRound(it->attribute("CSHX", "5").toDouble() * 10)); |
||
1509 | |||
1510 | if (it->hasAttribute("CSHY")) |
||
1511 | newStyle.setShadowYOffset(qRound(it->attribute("CSHY", "-5").toDouble() * 10)); |
||
1512 | |||
1513 | if (it->hasAttribute("COUT")) |
||
1514 | newStyle.setOutlineWidth(qRound(it->attribute("COUT", "1").toDouble() * 10)); |
||
1515 | |||
1516 | if (it->hasAttribute("CULP")) |
||
1517 | newStyle.setUnderlineOffset(qRound(it->attribute("CULP", "-0.1").toDouble() * 10)); |
||
1518 | |||
1519 | if (it->hasAttribute("CULW")) |
||
1520 | newStyle.setUnderlineWidth(qRound(it->attribute("CULW", "-0.1").toDouble() * 10)); |
||
1521 | |||
1522 | |||
1523 | if (it->hasAttribute("CSTP")) |
||
1524 | newStyle.setStrikethruOffset(qRound(it->attribute("CSTP", "-0.1").toDouble() * 10)); |
||
1525 | |||
1526 | if (it->hasAttribute("CSTW")) |
||
1527 | newStyle.setStrikethruWidth(qRound(it->attribute("CSTW", "-0.1").toDouble() * 10)); |
||
1528 | |||
1529 | fixLegacyCharStyle(newStyle); |
||
1530 | |||
1531 | if (impo && ab >= 0 && VorLFound) |
||
1532 | last->ParaStyle = DoVorl[ab].toInt(); |
||
5653 | cbradney | 1533 | else |
6733 | avox | 1534 | { |
1535 | last->ParaStyle = doc->docParagraphStyles.find(pstylename); |
||
1536 | } |
||
1537 | |||
5653 | cbradney | 1538 | int iobj = it->attribute("COBJ", "-1").toInt(); |
1539 | for (uint cxx=0; cxx<tmp2.length(); ++cxx) |
||
1540 | { |
||
6733 | avox | 1541 | QChar ch = tmp2.at(cxx); |
1542 | { // Legacy mode |
||
1543 | if (ch == QChar(5)) |
||
1544 | ch = SpecialChars::PARSEP; |
||
1545 | if (ch == QChar(4)) |
||
1546 | ch = SpecialChars::TAB; |
||
5653 | cbradney | 1547 | } |
6733 | avox | 1548 | |
5653 | cbradney | 1549 | int pos = obj->itemText.length(); |
1550 | if (ch == SpecialChars::OBJECT) { |
||
1551 | if (iobj != -1) { |
||
1552 | obj->itemText.insertObject(pos, doc->FrameItems.at(iobj)); |
||
1553 | } |
||
1554 | } |
||
1555 | else { |
||
1556 | obj->itemText.insertChars(pos, QString(ch)); |
||
1557 | } |
||
1558 | if (newStyle != last->Style) { |
||
1559 | #ifdef NLS_PROTO |
||
1560 | qDebug(QString("new style at %1: %2 -> %3").arg(pos).arg(last->Style.asString()).arg(newStyle.asString())); |
||
1561 | #endif |
||
5721 | avox | 1562 | obj->itemText.applyCharStyle(last->StyleStart, pos-last->StyleStart, last->Style); |
5653 | cbradney | 1563 | last->Style = newStyle; |
1564 | last->StyleStart = pos; |
||
1565 | } |
||
1566 | if (ch == SpecialChars::PARSEP) { |
||
6733 | avox | 1567 | ParagraphStyle pstyle; |
1568 | if (last->ParaStyle >= 0) { |
||
1569 | pstyle.setParent( doc->docParagraphStyles[last->ParaStyle].name()); |
||
1570 | } |
||
1571 | if (calign >= 0) |
||
1572 | pstyle.setAlignment(static_cast<ParagraphStyle::AlignmentType>(calign)); |
||
6805 | avox | 1573 | // qDebug(QString("par style at %1: %2/%3 (%4) calign %5").arg(pos).arg(pstyle.name()).arg(pstyle.parent()).arg(last->ParaStyle).arg(calign)); |
5721 | avox | 1574 | obj->itemText.applyStyle(pos, pstyle); |
5653 | cbradney | 1575 | } |
1576 | } |
||
5721 | avox | 1577 | obj->itemText.applyCharStyle(last->StyleStart, obj->itemText.length()-last->StyleStart, last->Style); |
6733 | avox | 1578 | ParagraphStyle pstyle; |
1579 | if (last->ParaStyle >= 0) { |
||
1580 | pstyle.setParent( doc->docParagraphStyles[last->ParaStyle].name()); |
||
1581 | } |
||
1582 | if (calign >= 0) |
||
1583 | pstyle.setAlignment(static_cast<ParagraphStyle::AlignmentType>(calign)); |
||
1584 | obj->itemText.applyStyle(obj->itemText.length()-1, pstyle); |
||
5653 | cbradney | 1585 | return; |
1586 | } |
||
1587 | |||
6733 | avox | 1588 | |
1589 | |||
5653 | cbradney | 1590 | void Scribus134Format::readParagraphStyle(ParagraphStyle& vg, const QDomElement& pg, SCFonts &avail, ScribusDoc *doc) |
1591 | { |
||
1592 | vg.setName(pg.attribute("NAME")); |
||
1593 | vg.setLineSpacingMode(static_cast<ParagraphStyle::LineSpacingMode>(pg.attribute("LINESPMode", "0").toInt())); |
||
1594 | vg.setLineSpacing(pg.attribute("LINESP").toDouble()); |
||
1595 | vg.setLeftMargin(pg.attribute("INDENT", "0").toDouble()); |
||
1596 | if (pg.hasAttribute("RMARGIN")) |
||
1597 | vg.setRightMargin(pg.attribute("RMARGIN", "0").toDouble()); |
||
1598 | else |
||
1599 | vg.setRightMargin(0); |
||
1600 | vg.setFirstIndent(pg.attribute("FIRST", "0").toDouble()); |
||
6733 | avox | 1601 | vg.setAlignment(static_cast<ParagraphStyle::AlignmentType>(pg.attribute("ALIGN").toInt())); |
5653 | cbradney | 1602 | vg.setGapBefore(pg.attribute("VOR", "0").toDouble()); |
1603 | vg.setGapAfter(pg.attribute("NACH", "0").toDouble()); |
||
1604 | PrefsManager * prefsManager = PrefsManager::instance(); |
||
1605 | QString tmpf = pg.attribute("FONT", doc->toolSettings.defFont); |
||
5980 | avox | 1606 | if ((!avail.contains(tmpf)) || (!avail[tmpf].usable())) |
5653 | cbradney | 1607 | { |
5980 | avox | 1608 | if ((!prefsManager->appPrefs.GFontSub.contains(tmpf)) || (!avail[prefsManager->appPrefs.GFontSub[tmpf]].usable())) |
5653 | cbradney | 1609 | { |
1610 | newReplacement = true; |
||
1611 | ReplacedFonts.insert(tmpf, prefsManager->appPrefs.toolSettings.defFont); |
||
1612 | } |
||
6295 | avox | 1613 | else { |
1614 | ReplacedFonts.insert(tmpf, prefsManager->appPrefs.GFontSub[tmpf]); } |
||
1615 | vg.charStyle().setFont(avail[ReplacedFonts[tmpf]]); |
||
1616 | } |
||
1617 | else |
||
1618 | { |
||
1619 | if (!doc->UsedFonts.contains(tmpf)) |
||
5653 | cbradney | 1620 | { |
6295 | avox | 1621 | // QFont fo = avail[tmpf]->Font; |
1622 | // fo.setPointSize(qRound(doc->toolSettings.defSize / 10.0)); |
||
1623 | doc->AddFont(tmpf, qRound(doc->toolSettings.defSize / 10.0)); |
||
5653 | cbradney | 1624 | } |
6295 | avox | 1625 | vg.charStyle().setFont(avail[tmpf]); |
1626 | } |
||
6733 | avox | 1627 | |
1628 | vg.charStyle().setFontSize(qRound(pg.attribute("FONTSIZE", "12").toDouble() * 10.0)); |
||
1629 | vg.setHasDropCap(static_cast<bool>(pg.attribute("DROP", "0").toInt())); |
||
1630 | vg.setDropCapLines(pg.attribute("DROPLIN", "2").toInt()); |
||
1631 | vg.setDropCapOffset(pg.attribute("DROPDIST", "0").toDouble()); |
||
1632 | vg.charStyle().setEffects(static_cast<StyleFlag>(pg.attribute("EFFECT", "0").toInt())); |
||
1633 | vg.charStyle().setFillColor(pg.attribute("FCOLOR", doc->toolSettings.dBrush)); |
||
1634 | vg.charStyle().setFillShade(pg.attribute("FSHADE", "100").toInt()); |
||
1635 | vg.charStyle().setStrokeColor(pg.attribute("SCOLOR", doc->toolSettings.dPen)); |
||
1636 | vg.charStyle().setStrokeShade(pg.attribute("SSHADE", "100").toInt()); |
||
1637 | vg.setUseBaselineGrid(static_cast<bool>(pg.attribute("BASE", "0").toInt())); |
||
1638 | vg.charStyle().setShadowXOffset(qRound(pg.attribute("TXTSHX", "5").toDouble() * 10)); |
||
1639 | vg.charStyle().setShadowYOffset(qRound(pg.attribute("TXTSHY", "-5").toDouble() * 10)); |
||
1640 | vg.charStyle().setOutlineWidth(qRound(pg.attribute("TXTOUT", "1").toDouble() * 10)); |
||
1641 | vg.charStyle().setUnderlineOffset(qRound(pg.attribute("TXTULP", "-0.1").toDouble() * 10)); |
||
1642 | vg.charStyle().setUnderlineWidth(qRound(pg.attribute("TXTULW", "-0.1").toDouble() * 10)); |
||
1643 | vg.charStyle().setStrikethruOffset(qRound(pg.attribute("TXTSTP", "-0.1").toDouble() * 10)); |
||
1644 | vg.charStyle().setStrikethruWidth(qRound(pg.attribute("TXTSTW", "-0.1").toDouble() * 10)); |
||
1645 | vg.charStyle().setScaleH(qRound(pg.attribute("SCALEH", "100").toDouble() * 10)); |
||
1646 | vg.charStyle().setScaleV(qRound(pg.attribute("SCALEV", "100").toDouble() * 10)); |
||
1647 | vg.charStyle().setBaselineOffset(qRound(pg.attribute("BASEO", "0").toDouble() * 10)); |
||
1648 | vg.charStyle().setTracking(qRound(pg.attribute("KERN", "0").toDouble() * 10)); |
||
1649 | // vg.tabValues().clear(); |
||
1650 | if ((pg.hasAttribute("NUMTAB")) && (pg.attribute("NUMTAB", "0").toInt() != 0)) |
||
1651 | { |
||
1652 | QValueList<ParagraphStyle::TabRecord> tbs; |
||
1653 | ParagraphStyle::TabRecord tb; |
||
1654 | QString tmp = pg.attribute("TABS"); |
||
1655 | QTextStream tgv(&tmp, IO_ReadOnly); |
||
1656 | double xf, xf2; |
||
1657 | for (int cxv = 0; cxv < pg.attribute("NUMTAB", "0").toInt(); cxv += 2) |
||
5653 | cbradney | 1658 | { |
6733 | avox | 1659 | tgv >> xf; |
1660 | tgv >> xf2; |
||
1661 | tb.tabPosition = xf2; |
||
1662 | tb.tabType = static_cast<int>(xf); |
||
1663 | tb.tabFillChar = QChar(); |
||
1664 | tbs.append(tb); |
||
5653 | cbradney | 1665 | } |
6733 | avox | 1666 | vg.setTabValues(tbs); |
1667 | tmp = ""; |
||
1668 | } |
||
1669 | else |
||
1670 | { |
||
1671 | QValueList<ParagraphStyle::TabRecord> tbs; |
||
1672 | QDomNode IT = pg.firstChild(); |
||
1673 | while(!IT.isNull()) |
||
5653 | cbradney | 1674 | { |
6733 | avox | 1675 | QDomElement it = IT.toElement(); |
1676 | if (it.tagName()=="Tabs") |
||
5653 | cbradney | 1677 | { |
6733 | avox | 1678 | ParagraphStyle::TabRecord tb; |
1679 | tb.tabPosition = it.attribute("Pos").toDouble(); |
||
1680 | tb.tabType = it.attribute("Type").toInt(); |
||
1681 | QString tbCh = ""; |
||
1682 | tbCh = it.attribute("Fill",""); |
||
1683 | if (tbCh.isEmpty()) |
||
1684 | tb.tabFillChar = QChar(); |
||
1685 | else |
||
1686 | tb.tabFillChar = tbCh[0]; |
||
1687 | tbs.append(tb); |
||
5653 | cbradney | 1688 | } |
6733 | avox | 1689 | vg.setTabValues(tbs); |
1690 | IT=IT.nextSibling(); |
||
5653 | cbradney | 1691 | } |
6733 | avox | 1692 | } |
1693 | fixLegacyParStyle(vg); |
||
5653 | cbradney | 1694 | } |
1695 | |||
6733 | avox | 1696 | |
5653 | cbradney | 1697 | PageItem* Scribus134Format::PasteItem(QDomElement *obj, ScribusDoc *doc) |
1698 | { |
||
5937 | jghali | 1699 | struct ImageLoadRequest loadingInfo; |
5653 | cbradney | 1700 | int z = 0; |
1701 | PageItem::ItemType pt = static_cast<PageItem::ItemType>(obj->attribute("PTYPE").toInt()); |
||
1702 | double x = obj->attribute("XPOS").toDouble(); |
||
1703 | double y = obj->attribute("YPOS").toDouble(); |
||
1704 | double w = obj->attribute("WIDTH").toDouble(); |
||
1705 | double h = obj->attribute("HEIGHT").toDouble(); |
||
1706 | double pw = obj->attribute("PWIDTH").toDouble(); |
||
1707 | double scx = obj->attribute("LOCALSCX").toDouble(); |
||
1708 | double scy = obj->attribute("LOCALSCY").toDouble(); |
||
1709 | QString Pcolor = obj->attribute("PCOLOR"); |
||
1710 | QString Pcolor2 = obj->attribute("PCOLOR2"); |
||
1711 | QColor tmpc; |
||
1712 | PageItem *currItem=NULL; |
||
1713 | QString tmp; |
||
1714 | int xi; |
||
1715 | double xf, yf, xf2; |
||
1716 | QString clPath; |
||
1717 | QDomNode IT; |
||
1718 | switch (pt) |
||
1719 | { |
||
1720 | // OBSOLETE CR 2005-02-06 |
||
1721 | case PageItem::ItemType1: |
||
1722 | z = doc->itemAdd(PageItem::Polygon, PageItem::Ellipse, x, y, w, h, pw, Pcolor, Pcolor2, true); |
||
1723 | currItem = doc->Items->at(z); |
||
1724 | break; |
||
1725 | // |
||
1726 | case PageItem::ImageFrame: |
||
1727 | z = doc->itemAdd(PageItem::ImageFrame, PageItem::Unspecified, x, y, w, h, 1, doc->toolSettings.dBrushPict, CommonStrings::None, true); |
||
1728 | currItem = doc->Items->at(z); |
||
1729 | currItem->setImageXYScale(scx, scy); |
||
1730 | currItem->setImageXYOffset(obj->attribute("LOCALX").toDouble(), obj->attribute("LOCALY").toDouble()); |
||
1731 | currItem->Pfile = obj->attribute("PFILE"); |
||
1732 | currItem->IProfile = obj->attribute("PRFILE",""); |
||
1733 | currItem->EmProfile = obj->attribute("EPROF",""); |
||
1734 | currItem->IRender = obj->attribute("IRENDER", "1").toInt(); |
||
1735 | currItem->UseEmbedded = obj->attribute("EMBEDDED", "1").toInt(); |
||
1736 | currItem->pixm.imgInfo.lowResType = obj->attribute("ImageRes", "1").toInt(); |
||
1737 | IT = obj->firstChild(); |
||
1738 | while(!IT.isNull()) |
||
1739 | { |
||
1740 | QDomElement it = IT.toElement(); |
||
1741 | if (it.tagName()=="ImageEffect") |
||
1742 | { |
||
1743 | struct ScImage::imageEffect ef; |
||
1744 | ef.effectParameters = it.attribute("Param"); |
||
1745 | ef.effectCode = it.attribute("Code").toInt(); |
||
1746 | currItem->effectsInUse.append(ef); |
||
1747 | } |
||
1748 | IT=IT.nextSibling(); |
||
1749 | } |
||
1750 | if (!currItem->Pfile.isEmpty()) |
||
1751 | doc->loadPict(currItem->Pfile, currItem, false); |
||
1752 | currItem->IProfile = obj->attribute("PRFILE",""); |
||
1753 | currItem->EmProfile = obj->attribute("EPROF",""); |
||
1754 | currItem->IRender = obj->attribute("IRENDER", "1").toInt(); |
||
1755 | currItem->UseEmbedded = obj->attribute("EMBEDDED", "1").toInt(); |
||
1756 | currItem->setImageXYScale(scx, scy); |
||
1757 | clPath = obj->attribute("ImageClip", ""); |
||
1758 | if (currItem->pixm.imgInfo.PDSpathData.contains(clPath)) |
||
1759 | { |
||
1760 | currItem->imageClip = currItem->pixm.imgInfo.PDSpathData[clPath].copy(); |
||
1761 | currItem->pixm.imgInfo.usedPath = clPath; |
||
1762 | QWMatrix cl; |
||
1763 | cl.translate(currItem->imageXOffset()*currItem->imageXScale(), currItem->imageYOffset()*currItem->imageYScale()); |
||
1764 | cl.scale(currItem->imageXScale(), currItem->imageYScale()); |
||
1765 | currItem->imageClip.map(cl); |
||
1766 | } |
||
1767 | currItem->setImageShown(obj->attribute("PICART").toInt()); |
||
1768 | /* currItem->BBoxX = obj->attribute("BBOXX").toDouble(); |
||
1769 | currItem->BBoxH = obj->attribute("BBOXH").toDouble(); */ |
||
1770 | currItem->ScaleType = obj->attribute("SCALETYPE", "1").toInt(); |
||
1771 | currItem->AspectRatio = obj->attribute("RATIO", "0").toInt(); |
||
1772 | currItem->setLineWidth(pw); |
||
1773 | if (currItem->pixm.imgInfo.layerInfo.count() != 0) |
||
1774 | { |
||
1775 | bool found = false; |
||
1776 | IT = obj->firstChild(); |
||
1777 | while(!IT.isNull()) |
||
1778 | { |
||
1779 | QDomElement it = IT.toElement(); |
||
1780 | if (it.tagName() == "PSDLayer") |
||
1781 | { |
||
1782 | found = true; |
||
1783 | loadingInfo.blend = it.attribute("Blend"); |
||
1784 | loadingInfo.opacity = it.attribute("Opacity").toInt(); |
||
1785 | loadingInfo.visible = static_cast<bool>(it.attribute("Visible").toInt()); |
||
6138 | fschmid | 1786 | loadingInfo.useMask = static_cast<bool>(it.attribute("useMask", "1").toInt()); |
5653 | cbradney | 1787 | currItem->pixm.imgInfo.RequestProps.insert(it.attribute("Layer").toInt(), loadingInfo); |
1788 | } |
||
1789 | IT=IT.nextSibling(); |
||
1790 | } |
||
1791 | if (found) |
||
1792 | { |
||
1793 | currItem->pixm.imgInfo.isRequest = true; |
||
1794 | doc->loadPict(currItem->Pfile, currItem, true); |
||
1795 | } |
||
1796 | } |
||
1797 | break; |
||
1798 | // OBSOLETE CR 2005-02-06 |
||
1799 | case PageItem::ItemType3: |
||
1800 | z = doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, x, y, w, h, pw, Pcolor, Pcolor2, true); |
||
1801 | currItem = doc->Items->at(z); |
||
1802 | break; |
||
1803 | // |
||
1804 | case PageItem::PathText: |
||
1805 | z = doc->itemAdd(PageItem::PathText, PageItem::Unspecified, x, y, w, h, pw, CommonStrings::None, Pcolor, true); |
||
1806 | currItem = doc->Items->at(z); |
||
1807 | if ((obj->attribute("ANNOTATION", "0").toInt()) && (static_cast<bool>(obj->attribute("ANICON", "0").toInt()))) |
||
1808 | { |
||
1809 | currItem->setImageXYScale(scx, scy); |
||
1810 | currItem->setImageXYOffset(obj->attribute("LOCALX").toDouble(), obj->attribute("LOCALY").toDouble()); |
||
1811 | currItem->Pfile = obj->attribute("PFILE"); |
||
1812 | currItem->Pfile2 = obj->attribute("PFILE2",""); |
||
1813 | currItem->Pfile3 = obj->attribute("PFILE3",""); |
||
1814 | currItem->IProfile = obj->attribute("PRFILE",""); |
||
1815 | currItem->EmProfile = obj->attribute("EPROF",""); |
||
1816 | currItem->IRender = obj->attribute("IRENDER", "1").toInt(); |
||
1817 | currItem->UseEmbedded = obj->attribute("EMBEDDED", "1").toInt(); |
||
1818 | doc->LoadPict(currItem->Pfile, z); |
||
1819 | currItem->setImageXYScale(scx, scy); |
||
1820 | currItem->setImageShown(obj->attribute("PICART").toInt()); |
||
1821 | /* currItem->BBoxX = obj->attribute("BBOXX").toDouble(); |
||
1822 | currItem->BBoxH = obj->attribute("BBOXH").toDouble(); */ |
||
1823 | currItem->ScaleType = obj->attribute("SCALETYPE", "1").toInt(); |
||
1824 | currItem->AspectRatio = obj->attribute("RATIO", "0").toInt(); |
||
1825 | } |
||
1826 | //currItem->convertTo(pt); |
||
1827 | break; |
||
1828 | case PageItem::TextFrame: |
||
1829 | z = doc->itemAdd(PageItem::TextFrame, PageItem::Unspecified, x, y, w, h, pw, CommonStrings::None, Pcolor, true); |
||
1830 | currItem = doc->Items->at(z); |
||
1831 | if ((obj->attribute("ANNOTATION", "0").toInt()) && (static_cast<bool>(obj->attribute("ANICON", "0").toInt()))) |
||
1832 | { |
||
1833 | currItem->setImageXYScale(scx, scy); |
||
1834 | currItem->setImageXYOffset(obj->attribute("LOCALX").toDouble(), obj->attribute("LOCALY").toDouble()); |
||
1835 |