Rev 14731 | Rev 14862 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
5653 | cbradney | 1 | /* |
2 | For general Scribus (>=1.3.2) copyright and licensing information please refer |
||
3 | to the COPYING file provided with the program. Following this notice may exist |
||
4 | a copyright and/or license notice that predates the release of Scribus 1.3.2 |
||
5 | for which a new license (GPL+exception) is in place. |
||
6 | */ |
||
7 | #include "scribus134format.h" |
||
8 | #include "scribus134formatimpl.h" |
||
9 | |||
10 | #include "../../formatidlist.h" |
||
11 | #include "commonstrings.h" |
||
13852 | jghali | 12 | #include "hyphenator.h" |
5653 | cbradney | 13 | #include "missing.h" |
13852 | jghali | 14 | #include "pageitem_latexframe.h" |
5653 | cbradney | 15 | #include "prefsmanager.h" |
13473 | pierre | 16 | #include "scclocale.h" |
5653 | cbradney | 17 | #include "scconfig.h" |
10607 | mrdocs | 18 | #include "scpattern.h" |
5653 | cbradney | 19 | #include "scribusdoc.h" |
20 | #include "scribusview.h" |
||
13503 | cbradney | 21 | #include "sctextstream.h" |
7478 | jghali | 22 | #include "sccolorengine.h" |
13519 | jghali | 23 | #include "scribuscore.h" |
13852 | jghali | 24 | #include "undomanager.h" |
5653 | cbradney | 25 | |
26 | #include "units.h" |
||
27 | #include "util.h" |
||
10203 | cbradney | 28 | #include "util_math.h" |
29 | #include "util_color.h" |
||
8022 | jghali | 30 | #include "scgzfile.h" |
10603 | fschmid | 31 | #include "scpattern.h" |
10170 | fschmid | 32 | #include <QCursor> |
11675 | cbradney | 33 | // #include <QDebug> |
10170 | fschmid | 34 | #include <QFileInfo> |
9803 | fschmid | 35 | #include <QList> |
9535 | fschmid | 36 | #include <QByteArray> |
8620 | subik | 37 | #include <QApplication> |
5653 | cbradney | 38 | |
39 | |||
40 | // See scplugin.h and pluginmanager.{cpp,h} for detail on what these methods |
||
41 | // do. That documentatation is not duplicated here. |
||
42 | // Please don't implement the functionality of your plugin here; do that |
||
43 | // in scribus134formatimpl.h and scribus134formatimpl.cpp . |
||
44 | |||
45 | Scribus134Format::Scribus134Format() : |
||
46 | LoadSavePlugin() |
||
47 | { |
||
48 | // Set action info in languageChange, so we only have to do |
||
49 | // it in one place. This includes registering file formats. |
||
50 | languageChange(); |
||
51 | } |
||
52 | |||
53 | Scribus134Format::~Scribus134Format() |
||
54 | { |
||
55 | unregisterAll(); |
||
56 | }; |
||
57 | |||
58 | void Scribus134Format::languageChange() |
||
59 | { |
||
60 | //(Re)register file formats. |
||
61 | unregisterAll(); |
||
62 | registerFormats(); |
||
63 | } |
||
64 | |||
65 | const QString Scribus134Format::fullTrName() const |
||
66 | { |
||
12851 | cbradney | 67 | return QObject::tr("Scribus 1.3.4+ Support"); |
5653 | cbradney | 68 | } |
69 | |||
70 | const ScActionPlugin::AboutData* Scribus134Format::getAboutData() const |
||
71 | { |
||
72 | AboutData* about = new AboutData; |
||
73 | Q_CHECK_PTR(about); |
||
12711 | cbradney | 74 | about->authors = QString::fromUtf8( |
75 | "Franz Schmid <franz@scribus.info>, " |
||
76 | "The Scribus Team"); |
||
77 | about->shortDescription = tr("Scribus 1.3.4+ File Format Support"); |
||
78 | about->description = tr("Allows Scribus to read Scribus 1.3.4 and higher formatted files."); |
||
79 | // about->version |
||
80 | // about->releaseDate |
||
81 | // about->copyright |
||
82 | about->license = "GPL"; |
||
5653 | cbradney | 83 | return about; |
84 | } |
||
85 | |||
86 | void Scribus134Format::deleteAboutData(const AboutData* about) const |
||
87 | { |
||
88 | Q_ASSERT(about); |
||
89 | delete about; |
||
90 | } |
||
91 | |||
92 | void Scribus134Format::registerFormats() |
||
93 | { |
||
94 | FileFormat fmt(this); |
||
12851 | cbradney | 95 | fmt.trName = tr("Scribus 1.3.4+ Document"); |
5653 | cbradney | 96 | fmt.formatId = FORMATID_SLA134IMPORT; |
97 | fmt.load = true; |
||
98 | fmt.save = true; |
||
99 | fmt.filter = fmt.trName + " (*.sla *.SLA *.sla.gz *.SLA.GZ *.scd *.SCD *.scd.gz *.SCD.GZ)"; |
||
10593 | fschmid | 100 | fmt.nameMatch = QRegExp("\\.(sla|scd)(\\.gz)?", Qt::CaseInsensitive); |
5653 | cbradney | 101 | fmt.mimeTypes = QStringList(); |
102 | fmt.mimeTypes.append("application/x-scribus"); |
||
103 | fmt.priority = 64; |
||
104 | registerFormat(fmt); |
||
105 | } |
||
106 | |||
107 | bool Scribus134Format::fileSupported(QIODevice* /* file */, const QString & fileName) const |
||
108 | { |
||
9535 | fschmid | 109 | QByteArray docBytes(""); |
5653 | cbradney | 110 | if(fileName.right(2) == "gz") |
111 | { |
||
11739 | jghali | 112 | if (!ScGzFile::readFromFile(fileName, docBytes, 4096)) |
5653 | cbradney | 113 | { |
114 | // FIXME: Needs better error return |
||
6855 | jghali | 115 | return false; |
5653 | cbradney | 116 | } |
117 | } |
||
118 | else |
||
119 | { |
||
120 | // Not gzip encoded, just load it |
||
121 | loadRawText(fileName, docBytes); |
||
122 | } |
||
7046 | avox | 123 | // if (docBytes.left(16) == "<SCRIBUSUTF8NEW " && docBytes.left(35).contains("Version=\"1.3.4")) |
124 | // return true; |
||
10593 | fschmid | 125 | int startElemPos = docBytes.left(512).indexOf("<SCRIBUSUTF8NEW "); |
13883 | jghali | 126 | return startElemPos >= 0 && ((docBytes.mid(startElemPos, 64).indexOf("Version=\"1.3.4") >= 0) || |
127 | (docBytes.mid(startElemPos, 64).indexOf("Version=\"1.3.5") >= 0) || |
||
128 | (docBytes.mid(startElemPos, 64).indexOf("Version=\"1.3.6") >= 0)); |
||
5653 | cbradney | 129 | } |
130 | |||
131 | QString Scribus134Format::readSLA(const QString & fileName) |
||
132 | { |
||
9535 | fschmid | 133 | QByteArray docBytes(""); |
5653 | cbradney | 134 | if(fileName.right(2) == "gz") |
135 | { |
||
11739 | jghali | 136 | if (!ScGzFile::readFromFile(fileName, docBytes)) |
5653 | cbradney | 137 | { |
138 | // FIXME: Needs better error return |
||
8022 | jghali | 139 | return false; |
5653 | cbradney | 140 | } |
141 | } |
||
142 | else |
||
143 | { |
||
144 | // Not gzip encoded, just load it |
||
145 | loadRawText(fileName, docBytes); |
||
146 | } |
||
147 | QString docText(""); |
||
10593 | fschmid | 148 | int startElemPos = docBytes.left(512).indexOf("<SCRIBUSUTF8NEW "); |
13883 | jghali | 149 | if (startElemPos >= 0 && ((docBytes.mid(startElemPos, 64).indexOf("Version=\"1.3.4") >= 0) || |
150 | (docBytes.mid(startElemPos, 64).indexOf("Version=\"1.3.5") >= 0) || |
||
151 | (docBytes.mid(startElemPos, 64).indexOf("Version=\"1.3.6") >= 0))) |
||
5653 | cbradney | 152 | docText = QString::fromUtf8(docBytes); |
153 | else |
||
154 | return QString::null; |
||
155 | if (docText.endsWith(QChar(10)) || docText.endsWith(QChar(13))) |
||
156 | docText.truncate(docText.length()-1); |
||
157 | return docText; |
||
158 | } |
||
159 | |||
9803 | fschmid | 160 | void Scribus134Format::getReplacedFontData(bool & getNewReplacement, QMap<QString,QString> &getReplacedFonts, QList<ScFace> &getDummyScFaces) |
5653 | cbradney | 161 | { |
8775 | cbradney | 162 | getNewReplacement=false; |
163 | getReplacedFonts.clear(); |
||
5653 | cbradney | 164 | } |
165 | |||
166 | bool Scribus134Format::loadFile(const QString & fileName, const FileFormat & /* fmt */, int /* flags */, int /* index */) |
||
167 | { |
||
168 | if (m_Doc==0 || m_AvailableFonts==0) |
||
169 | { |
||
170 | Q_ASSERT(m_Doc==0 || m_AvailableFonts==0); |
||
171 | return false; |
||
172 | } |
||
173 | ParagraphStyle vg; |
||
174 | struct ScribusDoc::BookMa bok; |
||
175 | int counter;//, Pgc; |
||
176 | //bool AtFl; |
||
177 | bool newVersion = false; |
||
14391 | jghali | 178 | QString tmp, tmpf, PgNam, Defont; |
5653 | cbradney | 179 | QMap<int,int> TableID; |
9856 | fschmid | 180 | QList<PageItem*> TableItems; |
7450 | fschmid | 181 | QMap<int,int> TableIDM; |
9856 | fschmid | 182 | QList<PageItem*> TableItemsM; |
7450 | fschmid | 183 | QMap<int,int> TableIDF; |
9856 | fschmid | 184 | QList<PageItem*> TableItemsF; |
6451 | fschmid | 185 | QMap<PageItem*, int> groupID; |
7444 | fschmid | 186 | QMap<PageItem*, int> groupIDM; |
7450 | fschmid | 187 | QMap<PageItem*, int> groupIDF; |
5653 | cbradney | 188 | int a; |
189 | PageItem *Neu; |
||
190 | Page* Apage; |
||
13636 | jghali | 191 | groupRemap.clear(); |
7994 | avox | 192 | itemRemap.clear(); |
193 | itemNext.clear(); |
||
194 | itemCount = 0; |
||
195 | itemRemapM.clear(); |
||
196 | itemNextM.clear(); |
||
197 | itemCountM = 0; |
||
198 | itemRemapF.clear(); |
||
199 | itemNextF.clear(); |
||
200 | itemCountF = 0; |
||
5653 | cbradney | 201 | QDomDocument docu("scridoc"); |
202 | QString f(readSLA(fileName)); |
||
203 | if (f.isEmpty()) |
||
14394 | jghali | 204 | { |
205 | setFileReadError(); |
||
5653 | cbradney | 206 | return false; |
14394 | jghali | 207 | } |
10593 | fschmid | 208 | QString fileDir = QFileInfo(fileName).absolutePath(); |
5653 | cbradney | 209 | /* 2004/10/02 - petr vanek - bug #1092 - missing <PAGE> crash Scribus. The check constraint moved into IsScribus() |
210 | FIXME: I've add test on containig tag PAGE but returning false freezes S. in scribus.cpp need some hack too... */ |
||
14391 | jghali | 211 | QString errorMsg; |
212 | int errorLine, errorColumn; |
||
213 | if (!docu.setContent(f, &errorMsg, &errorLine, &errorColumn)) |
||
214 | { |
||
215 | setDomParsingError(errorMsg, errorLine, errorColumn); |
||
5653 | cbradney | 216 | return false; |
14391 | jghali | 217 | } |
5653 | cbradney | 218 | m_Doc->PageColors.clear(); |
219 | m_Doc->Layers.clear(); |
||
220 | int layerToSetActive=0; |
||
221 | ScColor lf = ScColor(); |
||
222 | QDomElement elem=docu.documentElement(); |
||
223 | if (elem.tagName() != "SCRIBUSUTF8NEW") |
||
224 | return false; |
||
225 | if (elem.hasAttribute("Version")) |
||
226 | newVersion = true; |
||
227 | QDomNode DOC=elem.firstChild(); |
||
228 | if (m_mwProgressBar!=0) |
||
229 | { |
||
9953 | cbradney | 230 | m_mwProgressBar->setMaximum(DOC.childNodes().count()); |
231 | m_mwProgressBar->setValue(0); |
||
5653 | cbradney | 232 | } |
13519 | jghali | 233 | // Stop autosave timer,it will be restarted only if doc has autosave feature is enabled |
234 | if (m_Doc->autoSaveTimer->isActive()) |
||
235 | m_Doc->autoSaveTimer->stop(); |
||
5653 | cbradney | 236 | int ObCount = 0; |
237 | TableItems.clear(); |
||
238 | TableID.clear(); |
||
7450 | fschmid | 239 | TableItemsM.clear(); |
240 | TableIDM.clear(); |
||
241 | TableItemsF.clear(); |
||
242 | TableIDF.clear(); |
||
5653 | cbradney | 243 | PrefsManager* prefsManager=PrefsManager::instance(); |
244 | while(!DOC.isNull()) |
||
245 | { |
||
246 | QDomElement dc=DOC.toElement(); |
||
247 | /* |
||
248 | * Attribute von DOCUMENT auslesen |
||
249 | */ |
||
250 | //CB Add this in to set this in the file in memory. Its saved, why not load it. |
||
251 | //Will of course be replaced by per page settings although we still probably need a document default |
||
5789 | cbradney | 252 | m_Doc->m_pageSize = dc.attribute("PAGESIZE"); |
5653 | cbradney | 253 | m_Doc->PageOri = dc.attribute("ORIENTATION", "0").toInt(); |
254 | m_Doc->FirstPnum = dc.attribute("FIRSTNUM", "1").toInt(); |
||
255 | m_Doc->currentPageLayout=dc.attribute("BOOK", "0").toInt(); |
||
256 | int fp; |
||
257 | if (m_Doc->currentPageLayout == 0) |
||
258 | fp = 0; |
||
259 | else |
||
260 | { |
||
261 | if (dc.attribute("FIRSTLEFT", "0").toInt() == 1) |
||
262 | fp = 0; |
||
263 | else |
||
264 | fp = 1; |
||
265 | } |
||
266 | if (DOC.namedItem("PageSets").isNull()) |
||
267 | { |
||
268 | m_Doc->pageSets[m_Doc->currentPageLayout].FirstPage = fp; |
||
11349 | fschmid | 269 | // m_Doc->pageSets[m_Doc->currentPageLayout].GapHorizontal = dc.attribute("GapHorizontal", "0").toDouble(); |
270 | // m_Doc->pageSets[m_Doc->currentPageLayout].GapVertical = 0.0; |
||
271 | // m_Doc->pageSets[m_Doc->currentPageLayout].GapBelow = dc.attribute("GapVertical", "40").toDouble(); |
||
5653 | cbradney | 272 | } |
273 | m_Doc->setUsesAutomaticTextFrames(dc.attribute("AUTOTEXT").toInt()); |
||
274 | m_Doc->PageSp=dc.attribute("AUTOSPALTEN").toInt(); |
||
13473 | pierre | 275 | m_Doc->PageSpa=ScCLocale::toDoubleC( dc.attribute("ABSTSPALTEN") ); |
5653 | cbradney | 276 | m_Doc->setUnitIndex(dc.attribute("UNITS", "0").toInt()); |
13473 | pierre | 277 | m_Doc->toolSettings.defSize=qRound(ScCLocale::toDoubleC(dc.attribute("DSIZE")) * 10); |
5653 | cbradney | 278 | Defont=dc.attribute("DFONT"); |
8775 | cbradney | 279 | m_AvailableFonts->findFont(Defont, m_Doc); |
5653 | cbradney | 280 | m_Doc->toolSettings.defFont = Defont; |
281 | m_Doc->toolSettings.dCols=dc.attribute("DCOL", "1").toInt(); |
||
13475 | jghali | 282 | m_Doc->toolSettings.dGap=ScCLocale::toDoubleC(dc.attribute("DGAP"), 0.0); |
5653 | cbradney | 283 | m_Doc->documentInfo.setAuthor(dc.attribute("AUTHOR")); |
284 | m_Doc->documentInfo.setComments(dc.attribute("COMMENTS")); |
||
285 | m_Doc->documentInfo.setKeywords(dc.attribute("KEYWORDS","")); |
||
286 | m_Doc->documentInfo.setTitle(dc.attribute("TITLE")); |
||
287 | m_Doc->documentInfo.setPublisher(dc.attribute("PUBLISHER", "")); |
||
288 | m_Doc->documentInfo.setDate(dc.attribute("DOCDATE", "")); |
||
289 | m_Doc->documentInfo.setType(dc.attribute("DOCTYPE", "")); |
||
290 | m_Doc->documentInfo.setFormat(dc.attribute("DOCFORMAT", "")); |
||
291 | m_Doc->documentInfo.setIdent(dc.attribute("DOCIDENT", "")); |
||
292 | m_Doc->documentInfo.setSource(dc.attribute("DOCSOURCE", "")); |
||
293 | m_Doc->documentInfo.setLangInfo(dc.attribute("DOCLANGINFO", "")); |
||
294 | m_Doc->documentInfo.setRelation(dc.attribute("DOCRELATION", "")); |
||
295 | m_Doc->documentInfo.setCover(dc.attribute("DOCCOVER", "")); |
||
296 | m_Doc->documentInfo.setRights(dc.attribute("DOCRIGHTS", "")); |
||
297 | m_Doc->documentInfo.setContrib(dc.attribute("DOCCONTRIB", "")); |
||
298 | m_Doc->typographicSettings.valueSuperScript = dc.attribute("VHOCH").toInt(); |
||
299 | m_Doc->typographicSettings.scalingSuperScript = dc.attribute("VHOCHSC").toInt(); |
||
300 | m_Doc->typographicSettings.valueSubScript = dc.attribute("VTIEF").toInt(); |
||
301 | m_Doc->typographicSettings.scalingSubScript = dc.attribute("VTIEFSC").toInt(); |
||
302 | m_Doc->typographicSettings.valueSmallCaps = dc.attribute("VKAPIT").toInt(); |
||
13475 | jghali | 303 | m_Doc->typographicSettings.valueBaseGrid = ScCLocale::toDoubleC(dc.attribute("BASEGRID"), 12.0); |
304 | m_Doc->typographicSettings.offsetBaseGrid = ScCLocale::toDoubleC(dc.attribute("BASEO"), 0.0); |
||
5653 | cbradney | 305 | m_Doc->typographicSettings.autoLineSpacing = dc.attribute("AUTOL", "20").toInt(); |
306 | m_Doc->typographicSettings.valueUnderlinePos = dc.attribute("UnderlinePos", "-1").toInt(); |
||
307 | m_Doc->typographicSettings.valueUnderlineWidth = dc.attribute("UnderlineWidth", "-1").toInt(); |
||
308 | m_Doc->typographicSettings.valueStrikeThruPos = dc.attribute("StrikeThruPos", "-1").toInt(); |
||
309 | m_Doc->typographicSettings.valueStrikeThruWidth = dc.attribute("StrikeThruWidth", "-1").toInt(); |
||
13636 | jghali | 310 | m_Doc->GroupCounter = 1/*dc.attribute("GROUPC", "1").toInt()*/; |
5880 | jghali | 311 | //m_Doc->HasCMS = static_cast<bool>(dc.attribute("HCMS", "0").toInt()); |
5653 | cbradney | 312 | m_Doc->CMSSettings.SoftProofOn = static_cast<bool>(dc.attribute("DPSo", "0").toInt()); |
313 | m_Doc->CMSSettings.SoftProofFullOn = static_cast<bool>(dc.attribute("DPSFo", "0").toInt()); |
||
314 | m_Doc->CMSSettings.CMSinUse = static_cast<bool>(dc.attribute("DPuse", "0").toInt()); |
||
315 | m_Doc->CMSSettings.GamutCheck = static_cast<bool>(dc.attribute("DPgam", "0").toInt()); |
||
316 | m_Doc->CMSSettings.BlackPoint = static_cast<bool>(dc.attribute("DPbla", "1").toInt()); |
||
317 | m_Doc->CMSSettings.DefaultMonitorProfile = dc.attribute("DPMo",""); |
||
318 | m_Doc->CMSSettings.DefaultPrinterProfile = dc.attribute("DPPr",""); |
||
319 | m_Doc->CMSSettings.DefaultImageRGBProfile = dc.attribute("DPIn",""); |
||
320 | m_Doc->CMSSettings.DefaultImageCMYKProfile = dc.attribute("DPInCMYK",""); |
||
321 | m_Doc->CMSSettings.DefaultSolidColorRGBProfile = dc.attribute("DPIn2",""); |
||
322 | if (dc.hasAttribute("DPIn3")) |
||
323 | m_Doc->CMSSettings.DefaultSolidColorCMYKProfile = dc.attribute("DPIn3",""); |
||
324 | else |
||
325 | m_Doc->CMSSettings.DefaultSolidColorCMYKProfile = dc.attribute("DPPr",""); |
||
326 | //m_Doc->CMSSettings.DefaultIntentPrinter = dc.attribute("DIPr", "0").toInt(); |
||
327 | //m_Doc->CMSSettings.DefaultIntentMonitor = dc.attribute("DIMo", "1").toInt(); |
||
328 | m_Doc->CMSSettings.DefaultIntentColors = dc.attribute("DISc", "1").toInt(); |
||
329 | m_Doc->CMSSettings.DefaultIntentImages = dc.attribute("DIIm", "0").toInt(); |
||
330 | layerToSetActive=dc.attribute("ALAYER", "0").toInt(); |
||
331 | m_Doc->Language = dc.attribute("LANGUAGE", ""); |
||
332 | m_Doc->MinWordLen = dc.attribute("MINWORDLEN", "3").toInt(); |
||
333 | m_Doc->HyCount = dc.attribute("HYCOUNT", "2").toInt(); |
||
334 | if (dc.hasAttribute("PAGEWIDTH")) |
||
13473 | pierre | 335 | m_Doc->pageWidth=ScCLocale::toDoubleC(dc.attribute("PAGEWIDTH")); |
5653 | cbradney | 336 | else |
13473 | pierre | 337 | m_Doc->pageWidth=ScCLocale::toDoubleC(dc.attribute("PAGEWITH")); |
338 | m_Doc->pageHeight=ScCLocale::toDoubleC(dc.attribute("PAGEHEIGHT")); |
||
339 | m_Doc->pageMargins.Left=qMax(0.0, ScCLocale::toDoubleC(dc.attribute("BORDERLEFT"))); |
||
340 | m_Doc->pageMargins.Right=qMax(0.0, ScCLocale::toDoubleC(dc.attribute("BORDERRIGHT"))); |
||
341 | m_Doc->pageMargins.Top=qMax(0.0, ScCLocale::toDoubleC(dc.attribute("BORDERTOP"))); |
||
342 | m_Doc->pageMargins.Bottom=qMax(0.0, ScCLocale::toDoubleC(dc.attribute("BORDERBOTTOM"))); |
||
12334 | fschmid | 343 | m_Doc->marginPreset = dc.attribute("PRESET", "0").toInt(); |
13475 | jghali | 344 | m_Doc->bleeds.Top = ScCLocale::toDoubleC(dc.attribute("BleedTop"), 0.0); |
345 | m_Doc->bleeds.Left = ScCLocale::toDoubleC(dc.attribute("BleedLeft"), 0.0); |
||
346 | m_Doc->bleeds.Right = ScCLocale::toDoubleC(dc.attribute("BleedRight"), 0.0); |
||
347 | m_Doc->bleeds.Bottom = ScCLocale::toDoubleC(dc.attribute("BleedBottom"), 0.0); |
||
5653 | cbradney | 348 | m_Doc->Automatic = static_cast<bool>(dc.attribute("AUTOMATIC", "1").toInt()); |
349 | m_Doc->AutoCheck = static_cast<bool>(dc.attribute("AUTOCHECK", "0").toInt()); |
||
350 | m_Doc->GuideLock = static_cast<bool>(dc.attribute("GUIDELOCK", "0").toInt()); |
||
13475 | jghali | 351 | m_Doc->guidesSettings.minorGrid = ScCLocale::toDoubleC(dc.attribute("MINGRID"), prefsManager->appPrefs.guidesSettings.minorGrid); |
352 | m_Doc->guidesSettings.majorGrid = ScCLocale::toDoubleC(dc.attribute("MAJGRID"), prefsManager->appPrefs.guidesSettings.majorGrid); |
||
5653 | cbradney | 353 | m_Doc->guidesSettings.gridShown = static_cast<bool>(dc.attribute("SHOWGRID", "0").toInt()); |
354 | m_Doc->guidesSettings.guidesShown = static_cast<bool>(dc.attribute("SHOWGUIDES", "1").toInt()); |
||
355 | m_Doc->guidesSettings.colBordersShown = static_cast<bool>(dc.attribute("showcolborders", "0").toInt()); |
||
356 | m_Doc->guidesSettings.framesShown = static_cast<bool>(dc.attribute("SHOWFRAME", "1").toInt()); |
||
357 | m_Doc->guidesSettings.layerMarkersShown = static_cast<bool>(dc.attribute("SHOWLAYERM", "0").toInt()); |
||
358 | m_Doc->guidesSettings.marginsShown = static_cast<bool>(dc.attribute("SHOWMARGIN", "1").toInt()); |
||
359 | m_Doc->guidesSettings.baseShown = static_cast<bool>(dc.attribute("SHOWBASE", "0").toInt()); |
||
360 | m_Doc->guidesSettings.showPic = static_cast<bool>(dc.attribute("SHOWPICT", "1").toInt()); |
||
361 | m_Doc->guidesSettings.linkShown = static_cast<bool>(dc.attribute("SHOWLINK", "0").toInt()); |
||
362 | m_Doc->guidesSettings.showControls = static_cast<bool>(dc.attribute("SHOWControl", "0").toInt()); |
||
363 | m_Doc->guidesSettings.rulerMode = static_cast<bool>(dc.attribute("rulerMode", "1").toInt()); |
||
364 | m_Doc->guidesSettings.rulersShown = static_cast<bool>(dc.attribute("showrulers", "1").toInt()); |
||
7051 | fschmid | 365 | m_Doc->guidesSettings.showBleed = static_cast<bool>(dc.attribute("showBleed", "1").toInt()); |
13475 | jghali | 366 | m_Doc->rulerXoffset = ScCLocale::toDoubleC(dc.attribute("rulerXoffset"), 0.0); |
367 | m_Doc->rulerYoffset = ScCLocale::toDoubleC(dc.attribute("rulerYoffset"), 0.0); |
||
5653 | cbradney | 368 | m_Doc->SnapGuides = static_cast<bool>(dc.attribute("SnapToGuides", "0").toInt()); |
369 | m_Doc->useRaster = static_cast<bool>(dc.attribute("SnapToGrid", "0").toInt()); |
||
370 | m_Doc->toolSettings.polyC = dc.attribute("POLYC", "4").toInt(); |
||
13475 | jghali | 371 | m_Doc->toolSettings.polyF = ScCLocale::toDoubleC(dc.attribute("POLYF"), 0.5); |
372 | m_Doc->toolSettings.polyR = ScCLocale::toDoubleC(dc.attribute("POLYR"), 0.0); |
||
373 | m_Doc->toolSettings.polyCurvature = ScCLocale::toDoubleC(dc.attribute("POLYCUR"), 0.0); |
||
5653 | cbradney | 374 | m_Doc->toolSettings.polyFd = dc.attribute("POLYFD", "0").toInt(); |
375 | m_Doc->toolSettings.polyS = static_cast<bool>(dc.attribute("POLYS", "0").toInt()); |
||
376 | m_Doc->AutoSave = static_cast<bool>(dc.attribute("AutoSave", "0").toInt()); |
||
377 | m_Doc->AutoSaveTime = dc.attribute("AutoSaveTime", "600000").toInt(); |
||
13475 | jghali | 378 | m_Doc->scratch.Bottom = ScCLocale::toDoubleC(dc.attribute("ScratchBottom"), 20.0); |
5653 | cbradney | 379 | // FIXME A typo in early 1.3cvs (MAR 05) means we must support loading of |
380 | // FIXME 'ScatchLeft' for a while too. This can be removed in a few months. |
||
381 | if (dc.hasAttribute("ScatchLeft")) |
||
13475 | jghali | 382 | m_Doc->scratch.Left = ScCLocale::toDoubleC( dc.attribute("ScatchLeft"), 100.0); |
5653 | cbradney | 383 | else |
13475 | jghali | 384 | m_Doc->scratch.Left = ScCLocale::toDoubleC( dc.attribute("ScratchLeft"), 100.0); |
385 | m_Doc->scratch.Right = ScCLocale::toDoubleC( dc.attribute("ScratchRight"), 100.0); |
||
386 | m_Doc->scratch.Top = ScCLocale::toDoubleC( dc.attribute("ScratchTop"), 20.0); |
||
387 | m_Doc->GapHorizontal = ScCLocale::toDoubleC( dc.attribute("GapHorizontal"), -1.0); |
||
388 | m_Doc->GapVertical = ScCLocale::toDoubleC( dc.attribute("GapVertical"), -1.0); |
||
5653 | cbradney | 389 | m_Doc->toolSettings.dStartArrow = dc.attribute("StartArrow", "0").toInt(); |
390 | m_Doc->toolSettings.dEndArrow = dc.attribute("EndArrow", "0").toInt(); |
||
13475 | jghali | 391 | m_Doc->toolSettings.scaleX = ScCLocale::toDoubleC( dc.attribute("PICTSCX"), 1.0); |
392 | m_Doc->toolSettings.scaleY = ScCLocale::toDoubleC( dc.attribute("PICTSCY"), 1.0); |
||
5653 | cbradney | 393 | m_Doc->toolSettings.scaleType = static_cast<bool>(dc.attribute("PSCALE", "1").toInt()); |
394 | m_Doc->toolSettings.aspectRatio = static_cast<bool>(dc.attribute("PASPECT", "0").toInt()); |
||
395 | m_Doc->toolSettings.lowResType = dc.attribute("HalfRes", "1").toInt(); |
||
396 | m_Doc->toolSettings.useEmbeddedPath = static_cast<bool>(dc.attribute("EmbeddedPath", "0").toInt()); |
||
397 | if (dc.hasAttribute("PEN")) |
||
398 | m_Doc->toolSettings.dPen = dc.attribute("PEN"); |
||
399 | if (dc.hasAttribute("BRUSH")) |
||
400 | m_Doc->toolSettings.dBrush = dc.attribute("BRUSH"); |
||
401 | if (dc.hasAttribute("PENLINE")) |
||
402 | m_Doc->toolSettings.dPenLine = dc.attribute("PENLINE"); |
||
403 | if (dc.hasAttribute("PENTEXT")) |
||
404 | m_Doc->toolSettings.dPenText = dc.attribute("PENTEXT"); |
||
405 | if (dc.hasAttribute("StrokeText")) |
||
406 | m_Doc->toolSettings.dStrokeText = dc.attribute("StrokeText"); |
||
407 | m_Doc->toolSettings.dTextBackGround = dc.attribute("TextBackGround", CommonStrings::None); |
||
408 | m_Doc->toolSettings.dTextLineColor = dc.attribute("TextLineColor", CommonStrings::None); |
||
409 | m_Doc->toolSettings.dTextBackGroundShade = dc.attribute("TextBackGroundShade", "100").toInt(); |
||
410 | m_Doc->toolSettings.dTextLineShade = dc.attribute("TextLineShade", "100").toInt(); |
||
411 | m_Doc->toolSettings.dTextPenShade = dc.attribute("TextPenShade", "100").toInt(); |
||
412 | m_Doc->toolSettings.dTextStrokeShade = dc.attribute("TextStrokeShade", "100").toInt(); |
||
413 | m_Doc->toolSettings.dLineArt = static_cast<Qt::PenStyle>(dc.attribute("STIL").toInt()); |
||
414 | m_Doc->toolSettings.dLstyleLine = static_cast<Qt::PenStyle>(dc.attribute("STILLINE").toInt()); |
||
13475 | jghali | 415 | m_Doc->toolSettings.dWidth = ScCLocale::toDoubleC( dc.attribute("WIDTH"), 0.0); |
416 | m_Doc->toolSettings.dWidthLine = ScCLocale::toDoubleC( dc.attribute("WIDTHLINE"), 1.0); |
||
5653 | cbradney | 417 | m_Doc->toolSettings.dShade2 = dc.attribute("PENSHADE", "100").toInt(); |
418 | m_Doc->toolSettings.dShadeLine = dc.attribute("LINESHADE", "100").toInt(); |
||
419 | m_Doc->toolSettings.dShade = dc.attribute("BRUSHSHADE", "100").toInt(); |
||
14731 | fschmid | 420 | m_Doc->toolSettings.magMin = dc.attribute("MAGMIN", "1").toInt(); |
5653 | cbradney | 421 | m_Doc->toolSettings.magMax = dc.attribute("MAGMAX", "3200").toInt(); |
422 | m_Doc->toolSettings.magStep = dc.attribute("MAGSTEP", "200").toInt(); |
||
13475 | jghali | 423 | m_Doc->toolSettings.dispX = ScCLocale::toDoubleC( dc.attribute("dispX"), 10.0); |
424 | m_Doc->toolSettings.dispY = ScCLocale::toDoubleC( dc.attribute("dispY"), 10.0); |
||
425 | m_Doc->toolSettings.constrain = ScCLocale::toDoubleC( dc.attribute("constrain"), 15.0); |
||
5653 | cbradney | 426 | //CB Reset doc zoom step value to 200% instead of old values. |
14499 | jghali | 427 | if (m_Doc->toolSettings.magStep <= 100) |
428 | m_Doc->toolSettings.magStep = 200; |
||
5653 | cbradney | 429 | m_Doc->toolSettings.tabFillChar = dc.attribute("TabFill",""); |
13475 | jghali | 430 | m_Doc->toolSettings.dTabWidth= ScCLocale::toDoubleC(dc.attribute("TabWidth"), 36.0); |
5653 | cbradney | 431 | if (dc.hasAttribute("CPICT")) |
432 | m_Doc->toolSettings.dBrushPict = dc.attribute("CPICT"); |
||
433 | m_Doc->toolSettings.shadePict = dc.attribute("PICTSHADE", "100").toInt(); |
||
434 | if (dc.hasAttribute("PAGEC")) |
||
435 | m_Doc->papColor = QColor(dc.attribute("PAGEC")); |
||
436 | if (dc.hasAttribute("MARGC")) |
||
437 | m_Doc->guidesSettings.margColor = QColor(dc.attribute("MARGC")); |
||
438 | if (dc.hasAttribute("MINORC")) |
||
439 | m_Doc->guidesSettings.minorColor = QColor(dc.attribute("MINORC")); |
||
440 | if (dc.hasAttribute("MAJORC")) |
||
441 | m_Doc->guidesSettings.majorColor = QColor(dc.attribute("MAJORC")); |
||
442 | if (dc.hasAttribute("GuideC")) |
||
443 | m_Doc->guidesSettings.guideColor = QColor(dc.attribute("GuideC")); |
||
444 | if (dc.hasAttribute("BaseC")) |
||
445 | m_Doc->guidesSettings.baseColor = QColor(dc.attribute("BaseC")); |
||
446 | m_Doc->marginColored = static_cast<bool>(dc.attribute("RANDF", "0").toInt()); |
||
447 | m_Doc->guidesSettings.before = static_cast<bool>(dc.attribute("BACKG", "1").toInt()); |
||
13475 | jghali | 448 | m_Doc->guidesSettings.guideRad = ScCLocale::toDoubleC( dc.attribute("GuideRad"), 10.0); |
5653 | cbradney | 449 | m_Doc->guidesSettings.grabRad = dc.attribute("GRAB", "4").toInt(); |
450 | if (dc.hasAttribute("currentProfile")) |
||
451 | { |
||
452 | m_Doc->checkerProfiles.clear(); |
||
453 | m_Doc->curCheckProfile = dc.attribute("currentProfile"); |
||
454 | } |
||
455 | m_Doc->LastAuto = 0; |
||
456 | QDomNode PAGE=DOC.firstChild(); |
||
457 | counter = 0; |
||
458 | while(!PAGE.isNull()) |
||
459 | { |
||
460 | ObCount++; |
||
461 | if (m_mwProgressBar!=0) |
||
9953 | cbradney | 462 | m_mwProgressBar->setValue(ObCount); |
5653 | cbradney | 463 | QDomElement pg=PAGE.toElement(); |
464 | if (pg.tagName()=="PageSets") |
||
465 | { |
||
466 | QDomNode PGS = PAGE.firstChild(); |
||
467 | m_Doc->pageSets.clear(); |
||
468 | while(!PGS.isNull()) |
||
469 | { |
||
470 | QDomElement PgsAttr = PGS.toElement(); |
||
471 | if(PgsAttr.tagName() == "Set") |
||
472 | { |
||
473 | struct PageSet pageS; |
||
474 | pageS.Name = CommonStrings::untranslatePageSetString(PgsAttr.attribute("Name")); |
||
475 | pageS.FirstPage = PgsAttr.attribute("FirstPage", "0").toInt(); |
||
476 | pageS.Rows = PgsAttr.attribute("Rows", "1").toInt(); |
||
477 | pageS.Columns = PgsAttr.attribute("Columns", "1").toInt(); |
||
13473 | pierre | 478 | // pageS.GapHorizontal = ScCLocale::toDoubleC( PgsAttr.attribute("GapHorizontal", "0")); |
479 | // pageS.GapVertical = ScCLocale::toDoubleC( PgsAttr.attribute("GapVertical", "0")); |
||
480 | // pageS.GapBelow = ScCLocale::toDoubleC( PgsAttr.attribute("GapBelow", "0")); |
||
5653 | cbradney | 481 | pageS.pageNames.clear(); |
482 | QDomNode PGSN = PGS.firstChild(); |
||
483 | while(!PGSN.isNull()) |
||
484 | { |
||
485 | QDomElement PgsAttrN = PGSN.toElement(); |
||
486 | if(PgsAttrN.tagName() == "PageNames") |
||
487 | pageS.pageNames.append(CommonStrings::untranslatePageSetLocString(PgsAttrN.attribute("Name"))); |
||
488 | PGSN = PGSN.nextSibling(); |
||
489 | } |
||
490 | m_Doc->pageSets.append(pageS); |
||
11358 | fschmid | 491 | if ((m_Doc->pageSets.count()-1 == m_Doc->currentPageLayout) && ((m_Doc->GapHorizontal < 0) && (m_Doc->GapVertical < 0))) |
11349 | fschmid | 492 | { |
13475 | jghali | 493 | m_Doc->GapHorizontal = ScCLocale::toDoubleC( PgsAttr.attribute("GapHorizontal"), 0.0); |
494 | m_Doc->GapVertical = ScCLocale::toDoubleC( PgsAttr.attribute("GapBelow"), 0.0); |
||
11349 | fschmid | 495 | } |
5653 | cbradney | 496 | } |
497 | PGS = PGS.nextSibling(); |
||
498 | } |
||
499 | } |
||
500 | if (pg.tagName()=="CheckProfile") |
||
501 | { |
||
502 | struct checkerPrefs checkerSettings; |
||
503 | checkerSettings.ignoreErrors = static_cast<bool>(pg.attribute("ignoreErrors", "0").toInt()); |
||
504 | checkerSettings.autoCheck = static_cast<bool>(pg.attribute("autoCheck", "1").toInt()); |
||
505 | checkerSettings.checkGlyphs = static_cast<bool>(pg.attribute("checkGlyphs", "1").toInt()); |
||
506 | checkerSettings.checkOrphans = static_cast<bool>(pg.attribute("checkOrphans", "1").toInt()); |
||
507 | checkerSettings.checkOverflow = static_cast<bool>(pg.attribute("checkOverflow", "1").toInt()); |
||
508 | checkerSettings.checkPictures = static_cast<bool>(pg.attribute("checkPictures", "1").toInt()); |
||
509 | checkerSettings.checkResolution = static_cast<bool>(pg.attribute("checkResolution", "1").toInt()); |
||
510 | checkerSettings.checkTransparency = static_cast<bool>(pg.attribute("checkTransparency", "1").toInt()); |
||
13475 | jghali | 511 | checkerSettings.minResolution = ScCLocale::toDoubleC( pg.attribute("minResolution"), 72.0); |
512 | checkerSettings.maxResolution = ScCLocale::toDoubleC( pg.attribute("maxResolution"), 4800.0); |
||
5653 | cbradney | 513 | checkerSettings.checkAnnotations = static_cast<bool>(pg.attribute("checkAnnotations", "0").toInt()); |
514 | checkerSettings.checkRasterPDF = static_cast<bool>(pg.attribute("checkRasterPDF", "1").toInt()); |
||
515 | checkerSettings.checkForGIF = static_cast<bool>(pg.attribute("checkForGIF", "1").toInt()); |
||
6619 | fschmid | 516 | checkerSettings.ignoreOffLayers = static_cast<bool>(pg.attribute("ignoreOffLayers", "0").toInt()); |
14543 | cbradney | 517 | checkerSettings.checkOffConflictLayers = static_cast<bool>(pg.attribute("checkOffConflictLayers", "0").toInt()); |
5653 | cbradney | 518 | m_Doc->checkerProfiles[pg.attribute("Name")] = checkerSettings; |
519 | } |
||
520 | // 10/25/2004 pv - None is "reserved" color. cannot be defined in any file... |
||
521 | if(pg.tagName()=="COLOR" && pg.attribute("NAME")!=CommonStrings::None) |
||
522 | { |
||
523 | if (pg.hasAttribute("CMYK")) |
||
524 | lf.setNamedColor(pg.attribute("CMYK")); |
||
525 | else |
||
526 | lf.fromQColor(QColor(pg.attribute("RGB"))); |
||
527 | if (pg.hasAttribute("Spot")) |
||
528 | lf.setSpotColor(static_cast<bool>(pg.attribute("Spot").toInt())); |
||
529 | else |
||
530 | lf.setSpotColor(false); |
||
531 | if (pg.hasAttribute("Register")) |
||
532 | lf.setRegistrationColor(static_cast<bool>(pg.attribute("Register").toInt())); |
||
533 | else |
||
534 | lf.setRegistrationColor(false); |
||
11466 | jghali | 535 | QString name = pg.attribute("NAME"); |
536 | m_Doc->PageColors.insert((name.isEmpty()) ? lf.name() : name, lf); |
||
5653 | cbradney | 537 | } |
538 | if(pg.tagName()=="STYLE") |
||
539 | { |
||
540 | readParagraphStyle(vg, pg, *m_AvailableFonts, m_Doc); |
||
7442 | avox | 541 | StyleSet<ParagraphStyle>tmp; |
542 | tmp.create(vg); |
||
543 | m_Doc->redefineStyles(tmp, false); |
||
5653 | cbradney | 544 | } |
7000 | avox | 545 | if(pg.tagName()=="CHARSTYLE") |
546 | { |
||
547 | readParagraphStyle(vg, pg, *m_AvailableFonts, m_Doc); |
||
7442 | avox | 548 | StyleSet<CharStyle> temp; |
549 | temp.create(vg.charStyle()); |
||
550 | m_Doc->redefineCharStyles(temp, false); |
||
7000 | avox | 551 | } |
5653 | cbradney | 552 | if(pg.tagName()=="JAVA") |
553 | m_Doc->JavaScripts[pg.attribute("NAME")] = pg.attribute("SCRIPT"); |
||
554 | if(pg.tagName()=="LAYERS") |
||
555 | { |
||
10147 | jghali | 556 | int lnr = pg.attribute("NUMMER").toInt(); |
557 | int level = pg.attribute("LEVEL").toInt(); |
||
558 | ScLayer la( pg.attribute("NAME"), level, lnr); |
||
559 | la.isViewable = pg.attribute("SICHTBAR").toInt(); |
||
560 | la.isPrintable = pg.attribute("DRUCKEN").toInt(); |
||
561 | la.isEditable = pg.attribute("EDIT", "1").toInt(); |
||
562 | la.flowControl = pg.attribute("FLOW", "1").toInt(); |
||
13475 | jghali | 563 | la.transparency = ScCLocale::toDoubleC( pg.attribute("TRANS"), 1.0); |
10147 | jghali | 564 | la.blendMode = pg.attribute("BLEND", "0").toInt(); |
565 | la.outlineMode = pg.attribute("OUTL", "0").toInt(); |
||
5653 | cbradney | 566 | if (pg.hasAttribute("LAYERC")) |
567 | la.markerColor = QColor(pg.attribute("LAYERC","#000000")); |
||
568 | m_Doc->Layers.append(la); |
||
569 | } |
||
570 | /* if(pg.tagName()=="Bookmark") |
||
571 | { |
||
572 | bok.Title = pg.attribute("Title"); |
||
573 | bok.Text = pg.attribute("Text"); |
||
574 | bok.Aktion = pg.attribute("Aktion"); |
||
575 | bok.ItemNr = pg.attribute("ItemNr").toInt(); |
||
576 | bok.Seite = pg.attribute("Seite").toInt(); |
||
577 | bok.Element = pg.attribute("Element").toInt(); |
||
578 | bok.First = pg.attribute("First").toInt(); |
||
579 | bok.Last = pg.attribute("Last").toInt(); |
||
580 | bok.Prev = pg.attribute("Prev").toInt(); |
||
581 | bok.Next = pg.attribute("Next").toInt(); |
||
582 | bok.Parent = pg.attribute("Parent").toInt(); |
||
583 | m_Doc->BookMarks.append(bok); |
||
584 | } */ |
||
585 | if(pg.tagName()=="MultiLine") |
||
586 | { |
||
587 | multiLine ml; |
||
588 | QDomNode MuLn = PAGE.firstChild(); |
||
589 | while(!MuLn.isNull()) |
||
590 | { |
||
591 | QDomElement MuL = MuLn.toElement(); |
||
8557 | subik | 592 | struct SingleLine sl; |
5653 | cbradney | 593 | sl.Color = MuL.attribute("Color"); |
594 | sl.Dash = MuL.attribute("Dash").toInt(); |
||
595 | sl.LineEnd = MuL.attribute("LineEnd").toInt(); |
||
596 | sl.LineJoin = MuL.attribute("LineJoin").toInt(); |
||
597 | sl.Shade = MuL.attribute("Shade").toInt(); |
||
13473 | pierre | 598 | sl.Width = ScCLocale::toDoubleC( MuL.attribute("Width")); |
7752 | tsoots | 599 | ml.shortcut = MuL.attribute("Shortcut"); |
5653 | cbradney | 600 | ml.push_back(sl); |
601 | MuLn = MuLn.nextSibling(); |
||
602 | } |
||
603 | m_Doc->MLineStyles.insert(pg.attribute("Name"), ml); |
||
604 | } |
||
605 | if(pg.tagName()=="Arrows") |
||
606 | { |
||
607 | struct ArrowDesc arrow; |
||
608 | arrow.name = pg.attribute("Name"); |
||
609 | arrow.userArrow = true; |
||
610 | double xa, ya; |
||
611 | QString tmp = pg.attribute("Points"); |
||
13497 | jghali | 612 | ScTextStream fp(&tmp, QIODevice::ReadOnly); |
5653 | cbradney | 613 | for (uint cx = 0; cx < pg.attribute("NumPoints").toUInt(); ++cx) |
614 | { |
||
615 | fp >> xa; |
||
616 | fp >> ya; |
||
617 | arrow.points.addPoint(xa, ya); |
||
618 | } |
||
619 | m_Doc->arrowStyles.append(arrow); |
||
620 | } |
||
7104 | fschmid | 621 | if(pg.tagName()=="Printer") |
622 | { |
||
623 | m_Doc->Print_Options.firstUse = static_cast<bool>(pg.attribute("firstUse").toInt()); |
||
624 | m_Doc->Print_Options.toFile = static_cast<bool>(pg.attribute("toFile").toInt()); |
||
625 | m_Doc->Print_Options.useAltPrintCommand = static_cast<bool>(pg.attribute("useAltPrintCommand").toInt()); |
||
626 | m_Doc->Print_Options.outputSeparations = static_cast<bool>(pg.attribute("outputSeparations").toInt()); |
||
627 | m_Doc->Print_Options.useSpotColors = static_cast<bool>(pg.attribute("useSpotColors").toInt()); |
||
628 | m_Doc->Print_Options.useColor = static_cast<bool>(pg.attribute("useColor").toInt()); |
||
629 | m_Doc->Print_Options.mirrorH = static_cast<bool>(pg.attribute("mirrorH").toInt()); |
||
630 | m_Doc->Print_Options.mirrorV = static_cast<bool>(pg.attribute("mirrorV").toInt()); |
||
631 | m_Doc->Print_Options.useICC = static_cast<bool>(pg.attribute("useICC").toInt()); |
||
632 | m_Doc->Print_Options.doGCR = static_cast<bool>(pg.attribute("doGCR").toInt()); |
||
633 | m_Doc->Print_Options.doClip = static_cast<bool>(pg.attribute("doClip").toInt()); |
||
634 | m_Doc->Print_Options.setDevParam = static_cast<bool>(pg.attribute("setDevParam").toInt()); |
||
12247 | jghali | 635 | m_Doc->Print_Options.useDocBleeds = static_cast<bool>(pg.attribute("useDocBleeds").toInt()); |
7104 | fschmid | 636 | m_Doc->Print_Options.cropMarks = static_cast<bool>(pg.attribute("cropMarks").toInt()); |
637 | m_Doc->Print_Options.bleedMarks = static_cast<bool>(pg.attribute("bleedMarks").toInt()); |
||
638 | m_Doc->Print_Options.registrationMarks = static_cast<bool>(pg.attribute("registrationMarks").toInt()); |
||
639 | m_Doc->Print_Options.colorMarks = static_cast<bool>(pg.attribute("colorMarks").toInt()); |
||
12589 | fschmid | 640 | m_Doc->Print_Options.includePDFMarks = static_cast<bool>(pg.attribute("includePDFMarks", "1").toInt()); |
10947 | jghali | 641 | if (pg.hasAttribute("PrintEngine")) |
642 | m_Doc->Print_Options.prnEngine = (PrintEngine) pg.attribute("PrintEngine", "3").toInt(); |
||
643 | else |
||
644 | m_Doc->Print_Options.prnEngine = (PrintEngine) pg.attribute("PSLevel", "3").toInt(); |
||
13473 | pierre | 645 | m_Doc->Print_Options.markOffset = ScCLocale::toDoubleC( pg.attribute("markOffset")); |
646 | m_Doc->Print_Options.bleeds.Top = ScCLocale::toDoubleC( pg.attribute("BleedTop")); |
||
647 | m_Doc->Print_Options.bleeds.Left = ScCLocale::toDoubleC( pg.attribute("BleedLeft")); |
||
648 | m_Doc->Print_Options.bleeds.Right = ScCLocale::toDoubleC( pg.attribute("BleedRight")); |
||
649 | m_Doc->Print_Options.bleeds.Bottom = ScCLocale::toDoubleC( pg.attribute("BleedBottom")); |
||
7104 | fschmid | 650 | m_Doc->Print_Options.printer = pg.attribute("printer"); |
651 | m_Doc->Print_Options.filename = pg.attribute("filename"); |
||
652 | m_Doc->Print_Options.separationName = pg.attribute("separationName"); |
||
653 | m_Doc->Print_Options.printerCommand = pg.attribute("printerCommand"); |
||
654 | m_Doc->Print_Options.copies = 1; |
||
655 | QDomNode PFO = PAGE.firstChild(); |
||
656 | while(!PFO.isNull()) |
||
657 | { |
||
658 | QDomElement pdfF = PFO.toElement(); |
||
659 | if(pdfF.tagName() == "Separation") |
||
660 | m_Doc->Print_Options.allSeparations.append(pdfF.attribute("Name")); |
||
661 | PFO = PFO.nextSibling(); |
||
662 | } |
||
663 | } |
||
5653 | cbradney | 664 | if(pg.tagName()=="PDF") |
665 | { |
||
666 | m_Doc->PDF_Options.Articles = static_cast<bool>(pg.attribute("Articles").toInt()); |
||
667 | m_Doc->PDF_Options.Thumbnails = static_cast<bool>(pg.attribute("Thumbnails").toInt()); |
||
668 | m_Doc->PDF_Options.Compress = static_cast<bool>(pg.attribute("Compress").toInt()); |
||
11446 | jghali | 669 | m_Doc->PDF_Options.CompressMethod = (PDFOptions::PDFCompression) pg.attribute("CMethod", "0").toInt(); |
5653 | cbradney | 670 | m_Doc->PDF_Options.Quality = pg.attribute("Quality", "0").toInt(); |
671 | m_Doc->PDF_Options.RecalcPic = static_cast<bool>(pg.attribute("RecalcPic").toInt()); |
||
672 | m_Doc->PDF_Options.Bookmarks = static_cast<bool>(pg.attribute("Bookmarks").toInt()); |
||
6493 | fschmid | 673 | if (pg.hasAttribute("firstUse")) |
674 | m_Doc->PDF_Options.firstUse = static_cast<bool>(pg.attribute("firstUse").toInt()); |
||
675 | else |
||
676 | m_Doc->PDF_Options.firstUse = true; |
||
5653 | cbradney | 677 | if (pg.hasAttribute("MirrorH")) |
678 | m_Doc->PDF_Options.MirrorH = static_cast<bool>(pg.attribute("MirrorH").toInt()); |
||
679 | else |
||
680 | m_Doc->PDF_Options.MirrorH = false; |
||
681 | if (pg.hasAttribute("MirrorV")) |
||
682 | m_Doc->PDF_Options.MirrorV = static_cast<bool>(pg.attribute("MirrorV").toInt()); |
||
683 | else |
||
684 | m_Doc->PDF_Options.MirrorV = false; |
||
685 | if (pg.hasAttribute("RotateDeg")) |
||
686 | m_Doc->PDF_Options.RotateDeg = pg.attribute("RotateDeg", "0").toInt(); |
||
687 | else |
||
688 | m_Doc->PDF_Options.RotateDeg = 0; |
||
689 | if (pg.hasAttribute("Clip")) |
||
690 | m_Doc->PDF_Options.doClip = static_cast<bool>(pg.attribute("Clip").toInt()); |
||
691 | else |
||
692 | m_Doc->PDF_Options.doClip = false; |
||
693 | m_Doc->PDF_Options.PresentMode = static_cast<bool>(pg.attribute("PresentMode").toInt()); |
||
694 | m_Doc->PDF_Options.PicRes = pg.attribute("PicRes").toInt(); |
||
695 | // Fixme: check input pdf version |
||
696 | m_Doc->PDF_Options.Version = (PDFOptions::PDFVersion)pg.attribute("Version").toInt(); |
||
697 | m_Doc->PDF_Options.Resolution = pg.attribute("Resolution").toInt(); |
||
698 | m_Doc->PDF_Options.Binding = pg.attribute("Binding").toInt(); |
||
11948 | jghali | 699 | m_Doc->PDF_Options.fileName = ""; |
5653 | cbradney | 700 | m_Doc->PDF_Options.isGrayscale = static_cast<bool>(pg.attribute("Grayscale", "0").toInt()); |
701 | m_Doc->PDF_Options.UseRGB = static_cast<bool>(pg.attribute("RGBMode", "0").toInt()); |
||
702 | m_Doc->PDF_Options.UseProfiles = static_cast<bool>(pg.attribute("UseProfiles", "0").toInt()); |
||
703 | m_Doc->PDF_Options.UseProfiles2 = static_cast<bool>(pg.attribute("UseProfiles2", "0").toInt()); |
||
704 | m_Doc->PDF_Options.Intent = pg.attribute("Intent", "1").toInt(); |
||
705 | m_Doc->PDF_Options.Intent2 = pg.attribute("Intent2", "1").toInt(); |
||
706 | m_Doc->PDF_Options.SolidProf = pg.attribute("SolidP", ""); |
||
707 | m_Doc->PDF_Options.ImageProf = pg.attribute("ImageP", ""); |
||
708 | m_Doc->PDF_Options.PrintProf = pg.attribute("PrintP", ""); |
||
709 | m_Doc->PDF_Options.Info = pg.attribute("InfoString", ""); |
||
13475 | jghali | 710 | m_Doc->PDF_Options.bleeds.Top = ScCLocale::toDoubleC( pg.attribute("BTop"), 0.0); |
711 | m_Doc->PDF_Options.bleeds.Left = ScCLocale::toDoubleC( pg.attribute("BLeft"), 0.0); |
||
712 | m_Doc->PDF_Options.bleeds.Right = ScCLocale::toDoubleC( pg.attribute("BRight"), 0.0); |
||
713 | m_Doc->PDF_Options.bleeds.Bottom = ScCLocale::toDoubleC( pg.attribute("BBottom"), 0.0); |
||
10285 | jghali | 714 | m_Doc->PDF_Options.useDocBleeds = static_cast<bool>(pg.attribute("useDocBleeds", "1").toInt()); |
6921 | fschmid | 715 | m_Doc->PDF_Options.cropMarks = static_cast<bool>(pg.attribute("cropMarks", "0").toInt()); |
716 | m_Doc->PDF_Options.bleedMarks = static_cast<bool>(pg.attribute("bleedMarks", "0").toInt()); |
||
717 | m_Doc->PDF_Options.registrationMarks = static_cast<bool>(pg.attribute("registrationMarks", "0").toInt()); |
||
718 | m_Doc->PDF_Options.colorMarks = static_cast<bool>(pg.attribute("colorMarks", "0").toInt()); |
||
719 | m_Doc->PDF_Options.docInfoMarks = static_cast<bool>(pg.attribute("docInfoMarks", "0").toInt()); |
||
13475 | jghali | 720 | m_Doc->PDF_Options.markOffset = ScCLocale::toDoubleC( pg.attribute("markOffset"), 0.0); |
5653 | cbradney | 721 | m_Doc->PDF_Options.EmbeddedI = static_cast<bool>(pg.attribute("ImagePr", "0").toInt()); |
722 | m_Doc->PDF_Options.PassOwner = pg.attribute("PassOwner", ""); |
||
723 | m_Doc->PDF_Options.PassUser = pg.attribute("PassUser", ""); |
||
724 | m_Doc->PDF_Options.Permissions = pg.attribute("Permissions", "-4").toInt(); |
||
725 | m_Doc->PDF_Options.Encrypt = static_cast<bool>(pg.attribute("Encrypt", "0").toInt()); |
||
726 | m_Doc->PDF_Options.useLayers = static_cast<bool>(pg.attribute("UseLayers", "0").toInt()); |
||
727 | m_Doc->PDF_Options.UseLPI = static_cast<bool>(pg.attribute("UseLpi", "0").toInt()); |
||
728 | m_Doc->PDF_Options.UseSpotColors = static_cast<bool>(pg.attribute("UseSpotColors", "1").toInt()); |
||
729 | m_Doc->PDF_Options.doMultiFile = static_cast<bool>(pg.attribute("doMultiFile", "0").toInt()); |
||
730 | m_Doc->PDF_Options.displayBookmarks = static_cast<bool>(pg.attribute("displayBookmarks", "0").toInt()); |
||
731 | m_Doc->PDF_Options.displayFullscreen = static_cast<bool>(pg.attribute("displayFullscreen", "0").toInt()); |
||
732 | m_Doc->PDF_Options.displayLayers = static_cast<bool>(pg.attribute("displayLayers", "0").toInt()); |
||
733 | m_Doc->PDF_Options.displayThumbs = static_cast<bool>(pg.attribute("displayThumbs", "0").toInt()); |
||
734 | m_Doc->PDF_Options.hideMenuBar = static_cast<bool>(pg.attribute("hideMenuBar", "0").toInt()); |
||
735 | m_Doc->PDF_Options.hideToolBar = static_cast<bool>(pg.attribute("hideToolBar", "0").toInt()); |
||
736 | m_Doc->PDF_Options.fitWindow = static_cast<bool>(pg.attribute("fitWindow", "0").toInt()); |
||
737 | m_Doc->PDF_Options.PageLayout = pg.attribute("PageLayout", "0").toInt(); |
||
738 | m_Doc->PDF_Options.openAction = pg.attribute("openAction", ""); |
||
739 | QDomNode PFO = PAGE.firstChild(); |
||
740 | while(!PFO.isNull()) |
||
741 | { |
||
742 | QDomElement pdfF = PFO.toElement(); |
||
743 | if(pdfF.tagName() == "LPI") |
||
744 | { |
||
745 | struct LPIData lpo; |
||
746 | lpo.Angle = pdfF.attribute("Angle").toInt(); |
||
747 | lpo.Frequency = pdfF.attribute("Frequency").toInt(); |
||
748 | lpo.SpotFunc = pdfF.attribute("SpotFunction").toInt(); |
||
749 | m_Doc->PDF_Options.LPISettings[pdfF.attribute("Color")] = lpo; |
||
750 | } |
||
751 | if(pdfF.tagName() == "Fonts") |
||
752 | { |
||
753 | if (!m_Doc->PDF_Options.EmbedList.contains(pdfF.attribute("Name"))) |
||
754 | m_Doc->PDF_Options.EmbedList.append(pdfF.attribute("Name")); |
||
755 | } |
||
756 | if(pdfF.tagName() == "Subset") |
||
757 | { |
||
758 | if (!m_Doc->PDF_Options.SubsetList.contains(pdfF.attribute("Name"))) |
||
759 | m_Doc->PDF_Options.SubsetList.append(pdfF.attribute("Name")); |
||
760 | } |
||
761 | if(pdfF.tagName() == "Effekte") |
||
762 | { |
||
763 | struct PDFPresentationData ef; |
||
764 | ef.pageEffectDuration = pdfF.attribute("pageEffectDuration").toInt(); |
||
765 | ef.pageViewDuration = pdfF.attribute("pageViewDuration").toInt(); |
||
766 | ef.effectType = pdfF.attribute("effectType").toInt(); |
||
767 | ef.Dm = pdfF.attribute("Dm").toInt(); |
||
768 | ef.M = pdfF.attribute("M").toInt(); |
||
769 | ef.Di = pdfF.attribute("Di").toInt(); |
||
770 | m_Doc->PDF_Options.PresentVals.append(ef); |
||
771 | } |
||
772 | PFO = PFO.nextSibling(); |
||
773 | } |
||
774 | } |
||
775 | if(pg.tagName()=="DocItemAttributes") |
||
776 | { |
||
777 | QDomNode DIA = PAGE.firstChild(); |
||
778 | m_Doc->docItemAttributes.clear(); |
||
779 | while(!DIA.isNull()) |
||
780 | { |
||
781 | QDomElement itemAttr = DIA.toElement(); |
||
782 | if(itemAttr.tagName() == "ItemAttribute") |
||
783 | { |
||
784 | ObjectAttribute objattr; |
||
785 | objattr.name=itemAttr.attribute("Name"); |
||
786 | objattr.type=itemAttr.attribute("Type"); |
||
787 | objattr.value=itemAttr.attribute("Value"); |
||
788 | objattr.parameter=itemAttr.attribute("Parameter"); |
||
789 | objattr.relationship=itemAttr.attribute("Relationship"); |
||
790 | objattr.relationshipto=itemAttr.attribute("RelationshipTo"); |
||
791 | objattr.autoaddto=itemAttr.attribute("AutoAddTo"); |
||
792 | m_Doc->docItemAttributes.append(objattr); |
||
793 | } |
||
794 | DIA = DIA.nextSibling(); |
||
795 | } |
||
796 | } |
||
797 | if(pg.tagName()=="TablesOfContents") |
||
798 | { |
||
799 | QDomNode TOC = PAGE.firstChild(); |
||
800 | m_Doc->docToCSetups.clear(); |
||
801 | while(!TOC.isNull()) |
||
802 | { |
||
803 | QDomElement tocElem = TOC.toElement(); |
||
804 | if(tocElem.tagName() == "TableOfContents") |
||
805 | { |
||
806 | ToCSetup tocsetup; |
||
807 | tocsetup.name=tocElem.attribute("Name"); |
||
808 | tocsetup.itemAttrName=tocElem.attribute("ItemAttributeName"); |
||
809 | tocsetup.frameName=tocElem.attribute("FrameName"); |
||
8620 | subik | 810 | tocsetup.listNonPrintingFrames= QVariant(tocElem.attribute("ListNonPrinting")).toBool(); |
5653 | cbradney | 811 | tocsetup.textStyle=tocElem.attribute("Style"); |
812 | QString numberPlacement=tocElem.attribute("NumberPlacement"); |
||
813 | if (numberPlacement=="Beginning") |
||
814 | tocsetup.pageLocation=Beginning; |
||
815 | if (numberPlacement=="End") |
||
816 | tocsetup.pageLocation=End; |
||
817 | if (numberPlacement=="NotShown") |
||
818 | tocsetup.pageLocation=NotShown; |
||
819 | m_Doc->docToCSetups.append(tocsetup); |
||
820 | } |
||
821 | TOC = TOC.nextSibling(); |
||
822 | } |
||
823 | } |
||
824 | if(pg.tagName()=="Sections") |
||
825 | { |
||
826 | QDomNode Section = PAGE.firstChild(); |
||
827 | while(!Section.isNull()) |
||
828 | { |
||
829 | QDomElement sectionElem = Section.toElement(); |
||
830 | if(sectionElem.tagName() == "Section") |
||
831 | { |
||
832 | struct DocumentSection newSection; |
||
833 | newSection.number=sectionElem.attribute("Number").toInt(); |
||
834 | newSection.name=sectionElem.attribute("Name"); |
||
835 | newSection.fromindex=sectionElem.attribute("From").toInt(); |
||
836 | newSection.toindex=sectionElem.attribute("To").toInt(); |
||
837 | if (sectionElem.attribute("Type")=="Type_1_2_3") |
||
838 | newSection.type=Type_1_2_3; |
||
839 | if (sectionElem.attribute("Type")=="Type_i_ii_iii") |
||
840 | newSection.type=Type_i_ii_iii; |
||
841 | if (sectionElem.attribute("Type")=="Type_I_II_III") |
||
842 | newSection.type=Type_I_II_III; |
||
843 | if (sectionElem.attribute("Type")=="Type_a_b_c") |
||
844 | newSection.type=Type_a_b_c; |
||
845 | if (sectionElem.attribute("Type")=="Type_A_B_C") |
||
846 | newSection.type=Type_A_B_C; |
||
8980 | cbradney | 847 | if (sectionElem.attribute("Type")=="Type_None") |
848 | newSection.type=Type_None; |
||
5653 | cbradney | 849 | newSection.sectionstartindex=sectionElem.attribute("Start").toInt(); |
850 | newSection.reversed=static_cast<bool>(sectionElem.attribute("Reversed").toInt()); |
||
851 | newSection.active=static_cast<bool>(sectionElem.attribute("Active").toInt()); |
||
852 | m_Doc->sections.insert(newSection.number, newSection); |
||
853 | } |
||
854 | Section = Section.nextSibling(); |
||
855 | } |
||
856 | } |
||
10170 | fschmid | 857 | if (pg.tagName()=="HYPHEN") |
858 | { |
||
859 | QDomNode hyelm = pg.firstChild(); |
||
860 | while(!hyelm.isNull()) |
||
861 | { |
||
862 | QDomElement hyElem = hyelm.toElement(); |
||
863 | if (hyElem.tagName()=="EXCEPTION") |
||
864 | { |
||
865 | QString word = hyElem.attribute("WORD"); |
||
866 | QString hyph = hyElem.attribute("HYPHENATED"); |
||
867 | m_Doc->docHyphenator->specialWords.insert(word, hyph); |
||
868 | } |
||
869 | else if (hyElem.tagName()=="IGNORE") |
||
870 | { |
||
871 | QString word = hyElem.attribute("WORD"); |
||
872 | m_Doc->docHyphenator->ignoredWords.insert(word); |
||
873 | } |
||
874 | hyelm = hyelm.nextSibling(); |
||
875 | } |
||
876 | } |
||
5653 | cbradney | 877 | if ((pg.tagName()=="PAGE") || (pg.tagName()=="MASTERPAGE")) |
878 | { |
||
879 | a = pg.attribute("NUM").toInt(); |
||
880 | PgNam = ""; |
||
881 | PgNam = pg.attribute("NAM", ""); |
||
13574 | jghali | 882 | if (pg.tagName()=="MASTERPAGE" && PgNam.isEmpty()) |
883 | { |
||
884 | qDebug() << "scribus134format: corrupted masterpage with empty name detected"; |
||
885 | PAGE=PAGE.nextSibling(); |
||
886 | continue; |
||
887 | } |
||
5653 | cbradney | 888 | //Pgc = m_Doc->pageCount; |
889 | //AtFl = m_Doc->usesAutomaticTextFrames(); |
||
890 | if (PgNam.isEmpty()) |
||
891 | { |
||
892 | //m_Doc->pageCount = Pgc; |
||
893 | //m_Doc->Pages = &m_Doc->DocPages; |
||
894 | //m_Doc->setUsesAutomaticTextFrames(AtFl); |
||
895 | m_Doc->setMasterPageMode(false); |
||
896 | } |
||
897 | else |
||
898 | { |
||
899 | //m_Doc->pageCount = 0; |
||
900 | //m_Doc->setUsesAutomaticTextFrames(false); |
||
901 | //m_Doc->Pages = &m_Doc->MasterPages; |
||
902 | m_Doc->setMasterPageMode(true); |
||
903 | } |
||
904 | //CB: Stop calling damn GUI code in loading docs! IT doesnt *look* like |
||
905 | //this makes a difference apart from being faster, of course. |
||
906 | //ScMW->slotNewPage(a); |
||
907 | //Apage = m_Doc->Pages.at(a); |
||
908 | if (PgNam.isEmpty()) |
||
909 | { |
||
910 | Apage = m_Doc->addPage(a); |
||
911 | //m_Doc->DocPages = m_Doc->Pages; |
||
912 | //++m_Doc->pageCount; |
||
913 | } |
||
914 | else |
||
915 | { |
||
916 | Apage = m_Doc->addMasterPage(a, PgNam); |
||
917 | //Apage->setPageName(PgNam); |
||
918 | //m_Doc->MasterNames[PgNam] = a; |
||
919 | //m_Doc->MasterPages = m_Doc->Pages; |
||
920 | //m_Doc->pageCount = Pgc; |
||
921 | } |
||
922 | //m_Doc->setUsesAutomaticTextFrames(AtFl); |
||
923 | Apage->LeftPg=pg.attribute("LEFT", "0").toInt(); |
||
924 | QString Mus = ""; |
||
925 | Mus = pg.attribute("MNAM","Normal"); |
||
926 | if (!m_Doc->masterPageMode()) |
||
927 | Apage->MPageNam = Mus; |
||
928 | else |
||
929 | Apage->MPageNam = ""; |
||
930 | if (pg.hasAttribute("Size")) |
||
5789 | cbradney | 931 | Apage->m_pageSize = pg.attribute("Size"); |
5653 | cbradney | 932 | if (pg.hasAttribute("Orientation")) |
933 | Apage->PageOri = pg.attribute("Orientation").toInt(); |
||
13473 | pierre | 934 | Apage->setXOffset(ScCLocale::toDoubleC(pg.attribute("PAGEXPOS"))); |
935 | Apage->setYOffset(ScCLocale::toDoubleC(pg.attribute("PAGEYPOS"))); |
||
5653 | cbradney | 936 | if (pg.hasAttribute("PAGEWIDTH")) |
13473 | pierre | 937 | Apage->setWidth(ScCLocale::toDoubleC(pg.attribute("PAGEWIDTH"))); |
5653 | cbradney | 938 | else |
13473 | pierre | 939 | Apage->setWidth(ScCLocale::toDoubleC(pg.attribute("PAGEWITH"))); |
940 | Apage->setHeight(ScCLocale::toDoubleC(pg.attribute("PAGEHEIGHT"))); |
||
5653 | cbradney | 941 | Apage->setInitialHeight(Apage->height()); |
942 | Apage->setInitialWidth(Apage->width()); |
||
13473 | pierre | 943 | Apage->initialMargins.Top = qMax(0.0, ScCLocale::toDoubleC( pg.attribute("BORDERTOP"))); |
944 | Apage->initialMargins.Bottom = qMax(0.0, ScCLocale::toDoubleC(pg.attribute("BORDERBOTTOM"))); |
||
945 | Apage->initialMargins.Left = qMax(0.0, ScCLocale::toDoubleC(pg.attribute("BORDERLEFT"))); |
||
946 | Apage->initialMargins.Right = qMax(0.0,ScCLocale::toDoubleC( pg.attribute("BORDERRIGHT"))); |
||
12334 | fschmid | 947 | Apage->marginPreset = pg.attribute("PRESET", "0").toInt(); |
8509 | cbradney | 948 | Apage->Margins.Top = Apage->initialMargins.Top; |
949 | Apage->Margins.Bottom = Apage->initialMargins.Bottom; |
||
5653 | cbradney | 950 | m_Doc->setMasterPageMode(false); |
951 | //m_Doc->Pages=&m_Doc->DocPages; |
||
952 | // guides reading |
||
953 | tmp = ""; |
||
13473 | pierre | 954 | Apage->guides.setHorizontalAutoGap(ScCLocale::toDoubleC(pg.attribute("AGhorizontalAutoGap"), 0.0)); |
955 | Apage->guides.setVerticalAutoGap(ScCLocale::toDoubleC(pg.attribute("AGverticalAutoGap"), 0.0)); |
||
6027 | subik | 956 | Apage->guides.setHorizontalAutoCount(pg.attribute("AGhorizontalAutoCount", "0").toInt()); |
957 | Apage->guides.setVerticalAutoCount(pg.attribute("AGverticalAutoCount", "0").toInt()); |
||
6747 | subik | 958 | Apage->guides.setHorizontalAutoRefer(pg.attribute("AGhorizontalAutoRefer", "0").toInt()); |
959 | Apage->guides.setVerticalAutoRefer(pg.attribute("AGverticalAutoRefer", "0").toInt()); |
||
7682 | subik | 960 | GuideManagerIO::readVerticalGuides(pg.attribute("VerticalGuides"), |
5653 | cbradney | 961 | Apage, |
962 | GuideManagerCore::Standard, |
||
963 | pg.hasAttribute("NumVGuides")); |
||
7682 | subik | 964 | GuideManagerIO::readHorizontalGuides(pg.attribute("HorizontalGuides"), |
5653 | cbradney | 965 | Apage, |
966 | GuideManagerCore::Standard, |
||
967 | pg.hasAttribute("NumHGuides")); |
||
7715 | subik | 968 | GuideManagerIO::readSelection(pg.attribute("AGSelection"), Apage); |
969 | |||
14732 | jghali | 970 | Apage->guides.addHorizontals(Apage->guides.getAutoHorizontals(Apage), GuideManagerCore::Auto); |
971 | Apage->guides.addVerticals(Apage->guides.getAutoVerticals(Apage), GuideManagerCore::Auto); |
||
5653 | cbradney | 972 | } |
973 | if ((pg.tagName()=="PAGEOBJECT") || (pg.tagName()=="MASTEROBJECT") || (pg.tagName()=="FRAMEOBJECT")) |
||
974 | { |
||
975 | if ((pg.tagName()=="PAGEOBJECT") || (pg.tagName()=="FRAMEOBJECT")) |
||
976 | { |
||
977 | //m_Doc->Items = m_Doc->DocItems; |
||
978 | //m_Doc->Pages = &m_Doc->DocPages; |
||
979 | m_Doc->setMasterPageMode(false); |
||
980 | } |
||
981 | else |
||
982 | { |
||
983 | //m_Doc->Items = m_Doc->MasterItems; |
||
984 | //m_Doc->Pages = &m_Doc->MasterPages; |
||
985 | m_Doc->setMasterPageMode(true); |
||
986 | } |
||
14543 | cbradney | 987 | //CB comment out as no longer used int docGc = m_Doc->GroupCounter, |
988 | int pagenr = -1; |
||
5653 | cbradney | 989 | if ((!pg.attribute("OnMasterPage").isEmpty()) && (pg.tagName()=="MASTEROBJECT")) |
13423 | jghali | 990 | { |
5653 | cbradney | 991 | m_Doc->setCurrentPage(m_Doc->MasterPages.at(m_Doc->MasterNames[pg.attribute("OnMasterPage")])); |
13423 | jghali | 992 | pagenr = -2; |
993 | } |
||
13636 | jghali | 994 | /*m_Doc->GroupCounter = 0;*/ |
13423 | jghali | 995 | Neu = PasteItem(&pg, m_Doc, fileDir, pagenr); |
5653 | cbradney | 996 | Neu->setRedrawBounding(); |
997 | if (pg.tagName()=="MASTEROBJECT") |
||
998 | Neu->OwnPage = m_Doc->OnPage(Neu); |
||
999 | else |
||
1000 | Neu->OwnPage = pg.attribute("OwnPage").toInt(); |
||
1001 | if (pg.tagName()=="PAGEOBJECT") |
||
1002 | Neu->OnMasterPage = ""; |
||
13636 | jghali | 1003 | /*m_Doc->GroupCounter = docGc;*/ |
5653 | cbradney | 1004 | tmpf = pg.attribute("IFONT", m_Doc->toolSettings.defFont); |
8775 | cbradney | 1005 | m_AvailableFonts->findFont(tmpf, m_Doc); |
5653 | cbradney | 1006 | QDomNode IT=pg.firstChild(); |
1007 | LastStyles * last = new LastStyles(); |
||
1008 | while(!IT.isNull()) |
||
1009 | { |
||
1010 | QDomElement it=IT.toElement(); |
||
1011 | if (it.tagName()=="CSTOP") |
||
1012 | { |
||
1013 | QString name = it.attribute("NAME"); |
||
13475 | jghali | 1014 | double ramp = ScCLocale::toDoubleC( it.attribute("RAMP"), 0.0); |
5653 | cbradney | 1015 | int shade = it.attribute("SHADE", "100").toInt(); |
13475 | jghali | 1016 | double opa = ScCLocale::toDoubleC( it.attribute("TRANS"), 1.0); |
5653 | cbradney | 1017 | Neu->fill_gradient.addStop(SetColor(m_Doc, name, shade), ramp, 0.5, opa, name, shade); |
1018 | } |
||
11873 | fschmid | 1019 | if (it.tagName()=="ITEXT") |
5653 | cbradney | 1020 | GetItemText(&it, m_Doc, Neu, last); |
11873 | fschmid | 1021 | else if (it.tagName()=="para") |
1022 | { |
||
6864 | avox | 1023 | Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::PARSEP); |
1024 | ParagraphStyle newStyle; |
||
1025 | PrefsManager* prefsManager=PrefsManager::instance(); |
||
7965 | avox | 1026 | readParagraphStyle(newStyle, it, prefsManager->appPrefs.AvailFonts, m_Doc); |
1027 | Neu->itemText.setStyle(Neu->itemText.length()-1, newStyle); |
||
9053 | avox | 1028 | Neu->itemText.setCharStyle(Neu->itemText.length()-1, 1, last->Style); |
6864 | avox | 1029 | } |
14482 | jghali | 1030 | else if (it.tagName() == "trail") |
1031 | { |
||
1032 | ParagraphStyle newStyle; |
||
1033 | PrefsManager* prefsManager = PrefsManager::instance(); |
||
1034 | readParagraphStyle(newStyle, it, prefsManager->appPrefs.AvailFonts, m_Doc); |
||
1035 | Neu->itemText.setStyle(Neu->itemText.length(), newStyle); |
||
1036 | } |
||
11873 | fschmid | 1037 | else if (it.tagName()=="tab") |
13970 | jghali | 1038 | { |
1039 | CharStyle newStyle; |
||
6864 | avox | 1040 | Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::TAB); |
13970 | jghali | 1041 | GetCStyle(&it, m_Doc, newStyle); |
1042 | Neu->itemText.setCharStyle(Neu->itemText.length()-1, 1, newStyle); |
||
1043 | last->StyleStart = Neu->itemText.length()-1; |
||
1044 | last->Style = newStyle; |
||
1045 | } |
||
11873 | fschmid | 1046 | else if (it.tagName()=="breakline") |
6864 | avox | 1047 | Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::LINEBREAK); |
11873 | fschmid | 1048 | else if (it.tagName()=="breakcol") |
6864 | avox | 1049 | Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::COLBREAK); |
11873 | fschmid | 1050 | else if (it.tagName()=="breakframe") |
6864 | avox | 1051 | Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::FRAMEBREAK); |
11873 | fschmid | 1052 | else if (it.tagName()=="nbhyphen") |
1053 | Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::NBHYPHEN); |
||
1054 | else if (it.tagName()=="nbspace") |
||
1055 | Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::NBSPACE); |
||
1056 | else if (it.tagName()=="zwnbspace") |
||
1057 | Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::ZWNBSPACE); |
||
1058 | else if (it.tagName()=="zwspace") |
||
1059 | Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::ZWSPACE); |
||
11713 | fschmid | 1060 | else if (it.tagName()=="var") |
6864 | avox | 1061 | { |
11713 | fschmid | 1062 | if (it.attribute("name") == "pgno") |
1063 | Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::PAGENUMBER); |
||
1064 | else |
||
1065 | Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::PAGECOUNT); |
||
11706 | fschmid | 1066 | CharStyle newStyle; |
1067 | GetCStyle(&it, m_Doc, newStyle); |
||
1068 | Neu->itemText.setCharStyle(Neu->itemText.length()-1, 1, newStyle); |
||
11713 | fschmid | 1069 | last->StyleStart = Neu->itemText.length()-1; |
1070 | last->Style = newStyle; |
||
6864 | avox | 1071 | } |
5653 | cbradney | 1072 | |
1073 | //CB PageItemAttributes |
||
1074 | if(it.tagName()=="PageItemAttributes") |
||
1075 | { |
||
1076 | QDomNode PIA = it.firstChild(); |
||
1077 | ObjAttrVector pageItemAttributes; |
||
1078 | while(!PIA.isNull()) |
||
1079 | { |
||
1080 | QDomElement itemAttr = PIA.toElement(); |
||
1081 | if(itemAttr.tagName() == "ItemAttribute") |
||
1082 | { |
||
1083 | ObjectAttribute objattr; |
||
1084 | objattr.name=itemAttr.attribute("Name"); |
||
1085 | objattr.type=itemAttr.attribute("Type"); |
||
1086 | objattr.value=itemAttr.attribute("Value"); |
||
1087 | objattr.parameter=itemAttr.attribute("Parameter"); |
||
1088 | objattr.relationship=itemAttr.attribute("Relationship"); |
||
1089 | objattr.relationshipto=itemAttr.attribute("RelationshipTo"); |
||
1090 | objattr.autoaddto=itemAttr.attribute("AutoAddTo"); |
||
1091 | pageItemAttributes.append(objattr); |
||
1092 | } |
||
1093 | PIA = PIA.nextSibling(); |
||
1094 | } |
||
1095 | Neu->setObjectAttributes(&pageItemAttributes); |
||
1096 | } |
||
1097 | IT=IT.nextSibling(); |
||
1098 | } |
||
9644 | avox | 1099 | if (Neu->asTextFrame()) |
1100 | { |
||
1101 | /* |
||
1102 | QString dbg(""); |
||
1103 | for (int i=0; i < Neu->itemText.length(); ++i) |
||
1104 | { |
||
1105 | dbg += Neu->itemText.text(i,1); |
||
1106 | if (Neu->itemText.item(i)->effects() & ScStyle_HyphenationPossible) |
||
1107 | dbg += "~"; |
||
1108 | } |
||
1109 | qDebug("scribus134format: read itemtext '%s'", dbg.latin1()); |
||
1110 | */ } |
||
7913 | fschmid | 1111 | if (Neu->asPathText()) |
1112 | { |
||
1113 | Neu->updatePolyClip(); |
||
1114 | Neu->Frame = true; |
||
1115 | } |
||
5653 | cbradney | 1116 | delete last; |
1117 | if (Neu->fill_gradient.Stops() == 0) |
||
1118 | { |
||
7478 | jghali | 1119 | const ScColor& col1 = m_Doc->PageColors[m_Doc->toolSettings.dBrush]; |
1120 | const ScColor& col2 = m_Doc->PageColors[m_Doc->toolSettings.dPen]; |
||
1121 | Neu->fill_gradient.addStop(ScColorEngine::getRGBColor(col1, m_Doc), 0.0, 0.5, 1.0, m_Doc->toolSettings.dBrush, 100); |
||
1122 | Neu->fill_gradient.addStop(ScColorEngine::getRGBColor(col2, m_Doc), 1.0, 0.5, 1.0, m_Doc->toolSettings.dPen, 100); |
||
5653 | cbradney | 1123 | } |
1124 | // Neu->Language = ScMW->GetLang(pg.attribute("LANGUAGE", m_Doc->Language)); |
||
1125 | Neu->isAutoText = static_cast<bool>(pg.attribute("AUTOTEXT").toInt()); |
||
1126 | Neu->isEmbedded = static_cast<bool>(pg.attribute("isInline", "0").toInt()); |
||
13475 | jghali | 1127 | Neu->gXpos = ScCLocale::toDoubleC( pg.attribute("gXpos"), 0.0); |
1128 | Neu->gYpos = ScCLocale::toDoubleC( pg.attribute("gYpos"), 0.0); |
||
1129 | Neu->gWidth = ScCLocale::toDoubleC( pg.attribute("gWidth"), Neu->width()); |
||
1130 | Neu->gHeight = ScCLocale::toDoubleC( pg.attribute("gHeight"), Neu->height()); |
||
6733 | avox | 1131 | if (Neu->isAutoText) |
5653 | cbradney | 1132 | m_Doc->LastAuto = Neu; |
7994 | avox | 1133 | // first of linked chain? |
1134 | if (pg.tagName()=="PAGEOBJECT") |
||
1135 | { |
||
1136 | if (pg.attribute("NEXTITEM").toInt() != -1) |
||
8110 | jghali | 1137 | itemNext[Neu->ItemNr] = pg.attribute("NEXTITEM").toInt(); |
7994 | avox | 1138 | } |
1139 | else if (pg.tagName()=="MASTEROBJECT") |
||
1140 | { |
||
1141 | if (pg.attribute("NEXTITEM").toInt() != -1) |
||
8110 | jghali | 1142 | itemNextM[Neu->ItemNr] = pg.attribute("NEXTITEM").toInt(); |
7994 | avox | 1143 | } |
1144 | /* not sure if we want that... |
||
1145 | else if (pg.tagName()=="FRAMEOBJECT") |
||
1146 | { |
||
1147 | if (pg.attribute("NEXTITEM").toInt() != -1) |
||
8110 | jghali | 1148 | itemNextF[Neu->ItemNr] = pg.attribute("NEXTITEM").toInt(); |
7994 | avox | 1149 | }*/ |
1150 | |||
7450 | fschmid | 1151 | if (pg.tagName()=="FRAMEOBJECT") |
1152 | { |
||
9856 | fschmid | 1153 | m_Doc->FrameItems.append(m_Doc->Items->takeAt(Neu->ItemNr)); |
7450 | fschmid | 1154 | Neu->ItemNr = m_Doc->FrameItems.count()-1; |
1155 | } |
||
5653 | cbradney | 1156 | if (Neu->isTableItem) |
1157 | { |
||
7450 | fschmid | 1158 | if (pg.tagName()=="PAGEOBJECT") |
1159 | { |
||
1160 | TableItems.append(Neu); |
||
1161 | TableID.insert(pg.attribute("OwnLINK", "0").toInt(), Neu->ItemNr); |
||
1162 | } |
||
1163 | else if (pg.tagName()=="FRAMEOBJECT") |
||
1164 | { |
||
1165 | TableItemsF.append(Neu); |
||
1166 | TableIDF.insert(pg.attribute("OwnLINK", "0").toInt(), Neu->ItemNr); |
||
1167 | } |
||
1168 | else |
||
1169 | { |
||
1170 | TableItemsM.append(Neu); |
||
1171 | TableIDM.insert(pg.attribute("OwnLINK", "0").toInt(), Neu->ItemNr); |
||
1172 | } |
||
5653 | cbradney | 1173 | } |
6451 | fschmid | 1174 | Neu->isGroupControl = static_cast<bool>(pg.attribute("isGroupControl", "0").toInt()); |
1175 | if (Neu->isGroupControl) |
||
7444 | fschmid | 1176 | { |
13679 | jghali | 1177 | int groupLastItem = pg.attribute("groupsLastItem", "0").toInt(); |
1178 | if ((Neu->Groups.count() == 0) || (groupLastItem <= 0)) // Sanity check for some broken files created using buggy development versions. |
||
9604 | fschmid | 1179 | { |
1180 | Neu->isGroupControl = false; |
||
1181 | Neu->setFillColor("None"); |
||
1182 | } |
||
7444 | fschmid | 1183 | else |
9604 | fschmid | 1184 | { |
1185 | if (pg.tagName()=="PAGEOBJECT") |
||
13679 | jghali | 1186 | groupID.insert(Neu, groupLastItem + Neu->ItemNr); |
9604 | fschmid | 1187 | else if (pg.tagName()=="FRAMEOBJECT") |
13679 | jghali | 1188 | groupIDF.insert(Neu, groupLastItem + Neu->ItemNr); |
9604 | fschmid | 1189 | else |
13679 | jghali | 1190 | groupIDM.insert(Neu, groupLastItem + Neu->ItemNr); |
9604 | fschmid | 1191 | } |
7444 | fschmid | 1192 | } |
5653 | cbradney | 1193 | m_Doc->setMasterPageMode(false); |
1194 | counter++; |
||
1195 | } |
||
1196 | PAGE=PAGE.nextSibling(); |
||
1197 | } |
||
1198 | PAGE=DOC.firstChild(); |
||
1199 | while(!PAGE.isNull()) |
||
1200 | { |
||
1201 | QDomElement pg=PAGE.toElement(); |
||
1202 | if(pg.tagName()=="Bookmark") |
||
1203 | { |
||
9856 | fschmid | 1204 | int elem = pg.attribute("Element").toInt(); |
6573 | fschmid | 1205 | if (elem < m_Doc->Items->count()) |
1206 | { |
||
1207 | bok.Title = pg.attribute("Title"); |
||
1208 | bok.Text = pg.attribute("Text"); |
||
1209 | bok.Aktion = pg.attribute("Aktion"); |
||
1210 | bok.ItemNr = pg.attribute("ItemNr").toInt(); |
||
1211 | bok.PageObject = m_Doc->Items->at(elem); |
||
1212 | bok.First = pg.attribute("First").toInt(); |
||
1213 | bok.Last = pg.attribute("Last").toInt(); |
||
1214 | bok.Prev = pg.attribute("Prev").toInt(); |
||
1215 | bok.Next = pg.attribute("Next").toInt(); |
||
1216 | bok.Parent = pg.attribute("Parent").toInt(); |
||
1217 | m_Doc->BookMarks.append(bok); |
||
1218 | } |
||
5653 | cbradney | 1219 | } |
6380 | fschmid | 1220 | if(pg.tagName()=="Pattern") |
1221 | { |
||
6846 | fschmid | 1222 | QMap<PageItem*, int> groupID2; |
7450 | fschmid | 1223 | QMap<int,int> TableID2; |
9856 | fschmid | 1224 | QList<PageItem*> TableItems2; |
6380 | fschmid | 1225 | ScPattern pat; |
1226 | QDomNode pa = PAGE.firstChild(); |
||
1227 | uint ac = m_Doc->Items->count(); |
||
6381 | fschmid | 1228 | bool savedAlignGrid = m_Doc->useRaster; |
1229 | bool savedAlignGuides = m_Doc->SnapGuides; |
||
1230 | m_Doc->useRaster = false; |
||
1231 | m_Doc->SnapGuides = false; |
||
6380 | fschmid | 1232 | while(!pa.isNull()) |
1233 | { |
||
1234 | QDomElement pite = pa.toElement(); |
||
1235 | m_Doc->setMasterPageMode(false); |
||
14543 | cbradney | 1236 | //int docGc = m_Doc->GroupCounter; |
13636 | jghali | 1237 | /*m_Doc->GroupCounter = 0;*/ |
10259 | jghali | 1238 | Neu = PasteItem(&pite, m_Doc, fileDir); |
6380 | fschmid | 1239 | Neu->setRedrawBounding(); |
1240 | Neu->OwnPage = pite.attribute("OwnPage").toInt(); |
||
1241 | Neu->OnMasterPage = ""; |
||
13636 | jghali | 1242 | /*m_Doc->GroupCounter = docGc;*/ |
6380 | fschmid | 1243 | tmpf = pite.attribute("IFONT", m_Doc->toolSettings.defFont); |
8775 | cbradney | 1244 | m_AvailableFonts->findFont(tmpf, m_Doc); |
6380 | fschmid | 1245 | QDomNode IT=pite.firstChild(); |
1246 | LastStyles * last = new LastStyles(); |
||
1247 | while(!IT.isNull()) |
||
1248 | { |
||
1249 | QDomElement it=IT.toElement(); |
||
1250 | if (it.tagName()=="CSTOP") |
||
1251 | { |
||
1252 | QString name = it.attribute("NAME"); |
||
13475 | jghali | 1253 | double ramp = ScCLocale::toDoubleC( it.attribute("RAMP"), 0.0); |
6380 | fschmid | 1254 | int shade = it.attribute("SHADE", "100").toInt(); |
13475 | jghali | 1255 | double opa = ScCLocale::toDoubleC( it.attribute("TRANS"), 1.0); |
6380 | fschmid | 1256 | Neu->fill_gradient.addStop(SetColor(m_Doc, name, shade), ramp, 0.5, opa, name, shade); |
1257 | } |
||
1258 | if (it.tagName()=="ITEXT") |
||
1259 | GetItemText(&it, m_Doc, Neu, last); |
||
11873 | fschmid | 1260 | else if (it.tagName()=="para") |
1261 | { |
||
9053 | avox | 1262 | Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::PARSEP); |
1263 | ParagraphStyle newStyle; |
||
1264 | PrefsManager* prefsManager=PrefsManager::instance(); |
||
1265 | readParagraphStyle(newStyle, it, prefsManager->appPrefs.AvailFonts, m_Doc); |
||
1266 | Neu->itemText.setStyle(Neu->itemText.length()-1, newStyle); |
||
1267 | Neu->itemText.setCharStyle(Neu->itemText.length()-1, 1, last->Style); |
||
1268 | } |
||
14482 | jghali | 1269 | else if (it.tagName() == "trail") |
1270 | { |
||
1271 | ParagraphStyle newStyle; |
||
1272 | PrefsManager* prefsManager = PrefsManager::instance(); |
||
1273 | readParagraphStyle(newStyle, it, prefsManager->appPrefs.AvailFonts, m_Doc); |
||
1274 | Neu->itemText.setStyle(Neu->itemText.length(), newStyle); |
||
1275 | } |
||
11873 | fschmid | 1276 | else if (it.tagName()=="tab") |
13970 | jghali | 1277 | { |
1278 | CharStyle newStyle; |
||
9053 | avox | 1279 | Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::TAB); |
13970 | jghali | 1280 | GetCStyle(&it, m_Doc, newStyle); |
1281 | Neu->itemText.setCharStyle(Neu->itemText.length()-1, 1, newStyle); |
||
1282 | last->StyleStart = Neu->itemText.length()-1; |
||
1283 | last->Style = newStyle; |
||
1284 | } |
||
11873 | fschmid | 1285 | else if (it.tagName()=="breakline") |
9053 | avox | 1286 | Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::LINEBREAK); |
11873 | fschmid | 1287 | else if (it.tagName()=="breakcol") |
9053 | avox | 1288 | Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::COLBREAK); |
11873 | fschmid | 1289 | else if (it.tagName()=="breakframe") |
9053 | avox | 1290 | Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::FRAMEBREAK); |
11873 | fschmid | 1291 | else if (it.tagName()=="nbhyphen") |
1292 | Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::NBHYPHEN); |
||
1293 | else if (it.tagName()=="nbspace") |
||
1294 | Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::NBSPACE); |
||
1295 | else if (it.tagName()=="zwnbspace") |
||
1296 | Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::ZWNBSPACE); |
||
1297 | else if (it.tagName()=="zwspace") |
||
1298 | Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::ZWSPACE); |
||
11713 | fschmid | 1299 | else if (it.tagName()=="var") |
9053 | avox | 1300 | { |
11713 | fschmid | 1301 | if (it.attribute("name") == "pgno") |
1302 | Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::PAGENUMBER); |
||
1303 | else |
||
1304 | Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::PAGECOUNT); |
||
11706 | fschmid | 1305 | CharStyle newStyle; |
1306 | GetCStyle(&it, m_Doc, newStyle); |
||
1307 | Neu->itemText.setCharStyle(Neu->itemText.length()-1, 1, newStyle); |
||
11713 | fschmid | 1308 | last->StyleStart = Neu->itemText.length()-1; |
1309 | last->Style = newStyle; |
||
9053 | avox | 1310 | } |
1311 | |||
6380 | fschmid | 1312 | if(it.tagName()=="PageItemAttributes") |
1313 | { |
||
1314 | QDomNode PIA = it.firstChild(); |
||
1315 | ObjAttrVector pageItemAttributes; |
||
1316 | while(!PIA.isNull()) |
||
1317 | { |
||
1318 | QDomElement itemAttr = PIA.toElement(); |
||
1319 | if(itemAttr.tagName() == "ItemAttribute") |
||
1320 | { |
||
1321 | ObjectAttribute objattr; |
||
1322 | objattr.name=itemAttr.attribute("Name"); |
||
1323 | objattr.type=itemAttr.attribute("Type"); |
||
1324 | objattr.value=itemAttr.attribute("Value"); |
||
1325 | objattr.parameter=itemAttr.attribute("Parameter"); |
||
1326 | objattr.relationship=itemAttr.attribute("Relationship"); |
||
1327 | objattr.relationshipto=itemAttr.attribute("RelationshipTo"); |
||
1328 | objattr.autoaddto=itemAttr.attribute("AutoAddTo"); |
||
1329 | pageItemAttributes.append(objattr); |
||
1330 | } |
||
1331 | PIA = PIA.nextSibling(); |
||
1332 | } |
||
1333 | Neu->setObjectAttributes(&pageItemAttributes); |
||
1334 | } |
||
1335 | IT=IT.nextSibling(); |
||
1336 | } |
||
1337 | delete last; |
||
7913 | fschmid | 1338 | if (Neu->asPathText()) |
1339 | { |
||
1340 | Neu->updatePolyClip(); |
||
1341 | Neu->Frame = true; |
||
1342 | } |
||
6380 | fschmid | 1343 | if (Neu->fill_gradient.Stops() == 0) |
1344 | { |
||
7478 | jghali | 1345 | const ScColor& col1 = m_Doc->PageColors[m_Doc->toolSettings.dBrush]; |
1346 | const ScColor& col2 = m_Doc->PageColors[m_Doc->toolSettings.dPen]; |
||
1347 | Neu->fill_gradient.addStop(ScColorEngine::getRGBColor(col1, m_Doc), 0.0, 0.5, 1.0, m_Doc->toolSettings.dBrush, 100); |
||
1348 | Neu->fill_gradient.addStop(ScColorEngine::getRGBColor(col2, m_Doc), 1.0, 0.5, 1.0, m_Doc->toolSettings.dPen, 100); |
||
6380 | fschmid | 1349 | } |
1350 | Neu->isAutoText = static_cast<bool>(pite.attribute("AUTOTEXT").toInt()); |
||
1351 | Neu->isEmbedded = static_cast<bool>(pite.attribute("isInline", "0").toInt()); |
||
13475 | jghali | 1352 | Neu->gXpos = ScCLocale::toDoubleC( pite.attribute("gXpos"), 0.0); |
1353 | Neu->gYpos = ScCLocale::toDoubleC( pite.attribute("gYpos"), 0.0); |
||
1354 | Neu->gWidth = ScCLocale::toDoubleC( pite.attribute("gWidth"), Neu->width()); |
||
1355 | Neu->gHeight = ScCLocale::toDoubleC( pite.attribute("gHeight"), Neu->height()); |
||
6380 | fschmid | 1356 | if (Neu->isTableItem) |
1357 | { |
||
7450 | fschmid | 1358 | TableItems2.append(Neu); |
1359 | TableID2.insert(pite.attribute("OwnLINK", "0").toInt(), Neu->ItemNr); |
||
6380 | fschmid | 1360 | } |
6451 | fschmid | 1361 | Neu->isGroupControl = static_cast<bool>(pite.attribute("isGroupControl", "0").toInt()); |
1362 | if (Neu->isGroupControl) |
||
9604 | fschmid | 1363 | { |
13679 | jghali | 1364 | int groupLastItem = pg.attribute("groupsLastItem", "0").toInt(); |
1365 | if ((Neu->Groups.count() == 0) || (groupLastItem <= 0)) // Sanity check for some broken files created using buggy development versions. |
||
9604 | fschmid | 1366 | { |
1367 | Neu->isGroupControl = false; |
||
1368 | Neu->setFillColor("None"); |
||
1369 | } |
||
1370 | else |
||
1371 | groupID2.insert(Neu, pite.attribute("groupsLastItem", "0").toInt()+Neu->ItemNr); |
||
1372 | } |
||
6380 | fschmid | 1373 | pa = pa.nextSibling(); |
1374 | } |
||
6846 | fschmid | 1375 | if (groupID2.count() != 0) |
1376 | { |
||
1377 | QMap<PageItem*, int>::Iterator it; |
||
1378 | for (it = groupID2.begin(); it != groupID2.end(); ++it) |
||
1379 | { |
||
10427 | cbradney | 1380 | it.key()->groupsLastItem = m_Doc->Items->at(it.value()); |
6846 | fschmid | 1381 | } |
1382 | } |
||
7450 | fschmid | 1383 | if (TableItems2.count() != 0) |
1384 | { |
||
9856 | fschmid | 1385 | for (int ttc = 0; ttc < TableItems2.count(); ++ttc) |
7450 | fschmid | 1386 | { |
1387 | PageItem* ta = TableItems2.at(ttc); |
||
1388 | if (ta->TopLinkID != -1) |
||
1389 | ta->TopLink = m_Doc->Items->at(TableID2[ta->TopLinkID]); |
||
1390 | else |
||
1391 | ta->TopLink = 0; |
||
1392 | if (ta->LeftLinkID != -1) |
||
1393 | ta->LeftLink = m_Doc->Items->at(TableID2[ta->LeftLinkID]); |
||
1394 | else |
||
1395 | ta->LeftLink = 0; |
||
1396 | if (ta->RightLinkID != -1) |
||
1397 | ta->RightLink = m_Doc->Items->at(TableID2[ta->RightLinkID]); |
||
1398 | else |
||
1399 | ta->RightLink = 0; |
||
1400 | if (ta->BottomLinkID != -1) |
||
1401 | ta->BottomLink = m_Doc->Items->at(TableID2[ta->BottomLinkID]); |
||
1402 | else |
||
1403 | ta->BottomLink = 0; |
||
1404 | } |
||
1405 | } |
||
6381 | fschmid | 1406 | m_Doc->useRaster = savedAlignGrid; |
1407 | m_Doc->SnapGuides = savedAlignGuides; |
||
6380 | fschmid | 1408 | uint ae = m_Doc->Items->count(); |
1409 | pat.setDoc(m_Doc); |
||
13475 | jghali | 1410 | pat.width = ScCLocale::toDoubleC( pg.attribute("width"), 0.0); |
1411 | pat.height = ScCLocale::toDoubleC( pg.attribute("height"), 0.0); |
||
1412 | pat.scaleX = ScCLocale::toDoubleC( pg.attribute("scaleX"), 0.0); |
||
1413 | pat.scaleY = ScCLocale::toDoubleC( pg.attribute("scaleY"), 0.0); |
||
1414 | pat.xoffset = ScCLocale::toDoubleC( pg.attribute("xoffset"), 0.0); |
||
1415 | pat.yoffset = ScCLocale::toDoubleC( pg.attribute("yoffset"), 0.0); |
||
13887 | jghali | 1416 | if (ae > ac) |
6380 | fschmid | 1417 | { |
13887 | jghali | 1418 | PageItem* currItem = m_Doc->Items->at(ac); |
1419 | pat.pattern = currItem->DrawObj_toImage(); |
||
1420 | pat.pattern = pat.pattern.copy(-pat.xoffset, -pat.yoffset, pat.width, pat.height); |
||
1421 | for (uint as = ac; as < ae; ++as) |
||
1422 | { |
||
1423 | Neu = m_Doc->Items->takeAt(ac); |
||
1424 | Neu->moveBy(pat.xoffset, pat.yoffset, true); |
||
1425 | Neu->gXpos += pat.xoffset; |
||
1426 | Neu->gYpos += pat.yoffset; |
||
1427 | Neu->ItemNr = pat.items.count(); |
||
1428 | pat.items.append(Neu); |
||
1429 | } |
||
6380 | fschmid | 1430 | } |
13887 | jghali | 1431 | QString patName = pg.attribute("Name"); |
1432 | if (!patName.isEmpty()) |
||
1433 | m_Doc->docPatterns.insert(patName, pat); |
||
6380 | fschmid | 1434 | } |
5653 | cbradney | 1435 | PAGE=PAGE.nextSibling(); |
1436 | } |
||
1437 | DOC=DOC.nextSibling(); |
||
1438 | } |
||
7450 | fschmid | 1439 | if (TableItemsF.count() != 0) |
1440 | { |
||
9856 | fschmid | 1441 | for (int ttc = 0; ttc < TableItemsF.count(); ++ttc) |
7450 | fschmid | 1442 | { |
1443 | PageItem* ta = TableItemsF.at(ttc); |
||
1444 | if (ta->TopLinkID != -1) |
||
1445 | ta->TopLink = m_Doc->FrameItems.at(TableIDF[ta->TopLinkID]); |
||
1446 | else |
||
1447 | ta->TopLink = 0; |
||
1448 | if (ta->LeftLinkID != -1) |
||
1449 | ta->LeftLink = m_Doc->FrameItems.at(TableIDF[ta->LeftLinkID]); |
||
1450 | else |
||
1451 | ta->LeftLink = 0; |
||
1452 | if (ta->RightLinkID != -1) |
||
1453 | ta->RightLink = m_Doc->FrameItems.at(TableIDF[ta->RightLinkID]); |
||
1454 | else |
||
1455 | ta->RightLink = 0; |
||
1456 | if (ta->BottomLinkID != -1) |
||
1457 | ta->BottomLink = m_Doc->FrameItems.at(TableIDF[ta->BottomLinkID]); |
||
1458 | else |
||
1459 | ta->BottomLink = 0; |
||
1460 | } |
||
1461 | } |
||
1462 | if (TableItemsM.count() != 0) |
||
1463 | { |
||
9856 | fschmid | 1464 | for (int ttc = 0; ttc < TableItemsM.count(); ++ttc) |
7450 | fschmid | 1465 | { |
1466 | PageItem* ta = TableItemsM.at(ttc); |
||
1467 | if (ta->TopLinkID != -1) |
||
1468 | ta->TopLink = m_Doc->MasterItems.at(TableIDM[ta->TopLinkID]); |
||
1469 | else |
||
1470 | ta->TopLink = 0; |
||
1471 | if (ta->LeftLinkID != -1) |
||
1472 | ta->LeftLink = m_Doc->MasterItems.at(TableIDM[ta->LeftLinkID]); |
||
1473 | else |
||
1474 | ta->LeftLink = 0; |
||
1475 | if (ta->RightLinkID != -1) |
||
1476 | ta->RightLink = m_Doc->MasterItems.at(TableIDM[ta->RightLinkID]); |
||
1477 | else |
||
1478 | ta->RightLink = 0; |
||
1479 | if (ta->BottomLinkID != -1) |
||
1480 | ta->BottomLink = m_Doc->MasterItems.at(TableIDM[ta->BottomLinkID]); |
||
1481 | else |
||
1482 | ta->BottomLink = 0; |
||
1483 | } |
||
1484 | } |
||
5653 | cbradney | 1485 | if (TableItems.count() != 0) |
1486 | { |
||
9856 | fschmid | 1487 | for (int ttc = 0; ttc < TableItems.count(); ++ttc) |
5653 | cbradney | 1488 | { |
1489 | PageItem* ta = TableItems.at(ttc); |
||
1490 | if (ta->TopLinkID != -1) |
||
1491 | ta->TopLink = m_Doc->Items->at(TableID[ta->TopLinkID]); |
||
1492 | else |
||
1493 | ta->TopLink = 0; |
||
1494 | if (ta->LeftLinkID != -1) |
||
1495 | ta->LeftLink = m_Doc->Items->at(TableID[ta->LeftLinkID]); |
||
1496 | else |
||
1497 | ta->LeftLink = 0; |
||
1498 | if (ta->RightLinkID != -1) |
||
1499 | ta->RightLink = m_Doc->Items->at(TableID[ta->RightLinkID]); |
||
1500 | else |
||
1501 | ta->RightLink = 0; |
||
1502 | if (ta->BottomLinkID != -1) |
||
1503 | ta->BottomLink = m_Doc->Items->at(TableID[ta->BottomLinkID]); |
||
1504 | else |
||
1505 | ta->BottomLink = 0; |
||
1506 | } |
||
1507 | } |
||
7450 | fschmid | 1508 | if (groupIDF.count() != 0) |
1509 | { |
||
1510 | QMap<PageItem*, int>::Iterator it; |
||
1511 | for (it = groupIDF.begin(); it != groupIDF.end(); ++it) |
||
1512 | { |
||
10427 | cbradney | 1513 | it.key()->groupsLastItem = m_Doc->FrameItems.at(it.value()); |
7450 | fschmid | 1514 | } |
1515 | } |
||
6451 | fschmid | 1516 | if (groupID.count() != 0) |
1517 | { |
||
1518 | QMap<PageItem*, int>::Iterator it; |
||
1519 | for (it = groupID.begin(); it != groupID.end(); ++it) |
||
1520 | { |
||
10427 | cbradney | 1521 | it.key()->groupsLastItem = m_Doc->DocItems.at(it.value()); |
6451 | fschmid | 1522 | } |
1523 | } |
||
7444 | fschmid | 1524 | if (groupIDM.count() != 0) |
1525 | { |
||
1526 | QMap<PageItem*, int>::Iterator it; |
||
1527 | for (it = groupIDM.begin(); it != groupIDM.end(); ++it) |
||
1528 | { |
||
10427 | cbradney | 1529 | it.key()->groupsLastItem = m_Doc->MasterItems.at(it.value()); |
7444 | fschmid | 1530 | } |
1531 | } |
||
5653 | cbradney | 1532 | m_Doc->setActiveLayer(layerToSetActive); |
1533 | m_Doc->setMasterPageMode(false); |
||
1534 | m_Doc->reformPages(); |
||
1535 | |||
1536 | if (m_Doc->Layers.count() == 0) |
||
10147 | jghali | 1537 | m_Doc->Layers.newLayer( QObject::tr("Background") ); |
7994 | avox | 1538 | |
1539 | // reestablish textframe links |
||
1540 | if (itemNext.count() != 0) |
||
5653 | cbradney | 1541 | { |
7994 | avox | 1542 | QMap<int,int>::Iterator lc; |
1543 | for (lc = itemNext.begin(); lc != itemNext.end(); ++lc) |
||
5653 | cbradney | 1544 | { |
10427 | cbradney | 1545 | if (lc.value() >= 0) |
5653 | cbradney | 1546 | { |
7994 | avox | 1547 | PageItem * Its = m_Doc->DocItems.at(lc.key()); |
10427 | cbradney | 1548 | PageItem * Itn = m_Doc->DocItems.at(lc.value()); |
7994 | avox | 1549 | if (Itn->prevInChain() || Its->nextInChain()) |
1550 | { |
||
13085 | jghali | 1551 | qDebug() << "scribus134format: corruption in linked textframes detected"; |
7994 | avox | 1552 | continue; |
1553 | } |
||
1554 | Its->link(Itn); |
||
5653 | cbradney | 1555 | } |
1556 | } |
||
1557 | } |
||
7994 | avox | 1558 | |
1559 | if (itemNextM.count() != 0) |
||
7805 | fschmid | 1560 | { |
7994 | avox | 1561 | QMap<int,int>::Iterator lc; |
1562 | for (lc = itemNextM.begin(); lc != itemNextM.end(); ++lc) |
||
7805 | fschmid | 1563 | { |
10427 | cbradney | 1564 | if (lc.value() >= 0) |
7805 | fschmid | 1565 | { |
7994 | avox | 1566 | PageItem * Its = m_Doc->MasterItems.at(lc.key()); |
10427 | cbradney | 1567 | PageItem * Itn = m_Doc->MasterItems.at(lc.value()); |
7994 | avox | 1568 | if (Itn->prevInChain() || Its->nextInChain()) |
1569 | { |
||
13085 | jghali | 1570 | qDebug() << "scribus134format: corruption in linked textframes detected"; |
7994 | avox | 1571 | continue; |
1572 | } |
||
1573 | Its->link(Itn); |
||
7805 | fschmid | 1574 | } |
1575 | } |
||
1576 | } |
||
7994 | avox | 1577 | |
1578 | // reestablish first/lastAuto |
||
1579 | m_Doc->FirstAuto = m_Doc->LastAuto; |
||
1580 | if (m_Doc->LastAuto) |
||
1581 | { |
||
1582 | while (m_Doc->LastAuto->nextInChain()) |
||
1583 | m_Doc->LastAuto = m_Doc->LastAuto->nextInChain(); |
||
1584 | while (m_Doc->FirstAuto->prevInChain()) |
||
1585 | m_Doc->FirstAuto = m_Doc->FirstAuto->prevInChain(); |
||
1586 | } |
||
13519 | jghali | 1587 | |
1588 | // start auto save timer if needed |
||
1589 | if (m_Doc->AutoSave && ScCore->usingGUI()) |
||
1590 | m_Doc->autoSaveTimer->start(m_Doc->AutoSaveTime); |
||
7994 | avox | 1591 | |
5653 | cbradney | 1592 | if (m_mwProgressBar!=0) |
9953 | cbradney | 1593 | m_mwProgressBar->setValue(DOC.childNodes().count()); |
5653 | cbradney | 1594 | return true; |
1595 | // return false; |
||
1596 | } |
||
1597 | |||
1598 | |||
1599 | // Low level plugin API |
||
1600 | int scribus134format_getPluginAPIVersion() |
||
1601 | { |
||
1602 | return PLUGIN_API_VERSION; |
||
1603 | } |
||
1604 | |||
1605 | ScPlugin* scribus134format_getPlugin() |
||
1606 | { |
||
1607 | Scribus134Format* plug = new Scribus134Format(); |
||
1608 | Q_CHECK_PTR(plug); |
||
1609 | return plug; |
||
1610 | } |
||
1611 | |||
1612 | void scribus134format_freePlugin(ScPlugin* plugin) |
||
1613 | { |
||
1614 | Scribus134Format* plug = dynamic_cast<Scribus134Format*>(plugin); |
||
1615 | Q_ASSERT(plug); |
||
1616 | delete plug; |
||
1617 | } |
||
1618 | |||
1619 | |||
6733 | avox |