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