Rev 4584 | Rev 4618 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4430 | 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 | */ |
||
3 | paul | 7 | /*************************************************************************** |
8 | scribusXml.cpp the document xml library for scribus |
||
9 | ------------------- |
||
10 | begin : Sam Jul 14 10:00:00 CEST 2001 |
||
167 | Franz | 11 | copyright : (C) 2001 by Christian T�p |
3 | paul | 12 | email : christian.toepp@mr-ct@gmx.de |
13 | ***************************************************************************/ |
||
75 | Franz | 14 | |
3 | paul | 15 | #include "scribusXml.h" |
16 | #include "scribusXml.moc" |
||
17 | #include <qfile.h> |
||
18 | #include <qtextstream.h> |
||
19 | #include <qapplication.h> |
||
20 | #include <qtl.h> |
||
21 | #include <qcursor.h> |
||
22 | #include <qregexp.h> |
||
23 | #include <qdir.h> |
||
24 | #include <qtextcodec.h> |
||
25 | #include <cstdlib> |
||
26 | #include <cmath> |
||
27 | #include "missing.h" |
||
3670 | cbradney | 28 | #include "page.h" |
456 | fschmid | 29 | #include "pageitem.h" |
1525 | cbradney | 30 | #include "units.h" |
2834 | cbradney | 31 | #include "prefsmanager.h" |
3252 | craig | 32 | #include "scribusview.h" |
4546 | subik | 33 | #include "commonstrings.h" |
128 | Franz | 34 | |
3646 | craig | 35 | // We use some common routines defined in fileloader.h |
36 | #include "fileloader.h" |
||
37 | |||
1542 | cbradney | 38 | #include <iostream> |
39 | |||
2688 | craig | 40 | #include "scconfig.h" |
128 | Franz | 41 | |
3 | paul | 42 | #ifdef HAVE_LIBZ |
43 | #include <zlib.h> |
||
44 | #endif |
||
2531 | craig | 45 | #include "util.h" |
325 | Franz | 46 | |
504 | cbradney | 47 | using namespace std; |
48 | |||
2834 | cbradney | 49 | ScriXmlDoc::ScriXmlDoc() |
50 | { |
||
51 | prefsManager=PrefsManager::instance(); |
||
52 | } |
||
53 | |||
4546 | subik | 54 | |
383 | Franz | 55 | /*! |
56 | \fn ScriXmlDoc::IsScribus(QString fileName) |
||
421 | Franz | 57 | \author Frederic Dubuy <effediwhy@gmail.com>, Petr Vanek |
58 | \date august 17th 2004, 10/03/2004 |
||
59 | \brief Preliminary Scribus file validator. totally rewritten when fixing crash bug #1092. It's much simpler now. |
||
383 | Franz | 60 | \param Qtring filename of file to test |
61 | \retval true = Scribus format file, false : not Scribus |
||
62 | */ |
||
63 | bool ScriXmlDoc::IsScribus(QString fileName) |
||
64 | { |
||
3646 | craig | 65 | QString fText(FileLoader::readSLA(fileName)); |
2877 | cbradney | 66 | if ((fText.isEmpty()) || (!fText.startsWith("<SCRIBUS")) || (fText.contains("<PAGE ", true) == 0)) |
3646 | craig | 67 | return false; |
421 | Franz | 68 | return true; |
383 | Franz | 69 | } |
70 | |||
3197 | fschmid | 71 | void ScriXmlDoc::GetItemText(QDomElement *it, ScribusDoc *doc, bool VorLFound, bool impo, PageItem* obj) |
332 | Franz | 72 | { |
3197 | fschmid | 73 | QString tmp2, tmf, tmpf, tmp3; |
517 | fschmid | 74 | tmp2 = it->attribute("CH"); |
75 | tmp2.replace(QRegExp("\r"), QChar(5)); |
||
76 | tmp2.replace(QRegExp("\n"), QChar(5)); |
||
77 | tmp2.replace(QRegExp("\t"), QChar(4)); |
||
1194 | fschmid | 78 | tmpf = it->attribute("CFONT", doc->toolSettings.defFont); |
3197 | fschmid | 79 | bool unknown = false; |
80 | struct ScText *hg; |
||
81 | Foi* dummy; |
||
82 | if ((!prefsManager->appPrefs.AvailFonts.find(tmpf)) || (!prefsManager->appPrefs.AvailFonts[tmpf]->UseFont)) |
||
1428 | fschmid | 83 | { |
3197 | fschmid | 84 | bool isThere = false; |
85 | for (uint dl = 0; dl < dummyFois.count(); ++dl) |
||
1428 | fschmid | 86 | { |
3544 | avox | 87 | if (dummyFois.at(dl)->scName() == tmpf) |
1789 | fschmid | 88 | { |
3197 | fschmid | 89 | isThere = true; |
90 | dummy = dummyFois.at(dl); |
||
91 | break; |
||
1789 | fschmid | 92 | } |
1428 | fschmid | 93 | } |
3197 | fschmid | 94 | if (!isThere) |
1428 | fschmid | 95 | { |
3577 | fschmid | 96 | dummy = new Foi(tmpf, "", tmpf, "", "", 1, false); |
3197 | fschmid | 97 | dummyFois.append(dummy); |
1428 | fschmid | 98 | } |
3197 | fschmid | 99 | unknown = true; |
100 | if ((!prefsManager->appPrefs.GFontSub.contains(tmpf)) || (!prefsManager->appPrefs.AvailFonts[prefsManager->appPrefs.GFontSub[tmpf]]->UseFont)) |
||
1789 | fschmid | 101 | { |
3197 | fschmid | 102 | newReplacement = true; |
103 | ReplacedFonts.insert(tmpf, prefsManager->appPrefs.toolSettings.defFont); |
||
1789 | fschmid | 104 | } |
3197 | fschmid | 105 | else |
106 | ReplacedFonts.insert(tmpf, prefsManager->appPrefs.GFontSub[tmpf]); |
||
1428 | fschmid | 107 | } |
332 | Franz | 108 | else |
1428 | fschmid | 109 | { |
3197 | fschmid | 110 | if (!doc->UsedFonts.contains(tmpf)) |
111 | { |
||
3544 | avox | 112 | // QFont fo = prefsManager->appPrefs.AvailFonts[tmpf]->Font; |
113 | // fo.setPointSize(qRound(doc->toolSettings.defSize / 10.0)); |
||
114 | doc->AddFont(tmpf); |
||
3197 | fschmid | 115 | } |
1428 | fschmid | 116 | } |
4026 | craig | 117 | int size = qRound(it->attribute("CSIZE").toDouble() * 10); |
3197 | fschmid | 118 | QString fcolor = it->attribute("CCOLOR"); |
2382 | fschmid | 119 | int extra; |
120 | if (it->hasAttribute("CEXTRA")) |
||
4026 | craig | 121 | extra = qRound(it->attribute("CEXTRA").toDouble() / it->attribute("CSIZE").toDouble() * 1000.0); |
2382 | fschmid | 122 | else |
4026 | craig | 123 | extra = it->attribute("CKERN").toInt(); |
124 | int shade = it->attribute("CSHADE").toInt(); |
||
125 | int style = it->attribute("CSTYLE").toInt() & 255; |
||
126 | int ab = it->attribute("CAB", "0").toInt(); |
||
4546 | subik | 127 | QString stroke = it->attribute("CSTROKE",CommonStrings::None); |
4026 | craig | 128 | int shade2 = it->attribute("CSHADE2", "100").toInt(); |
129 | int scale = qRound(it->attribute("CSCALE", "100").toDouble() * 10); |
||
130 | int scalev = qRound(it->attribute("CSCALEV", "100").toDouble() * 10); |
||
131 | int base = qRound(it->attribute("CBASE", "0").toDouble() * 10); |
||
132 | int shX = qRound(it->attribute("CSHX", "5").toDouble() * 10); |
||
133 | int shY = qRound(it->attribute("CSHY", "-5").toDouble() * 10); |
||
134 | int outL = qRound(it->attribute("COUT", "1").toDouble() * 10); |
||
135 | int ulp = qRound(it->attribute("CULP", "-0.1").toDouble() * 10); |
||
136 | int ulw = qRound(it->attribute("CULW", "-0.1").toDouble() * 10); |
||
137 | int stp = qRound(it->attribute("CSTP", "-0.1").toDouble() * 10); |
||
138 | int stw = qRound(it->attribute("CSTW", "-0.1").toDouble() * 10); |
||
517 | fschmid | 139 | for (uint cxx=0; cxx<tmp2.length(); ++cxx) |
3197 | fschmid | 140 | { |
141 | hg = new ScText; |
||
142 | hg->ch = tmp2.at(cxx); |
||
143 | if (hg->ch == QChar(5)) |
||
144 | hg->ch = QChar(13); |
||
145 | if (hg->ch == QChar(4)) |
||
146 | hg->ch = QChar(9); |
||
147 | if (unknown) |
||
148 | hg->cfont = dummy; |
||
149 | else |
||
150 | hg->cfont = (*doc->AllFonts)[tmpf]; |
||
151 | hg->csize = size; |
||
152 | hg->ccolor = fcolor; |
||
153 | hg->cextra = extra; |
||
154 | hg->cshade = shade; |
||
155 | hg->cselect = false; |
||
156 | hg->cstyle = style; |
||
157 | if (impo) |
||
158 | { |
||
159 | if (VorLFound) |
||
160 | hg->cab = DoVorl[ab].toUInt(); |
||
161 | else |
||
162 | { |
||
163 | if (ab < 5) |
||
164 | hg->cab = ab; |
||
165 | else |
||
166 | hg->cab = 0; |
||
167 | } |
||
168 | } |
||
169 | else |
||
170 | hg->cab = ab; |
||
171 | hg->cstroke = stroke; |
||
172 | hg->cshade2 = shade2; |
||
173 | hg->cscale = QMIN(QMAX(scale, 100), 4000); |
||
174 | hg->cscalev = QMIN(QMAX(scalev, 100), 4000); |
||
175 | hg->cbase = base; |
||
176 | hg->cshadowx = shX; |
||
177 | hg->cshadowy = shY; |
||
178 | hg->coutline = outL; |
||
179 | hg->cunderpos = ulp; |
||
180 | hg->cunderwidth = ulw; |
||
181 | hg->cstrikepos = stp; |
||
182 | hg->cstrikewidth = stw; |
||
183 | hg->xp = 0; |
||
184 | hg->yp = 0; |
||
185 | hg->PRot = 0; |
||
186 | hg->PtransX = 0; |
||
187 | hg->PtransY = 0; |
||
188 | hg->cembedded = 0; |
||
189 | obj->itemText.append(hg); |
||
190 | } |
||
191 | return; |
||
517 | fschmid | 192 | } |
193 | |||
2834 | cbradney | 194 | QString ScriXmlDoc::AskForFont(SCFonts &avail, QString fStr, ScribusDoc *doc) |
517 | fschmid | 195 | { |
3544 | avox | 196 | // QFont fo; |
517 | fschmid | 197 | QString tmpf = fStr; |
198 | if ((!avail.find(tmpf)) || (!avail[tmpf]->UseFont)) |
||
340 | Franz | 199 | { |
2834 | cbradney | 200 | if ((!prefsManager->appPrefs.GFontSub.contains(tmpf)) || (!avail[prefsManager->appPrefs.GFontSub[tmpf]]->UseFont)) |
340 | Franz | 201 | { |
517 | fschmid | 202 | qApp->setOverrideCursor(QCursor(arrowCursor), true); |
2834 | cbradney | 203 | MissingFont *dia = new MissingFont(0, tmpf, doc); |
517 | fschmid | 204 | dia->exec(); |
713 | cbradney | 205 | tmpf = dia->getReplacementFont(); |
517 | fschmid | 206 | delete dia; |
207 | qApp->setOverrideCursor(QCursor(waitCursor), true); |
||
2834 | cbradney | 208 | prefsManager->appPrefs.GFontSub[fStr] = tmpf; |
340 | Franz | 209 | } |
517 | fschmid | 210 | else |
2834 | cbradney | 211 | tmpf = prefsManager->appPrefs.GFontSub[tmpf]; |
1166 | fschmid | 212 | ReplacedFonts[fStr] = tmpf; |
340 | Franz | 213 | } |
1786 | fschmid | 214 | if (!doc->UsedFonts.contains(tmpf)) |
215 | { |
||
3544 | avox | 216 | // fo = avail[tmpf]->Font; |
217 | // fo.setPointSize(qRound(doc->toolSettings.defSize / 10.0)); |
||
218 | doc->AddFont(tmpf); |
||
1786 | fschmid | 219 | } |
517 | fschmid | 220 | DoFonts[fStr] = tmpf; |
221 | return tmpf; |
||
332 | Franz | 222 | } |
223 | |||
517 | fschmid | 224 | void ScriXmlDoc::SetItemProps(QDomElement *ob, PageItem* item, bool newFormat) |
332 | Franz | 225 | { |
2881 | fschmid | 226 | double xf, yf; |
332 | Franz | 227 | QString tmp, tmpy; |
522 | fschmid | 228 | if (newFormat) |
229 | ob->setAttribute("OwnPage", item->OwnPage); |
||
1460 | cbradney | 230 | ob->setAttribute("PTYPE",item->itemType()); |
3903 | cbradney | 231 | ob->setAttribute("XPOS",item->xPos()); |
232 | ob->setAttribute("YPOS",item->yPos()); |
||
3934 | cbradney | 233 | ob->setAttribute("WIDTH",item->width()); |
234 | ob->setAttribute("HEIGHT",item->height()); |
||
3989 | cbradney | 235 | ob->setAttribute("RADRECT",item->cornerRadius()); |
332 | Franz | 236 | ob->setAttribute("FRTYPE", item->FrameType); |
237 | ob->setAttribute("CLIPEDIT", item->ClipEdited ? 1 : 0); |
||
4580 | cbradney | 238 | ob->setAttribute("PWIDTH",item->lineWidth()); |
1394 | cbradney | 239 | ob->setAttribute("PCOLOR",item->fillColor()); |
240 | ob->setAttribute("PCOLOR2",item->lineColor()); |
||
332 | Franz | 241 | ob->setAttribute("TXTFILL",item->TxtFill); |
242 | ob->setAttribute("TXTSTROKE",item->TxtStroke); |
||
243 | ob->setAttribute("TXTSTRSH",item->ShTxtStroke); |
||
244 | ob->setAttribute("TXTFILLSH",item->ShTxtFill); |
||
2242 | fschmid | 245 | ob->setAttribute("TXTSCALE",item->TxtScale / 10.0); |
246 | ob->setAttribute("TXTSCALEV",item->TxtScaleV / 10.0); |
||
247 | ob->setAttribute("TXTBASE",item->TxtBase / 10.0); |
||
2247 | fschmid | 248 | ob->setAttribute("TXTSHX",item->TxtShadowX / 10.0); |
249 | ob->setAttribute("TXTSHY",item->TxtShadowY / 10.0); |
||
2257 | fschmid | 250 | ob->setAttribute("TXTOUT",item->TxtOutline / 10.0); |
2262 | fschmid | 251 | ob->setAttribute("TXTULP",item->TxtUnderPos / 10.0); |
252 | ob->setAttribute("TXTULW",item->TxtUnderWidth / 10.0); |
||
2272 | fschmid | 253 | ob->setAttribute("TXTSTP",item->TxtStrikePos / 10.0); |
254 | ob->setAttribute("TXTSTW",item->TxtStrikeWidth / 10.0); |
||
332 | Franz | 255 | ob->setAttribute("TXTSTYLE",item->TxTStyle); |
256 | ob->setAttribute("COLUMNS", item->Cols); |
||
257 | ob->setAttribute("COLGAP", item->ColGap); |
||
258 | ob->setAttribute("NAMEDLST",item->NamedLStyle); |
||
1394 | cbradney | 259 | ob->setAttribute("SHADE",item->fillShade()); |
260 | ob->setAttribute("SHADE2",item->lineShade()); |
||
332 | Franz | 261 | ob->setAttribute("GRTYP",item->GrType); |
3934 | cbradney | 262 | ob->setAttribute("ROT",item->rotation()); |
332 | Franz | 263 | ob->setAttribute("PLINEART",item->PLineArt); |
264 | ob->setAttribute("PLINEEND", item->PLineEnd); |
||
265 | ob->setAttribute("PLINEJOIN", item->PLineJoin); |
||
4584 | cbradney | 266 | ob->setAttribute("LINESP",item->lineSpacing()); |
267 | ob->setAttribute("LINESPMode", item->lineSpacingMode()); |
||
2382 | fschmid | 268 | ob->setAttribute("TXTKERN",item->ExtraV); |
3985 | cbradney | 269 | ob->setAttribute("LOCALSCX",item->imageXScale()); |
270 | ob->setAttribute("LOCALSCY",item->imageYScale()); |
||
271 | ob->setAttribute("LOCALX",item->imageXOffset()); |
||
272 | ob->setAttribute("LOCALY",item->imageYOffset()); |
||
4492 | cbradney | 273 | ob->setAttribute("PICART", item->imageShown() ? 1 : 0); |
332 | Franz | 274 | ob->setAttribute("PLTSHOW", item->PoShow ? 1 : 0); |
275 | ob->setAttribute("BASEOF", item->BaseOffs); |
||
1392 | cbradney | 276 | ob->setAttribute("FLIPPEDH", item->imageFlippedH()); |
277 | ob->setAttribute("FLIPPEDV", item->imageFlippedV()); |
||
4335 | fschmid | 278 | /* ob->setAttribute("BBOXX",item->BBoxX); |
279 | ob->setAttribute("BBOXH",item->BBoxH); */ |
||
4073 | cbradney | 280 | ob->setAttribute("IFONT",item->font()); |
281 | ob->setAttribute("ISIZE",item->fontSize() / 10.0 ); |
||
332 | Franz | 282 | ob->setAttribute("SCALETYPE", item->ScaleType ? 1 : 0); |
283 | ob->setAttribute("RATIO", item->AspectRatio ? 1 : 0); |
||
2449 | cbradney | 284 | ob->setAttribute("PRINTABLE", item->printable() ? 1 : 0); |
4084 | cbradney | 285 | if(item->isAnnotation()) |
332 | Franz | 286 | { |
287 | ob->setAttribute("ANNOTATION",1); |
||
4084 | cbradney | 288 | ob->setAttribute("ANTYPE", item->annotation().Type()); |
289 | ob->setAttribute("ANACTION", item->annotation().Action()); |
||
290 | ob->setAttribute("ANEACT", item->annotation().E_act()); |
||
291 | ob->setAttribute("ANXACT", item->annotation().X_act()); |
||
292 | ob->setAttribute("ANDACT", item->annotation().D_act()); |
||
293 | ob->setAttribute("ANFOACT", item->annotation().Fo_act()); |
||
294 | ob->setAttribute("ANBLACT", item->annotation().Bl_act()); |
||
295 | ob->setAttribute("ANKACT", item->annotation().K_act()); |
||
296 | ob->setAttribute("ANFACT", item->annotation().F_act()); |
||
297 | ob->setAttribute("ANVACT", item->annotation().V_act()); |
||
298 | ob->setAttribute("ANCACT", item->annotation().C_act()); |
||
299 | if (item->annotation().ActionType() == 8) |
||
300 | ob->setAttribute("ANEXTERN", item->annotation().Extern()); |
||
332 | Franz | 301 | else |
4084 | cbradney | 302 | ob->setAttribute("ANEXTERN", Path2Relative(item->annotation().Extern())); |
303 | ob->setAttribute("ANZIEL", item->annotation().Ziel()); |
||
304 | ob->setAttribute("ANACTYP", item->annotation().ActionType()); |
||
305 | ob->setAttribute("ANTOOLTIP", item->annotation().ToolTip()); |
||
306 | ob->setAttribute("ANBWID", item->annotation().Bwid()); |
||
307 | ob->setAttribute("ANBSTY", item->annotation().Bsty()); |
||
308 | ob->setAttribute("ANFEED", item->annotation().Feed()); |
||
309 | ob->setAttribute("ANFLAG", item->annotation().Flag()); |
||
310 | ob->setAttribute("ANFONT", item->annotation().Font()); |
||
311 | ob->setAttribute("ANFORMAT", item->annotation().Format()); |
||
312 | ob->setAttribute("ANROLL", item->annotation().RollOver()); |
||
313 | ob->setAttribute("ANDOWN", item->annotation().Down()); |
||
314 | ob->setAttribute("ANVIS", item->annotation().Vis()); |
||
315 | ob->setAttribute("ANMC", item->annotation().MaxChar()); |
||
316 | ob->setAttribute("ANCHK", item->annotation().IsChk()); |
||
317 | ob->setAttribute("ANAA", item->annotation().AAact()); |
||
318 | ob->setAttribute("ANCHKS", item->annotation().ChkStil()); |
||
319 | ob->setAttribute("ANBCOL", item->annotation().borderColor()); |
||
320 | ob->setAttribute("ANHTML", item->annotation().HTML()); |
||
321 | ob->setAttribute("ANICON", item->annotation().UseIcons()); |
||
322 | ob->setAttribute("ANPLACE", item->annotation().IPlace()); |
||
323 | ob->setAttribute("ANSCALE", item->annotation().ScaleW()); |
||
332 | Franz | 324 | } |
325 | else |
||
326 | ob->setAttribute("ANNOTATION",0); |
||
1361 | tsoots | 327 | ob->setAttribute("ANNAME", !item->AutoName ? item->itemName() : QString("")); |
1653 | craig | 328 | ob->setAttribute("TEXTFLOW", item->textFlowsAroundFrame() ? 1 : 0); |
329 | ob->setAttribute("TEXTFLOW2", item->textFlowUsesBoundingBox() ? 1 : 0); |
||
1656 | craig | 330 | ob->setAttribute("TEXTFLOW3", item->textFlowUsesContourLine() ? 1 : 0); |
332 | Franz | 331 | ob->setAttribute("AUTOTEXT", item->isAutoText ? 1 : 0); |
3988 | cbradney | 332 | ob->setAttribute("EXTRA",item->textToFrameDistLeft()); |
333 | ob->setAttribute("TEXTRA",item->textToFrameDistTop()); |
||
334 | ob->setAttribute("BEXTRA",item->textToFrameDistBottom()); |
||
335 | ob->setAttribute("REXTRA",item->textToFrameDistRight()); |
||
3625 | avox | 336 | if (((item->asImageFrame()) || (item->asTextFrame())) && (!item->Pfile.isEmpty())) |
332 | Franz | 337 | ob->setAttribute("PFILE",Path2Relative(item->Pfile)); |
338 | else |
||
339 | ob->setAttribute("PFILE",""); |
||
2877 | cbradney | 340 | if (!item->Pfile2.isEmpty()) |
332 | Franz | 341 | ob->setAttribute("PFILE2",Path2Relative(item->Pfile2)); |
342 | else |
||
343 | ob->setAttribute("PFILE2",""); |
||
2877 | cbradney | 344 | if (!item->Pfile3.isEmpty()) |
332 | Franz | 345 | ob->setAttribute("PFILE3",Path2Relative(item->Pfile3)); |
346 | else |
||
347 | ob->setAttribute("PFILE3",""); |
||
348 | ob->setAttribute("PRFILE",item->IProfile); |
||
349 | ob->setAttribute("EPROF", item->EmProfile); |
||
350 | ob->setAttribute("IRENDER",item->IRender); |
||
351 | ob->setAttribute("EMBEDDED", item->UseEmbedded ? 1 : 0); |
||
1392 | cbradney | 352 | ob->setAttribute("LOCK", item->locked() ? 1 : 0); |
353 | ob->setAttribute("LOCKR", item->sizeLocked() ? 1 : 0); |
||
3988 | cbradney | 354 | ob->setAttribute("REVERS", item->reversed() ? 1 : 0); |
1394 | cbradney | 355 | ob->setAttribute("TransValue", item->fillTransparency()); |
356 | ob->setAttribute("TransValueS", item->lineTransparency()); |
||
332 | Franz | 357 | ob->setAttribute("isTableItem", static_cast<int>(item->isTableItem)); |
358 | ob->setAttribute("TopLine", static_cast<int>(item->TopLine)); |
||
359 | ob->setAttribute("LeftLine", static_cast<int>(item->LeftLine)); |
||
360 | ob->setAttribute("RightLine", static_cast<int>(item->RightLine)); |
||
361 | ob->setAttribute("BottomLine", static_cast<int>(item->BottomLine)); |
||
362 | if (item->isTableItem) |
||
363 | { |
||
364 | if (item->TopLink != 0) |
||
365 | ob->setAttribute("TopLINK", item->TopLink->ItemNr); |
||
366 | else |
||
367 | ob->setAttribute("TopLINK", -1); |
||
368 | if (item->LeftLink != 0) |
||
369 | ob->setAttribute("LeftLINK", item->LeftLink->ItemNr); |
||
370 | else |
||
371 | ob->setAttribute("LeftLINK", -1); |
||
372 | if (item->RightLink != 0) |
||
373 | ob->setAttribute("RightLINK", item->RightLink->ItemNr); |
||
374 | else |
||
375 | ob->setAttribute("RightLINK", -1); |
||
376 | if (item->BottomLink != 0) |
||
377 | ob->setAttribute("BottomLINK", item->BottomLink->ItemNr); |
||
378 | else |
||
379 | ob->setAttribute("BottomLINK", -1); |
||
380 | ob->setAttribute("OwnLINK", item->ItemNr); |
||
381 | } |
||
382 | ob->setAttribute("NUMDASH", static_cast<int>(item->DashValues.count())); |
||
383 | QString dlp = ""; |
||
384 | QValueList<double>::Iterator dax; |
||
385 | for (dax = item->DashValues.begin(); dax != item->DashValues.end(); ++dax) |
||
386 | dlp += tmp.setNum((*dax)) + " "; |
||
387 | ob->setAttribute("DASHS", dlp); |
||
388 | ob->setAttribute("DASHOFF", item->DashOffset); |
||
389 | ob->setAttribute("NUMPO",item->PoLine.size()); |
||
390 | QString polp = ""; |
||
391 | for (uint nxx=0; nxx<item->PoLine.size(); ++nxx) |
||
392 | { |
||
393 | item->PoLine.point(nxx, &xf, &yf); |
||
394 | polp += tmp.setNum(xf) + " " + tmpy.setNum(yf) + " "; |
||
395 | } |
||
396 | ob->setAttribute("POCOOR", polp); |
||
340 | Franz | 397 | ob->setAttribute("NUMCO",item->ContourLine.size()); |
398 | QString colp = ""; |
||
399 | for (uint nxx=0; nxx<item->ContourLine.size(); ++nxx) |
||
400 | { |
||
401 | item->ContourLine.point(nxx, &xf, &yf); |
||
402 | colp += tmp.setNum(xf) + " " + tmpy.setNum(yf) + " "; |
||
403 | } |
||
404 | ob->setAttribute("COCOOR", colp); |
||
332 | Franz | 405 | ob->setAttribute("NUMGROUP", static_cast<int>(item->Groups.count())); |
406 | QString glp = ""; |
||
407 | QValueStack<int>::Iterator nx; |
||
408 | for (nx = item->Groups.begin(); nx != item->Groups.end(); ++nx) |
||
409 | glp += tmp.setNum((*nx)) + " "; |
||
410 | ob->setAttribute("GROUPS", glp); |
||
411 | ob->setAttribute("LANGUAGE", item->Language); |
||
4061 | craig | 412 | ob->setAttribute("startArrowIndex", item->startArrowIndex()); |
413 | ob->setAttribute("endArrowIndex", item->endArrowIndex()); |
||
332 | Franz | 414 | } |
415 | |||
118 | Franz | 416 | bool ScriXmlDoc::ReadLStyles(QString fileName, QMap<QString,multiLine> *Sty) |
417 | { |
||
418 | QDomDocument docu("scridoc"); |
||
3646 | craig | 419 | QString f(FileLoader::readSLA(fileName)); |
2877 | cbradney | 420 | if (f.isEmpty()) |
118 | Franz | 421 | return false; |
422 | if(!docu.setContent(f)) |
||
423 | return false; |
||
424 | QDomElement elem=docu.documentElement(); |
||
425 | if ((elem.tagName() != "SCRIBUS") && (elem.tagName() != "SCRIBUSUTF8")) |
||
426 | return false; |
||
427 | QDomNode DOC=elem.firstChild(); |
||
428 | while(!DOC.isNull()) |
||
167 | Franz | 429 | { |
118 | Franz | 430 | QDomElement dc=DOC.toElement(); |
431 | QDomNode PAGE=DOC.firstChild(); |
||
432 | while(!PAGE.isNull()) |
||
167 | Franz | 433 | { |
118 | Franz | 434 | QDomElement pg=PAGE.toElement(); |
435 | if(pg.tagName()=="MultiLine") |
||
167 | Franz | 436 | { |
118 | Franz | 437 | multiLine ml; |
438 | QDomNode MuLn = PAGE.firstChild(); |
||
439 | while(!MuLn.isNull()) |
||
167 | Franz | 440 | { |
118 | Franz | 441 | QDomElement MuL = MuLn.toElement(); |
1065 | cbradney | 442 | struct SingleLine sl; |
118 | Franz | 443 | sl.Color = MuL.attribute("Color"); |
4026 | craig | 444 | sl.Dash = MuL.attribute("Dash").toInt(); |
445 | sl.LineEnd = MuL.attribute("LineEnd").toInt(); |
||
446 | sl.LineJoin = MuL.attribute("LineJoin").toInt(); |
||
447 | sl.Shade = MuL.attribute("Shade").toInt(); |
||
448 | sl.Width = MuL.attribute("Width").toDouble(); |
||
118 | Franz | 449 | ml.push_back(sl); |
450 | MuLn = MuLn.nextSibling(); |
||
167 | Franz | 451 | } |
118 | Franz | 452 | QString Nam = pg.attribute("Name"); |
453 | QString Nam2 = Nam; |
||
454 | int copyC = 1; |
||
455 | while (Sty->contains(Nam2)) |
||
167 | Franz | 456 | { |
118 | Franz | 457 | Nam2 = tr("Copy #%1 of ").arg(copyC)+Nam; |
458 | copyC++; |
||
167 | Franz | 459 | } |
118 | Franz | 460 | Sty->insert(Nam2, ml); |
167 | Franz | 461 | } |
118 | Franz | 462 | PAGE=PAGE.nextSibling(); |
167 | Franz | 463 | } |
118 | Franz | 464 | DOC=DOC.nextSibling(); |
167 | Franz | 465 | } |
118 | Franz | 466 | return true; |
467 | } |
||
468 | |||
2834 | cbradney | 469 | void ScriXmlDoc::GetStyle(QDomElement *pg, struct ParagraphStyle *vg, QValueList<ParagraphStyle> &docParagraphStyles, ScribusDoc* doc, bool fl) |
332 | Franz | 470 | { |
471 | bool fou; |
||
472 | QString tmpf, tmf, tmV; |
||
2282 | fschmid | 473 | double xf, xf2; |
332 | Franz | 474 | fou = false; |
2282 | fschmid | 475 | bool tabEQ = false; |
332 | Franz | 476 | vg->Vname = pg->attribute("NAME"); |
4026 | craig | 477 | vg->LineSpaMode = pg->attribute("LINESPMode", "0").toInt(); |
478 | vg->LineSpa = pg->attribute("LINESP").toDouble(); |
||
479 | vg->Indent = pg->attribute("INDENT", "0").toDouble(); |
||
480 | vg->First = pg->attribute("FIRST", "0").toDouble(); |
||
481 | vg->textAlignment = pg->attribute("ALIGN").toInt(); |
||
482 | vg->gapBefore = pg->attribute("VOR", "0").toDouble(); |
||
483 | vg->gapAfter = pg->attribute("NACH", "0").toDouble(); |
||
1194 | fschmid | 484 | tmpf = pg->attribute("FONT", doc->toolSettings.defFont); |
2877 | cbradney | 485 | if (tmpf.isEmpty()) |
1194 | fschmid | 486 | tmpf = doc->toolSettings.defFont; |
332 | Franz | 487 | tmf = tmpf; |
488 | if (!DoFonts.contains(tmpf)) |
||
2834 | cbradney | 489 | tmpf = AskForFont(prefsManager->appPrefs.AvailFonts, tmpf, doc); |
332 | Franz | 490 | else |
491 | tmpf = DoFonts[tmf]; |
||
492 | vg->Font = tmpf; |
||
4026 | craig | 493 | vg->FontSize = qRound(pg->attribute("FONTSIZE", "12").toDouble() * 10.0); |
494 | vg->Drop = static_cast<bool>(pg->attribute("DROP", "0").toInt()); |
||
495 | vg->DropLin = pg->attribute("DROPLIN", "2").toInt(); |
||
496 | vg->DropDist = pg->attribute("DROPDIST", "0").toDouble(); |
||
497 | vg->FontEffect = pg->attribute("EFFECT", "0").toInt(); |
||
1194 | fschmid | 498 | vg->FColor = pg->attribute("FCOLOR", doc->toolSettings.dBrush); |
4026 | craig | 499 | vg->FShade = pg->attribute("FSHADE", "100").toInt(); |
1194 | fschmid | 500 | vg->SColor = pg->attribute("SCOLOR", doc->toolSettings.dPen); |
4026 | craig | 501 | vg->SShade = pg->attribute("SSHADE", "100").toInt(); |
502 | vg->BaseAdj = static_cast<bool>(pg->attribute("BASE", "0").toInt()); |
||
503 | vg->txtShadowX = qRound(pg->attribute("TXTSHX", "5").toDouble() * 10); |
||
504 | vg->txtShadowY = qRound(pg->attribute("TXTSHY", "-5").toDouble() * 10); |
||
505 | vg->txtOutline = qRound(pg->attribute("TXTOUT", "1").toDouble() * 10); |
||
506 | vg->txtUnderPos = qRound(pg->attribute("TXTULP", "-0.1").toDouble() * 10); |
||
507 | vg->txtUnderWidth = qRound(pg->attribute("TXTULW", "-0.1").toDouble() * 10); |
||
508 | vg->txtStrikePos = qRound(pg->attribute("TXTSTP", "-0.1").toDouble() * 10); |
||
509 | vg->txtStrikeWidth = qRound(pg->attribute("TXTSTW", "-0.1").toDouble() * 10); |
||
510 | vg->scaleH = qRound(pg->attribute("SCALEH", "100").toDouble() * 10); |
||
511 | vg->scaleV = qRound(pg->attribute("SCALEV", "100").toDouble() * 10); |
||
512 | vg->baseOff = qRound(pg->attribute("BASEO", "0").toDouble() * 10); |
||
513 | vg->kernVal = qRound(pg->attribute("KERN", "0").toDouble() * 10); |
||
2282 | fschmid | 514 | vg->TabValues.clear(); |
4026 | craig | 515 | if ((pg->hasAttribute("NUMTAB")) && (pg->attribute("NUMTAB", "0").toInt() != 0)) |
332 | Franz | 516 | { |
2282 | fschmid | 517 | struct PageItem::TabRecord tb; |
332 | Franz | 518 | QString tmp = pg->attribute("TABS"); |
519 | QTextStream tgv(&tmp, IO_ReadOnly); |
||
520 | vg->TabValues.clear(); |
||
4026 | craig | 521 | for (int cxv = 0; cxv < pg->attribute("NUMTAB", "0").toInt(); cxv += 2) |
332 | Franz | 522 | { |
523 | tgv >> xf; |
||
2282 | fschmid | 524 | tgv >> xf2; |
525 | tb.tabPosition = xf2; |
||
526 | tb.tabType = static_cast<int>(xf); |
||
527 | tb.tabFillChar = QChar(); |
||
528 | vg->TabValues.append(tb); |
||
332 | Franz | 529 | } |
530 | tmp = ""; |
||
531 | } |
||
532 | else |
||
2282 | fschmid | 533 | { |
534 | QDomNode IT = pg->firstChild(); |
||
535 | while(!IT.isNull()) |
||
536 | { |
||
537 | QDomElement it = IT.toElement(); |
||
538 | if (it.tagName()=="Tabs") |
||
539 | { |
||
540 | struct PageItem::TabRecord tb; |
||
4026 | craig | 541 | tb.tabPosition = it.attribute("Pos").toDouble(); |
542 | tb.tabType = it.attribute("Type").toInt(); |
||
2282 | fschmid | 543 | QString tbCh = ""; |
544 | tbCh = it.attribute("Fill",""); |
||
2877 | cbradney | 545 | if (tbCh.isEmpty()) |
2282 | fschmid | 546 | tb.tabFillChar = QChar(); |
547 | else |
||
548 | tb.tabFillChar = tbCh[0]; |
||
549 | vg->TabValues.append(tb); |
||
550 | } |
||
551 | IT=IT.nextSibling(); |
||
552 | } |
||
553 | } |
||
1065 | cbradney | 554 | for (uint xx=0; xx<docParagraphStyles.count(); ++xx) |
332 | Franz | 555 | { |
1065 | cbradney | 556 | if (vg->Vname == docParagraphStyles[xx].Vname) |
332 | Franz | 557 | { |
2282 | fschmid | 558 | struct PageItem::TabRecord tb; |
559 | tabEQ = false; |
||
2677 | fschmid | 560 | if ((docParagraphStyles[xx].TabValues.count() == 0) && (vg->TabValues.count() == 0)) |
561 | tabEQ = true; |
||
562 | else |
||
2282 | fschmid | 563 | { |
2677 | fschmid | 564 | for (uint t1 = 0; t1 < docParagraphStyles[xx].TabValues.count(); t1++) |
2282 | fschmid | 565 | { |
2677 | fschmid | 566 | tb.tabPosition = docParagraphStyles[xx].TabValues[t1].tabPosition; |
567 | tb.tabType = docParagraphStyles[xx].TabValues[t1].tabType; |
||
568 | tb.tabFillChar = docParagraphStyles[xx].TabValues[t1].tabFillChar; |
||
569 | for (uint t2 = 0; t2 < vg->TabValues.count(); t2++) |
||
2282 | fschmid | 570 | { |
2677 | fschmid | 571 | struct PageItem::TabRecord tb2; |
572 | tb2.tabPosition = vg->TabValues[t2].tabPosition; |
||
573 | tb2.tabType = vg->TabValues[t2].tabType; |
||
574 | tb2.tabFillChar = vg->TabValues[t2].tabFillChar; |
||
575 | if ((tb2.tabFillChar == tb.tabFillChar) && (tb2.tabPosition == tb.tabPosition) && (tb2.tabType == tb.tabType)) |
||
576 | { |
||
577 | tabEQ = true; |
||
578 | break; |
||
579 | } |
||
580 | } |
||
581 | if (tabEQ) |
||
2282 | fschmid | 582 | break; |
583 | } |
||
584 | } |
||
4097 | cbradney | 585 | //Compare the attributes of the pasted styles vs existing ones |
1065 | cbradney | 586 | if ((vg->LineSpa == docParagraphStyles[xx].LineSpa) && |
2309 | fschmid | 587 | (vg->LineSpaMode == docParagraphStyles[xx].LineSpaMode) && |
1065 | cbradney | 588 | (vg->Indent == docParagraphStyles[xx].Indent) && |
589 | (vg->First == docParagraphStyles[xx].First) && |
||
590 | (vg->textAlignment == docParagraphStyles[xx].textAlignment) && |
||
591 | (vg->gapBefore == docParagraphStyles[xx].gapBefore) && |
||
592 | (vg->gapAfter == docParagraphStyles[xx].gapAfter) && |
||
2282 | fschmid | 593 | (vg->Font == docParagraphStyles[xx].Font) && (tabEQ) && |
1065 | cbradney | 594 | (vg->Drop == docParagraphStyles[xx].Drop) && |
595 | (vg->DropLin == docParagraphStyles[xx].DropLin) && |
||
2362 | fschmid | 596 | (vg->DropDist == docParagraphStyles[xx].DropDist) && |
1065 | cbradney | 597 | (vg->FontEffect == docParagraphStyles[xx].FontEffect) && |
598 | (vg->FColor == docParagraphStyles[xx].FColor) && |
||
599 | (vg->FShade == docParagraphStyles[xx].FShade) && |
||
600 | (vg->SColor == docParagraphStyles[xx].SColor) && |
||
601 | (vg->SShade == docParagraphStyles[xx].SShade) && |
||
602 | (vg->BaseAdj == docParagraphStyles[xx].BaseAdj) && |
||
2273 | fschmid | 603 | (vg->txtShadowX == docParagraphStyles[xx].txtShadowX) && |
604 | (vg->txtShadowY == docParagraphStyles[xx].txtShadowY) && |
||
605 | (vg->txtOutline == docParagraphStyles[xx].txtOutline) && |
||
606 | (vg->txtUnderPos == docParagraphStyles[xx].txtUnderPos) && |
||
607 | (vg->txtUnderWidth == docParagraphStyles[xx].txtUnderWidth) && |
||
608 | (vg->txtStrikePos == docParagraphStyles[xx].txtStrikePos) && |
||
609 | (vg->txtStrikeWidth == docParagraphStyles[xx].txtStrikeWidth) && |
||
2379 | fschmid | 610 | (vg->scaleH == docParagraphStyles[xx].scaleH) && |
611 | (vg->scaleV == docParagraphStyles[xx].scaleV) && |
||
612 | (vg->baseOff == docParagraphStyles[xx].baseOff) && |
||
613 | (vg->kernVal == docParagraphStyles[xx].kernVal) && |
||
1065 | cbradney | 614 | (vg->FontSize == docParagraphStyles[xx].FontSize)) |
335 | Franz | 615 | { |
616 | if (fl) |
||
617 | { |
||
618 | DoVorl[VorlC] = tmV.setNum(xx); |
||
619 | VorlC++; |
||
620 | } |
||
332 | Franz | 621 | fou = true; |
335 | Franz | 622 | } |
332 | Franz | 623 | else |
624 | { |
||
1065 | cbradney | 625 | vg->Vname = "Copy of "+docParagraphStyles[xx].Vname; |
332 | Franz | 626 | fou = false; |
627 | } |
||
628 | break; |
||
629 | } |
||
630 | } |
||
631 | if (!fou) |
||
632 | { |
||
1065 | cbradney | 633 | for (uint xx=0; xx< docParagraphStyles.count(); ++xx) |
332 | Franz | 634 | { |
2282 | fschmid | 635 | struct PageItem::TabRecord tb; |
636 | tabEQ = false; |
||
637 | for (uint t1 = 0; t1 < docParagraphStyles[xx].TabValues.count(); t1++) |
||
638 | { |
||
639 | tb.tabPosition = docParagraphStyles[xx].TabValues[t1].tabPosition; |
||
640 | tb.tabType = docParagraphStyles[xx].TabValues[t1].tabType; |
||
641 | tb.tabFillChar = docParagraphStyles[xx].TabValues[t1].tabFillChar; |
||
642 | for (uint t2 = 0; t2 < vg->TabValues.count(); t2++) |
||
643 | { |
||
644 | struct PageItem::TabRecord tb2; |
||
645 | tb2.tabPosition = vg->TabValues[t2].tabPosition; |
||
646 | tb2.tabType = vg->TabValues[t2].tabType; |
||
647 | tb2.tabFillChar = vg->TabValues[t2].tabFillChar; |
||
648 | if ((tb2.tabFillChar == tb.tabFillChar) && (tb2.tabPosition == tb.tabPosition) && (tb2.tabType == tb.tabType)) |
||
649 | { |
||
650 | tabEQ = true; |
||
651 | break; |
||
652 | } |
||
653 | } |
||
654 | if (tabEQ) |
||
655 | break; |
||
656 | } |
||
1065 | cbradney | 657 | if ((vg->LineSpa == docParagraphStyles[xx].LineSpa) && |
2309 | fschmid | 658 | (vg->LineSpaMode == docParagraphStyles[xx].LineSpaMode) && |
1065 | cbradney | 659 | (vg->Indent == docParagraphStyles[xx].Indent) && |
660 | (vg->First == docParagraphStyles[xx].First) && |
||
661 | (vg->textAlignment == docParagraphStyles[xx].textAlignment) && |
||
662 | (vg->gapBefore == docParagraphStyles[xx].gapBefore) && |
||
663 | (vg->gapAfter == docParagraphStyles[xx].gapAfter) && |
||
2282 | fschmid | 664 | (vg->Font == docParagraphStyles[xx].Font) && (tabEQ) && |
1065 | cbradney | 665 | (vg->Drop == docParagraphStyles[xx].Drop) && |
666 | (vg->DropLin == docParagraphStyles[xx].DropLin) && |
||
2362 | fschmid | 667 | (vg->DropDist == docParagraphStyles[xx].DropDist) && |
1065 | cbradney | 668 | (vg->FontEffect == docParagraphStyles[xx].FontEffect) && |
669 | (vg->FColor == docParagraphStyles[xx].FColor) && |
||
670 | (vg->FShade == docParagraphStyles[xx].FShade) && |
||
671 | (vg->SColor == docParagraphStyles[xx].SColor) && |
||
672 | (vg->SShade == docParagraphStyles[xx].SShade) && |
||
673 | (vg->BaseAdj == docParagraphStyles[xx].BaseAdj) && |
||
2273 | fschmid | 674 | (vg->txtShadowX == docParagraphStyles[xx].txtShadowX) && |
675 | (vg->txtShadowY == docParagraphStyles[xx].txtShadowY) && |
||
676 | (vg->txtOutline == docParagraphStyles[xx].txtOutline) && |
||
677 | (vg->txtUnderPos == docParagraphStyles[xx].txtUnderPos) && |
||
678 | (vg->txtUnderWidth == docParagraphStyles[xx].txtUnderWidth) && |
||
679 | (vg->txtStrikePos == docParagraphStyles[xx].txtStrikePos) && |
||
680 | (vg->txtStrikeWidth == docParagraphStyles[xx].txtStrikeWidth) && |
||
2379 | fschmid | 681 | (vg->scaleH == docParagraphStyles[xx].scaleH) && |
682 | (vg->scaleV == docParagraphStyles[xx].scaleV) && |
||
683 | (vg->baseOff == docParagraphStyles[xx].baseOff) && |
||
684 | (vg->kernVal == docParagraphStyles[xx].kernVal) && |
||
1065 | cbradney | 685 | (vg->FontSize == docParagraphStyles[xx].FontSize)) |
332 | Franz | 686 | { |
1065 | cbradney | 687 | vg->Vname = docParagraphStyles[xx].Vname; |
332 | Franz | 688 | fou = true; |
689 | if (fl) |
||
690 | { |
||
691 | DoVorl[VorlC] = tmV.setNum(xx); |
||
692 | VorlC++; |
||
693 | } |
||
694 | break; |
||
695 | } |
||
696 | } |
||
697 | } |
||
698 | if (!fou) |
||
699 | { |
||
1065 | cbradney | 700 | docParagraphStyles.append(*vg); |
332 | Franz | 701 | if (fl) |
702 | { |
||
1065 | cbradney | 703 | DoVorl[VorlC] = tmV.setNum(docParagraphStyles.count()-1); |
332 | Franz | 704 | VorlC++; |
705 | } |
||
706 | } |
||
707 | } |
||
708 | |||
2834 | cbradney | 709 | bool ScriXmlDoc::ReadStyles(QString fileName, ScribusDoc* doc) |
117 | Franz | 710 | { |
1065 | cbradney | 711 | struct ParagraphStyle vg; |
117 | Franz | 712 | QDomDocument docu("scridoc"); |
332 | Franz | 713 | QString tmpf, tmf; |
117 | Franz | 714 | DoFonts.clear(); |
3646 | craig | 715 | QString f (FileLoader::readSLA(fileName)); |
2877 | cbradney | 716 | if (f.isEmpty()) |
117 | Franz | 717 | return false; |
718 | if(!docu.setContent(f)) |
||
719 | return false; |
||
720 | QDomElement elem=docu.documentElement(); |
||
1884 | fschmid | 721 | if ((elem.tagName() != "SCRIBUS") && (elem.tagName() != "SCRIBUSUTF8") && (elem.tagName() != "SCRIBUSUTF8NEW")) |
117 | Franz | 722 | return false; |
723 | QDomNode DOC=elem.firstChild(); |
||
724 | while(!DOC.isNull()) |
||
167 | Franz | 725 | { |
117 | Franz | 726 | QDomElement dc=DOC.toElement(); |
727 | QDomNode PAGE=DOC.firstChild(); |
||
728 | while(!PAGE.isNull()) |
||
167 | Franz | 729 | { |
117 | Franz | 730 | QDomElement pg=PAGE.toElement(); |
731 | if(pg.tagName()=="STYLE") |
||
2834 | cbradney | 732 | GetStyle(&pg, &vg, docParagraphStyles, doc, false); |
117 | Franz | 733 | PAGE=PAGE.nextSibling(); |
167 | Franz | 734 | } |
117 | Franz | 735 | DOC=DOC.nextSibling(); |
167 | Franz | 736 | } |
117 | Franz | 737 | return true; |
738 | } |
||
739 | |||
3 | paul | 740 | bool ScriXmlDoc::ReadColors(QString fileName) |
741 | { |
||
742 | QDomDocument docu("scridoc"); |
||
3646 | craig | 743 | QString f(FileLoader::readSLA(fileName)); |
2877 | cbradney | 744 | if (f.isEmpty()) |
3 | paul | 745 | return false; |
746 | if(!docu.setContent(f)) |
||
747 | return false; |
||
748 | Farben.clear(); |
||
2886 | fschmid | 749 | ScColor lf = ScColor(); |
3 | paul | 750 | QDomElement elem=docu.documentElement(); |
1884 | fschmid | 751 | if ((elem.tagName() != "SCRIBUS") && (elem.tagName() != "SCRIBUSUTF8") && (elem.tagName() != "SCRIBUSUTF8NEW")) |
3 | paul | 752 | return false; |
753 | QDomNode DOC=elem.firstChild(); |
||
754 | while(!DOC.isNull()) |
||
167 | Franz | 755 | { |
3 | paul | 756 | QDomElement dc=DOC.toElement(); |
757 | QDomNode PAGE=DOC.firstChild(); |
||
758 | while(!PAGE.isNull()) |
||
167 | Franz | 759 | { |
3 | paul | 760 | QDomElement pg=PAGE.toElement(); |
516 | fschmid | 761 | // 10/25/2004 pv - None is "reserved" color. cannot be defined in any file... |
4546 | subik | 762 | if(pg.tagName()=="COLOR" && pg.attribute("NAME")!=CommonStrings::None) |
167 | Franz | 763 | { |
2883 | craig | 764 | if (pg.hasAttribute("CMYK")) |
765 | lf.setNamedColor(pg.attribute("CMYK")); |
||
766 | else |
||
767 | lf.fromQColor(QColor(pg.attribute("RGB"))); |
||
3057 | fschmid | 768 | if (pg.hasAttribute("Spot")) |
4026 | craig | 769 | lf.setSpotColor(static_cast<bool>(pg.attribute("Spot").toInt())); |
3057 | fschmid | 770 | else |
771 | lf.setSpotColor(false); |
||
3060 | fschmid | 772 | if (pg.hasAttribute("Register")) |
4026 | craig | 773 | lf.setRegistrationColor(static_cast<bool>(pg.attribute("Register").toInt())); |
3060 | fschmid | 774 | else |
775 | lf.setRegistrationColor(false); |
||
2883 | craig | 776 | Farben[pg.attribute("NAME")] = lf; |
167 | Franz | 777 | } |
3 | paul | 778 | PAGE=PAGE.nextSibling(); |
167 | Franz | 779 | } |
3 | paul | 780 | DOC=DOC.nextSibling(); |
167 | Franz | 781 | } |
3 | paul | 782 | return true; |
783 | } |
||
784 | |||
118 | Franz | 785 | bool ScriXmlDoc::ReadPageCount(QString fileName, int *num1, int *num2) |
3 | paul | 786 | { |
167 | Franz | 787 | QString PgNam; |
788 | int counter = 0; |
||
789 | int counter2 = 0; |
||
790 | MNames.clear(); |
||
791 | QDomDocument docu("scridoc"); |
||
3646 | craig | 792 | QString f(FileLoader::readSLA(fileName)); |
2877 | cbradney | 793 | if (f.isEmpty()) |
167 | Franz | 794 | return false; |
795 | if(!docu.setContent(f)) |
||
796 | return false; |
||
797 | QDomElement elem=docu.documentElement(); |
||
3197 | fschmid | 798 | if ((elem.tagName() != "SCRIBUS") && (elem.tagName() != "SCRIBUSUTF8") && (elem.tagName() != "SCRIBUSUTF8NEW")) |
167 | Franz | 799 | return false; |
800 | QDomNode DOC=elem.firstChild(); |
||
801 | while(!DOC.isNull()) |
||
3 | paul | 802 | { |
167 | Franz | 803 | QDomNode PAGE=DOC.firstChild(); |
804 | while(!PAGE.isNull()) |
||
3 | paul | 805 | { |
167 | Franz | 806 | QDomElement pg=PAGE.toElement(); |
3197 | fschmid | 807 | if (elem.tagName() == "SCRIBUSUTF8NEW") |
3 | paul | 808 | { |
167 | Franz | 809 | PgNam = pg.attribute("NAM", ""); |
3197 | fschmid | 810 | if(pg.tagName()=="PAGE") |
167 | Franz | 811 | counter++; |
3197 | fschmid | 812 | if(pg.tagName()=="MASTERPAGE") |
118 | Franz | 813 | { |
167 | Franz | 814 | counter2++; |
815 | MNames.append(PgNam); |
||
118 | Franz | 816 | } |
3 | paul | 817 | } |
3197 | fschmid | 818 | else |
819 | { |
||
820 | if(pg.tagName()=="PAGE") |
||
821 | { |
||
822 | PgNam = pg.attribute("NAM", ""); |
||
823 | if (PgNam.isEmpty()) |
||
824 | counter++; |
||
825 | else |
||
826 | { |
||
827 | counter2++; |
||
828 | MNames.append(PgNam); |
||
829 | } |
||
830 | } |
||
831 | } |
||
832 | PAGE=PAGE.nextSibling(); |
||
3 | paul | 833 | } |
3197 | fschmid | 834 | DOC=DOC.nextSibling(); |
3 | paul | 835 | } |
167 | Franz | 836 | *num1 = counter; |
837 | *num2 = counter2; |
||
838 | return true; |
||
3 | paul | 839 | } |
840 | |||
118 | Franz | 841 | bool ScriXmlDoc::ReadPage(QString fileName, SCFonts &avail, ScribusDoc *doc, ScribusView *view, int PageToLoad, bool Mpage) |
3 | paul | 842 | { |
1065 | cbradney | 843 | struct CopyPasteBuffer OB; |
844 | struct ParagraphStyle vg; |
||
167 | Franz | 845 | struct Layer la; |
846 | struct ScribusDoc::BookMa bok; |
||
847 | struct Linked Link; |
||
848 | PageItem *Neu; |
||
849 | LFrames.clear(); |
||
3646 | craig | 850 | QString tmV, tmp, tmpf, tmp2, tmp3, tmp4, PgNam, Defont, tmf; |
234 | Franz | 851 | QMap<int,int> TableID; |
852 | QPtrList<PageItem> TableItems; |
||
332 | Franz | 853 | int x, a, counter, baseobj; |
854 | double xf; |
||
167 | Franz | 855 | bool newVersion = false; |
856 | bool VorLFound = false; |
||
1119 | fschmid | 857 | QMap<int,int> layerTrans; |
858 | int maxLayer = 0; |
||
859 | int maxLevel = 0; |
||
860 | layerTrans.clear(); |
||
2955 | fschmid | 861 | uint layerCount=doc->layerCount(); |
2937 | cbradney | 862 | for (uint la2 = 0; la2 < layerCount; ++la2) |
1119 | fschmid | 863 | { |
864 | maxLayer = QMAX(doc->Layers[la2].LNr, maxLayer); |
||
865 | maxLevel = QMAX(doc->Layers[la2].Level, maxLevel); |
||
866 | } |
||
167 | Franz | 867 | DoVorl.clear(); |
868 | DoFonts.clear(); |
||
1194 | fschmid | 869 | DoFonts[doc->toolSettings.defFont] = doc->toolSettings.defFont; |
167 | Franz | 870 | DoVorl[0] = "0"; |
871 | DoVorl[1] = "1"; |
||
872 | DoVorl[2] = "2"; |
||
873 | DoVorl[3] = "3"; |
||
874 | DoVorl[4] = "4"; |
||
875 | VorlC = 5; |
||
876 | QDomDocument docu("scridoc"); |
||
3646 | craig | 877 | QString f(FileLoader::readSLA(fileName)); |
2877 | cbradney | 878 | if (f.isEmpty()) |
167 | Franz | 879 | return false; |
880 | if(!docu.setContent(f)) |
||
881 | return false; |
||
2886 | fschmid | 882 | ScColor lf = ScColor(); |
167 | Franz | 883 | QDomElement elem=docu.documentElement(); |
884 | if ((elem.tagName() != "SCRIBUS") && (elem.tagName() != "SCRIBUSUTF8")) |
||
885 | return false; |
||
886 | if (elem.hasAttribute("Version")) |
||
887 | newVersion = true; |
||
888 | QDomNode DOC=elem.firstChild(); |
||
889 | while(!DOC.isNull()) |
||
114 | Franz | 890 | { |
167 | Franz | 891 | QDomElement dc=DOC.toElement(); |
3 | paul | 892 | /* |
893 | * Attribute von DOCUMENT auslesen |
||
894 | */ |
||
167 | Franz | 895 | QDomNode PAGE=DOC.firstChild(); |
896 | while(!PAGE.isNull()) |
||
114 | Franz | 897 | { |
167 | Franz | 898 | QDomElement pg=PAGE.toElement(); |
516 | fschmid | 899 | // 10/25/2004 pv - None is "reserved" color. cannot be defined in any file... |
4546 | subik | 900 | if(pg.tagName()=="COLOR" && pg.attribute("NAME")!=CommonStrings::None) |
3 | paul | 901 | { |
167 | Franz | 902 | if (pg.hasAttribute("CMYK")) |
903 | lf.setNamedColor(pg.attribute("CMYK")); |
||
904 | else |
||
905 | lf.fromQColor(QColor(pg.attribute("RGB"))); |
||
906 | doc->PageColors[pg.attribute("NAME")] = lf; |
||
3 | paul | 907 | } |
167 | Franz | 908 | if(pg.tagName()=="STYLE") |
3 | paul | 909 | { |
2834 | cbradney | 910 | GetStyle(&pg, &vg, doc->docParagraphStyles, doc, true); |
167 | Franz | 911 | VorLFound = true; |
3 | paul | 912 | } |
167 | Franz | 913 | if(pg.tagName()=="JAVA") |
914 | doc->JavaScripts[pg.attribute("NAME")] = pg.attribute("SCRIPT"); |
||
915 | if(pg.tagName()=="LAYERS") |
||
3 | paul | 916 | { |
4026 | craig | 917 | la.LNr = pg.attribute("NUMMER").toInt(); |
918 | la.Level = pg.attribute("LEVEL").toInt(); |
||
167 | Franz | 919 | la.Name = pg.attribute("NAME"); |
4026 | craig | 920 | la.isViewable = pg.attribute("SICHTBAR").toInt(); |
921 | la.isPrintable = pg.attribute("DRUCKEN").toInt(); |
||
167 | Franz | 922 | bool laex = false; |
2955 | fschmid | 923 | uint layerCount=doc->layerCount(); |
2937 | cbradney | 924 | for (uint la2 = 0; la2 < layerCount; ++la2) |
3 | paul | 925 | { |
167 | Franz | 926 | if (doc->Layers[la2].Name == la.Name) |
1119 | fschmid | 927 | { |
167 | Franz | 928 | laex = true; |
1119 | fschmid | 929 | layerTrans.insert(la.LNr, doc->Layers[la2].LNr); |
930 | } |
||
3 | paul | 931 | } |
167 | Franz | 932 | if (!laex) |
1119 | fschmid | 933 | { |
934 | maxLayer++; |
||
935 | maxLevel++; |
||
936 | layerTrans.insert(la.LNr, maxLayer); |
||
937 | la.LNr = maxLayer; |
||
938 | la.Level = maxLevel; |
||
167 | Franz | 939 | doc->Layers.append(la); |
1119 | fschmid | 940 | } |
3 | paul | 941 | } |
167 | Franz | 942 | if(pg.tagName()=="Bookmark") |
3 | paul | 943 | { |
167 | Franz | 944 | bok.Title = pg.attribute("Title"); |
945 | bok.Text = pg.attribute("Text"); |
||
946 | bok.Aktion = pg.attribute("Aktion"); |
||
4026 | craig | 947 | bok.ItemNr = pg.attribute("ItemNr").toInt(); |
948 | bok.Seite = pg.attribute("Seite").toInt(); |
||
949 | bok.Element = pg.attribute("Element").toInt(); |
||
950 | bok.First = pg.attribute("First").toInt(); |
||
951 | bok.Last = pg.attribute("Last").toInt(); |
||
952 | bok.Prev = pg.attribute("Prev").toInt(); |
||
953 | bok.Next = pg.attribute("Next").toInt(); |
||
954 | bok.Parent = pg.attribute("Parent").toInt(); |
||
167 | Franz | 955 | doc->BookMarks.append(bok); |
3 | paul | 956 | } |
167 | Franz | 957 | if(pg.tagName()=="MultiLine") |
31 | Franz | 958 | { |
167 | Franz | 959 | multiLine ml; |
960 | QDomNode MuLn = PAGE.firstChild(); |
||
961 | while(!MuLn.isNull()) |
||
31 | Franz | 962 | { |
167 | Franz | 963 | QDomElement MuL = MuLn.toElement(); |
1065 | cbradney | 964 | struct SingleLine sl; |
167 | Franz | 965 | sl.Color = MuL.attribute("Color"); |
4026 | craig | 966 | sl.Dash = MuL.attribute("Dash").toInt(); |
967 | sl.LineEnd = MuL.attribute("LineEnd").toInt(); |
||
968 | sl.LineJoin = MuL.attribute("LineJoin").toInt(); |
||
969 | sl.Shade = MuL.attribute("Shade").toInt(); |
||
970 | sl.Width = MuL.attribute("Width").toDouble(); |
||
167 | Franz | 971 | ml.push_back(sl); |
972 | MuLn = MuLn.nextSibling(); |
||
31 | Franz | 973 | } |
167 | Franz | 974 | QString Nam = pg.attribute("Name"); |
975 | QString Nam2 = Nam; |
||
976 | int copyC = 1; |
||
977 | while (doc->MLineStyles.contains(Nam2)) |
||
118 | Franz | 978 | { |
167 | Franz | 979 | Nam2 = tr("Copy #%1 of ").arg(copyC)+Nam; |
980 | copyC++; |
||
118 | Franz | 981 | } |
167 | Franz | 982 | doc->MLineStyles.insert(Nam2, ml); |
31 | Franz | 983 | } |
4026 | craig | 984 | if ((pg.tagName()=="PAGE") && (pg.attribute("NUM").toInt() == PageToLoad)) |
114 | Franz | 985 | { |
3200 | cbradney | 986 | a = doc->currentPage->pageNr(); |
3268 | fschmid | 987 | if ((pg.attribute("NAM", "").isEmpty()) && (Mpage)) |
118 | Franz | 988 | { |
167 | Franz | 989 | PAGE=PAGE.nextSibling(); |
990 | continue; |
||
118 | Franz | 991 | } |
167 | Franz | 992 | if (Mpage) |
118 | Franz | 993 | { |
4026 | craig | 994 | doc->Pages->at(a)->LeftPg=pg.attribute("LEFT", "0").toInt(); |
3724 | cbradney | 995 | doc->Pages->at(a)->setPageName(pg.attribute("NAM","")); |
118 | Franz | 996 | } |
234 | Franz | 997 | TableItems.clear(); |
998 | TableID.clear(); |
||
3 | paul | 999 | /* |
1000 | * Attribute von PAGE auslesen |
||
1001 | */ |
||
4026 | craig | 1002 | if ((pg.hasAttribute("NumVGuides")) && (pg.attribute("NumVGuides", "0").toInt() != 0)) |
3 | paul | 1003 | { |
167 | Franz | 1004 | tmp = pg.attribute("VerticalGuides"); |
1005 | QTextStream fgv(&tmp, IO_ReadOnly); |
||
3724 | cbradney | 1006 | doc->Pages->at(a)->YGuides.clear(); |
4026 | craig | 1007 | for (int cxv = 0; cxv < pg.attribute("NumVGuides", "0").toInt(); ++cxv) |
3 | paul | 1008 | { |
167 | Franz | 1009 | fgv >> xf; |
3724 | cbradney | 1010 | doc->Pages->at(a)->YGuides.append(xf); |
3 | paul | 1011 | } |
3724 | cbradney | 1012 | qHeapSort(doc->Pages->at(a)->YGuides); |
167 | Franz | 1013 | tmp = ""; |
3 | paul | 1014 | } |
167 | Franz | 1015 | else |
3724 | cbradney | 1016 | doc->Pages->at(a)->YGuides.clear(); |
4026 | craig | 1017 | if ((pg.hasAttribute("NumHGuides")) && (pg.attribute("NumHGuides", "0").toInt() != 0)) |
3 | paul | 1018 | { |
167 | Franz | 1019 | tmp = pg.attribute("HorizontalGuides"); |
1020 | QTextStream fgh(&tmp, IO_ReadOnly); |
||
3724 | cbradney | 1021 | doc->Pages->at(a)->XGuides.clear(); |
4026 | craig | 1022 | for (int cxh = 0; cxh < pg.attribute("NumHGuides", "0").toInt(); ++cxh) |
3 | paul | 1023 | { |
167 | Franz | 1024 | fgh >> xf; |
3724 | cbradney | 1025 | doc->Pages->at(a)->XGuides.append(xf); |
3 | paul | 1026 | } |
3724 | cbradney | 1027 | qHeapSort(doc->Pages->at(a)->XGuides); |
167 | Franz | 1028 | tmp = ""; |
3 | paul | 1029 | } |
167 | Franz | 1030 | else |
3724 | cbradney | 1031 | doc->Pages->at(a)->XGuides.clear(); |
167 | Franz | 1032 | QDomNode OBJ=PAGE.firstChild(); |
3727 | cbradney | 1033 | counter = doc->Items->count(); |
167 | Franz | 1034 | baseobj = counter; |
1035 | while(!OBJ.isNull()) |
||
114 | Franz | 1036 | { |
167 | Franz | 1037 | QDomElement obj=OBJ.toElement(); |
3 | paul | 1038 | /* |
1039 | * Attribute von OBJECT auslesen |
||
1040 | */ |
||
4026 | craig | 1041 | if ((obj.attribute("NEXTITEM").toInt() != -1) && (obj.attribute("NEXTPAGE").toInt() == PageToLoad)) |
31 | Franz | 1042 | { |
4026 | craig | 1043 | if (obj.attribute("BACKITEM").toInt() == -1) |
31 | Franz | 1044 | { |
167 | Franz | 1045 | Link.Start = counter; |
1046 | Link.StPag = a; |
||
1047 | LFrames.append(Link); |
||
31 | Franz | 1048 | } |
1049 | } |
||
332 | Franz | 1050 | GetItemProps(newVersion, &obj, &OB); |
4026 | craig | 1051 | OB.Xpos = obj.attribute("XPOS").toDouble()+doc->Pages->at(a)->xOffset(); |
1052 | OB.Ypos=obj.attribute("YPOS").toDouble()+doc->Pages->at(a)->yOffset(); |
||
167 | Franz | 1053 | OB.NamedLStyle = obj.attribute("NAMEDLST", ""); |
1054 | if (!doc->MLineStyles.contains(OB.NamedLStyle)) |
||
1055 | OB.NamedLStyle = ""; |
||
4026 | craig | 1056 | OB.isBookmark=obj.attribute("BOOKMARK").toInt(); |
167 | Franz | 1057 | if ((OB.isBookmark) && (doc->BookMarks.count() == 0)) |
1058 | doc->OldBM = true; |
||
4026 | craig | 1059 | OB.BMnr = obj.attribute("BookNr", "0").toInt(); |
1060 | OB.textAlignment = DoVorl[obj.attribute("ALIGN", "0").toInt()].toUInt(); |
||
1194 | fschmid | 1061 | tmpf = obj.attribute("IFONT", doc->toolSettings.defFont); |
2877 | cbradney | 1062 | if (tmpf.isEmpty()) |
1194 | fschmid | 1063 | tmpf = doc->toolSettings.defFont; |
323 | Franz | 1064 | tmf = tmpf; |
1065 | if (!DoFonts.contains(tmpf)) |
||
2834 | cbradney | 1066 | tmpf = AskForFont(avail, tmpf, doc); |
323 | Franz | 1067 | else |
1068 | tmpf = DoFonts[tmf]; |
||
1069 | OB.IFont = tmpf; |
||
4026 | craig | 1070 | OB.LayerNr = layerTrans[obj.attribute("LAYER", "0").toInt()]; |
167 | Franz | 1071 | OB.Language = obj.attribute("LANGUAGE", doc->Language); |
1072 | tmp = ""; |
||
4026 | craig | 1073 | if ((obj.hasAttribute("GROUPS")) && (obj.attribute("NUMGROUP", "0").toInt() != 0)) |
3 | paul | 1074 | { |
167 | Franz | 1075 | tmp = obj.attribute("GROUPS"); |
1076 | QTextStream fg(&tmp, IO_ReadOnly); |
||
1077 | OB.Groups.clear(); |
||
4026 | craig | 1078 | for (int cx = 0; cx < obj.attribute("NUMGROUP", "0").toInt(); ++cx) |
3 | paul | 1079 | { |
167 | Franz | 1080 | fg >> x; |
1081 | OB.Groups.push(x); |
||
3 | paul | 1082 | } |
1083 | tmp = ""; |
||
1084 | } |
||
167 | Franz | 1085 | else |
1086 | OB.Groups.clear(); |
||
3 | paul | 1087 | QDomNode IT=OBJ.firstChild(); |
1088 | while(!IT.isNull()) |
||
167 | Franz | 1089 | { |
3 | paul | 1090 | QDomElement it=IT.toElement(); |
295 | Franz | 1091 | if (it.tagName()=="CSTOP") |
1092 | { |
||
1093 | QString name = it.attribute("NAME"); |
||
4026 | craig | 1094 | double ramp = it.attribute("RAMP", "0.0").toDouble(); |
1095 | int shade = it.attribute("SHADE", "100").toInt(); |
||
1096 | double opa = it.attribute("TRANS", "1").toDouble(); |
||
690 | cbradney | 1097 | OB.fill_gradient.addStop(SetColor(doc, name, shade), ramp, 0.5, opa, name, shade); |
2180 | fschmid | 1098 | OB.GrColor = ""; |
1099 | OB.GrColor2 = ""; |
||
295 | Franz | 1100 | } |
332 | Franz | 1101 | IT=IT.nextSibling(); |
114 | Franz | 1102 | } |
3197 | fschmid | 1103 | OB.itemText = ""; |
456 | fschmid | 1104 | view->PasteItem(&OB, true); |
3727 | cbradney | 1105 | Neu = doc->Items->at(counter); |
3197 | fschmid | 1106 | IT=OBJ.firstChild(); |
1107 | while(!IT.isNull()) |
||
1108 | { |
||
1109 | QDomElement it=IT.toElement(); |
||
1110 | if (it.tagName()=="ITEXT") |
||
1111 | GetItemText(&it, doc, VorLFound, true, Neu); |
||
1112 | IT=IT.nextSibling(); |
||
1113 | } |
||
4026 | craig | 1114 | if (obj.attribute("NEXTPAGE").toInt() == PageToLoad) |
31 | Franz | 1115 | { |
4026 | craig | 1116 | Neu->NextIt = baseobj + obj.attribute("NEXTITEM").toInt(); |
1117 | Neu->NextPg = a; // obj.attribute("NEXTPAGE").toInt(); |
||
31 | Franz | 1118 | } |
3197 | fschmid | 1119 | else |
1120 | Neu->NextIt = -1; |
||
234 | Franz | 1121 | if (Neu->isTableItem) |
1122 | { |
||
1123 | TableItems.append(Neu); |
||
4026 | craig | 1124 | TableID.insert(obj.attribute("OwnLINK", "0").toInt(), Neu->ItemNr); |
234 | Franz | 1125 | } |
167 | Franz | 1126 | counter++; |
1127 | OBJ=OBJ.nextSibling(); |
||
114 | Franz | 1128 | } |
234 | Franz | 1129 | if (TableItems.count() != 0) |
1130 | { |
||
1131 | for (uint ttc = 0; ttc < TableItems.count(); ++ttc) |
||
1132 | { |
||
1133 | PageItem* ta = TableItems.at(ttc); |
||
1134 | if (ta->TopLinkID != -1) |
||
3727 | cbradney | 1135 | ta->TopLink = doc->Items->at(TableID[ta->TopLinkID]); |
234 | Franz | 1136 | else |
1137 | ta->TopLink = 0; |
||
1138 | if (ta->LeftLinkID != -1) |
||
3727 | cbradney | 1139 | ta->LeftLink = doc->Items->at(TableID[ta->LeftLinkID]); |
234 | Franz | 1140 | else |
1141 | ta->LeftLink = 0; |
||
1142 | if (ta->RightLinkID != -1) |
||
3727 | cbradney | 1143 | ta->RightLink = doc->Items->at(TableID[ta->RightLinkID]); |
234 | Franz | 1144 | else |
1145 | ta->RightLink = 0; |
||
1146 | if (ta->BottomLinkID != -1) |
||
3727 | cbradney | 1147 | ta->BottomLink = doc->Items->at(TableID[ta->BottomLinkID]); |
234 | Franz | 1148 | else |
1149 | ta->BottomLink = 0; |
||
1150 | } |
||
1151 | } |
||
167 | Franz | 1152 | if (LFrames.count() != 0) |
31 | Franz | 1153 | { |
167 | Franz | 1154 | PageItem *Its; |
1155 | PageItem *Itn; |
||
1156 | PageItem *Itr; |
||
1157 | QValueList<Linked>::Iterator lc; |
||
1158 | for (lc = LFrames.begin(); lc != LFrames.end(); ++lc) |
||
31 | Franz | 1159 | { |
3727 | cbradney | 1160 | Its = doc->Items->at((*lc).Start); |
167 | Franz | 1161 | Itr = Its; |
1162 | Its->BackBox = 0; |
||
1163 | while (Its->NextIt != -1) |
||
31 | Franz | 1164 | { |
167 | Franz | 1165 | if (Its->NextPg == a) |
114 | Franz | 1166 | { |
3727 | cbradney | 1167 | Itn = doc->Items->at(Its->NextIt); |
167 | Franz | 1168 | Its->NextBox = Itn; |
1169 | Itn->BackBox = Its; |
||
1170 | Its = Itn; |
||
114 | Franz | 1171 | } |
167 | Franz | 1172 | else |
1173 | break; |
||
31 | Franz | 1174 | } |
167 | Franz | 1175 | Its->NextBox = 0; |
31 | Franz | 1176 | } |
1177 | } |
||
167 | Franz | 1178 | if (!Mpage) |
1179 | view->reformPages(); |
||
1180 | return true; |
||
114 | Franz | 1181 | } |
3 | paul | 1182 | PAGE=PAGE.nextSibling(); |
2784 | subik | 1183 | } |
3 | paul | 1184 | DOC=DOC.nextSibling(); |
167 | Franz | 1185 | } |
1186 | return false; |
||
3 | paul | 1187 | } |
1188 | |||
1189 | bool ScriXmlDoc::ReadDoc(QString fileName, SCFonts &avail, ScribusDoc *doc, ScribusView *view, QProgressBar *dia2) |
||
1190 | { |
||
1542 | cbradney | 1191 | //Scribus 1.2 docs, see fileloader.cpp for 1.3 docs |
1065 | cbradney | 1192 | struct CopyPasteBuffer OB; |
1193 | struct ParagraphStyle vg; |
||
167 | Franz | 1194 | struct Layer la; |
1195 | struct ScribusDoc::BookMa bok; |
||
3787 | cbradney | 1196 | int counter; |
167 | Franz | 1197 | bool newVersion = false; |
1198 | struct Linked Link; |
||
1199 | QString tmp, tmpf, tmp2, tmp3, tmp4, PgNam, Defont, tmf; |
||
234 | Franz | 1200 | QMap<int,int> TableID; |
1201 | QPtrList<PageItem> TableItems; |
||
332 | Franz | 1202 | int x, a; |
2282 | fschmid | 1203 | double xf, xf2; |
167 | Franz | 1204 | PageItem *Neu; |
1205 | LFrames.clear(); |
||
1206 | QDomDocument docu("scridoc"); |
||
1746 | fschmid | 1207 | QFile fi(fileName); |
3646 | craig | 1208 | // Load the document text |
1209 | QString f(FileLoader::readSLA(fileName)); |
||
1210 | // Build the DOM from it |
||
1211 | if (!docu.setContent(f)) |
||
1212 | return false; |
||
1213 | // and begin loading the doc |
||
2784 | subik | 1214 | doc->PageColors.clear(); |
167 | Franz | 1215 | doc->Layers.clear(); |
2886 | fschmid | 1216 | ScColor lf = ScColor(); |
167 | Franz | 1217 | QDomElement elem=docu.documentElement(); |
1218 | if ((elem.tagName() != "SCRIBUS") && (elem.tagName() != "SCRIBUSUTF8")) |
||
1219 | return false; |
||
1220 | if (elem.hasAttribute("Version")) |
||
1221 | newVersion = true; |
||
1222 | QDomNode DOC=elem.firstChild(); |
||
1223 | dia2->setTotalSteps(DOC.childNodes().count()); |
||
1224 | dia2->setProgress(0); |
||
1225 | int ObCount = 0; |
||
3967 | craig | 1226 | int activeLayer = 0; |
167 | Franz | 1227 | while(!DOC.isNull()) |
1228 | { |
||
1229 | QDomElement dc=DOC.toElement(); |
||
3 | paul | 1230 | /* |
1231 | * Attribute von DOCUMENT auslesen |
||
1232 | */ |
||
2305 | cbradney | 1233 | if (dc.hasAttribute("PAGEWIDTH")) |
4026 | craig | 1234 | doc->pageWidth=dc.attribute("PAGEWIDTH").toDouble(); |
2305 | cbradney | 1235 | else |
4026 | craig | 1236 | doc->pageWidth=dc.attribute("PAGEWITH").toDouble(); |
1237 | doc->pageHeight=dc.attribute("PAGEHEIGHT").toDouble(); |
||
4595 | fschmid | 1238 | doc->pageMargins.Left=QMAX(0.0, dc.attribute("BORDERLEFT").toDouble()); |
1239 | doc->pageMargins.Right=QMAX(0.0, dc.attribute("BORDERRIGHT").toDouble()); |
||
1240 | doc->pageMargins.Top=QMAX(0.0, dc.attribute("BORDERTOP").toDouble()); |
||
1241 | doc->pageMargins.Bottom=QMAX(0.0, dc.attribute("BORDERBOTTOM").toDouble()); |
||
4026 | craig | 1242 | doc->PageOri = dc.attribute("ORIENTATION", "0").toInt(); |
519 | cbradney | 1243 | doc->PageSize = dc.attribute("PAGESIZE"); |
4026 | craig | 1244 | doc->FirstPnum = dc.attribute("FIRSTNUM", "1").toInt(); |
1245 | doc->currentPageLayout=dc.attribute("BOOK", "0").toInt(); |
||
3016 | fschmid | 1246 | int fp; |
4026 | craig | 1247 | if (dc.attribute("FIRSTLEFT", "0").toInt() == 1) |
3016 | fschmid | 1248 | fp = 0; |
2912 | fschmid | 1249 | else |
3016 | fschmid | 1250 | fp = 1; |
3032 | fschmid | 1251 | if (doc->currentPageLayout == 0) |
3016 | fschmid | 1252 | fp = 0; |
3032 | fschmid | 1253 | doc->pageSets[doc->currentPageLayout].FirstPage = fp; |
4026 | craig | 1254 | doc->setUsesAutomaticTextFrames(dc.attribute("AUTOTEXT").toInt()); |
1255 | doc->PageSp=dc.attribute("AUTOSPALTEN").toInt(); |
||
1256 | doc->PageSpa=dc.attribute("ABSTSPALTEN").toDouble(); |
||
1257 | doc->setUnitIndex(dc.attribute("UNITS", "0").toInt()); |
||
879 | fschmid | 1258 | doc->guidesSettings.gridShown = view->Prefs->guidesSettings.gridShown; |
1259 | doc->guidesSettings.guidesShown = view->Prefs->guidesSettings.guidesShown; |
||
1260 | doc->guidesSettings.framesShown = view->Prefs->guidesSettings.framesShown; |
||
1261 | doc->guidesSettings.marginsShown = view->Prefs->guidesSettings.marginsShown; |
||
1262 | doc->guidesSettings.baseShown = view->Prefs->guidesSettings.baseShown; |
||
1263 | doc->guidesSettings.linkShown = view->Prefs->guidesSettings.linkShown; |
||
1264 | doc->guidesSettings.showPic = true; |
||
2353 | fschmid | 1265 | doc->guidesSettings.showControls = false; |
167 | Franz | 1266 | DoFonts.clear(); |
4026 | craig | 1267 | doc->toolSettings.defSize=qRound(dc.attribute("DSIZE").toDouble() * 10); |
167 | Franz | 1268 | Defont=dc.attribute("DFONT"); |
1428 | fschmid | 1269 | if ((!avail.find(Defont)) || (!avail[Defont]->UseFont)) |
121 | Franz | 1270 | { |
1428 | fschmid | 1271 | ReplacedFonts.insert(Defont, view->Prefs->toolSettings.defFont); |
1272 | Defont = view->Prefs->toolSettings.defFont; |
||
121 | Franz | 1273 | } |
325 | Franz | 1274 | else |
1428 | fschmid | 1275 | { |
1786 | fschmid | 1276 | if (!doc->UsedFonts.contains(tmpf)) |
1277 | { |
||
3544 | avox | 1278 | // QFont fo = avail[Defont]->Font; |
1279 | // fo.setPointSize(qRound(doc->toolSettings.defSize / 10.0)); |
||
1280 | doc->AddFont(Defont); |
||
1786 | fschmid | 1281 | } |
1428 | fschmid | 1282 | } |
1194 | fschmid | 1283 | doc->toolSettings.defFont = Defont; |
4026 | craig | 1284 | doc->toolSettings.dCols=dc.attribute("DCOL", "1").toInt(); |
1285 | doc->toolSettings.dGap=dc.attribute("DGAP", "0.0").toDouble(); |
||
2024 | cbradney | 1286 | doc->documentInfo.setAuthor(dc.attribute("AUTHOR")); |
1287 | doc->documentInfo.setComments(dc.attribute("COMMENTS")); |
||
1288 | doc->documentInfo.setKeywords(dc.attribute("KEYWORDS","")); |
||
1289 | doc->documentInfo.setTitle(dc.attribute("TITLE")); |
||
1290 | doc->documentInfo.setPublisher(dc.attribute("PUBLISHER", "")); |
||
1291 | doc->documentInfo.setDate(dc.attribute("DOCDATE", "")); |
||
1292 | doc->documentInfo.setType(dc.attribute("DOCTYPE", "")); |
||
1293 | doc->documentInfo.setFormat(dc.attribute("DOCFORMAT", "")); |
||
1294 | doc->documentInfo.setIdent(dc.attribute("DOCIDENT", "")); |
||
1295 | doc->documentInfo.setSource(dc.attribute("DOCSOURCE", "")); |
||
1296 | doc->documentInfo.setLangInfo(dc.attribute("DOCLANGINFO", "")); |
||
1297 | doc->documentInfo.setRelation(dc.attribute("DOCRELATION", "")); |
||
1298 | doc->documentInfo.setCover(dc.attribute("DOCCOVER", "")); |
||
1299 | doc->documentInfo.setRights(dc.attribute("DOCRIGHTS", "")); |
||
1300 | doc->documentInfo.setContrib(dc.attribute("DOCCONTRIB", "")); |
||
4026 | craig | 1301 | doc->typographicSettings.valueSuperScript = dc.attribute("VHOCH").toInt(); |
1302 | doc->typographicSettings.scalingSuperScript = dc.attribute("VHOCHSC").toInt(); |
||
1303 | doc->typographicSettings.valueSubScript = dc.attribute("VTIEF").toInt(); |
||
1304 | doc->typographicSettings.scalingSubScript = dc.attribute("VTIEFSC").toInt(); |
||
1305 | doc->typographicSettings.valueSmallCaps = dc.attribute("VKAPIT").toInt(); |
||
1306 | doc->typographicSettings.valueBaseGrid = dc.attribute("BASEGRID", "12").toDouble(); |
||
1307 | doc->typographicSettings.offsetBaseGrid = dc.attribute("BASEO", "0").toDouble(); |
||
1308 | doc->typographicSettings.autoLineSpacing = dc.attribute("AUTOL", "20").toInt(); |
||
1309 | doc->GroupCounter=dc.attribute("GROUPC", "1").toInt(); |
||
1310 | doc->HasCMS = static_cast<bool>(dc.attribute("HCMS", "0").toInt()); |
||
1311 | doc->CMSSettings.SoftProofOn = static_cast<bool>(dc.attribute("DPSo", "0").toInt()); |
||
1312 | doc->CMSSettings.CMSinUse = static_cast<bool>(dc.attribute("DPuse", "0").toInt()); |
||
1313 | doc->CMSSettings.GamutCheck = static_cast<bool>(dc.attribute("DPgam", "0").toInt()); |
||
1314 | doc->CMSSettings.BlackPoint = static_cast<bool>(dc.attribute("DPbla", "1").toInt()); |
||
167 | Franz | 1315 | doc->CMSSettings.DefaultMonitorProfile = dc.attribute("DPMo",""); |
1316 | doc->CMSSettings.DefaultPrinterProfile = dc.attribute("DPPr",""); |
||
2984 | fschmid | 1317 | doc->CMSSettings.DefaultImageRGBProfile = dc.attribute("DPIn",""); |
1318 | doc->CMSSettings.DefaultSolidColorProfile = dc.attribute("DPIn2",""); |
||
4026 | craig | 1319 | doc->CMSSettings.DefaultIntentPrinter = dc.attribute("DIPr", "0").toInt(); |
1320 | doc->CMSSettings.DefaultIntentMonitor = dc.attribute("DIMo", "1").toInt(); |
||
1321 | doc->CMSSettings.DefaultIntentImages = dc.attribute("DIMo2", "1").toInt(); |
||
1322 | activeLayer = dc.attribute("ALAYER", "0").toInt(); |
||
167 | Franz | 1323 | doc->Language = dc.attribute("LANGUAGE", ""); |
4026 | craig | 1324 | doc->MinWordLen = dc.attribute("MINWORDLEN", "3").toInt(); |
1325 | doc->HyCount = dc.attribute("HYCOUNT", "2").toInt(); |
||
1326 | doc->Automatic = static_cast<bool>(dc.attribute("AUTOMATIC", "1").toInt()); |
||
1327 | doc->AutoCheck = static_cast<bool>(dc.attribute("AUTOCHECK", "0").toInt()); |
||
1328 | doc->GuideLock = static_cast<bool>(dc.attribute("GUIDELOCK", "0").toInt()); |
||
1329 | doc->SnapGuides = static_cast<bool>(dc.attribute("SnapToGuides", "0").toInt()); |
||
1330 | doc->useRaster = static_cast<bool>(dc.attribute("SnapToGrid", "0").toInt()); |
||
1331 | doc->guidesSettings.minorGrid = dc.attribute("MINGRID", tmp.setNum(view->Prefs->guidesSettings.minorGrid)).toDouble(); |
||
1332 | doc->guidesSettings.majorGrid = dc.attribute("MAJGRID", tmp.setNum(view->Prefs->guidesSettings.majorGrid)).toDouble(); |
||
1194 | fschmid | 1333 | doc->toolSettings.dStartArrow = 0; |
1334 | doc->toolSettings.dEndArrow = 0; |
||
1016 | fschmid | 1335 | doc->LastAuto = 0; |
167 | Franz | 1336 | QDomNode PAGE=DOC.firstChild(); |
456 | fschmid | 1337 | counter = 0; |
167 | Franz | 1338 | while(!PAGE.isNull()) |
3 | paul | 1339 | { |
167 | Franz | 1340 | ObCount++; |
1341 | dia2->setProgress(ObCount); |
||
1342 | QDomElement pg=PAGE.toElement(); |
||
516 | fschmid | 1343 | // 10/25/2004 pv - None is "reserved" color. cannot be defined in any file... |
4546 | subik | 1344 | if(pg.tagName()=="COLOR" && pg.attribute("NAME")!=CommonStrings::None) |
3 | paul | 1345 | { |
167 | Franz | 1346 | if (pg.hasAttribute("CMYK")) |
1347 | lf.setNamedColor(pg.attribute("CMYK")); |
||
1348 | else |
||
1349 | lf.fromQColor(QColor(pg.attribute("RGB"))); |
||
1350 | doc->PageColors[pg.attribute("NAME")] = lf; |
||
3 | paul | 1351 | } |
167 | Franz | 1352 | if(pg.tagName()=="STYLE") |
3 | paul | 1353 | { |
167 | Franz | 1354 | vg.Vname = pg.attribute("NAME"); |
4026 | craig | 1355 | vg.LineSpaMode = pg.attribute("LINESPMode", "0").toInt(); |
1356 | vg.LineSpa = pg.attribute("LINESP").toDouble(); |
||
1357 | vg.Indent = pg.attribute("INDENT", "0").toDouble(); |
||
1358 | vg.First = pg.attribute("FIRST", "0").toDouble(); |
||
1359 | vg.textAlignment = pg.attribute("ALIGN").toInt(); |
||
1360 | vg.gapBefore = pg.attribute("VOR", "0").toDouble(); |
||
1361 | vg.gapAfter = pg.attribute("NACH", "0").toDouble(); |
||
1194 | fschmid | 1362 | tmpf = pg.attribute("FONT", doc->toolSettings.defFont); |
1428 | fschmid | 1363 | if ((!avail.find(tmpf)) || (!avail[tmpf]->UseFont)) |
1364 | { |
||
1365 | if ((!view->Prefs->GFontSub.contains(tmpf)) || (!avail[view->Prefs->GFontSub[tmpf]]->UseFont)) |
||
1468 | fschmid | 1366 | { |
1367 | newReplacement = true; |
||
1428 | fschmid | 1368 | ReplacedFonts.insert(tmpf, view->Prefs->toolSettings.defFont); |
1468 | fschmid | 1369 | } |
1428 | fschmid | 1370 | else |
1371 | ReplacedFonts.insert(tmpf, view->Prefs->GFontSub[tmpf]); |
||
1372 | } |
||
167 | Franz | 1373 | else |
1428 | fschmid | 1374 | { |
1786 | fschmid | 1375 | if (!doc->UsedFonts.contains(tmpf)) |
1376 | { |
||
3544 | avox | 1377 | // QFont fo = avail[tmpf]->Font; |
1378 | // fo.setPointSize(qRound(doc->toolSettings.defSize / 10.0)); |
||
1379 | doc->AddFont(tmpf); |
||
1786 | fschmid | 1380 | } |
1428 | fschmid | 1381 | } |
323 | Franz | 1382 | vg.Font = tmpf; |
4026 | craig | 1383 | vg.FontSize = qRound(pg.attribute("FONTSIZE", "12").toDouble() * 10.0); |
1384 | vg.Drop = static_cast<bool>(pg.attribute("DROP", "0").toInt()); |
||
1385 | vg.DropLin = pg.attribute("DROPLIN", "2").toInt(); |
||
1386 | vg.DropDist = pg.attribute("DROPDIST", "0").toDouble(); |
||
1387 | vg.FontEffect = pg.attribute("EFFECT", "0").toInt(); |
||
1194 | fschmid | 1388 | vg.FColor = pg.attribute("FCOLOR", doc->toolSettings.dBrush); |
4026 | craig | 1389 | vg.FShade = pg.attribute("FSHADE", "100").toInt(); |
1194 | fschmid | 1390 | vg.SColor = pg.attribute("SCOLOR", doc->toolSettings.dPen); |
4026 | craig | 1391 | vg.SShade = pg.attribute("SSHADE", "100").toInt(); |
1392 | vg.BaseAdj = static_cast<bool>(pg.attribute("BASE", "0").toInt()); |
||
2273 | fschmid | 1393 | vg.txtShadowX = 50; |
1394 | vg.txtShadowY = -50; |
||
1395 | vg.txtOutline = 10; |
||
2889 | cbradney | 1396 | vg.txtUnderPos = doc->typographicSettings.valueUnderlinePos; |
1397 | vg.txtUnderWidth = doc->typographicSettings.valueUnderlineWidth; |
||
1398 | vg.txtStrikePos = doc->typographicSettings.valueStrikeThruPos; |
||
1399 | vg.txtStrikeWidth = doc->typographicSettings.valueStrikeThruPos; |
||
2385 | fschmid | 1400 | vg.scaleH = 1000; |
1401 | vg.scaleV = 1000; |
||
2379 | fschmid | 1402 | vg.baseOff = 0; |
1403 | vg.kernVal = 0; |
||
4026 | craig | 1404 | if ((pg.hasAttribute("NUMTAB")) && (pg.attribute("NUMTAB", "0").toInt() != 0)) |
140 | Franz | 1405 | { |
167 | Franz | 1406 | tmp = pg.attribute("TABS"); |
1407 | QTextStream tgv(&tmp, IO_ReadOnly); |
||
1408 | vg.TabValues.clear(); |
||
2282 | fschmid | 1409 | struct PageItem::TabRecord tb; |
4026 | craig | 1410 | for (int cxv = 0; cxv < pg.attribute("NUMTAB", "0").toInt(); cxv += 2) |
140 | Franz | 1411 | { |
167 | Franz | 1412 | tgv >> xf; |
2282 | fschmid | 1413 | tgv >> xf2; |
1414 | tb.tabPosition = xf2; |
||
1415 | tb.tabType = static_cast<int>(xf); |
||
1416 | tb.tabFillChar = QChar(); |
||
1417 | vg.TabValues.append(tb); |
||
140 | Franz | 1418 | } |
167 | Franz | 1419 | tmp = ""; |
140 | Franz | 1420 | } |
167 | Franz | 1421 | else |
1422 | vg.TabValues.clear(); |
||
1065 | cbradney | 1423 | doc->docParagraphStyles.append(vg); |
3 | paul | 1424 | } |
167 | Franz | 1425 | if(pg.tagName()=="JAVA") |
1426 | doc->JavaScripts[pg.attribute("NAME")] = pg.attribute("SCRIPT"); |
||
1427 | if(pg.tagName()=="LAYERS") |
||
3 | paul | 1428 | { |
4026 | craig | 1429 | la.LNr = pg.attribute("NUMMER").toInt(); |
1430 | la.Level = pg.attribute("LEVEL").toInt(); |
||
167 | Franz | 1431 | la.Name = pg.attribute("NAME"); |
4026 | craig | 1432 | la.isViewable = pg.attribute("SICHTBAR").toInt(); |
1433 | la.isPrintable = pg.attribute("DRUCKEN").toInt(); |
||
167 | Franz | 1434 | doc->Layers.append(la); |
3 | paul | 1435 | } |
167 | Franz | 1436 | if(pg.tagName()=="Bookmark") |
3 | paul | 1437 | { |
167 | Franz | 1438 | bok.Title = pg.attribute("Title"); |
1439 | bok.Text = pg.attribute("Text"); |
||
1440 | bok.Aktion = pg.attribute("Aktion"); |
||
4026 | craig | 1441 | bok.ItemNr = pg.attribute("ItemNr").toInt(); |
1442 | bok.Seite = pg.attribute("Seite").toInt(); |
||
1443 | bok.Element = pg.attribute("Element").toInt(); |
||
1444 | bok.First = pg.attribute("First").toInt(); |
||
1445 | bok.Last = pg.attribute("Last").toInt(); |
||
1446 | bok.Prev = pg.attribute("Prev").toInt(); |
||
1447 | bok.Next = pg.attribute("Next").toInt(); |
||
1448 | bok.Parent = pg.attribute("Parent").toInt(); |
||
167 | Franz | 1449 | doc->BookMarks.append(bok); |
3 | paul | 1450 | } |
167 | Franz | 1451 | if(pg.tagName()=="MultiLine") |
27 | Franz | 1452 | { |
167 | Franz | 1453 | multiLine ml; |
1454 | QDomNode MuLn = PAGE.firstChild(); |
||
1455 | while(!MuLn.isNull()) |
||
27 | Franz | 1456 | { |
167 | Franz | 1457 | QDomElement MuL = MuLn.toElement(); |
1065 | cbradney | 1458 | struct SingleLine sl; |
167 | Franz | 1459 | sl.Color = MuL.attribute("Color"); |
4026 | craig | 1460 | sl.Dash = MuL.attribute("Dash").toInt(); |
1461 | sl.LineEnd = MuL.attribute("LineEnd").toInt(); |
||
1462 | sl.LineJoin = MuL.attribute("LineJoin").toInt(); |
||
1463 | sl.Shade = MuL.attribute("Shade").toInt(); |
||
1464 | sl.Width = MuL.attribute("Width").toDouble(); |
||
167 | Franz | 1465 | ml.push_back(sl); |
1466 | MuLn = MuLn.nextSibling(); |
||
27 | Franz | 1467 | } |
167 | Franz | 1468 | doc->MLineStyles.insert(pg.attribute("Name"), ml); |
27 | Franz | 1469 | } |
167 | Franz | 1470 | if(pg.tagName()=="PAGE") |
114 | Franz | 1471 | { |
234 | Franz | 1472 | TableItems.clear(); |
1473 | TableID.clear(); |
||
3 | paul | 1474 | /* |
1475 | * Attribute von PAGE auslesen |
||
1476 | */ |
||
4026 | craig | 1477 | a = pg.attribute("NUM").toInt(); |
167 | Franz | 1478 | PgNam = ""; |
1479 | PgNam = pg.attribute("NAM", ""); |
||
3787 | cbradney | 1480 | QString Mus = ""; |
1481 | Mus = pg.attribute("MNAM","Normal"); |
||
2877 | cbradney | 1482 | if (PgNam.isEmpty()) |
3 | paul | 1483 | { |
3972 | cbradney | 1484 | //We store the pages master page but do not apply it now |
1485 | //as it may not exist yet. They are applied in scribus.cpp for now. |
||
3724 | cbradney | 1486 | doc->setMasterPageMode(false); |
3972 | cbradney | 1487 | doc->currentPage=doc->addPage(a); |
1488 | doc->currentPage->MPageNam=Mus; |
||
3 | paul | 1489 | } |
167 | Franz | 1490 | else |
3 | paul | 1491 | { |
3724 | cbradney | 1492 | doc->setMasterPageMode(true); |
3787 | cbradney | 1493 | doc->currentPage=doc->addMasterPage(a, PgNam); |
3 | paul | 1494 | } |
3648 | cbradney | 1495 | //CB: Remove this unnecessarily "slow" slot call when we have no gui for the doc yet! |
1496 | //Items dont appear in the right place if we just doc->addPage(a); for <=1.2.x docs |
||
1497 | //so we have to call the view, but we certainly dont need to emit to the mainwindow! |
||
4546 | subik | 1498 | //This call now picks up the added page and does some view black magic. A must for |
3787 | cbradney | 1499 | //1.2.x docs! |
3648 | cbradney | 1500 | view->addPage(a); |
1501 | //emit NewPage(a); |
||
4026 | craig | 1502 | doc->Pages->at(a)->LeftPg=pg.attribute("LEFT", "0").toInt(); |
3787 | cbradney | 1503 | |
4026 | craig | 1504 | if ((pg.hasAttribute("NumVGuides")) && (pg.attribute("NumVGuides", "0").toInt() != 0)) |
3 | paul | 1505 | { |
167 | Franz | 1506 | tmp = pg.attribute("VerticalGuides"); |
1507 | QTextStream fgv(&tmp, IO_ReadOnly); |
||
3724 | cbradney | 1508 | doc->Pages->at(a)->YGuides.clear(); |
4026 | craig | 1509 | for (int cxv = 0; cxv < pg.attribute("NumVGuides", "0").toInt(); ++cxv) |
3 | paul | 1510 | { |
167 | Franz | 1511 | fgv >> xf; |
3724 | cbradney | 1512 | doc->Pages->at(a)->YGuides.append(xf); |
3 | paul | 1513 | } |
3724 | cbradney | 1514 | qHeapSort(doc->Pages->at(a)->YGuides); |
167 | Franz | 1515 | tmp = ""; |
3 | paul | 1516 | } |
167 | Franz | 1517 | else |
3724 | cbradney | 1518 | doc->Pages->at(a)->YGuides.clear(); |
4026 | craig | 1519 | if ((pg.hasAttribute("NumHGuides")) && (pg.attribute("NumHGuides", "0").toInt() != 0)) |
3 | paul | 1520 | { |
167 | Franz | 1521 | tmp = pg.attribute("HorizontalGuides"); |
1522 | QTextStream fgh(&tmp, IO_ReadOnly); |
||
3724 | cbradney | 1523 | doc->Pages->at(a)->XGuides.clear(); |
4026 | craig | 1524 | for (int cxh = 0; cxh < pg.attribute("NumHGuides", "0").toInt(); ++cxh) |
3 | paul | 1525 | { |
167 | Franz | 1526 | fgh >> xf; |
3724 | cbradney | 1527 | doc->Pages->at(a)->XGuides.append(xf); |
3 | paul | 1528 | } |
3724 | cbradney | 1529 | qHeapSort(doc->Pages->at(a)->XGuides); |
167 | Franz | 1530 | tmp = ""; |
3 | paul | 1531 | } |
167 | Franz | 1532 | else |
3724 | cbradney | 1533 | doc->Pages->at(a)->XGuides.clear(); |
167 | Franz | 1534 | QDomNode OBJ=PAGE.firstChild(); |
1535 | while(!OBJ.isNull()) |
||
1536 | { |
||
1537 | QDomElement obj=OBJ.toElement(); |
||
3 | paul | 1538 | /* |
1539 | * Attribute von OBJECT auslesen |
||
1540 | */ |
||
4026 | craig | 1541 | if ((obj.attribute("NEXTITEM").toInt() != -1) || (static_cast<bool>(obj.attribute("AUTOTEXT").toInt()))) |
3 | paul | 1542 | { |
4026 | craig | 1543 | if (obj.attribute("BACKITEM").toInt() == -1) |
3 | paul | 1544 | { |
167 | Franz | 1545 | Link.Start = counter; |
1546 | Link.StPag = a; |
||
1547 | LFrames.append(Link); |
||
3 | paul | 1548 | } |
1549 | } |
||
332 | Franz | 1550 | GetItemProps(newVersion, &obj, &OB); |
4026 | craig | 1551 | OB.Xpos = obj.attribute("XPOS").toDouble()+doc->Pages->at(a)->xOffset(); |
1552 | OB.Ypos=obj.attribute("YPOS").toDouble()+doc->Pages->at(a)->yOffset(); |
||
167 | Franz | 1553 | OB.NamedLStyle = obj.attribute("NAMEDLST", ""); |
4026 | craig | 1554 | OB.isBookmark=obj.attribute("BOOKMARK").toInt(); |
167 | Franz | 1555 | if ((OB.isBookmark) && (doc->BookMarks.count() == 0)) |
1556 | doc->OldBM = true; |
||
4026 | craig | 1557 | OB.BMnr = obj.attribute("BookNr", "0").toInt(); |
1558 | OB.textAlignment = obj.attribute("ALIGN", "0").toInt(); |
||
745 | fschmid | 1559 | OB.startArrowIndex = 0; |
1560 | OB.endArrowIndex = 0; |
||
1194 | fschmid | 1561 | tmpf = obj.attribute("IFONT", doc->toolSettings.defFont); |
1428 | fschmid | 1562 | if ((!avail.find(tmpf)) || (!avail[tmpf]->UseFont)) |
1563 | { |
||
1564 | if ((!view->Prefs->GFontSub.contains(tmpf)) || (!avail[view->Prefs->GFontSub[tmpf]]->UseFont)) |
||
1468 | fschmid | 1565 | { |
1566 | newReplacement = true; |
||
1428 | fschmid | 1567 | ReplacedFonts.insert(tmpf, view->Prefs->toolSettings.defFont); |
1468 | fschmid | 1568 | } |
1428 | fschmid | 1569 | else |
1570 | ReplacedFonts.insert(tmpf, view->Prefs->GFontSub[tmpf]); |
||
1571 | } |
||
204 | Franz | 1572 | else |
1428 | fschmid | 1573 | { |
1786 | fschmid | 1574 | if (!doc->UsedFonts.contains(tmpf)) |
1575 | { |
||
3544 | avox | 1576 | // QFont fo = avail[tmpf]->Font; |
1577 | // fo.setPointSize(qRound(doc->toolSettings.defSize / 10.0)); |
||
1578 | doc->AddFont(tmpf); |
||
1786 | fschmid | 1579 | } |
1428 | fschmid | 1580 | } |
323 | Franz | 1581 | OB.IFont = tmpf; |
4026 | craig | 1582 | OB.LayerNr = obj.attribute("LAYER", "0").toInt(); |
167 | Franz | 1583 | OB.Language = obj.attribute("LANGUAGE", doc->Language); |
1584 | tmp = ""; |
||
4026 | craig | 1585 | if ((obj.hasAttribute("GROUPS")) && (obj.attribute("NUMGROUP", "0").toInt() != 0)) |
3 | paul | 1586 | { |
167 | Franz | 1587 | tmp = obj.attribute("GROUPS"); |
1588 | QTextStream fg(&tmp, IO_ReadOnly); |
||
1589 | OB.Groups.clear(); |
||
4026 | craig | 1590 | for (int cx = 0; cx < obj.attribute("NUMGROUP", "0").toInt(); ++cx) |
3 | paul | 1591 | { |
167 | Franz | 1592 | fg >> x; |
1593 | OB.Groups.push(x); |
||
3 | paul | 1594 | } |
167 | Franz | 1595 | tmp = ""; |
3 | paul | 1596 | } |
167 | Franz | 1597 | else |
1598 | OB.Groups.clear(); |
||
1599 | QDomNode IT=OBJ.firstChild(); |
||
1600 | while(!IT.isNull()) |
||
1601 | { |
||
1602 | QDomElement it=IT.toElement(); |
||
295 | Franz | 1603 | if (it.tagName()=="CSTOP") |
1604 | { |
||
1605 | QString name = it.attribute("NAME"); |
||
4026 | craig | 1606 | double ramp = it.attribute("RAMP", "0.0").toDouble(); |
1607 | int shade = it.attribute("SHADE", "100").toInt(); |
||
1608 | double opa = it.attribute("TRANS", "1").toDouble(); |
||
690 | cbradney | 1609 | OB.fill_gradient.addStop(SetColor(doc, name, shade), ramp, 0.5, opa, name, shade); |
2180 | fschmid | 1610 | OB.GrColor = ""; |
1611 | OB.GrColor2 = ""; |
||
295 | Franz | 1612 | } |
167 | Franz | 1613 | IT=IT.nextSibling(); |
1614 | } |
||
1789 | fschmid | 1615 | OB.itemText = ""; |
167 | Franz | 1616 | int docGc = doc->GroupCounter; |
1617 | doc->GroupCounter = 0; |
||
3727 | cbradney | 1618 | uint last = doc->Items->count(); |
456 | fschmid | 1619 | view->PasteItem(&OB, true); |
167 | Franz | 1620 | doc->GroupCounter = docGc; |
3727 | cbradney | 1621 | Neu = doc->Items->at(last); |
1866 | fschmid | 1622 | Neu->OnMasterPage = PgNam; |
3817 | cbradney | 1623 | Neu->OwnPage = a; //No need to scan for OnPage as we know page by page in 1.2.x |
3820 | cbradney | 1624 | Neu->oldOwnPage = 0; |
3790 | cbradney | 1625 | Neu->setRedrawBounding(); |
1789 | fschmid | 1626 | IT=OBJ.firstChild(); |
1627 | while(!IT.isNull()) |
||
1628 | { |
||
1629 | QDomElement it=IT.toElement(); |
||
1630 | if (it.tagName()=="ITEXT") |
||
3197 | fschmid | 1631 | GetItemText(&it, doc, false, false, Neu); |
1789 | fschmid | 1632 | IT=IT.nextSibling(); |
1633 | } |
||
4026 | craig | 1634 | Neu->isAutoText=static_cast<bool>(obj.attribute("AUTOTEXT").toInt()); |
167 | Franz | 1635 | if (Neu->isAutoText) |
1636 | doc->LastAuto = Neu; |
||
4026 | craig | 1637 | Neu->NextIt = obj.attribute("NEXTITEM").toInt(); |
1638 | Neu->NextPg = obj.attribute("NEXTPAGE").toInt(); |
||
234 | Franz | 1639 | if (Neu->isTableItem) |
1640 | { |
||
1641 | TableItems.append(Neu); |
||
4026 | craig | 1642 | TableID.insert(obj.attribute("OwnLINK", "0").toInt(), Neu->ItemNr); |
234 | Franz | 1643 | } |
167 | Franz | 1644 | counter++; |
1645 | OBJ=OBJ.nextSibling(); |
||
114 | Franz | 1646 | } |
234 | Franz | 1647 | if (TableItems.count() != 0) |
1648 | { |
||
1649 | for (uint ttc = 0; ttc < TableItems.count(); ++ttc) |
||
1650 | { |
||
1651 | PageItem* ta = TableItems.at(ttc); |
||
1652 | if (ta->TopLinkID != -1) |
||
3727 | cbradney | 1653 | ta->TopLink = doc->Items->at(TableID[ta->TopLinkID]); |
234 | Franz | 1654 | else |
1655 | ta->TopLink = 0; |
||
1656 | if (ta->LeftLinkID != -1) |
||