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