~ubuntu-branches/ubuntu/trusty/scribus-ng/trusty

« back to all changes in this revision

Viewing changes to scribus/plugins/fileloader/scribus134format/scribus134format.cpp

  • Committer: Package Import Robot
  • Author(s): Oleksandr Moskalenko
  • Date: 2012-02-15 15:57:12 UTC
  • mfrom: (4.2.10 sid)
  • Revision ID: package-import@ubuntu.com-20120215155712-biimoc8o875jht80
Tags: 1.4.0.dfsg+r17300-1
* Prepare a dummy transitional package to converge on the 1.4.0 release.
* debian/NEWS: update the news.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
For general Scribus (>=1.3.2) copyright and licensing information please refer
3
 
to the COPYING file provided with the program. Following this notice may exist
4
 
a copyright and/or license notice that predates the release of Scribus 1.3.2
5
 
for which a new license (GPL+exception) is in place.
6
 
*/
7
 
#include "scribus134format.h"
8
 
#include "scribus134formatimpl.h"
9
 
 
10
 
#include "../../formatidlist.h"
11
 
#include "commonstrings.h"
12
 
#include "hyphenator.h"
13
 
#include "missing.h"
14
 
#include "pageitem_latexframe.h"
15
 
#include "prefsmanager.h"
16
 
#include "scclocale.h"
17
 
#include "scconfig.h"
18
 
#include "scpattern.h"
19
 
#include "scribusdoc.h"
20
 
#include "scribusview.h"
21
 
#include "sctextstream.h"
22
 
#include "sccolorengine.h"
23
 
#include "scribuscore.h"
24
 
#include "undomanager.h"
25
 
 
26
 
#include "units.h"
27
 
#include "util.h"
28
 
#include "util_math.h"
29
 
#include "util_color.h"
30
 
#include "scgzfile.h"
31
 
#include "scpattern.h"
32
 
#include <QCursor>
33
 
// #include <QDebug>
34
 
#include <QFileInfo>
35
 
#include <QList>
36
 
#include <QByteArray>
37
 
#include <QApplication>
38
 
 
39
 
 
40
 
// See scplugin.h and pluginmanager.{cpp,h} for detail on what these methods
41
 
// do. That documentatation is not duplicated here.
42
 
// Please don't implement the functionality of your plugin here; do that
43
 
// in scribus134formatimpl.h and scribus134formatimpl.cpp .
44
 
 
45
 
Scribus134Format::Scribus134Format() :
46
 
        LoadSavePlugin()
47
 
{
48
 
        // Set action info in languageChange, so we only have to do
49
 
        // it in one place. This includes registering file formats.
50
 
        languageChange();
51
 
}
52
 
 
53
 
Scribus134Format::~Scribus134Format()
54
 
{
55
 
        unregisterAll();
56
 
};
57
 
 
58
 
void Scribus134Format::languageChange()
59
 
{
60
 
        //(Re)register file formats.
61
 
        unregisterAll();
62
 
        registerFormats();
63
 
}
64
 
 
65
 
const QString Scribus134Format::fullTrName() const
66
 
{
67
 
        return QObject::tr("Scribus 1.3.4+ Support");
68
 
}
69
 
 
70
 
const ScActionPlugin::AboutData* Scribus134Format::getAboutData() const
71
 
{
72
 
        AboutData* about = new AboutData;
73
 
        Q_CHECK_PTR(about);
74
 
        about->authors = QString::fromUtf8(
75
 
                        "Franz Schmid <franz@scribus.info>, "
76
 
                        "The Scribus Team");
77
 
        about->shortDescription = tr("Scribus 1.3.4+ File Format Support");
78
 
        about->description = tr("Allows Scribus to read Scribus 1.3.4 and higher formatted files.");
79
 
        // about->version
80
 
        // about->releaseDate
81
 
        // about->copyright
82
 
        about->license = "GPL";
83
 
        return about;
84
 
}
85
 
 
86
 
void Scribus134Format::deleteAboutData(const AboutData* about) const
87
 
{
88
 
        Q_ASSERT(about);
89
 
        delete about;
90
 
}
91
 
 
92
 
void Scribus134Format::registerFormats()
93
 
{
94
 
        FileFormat fmt(this);
95
 
        fmt.trName = tr("Scribus 1.3.4+ Document");
96
 
        fmt.formatId = FORMATID_SLA134IMPORT;
97
 
        fmt.load = true;
98
 
        fmt.save = true;
99
 
        fmt.filter = fmt.trName + " (*.sla *.SLA *.sla.gz *.SLA.GZ *.scd *.SCD *.scd.gz *.SCD.GZ)";
100
 
        fmt.nameMatch = QRegExp("\\.(sla|scd)(\\.gz)?", Qt::CaseInsensitive);
101
 
        fmt.mimeTypes = QStringList();
102
 
        fmt.mimeTypes.append("application/x-scribus");
103
 
        fmt.priority = 64;
104
 
        registerFormat(fmt);
105
 
}
106
 
 
107
 
bool Scribus134Format::fileSupported(QIODevice* /* file */, const QString & fileName) const
108
 
{
109
 
        QByteArray docBytes("");
110
 
        if(fileName.right(2) == "gz")
111
 
        {
112
 
                if (!ScGzFile::readFromFile(fileName, docBytes, 4096))
113
 
                {
114
 
                        // FIXME: Needs better error return
115
 
                        return false;
116
 
                }
117
 
        }
118
 
        else
119
 
        {
120
 
                // Not gzip encoded, just load it
121
 
                loadRawText(fileName, docBytes);
122
 
        }
123
 
//      if (docBytes.left(16) == "<SCRIBUSUTF8NEW " && docBytes.left(35).contains("Version=\"1.3.4"))
124
 
//              return true;
125
 
        QRegExp regExp134("Version=\"1.3.[4-9]");
126
 
        QRegExp regExp140("Version=\"1.4.[0-9]");
127
 
        int startElemPos = docBytes.left(512).indexOf("<SCRIBUSUTF8NEW ");
128
 
        if (startElemPos >= 0)
129
 
        {
130
 
                bool is134 = ( regExp134.indexIn(docBytes.mid(startElemPos, 64)) >= 0 );
131
 
                bool is140 = ( regExp140.indexIn(docBytes.mid(startElemPos, 64)) >= 0 );
132
 
                return (is134 || is140);
133
 
        }
134
 
        return false;
135
 
}
136
 
 
137
 
QString Scribus134Format::readSLA(const QString & fileName)
138
 
{
139
 
        QByteArray docBytes("");
140
 
        if(fileName.right(2) == "gz")
141
 
        {
142
 
                if (!ScGzFile::readFromFile(fileName, docBytes))
143
 
                {
144
 
                        // FIXME: Needs better error return
145
 
                        return QString::null;
146
 
                }
147
 
        }
148
 
        else
149
 
        {
150
 
                // Not gzip encoded, just load it
151
 
                loadRawText(fileName, docBytes);
152
 
        }
153
 
        QString docText("");
154
 
        int startElemPos = docBytes.left(512).indexOf("<SCRIBUSUTF8NEW ");
155
 
        if (startElemPos >= 0)
156
 
        {
157
 
                QRegExp regExp134("Version=\"1.3.[4-9]");
158
 
                QRegExp regExp140("Version=\"1.4.[0-9]");
159
 
                bool is134 = ( regExp134.indexIn(docBytes.mid(startElemPos, 64)) >= 0 );
160
 
                bool is140 = ( regExp140.indexIn(docBytes.mid(startElemPos, 64)) >= 0 );
161
 
                if (is134 || is140)
162
 
                        docText = QString::fromUtf8(docBytes);
163
 
                if (docText.endsWith(QChar(10)) || docText.endsWith(QChar(13)))
164
 
                        docText.truncate(docText.length()-1);
165
 
        }
166
 
        if (docText.isEmpty())
167
 
                return QString::null;
168
 
        return docText;
169
 
}
170
 
 
171
 
void Scribus134Format::getReplacedFontData(bool & getNewReplacement, QMap<QString,QString> &getReplacedFonts, QList<ScFace> &getDummyScFaces)
172
 
{
173
 
        getNewReplacement=false;
174
 
        getReplacedFonts.clear();
175
 
}
176
 
 
177
 
bool Scribus134Format::loadFile(const QString & fileName, const FileFormat & /* fmt */, int /* flags */, int /* index */)
178
 
{
179
 
        if (m_Doc==0 || m_AvailableFonts==0)
180
 
        {
181
 
                Q_ASSERT(m_Doc==0 || m_AvailableFonts==0);
182
 
                return false;
183
 
        }
184
 
        ParagraphStyle vg;
185
 
        struct ScribusDoc::BookMa bok;
186
 
        int counter;//, Pgc;
187
 
        //bool AtFl;
188
 
        bool newVersion = false;
189
 
        QString tmp, tmpf, PgNam, Defont;
190
 
        QMap<int,int> TableID;
191
 
        QList<PageItem*> TableItems;
192
 
        QMap<int,int> TableIDM;
193
 
        QList<PageItem*> TableItemsM;
194
 
        QMap<int,int> TableIDF;
195
 
        QList<PageItem*> TableItemsF;
196
 
        QMap<PageItem*, int> groupID;
197
 
        QMap<PageItem*, int> groupIDM;
198
 
        QMap<PageItem*, int> groupIDF;
199
 
        int a;
200
 
        PageItem *Neu;
201
 
        Page* Apage;
202
 
        groupRemap.clear();
203
 
        itemRemap.clear();
204
 
        itemNext.clear();
205
 
        itemCount = 0;
206
 
        itemRemapM.clear();
207
 
        itemNextM.clear();
208
 
        itemCountM = 0;
209
 
        itemRemapF.clear();
210
 
        itemNextF.clear();
211
 
        itemCountF = 0;
212
 
        QDomDocument docu("scridoc");
213
 
        QString f(readSLA(fileName));
214
 
        if (f.isEmpty())
215
 
        {
216
 
                setFileReadError();
217
 
                return false;
218
 
        }
219
 
        QString fileDir = QFileInfo(fileName).absolutePath();
220
 
        /* 2004/10/02 - petr vanek - bug #1092 - missing <PAGE> crash Scribus. The check constraint moved into IsScribus()
221
 
        FIXME: I've add test on containig tag PAGE but returning false freezes S. in scribus.cpp need some hack too...  */
222
 
        QString errorMsg;
223
 
        int errorLine, errorColumn;
224
 
        if (!docu.setContent(f, &errorMsg, &errorLine, &errorColumn))
225
 
        {
226
 
                setDomParsingError(errorMsg, errorLine, errorColumn);
227
 
                return false;
228
 
        }
229
 
        m_Doc->PageColors.clear();
230
 
        m_Doc->Layers.clear();
231
 
        int layerToSetActive=0;
232
 
        ScColor lf = ScColor();
233
 
        QDomElement elem=docu.documentElement();
234
 
        if (elem.tagName() != "SCRIBUSUTF8NEW")
235
 
                return false;
236
 
        if (elem.hasAttribute("Version"))
237
 
                newVersion = true;
238
 
        QDomNode DOC=elem.firstChild();
239
 
        if (m_mwProgressBar!=0)
240
 
        {
241
 
                m_mwProgressBar->setMaximum(DOC.childNodes().count());
242
 
                m_mwProgressBar->setValue(0);
243
 
        }
244
 
        // Stop autosave timer,it will be restarted only if doc has autosave feature is enabled
245
 
        if (m_Doc->autoSaveTimer->isActive())
246
 
                m_Doc->autoSaveTimer->stop();
247
 
        int ObCount = 0;
248
 
        TableItems.clear();
249
 
        TableID.clear();
250
 
        TableItemsM.clear();
251
 
        TableIDM.clear();
252
 
        TableItemsF.clear();
253
 
        TableIDF.clear();
254
 
        PrefsManager* prefsManager=PrefsManager::instance();
255
 
        while(!DOC.isNull())
256
 
        {
257
 
                QDomElement dc=DOC.toElement();
258
 
        /*
259
 
        * Attribute von DOCUMENT auslesen
260
 
        */
261
 
                //CB Add this in to set this in the file in memory. Its saved, why not load it.
262
 
                //Will of course be replaced by per page settings although we still probably need a document default
263
 
                m_Doc->m_pageSize = dc.attribute("PAGESIZE");
264
 
                m_Doc->PageOri = dc.attribute("ORIENTATION", "0").toInt();
265
 
                m_Doc->FirstPnum = dc.attribute("FIRSTNUM", "1").toInt();
266
 
                m_Doc->currentPageLayout=dc.attribute("BOOK", "0").toInt();
267
 
                int fp;
268
 
                if (m_Doc->currentPageLayout == 0)
269
 
                        fp = 0;
270
 
                else
271
 
                {
272
 
                        if (dc.attribute("FIRSTLEFT", "0").toInt() == 1)
273
 
                                fp = 0;
274
 
                        else
275
 
                                fp = 1;
276
 
                }
277
 
                if (DOC.namedItem("PageSets").isNull())
278
 
                {
279
 
                        m_Doc->pageSets[m_Doc->currentPageLayout].FirstPage = fp;
280
 
//                      m_Doc->pageSets[m_Doc->currentPageLayout].GapHorizontal = dc.attribute("GapHorizontal", "0").toDouble();
281
 
//                      m_Doc->pageSets[m_Doc->currentPageLayout].GapVertical = 0.0;
282
 
//                      m_Doc->pageSets[m_Doc->currentPageLayout].GapBelow = dc.attribute("GapVertical", "40").toDouble();
283
 
                }
284
 
                m_Doc->setUsesAutomaticTextFrames(dc.attribute("AUTOTEXT").toInt());
285
 
                m_Doc->PageSp=dc.attribute("AUTOSPALTEN").toInt();
286
 
                m_Doc->PageSpa=ScCLocale::toDoubleC( dc.attribute("ABSTSPALTEN") );
287
 
                m_Doc->setUnitIndex(dc.attribute("UNITS", "0").toInt());
288
 
                m_Doc->toolSettings.defSize=qRound(ScCLocale::toDoubleC(dc.attribute("DSIZE")) * 10);
289
 
                Defont=dc.attribute("DFONT");
290
 
                m_AvailableFonts->findFont(Defont, m_Doc);
291
 
                m_Doc->toolSettings.defFont = Defont;
292
 
                m_Doc->toolSettings.dCols=dc.attribute("DCOL", "1").toInt();
293
 
                m_Doc->toolSettings.dGap=ScCLocale::toDoubleC(dc.attribute("DGAP"), 0.0);
294
 
                m_Doc->documentInfo.setAuthor(dc.attribute("AUTHOR"));
295
 
                m_Doc->documentInfo.setComments(dc.attribute("COMMENTS"));
296
 
                m_Doc->documentInfo.setKeywords(dc.attribute("KEYWORDS",""));
297
 
                m_Doc->documentInfo.setTitle(dc.attribute("TITLE"));
298
 
                m_Doc->documentInfo.setPublisher(dc.attribute("PUBLISHER", ""));
299
 
                m_Doc->documentInfo.setDate(dc.attribute("DOCDATE", ""));
300
 
                m_Doc->documentInfo.setType(dc.attribute("DOCTYPE", ""));
301
 
                m_Doc->documentInfo.setFormat(dc.attribute("DOCFORMAT", ""));
302
 
                m_Doc->documentInfo.setIdent(dc.attribute("DOCIDENT", ""));
303
 
                m_Doc->documentInfo.setSource(dc.attribute("DOCSOURCE", ""));
304
 
                m_Doc->documentInfo.setLangInfo(dc.attribute("DOCLANGINFO", ""));
305
 
                m_Doc->documentInfo.setRelation(dc.attribute("DOCRELATION", ""));
306
 
                m_Doc->documentInfo.setCover(dc.attribute("DOCCOVER", ""));
307
 
                m_Doc->documentInfo.setRights(dc.attribute("DOCRIGHTS", ""));
308
 
                m_Doc->documentInfo.setContrib(dc.attribute("DOCCONTRIB", ""));
309
 
                m_Doc->typographicSettings.valueSuperScript = dc.attribute("VHOCH").toInt();
310
 
                m_Doc->typographicSettings.scalingSuperScript = dc.attribute("VHOCHSC").toInt();
311
 
                m_Doc->typographicSettings.valueSubScript = dc.attribute("VTIEF").toInt();
312
 
                m_Doc->typographicSettings.scalingSubScript = dc.attribute("VTIEFSC").toInt();
313
 
                m_Doc->typographicSettings.valueSmallCaps = dc.attribute("VKAPIT").toInt();
314
 
                m_Doc->typographicSettings.valueBaseGrid = ScCLocale::toDoubleC(dc.attribute("BASEGRID"), 12.0);
315
 
                m_Doc->typographicSettings.offsetBaseGrid = ScCLocale::toDoubleC(dc.attribute("BASEO"), 0.0);
316
 
                m_Doc->typographicSettings.autoLineSpacing = dc.attribute("AUTOL", "20").toInt();
317
 
                m_Doc->typographicSettings.valueUnderlinePos = dc.attribute("UnderlinePos", "-1").toInt();
318
 
                m_Doc->typographicSettings.valueUnderlineWidth = dc.attribute("UnderlineWidth", "-1").toInt();
319
 
                m_Doc->typographicSettings.valueStrikeThruPos = dc.attribute("StrikeThruPos", "-1").toInt();
320
 
                m_Doc->typographicSettings.valueStrikeThruWidth = dc.attribute("StrikeThruWidth", "-1").toInt();
321
 
                m_Doc->GroupCounter = 1/*dc.attribute("GROUPC", "1").toInt()*/;
322
 
                //m_Doc->HasCMS = static_cast<bool>(dc.attribute("HCMS", "0").toInt());
323
 
                m_Doc->CMSSettings.SoftProofOn = static_cast<bool>(dc.attribute("DPSo", "0").toInt());
324
 
                m_Doc->CMSSettings.SoftProofFullOn = static_cast<bool>(dc.attribute("DPSFo", "0").toInt());
325
 
                m_Doc->CMSSettings.CMSinUse = static_cast<bool>(dc.attribute("DPuse", "0").toInt());
326
 
                m_Doc->CMSSettings.GamutCheck = static_cast<bool>(dc.attribute("DPgam", "0").toInt());
327
 
                m_Doc->CMSSettings.BlackPoint = static_cast<bool>(dc.attribute("DPbla", "1").toInt());
328
 
                m_Doc->CMSSettings.DefaultMonitorProfile = dc.attribute("DPMo","");
329
 
                m_Doc->CMSSettings.DefaultPrinterProfile = dc.attribute("DPPr","");
330
 
                m_Doc->CMSSettings.DefaultImageRGBProfile = dc.attribute("DPIn","");
331
 
                m_Doc->CMSSettings.DefaultImageCMYKProfile = dc.attribute("DPInCMYK","");
332
 
                m_Doc->CMSSettings.DefaultSolidColorRGBProfile = dc.attribute("DPIn2","");
333
 
                if (dc.hasAttribute("DPIn3"))
334
 
                        m_Doc->CMSSettings.DefaultSolidColorCMYKProfile = dc.attribute("DPIn3","");
335
 
                else
336
 
                        m_Doc->CMSSettings.DefaultSolidColorCMYKProfile = dc.attribute("DPPr","");
337
 
                //m_Doc->CMSSettings.DefaultIntentPrinter = dc.attribute("DIPr", "0").toInt();
338
 
                //m_Doc->CMSSettings.DefaultIntentMonitor = dc.attribute("DIMo", "1").toInt();
339
 
                m_Doc->CMSSettings.DefaultIntentColors = (eRenderIntent) dc.attribute("DISc", "1").toInt();
340
 
                m_Doc->CMSSettings.DefaultIntentImages = (eRenderIntent) dc.attribute("DIIm", "0").toInt();
341
 
                layerToSetActive=dc.attribute("ALAYER", "0").toInt();
342
 
                m_Doc->Language = dc.attribute("LANGUAGE", "");
343
 
                m_Doc->MinWordLen = dc.attribute("MINWORDLEN", "3").toInt();
344
 
                m_Doc->HyCount = dc.attribute("HYCOUNT", "2").toInt();
345
 
                if (dc.hasAttribute("PAGEWIDTH"))
346
 
                        m_Doc->pageWidth=ScCLocale::toDoubleC(dc.attribute("PAGEWIDTH"));
347
 
                else
348
 
                        m_Doc->pageWidth=ScCLocale::toDoubleC(dc.attribute("PAGEWITH"));
349
 
                m_Doc->pageHeight=ScCLocale::toDoubleC(dc.attribute("PAGEHEIGHT"));
350
 
                m_Doc->pageMargins.Left=qMax(0.0, ScCLocale::toDoubleC(dc.attribute("BORDERLEFT")));
351
 
                m_Doc->pageMargins.Right=qMax(0.0, ScCLocale::toDoubleC(dc.attribute("BORDERRIGHT")));
352
 
                m_Doc->pageMargins.Top=qMax(0.0, ScCLocale::toDoubleC(dc.attribute("BORDERTOP")));
353
 
                m_Doc->pageMargins.Bottom=qMax(0.0, ScCLocale::toDoubleC(dc.attribute("BORDERBOTTOM")));
354
 
                m_Doc->marginPreset = dc.attribute("PRESET", "0").toInt();
355
 
                m_Doc->bleeds.Top    = ScCLocale::toDoubleC(dc.attribute("BleedTop"), 0.0);
356
 
                m_Doc->bleeds.Left   = ScCLocale::toDoubleC(dc.attribute("BleedLeft"), 0.0);
357
 
                m_Doc->bleeds.Right  = ScCLocale::toDoubleC(dc.attribute("BleedRight"), 0.0);
358
 
                m_Doc->bleeds.Bottom = ScCLocale::toDoubleC(dc.attribute("BleedBottom"), 0.0);
359
 
                m_Doc->Automatic = static_cast<bool>(dc.attribute("AUTOMATIC", "1").toInt());
360
 
                m_Doc->AutoCheck = static_cast<bool>(dc.attribute("AUTOCHECK", "0").toInt());
361
 
                m_Doc->GuideLock = static_cast<bool>(dc.attribute("GUIDELOCK", "0").toInt());
362
 
                m_Doc->guidesSettings.minorGrid = ScCLocale::toDoubleC(dc.attribute("MINGRID"), prefsManager->appPrefs.guidesSettings.minorGrid);
363
 
                m_Doc->guidesSettings.majorGrid = ScCLocale::toDoubleC(dc.attribute("MAJGRID"), prefsManager->appPrefs.guidesSettings.majorGrid);
364
 
                m_Doc->guidesSettings.gridShown = static_cast<bool>(dc.attribute("SHOWGRID", "0").toInt());
365
 
                m_Doc->guidesSettings.guidesShown = static_cast<bool>(dc.attribute("SHOWGUIDES", "1").toInt());
366
 
                m_Doc->guidesSettings.colBordersShown = static_cast<bool>(dc.attribute("showcolborders", "0").toInt());
367
 
                m_Doc->guidesSettings.framesShown = static_cast<bool>(dc.attribute("SHOWFRAME", "1").toInt());
368
 
                m_Doc->guidesSettings.layerMarkersShown = static_cast<bool>(dc.attribute("SHOWLAYERM", "0").toInt());
369
 
                m_Doc->guidesSettings.marginsShown = static_cast<bool>(dc.attribute("SHOWMARGIN", "1").toInt());
370
 
                m_Doc->guidesSettings.baseShown = static_cast<bool>(dc.attribute("SHOWBASE", "0").toInt());
371
 
                m_Doc->guidesSettings.showPic = static_cast<bool>(dc.attribute("SHOWPICT", "1").toInt());
372
 
                m_Doc->guidesSettings.linkShown = static_cast<bool>(dc.attribute("SHOWLINK", "0").toInt());
373
 
                m_Doc->guidesSettings.showControls = static_cast<bool>(dc.attribute("SHOWControl", "0").toInt());
374
 
                m_Doc->guidesSettings.rulerMode = static_cast<bool>(dc.attribute("rulerMode", "1").toInt());
375
 
                m_Doc->guidesSettings.rulersShown = static_cast<bool>(dc.attribute("showrulers", "1").toInt());
376
 
                m_Doc->guidesSettings.showBleed = static_cast<bool>(dc.attribute("showBleed", "1").toInt());
377
 
                m_Doc->rulerXoffset = ScCLocale::toDoubleC(dc.attribute("rulerXoffset"), 0.0);
378
 
                m_Doc->rulerYoffset = ScCLocale::toDoubleC(dc.attribute("rulerYoffset"), 0.0);
379
 
                m_Doc->SnapGuides = static_cast<bool>(dc.attribute("SnapToGuides", "0").toInt());
380
 
                m_Doc->useRaster = static_cast<bool>(dc.attribute("SnapToGrid", "0").toInt());
381
 
                m_Doc->toolSettings.polyC = dc.attribute("POLYC", "4").toInt();
382
 
                m_Doc->toolSettings.polyF = ScCLocale::toDoubleC(dc.attribute("POLYF"), 0.5);
383
 
                m_Doc->toolSettings.polyR = ScCLocale::toDoubleC(dc.attribute("POLYR"), 0.0);
384
 
                m_Doc->toolSettings.polyCurvature = ScCLocale::toDoubleC(dc.attribute("POLYCUR"), 0.0);
385
 
                m_Doc->toolSettings.polyFd = dc.attribute("POLYFD", "0").toInt();
386
 
                m_Doc->toolSettings.polyS = static_cast<bool>(dc.attribute("POLYS", "0").toInt());
387
 
                m_Doc->AutoSave = static_cast<bool>(dc.attribute("AutoSave", "0").toInt());
388
 
                m_Doc->AutoSaveTime = dc.attribute("AutoSaveTime", "600000").toInt();
389
 
                m_Doc->scratch.Bottom = ScCLocale::toDoubleC(dc.attribute("ScratchBottom"), 20.0);
390
 
                // FIXME A typo in early 1.3cvs (MAR 05) means we must support loading of
391
 
                // FIXME 'ScatchLeft' for a while too. This can be removed in a few months.
392
 
                if (dc.hasAttribute("ScatchLeft"))
393
 
                        m_Doc->scratch.Left = ScCLocale::toDoubleC( dc.attribute("ScatchLeft"), 100.0);
394
 
                else
395
 
                        m_Doc->scratch.Left = ScCLocale::toDoubleC( dc.attribute("ScratchLeft"), 100.0);
396
 
                m_Doc->scratch.Right = ScCLocale::toDoubleC( dc.attribute("ScratchRight"), 100.0);
397
 
                m_Doc->scratch.Top   = ScCLocale::toDoubleC( dc.attribute("ScratchTop"), 20.0);
398
 
                m_Doc->GapHorizontal = ScCLocale::toDoubleC( dc.attribute("GapHorizontal"), -1.0);
399
 
                m_Doc->GapVertical   = ScCLocale::toDoubleC( dc.attribute("GapVertical"), -1.0);
400
 
                m_Doc->toolSettings.dStartArrow = dc.attribute("StartArrow", "0").toInt();
401
 
                m_Doc->toolSettings.dEndArrow = dc.attribute("EndArrow", "0").toInt();
402
 
                m_Doc->toolSettings.scaleX = ScCLocale::toDoubleC( dc.attribute("PICTSCX"), 1.0);
403
 
                m_Doc->toolSettings.scaleY = ScCLocale::toDoubleC( dc.attribute("PICTSCY"), 1.0);
404
 
                m_Doc->toolSettings.scaleType = static_cast<bool>(dc.attribute("PSCALE", "1").toInt());
405
 
                m_Doc->toolSettings.aspectRatio = static_cast<bool>(dc.attribute("PASPECT", "0").toInt());
406
 
                m_Doc->toolSettings.lowResType = dc.attribute("HalfRes", "1").toInt();
407
 
                m_Doc->toolSettings.useEmbeddedPath = static_cast<bool>(dc.attribute("EmbeddedPath", "0").toInt());
408
 
                if (dc.hasAttribute("PEN"))
409
 
                        m_Doc->toolSettings.dPen = dc.attribute("PEN");
410
 
                if (dc.hasAttribute("BRUSH"))
411
 
                        m_Doc->toolSettings.dBrush = dc.attribute("BRUSH");
412
 
                if (dc.hasAttribute("PENLINE"))
413
 
                        m_Doc->toolSettings.dPenLine = dc.attribute("PENLINE");
414
 
                if (dc.hasAttribute("PENTEXT"))
415
 
                        m_Doc->toolSettings.dPenText = dc.attribute("PENTEXT");
416
 
                if (dc.hasAttribute("StrokeText"))
417
 
                        m_Doc->toolSettings.dStrokeText = dc.attribute("StrokeText");
418
 
                m_Doc->toolSettings.dTextBackGround = dc.attribute("TextBackGround", CommonStrings::None);
419
 
                m_Doc->toolSettings.dTextLineColor = dc.attribute("TextLineColor", CommonStrings::None);
420
 
                m_Doc->toolSettings.dTextBackGroundShade = dc.attribute("TextBackGroundShade", "100").toInt();
421
 
                m_Doc->toolSettings.dTextLineShade = dc.attribute("TextLineShade", "100").toInt();
422
 
                m_Doc->toolSettings.dTextPenShade = dc.attribute("TextPenShade", "100").toInt();
423
 
                m_Doc->toolSettings.dTextStrokeShade = dc.attribute("TextStrokeShade", "100").toInt();
424
 
                m_Doc->toolSettings.dLineArt = static_cast<Qt::PenStyle>(dc.attribute("STIL").toInt());
425
 
                m_Doc->toolSettings.dLstyleLine = static_cast<Qt::PenStyle>(dc.attribute("STILLINE").toInt());
426
 
                m_Doc->toolSettings.dWidth = ScCLocale::toDoubleC( dc.attribute("WIDTH"), 0.0);
427
 
                m_Doc->toolSettings.dWidthLine = ScCLocale::toDoubleC( dc.attribute("WIDTHLINE"), 1.0);
428
 
                m_Doc->toolSettings.dShade2 = dc.attribute("PENSHADE", "100").toInt();
429
 
                m_Doc->toolSettings.dShadeLine = dc.attribute("LINESHADE", "100").toInt();
430
 
                m_Doc->toolSettings.dShade = dc.attribute("BRUSHSHADE", "100").toInt();
431
 
                m_Doc->toolSettings.magMin = dc.attribute("MAGMIN", "1").toInt();
432
 
                m_Doc->toolSettings.magMax = dc.attribute("MAGMAX", "3200").toInt();
433
 
                m_Doc->toolSettings.magStep = dc.attribute("MAGSTEP", "200").toInt();
434
 
                m_Doc->toolSettings.dispX = ScCLocale::toDoubleC( dc.attribute("dispX"), 10.0);
435
 
                m_Doc->toolSettings.dispY = ScCLocale::toDoubleC( dc.attribute("dispY"), 10.0);
436
 
                m_Doc->toolSettings.constrain = ScCLocale::toDoubleC( dc.attribute("constrain"), 15.0);
437
 
                //CB Reset doc zoom step value to 200% instead of old values.
438
 
                if (m_Doc->toolSettings.magStep <= 100)
439
 
                        m_Doc->toolSettings.magStep = 200;
440
 
                m_Doc->toolSettings.tabFillChar = dc.attribute("TabFill","");
441
 
                m_Doc->toolSettings.dTabWidth= ScCLocale::toDoubleC(dc.attribute("TabWidth"), 36.0);
442
 
                if (dc.hasAttribute("CPICT"))
443
 
                        m_Doc->toolSettings.dBrushPict = dc.attribute("CPICT");
444
 
                m_Doc->toolSettings.shadePict = dc.attribute("PICTSHADE", "100").toInt();
445
 
                if (dc.hasAttribute("PAGEC"))
446
 
                        m_Doc->papColor = QColor(dc.attribute("PAGEC"));
447
 
                if (dc.hasAttribute("MARGC"))
448
 
                        m_Doc->guidesSettings.margColor = QColor(dc.attribute("MARGC"));
449
 
                if (dc.hasAttribute("MINORC"))
450
 
                        m_Doc->guidesSettings.minorColor = QColor(dc.attribute("MINORC"));
451
 
                if (dc.hasAttribute("MAJORC"))
452
 
                        m_Doc->guidesSettings.majorColor = QColor(dc.attribute("MAJORC"));
453
 
                if (dc.hasAttribute("GuideC"))
454
 
                        m_Doc->guidesSettings.guideColor = QColor(dc.attribute("GuideC"));
455
 
                if (dc.hasAttribute("BaseC"))
456
 
                        m_Doc->guidesSettings.baseColor = QColor(dc.attribute("BaseC"));
457
 
                m_Doc->marginColored = static_cast<bool>(dc.attribute("RANDF", "0").toInt());
458
 
                m_Doc->guidesSettings.before = static_cast<bool>(dc.attribute("BACKG", "1").toInt());
459
 
                m_Doc->guidesSettings.guideRad = ScCLocale::toDoubleC( dc.attribute("GuideRad"), 10.0);
460
 
                m_Doc->guidesSettings.grabRad = dc.attribute("GRAB", "4").toInt();
461
 
                if (dc.hasAttribute("currentProfile"))
462
 
                {
463
 
                        m_Doc->checkerProfiles.clear();
464
 
                        m_Doc->curCheckProfile = dc.attribute("currentProfile");
465
 
                }
466
 
                m_Doc->LastAuto = 0;
467
 
                QDomNode PAGE=DOC.firstChild();
468
 
                counter = 0;
469
 
                while(!PAGE.isNull())
470
 
                {
471
 
                        ObCount++;
472
 
                        if (m_mwProgressBar!=0)
473
 
                                m_mwProgressBar->setValue(ObCount);
474
 
                        QDomElement pg=PAGE.toElement();
475
 
                        if (pg.tagName()=="PageSets")
476
 
                        {
477
 
                                QDomNode PGS = PAGE.firstChild();
478
 
                                m_Doc->pageSets.clear();
479
 
                                while(!PGS.isNull())
480
 
                                {
481
 
                                        QDomElement PgsAttr = PGS.toElement();
482
 
                                        if(PgsAttr.tagName() == "Set")
483
 
                                        {
484
 
                                                struct PageSet pageS;
485
 
                                                pageS.Name = CommonStrings::untranslatePageSetString(PgsAttr.attribute("Name"));
486
 
                                                pageS.FirstPage = PgsAttr.attribute("FirstPage", "0").toInt();
487
 
                                                pageS.Rows = PgsAttr.attribute("Rows", "1").toInt();
488
 
                                                pageS.Columns = PgsAttr.attribute("Columns", "1").toInt();
489
 
//                                              pageS.GapHorizontal = ScCLocale::toDoubleC( PgsAttr.attribute("GapHorizontal", "0"));
490
 
//                                              pageS.GapVertical = ScCLocale::toDoubleC( PgsAttr.attribute("GapVertical", "0"));
491
 
//                                              pageS.GapBelow = ScCLocale::toDoubleC( PgsAttr.attribute("GapBelow", "0"));
492
 
                                                pageS.pageNames.clear();
493
 
                                                QDomNode PGSN = PGS.firstChild();
494
 
                                                while(!PGSN.isNull())
495
 
                                                {
496
 
                                                        QDomElement PgsAttrN = PGSN.toElement();
497
 
                                                        if(PgsAttrN.tagName() == "PageNames")
498
 
                                                                pageS.pageNames.append(CommonStrings::untranslatePageSetLocString(PgsAttrN.attribute("Name")));
499
 
                                                        PGSN = PGSN.nextSibling();
500
 
                                                }
501
 
                                                m_Doc->pageSets.append(pageS);
502
 
                                                if ((m_Doc->pageSets.count()-1 == m_Doc->currentPageLayout) && ((m_Doc->GapHorizontal < 0) && (m_Doc->GapVertical < 0)))
503
 
                                                {
504
 
                                                        m_Doc->GapHorizontal = ScCLocale::toDoubleC( PgsAttr.attribute("GapHorizontal"), 0.0);
505
 
                                                        m_Doc->GapVertical   = ScCLocale::toDoubleC( PgsAttr.attribute("GapBelow"), 0.0);
506
 
                                                }
507
 
                                        }
508
 
                                        PGS = PGS.nextSibling();
509
 
                                }
510
 
                        }
511
 
                        if (pg.tagName()=="CheckProfile")
512
 
                        {
513
 
                                struct checkerPrefs checkerSettings;
514
 
                                checkerSettings.ignoreErrors = static_cast<bool>(pg.attribute("ignoreErrors", "0").toInt());
515
 
                                checkerSettings.autoCheck = static_cast<bool>(pg.attribute("autoCheck", "1").toInt());
516
 
                                checkerSettings.checkGlyphs = static_cast<bool>(pg.attribute("checkGlyphs", "1").toInt());
517
 
                                checkerSettings.checkOrphans = static_cast<bool>(pg.attribute("checkOrphans", "1").toInt());
518
 
                                checkerSettings.checkOverflow = static_cast<bool>(pg.attribute("checkOverflow", "1").toInt());
519
 
                                checkerSettings.checkPictures = static_cast<bool>(pg.attribute("checkPictures", "1").toInt());
520
 
                                checkerSettings.checkResolution = static_cast<bool>(pg.attribute("checkResolution", "1").toInt());
521
 
                                checkerSettings.checkTransparency = static_cast<bool>(pg.attribute("checkTransparency", "1").toInt());
522
 
                                checkerSettings.minResolution = ScCLocale::toDoubleC( pg.attribute("minResolution"), 72.0);
523
 
                                checkerSettings.maxResolution = ScCLocale::toDoubleC( pg.attribute("maxResolution"), 4800.0);
524
 
                                checkerSettings.checkAnnotations = static_cast<bool>(pg.attribute("checkAnnotations", "0").toInt());
525
 
                                checkerSettings.checkRasterPDF = static_cast<bool>(pg.attribute("checkRasterPDF", "1").toInt());
526
 
                                checkerSettings.checkForGIF = static_cast<bool>(pg.attribute("checkForGIF", "1").toInt());
527
 
                                checkerSettings.ignoreOffLayers = static_cast<bool>(pg.attribute("ignoreOffLayers", "0").toInt());
528
 
                                checkerSettings.checkOffConflictLayers = static_cast<bool>(pg.attribute("checkOffConflictLayers", "0").toInt());
529
 
                                m_Doc->checkerProfiles[pg.attribute("Name")] = checkerSettings;
530
 
                        }
531
 
                        // 10/25/2004 pv - None is "reserved" color. cannot be defined in any file...
532
 
                        if(pg.tagName()=="COLOR" && pg.attribute("NAME")!=CommonStrings::None)
533
 
                        {
534
 
                                if (pg.hasAttribute("CMYK"))
535
 
                                        lf.setNamedColor(pg.attribute("CMYK"));
536
 
                                else
537
 
                                        lf.fromQColor(QColor(pg.attribute("RGB")));
538
 
                                if (pg.hasAttribute("Spot"))
539
 
                                        lf.setSpotColor(static_cast<bool>(pg.attribute("Spot").toInt()));
540
 
                                else
541
 
                                        lf.setSpotColor(false);
542
 
                                if (pg.hasAttribute("Register"))
543
 
                                        lf.setRegistrationColor(static_cast<bool>(pg.attribute("Register").toInt()));
544
 
                                else
545
 
                                        lf.setRegistrationColor(false);
546
 
                                QString name = pg.attribute("NAME");
547
 
                                m_Doc->PageColors.insert((name.isEmpty()) ? lf.name() : name, lf);
548
 
                        }
549
 
                        if(pg.tagName()=="STYLE")
550
 
                        {
551
 
                                readParagraphStyle(vg, pg, *m_AvailableFonts, m_Doc);
552
 
                                StyleSet<ParagraphStyle>tmp;
553
 
                                tmp.create(vg);
554
 
                                m_Doc->redefineStyles(tmp, false);
555
 
                        }
556
 
                        if(pg.tagName()=="CHARSTYLE")
557
 
                        {
558
 
                                readParagraphStyle(vg, pg, *m_AvailableFonts, m_Doc);
559
 
                                StyleSet<CharStyle> temp;
560
 
                                temp.create(vg.charStyle());
561
 
                                m_Doc->redefineCharStyles(temp, false);
562
 
                        }
563
 
                        if(pg.tagName()=="JAVA")
564
 
                                m_Doc->JavaScripts[pg.attribute("NAME")] = pg.attribute("SCRIPT");
565
 
                        if(pg.tagName()=="LAYERS")
566
 
                        {
567
 
                                int lnr   = pg.attribute("NUMMER").toInt();
568
 
                                int level = pg.attribute("LEVEL").toInt();
569
 
                                ScLayer la( pg.attribute("NAME"), level, lnr);
570
 
                                la.isViewable   = pg.attribute("SICHTBAR").toInt();
571
 
                                la.isPrintable  = pg.attribute("DRUCKEN").toInt();
572
 
                                la.isEditable   = pg.attribute("EDIT", "1").toInt();
573
 
                                la.flowControl  = pg.attribute("FLOW", "1").toInt();
574
 
                                la.transparency = ScCLocale::toDoubleC( pg.attribute("TRANS"), 1.0);
575
 
                                la.blendMode    = pg.attribute("BLEND", "0").toInt();
576
 
                                la.outlineMode  = pg.attribute("OUTL", "0").toInt();
577
 
                                if (pg.hasAttribute("LAYERC"))
578
 
                                        la.markerColor =  QColor(pg.attribute("LAYERC","#000000"));
579
 
                                m_Doc->Layers.append(la);
580
 
                        }
581
 
/*                      if(pg.tagName()=="Bookmark")
582
 
                        {
583
 
                                bok.Title = pg.attribute("Title");
584
 
                                bok.Text = pg.attribute("Text");
585
 
                                bok.Aktion = pg.attribute("Aktion");
586
 
                                bok.ItemNr = pg.attribute("ItemNr").toInt();
587
 
                                bok.Seite = pg.attribute("Seite").toInt();
588
 
                                bok.Element = pg.attribute("Element").toInt();
589
 
                                bok.First = pg.attribute("First").toInt();
590
 
                                bok.Last = pg.attribute("Last").toInt();
591
 
                                bok.Prev = pg.attribute("Prev").toInt();
592
 
                                bok.Next = pg.attribute("Next").toInt();
593
 
                                bok.Parent = pg.attribute("Parent").toInt();
594
 
                                m_Doc->BookMarks.append(bok);
595
 
                        } */
596
 
                        if(pg.tagName()=="MultiLine")
597
 
                        {
598
 
                                multiLine ml;
599
 
                                QDomNode MuLn = PAGE.firstChild();
600
 
                                while(!MuLn.isNull())
601
 
                                {
602
 
                                        QDomElement MuL = MuLn.toElement();
603
 
                                        struct SingleLine sl;
604
 
                                        sl.Color = MuL.attribute("Color");
605
 
                                        sl.Dash = MuL.attribute("Dash").toInt();
606
 
                                        sl.LineEnd = MuL.attribute("LineEnd").toInt();
607
 
                                        sl.LineJoin = MuL.attribute("LineJoin").toInt();
608
 
                                        sl.Shade = MuL.attribute("Shade").toInt();
609
 
                                        sl.Width = ScCLocale::toDoubleC( MuL.attribute("Width"));
610
 
                                        ml.shortcut = MuL.attribute("Shortcut");
611
 
                                        ml.push_back(sl);
612
 
                                        MuLn = MuLn.nextSibling();
613
 
                                }
614
 
                                m_Doc->MLineStyles.insert(pg.attribute("Name"), ml);
615
 
                        }
616
 
                        if(pg.tagName()=="Arrows")
617
 
                        {
618
 
                                struct ArrowDesc arrow;
619
 
                                arrow.name = pg.attribute("Name");
620
 
                                arrow.userArrow = true;
621
 
                                double xa, ya;
622
 
                                QString tmp = pg.attribute("Points");
623
 
                                ScTextStream fp(&tmp, QIODevice::ReadOnly);
624
 
                                for (uint cx = 0; cx < pg.attribute("NumPoints").toUInt(); ++cx)
625
 
                                {
626
 
                                        fp >> xa;
627
 
                                        fp >> ya;
628
 
                                        arrow.points.addPoint(xa, ya);
629
 
                                }
630
 
                                m_Doc->arrowStyles.append(arrow);
631
 
                        }
632
 
                        if(pg.tagName()=="Printer")
633
 
                        {
634
 
                                m_Doc->Print_Options.firstUse = static_cast<bool>(pg.attribute("firstUse").toInt());
635
 
                                m_Doc->Print_Options.toFile = static_cast<bool>(pg.attribute("toFile").toInt());
636
 
                                m_Doc->Print_Options.useAltPrintCommand = static_cast<bool>(pg.attribute("useAltPrintCommand").toInt());
637
 
                                m_Doc->Print_Options.outputSeparations = static_cast<bool>(pg.attribute("outputSeparations").toInt());
638
 
                                m_Doc->Print_Options.useSpotColors = static_cast<bool>(pg.attribute("useSpotColors").toInt());
639
 
                                m_Doc->Print_Options.useColor = static_cast<bool>(pg.attribute("useColor").toInt());
640
 
                                m_Doc->Print_Options.mirrorH = static_cast<bool>(pg.attribute("mirrorH").toInt());
641
 
                                m_Doc->Print_Options.mirrorV = static_cast<bool>(pg.attribute("mirrorV").toInt());
642
 
                                m_Doc->Print_Options.useICC = static_cast<bool>(pg.attribute("useICC").toInt());
643
 
                                m_Doc->Print_Options.doGCR = static_cast<bool>(pg.attribute("doGCR").toInt());
644
 
                                m_Doc->Print_Options.doClip = static_cast<bool>(pg.attribute("doClip").toInt());
645
 
                                m_Doc->Print_Options.setDevParam = static_cast<bool>(pg.attribute("setDevParam").toInt());
646
 
                                m_Doc->Print_Options.useDocBleeds = static_cast<bool>(pg.attribute("useDocBleeds").toInt());
647
 
                                m_Doc->Print_Options.cropMarks = static_cast<bool>(pg.attribute("cropMarks").toInt());
648
 
                                m_Doc->Print_Options.bleedMarks = static_cast<bool>(pg.attribute("bleedMarks").toInt());
649
 
                                m_Doc->Print_Options.registrationMarks = static_cast<bool>(pg.attribute("registrationMarks").toInt());
650
 
                                m_Doc->Print_Options.colorMarks = static_cast<bool>(pg.attribute("colorMarks").toInt());
651
 
                                m_Doc->Print_Options.includePDFMarks = static_cast<bool>(pg.attribute("includePDFMarks", "1").toInt());
652
 
                                if (pg.hasAttribute("PrintEngine"))
653
 
                                        m_Doc->Print_Options.prnEngine = (PrintEngine) pg.attribute("PrintEngine", "3").toInt();
654
 
                                else
655
 
                                        m_Doc->Print_Options.prnEngine = (PrintEngine) pg.attribute("PSLevel", "3").toInt();
656
 
                                m_Doc->Print_Options.markOffset = ScCLocale::toDoubleC( pg.attribute("markOffset"));
657
 
                                m_Doc->Print_Options.bleeds.Top = ScCLocale::toDoubleC( pg.attribute("BleedTop"));
658
 
                                m_Doc->Print_Options.bleeds.Left = ScCLocale::toDoubleC( pg.attribute("BleedLeft"));
659
 
                                m_Doc->Print_Options.bleeds.Right = ScCLocale::toDoubleC( pg.attribute("BleedRight"));
660
 
                                m_Doc->Print_Options.bleeds.Bottom = ScCLocale::toDoubleC( pg.attribute("BleedBottom"));
661
 
                                m_Doc->Print_Options.printer = pg.attribute("printer");
662
 
                                m_Doc->Print_Options.filename = pg.attribute("filename");
663
 
                                m_Doc->Print_Options.separationName = pg.attribute("separationName");
664
 
                                m_Doc->Print_Options.printerCommand = pg.attribute("printerCommand");
665
 
                                m_Doc->Print_Options.copies = 1;
666
 
                                QDomNode PFO = PAGE.firstChild();
667
 
                                while(!PFO.isNull())
668
 
                                {
669
 
                                        QDomElement pdfF = PFO.toElement();
670
 
                                        if(pdfF.tagName() == "Separation")
671
 
                                                m_Doc->Print_Options.allSeparations.append(pdfF.attribute("Name"));
672
 
                                        PFO = PFO.nextSibling();
673
 
                                }
674
 
                        }
675
 
                        if(pg.tagName()=="PDF")
676
 
                        {
677
 
                                m_Doc->PDF_Options.Articles = static_cast<bool>(pg.attribute("Articles").toInt());
678
 
                                m_Doc->PDF_Options.Thumbnails = static_cast<bool>(pg.attribute("Thumbnails").toInt());
679
 
                                m_Doc->PDF_Options.Compress = static_cast<bool>(pg.attribute("Compress").toInt());
680
 
                                m_Doc->PDF_Options.CompressMethod = (PDFOptions::PDFCompression) pg.attribute("CMethod", "0").toInt();
681
 
                                m_Doc->PDF_Options.Quality = pg.attribute("Quality", "0").toInt();
682
 
                                m_Doc->PDF_Options.RecalcPic = static_cast<bool>(pg.attribute("RecalcPic").toInt());
683
 
                                m_Doc->PDF_Options.Bookmarks = static_cast<bool>(pg.attribute("Bookmarks").toInt());
684
 
                                if (pg.hasAttribute("firstUse"))
685
 
                                        m_Doc->PDF_Options.firstUse = static_cast<bool>(pg.attribute("firstUse").toInt());
686
 
                                else
687
 
                                        m_Doc->PDF_Options.firstUse = true;
688
 
                                if (pg.hasAttribute("MirrorH"))
689
 
                                        m_Doc->PDF_Options.MirrorH = static_cast<bool>(pg.attribute("MirrorH").toInt());
690
 
                                else
691
 
                                        m_Doc->PDF_Options.MirrorH = false;
692
 
                                if (pg.hasAttribute("MirrorV"))
693
 
                                        m_Doc->PDF_Options.MirrorV = static_cast<bool>(pg.attribute("MirrorV").toInt());
694
 
                                else
695
 
                                        m_Doc->PDF_Options.MirrorV = false;
696
 
                                if (pg.hasAttribute("RotateDeg"))
697
 
                                        m_Doc->PDF_Options.RotateDeg = pg.attribute("RotateDeg", "0").toInt();
698
 
                                else
699
 
                                        m_Doc->PDF_Options.RotateDeg = 0;
700
 
                                if (pg.hasAttribute("Clip"))
701
 
                                        m_Doc->PDF_Options.doClip = static_cast<bool>(pg.attribute("Clip").toInt());
702
 
                                else
703
 
                                        m_Doc->PDF_Options.doClip = false;
704
 
                                m_Doc->PDF_Options.PresentMode = static_cast<bool>(pg.attribute("PresentMode").toInt());
705
 
                                m_Doc->PDF_Options.PicRes = pg.attribute("PicRes").toInt();
706
 
                                // Fixme: check input pdf version
707
 
                                m_Doc->PDF_Options.Version = (PDFOptions::PDFVersion)pg.attribute("Version").toInt();
708
 
                                m_Doc->PDF_Options.Resolution = pg.attribute("Resolution").toInt();
709
 
                                m_Doc->PDF_Options.Binding = pg.attribute("Binding").toInt();
710
 
                                m_Doc->PDF_Options.fileName = "";
711
 
                                m_Doc->PDF_Options.isGrayscale = static_cast<bool>(pg.attribute("Grayscale", "0").toInt());
712
 
                                m_Doc->PDF_Options.UseRGB = static_cast<bool>(pg.attribute("RGBMode", "0").toInt());
713
 
                                m_Doc->PDF_Options.UseProfiles = static_cast<bool>(pg.attribute("UseProfiles", "0").toInt());
714
 
                                m_Doc->PDF_Options.UseProfiles2 = static_cast<bool>(pg.attribute("UseProfiles2", "0").toInt());
715
 
                                m_Doc->PDF_Options.Intent = pg.attribute("Intent", "1").toInt();
716
 
                                m_Doc->PDF_Options.Intent2 = pg.attribute("Intent2", "1").toInt();
717
 
                                m_Doc->PDF_Options.SolidProf = pg.attribute("SolidP", "");
718
 
                                m_Doc->PDF_Options.ImageProf = pg.attribute("ImageP", "");
719
 
                                m_Doc->PDF_Options.PrintProf = pg.attribute("PrintP", "");
720
 
                                m_Doc->PDF_Options.Info = pg.attribute("InfoString", "");
721
 
                                m_Doc->PDF_Options.bleeds.Top    = ScCLocale::toDoubleC( pg.attribute("BTop"), 0.0);
722
 
                                m_Doc->PDF_Options.bleeds.Left   = ScCLocale::toDoubleC( pg.attribute("BLeft"), 0.0);
723
 
                                m_Doc->PDF_Options.bleeds.Right  = ScCLocale::toDoubleC( pg.attribute("BRight"), 0.0);
724
 
                                m_Doc->PDF_Options.bleeds.Bottom = ScCLocale::toDoubleC( pg.attribute("BBottom"), 0.0);
725
 
                                m_Doc->PDF_Options.useDocBleeds = static_cast<bool>(pg.attribute("useDocBleeds", "1").toInt());
726
 
                                m_Doc->PDF_Options.cropMarks = static_cast<bool>(pg.attribute("cropMarks", "0").toInt());
727
 
                                m_Doc->PDF_Options.bleedMarks = static_cast<bool>(pg.attribute("bleedMarks", "0").toInt());
728
 
                                m_Doc->PDF_Options.registrationMarks = static_cast<bool>(pg.attribute("registrationMarks", "0").toInt());
729
 
                                m_Doc->PDF_Options.colorMarks = static_cast<bool>(pg.attribute("colorMarks", "0").toInt());
730
 
                                m_Doc->PDF_Options.docInfoMarks = static_cast<bool>(pg.attribute("docInfoMarks", "0").toInt());
731
 
                                m_Doc->PDF_Options.markOffset = ScCLocale::toDoubleC( pg.attribute("markOffset"), 0.0);
732
 
                                m_Doc->PDF_Options.EmbeddedI = static_cast<bool>(pg.attribute("ImagePr", "0").toInt());
733
 
                                m_Doc->PDF_Options.PassOwner = pg.attribute("PassOwner", "");
734
 
                                m_Doc->PDF_Options.PassUser = pg.attribute("PassUser", "");
735
 
                                m_Doc->PDF_Options.Permissions = pg.attribute("Permissions", "-4").toInt();
736
 
                                m_Doc->PDF_Options.Encrypt = static_cast<bool>(pg.attribute("Encrypt", "0").toInt());
737
 
                                m_Doc->PDF_Options.useLayers = static_cast<bool>(pg.attribute("UseLayers", "0").toInt());
738
 
                                m_Doc->PDF_Options.UseLPI = static_cast<bool>(pg.attribute("UseLpi", "0").toInt());
739
 
                                m_Doc->PDF_Options.UseSpotColors = static_cast<bool>(pg.attribute("UseSpotColors", "1").toInt());
740
 
                                m_Doc->PDF_Options.doMultiFile = static_cast<bool>(pg.attribute("doMultiFile", "0").toInt());
741
 
                                m_Doc->PDF_Options.displayBookmarks = static_cast<bool>(pg.attribute("displayBookmarks", "0").toInt());
742
 
                                m_Doc->PDF_Options.displayFullscreen = static_cast<bool>(pg.attribute("displayFullscreen", "0").toInt());
743
 
                                m_Doc->PDF_Options.displayLayers = static_cast<bool>(pg.attribute("displayLayers", "0").toInt());
744
 
                                m_Doc->PDF_Options.displayThumbs = static_cast<bool>(pg.attribute("displayThumbs", "0").toInt());
745
 
                                m_Doc->PDF_Options.hideMenuBar = static_cast<bool>(pg.attribute("hideMenuBar", "0").toInt());
746
 
                                m_Doc->PDF_Options.hideToolBar = static_cast<bool>(pg.attribute("hideToolBar", "0").toInt());
747
 
                                m_Doc->PDF_Options.fitWindow = static_cast<bool>(pg.attribute("fitWindow", "0").toInt());
748
 
                                m_Doc->PDF_Options.PageLayout = pg.attribute("PageLayout", "0").toInt();
749
 
                                m_Doc->PDF_Options.openAction = pg.attribute("openAction", "");
750
 
                                QDomNode PFO = PAGE.firstChild();
751
 
                                while(!PFO.isNull())
752
 
                                {
753
 
                                        QDomElement pdfF = PFO.toElement();
754
 
                                        if(pdfF.tagName() == "LPI")
755
 
                                        {
756
 
                                                struct LPIData lpo;
757
 
                                                lpo.Angle = pdfF.attribute("Angle").toInt();
758
 
                                                lpo.Frequency = pdfF.attribute("Frequency").toInt();
759
 
                                                lpo.SpotFunc = pdfF.attribute("SpotFunction").toInt();
760
 
                                                m_Doc->PDF_Options.LPISettings[pdfF.attribute("Color")] = lpo;
761
 
                                        }
762
 
                                        if(pdfF.tagName() == "Fonts")
763
 
                                        {
764
 
                                                if (!m_Doc->PDF_Options.EmbedList.contains(pdfF.attribute("Name")))
765
 
                                                        m_Doc->PDF_Options.EmbedList.append(pdfF.attribute("Name"));
766
 
                                        }
767
 
                                        if(pdfF.tagName() == "Subset")
768
 
                                        {
769
 
                                                if (!m_Doc->PDF_Options.SubsetList.contains(pdfF.attribute("Name")))
770
 
                                                        m_Doc->PDF_Options.SubsetList.append(pdfF.attribute("Name"));
771
 
                                        }
772
 
                                        if(pdfF.tagName() == "Effekte")
773
 
                                        {
774
 
                                                struct PDFPresentationData ef;
775
 
                                                ef.pageEffectDuration = pdfF.attribute("pageEffectDuration").toInt();
776
 
                                                ef.pageViewDuration = pdfF.attribute("pageViewDuration").toInt();
777
 
                                                ef.effectType = pdfF.attribute("effectType").toInt();
778
 
                                                ef.Dm = pdfF.attribute("Dm").toInt();
779
 
                                                ef.M = pdfF.attribute("M").toInt();
780
 
                                                ef.Di = pdfF.attribute("Di").toInt();
781
 
                                                m_Doc->PDF_Options.PresentVals.append(ef);
782
 
                                        }
783
 
                                        PFO = PFO.nextSibling();
784
 
                                }
785
 
                        }
786
 
                        if(pg.tagName()=="DocItemAttributes")
787
 
                        {
788
 
                                QDomNode DIA = PAGE.firstChild();
789
 
                                m_Doc->docItemAttributes.clear();
790
 
                                while(!DIA.isNull())
791
 
                                {
792
 
                                        QDomElement itemAttr = DIA.toElement();
793
 
                                        if(itemAttr.tagName() == "ItemAttribute")
794
 
                                        {
795
 
                                                ObjectAttribute objattr;
796
 
                                                objattr.name=itemAttr.attribute("Name");
797
 
                                                objattr.type=itemAttr.attribute("Type");
798
 
                                                objattr.value=itemAttr.attribute("Value");
799
 
                                                objattr.parameter=itemAttr.attribute("Parameter");
800
 
                                                objattr.relationship=itemAttr.attribute("Relationship");
801
 
                                                objattr.relationshipto=itemAttr.attribute("RelationshipTo");
802
 
                                                objattr.autoaddto=itemAttr.attribute("AutoAddTo");
803
 
                                                m_Doc->docItemAttributes.append(objattr);
804
 
                                        }
805
 
                                        DIA = DIA.nextSibling();
806
 
                                }
807
 
                        }
808
 
                        if(pg.tagName()=="TablesOfContents")
809
 
                        {
810
 
                                QDomNode TOC = PAGE.firstChild();
811
 
                                m_Doc->docToCSetups.clear();
812
 
                                while(!TOC.isNull())
813
 
                                {
814
 
                                        QDomElement tocElem = TOC.toElement();
815
 
                                        if(tocElem.tagName() == "TableOfContents")
816
 
                                        {
817
 
                                                ToCSetup tocsetup;
818
 
                                                tocsetup.name=tocElem.attribute("Name");
819
 
                                                tocsetup.itemAttrName=tocElem.attribute("ItemAttributeName");
820
 
                                                tocsetup.frameName=tocElem.attribute("FrameName");
821
 
                                                tocsetup.listNonPrintingFrames= QVariant(tocElem.attribute("ListNonPrinting")).toBool();
822
 
                                                tocsetup.textStyle=tocElem.attribute("Style");
823
 
                                                QString numberPlacement=tocElem.attribute("NumberPlacement");
824
 
                                                if (numberPlacement=="Beginning")
825
 
                                                        tocsetup.pageLocation=Beginning;
826
 
                                                if (numberPlacement=="End")
827
 
                                                        tocsetup.pageLocation=End;
828
 
                                                if (numberPlacement=="NotShown")
829
 
                                                        tocsetup.pageLocation=NotShown;
830
 
                                                m_Doc->docToCSetups.append(tocsetup);
831
 
                                        }
832
 
                                        TOC = TOC.nextSibling();
833
 
                                }
834
 
                        }
835
 
                        if(pg.tagName()=="Sections")
836
 
                        {
837
 
                                QDomNode Section = PAGE.firstChild();
838
 
                                while(!Section.isNull())
839
 
                                {
840
 
                                        QDomElement sectionElem = Section.toElement();
841
 
                                        if(sectionElem.tagName() == "Section")
842
 
                                        {
843
 
                                                struct DocumentSection newSection;
844
 
                                                newSection.number=sectionElem.attribute("Number").toInt();
845
 
                                                newSection.name=sectionElem.attribute("Name");
846
 
                                                newSection.fromindex=sectionElem.attribute("From").toInt();
847
 
                                                newSection.toindex=sectionElem.attribute("To").toInt();
848
 
                                                if (sectionElem.attribute("Type")=="Type_1_2_3")
849
 
                                                        newSection.type=Type_1_2_3;
850
 
                                                if (sectionElem.attribute("Type")=="Type_i_ii_iii")
851
 
                                                        newSection.type=Type_i_ii_iii;
852
 
                                                if (sectionElem.attribute("Type")=="Type_I_II_III")
853
 
                                                        newSection.type=Type_I_II_III;
854
 
                                                if (sectionElem.attribute("Type")=="Type_a_b_c")
855
 
                                                        newSection.type=Type_a_b_c;
856
 
                                                if (sectionElem.attribute("Type")=="Type_A_B_C")
857
 
                                                        newSection.type=Type_A_B_C;
858
 
                                                if (sectionElem.attribute("Type")=="Type_None")
859
 
                                                        newSection.type=Type_None;
860
 
                                                newSection.sectionstartindex=sectionElem.attribute("Start").toInt();
861
 
                                                newSection.reversed=static_cast<bool>(sectionElem.attribute("Reversed").toInt());
862
 
                                                newSection.active=static_cast<bool>(sectionElem.attribute("Active").toInt());
863
 
                                                m_Doc->sections.insert(newSection.number, newSection);
864
 
                                        }
865
 
                                        Section = Section.nextSibling();
866
 
                                }
867
 
                        }
868
 
                        if (pg.tagName()=="HYPHEN")
869
 
                        {
870
 
                                QDomNode hyelm = pg.firstChild();
871
 
                                while(!hyelm.isNull())
872
 
                                {
873
 
                                        QDomElement hyElem = hyelm.toElement();
874
 
                                        if (hyElem.tagName()=="EXCEPTION")
875
 
                                        {
876
 
                                                QString word = hyElem.attribute("WORD");
877
 
                                                QString hyph = hyElem.attribute("HYPHENATED");
878
 
                                                m_Doc->docHyphenator->specialWords.insert(word, hyph);
879
 
                                        }
880
 
                                        else if (hyElem.tagName()=="IGNORE")
881
 
                                        {
882
 
                                                QString word = hyElem.attribute("WORD");
883
 
                                                m_Doc->docHyphenator->ignoredWords.insert(word);
884
 
                                        }
885
 
                                        hyelm = hyelm.nextSibling();
886
 
                                }
887
 
                        }
888
 
                        if ((pg.tagName()=="PAGE") || (pg.tagName()=="MASTERPAGE"))
889
 
                        {
890
 
                                a = pg.attribute("NUM").toInt();
891
 
                                PgNam = "";
892
 
                                PgNam = pg.attribute("NAM", "");
893
 
                                if (pg.tagName()=="MASTERPAGE" && PgNam.isEmpty())
894
 
                                {
895
 
                                        qDebug() << "scribus134format: corrupted masterpage with empty name detected";
896
 
                                        PAGE=PAGE.nextSibling();
897
 
                                        continue;
898
 
                                }
899
 
                                //Pgc = m_Doc->pageCount;
900
 
                                //AtFl = m_Doc->usesAutomaticTextFrames();
901
 
                                if (PgNam.isEmpty())
902
 
                                {
903
 
                                        //m_Doc->pageCount = Pgc;
904
 
                                        //m_Doc->Pages = &m_Doc->DocPages;
905
 
                                        //m_Doc->setUsesAutomaticTextFrames(AtFl);
906
 
                                        m_Doc->setMasterPageMode(false);
907
 
                                }
908
 
                                else
909
 
                                {
910
 
                                        //m_Doc->pageCount = 0;
911
 
                                        //m_Doc->setUsesAutomaticTextFrames(false);
912
 
                                        //m_Doc->Pages = &m_Doc->MasterPages;
913
 
                                        m_Doc->setMasterPageMode(true);
914
 
                                }
915
 
                                //CB: Stop calling damn GUI code in loading docs! IT doesnt *look* like
916
 
                                //this makes a difference apart from being faster, of course.
917
 
                                //ScMW->slotNewPage(a);
918
 
                                //Apage = m_Doc->Pages.at(a);
919
 
                                if (PgNam.isEmpty())
920
 
                                {
921
 
                                        Apage = m_Doc->addPage(a);
922
 
                                        //m_Doc->DocPages = m_Doc->Pages;
923
 
                                        //++m_Doc->pageCount;
924
 
                                }
925
 
                                else
926
 
                                {
927
 
                                        Apage = m_Doc->addMasterPage(a, PgNam);
928
 
                                        //Apage->setPageName(PgNam);
929
 
                                        //m_Doc->MasterNames[PgNam] = a;
930
 
                                        //m_Doc->MasterPages = m_Doc->Pages;
931
 
                                        //m_Doc->pageCount = Pgc;
932
 
                                }
933
 
                                //m_Doc->setUsesAutomaticTextFrames(AtFl);
934
 
                                Apage->LeftPg=pg.attribute("LEFT", "0").toInt();
935
 
                                QString Mus = "";
936
 
                                Mus = pg.attribute("MNAM","Normal");
937
 
                                if (!m_Doc->masterPageMode())
938
 
                                        Apage->MPageNam = Mus;
939
 
                                else
940
 
                                        Apage->MPageNam = "";
941
 
                                if (pg.hasAttribute("Size"))
942
 
                                        Apage->m_pageSize = pg.attribute("Size");
943
 
                                if (pg.hasAttribute("Orientation"))
944
 
                                        Apage->PageOri = pg.attribute("Orientation").toInt();
945
 
                                Apage->setXOffset(ScCLocale::toDoubleC(pg.attribute("PAGEXPOS")));
946
 
                                Apage->setYOffset(ScCLocale::toDoubleC(pg.attribute("PAGEYPOS")));
947
 
                                if (pg.hasAttribute("PAGEWIDTH"))
948
 
                                        Apage->setWidth(ScCLocale::toDoubleC(pg.attribute("PAGEWIDTH")));
949
 
                                else
950
 
                                        Apage->setWidth(ScCLocale::toDoubleC(pg.attribute("PAGEWITH")));
951
 
                                Apage->setHeight(ScCLocale::toDoubleC(pg.attribute("PAGEHEIGHT")));
952
 
                                Apage->setInitialHeight(Apage->height());
953
 
                                Apage->setInitialWidth(Apage->width());
954
 
                                Apage->initialMargins.Top = qMax(0.0, ScCLocale::toDoubleC( pg.attribute("BORDERTOP")));
955
 
                                Apage->initialMargins.Bottom =  qMax(0.0, ScCLocale::toDoubleC(pg.attribute("BORDERBOTTOM")));
956
 
                                Apage->initialMargins.Left =  qMax(0.0, ScCLocale::toDoubleC(pg.attribute("BORDERLEFT")));
957
 
                                Apage->initialMargins.Right =  qMax(0.0,ScCLocale::toDoubleC( pg.attribute("BORDERRIGHT")));
958
 
                                Apage->marginPreset = pg.attribute("PRESET", "0").toInt();
959
 
                                Apage->Margins.Top = Apage->initialMargins.Top;
960
 
                                Apage->Margins.Bottom = Apage->initialMargins.Bottom;
961
 
                                m_Doc->setMasterPageMode(false);
962
 
                                //m_Doc->Pages=&m_Doc->DocPages;
963
 
                                // guides reading
964
 
                                tmp = "";
965
 
                                Apage->guides.setHorizontalAutoGap(ScCLocale::toDoubleC(pg.attribute("AGhorizontalAutoGap"), 0.0));
966
 
                                Apage->guides.setVerticalAutoGap(ScCLocale::toDoubleC(pg.attribute("AGverticalAutoGap"), 0.0));
967
 
                                Apage->guides.setHorizontalAutoCount(pg.attribute("AGhorizontalAutoCount", "0").toInt());
968
 
                                Apage->guides.setVerticalAutoCount(pg.attribute("AGverticalAutoCount", "0").toInt());
969
 
                                Apage->guides.setHorizontalAutoRefer(pg.attribute("AGhorizontalAutoRefer", "0").toInt());
970
 
                                Apage->guides.setVerticalAutoRefer(pg.attribute("AGverticalAutoRefer", "0").toInt());
971
 
                                GuideManagerIO::readVerticalGuides(pg.attribute("VerticalGuides"),
972
 
                                                Apage,
973
 
                                                GuideManagerCore::Standard,
974
 
                                                pg.hasAttribute("NumVGuides"));
975
 
                                GuideManagerIO::readHorizontalGuides(pg.attribute("HorizontalGuides"),
976
 
                                                Apage,
977
 
                                                GuideManagerCore::Standard,
978
 
                                                pg.hasAttribute("NumHGuides"));
979
 
                                GuideManagerIO::readSelection(pg.attribute("AGSelection"), Apage);
980
 
                                
981
 
                                Apage->guides.addHorizontals(Apage->guides.getAutoHorizontals(Apage), GuideManagerCore::Auto);
982
 
                                Apage->guides.addVerticals(Apage->guides.getAutoVerticals(Apage), GuideManagerCore::Auto);
983
 
                        }
984
 
                        if ((pg.tagName()=="PAGEOBJECT") || (pg.tagName()=="MASTEROBJECT") || (pg.tagName()=="FRAMEOBJECT"))
985
 
                        {
986
 
                                        if ((pg.tagName()=="PAGEOBJECT") || (pg.tagName()=="FRAMEOBJECT"))
987
 
                                        {
988
 
                                                //m_Doc->Items = m_Doc->DocItems;
989
 
                                                //m_Doc->Pages = &m_Doc->DocPages;
990
 
                                                m_Doc->setMasterPageMode(false);
991
 
                                        }
992
 
                                        else
993
 
                                        {
994
 
                                                //m_Doc->Items = m_Doc->MasterItems;
995
 
                                                //m_Doc->Pages = &m_Doc->MasterPages;
996
 
                                                m_Doc->setMasterPageMode(true);
997
 
                                        }
998
 
//CB comment out as no longer used                                      int docGc = m_Doc->GroupCounter, 
999
 
                                        int pagenr = -1;
1000
 
                                        if ((!pg.attribute("OnMasterPage").isEmpty()) && (pg.tagName()=="MASTEROBJECT"))
1001
 
                                        {
1002
 
                                                m_Doc->setCurrentPage(m_Doc->MasterPages.at(m_Doc->MasterNames[pg.attribute("OnMasterPage")]));
1003
 
                                                pagenr = -2;
1004
 
                                        }
1005
 
                                        /*m_Doc->GroupCounter = 0;*/
1006
 
                                        Neu = PasteItem(&pg, m_Doc, fileDir, pagenr);
1007
 
                                        Neu->setRedrawBounding();
1008
 
                                        if (pg.tagName()=="MASTEROBJECT")
1009
 
                                                Neu->OwnPage = m_Doc->OnPage(Neu);
1010
 
                                        else
1011
 
                                                Neu->OwnPage = pg.attribute("OwnPage").toInt();
1012
 
                                        if (pg.tagName()=="PAGEOBJECT")
1013
 
                                                Neu->OnMasterPage = "";
1014
 
                                        /*m_Doc->GroupCounter = docGc;*/
1015
 
                                        tmpf = pg.attribute("IFONT", m_Doc->toolSettings.defFont);
1016
 
                                        m_AvailableFonts->findFont(tmpf, m_Doc);
1017
 
                                        QDomNode IT=pg.firstChild();
1018
 
                                        LastStyles * last = new LastStyles();
1019
 
                                        while(!IT.isNull())
1020
 
                                        {
1021
 
                                                QDomElement it=IT.toElement();
1022
 
                                                if (it.tagName()=="CSTOP")
1023
 
                                                {
1024
 
                                                        QString name = it.attribute("NAME");
1025
 
                                                        double ramp = ScCLocale::toDoubleC( it.attribute("RAMP"), 0.0);
1026
 
                                                        int shade = it.attribute("SHADE", "100").toInt();
1027
 
                                                        double opa = ScCLocale::toDoubleC( it.attribute("TRANS"), 1.0);
1028
 
                                                        Neu->fill_gradient.addStop(SetColor(m_Doc, name, shade), ramp, 0.5, opa, name, shade);
1029
 
                                                }
1030
 
                                                if (it.tagName()=="ITEXT")
1031
 
                                                        GetItemText(&it, m_Doc, Neu, last);
1032
 
                                                else if (it.tagName()=="para")
1033
 
                                                {
1034
 
                                                        Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::PARSEP);
1035
 
                                                        ParagraphStyle newStyle;
1036
 
                                                        PrefsManager* prefsManager=PrefsManager::instance();
1037
 
                                                        readParagraphStyle(newStyle, it, prefsManager->appPrefs.AvailFonts, m_Doc);
1038
 
                                                        Neu->itemText.setStyle(Neu->itemText.length()-1, newStyle);
1039
 
                                                        Neu->itemText.setCharStyle(Neu->itemText.length()-1, 1, last->Style);
1040
 
                                                }
1041
 
                                                else if (it.tagName() == "trail")
1042
 
                                                {
1043
 
                                                        ParagraphStyle newStyle;
1044
 
                                                        PrefsManager* prefsManager = PrefsManager::instance();
1045
 
                                                        readParagraphStyle(newStyle, it, prefsManager->appPrefs.AvailFonts, m_Doc);
1046
 
                                                        Neu->itemText.setStyle(Neu->itemText.length(), newStyle);
1047
 
                                                }
1048
 
                                                else if (it.tagName()=="tab")
1049
 
                                                {
1050
 
                                                        CharStyle newStyle;
1051
 
                                                        Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::TAB);
1052
 
                                                        GetCStyle(&it, m_Doc, newStyle);
1053
 
                                                        Neu->itemText.setCharStyle(Neu->itemText.length()-1, 1, newStyle);
1054
 
                                                        last->StyleStart = Neu->itemText.length()-1;
1055
 
                                                        last->Style = newStyle;
1056
 
                                                }
1057
 
                                                else if (it.tagName()=="breakline")
1058
 
                                                        Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::LINEBREAK);
1059
 
                                                else if (it.tagName()=="breakcol")
1060
 
                                                        Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::COLBREAK);
1061
 
                                                else if (it.tagName()=="breakframe")
1062
 
                                                        Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::FRAMEBREAK);
1063
 
                                                else if (it.tagName()=="nbhyphen")
1064
 
                                                        Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::NBHYPHEN);
1065
 
                                                else if (it.tagName()=="nbspace")
1066
 
                                                        Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::NBSPACE);
1067
 
                                                else if (it.tagName()=="zwnbspace")
1068
 
                                                        Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::ZWNBSPACE);
1069
 
                                                else if (it.tagName()=="zwspace")
1070
 
                                                        Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::ZWSPACE);
1071
 
                                                else if (it.tagName()=="var")
1072
 
                                                {
1073
 
                                                        if (it.attribute("name") == "pgno")
1074
 
                                                                Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::PAGENUMBER);
1075
 
                                                        else
1076
 
                                                                Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::PAGECOUNT);
1077
 
                                                        CharStyle newStyle;
1078
 
                                                        GetCStyle(&it, m_Doc, newStyle);
1079
 
                                                        Neu->itemText.setCharStyle(Neu->itemText.length()-1, 1, newStyle);
1080
 
                                                        last->StyleStart = Neu->itemText.length()-1;
1081
 
                                                        last->Style = newStyle;
1082
 
                                                }
1083
 
 
1084
 
                                                //CB PageItemAttributes
1085
 
                                                if(it.tagName()=="PageItemAttributes")
1086
 
                                                {
1087
 
                                                        QDomNode PIA = it.firstChild();
1088
 
                                                        ObjAttrVector pageItemAttributes;
1089
 
                                                        while(!PIA.isNull())
1090
 
                                                        {
1091
 
                                                                QDomElement itemAttr = PIA.toElement();
1092
 
                                                                if(itemAttr.tagName() == "ItemAttribute")
1093
 
                                                                {
1094
 
                                                                        ObjectAttribute objattr;
1095
 
                                                                        objattr.name=itemAttr.attribute("Name");
1096
 
                                                                        objattr.type=itemAttr.attribute("Type");
1097
 
                                                                        objattr.value=itemAttr.attribute("Value");
1098
 
                                                                        objattr.parameter=itemAttr.attribute("Parameter");
1099
 
                                                                        objattr.relationship=itemAttr.attribute("Relationship");
1100
 
                                                                        objattr.relationshipto=itemAttr.attribute("RelationshipTo");
1101
 
                                                                        objattr.autoaddto=itemAttr.attribute("AutoAddTo");
1102
 
                                                                        pageItemAttributes.append(objattr);
1103
 
                                                                }
1104
 
                                                                PIA = PIA.nextSibling();
1105
 
                                                        }
1106
 
                                                        Neu->setObjectAttributes(&pageItemAttributes);
1107
 
                                                }
1108
 
                                                IT=IT.nextSibling();
1109
 
                                        }
1110
 
                                        if (Neu->asTextFrame())
1111
 
                                        {
1112
 
/*
1113
 
 QString dbg("");
1114
 
                                                for (int i=0; i < Neu->itemText.length(); ++i)
1115
 
                                                {
1116
 
                                                        dbg += Neu->itemText.text(i,1);
1117
 
                                                        if (Neu->itemText.item(i)->effects() & ScStyle_HyphenationPossible)
1118
 
                                                                dbg += "~";
1119
 
                                                }
1120
 
                                                qDebug("scribus134format: read itemtext '%s'", dbg.latin1());
1121
 
*/                                      }
1122
 
                                        if (Neu->asPathText())
1123
 
                                        {
1124
 
                                                Neu->updatePolyClip();
1125
 
                                                Neu->Frame = true;
1126
 
                                        }
1127
 
                                        delete last;
1128
 
                                        if (Neu->fill_gradient.Stops() == 0)
1129
 
                                        {
1130
 
                                                const ScColor& col1 = m_Doc->PageColors[m_Doc->toolSettings.dBrush];
1131
 
                                                const ScColor& col2 = m_Doc->PageColors[m_Doc->toolSettings.dPen];
1132
 
                                                Neu->fill_gradient.addStop(ScColorEngine::getRGBColor(col1, m_Doc), 0.0, 0.5, 1.0, m_Doc->toolSettings.dBrush, 100);
1133
 
                                                Neu->fill_gradient.addStop(ScColorEngine::getRGBColor(col2, m_Doc), 1.0, 0.5, 1.0, m_Doc->toolSettings.dPen, 100);
1134
 
                                        }
1135
 
//                                      Neu->Language = ScMW->GetLang(pg.attribute("LANGUAGE", m_Doc->Language));
1136
 
                                        Neu->isAutoText = static_cast<bool>(pg.attribute("AUTOTEXT").toInt());
1137
 
                                        Neu->isEmbedded = static_cast<bool>(pg.attribute("isInline", "0").toInt());
1138
 
                                        Neu->gXpos = ScCLocale::toDoubleC( pg.attribute("gXpos"), 0.0);
1139
 
                                        Neu->gYpos = ScCLocale::toDoubleC( pg.attribute("gYpos"), 0.0);
1140
 
                                        Neu->gWidth = ScCLocale::toDoubleC( pg.attribute("gWidth"), Neu->width());
1141
 
                                        Neu->gHeight = ScCLocale::toDoubleC( pg.attribute("gHeight"), Neu->height());
1142
 
                                        if (Neu->isAutoText)
1143
 
                                                m_Doc->LastAuto = Neu;
1144
 
                                        // first of linked chain?
1145
 
                                        if (pg.tagName()=="PAGEOBJECT")
1146
 
                                        {
1147
 
                                                if (pg.attribute("NEXTITEM").toInt() != -1)
1148
 
                                                        itemNext[Neu->ItemNr] = pg.attribute("NEXTITEM").toInt();
1149
 
                                        }
1150
 
                                        else if (pg.tagName()=="MASTEROBJECT")
1151
 
                                        {
1152
 
                                                if (pg.attribute("NEXTITEM").toInt() != -1)
1153
 
                                                        itemNextM[Neu->ItemNr] = pg.attribute("NEXTITEM").toInt();
1154
 
                                        }
1155
 
                                        /* not sure if we want that...
1156
 
                                        else if (pg.tagName()=="FRAMEOBJECT")
1157
 
                                        {
1158
 
                                                if (pg.attribute("NEXTITEM").toInt() != -1)
1159
 
                                                        itemNextF[Neu->ItemNr] = pg.attribute("NEXTITEM").toInt();
1160
 
                                        }*/
1161
 
 
1162
 
                                        if (pg.tagName()=="FRAMEOBJECT")
1163
 
                                        {
1164
 
                                                m_Doc->FrameItems.append(m_Doc->Items->takeAt(Neu->ItemNr));
1165
 
                                                Neu->ItemNr = m_Doc->FrameItems.count()-1;
1166
 
                                        }
1167
 
                                        if (Neu->isTableItem)
1168
 
                                        {
1169
 
                                                if (pg.tagName()=="PAGEOBJECT")
1170
 
                                                {
1171
 
                                                        TableItems.append(Neu);
1172
 
                                                        TableID.insert(pg.attribute("OwnLINK", "0").toInt(), Neu->ItemNr);
1173
 
                                                }
1174
 
                                                else if (pg.tagName()=="FRAMEOBJECT")
1175
 
                                                {
1176
 
                                                        TableItemsF.append(Neu);
1177
 
                                                        TableIDF.insert(pg.attribute("OwnLINK", "0").toInt(), Neu->ItemNr);
1178
 
                                                }
1179
 
                                                else
1180
 
                                                {
1181
 
                                                        TableItemsM.append(Neu);
1182
 
                                                        TableIDM.insert(pg.attribute("OwnLINK", "0").toInt(), Neu->ItemNr);
1183
 
                                                }
1184
 
                                        }
1185
 
                                        Neu->isGroupControl = static_cast<bool>(pg.attribute("isGroupControl", "0").toInt());
1186
 
                                        if (Neu->isGroupControl)
1187
 
                                        {
1188
 
                                                int groupLastItem = pg.attribute("groupsLastItem", "0").toInt();
1189
 
                                                if ((Neu->Groups.count() == 0) || (groupLastItem <= 0)) // Sanity check for some broken files created using buggy development versions.
1190
 
                                                {
1191
 
                                                        Neu->isGroupControl = false;
1192
 
                                                        Neu->setFillColor("None");
1193
 
                                                }
1194
 
                                                else
1195
 
                                                {
1196
 
                                                        if (pg.tagName()=="PAGEOBJECT")
1197
 
                                                                groupID.insert(Neu, groupLastItem + Neu->ItemNr);
1198
 
                                                        else if (pg.tagName()=="FRAMEOBJECT")
1199
 
                                                                groupIDF.insert(Neu,  groupLastItem + Neu->ItemNr);
1200
 
                                                        else
1201
 
                                                                groupIDM.insert(Neu,  groupLastItem + Neu->ItemNr);
1202
 
                                                }
1203
 
                                        }
1204
 
                                        m_Doc->setMasterPageMode(false);
1205
 
                                        counter++;
1206
 
                                }
1207
 
                        PAGE=PAGE.nextSibling();
1208
 
                }
1209
 
                PAGE=DOC.firstChild();
1210
 
                while(!PAGE.isNull())
1211
 
                {
1212
 
                        QDomElement pg=PAGE.toElement();
1213
 
                        if(pg.tagName()=="Bookmark")
1214
 
                        {
1215
 
                                int elem = pg.attribute("Element").toInt();
1216
 
                                if (elem < m_Doc->Items->count())
1217
 
                                {
1218
 
                                        bok.Title = pg.attribute("Title");
1219
 
                                        bok.Text = pg.attribute("Text");
1220
 
                                        bok.Aktion = pg.attribute("Aktion");
1221
 
                                        bok.ItemNr = pg.attribute("ItemNr").toInt();
1222
 
                                        bok.PageObject = m_Doc->Items->at(elem);
1223
 
                                        bok.First = pg.attribute("First").toInt();
1224
 
                                        bok.Last = pg.attribute("Last").toInt();
1225
 
                                        bok.Prev = pg.attribute("Prev").toInt();
1226
 
                                        bok.Next = pg.attribute("Next").toInt();
1227
 
                                        bok.Parent = pg.attribute("Parent").toInt();
1228
 
                                        m_Doc->BookMarks.append(bok);
1229
 
                                }
1230
 
                        }
1231
 
                        if(pg.tagName()=="Pattern")
1232
 
                        {
1233
 
                                QMap<PageItem*, int> groupID2;
1234
 
                                QMap<int,int> TableID2;
1235
 
                                QList<PageItem*> TableItems2;
1236
 
                                ScPattern pat;
1237
 
                                QDomNode pa = PAGE.firstChild();
1238
 
                                uint ac = m_Doc->Items->count();
1239
 
                                bool savedAlignGrid = m_Doc->useRaster;
1240
 
                                bool savedAlignGuides = m_Doc->SnapGuides;
1241
 
                                m_Doc->useRaster = false;
1242
 
                                m_Doc->SnapGuides = false;
1243
 
                                while(!pa.isNull())
1244
 
                                {
1245
 
                                        QDomElement pite = pa.toElement();
1246
 
                                        m_Doc->setMasterPageMode(false);
1247
 
                                        //int docGc = m_Doc->GroupCounter;
1248
 
                                        /*m_Doc->GroupCounter = 0;*/
1249
 
                                        Neu = PasteItem(&pite, m_Doc, fileDir);
1250
 
                                        Neu->setRedrawBounding();
1251
 
                                        Neu->OwnPage = pite.attribute("OwnPage").toInt();
1252
 
                                        Neu->OnMasterPage = "";
1253
 
                                        /*m_Doc->GroupCounter = docGc;*/
1254
 
                                        tmpf = pite.attribute("IFONT", m_Doc->toolSettings.defFont);
1255
 
                                        m_AvailableFonts->findFont(tmpf, m_Doc);
1256
 
                                        QDomNode IT=pite.firstChild();
1257
 
                                        LastStyles * last = new LastStyles();
1258
 
                                        while(!IT.isNull())
1259
 
                                        {
1260
 
                                                QDomElement it=IT.toElement();
1261
 
                                                if (it.tagName()=="CSTOP")
1262
 
                                                {
1263
 
                                                        QString name = it.attribute("NAME");
1264
 
                                                        double ramp = ScCLocale::toDoubleC( it.attribute("RAMP"), 0.0);
1265
 
                                                        int shade = it.attribute("SHADE", "100").toInt();
1266
 
                                                        double opa = ScCLocale::toDoubleC( it.attribute("TRANS"), 1.0);
1267
 
                                                        Neu->fill_gradient.addStop(SetColor(m_Doc, name, shade), ramp, 0.5, opa, name, shade);
1268
 
                                                }
1269
 
                                                if (it.tagName()=="ITEXT")
1270
 
                                                        GetItemText(&it, m_Doc, Neu, last);
1271
 
                                                else if (it.tagName()=="para")
1272
 
                                                {
1273
 
                                                        Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::PARSEP);
1274
 
                                                        ParagraphStyle newStyle;
1275
 
                                                        PrefsManager* prefsManager=PrefsManager::instance();
1276
 
                                                        readParagraphStyle(newStyle, it, prefsManager->appPrefs.AvailFonts, m_Doc);
1277
 
                                                        Neu->itemText.setStyle(Neu->itemText.length()-1, newStyle);
1278
 
                                                        Neu->itemText.setCharStyle(Neu->itemText.length()-1, 1, last->Style);
1279
 
                                                }
1280
 
                                                else if (it.tagName() == "trail")
1281
 
                                                {
1282
 
                                                        ParagraphStyle newStyle;
1283
 
                                                        PrefsManager* prefsManager = PrefsManager::instance();
1284
 
                                                        readParagraphStyle(newStyle, it, prefsManager->appPrefs.AvailFonts, m_Doc);
1285
 
                                                        Neu->itemText.setStyle(Neu->itemText.length(), newStyle);
1286
 
                                                }
1287
 
                                                else if (it.tagName()=="tab")
1288
 
                                                {
1289
 
                                                        CharStyle newStyle;
1290
 
                                                        Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::TAB);
1291
 
                                                        GetCStyle(&it, m_Doc, newStyle);
1292
 
                                                        Neu->itemText.setCharStyle(Neu->itemText.length()-1, 1, newStyle);
1293
 
                                                        last->StyleStart = Neu->itemText.length()-1;
1294
 
                                                        last->Style = newStyle;
1295
 
                                                }
1296
 
                                                else if (it.tagName()=="breakline")
1297
 
                                                        Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::LINEBREAK);
1298
 
                                                else if (it.tagName()=="breakcol")
1299
 
                                                        Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::COLBREAK);
1300
 
                                                else if (it.tagName()=="breakframe")
1301
 
                                                        Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::FRAMEBREAK);
1302
 
                                                else if (it.tagName()=="nbhyphen")
1303
 
                                                        Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::NBHYPHEN);
1304
 
                                                else if (it.tagName()=="nbspace")
1305
 
                                                        Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::NBSPACE);
1306
 
                                                else if (it.tagName()=="zwnbspace")
1307
 
                                                        Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::ZWNBSPACE);
1308
 
                                                else if (it.tagName()=="zwspace")
1309
 
                                                        Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::ZWSPACE);
1310
 
                                                else if (it.tagName()=="var")
1311
 
                                                {
1312
 
                                                        if (it.attribute("name") == "pgno")
1313
 
                                                                Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::PAGENUMBER);
1314
 
                                                        else
1315
 
                                                                Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::PAGECOUNT);
1316
 
                                                        CharStyle newStyle;
1317
 
                                                        GetCStyle(&it, m_Doc, newStyle);
1318
 
                                                        Neu->itemText.setCharStyle(Neu->itemText.length()-1, 1, newStyle);
1319
 
                                                        last->StyleStart = Neu->itemText.length()-1;
1320
 
                                                        last->Style = newStyle;
1321
 
                                                }
1322
 
                                                
1323
 
                                                if(it.tagName()=="PageItemAttributes")
1324
 
                                                {
1325
 
                                                        QDomNode PIA = it.firstChild();
1326
 
                                                        ObjAttrVector pageItemAttributes;
1327
 
                                                        while(!PIA.isNull())
1328
 
                                                        {
1329
 
                                                                QDomElement itemAttr = PIA.toElement();
1330
 
                                                                if(itemAttr.tagName() == "ItemAttribute")
1331
 
                                                                {
1332
 
                                                                        ObjectAttribute objattr;
1333
 
                                                                        objattr.name=itemAttr.attribute("Name");
1334
 
                                                                        objattr.type=itemAttr.attribute("Type");
1335
 
                                                                        objattr.value=itemAttr.attribute("Value");
1336
 
                                                                        objattr.parameter=itemAttr.attribute("Parameter");
1337
 
                                                                        objattr.relationship=itemAttr.attribute("Relationship");
1338
 
                                                                        objattr.relationshipto=itemAttr.attribute("RelationshipTo");
1339
 
                                                                        objattr.autoaddto=itemAttr.attribute("AutoAddTo");
1340
 
                                                                        pageItemAttributes.append(objattr);
1341
 
                                                                }
1342
 
                                                                PIA = PIA.nextSibling();
1343
 
                                                        }
1344
 
                                                        Neu->setObjectAttributes(&pageItemAttributes);
1345
 
                                                }
1346
 
                                                IT=IT.nextSibling();
1347
 
                                        }
1348
 
                                        delete last;
1349
 
                                        if (Neu->asPathText())
1350
 
                                        {
1351
 
                                                Neu->updatePolyClip();
1352
 
                                                Neu->Frame = true;
1353
 
                                        }
1354
 
                                        if (Neu->fill_gradient.Stops() == 0)
1355
 
                                        {
1356
 
                                                const ScColor& col1 = m_Doc->PageColors[m_Doc->toolSettings.dBrush];
1357
 
                                                const ScColor& col2 = m_Doc->PageColors[m_Doc->toolSettings.dPen];
1358
 
                                                Neu->fill_gradient.addStop(ScColorEngine::getRGBColor(col1, m_Doc), 0.0, 0.5, 1.0, m_Doc->toolSettings.dBrush, 100);
1359
 
                                                Neu->fill_gradient.addStop(ScColorEngine::getRGBColor(col2, m_Doc), 1.0, 0.5, 1.0, m_Doc->toolSettings.dPen, 100);
1360
 
                                        }
1361
 
                                        Neu->isAutoText = static_cast<bool>(pite.attribute("AUTOTEXT").toInt());
1362
 
                                        Neu->isEmbedded = static_cast<bool>(pite.attribute("isInline", "0").toInt());
1363
 
                                        Neu->gXpos = ScCLocale::toDoubleC( pite.attribute("gXpos"), 0.0);
1364
 
                                        Neu->gYpos = ScCLocale::toDoubleC( pite.attribute("gYpos"), 0.0);
1365
 
                                        Neu->gWidth  = ScCLocale::toDoubleC( pite.attribute("gWidth"), Neu->width());
1366
 
                                        Neu->gHeight = ScCLocale::toDoubleC( pite.attribute("gHeight"), Neu->height());
1367
 
                                        if (Neu->isTableItem)
1368
 
                                        {
1369
 
                                                TableItems2.append(Neu);
1370
 
                                                TableID2.insert(pite.attribute("OwnLINK", "0").toInt(), Neu->ItemNr);
1371
 
                                        }
1372
 
                                        Neu->isGroupControl = static_cast<bool>(pite.attribute("isGroupControl", "0").toInt());
1373
 
                                        if (Neu->isGroupControl)
1374
 
                                        {
1375
 
                                                int groupLastItem = pg.attribute("groupsLastItem", "0").toInt();
1376
 
                                                if ((Neu->Groups.count() == 0) || (groupLastItem <= 0)) // Sanity check for some broken files created using buggy development versions.
1377
 
                                                {
1378
 
                                                        Neu->isGroupControl = false;
1379
 
                                                        Neu->setFillColor("None");
1380
 
                                                }
1381
 
                                                else
1382
 
                                                        groupID2.insert(Neu, pite.attribute("groupsLastItem", "0").toInt()+Neu->ItemNr);
1383
 
                                        }
1384
 
                                        pa = pa.nextSibling();
1385
 
                                }
1386
 
                                if (groupID2.count() != 0)
1387
 
                                {
1388
 
                                        QMap<PageItem*, int>::Iterator it;
1389
 
                                        for (it = groupID2.begin(); it != groupID2.end(); ++it)
1390
 
                                        {
1391
 
                                                it.key()->groupsLastItem = m_Doc->Items->at(it.value());
1392
 
                                        }
1393
 
                                }
1394
 
                                if (TableItems2.count() != 0)
1395
 
                                {
1396
 
                                        for (int ttc = 0; ttc < TableItems2.count(); ++ttc)
1397
 
                                        {
1398
 
                                                PageItem* ta = TableItems2.at(ttc);
1399
 
                                                if (ta->TopLinkID != -1)
1400
 
                                                        ta->TopLink = m_Doc->Items->at(TableID2[ta->TopLinkID]);
1401
 
                                                else
1402
 
                                                        ta->TopLink = 0;
1403
 
                                                if (ta->LeftLinkID != -1)
1404
 
                                                        ta->LeftLink = m_Doc->Items->at(TableID2[ta->LeftLinkID]);
1405
 
                                                else
1406
 
                                                        ta->LeftLink = 0;
1407
 
                                                if (ta->RightLinkID != -1)
1408
 
                                                        ta->RightLink = m_Doc->Items->at(TableID2[ta->RightLinkID]);
1409
 
                                                else
1410
 
                                                        ta->RightLink = 0;
1411
 
                                                if (ta->BottomLinkID != -1)
1412
 
                                                        ta->BottomLink = m_Doc->Items->at(TableID2[ta->BottomLinkID]);
1413
 
                                                else
1414
 
                                                        ta->BottomLink = 0;
1415
 
                                        }
1416
 
                                }
1417
 
                                m_Doc->useRaster = savedAlignGrid;
1418
 
                                m_Doc->SnapGuides = savedAlignGuides;
1419
 
                                uint ae = m_Doc->Items->count();
1420
 
                                pat.setDoc(m_Doc);
1421
 
                                pat.width = ScCLocale::toDoubleC( pg.attribute("width"), 0.0);
1422
 
                                pat.height = ScCLocale::toDoubleC( pg.attribute("height"), 0.0);
1423
 
                                pat.scaleX = ScCLocale::toDoubleC( pg.attribute("scaleX"), 0.0);
1424
 
                                pat.scaleY = ScCLocale::toDoubleC( pg.attribute("scaleY"), 0.0);
1425
 
                                pat.xoffset = ScCLocale::toDoubleC( pg.attribute("xoffset"), 0.0);
1426
 
                                pat.yoffset = ScCLocale::toDoubleC( pg.attribute("yoffset"), 0.0);
1427
 
                                if (ae > ac)
1428
 
                                {
1429
 
                                        PageItem* currItem = m_Doc->Items->at(ac);
1430
 
                                        pat.pattern = currItem->DrawObj_toImage();
1431
 
                                        pat.pattern = pat.pattern.copy(-pat.xoffset, -pat.yoffset, pat.width, pat.height);
1432
 
                                        for (uint as = ac; as < ae; ++as)
1433
 
                                        {
1434
 
                                                Neu = m_Doc->Items->takeAt(ac);
1435
 
                                                Neu->moveBy(pat.xoffset, pat.yoffset, true);
1436
 
                                                Neu->gXpos += pat.xoffset;
1437
 
                                                Neu->gYpos += pat.yoffset;
1438
 
                                                Neu->ItemNr = pat.items.count();
1439
 
                                                pat.items.append(Neu);
1440
 
                                        }
1441
 
                                }
1442
 
                                QString patName = pg.attribute("Name");
1443
 
                                if (!patName.isEmpty())
1444
 
                                        m_Doc->docPatterns.insert(patName, pat);
1445
 
                        }
1446
 
                        PAGE=PAGE.nextSibling();
1447
 
                }
1448
 
                DOC=DOC.nextSibling();
1449
 
        }
1450
 
        if (TableItemsF.count() != 0)
1451
 
        {
1452
 
                for (int ttc = 0; ttc < TableItemsF.count(); ++ttc)
1453
 
                {
1454
 
                        PageItem* ta = TableItemsF.at(ttc);
1455
 
                        if (ta->TopLinkID != -1)
1456
 
                                ta->TopLink = m_Doc->FrameItems.at(TableIDF[ta->TopLinkID]);
1457
 
                        else
1458
 
                                ta->TopLink = 0;
1459
 
                        if (ta->LeftLinkID != -1)
1460
 
                                ta->LeftLink = m_Doc->FrameItems.at(TableIDF[ta->LeftLinkID]);
1461
 
                        else
1462
 
                                ta->LeftLink = 0;
1463
 
                        if (ta->RightLinkID != -1)
1464
 
                                ta->RightLink = m_Doc->FrameItems.at(TableIDF[ta->RightLinkID]);
1465
 
                        else
1466
 
                                ta->RightLink = 0;
1467
 
                        if (ta->BottomLinkID != -1)
1468
 
                                ta->BottomLink = m_Doc->FrameItems.at(TableIDF[ta->BottomLinkID]);
1469
 
                        else
1470
 
                                ta->BottomLink = 0;
1471
 
                }
1472
 
        }
1473
 
        if (TableItemsM.count() != 0)
1474
 
        {
1475
 
                for (int ttc = 0; ttc < TableItemsM.count(); ++ttc)
1476
 
                {
1477
 
                        PageItem* ta = TableItemsM.at(ttc);
1478
 
                        if (ta->TopLinkID != -1)
1479
 
                                ta->TopLink = m_Doc->MasterItems.at(TableIDM[ta->TopLinkID]);
1480
 
                        else
1481
 
                                ta->TopLink = 0;
1482
 
                        if (ta->LeftLinkID != -1)
1483
 
                                ta->LeftLink = m_Doc->MasterItems.at(TableIDM[ta->LeftLinkID]);
1484
 
                        else
1485
 
                                ta->LeftLink = 0;
1486
 
                        if (ta->RightLinkID != -1)
1487
 
                                ta->RightLink = m_Doc->MasterItems.at(TableIDM[ta->RightLinkID]);
1488
 
                        else
1489
 
                                ta->RightLink = 0;
1490
 
                        if (ta->BottomLinkID != -1)
1491
 
                                ta->BottomLink = m_Doc->MasterItems.at(TableIDM[ta->BottomLinkID]);
1492
 
                        else
1493
 
                                ta->BottomLink = 0;
1494
 
                }
1495
 
        }
1496
 
        if (TableItems.count() != 0)
1497
 
        {
1498
 
                for (int ttc = 0; ttc < TableItems.count(); ++ttc)
1499
 
                {
1500
 
                        PageItem* ta = TableItems.at(ttc);
1501
 
                        if (ta->TopLinkID != -1)
1502
 
                                ta->TopLink = m_Doc->Items->at(TableID[ta->TopLinkID]);
1503
 
                        else
1504
 
                                ta->TopLink = 0;
1505
 
                        if (ta->LeftLinkID != -1)
1506
 
                                ta->LeftLink = m_Doc->Items->at(TableID[ta->LeftLinkID]);
1507
 
                        else
1508
 
                                ta->LeftLink = 0;
1509
 
                        if (ta->RightLinkID != -1)
1510
 
                                ta->RightLink = m_Doc->Items->at(TableID[ta->RightLinkID]);
1511
 
                        else
1512
 
                                ta->RightLink = 0;
1513
 
                        if (ta->BottomLinkID != -1)
1514
 
                                ta->BottomLink = m_Doc->Items->at(TableID[ta->BottomLinkID]);
1515
 
                        else
1516
 
                                ta->BottomLink = 0;
1517
 
                }
1518
 
        }
1519
 
        if (groupIDF.count() != 0)
1520
 
        {
1521
 
                QMap<PageItem*, int>::Iterator it;
1522
 
                for (it = groupIDF.begin(); it != groupIDF.end(); ++it)
1523
 
                {
1524
 
                        it.key()->groupsLastItem = m_Doc->FrameItems.at(it.value());
1525
 
                }
1526
 
        }
1527
 
        if (groupID.count() != 0)
1528
 
        {
1529
 
                QMap<PageItem*, int>::Iterator it;
1530
 
                for (it = groupID.begin(); it != groupID.end(); ++it)
1531
 
                {
1532
 
                        it.key()->groupsLastItem = m_Doc->DocItems.at(it.value());
1533
 
                }
1534
 
        }
1535
 
        if (groupIDM.count() != 0)
1536
 
        {
1537
 
                QMap<PageItem*, int>::Iterator it;
1538
 
                for (it = groupIDM.begin(); it != groupIDM.end(); ++it)
1539
 
                {
1540
 
                        it.key()->groupsLastItem = m_Doc->MasterItems.at(it.value());
1541
 
                }
1542
 
        }
1543
 
        m_Doc->setActiveLayer(layerToSetActive);
1544
 
        m_Doc->setMasterPageMode(false);
1545
 
        m_Doc->reformPages();
1546
 
 
1547
 
        if (m_Doc->Layers.count() == 0)
1548
 
                m_Doc->Layers.newLayer( QObject::tr("Background") );
1549
 
 
1550
 
        // reestablish textframe links
1551
 
        if (itemNext.count() != 0)
1552
 
        {
1553
 
                QMap<int,int>::Iterator lc;
1554
 
                for (lc = itemNext.begin(); lc != itemNext.end(); ++lc)
1555
 
                {
1556
 
                        if (lc.value() >= 0)
1557
 
                        {
1558
 
                                PageItem * Its = m_Doc->DocItems.at(lc.key());
1559
 
                                PageItem * Itn = m_Doc->DocItems.at(lc.value());
1560
 
                                if (Itn->prevInChain() || Its->nextInChain()) 
1561
 
                                {
1562
 
                                        qDebug() << "scribus134format: corruption in linked textframes detected";
1563
 
                                        continue;
1564
 
                                }
1565
 
                                Its->link(Itn);
1566
 
                        }
1567
 
                }
1568
 
        }
1569
 
        
1570
 
        if (itemNextM.count() != 0)
1571
 
        {
1572
 
                QMap<int,int>::Iterator lc;
1573
 
                for (lc = itemNextM.begin(); lc != itemNextM.end(); ++lc)
1574
 
                {
1575
 
                        if (lc.value() >= 0)
1576
 
                        {
1577
 
                                PageItem * Its = m_Doc->MasterItems.at(lc.key());
1578
 
                                PageItem * Itn = m_Doc->MasterItems.at(lc.value());
1579
 
                                if (Itn->prevInChain() || Its->nextInChain()) 
1580
 
                                {
1581
 
                                        qDebug() << "scribus134format: corruption in linked textframes detected";
1582
 
                                        continue;
1583
 
                                }
1584
 
                                Its->link(Itn);
1585
 
                        }
1586
 
                }
1587
 
        }
1588
 
        
1589
 
        // reestablish first/lastAuto
1590
 
        m_Doc->FirstAuto = m_Doc->LastAuto;
1591
 
        if (m_Doc->LastAuto)
1592
 
        {
1593
 
                while (m_Doc->LastAuto->nextInChain())
1594
 
                        m_Doc->LastAuto = m_Doc->LastAuto->nextInChain();
1595
 
                while (m_Doc->FirstAuto->prevInChain())
1596
 
                        m_Doc->FirstAuto = m_Doc->FirstAuto->prevInChain();
1597
 
        }
1598
 
 
1599
 
        // start auto save timer if needed
1600
 
        if (m_Doc->AutoSave  && ScCore->usingGUI())
1601
 
                m_Doc->autoSaveTimer->start(m_Doc->AutoSaveTime);
1602
 
        
1603
 
        if (m_mwProgressBar!=0)
1604
 
                m_mwProgressBar->setValue(DOC.childNodes().count());
1605
 
        return true;
1606
 
//      return false;
1607
 
}
1608
 
 
1609
 
 
1610
 
// Low level plugin API
1611
 
int scribus134format_getPluginAPIVersion()
1612
 
{
1613
 
        return PLUGIN_API_VERSION;
1614
 
}
1615
 
 
1616
 
ScPlugin* scribus134format_getPlugin()
1617
 
{
1618
 
        Scribus134Format* plug = new Scribus134Format();
1619
 
        Q_CHECK_PTR(plug);
1620
 
        return plug;
1621
 
}
1622
 
 
1623
 
void scribus134format_freePlugin(ScPlugin* plugin)
1624
 
{
1625
 
        Scribus134Format* plug = dynamic_cast<Scribus134Format*>(plugin);
1626
 
        Q_ASSERT(plug);
1627
 
        delete plug;
1628
 
}
1629
 
 
1630
 
 
1631
 
namespace {
1632
 
        const int NOVALUE = -16000;
1633
 
        
1634
 
        void fixLegacyCharStyle(CharStyle& cstyle) 
1635
 
        {
1636
 
                if (! cstyle.font().usable())
1637
 
                        cstyle.resetFont();
1638
 
                if (cstyle.fontSize() <= -16000 / 10)
1639
 
                        cstyle.resetFontSize();
1640
 
//              if (cstyle.effects() == 65535)
1641
 
//                      cstyle.resetEffects();
1642
 
                if (cstyle.fillColor().isEmpty())
1643
 
                        cstyle.resetFillColor();
1644
 
                if (cstyle.fillShade() <= -16000)
1645
 
                        cstyle.resetFillShade();
1646
 
                if (cstyle.strokeColor().isEmpty())
1647
 
                        cstyle.resetStrokeColor();
1648
 
                if (cstyle.strokeShade() <= -16000)
1649
 
                        cstyle.resetStrokeShade();
1650
 
                if (cstyle.shadowXOffset() <= -16000 / 10)
1651
 
                        cstyle.resetShadowXOffset();
1652
 
                if (cstyle.shadowYOffset() <= -16000 / 10)
1653
 
                        cstyle.resetShadowYOffset();
1654
 
                if (cstyle.outlineWidth() <= -16000 / 10)
1655
 
                        cstyle.resetOutlineWidth();
1656
 
                if (cstyle.underlineOffset() <= -16000 / 10)
1657
 
                        cstyle.resetUnderlineOffset();
1658
 
                if (cstyle.underlineWidth() <= -16000 / 10)
1659
 
                        cstyle.resetUnderlineWidth();
1660
 
                if (cstyle.strikethruOffset() <= -16000 / 10)
1661
 
                        cstyle.resetStrikethruOffset();
1662
 
                if (cstyle.strikethruWidth() <= -16000 / 10)
1663
 
                        cstyle.resetStrikethruWidth();
1664
 
                if (cstyle.scaleH() <= -16000 / 10)
1665
 
                        cstyle.resetScaleH();
1666
 
                if (cstyle.scaleV() <= -16000 / 10)
1667
 
                        cstyle.resetScaleV();
1668
 
                if (cstyle.baselineOffset() <= -16000 / 10)
1669
 
                        cstyle.resetBaselineOffset();
1670
 
                if (cstyle.tracking() <= -16000 / 10)
1671
 
                        cstyle.resetTracking();
1672
 
        }
1673
 
        
1674
 
        void fixLegacyParStyle(ParagraphStyle& pstyle) 
1675
 
        {
1676
 
                if (pstyle.lineSpacing() <= -16000)
1677
 
                        pstyle.resetLineSpacing();
1678
 
                if (pstyle.leftMargin() <= -16000)
1679
 
                        pstyle.resetLeftMargin();
1680
 
                if (pstyle.rightMargin() <= -16000)
1681
 
                        pstyle.resetRightMargin();
1682
 
                if (pstyle.firstIndent() <= -16000)
1683
 
                        pstyle.resetFirstIndent();
1684
 
                if (pstyle.alignment() < 0)
1685
 
                        pstyle.resetAlignment();
1686
 
                if (pstyle.gapBefore() <= -16000)
1687
 
                        pstyle.resetGapBefore();
1688
 
                if (pstyle.gapAfter() <= -16000)
1689
 
                        pstyle.resetGapAfter();
1690
 
                if (pstyle.dropCapLines() < 0)
1691
 
                        pstyle.resetDropCapLines();
1692
 
                if (pstyle.dropCapOffset() <= -16000)
1693
 
                        pstyle.resetDropCapOffset();
1694
 
                fixLegacyCharStyle(pstyle.charStyle());
1695
 
        }
1696
 
        
1697
 
}// namespace
1698
 
 
1699
 
 
1700
 
void Scribus134Format::GetCStyle(const QDomElement *it, ScribusDoc *doc, CharStyle & newStyle)
1701
 
{
1702
 
        if (it->hasAttribute("CNAME"))
1703
 
                newStyle.setName(it->attribute("CNAME"));
1704
 
        // The default style attribute must be correctly set before trying to assign a parent
1705
 
        if (newStyle.hasName() && it->hasAttribute("DefaultStyle"))
1706
 
                newStyle.setDefaultStyle(it->attribute("DefaultStyle").toInt());
1707
 
        else if (newStyle.name() == CommonStrings::DefaultCharacterStyle || newStyle.name() == CommonStrings::trDefaultCharacterStyle)
1708
 
                newStyle.setDefaultStyle(true);
1709
 
        else
1710
 
                newStyle.setDefaultStyle(false);
1711
 
        if (it->hasAttribute("CPARENT"))
1712
 
                newStyle.setParent(it->attribute("CPARENT"));
1713
 
        if (it->hasAttribute("FONT"))
1714
 
                newStyle.setFont(m_AvailableFonts->findFont(it->attribute("FONT"),doc));
1715
 
        
1716
 
        if (it->hasAttribute("FONTSIZE"))
1717
 
                newStyle.setFontSize(qRound(ScCLocale::toDoubleC(it->attribute("FONTSIZE")) * 10));
1718
 
        
1719
 
        if (it->hasAttribute("FCOLOR"))
1720
 
                newStyle.setFillColor(it->attribute("FCOLOR"));
1721
 
        
1722
 
        if (it->hasAttribute("KERN"))
1723
 
                newStyle.setTracking(qRound(ScCLocale::toDoubleC(it->attribute("KERN")) * 10));
1724
 
        
1725
 
        if (it->hasAttribute("FSHADE"))
1726
 
                newStyle.setFillShade(it->attribute("FSHADE").toInt());
1727
 
        
1728
 
        if (it->hasAttribute("EFFECTS"))
1729
 
                newStyle.setFeatures(static_cast<StyleFlag>(it->attribute("EFFECTS").toInt()).featureList());
1730
 
        
1731
 
        if (it->hasAttribute("EFFECT"))
1732
 
                newStyle.setFeatures(static_cast<StyleFlag>(it->attribute("EFFECT").toInt()).featureList());
1733
 
        
1734
 
        if (it->hasAttribute("FEATURES"))
1735
 
                newStyle.setFeatures(it->attribute("FEATURES").split( " ", QString::SkipEmptyParts));
1736
 
        
1737
 
        if (it->hasAttribute("SCOLOR"))
1738
 
                newStyle.setStrokeColor(it->attribute("SCOLOR", CommonStrings::None));
1739
 
        
1740
 
        if (it->hasAttribute("SSHADE"))
1741
 
                newStyle.setStrokeShade(it->attribute("SSHADE").toInt());
1742
 
        
1743
 
        if (it->hasAttribute("SCALEH"))
1744
 
                newStyle.setScaleH(qRound(ScCLocale::toDoubleC(it->attribute("SCALEH")) * 10));
1745
 
        
1746
 
        if (it->hasAttribute("SCALEV"))
1747
 
                newStyle.setScaleV(qRound(ScCLocale::toDoubleC(it->attribute("SCALEV")) * 10));
1748
 
        
1749
 
        if (it->hasAttribute("BASEO"))
1750
 
                newStyle.setBaselineOffset(qRound(ScCLocale::toDoubleC(it->attribute("BASEO")) * 10));
1751
 
        
1752
 
        if (it->hasAttribute("TXTSHX"))
1753
 
                newStyle.setShadowXOffset(qRound(ScCLocale::toDoubleC(it->attribute("TXTSHX")) * 10));
1754
 
        
1755
 
        if (it->hasAttribute("TXTSHY"))
1756
 
                newStyle.setShadowYOffset(qRound(ScCLocale::toDoubleC(it->attribute("TXTSHY")) * 10));
1757
 
        
1758
 
        if (it->hasAttribute("TXTOUT"))
1759
 
                newStyle.setOutlineWidth(qRound(ScCLocale::toDoubleC(it->attribute("TXTOUT")) * 10));
1760
 
        
1761
 
        if (it->hasAttribute("TXTULP"))
1762
 
                newStyle.setUnderlineOffset(qRound(ScCLocale::toDoubleC(it->attribute("TXTULP")) * 10));
1763
 
        
1764
 
        if (it->hasAttribute("TXTULW"))
1765
 
                newStyle.setUnderlineWidth(qRound(ScCLocale::toDoubleC(it->attribute("TXTULW")) * 10));
1766
 
        
1767
 
        if (it->hasAttribute("TXTSTP"))
1768
 
                newStyle.setStrikethruOffset(qRound(ScCLocale::toDoubleC(it->attribute("TXTSTP")) * 10));
1769
 
        
1770
 
        if (it->hasAttribute("TXTSTW"))
1771
 
                newStyle.setStrikethruWidth(qRound(ScCLocale::toDoubleC(it->attribute("TXTSTW")) * 10));
1772
 
 
1773
 
        if (it->hasAttribute("LANGUAGE"))
1774
 
                newStyle.setLanguage(it->attribute("LANGUAGE"));
1775
 
 
1776
 
        if (it->hasAttribute("SHORTCUT"))
1777
 
                newStyle.setShortcut(it->attribute("SHORTCUT"));
1778
 
 
1779
 
        if (it->hasAttribute("wordTrack"))
1780
 
                newStyle.setWordTracking(ScCLocale::toDoubleC(it->attribute("wordTrack")));
1781
 
 
1782
 
}       
1783
 
 
1784
 
void Scribus134Format::GetItemText(QDomElement *it, ScribusDoc *doc, PageItem* obj, LastStyles* last, bool impo, bool VorLFound)
1785
 
{
1786
 
        QString tmp2;
1787
 
        CharStyle newStyle;
1788
 
        
1789
 
        GetCStyle(it, doc, newStyle);
1790
 
 
1791
 
        if (it->hasAttribute("Unicode"))
1792
 
        {
1793
 
                tmp2 = QChar(it->attribute("Unicode").toUInt());
1794
 
        }
1795
 
        else
1796
 
        {
1797
 
                tmp2 = it->attribute("CH");
1798
 
                
1799
 
                // legacy stuff:
1800
 
                tmp2.replace(QRegExp("\r"), QChar(13));
1801
 
                tmp2.replace(QRegExp("\n"), QChar(13));
1802
 
                tmp2.replace(QRegExp("\t"), QChar(9));
1803
 
        }
1804
 
        
1805
 
        // more legacy stuff:
1806
 
        
1807
 
        if (it->hasAttribute("CFONT"))
1808
 
                newStyle.setFont(m_AvailableFonts->findFont(it->attribute("CFONT"), doc));
1809
 
        
1810
 
        if (it->hasAttribute("CSIZE"))
1811
 
                newStyle.setFontSize(qRound(ScCLocale::toDoubleC(it->attribute("CSIZE")) * 10));
1812
 
        
1813
 
        if (it->hasAttribute("CCOLOR"))
1814
 
                newStyle.setFillColor(it->attribute("CCOLOR"));
1815
 
        
1816
 
        if (it->hasAttribute("CEXTRA"))
1817
 
                newStyle.setTracking(qRound(ScCLocale::toDoubleC(it->attribute("CEXTRA")) / ScCLocale::toDoubleC(it->attribute("CSIZE")) * 1000.0));
1818
 
        else if (it->hasAttribute("CKERN"))
1819
 
                newStyle.setTracking(it->attribute("CKERN").toInt());
1820
 
        
1821
 
        if (it->hasAttribute("CSHADE"))
1822
 
                newStyle.setFillShade(it->attribute("CSHADE").toInt());
1823
 
        
1824
 
        if (it->hasAttribute("CSTYLE"))
1825
 
                newStyle.setFeatures(static_cast<StyleFlag>(it->attribute("CSTYLE").toInt()).featureList());
1826
 
 
1827
 
        QString pstylename = it->attribute("PSTYLE", "");
1828
 
        int calign = it->attribute("CALIGN", "-1").toInt();             
1829
 
        
1830
 
        int ab = it->attribute("CAB", "-1").toInt();
1831
 
        if (ab >= 5) {
1832
 
                pstylename = doc->paragraphStyles()[ab-5].name();
1833
 
                calign = -1;
1834
 
        }
1835
 
        else if (ab >= 0) {
1836
 
                pstylename = "";
1837
 
                calign = ab;
1838
 
        }
1839
 
        
1840
 
        if (it->hasAttribute("CSTROKE"))
1841
 
                newStyle.setStrokeColor(it->attribute("CSTROKE", CommonStrings::None));
1842
 
        
1843
 
        if (it->hasAttribute("CSHADE2"))
1844
 
                newStyle.setStrokeShade(it->attribute("CSHADE2", "100").toInt());
1845
 
        
1846
 
        if (it->hasAttribute("CSCALE"))
1847
 
                newStyle.setScaleH(qMin(qMax(qRound(ScCLocale::toDoubleC(it->attribute("CSCALE"), 100.0) * 10), 100), 4000));
1848
 
        
1849
 
        if (it->hasAttribute("CSCALEV"))
1850
 
                newStyle.setScaleV(qMin(qMax(qRound(ScCLocale::toDoubleC(it->attribute("CSCALEV"), 100.0) * 10), 100), 4000));
1851
 
        
1852
 
        if (it->hasAttribute("CBASE"))
1853
 
                newStyle.setBaselineOffset(qRound(ScCLocale::toDoubleC(it->attribute("CBASE")) * 10));
1854
 
        
1855
 
        if (it->hasAttribute("CSHX"))
1856
 
                newStyle.setShadowXOffset(qRound(ScCLocale::toDoubleC(it->attribute("CSHX"), 5.0) * 10));
1857
 
        
1858
 
        if (it->hasAttribute("CSHY"))
1859
 
                newStyle.setShadowYOffset(qRound(ScCLocale::toDoubleC(it->attribute("CSHY"), -5.0) * 10));
1860
 
        
1861
 
        if (it->hasAttribute("COUT"))
1862
 
                newStyle.setOutlineWidth(qRound(ScCLocale::toDoubleC(it->attribute("COUT"), 1.0) * 10));
1863
 
        
1864
 
        if (it->hasAttribute("CULP"))
1865
 
                newStyle.setUnderlineOffset(qRound(ScCLocale::toDoubleC(it->attribute("CULP"), -0.1) * 10));
1866
 
        
1867
 
        if (it->hasAttribute("CULW"))
1868
 
                newStyle.setUnderlineWidth(qRound(ScCLocale::toDoubleC(it->attribute("CULW"), -0.1) * 10));
1869
 
        
1870
 
        
1871
 
        if (it->hasAttribute("CSTP"))
1872
 
                newStyle.setStrikethruOffset(qRound(ScCLocale::toDoubleC(it->attribute("CSTP"), -0.1) * 10));
1873
 
        
1874
 
        if (it->hasAttribute("CSTW"))
1875
 
                newStyle.setStrikethruWidth(qRound(ScCLocale::toDoubleC(it->attribute("CSTW"), -0.1) * 10));
1876
 
        
1877
 
        fixLegacyCharStyle(newStyle);
1878
 
        
1879
 
        if (impo && ab >= 0 && VorLFound)
1880
 
                last->ParaStyle = DoVorl[ab].toInt();
1881
 
        else
1882
 
                last->ParaStyle = pstylename;
1883
 
        // end of legacy stuff
1884
 
        
1885
 
        int iobj = it->attribute("COBJ", "-1").toInt();
1886
 
 
1887
 
        for (int cxx=0; cxx<tmp2.length(); ++cxx)
1888
 
        {
1889
 
                QChar ch = tmp2.at(cxx);                
1890
 
                { // Legacy mode
1891
 
                        if (ch == QChar(5))
1892
 
                                ch = SpecialChars::PARSEP;
1893
 
                        if (ch == QChar(4))
1894
 
                                ch = SpecialChars::TAB;
1895
 
                }
1896
 
                
1897
 
                int pos = obj->itemText.length();
1898
 
                if (ch == SpecialChars::OBJECT) {
1899
 
                        if (iobj >= 0) {
1900
 
                                if (iobj < doc->FrameItems.count())
1901
 
                                        obj->itemText.insertObject(pos, doc->FrameItems.at(iobj));
1902
 
                                else
1903
 
                                        qDebug() << QString("scribus134format: invalid inline frame used in text object : %1").arg(iobj);
1904
 
                        }
1905
 
                }
1906
 
                else if (ch == SpecialChars::SHYPHEN && pos > 0)
1907
 
                {
1908
 
//                      qDebug() << QString("scribus134format: SHYPHEN at %1").arg(pos);
1909
 
                        ScText* lastItem = obj->itemText.item(pos-1);
1910
 
                        // double SHY means user provided SHY, single SHY is automatic one
1911
 
                        if (lastItem->effects() & ScStyle_HyphenationPossible)
1912
 
                        {
1913
 
                                lastItem->setEffects(lastItem->effects() & ~ScStyle_HyphenationPossible);
1914
 
                                obj->itemText.insertChars(pos, QString(ch));
1915
 
                        }
1916
 
                        else
1917
 
                        {
1918
 
                                lastItem->setEffects(lastItem->effects() | ScStyle_HyphenationPossible);
1919
 
                        }
1920
 
                }
1921
 
                else {
1922
 
                        obj->itemText.insertChars(pos, QString(ch));
1923
 
                }
1924
 
//              qDebug() << QString("style at %1: %2 ^ %3 = %4 (%5)").arg(pos).arg((uint)newStyle.effects()).arg((uint)last->Style.effects()).arg((uint)(newStyle.effects() ^ last->Style.effects())).arg(newStyle != last->Style);
1925
 
                if (newStyle != last->Style) // || (newStyle.effects() ^ last->Style.effects()) == ScStyle_HyphenationPossible) 
1926
 
                {  // FIXME StyleFlag operator== ignores hyphen flag
1927
 
//                      qDebug() << QString("new style at %1: %2 -> %3").arg(pos).arg(last->Style.asString()).arg(newStyle.asString());
1928
 
                        obj->itemText.setCharStyle(last->StyleStart, pos-last->StyleStart, last->Style);
1929
 
                        last->Style = newStyle;
1930
 
                        last->StyleStart = pos;
1931
 
                }
1932
 
                if (ch == SpecialChars::PARSEP) {
1933
 
                        ParagraphStyle pstyle;
1934
 
                        // Qt4 if (last->ParaStyle >= 0) {
1935
 
                        if (!last->ParaStyle.isEmpty()) {
1936
 
                                pstyle.setParent( last->ParaStyle );
1937
 
                        }
1938
 
                        if (calign >= 0)
1939
 
                                pstyle.setAlignment(static_cast<ParagraphStyle::AlignmentType>(calign));
1940
 
//                      qDebug() << QString("par style at %1: %2/%3 (%4) calign %5").arg(pos).arg(pstyle.name()).arg(pstyle.parent()).arg(last->ParaStyle).arg(calign);
1941
 
                        obj->itemText.applyStyle(pos, pstyle);
1942
 
                }
1943
 
        }
1944
 
 
1945
 
        obj->itemText.setCharStyle(last->StyleStart, obj->itemText.length()-last->StyleStart, last->Style);
1946
 
        last->StyleStart = obj->itemText.length();
1947
 
/*
1948
 
        QString dbg("");
1949
 
        for (int i=0; i < obj->itemText.length(); ++i)
1950
 
        {
1951
 
                dbg += obj->itemText.text(i,1);
1952
 
                if (obj->itemText.item(i)->effects() & ScStyle_HyphenationPossible)
1953
 
                        dbg += "~";
1954
 
        }
1955
 
        qDebug("scribus134format: read itemtext %d '%s'", obj->itemText.length(), dbg.latin1());
1956
 
        */
1957
 
        ParagraphStyle pstyle;
1958
 
 
1959
 
        if (!last->ParaStyle.isEmpty()) { // Qt4 >= 0) {
1960
 
                pstyle.setParent( last->ParaStyle );
1961
 
                obj->itemText.applyStyle(obj->itemText.length()-1, pstyle);
1962
 
        }
1963
 
        if (calign >= 0) {
1964
 
                pstyle.setAlignment(static_cast<ParagraphStyle::AlignmentType>(calign));
1965
 
                obj->itemText.applyStyle(obj->itemText.length()-1, pstyle);
1966
 
        }
1967
 
}
1968
 
 
1969
 
 
1970
 
 
1971
 
void Scribus134Format::readParagraphStyle(ParagraphStyle& vg, const QDomElement& pg, SCFonts &avail, ScribusDoc *doc)
1972
 
{
1973
 
        vg.erase();
1974
 
        vg.setName(pg.attribute("NAME", ""));
1975
 
        // The default style attribute must be correctly set before trying to assign a parent
1976
 
        if (pg.hasAttribute("DefaultStyle"))
1977
 
                vg.setDefaultStyle(pg.attribute("DefaultStyle").toInt());
1978
 
        else if (vg.name() == CommonStrings::DefaultParagraphStyle || vg.name() == CommonStrings::trDefaultParagraphStyle)
1979
 
                vg.setDefaultStyle(true);
1980
 
        else
1981
 
                vg.setDefaultStyle(false);
1982
 
        QString parentStyle = pg.attribute("PARENT", "");
1983
 
        if (!parentStyle.isEmpty())
1984
 
        {
1985
 
                if (m_Doc->styleExists(parentStyle))
1986
 
                        vg.setParent(parentStyle);
1987
 
                else
1988
 
                        vg.setParent(CommonStrings::DefaultParagraphStyle);
1989
 
        }
1990
 
        if (pg.hasAttribute("LINESPMode"))
1991
 
                vg.setLineSpacingMode(static_cast<ParagraphStyle::LineSpacingMode>(pg.attribute("LINESPMode").toInt()));
1992
 
        if (pg.hasAttribute("LINESP"))
1993
 
                vg.setLineSpacing(ScCLocale::toDoubleC(pg.attribute("LINESP")));
1994
 
        if (pg.hasAttribute("INDENT"))
1995
 
                vg.setLeftMargin(ScCLocale::toDoubleC(pg.attribute("INDENT")));
1996
 
        if (pg.hasAttribute("RMARGIN"))
1997
 
                vg.setRightMargin(ScCLocale::toDoubleC(pg.attribute("RMARGIN")));
1998
 
        if (pg.hasAttribute("FIRST"))
1999
 
                vg.setFirstIndent(ScCLocale::toDoubleC(pg.attribute("FIRST")));
2000
 
        if (pg.hasAttribute("ALIGN"))
2001
 
                vg.setAlignment(static_cast<ParagraphStyle::AlignmentType>(pg.attribute("ALIGN").toInt()));
2002
 
        if (pg.hasAttribute("VOR"))
2003
 
                vg.setGapBefore(ScCLocale::toDoubleC(pg.attribute("VOR")));
2004
 
        if (pg.hasAttribute("NACH"))
2005
 
                vg.setGapAfter(ScCLocale::toDoubleC(pg.attribute("NACH")));
2006
 
        if (pg.hasAttribute("DROP"))
2007
 
                vg.setHasDropCap(static_cast<bool>(pg.attribute("DROP").toInt()));
2008
 
        if (pg.hasAttribute("DROPLIN"))
2009
 
                vg.setDropCapLines(pg.attribute("DROPLIN").toInt());
2010
 
        if (pg.hasAttribute("DROPDIST"))
2011
 
                vg.setDropCapOffset(ScCLocale::toDoubleC(pg.attribute("DROPDIST")));
2012
 
        if (pg.hasAttribute("PSHORTCUT"))
2013
 
                vg.setShortcut(pg.attribute("PSHORTCUT"));
2014
 
 
2015
 
        //              vg.tabValues().clear();
2016
 
        if ((pg.hasAttribute("NUMTAB")) && (pg.attribute("NUMTAB", "0").toInt() != 0))
2017
 
        {
2018
 
                QList<ParagraphStyle::TabRecord> tbs;
2019
 
                ParagraphStyle::TabRecord tb;
2020
 
                QString tmp = pg.attribute("TABS");
2021
 
                ScTextStream tgv(&tmp, QIODevice::ReadOnly);
2022
 
                double xf, xf2;
2023
 
                for (int cxv = 0; cxv < pg.attribute("NUMTAB", "0").toInt(); cxv += 2)
2024
 
                {
2025
 
                        tgv >> xf;
2026
 
                        tgv >> xf2;
2027
 
                        tb.tabPosition = xf2;
2028
 
                        tb.tabType = static_cast<int>(xf);
2029
 
                        tb.tabFillChar =  QChar();
2030
 
                        tbs.append(tb);
2031
 
                }
2032
 
                vg.setTabValues(tbs);
2033
 
                tmp = "";
2034
 
        }
2035
 
        else
2036
 
        {
2037
 
                QList<ParagraphStyle::TabRecord> tbs;
2038
 
                vg.resetTabValues();
2039
 
                QDomNode IT = pg.firstChild();
2040
 
                while(!IT.isNull())
2041
 
                {
2042
 
                        QDomElement it = IT.toElement();
2043
 
                        if (it.tagName()=="Tabs")
2044
 
                        {
2045
 
                                ParagraphStyle::TabRecord tb;
2046
 
                                tb.tabPosition = ScCLocale::toDoubleC( it.attribute("Pos"));
2047
 
                                tb.tabType = it.attribute("Type").toInt();
2048
 
                                QString tbCh = "";
2049
 
                                tbCh = it.attribute("Fill","");
2050
 
                                if (tbCh.isEmpty())
2051
 
                                        tb.tabFillChar = QChar();
2052
 
                                else
2053
 
                                        tb.tabFillChar = tbCh[0];
2054
 
                                tbs.append(tb);
2055
 
                        }
2056
 
                        IT=IT.nextSibling();
2057
 
                }
2058
 
                if (tbs.count() > 0)
2059
 
                        vg.setTabValues(tbs);
2060
 
        }
2061
 
        
2062
 
        if (pg.hasAttribute("OpticalMargins"))
2063
 
                vg.setOpticalMargins(pg.attribute("OpticalMargins").toInt());
2064
 
        if (pg.hasAttribute("HyphenationMode"))
2065
 
                vg.setHyphenationMode(pg.attribute("HyphenationMode").toInt());
2066
 
        if (pg.hasAttribute("MinWordTrack"))
2067
 
                vg.setMinWordTracking(ScCLocale::toDoubleC(pg.attribute("MinWordTrack")));
2068
 
        if (pg.hasAttribute("NormWordTrack"))
2069
 
                vg.charStyle().setWordTracking(ScCLocale::toDoubleC(pg.attribute("NormWordTrack")));
2070
 
        if (pg.hasAttribute("MinGlyphShrink"))
2071
 
                vg.setMinGlyphExtension(ScCLocale::toDoubleC(pg.attribute("MinGlyphShrink")));
2072
 
        if (pg.hasAttribute("MaxGlyphExtend"))
2073
 
                vg.setMaxGlyphExtension(ScCLocale::toDoubleC(pg.attribute("MaxGlyphExtend")));
2074
 
        
2075
 
        GetCStyle( &pg, doc, vg.charStyle());
2076
 
        
2077
 
        fixLegacyParStyle(vg);
2078
 
}
2079
 
 
2080
 
PageItem* Scribus134Format::PasteItem(QDomElement *obj, ScribusDoc *doc, const QString& baseDir, int pagenr)
2081
 
{
2082
 
        struct ImageLoadRequest loadingInfo;
2083
 
        int z = 0;
2084
 
        PageItem::ItemType pt = static_cast<PageItem::ItemType>(obj->attribute("PTYPE").toInt());
2085
 
        double x = ScCLocale::toDoubleC( obj->attribute("XPOS"));
2086
 
        double y = ScCLocale::toDoubleC( obj->attribute("YPOS"));
2087
 
        double w = ScCLocale::toDoubleC( obj->attribute("WIDTH"));
2088
 
        double h = ScCLocale::toDoubleC( obj->attribute("HEIGHT"));
2089
 
        double pw = ScCLocale::toDoubleC( obj->attribute("PWIDTH"));
2090
 
        double scx = ScCLocale::toDoubleC( obj->attribute("LOCALSCX"));
2091
 
        double scy = ScCLocale::toDoubleC( obj->attribute("LOCALSCY"));
2092
 
        QString Pcolor = obj->attribute("PCOLOR");
2093
 
        if (Pcolor.isEmpty())
2094
 
                Pcolor = "None";
2095
 
        QString Pcolor2 = obj->attribute("PCOLOR2");
2096
 
        if (Pcolor2.isEmpty())
2097
 
                Pcolor2 = "None";
2098
 
        QColor tmpc;
2099
 
        PageItem *currItem=NULL;
2100
 
        QString tmp;
2101
 
        int xi;
2102
 
        double xf, yf, xf2;
2103
 
        QString clPath;
2104
 
        QDomNode IT;
2105
 
        switch (pt)
2106
 
        {
2107
 
        // OBSOLETE CR 2005-02-06
2108
 
        case PageItem::ItemType1:
2109
 
                z = doc->itemAdd(PageItem::Polygon, PageItem::Ellipse, x, y, w, h, pw, Pcolor, Pcolor2, true);
2110
 
                currItem = doc->Items->at(z);
2111
 
                if (pagenr > -2) 
2112
 
                        currItem->OwnPage = pagenr;
2113
 
                break;
2114
 
        //
2115
 
        case PageItem::ImageFrame:
2116
 
        case PageItem::LatexFrame: /*Everything that is valid for image frames is also valid for latex frames*/
2117
 
                z = doc->itemAdd(pt, PageItem::Unspecified, x, y, w, h, 1, doc->toolSettings.dBrushPict, CommonStrings::None, true);
2118
 
                currItem = doc->Items->at(z);
2119
 
                UndoManager::instance()->setUndoEnabled(false);
2120
 
                if (pagenr > -2) 
2121
 
                        currItem->OwnPage = pagenr;
2122
 
                currItem->ScaleType = obj->attribute("SCALETYPE", "1").toInt();
2123
 
                currItem->AspectRatio = obj->attribute("RATIO", "0").toInt();
2124
 
                currItem->setImageXYScale(scx, scy);
2125
 
                currItem->setImageXYOffset(ScCLocale::toDoubleC(obj->attribute("LOCALX")), ScCLocale::toDoubleC(obj->attribute("LOCALY")));
2126
 
                if (currItem->asLatexFrame())
2127
 
                {
2128
 
                        PageItem_LatexFrame *latexitem = currItem->asLatexFrame();
2129
 
                //      currItem->PictureIsAvailable = true;
2130
 
                        currItem->invalid = true;
2131
 
                        IT = obj->firstChild();
2132
 
                        while(!IT.isNull())
2133
 
                        {
2134
 
                                QDomElement it = IT.toElement();
2135
 
                                if (it.tagName()=="LATEX")
2136
 
                                {
2137
 
                                        latexitem->setConfigFile(it.attribute("ConfigFile"), true);
2138
 
                                        latexitem->setDpi(it.attribute("DPI").toInt());
2139
 
                                        latexitem->setUsePreamble(static_cast<bool>(it.attribute("USE_PREAMBLE").toInt()));
2140
 
                                        QDomElement property = it.firstChildElement("PROPERTY");
2141
 
                                        while (!property.isNull())
2142
 
                                        {
2143
 
                                                QString name = property.attribute("name");
2144
 
                                                QString value = property.attribute("value");
2145
 
                                                property = property.nextSiblingElement("PROPERTY");
2146
 
                                                if (name.isEmpty()) continue;
2147
 
                                                latexitem->editorProperties[name] = value;
2148
 
                                        }
2149
 
                                        QString temp = it.text();
2150
 
                                        latexitem->setFormula(temp, false);
2151
 
                                        
2152
 
                                }
2153
 
                                IT=IT.nextSibling();
2154
 
                        }
2155
 
                }
2156
 
                else
2157
 
                {
2158
 
                        bool inlineF = static_cast<bool>(obj->attribute("isInlineImage", "0").toInt());
2159
 
                        QString dat = obj->attribute("ImageData", "");
2160
 
                        QByteArray inlineImageData;
2161
 
                        inlineImageData.append(dat);
2162
 
                        QString inlineImageExt = obj->attribute("inlineImageExt", "");
2163
 
                        if (inlineF)
2164
 
                        {
2165
 
                                if (inlineImageData.size() > 0)
2166
 
                                {
2167
 
                                        currItem->tempImageFile = new QTemporaryFile(QDir::tempPath() + "/scribus_temp_XXXXXX." + inlineImageExt);
2168
 
                                        currItem->tempImageFile->open();
2169
 
                                        QString fileName = getLongPathName(currItem->tempImageFile->fileName());
2170
 
                                        currItem->tempImageFile->close();
2171
 
                                        inlineImageData = qUncompress(QByteArray::fromBase64(inlineImageData));
2172
 
                                        QFile outFil(fileName);
2173
 
                                        if (outFil.open(QIODevice::WriteOnly))
2174
 
                                        {
2175
 
                                                outFil.write(inlineImageData);
2176
 
                                                outFil.close();
2177
 
                                                currItem->isInlineImage = true;
2178
 
                                                currItem->Pfile = fileName;
2179
 
                                        }
2180
 
                                }
2181
 
                        }
2182
 
                        else
2183
 
                                currItem->Pfile = Relative2Path(obj->attribute("PFILE"), baseDir);
2184
 
                }
2185
 
                currItem->IProfile  = obj->attribute("PRFILE","");
2186
 
                currItem->EmProfile = obj->attribute("EPROF","");
2187
 
                currItem->IRender   = (eRenderIntent) obj->attribute("IRENDER", "1").toInt();
2188
 
                currItem->UseEmbedded = obj->attribute("EMBEDDED", "1").toInt();
2189
 
                currItem->pixm.imgInfo.lowResType = obj->attribute("ImageRes", "1").toInt();
2190
 
                currItem->pixm.imgInfo.actualPageNumber = obj->attribute("Pagenumber", "0").toInt();
2191
 
                IT = obj->firstChild();
2192
 
                while(!IT.isNull())
2193
 
                {
2194
 
                        QDomElement it = IT.toElement();
2195
 
                        if (it.tagName()=="ImageEffect")
2196
 
                        {
2197
 
                                struct ImageEffect ef;
2198
 
                                ef.effectParameters = it.attribute("Param");
2199
 
                                ef.effectCode = it.attribute("Code").toInt();
2200
 
                                currItem->effectsInUse.append(ef);
2201
 
                        }
2202
 
                        IT=IT.nextSibling();
2203
 
                }
2204
 
                if (!currItem->Pfile.isEmpty())
2205
 
                        doc->loadPict(currItem->Pfile, currItem, false);
2206
 
                currItem->IProfile  = obj->attribute("PRFILE","");
2207
 
                currItem->EmProfile = obj->attribute("EPROF","");
2208
 
                currItem->IRender   = (eRenderIntent) obj->attribute("IRENDER", "1").toInt();
2209
 
                currItem->UseEmbedded = obj->attribute("EMBEDDED", "1").toInt();
2210
 
                currItem->setImageXYScale(scx, scy);
2211
 
                clPath = obj->attribute("ImageClip", "");
2212
 
                if (currItem->pixm.imgInfo.PDSpathData.contains(clPath))
2213
 
                {
2214
 
                        currItem->imageClip = currItem->pixm.imgInfo.PDSpathData[clPath].copy();
2215
 
                        currItem->pixm.imgInfo.usedPath = clPath;
2216
 
                        QMatrix cl;
2217
 
                        cl.translate(currItem->imageXOffset()*currItem->imageXScale(), currItem->imageYOffset()*currItem->imageYScale());
2218
 
                        cl.scale(currItem->imageXScale(), currItem->imageYScale());
2219
 
                        currItem->imageClip.map(cl);
2220
 
                }
2221
 
                currItem->setImageShown(obj->attribute("PICART").toInt());
2222
 
/*              currItem->BBoxX = ScCLocale::toDoubleC( obj->attribute("BBOXX"));
2223
 
                currItem->BBoxH = ScCLocale::toDoubleC( obj->attribute("BBOXH")); */
2224
 
                currItem->setLineWidth(pw);
2225
 
                if (currItem->pixm.imgInfo.layerInfo.count() != 0)
2226
 
                {
2227
 
                        bool found = false;
2228
 
                        IT = obj->firstChild();
2229
 
                        while(!IT.isNull())
2230
 
                        {
2231
 
                                QDomElement it = IT.toElement();
2232
 
                                if (it.tagName() == "PSDLayer")
2233
 
                                {
2234
 
                                        found = true;
2235
 
                                        loadingInfo.blend = it.attribute("Blend");
2236
 
                                        loadingInfo.opacity = it.attribute("Opacity").toInt();
2237
 
                                        loadingInfo.visible = static_cast<bool>(it.attribute("Visible").toInt());
2238
 
                                        loadingInfo.useMask = static_cast<bool>(it.attribute("useMask", "1").toInt());
2239
 
                                        currItem->pixm.imgInfo.RequestProps.insert(it.attribute("Layer").toInt(), loadingInfo);
2240
 
                                }
2241
 
                                IT=IT.nextSibling();
2242
 
                        }
2243
 
                        if (found)
2244
 
                        {
2245
 
                                currItem->pixm.imgInfo.isRequest = true;
2246
 
                                doc->loadPict(currItem->Pfile, currItem, true);
2247
 
                        }
2248
 
                }
2249
 
                UndoManager::instance()->setUndoEnabled(true);
2250
 
                break;
2251
 
        // OBSOLETE CR 2005-02-06
2252
 
        case PageItem::ItemType3:
2253
 
                z = doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, x, y, w, h, pw, Pcolor, Pcolor2, true);
2254
 
                currItem = doc->Items->at(z);
2255
 
                if (pagenr > -2) 
2256
 
                        currItem->OwnPage = pagenr;
2257
 
                break;
2258
 
        //
2259
 
        case PageItem::PathText:
2260
 
                z = doc->itemAdd(PageItem::PathText, PageItem::Unspecified, x, y, w, h, pw, CommonStrings::None, Pcolor, true);
2261
 
                currItem = doc->Items->at(z);
2262
 
                if (pagenr > -2) 
2263
 
                        currItem->OwnPage = pagenr;
2264
 
                //currItem->convertTo(pt);
2265
 
                break;
2266
 
        case PageItem::TextFrame:
2267
 
                z = doc->itemAdd(PageItem::TextFrame, PageItem::Unspecified, x, y, w, h, pw, CommonStrings::None, Pcolor, true);
2268
 
                currItem = doc->Items->at(z);
2269
 
                if (pagenr > -2) 
2270
 
                        currItem->OwnPage = pagenr;
2271
 
                //currItem->convertTo(pt);
2272
 
                break;
2273
 
        case PageItem::Line:
2274
 
                z = doc->itemAdd(PageItem::Line, PageItem::Unspecified, x, y, w, h, pw, CommonStrings::None, Pcolor2, true);
2275
 
                currItem = doc->Items->at(z);
2276
 
                if (pagenr > -2) 
2277
 
                        currItem->OwnPage = pagenr;
2278
 
                break;
2279
 
        case PageItem::Polygon:
2280
 
                z = doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, x, y, w, h, pw, Pcolor, Pcolor2, true);
2281
 
                currItem = doc->Items->at(z);
2282
 
                if (pagenr > -2) 
2283
 
                        currItem->OwnPage = pagenr;
2284
 
                break;
2285
 
        case PageItem::PolyLine:
2286
 
                z = doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, x, y, w, h, pw, Pcolor, Pcolor2, true);
2287
 
                currItem = doc->Items->at(z);
2288
 
                if (pagenr > -2) 
2289
 
                        currItem->OwnPage = pagenr;
2290
 
                break;
2291
 
        case PageItem::Multiple:
2292
 
                Q_ASSERT(false);
2293
 
                break;
2294
 
        }
2295
 
 
2296
 
        UndoManager::instance()->setUndoEnabled(false);
2297
 
        currItem->FrameType = obj->attribute("FRTYPE", "0").toInt();
2298
 
        int startArrowIndex = obj->attribute("startArrowIndex", "0").toInt();
2299
 
        if ((startArrowIndex < 0) || (startArrowIndex > static_cast<int>(doc->arrowStyles.size())))
2300
 
        {
2301
 
                qDebug() << QString("scribus134format: invalid arrow index: %").arg(startArrowIndex);
2302
 
                startArrowIndex = 0;
2303
 
        }
2304
 
        currItem->setStartArrowIndex(startArrowIndex);
2305
 
        int endArrowIndex = obj->attribute("endArrowIndex", "0").toInt();
2306
 
        if ((endArrowIndex < 0) || (endArrowIndex > static_cast<int>(doc->arrowStyles.size())))
2307
 
        {
2308
 
                qDebug() << QString("scribus134format: invalid arrow index: %").arg(endArrowIndex);
2309
 
                endArrowIndex = 0;
2310
 
        }
2311
 
        currItem->setEndArrowIndex(endArrowIndex);
2312
 
        currItem->NamedLStyle = obj->attribute("NAMEDLST", "");
2313
 
        currItem->isBookmark = obj->attribute("BOOKMARK").toInt();
2314
 
        if ((currItem->isBookmark) && (doc->BookMarks.count() == 0))
2315
 
                doc->OldBM = true;
2316
 
        currItem->setImageFlippedH(obj->attribute("FLIPPEDH").toInt());
2317
 
        currItem->setImageFlippedV(obj->attribute("FLIPPEDV").toInt());
2318
 
        currItem->setCornerRadius(ScCLocale::toDoubleC(obj->attribute("RADRECT"), 0.0));
2319
 
        currItem->ClipEdited = obj->attribute("CLIPEDIT", "0").toInt();
2320
 
        currItem->setFillColor(Pcolor);
2321
 
        currItem->setLineColor(Pcolor2);
2322
 
        currItem->setFillShade(obj->attribute("SHADE").toInt());
2323
 
        currItem->setLineShade(obj->attribute("SHADE2").toInt());
2324
 
        ParagraphStyle pstyle;
2325
 
        if (obj->hasAttribute("LINESP"))
2326
 
                pstyle.setLineSpacing(ScCLocale::toDoubleC(obj->attribute("LINESP")));
2327
 
        if (obj->hasAttribute("LINESPMode"))
2328
 
                pstyle.setLineSpacingMode(static_cast<ParagraphStyle::LineSpacingMode>(obj->attribute("LINESPMode", "0").toInt()));
2329
 
        if (obj->hasAttribute("ALIGN"))
2330
 
                pstyle.setAlignment(static_cast<ParagraphStyle::AlignmentType>(obj->attribute("ALIGN", "0").toInt()));
2331
 
        if (obj->hasAttribute("IFONT"))
2332
 
                pstyle.charStyle().setFont(m_AvailableFonts->findFont(obj->attribute("IFONT"), doc));
2333
 
        if (obj->hasAttribute("ISIZE"))
2334
 
                pstyle.charStyle().setFontSize(qRound(ScCLocale::toDoubleC(obj->attribute("ISIZE")) * 10));
2335
 
        if (obj->hasAttribute("TXTSTROKE"))
2336
 
                pstyle.charStyle().setStrokeColor(obj->attribute("TXTSTROKE"));
2337
 
        if (obj->hasAttribute("TXTFILL"))
2338
 
                pstyle.charStyle().setFillColor(obj->attribute("TXTFILL"));
2339
 
        if (obj->hasAttribute("TXTSTRSH"))
2340
 
                pstyle.charStyle().setStrokeShade(obj->attribute("TXTSTRSH").toInt());
2341
 
        if (obj->hasAttribute("TXTFILLSH"))
2342
 
                pstyle.charStyle().setFillShade(obj->attribute("TXTFILLSH").toInt());
2343
 
        if (obj->hasAttribute("TXTSCALE"))
2344
 
                pstyle.charStyle().setScaleH(qRound(ScCLocale::toDoubleC(obj->attribute("TXTSCALE")) * 10));
2345
 
        if (obj->hasAttribute("TXTSCALEV"))
2346
 
                pstyle.charStyle().setScaleV(qRound(ScCLocale::toDoubleC(obj->attribute("TXTSCALEV")) * 10));
2347
 
        if (obj->hasAttribute("TXTBASE"))
2348
 
                pstyle.charStyle().setBaselineOffset(qRound(ScCLocale::toDoubleC(obj->attribute("TXTBASE")) * 10));
2349
 
        if (obj->hasAttribute("TXTSHX"))
2350
 
                pstyle.charStyle().setShadowXOffset(qRound(ScCLocale::toDoubleC(obj->attribute("TXTSHX")) * 10));
2351
 
        if (obj->hasAttribute("TXTSHY"))
2352
 
                pstyle.charStyle().setShadowYOffset(qRound(ScCLocale::toDoubleC(obj->attribute("TXTSHY")) * 10));
2353
 
        if (obj->hasAttribute("TXTOUT"))
2354
 
                pstyle.charStyle().setOutlineWidth(qRound(ScCLocale::toDoubleC(obj->attribute("TXTOUT")) * 10));
2355
 
        if (obj->hasAttribute("TXTULP"))
2356
 
                pstyle.charStyle().setUnderlineOffset(qRound(ScCLocale::toDoubleC(obj->attribute("TXTULP")) * 10));
2357
 
        if (obj->hasAttribute("TXTULW"))
2358
 
                pstyle.charStyle().setUnderlineWidth(qRound(ScCLocale::toDoubleC(obj->attribute("TXTULW")) * 10));
2359
 
        if (obj->hasAttribute("TXTSTP"))
2360
 
                pstyle.charStyle().setStrikethruOffset(qRound(ScCLocale::toDoubleC(obj->attribute("TXTSTP")) * 10));
2361
 
        if (obj->hasAttribute("TXTSTW"))
2362
 
                pstyle.charStyle().setStrikethruWidth(qRound(ScCLocale::toDoubleC(obj->attribute("TXTSTW")) * 10));
2363
 
        if (obj->hasAttribute("TXTSTYLE"))
2364
 
                pstyle.charStyle().setFeatures(static_cast<StyleFlag>(obj->attribute("TXTSTYLE").toInt()).featureList());
2365
 
        if (obj->hasAttribute("TXTKERN"))
2366
 
                pstyle.charStyle().setTracking(qRound(ScCLocale::toDoubleC(obj->attribute("TXTKERN"), 0.0) * 10));
2367
 
        if (obj->hasAttribute("wordTrack"))
2368
 
                pstyle.charStyle().setWordTracking(ScCLocale::toDoubleC(obj->attribute("wordTrack")));
2369
 
        if (obj->hasAttribute("MinWordTrack"))
2370
 
                pstyle.setMinWordTracking(ScCLocale::toDoubleC(obj->attribute("MinWordTrack")));
2371
 
        if (obj->hasAttribute("MinGlyphShrink"))
2372
 
                pstyle.setMinGlyphExtension(ScCLocale::toDoubleC(obj->attribute("MinGlyphShrink")));
2373
 
        if (obj->hasAttribute("MaxGlyphExtend"))
2374
 
                pstyle.setMaxGlyphExtension(ScCLocale::toDoubleC(obj->attribute("MaxGlyphExtend")));
2375
 
        if (obj->hasAttribute("OpticalMargins"))
2376
 
                pstyle.setOpticalMargins(obj->attribute("OpticalMargins").toInt());
2377
 
        if (obj->hasAttribute("HyphenationMode"))
2378
 
                pstyle.setHyphenationMode(obj->attribute("HyphenationMode").toInt());
2379
 
        if (obj->hasAttribute("leftMargin"))
2380
 
                pstyle.setLeftMargin(ScCLocale::toDoubleC(obj->attribute("leftMargin")));
2381
 
        if (obj->hasAttribute("rightMargin"))
2382
 
                pstyle.setRightMargin(ScCLocale::toDoubleC(obj->attribute("rightMargin")));
2383
 
        if (obj->hasAttribute("firstIndent"))
2384
 
                pstyle.setFirstIndent(ScCLocale::toDoubleC(obj->attribute("firstIndent")));
2385
 
        currItem->itemText.setDefaultStyle(pstyle);
2386
 
 
2387
 
        if (obj->hasAttribute("PSTYLE"))
2388
 
        {
2389
 
                QString pstyleName = obj->attribute("PSTYLE");
2390
 
                if (!pstyleName.isEmpty())
2391
 
                {
2392
 
                        ParagraphStyle defStyle(currItem->itemText.defaultStyle());
2393
 
                        defStyle.setParent(pstyleName);
2394
 
                        currItem->itemText.setDefaultStyle(defStyle);
2395
 
                }
2396
 
        }
2397
 
 
2398
 
        currItem->setRotation(ScCLocale::toDoubleC(obj->attribute("ROT")));
2399
 
        currItem->setTextToFrameDist(ScCLocale::toDoubleC(obj->attribute("EXTRA")),
2400
 
                                                                ScCLocale::toDoubleC(obj->attribute("REXTRA"), 1.0),
2401
 
                                                                ScCLocale::toDoubleC(obj->attribute("TEXTRA"), 1.0),
2402
 
                                                                ScCLocale::toDoubleC(obj->attribute("BEXTRA"), 1.0));
2403
 
        currItem->setFirstLineOffset(static_cast<FirstLineOffsetPolicy>(obj->attribute("FLOP").toInt()));
2404
 
 
2405
 
        currItem->PLineArt = Qt::PenStyle(obj->attribute("PLINEART").toInt());
2406
 
        currItem->PLineEnd = Qt::PenCapStyle(obj->attribute("PLINEEND", "0").toInt());
2407
 
        currItem->PLineJoin = Qt::PenJoinStyle(obj->attribute("PLINEJOIN", "0").toInt());
2408
 
        currItem->setPrintEnabled(obj->attribute("PRINTABLE").toInt());
2409
 
        currItem->setIsAnnotation(obj->attribute("ANNOTATION", "0").toInt());
2410
 
        currItem->annotation().setType(obj->attribute("ANTYPE", "0").toInt());
2411
 
        QString AnName = obj->attribute("ANNAME","");
2412
 
        if (!AnName.isEmpty())
2413
 
        {
2414
 
                if (currItem->itemName() == AnName)
2415
 
                        currItem->AutoName = true;
2416
 
                else
2417
 
                {
2418
 
                        currItem->setItemName(AnName);
2419
 
                        currItem->AutoName = false;
2420
 
                }
2421
 
        }
2422
 
 
2423
 
        currItem->annotation().setAction(obj->attribute("ANACTION",""));
2424
 
        currItem->annotation().setE_act(obj->attribute("ANEACT",""));
2425
 
        currItem->annotation().setX_act(obj->attribute("ANXACT",""));
2426
 
        currItem->annotation().setD_act(obj->attribute("ANDACT",""));
2427
 
        currItem->annotation().setFo_act(obj->attribute("ANFOACT",""));
2428
 
        currItem->annotation().setBl_act(obj->attribute("ANBLACT",""));
2429
 
        currItem->annotation().setK_act(obj->attribute("ANKACT",""));
2430
 
        currItem->annotation().setF_act(obj->attribute("ANFACT",""));
2431
 
        currItem->annotation().setV_act(obj->attribute("ANVACT",""));
2432
 
        currItem->annotation().setC_act(obj->attribute("ANCACT",""));
2433
 
        currItem->annotation().setActionType(obj->attribute("ANACTYP", "0").toInt());
2434
 
        currItem->annotation().setExtern(obj->attribute("ANEXTERN",""));
2435
 
        if ((!currItem->annotation().Extern().isEmpty()) && (currItem->annotation().ActionType() != 8))
2436
 
                currItem->annotation().setExtern(Relative2Path(obj->attribute("ANEXTERN","") , baseDir));
2437
 
        currItem->annotation().setZiel(obj->attribute("ANZIEL", "0").toInt());
2438
 
        currItem->annotation().setToolTip(obj->attribute("ANTOOLTIP",""));
2439
 
        currItem->annotation().setRollOver(obj->attribute("ANROLL",""));
2440
 
        currItem->annotation().setDown(obj->attribute("ANDOWN",""));
2441
 
        currItem->annotation().setBwid(obj->attribute("ANBWID", "1").toInt());
2442
 
        currItem->annotation().setBsty(obj->attribute("ANBSTY", "0").toInt());
2443
 
        currItem->annotation().setFeed(obj->attribute("ANFEED", "1").toInt());
2444
 
        currItem->annotation().setFlag(obj->attribute("ANFLAG", "0").toInt());
2445
 
        currItem->annotation().setFont(obj->attribute("ANFONT", "4").toInt());
2446
 
        currItem->annotation().setFormat(obj->attribute("ANFORMAT", "0").toInt());
2447
 
        currItem->annotation().setVis(obj->attribute("ANVIS", "0").toInt());
2448
 
        currItem->annotation().setIsChk(static_cast<bool>(obj->attribute("ANCHK", "0").toInt()));
2449
 
        currItem->annotation().setAAact(static_cast<bool>(obj->attribute("ANAA", "0").toInt()));
2450
 
        currItem->annotation().setHTML(obj->attribute("ANHTML", "0").toInt());
2451
 
        currItem->annotation().setUseIcons(static_cast<bool>(obj->attribute("ANICON", "0").toInt()));
2452
 
        currItem->annotation().setChkStil(obj->attribute("ANCHKS", "0").toInt());
2453
 
        currItem->annotation().setMaxChar(obj->attribute("ANMC", "-1").toInt());
2454
 
        currItem->annotation().setBorderColor(obj->attribute("ANBCOL", CommonStrings::None));
2455
 
        currItem->annotation().setIPlace(obj->attribute("ANPLACE", "1").toInt());
2456
 
        currItem->annotation().setScaleW(obj->attribute("ANSCALE", "0").toInt());
2457
 
 
2458
 
        if (currItem->asTextFrame() || currItem->asPathText())
2459
 
        {
2460
 
                UndoManager::instance()->setUndoEnabled(false);
2461
 
                if (currItem->isAnnotation() && currItem->annotation().UseIcons())
2462
 
                {
2463
 
                        currItem->ScaleType = obj->attribute("SCALETYPE", "1").toInt();
2464
 
                        currItem->AspectRatio = obj->attribute("RATIO", "0").toInt();
2465
 
                        currItem->setImageXYScale(scx, scy);
2466
 
                        currItem->setImageXYOffset(ScCLocale::toDoubleC(obj->attribute("LOCALX")), ScCLocale::toDoubleC(obj->attribute("LOCALY")));
2467
 
                        currItem->Pfile  = Relative2Path(obj->attribute("PFILE","") , baseDir);
2468
 
                        currItem->Pfile2 = Relative2Path(obj->attribute("PFILE2",""), baseDir);
2469
 
                        currItem->Pfile3 = Relative2Path(obj->attribute("PFILE3",""), baseDir);
2470
 
                        currItem->IProfile = obj->attribute("PRFILE","");
2471
 
                        currItem->EmProfile = obj->attribute("EPROF","");
2472
 
                        currItem->IRender   = (eRenderIntent) obj->attribute("IRENDER", "1").toInt();
2473
 
                        currItem->UseEmbedded = obj->attribute("EMBEDDED", "1").toInt();
2474
 
                        doc->LoadPict(currItem->Pfile, z);
2475
 
                        currItem->setImageXYScale(scx, scy);
2476
 
                        currItem->setImageShown(obj->attribute("PICART").toInt());
2477
 
/*                      currItem->BBoxX = ScCLocale::toDoubleC( obj->attribute("BBOXX"));
2478
 
                        currItem->BBoxH = ScCLocale::toDoubleC( obj->attribute("BBOXH")); */
2479
 
                }
2480
 
                UndoManager::instance()->setUndoEnabled(true);
2481
 
        }
2482
 
 
2483
 
        currItem->TopLine = static_cast<bool>(obj->attribute("TopLine", "0").toInt());
2484
 
        currItem->LeftLine = static_cast<bool>(obj->attribute("LeftLine", "0").toInt());
2485
 
        currItem->RightLine = static_cast<bool>(obj->attribute("RightLine", "0").toInt());
2486
 
        currItem->BottomLine = static_cast<bool>(obj->attribute("BottomLine", "0").toInt());
2487
 
        currItem->isTableItem = static_cast<bool>(obj->attribute("isTableItem", "0").toInt());
2488
 
        currItem->TopLinkID =  obj->attribute("TopLINK", "-1").toInt();
2489
 
        currItem->LeftLinkID =  obj->attribute("LeftLINK", "-1").toInt();
2490
 
        currItem->RightLinkID =  obj->attribute("RightLINK", "-1").toInt();
2491
 
        currItem->BottomLinkID =  obj->attribute("BottomLINK", "-1").toInt();
2492
 
        currItem->PoShow = obj->attribute("PLTSHOW", "0").toInt();
2493
 
        currItem->BaseOffs = ScCLocale::toDoubleC( obj->attribute("BASEOF"), 0.0);
2494
 
        currItem->textPathType =  obj->attribute("textPathType", "0").toInt();
2495
 
        currItem->textPathFlipped = static_cast<bool>(obj->attribute("textPathFlipped", "0").toInt());
2496
 
        if ( obj->hasAttribute("TEXTFLOWMODE") )
2497
 
                currItem->setTextFlowMode((PageItem::TextFlowMode) obj->attribute("TEXTFLOWMODE", "0").toInt());
2498
 
        else if ( obj->attribute("TEXTFLOW").toInt() )
2499
 
        {
2500
 
                if (obj->attribute("TEXTFLOW2", "0").toInt())
2501
 
                        currItem->setTextFlowMode(PageItem::TextFlowUsesBoundingBox);
2502
 
                else if (obj->attribute("TEXTFLOW3", "0").toInt())
2503
 
                        currItem->setTextFlowMode(PageItem::TextFlowUsesContourLine);
2504
 
                else
2505
 
                        currItem->setTextFlowMode(PageItem::TextFlowUsesFrameShape);    
2506
 
        }
2507
 
        else
2508
 
                currItem->setTextFlowMode(PageItem::TextFlowDisabled);
2509
 
        currItem->DashOffset = ScCLocale::toDoubleC( obj->attribute("DASHOFF"), 0.0);
2510
 
        currItem->setReversed(static_cast<bool>(obj->attribute("REVERS", "0").toInt()));
2511
 
        currItem->setLocked(static_cast<bool>(obj->attribute("LOCK", "0").toInt()));
2512
 
        currItem->setSizeLocked(static_cast<bool>(obj->attribute("LOCKR", "0").toInt()));
2513
 
        currItem->setFillTransparency(ScCLocale::toDoubleC(obj->attribute("TransValue"), 0.0));
2514
 
        currItem->fillRule = static_cast<bool>(obj->attribute("fillRule", "1").toInt());
2515
 
        currItem->doOverprint = static_cast<bool>(obj->attribute("doOverprint", "0").toInt());
2516
 
        if (obj->hasAttribute("TransValueS"))
2517
 
                currItem->setLineTransparency(ScCLocale::toDoubleC(obj->attribute("TransValueS"), 0.0));
2518
 
        else
2519
 
                currItem->setLineTransparency(ScCLocale::toDoubleC(obj->attribute("TransValue"), 0.0));
2520
 
        currItem->setFillBlendmode(obj->attribute("TransBlend", "0").toInt());
2521
 
        currItem->setLineBlendmode(obj->attribute("TransBlendS", "0").toInt());
2522
 
        if (obj->attribute("TRANSPARENT", "0").toInt() == 1)
2523
 
                currItem->setFillColor(CommonStrings::None);
2524
 
        currItem->Cols = obj->attribute("COLUMNS", "1").toInt();
2525
 
        currItem->ColGap = ScCLocale::toDoubleC( obj->attribute("COLGAP"), 0.0);
2526
 
        if (obj->attribute("LAYER", "0").toInt() != -1)
2527
 
                currItem->LayerNr = obj->attribute("LAYER", "0").toInt();
2528
 
 
2529
 
        tmp = "";
2530
 
        if ((obj->hasAttribute("GROUPS")) && (obj->attribute("NUMGROUP", "0").toInt() != 0))
2531
 
        {
2532
 
                int groupMax = doc->GroupCounter;
2533
 
                QMap<int, int>::ConstIterator gIt;
2534
 
                tmp = obj->attribute("GROUPS");
2535
 
                ScTextStream fg(&tmp, QIODevice::ReadOnly);
2536
 
                currItem->Groups.clear();
2537
 
                for (int cx = 0; cx < obj->attribute("NUMGROUP", "0").toInt(); ++cx)
2538
 
                {
2539
 
                        fg >> xi;
2540
 
                        gIt = groupRemap.find(xi);
2541
 
                        if (gIt != groupRemap.end())
2542
 
                                currItem->Groups.push(gIt.value());
2543
 
                        else
2544
 
                        {
2545
 
                                currItem->Groups.push(groupMax); 
2546
 
                                groupRemap.insert(xi, groupMax);
2547
 
                                ++groupMax;
2548
 
                        }
2549
 
                }
2550
 
                doc->GroupCounter = groupMax;
2551
 
                tmp = "";
2552
 
        }
2553
 
        else
2554
 
                currItem->Groups.clear();
2555
 
 
2556
 
        QList<ParagraphStyle::TabRecord> tbs;
2557
 
        tmp = "";
2558
 
        if ((obj->hasAttribute("NUMTAB")) && (obj->attribute("NUMTAB", "0").toInt() != 0))
2559
 
        {
2560
 
                ParagraphStyle::TabRecord tb;
2561
 
                tmp = obj->attribute("TABS");
2562
 
                ScTextStream tgv(&tmp, QIODevice::ReadOnly);
2563
 
                for (int cxv = 0; cxv < obj->attribute("NUMTAB", "0").toInt(); cxv += 2)
2564
 
                {
2565
 
                        tgv >> xf;
2566
 
                        tgv >> xf2;
2567
 
                        tb.tabPosition = xf2;
2568
 
                        tb.tabType = static_cast<int>(xf);
2569
 
                        tb.tabFillChar = QChar();
2570
 
                        tbs.append(tb);
2571
 
                }
2572
 
                tmp = "";
2573
 
        }
2574
 
        else
2575
 
        {
2576
 
                IT = obj->firstChild();
2577
 
                while(!IT.isNull())
2578
 
                {
2579
 
                        QDomElement it = IT.toElement();
2580
 
                        if (it.tagName()=="Tabs")
2581
 
                        {
2582
 
                                ParagraphStyle::TabRecord tb;
2583
 
                                tb.tabPosition = ScCLocale::toDoubleC( it.attribute("Pos"));
2584
 
                                tb.tabType = it.attribute("Type").toInt();
2585
 
                                QString tbCh = "";
2586
 
                                tbCh = it.attribute("Fill","");
2587
 
                                if (tbCh.isEmpty())
2588
 
                                        tb.tabFillChar = QChar();
2589
 
                                else
2590
 
                                        tb.tabFillChar = tbCh[0];
2591
 
                                tbs.append(tb);
2592
 
                        }
2593
 
                        IT=IT.nextSibling();
2594
 
                }
2595
 
        }
2596
 
        if (tbs.count() > 0) {
2597
 
                ParagraphStyle newDefault(currItem->itemText.defaultStyle());
2598
 
                newDefault.setTabValues(tbs);
2599
 
                currItem->itemText.setDefaultStyle(newDefault);
2600
 
        }
2601
 
        
2602
 
        if ((obj->hasAttribute("NUMDASH")) && (obj->attribute("NUMDASH", "0").toInt() != 0))
2603
 
        {
2604
 
                tmp = obj->attribute("DASHS");
2605
 
                ScTextStream dgv(&tmp, QIODevice::ReadOnly);
2606
 
                currItem->DashValues.clear();
2607
 
                for (int cxv = 0; cxv < obj->attribute("NUMDASH", "0").toInt(); ++cxv)
2608
 
                {
2609
 
                        dgv >> xf;
2610
 
                        currItem->DashValues.append(xf);
2611
 
                }
2612
 
                tmp = "";
2613
 
        }
2614
 
        else
2615
 
                currItem->DashValues.clear();
2616
 
        tmp = "";
2617
 
        if (obj->hasAttribute("NUMPO"))
2618
 
        {
2619
 
                currItem->PoLine.resize(obj->attribute("NUMPO").toUInt());
2620
 
                tmp = obj->attribute("POCOOR");
2621
 
                ScTextStream fp(&tmp, QIODevice::ReadOnly);
2622
 
                for (uint cx=0; cx<obj->attribute("NUMPO").toUInt(); ++cx)
2623
 
                {
2624
 
                        fp >> xf;
2625
 
                        fp >> yf;
2626
 
                        currItem->PoLine.setPoint(cx, xf, yf);
2627
 
                }
2628
 
        }
2629
 
        else
2630
 
                currItem->PoLine.resize(0);
2631
 
        tmp = "";
2632
 
        if (obj->hasAttribute("NUMCO"))
2633
 
        {
2634
 
                currItem->ContourLine.resize(obj->attribute("NUMCO").toUInt());
2635
 
                tmp = obj->attribute("COCOOR");
2636
 
                ScTextStream fp(&tmp, QIODevice::ReadOnly);
2637
 
                for (uint cx=0; cx<obj->attribute("NUMCO").toUInt(); ++cx)
2638
 
                {
2639
 
                        fp >> xf;
2640
 
                        fp >> yf;
2641
 
                        currItem->ContourLine.setPoint(cx, xf, yf);
2642
 
                }
2643
 
        }
2644
 
        else
2645
 
                currItem->ContourLine = currItem->PoLine.copy();
2646
 
        if (!currItem->asLine())
2647
 
                currItem->Clip = FlattenPath(currItem->PoLine, currItem->Segments);
2648
 
        else
2649
 
        {
2650
 
                int ph = static_cast<int>(qMax(1.0, currItem->lineWidth() / 2.0));
2651
 
                currItem->Segments.clear();
2652
 
                currItem->PoLine.resize(0);
2653
 
                currItem->Clip.setPoints(4, -ph,-ph, static_cast<int>(currItem->width()+ph),-ph,
2654
 
                                  static_cast<int>(currItem->width()+ph),static_cast<int>(currItem->height()+ph),
2655
 
                                  -ph,static_cast<int>(currItem->height()+ph));
2656
 
                currItem->setHeight(1.0);
2657
 
        }
2658
 
        if (currItem->asImageFrame())
2659
 
                currItem->AdjustPictScale();
2660
 
        if (currItem->asPathText())
2661
 
        {
2662
 
                currItem->updatePolyClip();
2663
 
                currItem->Frame = true;
2664
 
        }
2665
 
        currItem->GrType = obj->attribute("GRTYP", "0").toInt();
2666
 
        QString GrColor;
2667
 
        QString GrColor2;
2668
 
        int GrShade = 0;
2669
 
        int GrShade2 = 0;
2670
 
        if (currItem->GrType != 0)
2671
 
        {
2672
 
                if (currItem->GrType == 8)
2673
 
                {
2674
 
                        currItem->setPattern(obj->attribute("pattern", ""));
2675
 
                        double patternScaleX = ScCLocale::toDoubleC( obj->attribute("pScaleX"), 100.0);
2676
 
                        double patternScaleY = ScCLocale::toDoubleC( obj->attribute("pScaleY"), 100.0);
2677
 
                        double patternOffsetX = ScCLocale::toDoubleC( obj->attribute("pOffsetX"), 0.0);
2678
 
                        double patternOffsetY = ScCLocale::toDoubleC( obj->attribute("pOffsetY"), 0.0);
2679
 
                        double patternRotation = ScCLocale::toDoubleC( obj->attribute("pRotation"), 0.0);
2680
 
                        currItem->setPatternTransform(patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation);
2681
 
                }
2682
 
                else
2683
 
                {
2684
 
                        currItem->GrStartX = ScCLocale::toDoubleC( obj->attribute("GRSTARTX"), 0.0);
2685
 
                        currItem->GrStartY = ScCLocale::toDoubleC( obj->attribute("GRSTARTY"), 0.0);
2686
 
                        currItem->GrEndX = ScCLocale::toDoubleC( obj->attribute("GRENDX"), 0.0);
2687
 
                        currItem->GrEndY = ScCLocale::toDoubleC( obj->attribute("GRENDY"), 0.0);
2688
 
                        GrColor = obj->attribute("GRCOLOR","");
2689
 
                        if (!GrColor.isEmpty())
2690
 
                        {
2691
 
                                GrColor2 = obj->attribute("GRCOLOR2","");
2692
 
                                GrShade = obj->attribute("GRSHADE", "100").toInt();
2693
 
                                GrShade2 = obj->attribute("GRSHADE2", "100").toInt();
2694
 
                        }
2695
 
                }
2696
 
        }
2697
 
        if ((currItem->GrType != 0) && (currItem->GrType != 8))
2698
 
        {
2699
 
                currItem->fill_gradient.clearStops();
2700
 
                if ((!GrColor.isEmpty()) && (!GrColor2.isEmpty()))
2701
 
                {
2702
 
                        if (currItem->GrType == 5)
2703
 
                        {
2704
 
                                if ((GrColor != CommonStrings::None) && (!GrColor.isEmpty()))
2705
 
                                        currItem->SetQColor(&tmpc, GrColor, GrShade);
2706
 
                                currItem->fill_gradient.addStop(tmpc, 0.0, 0.5, 1.0, GrColor, GrShade);
2707
 
                                if ((GrColor2 != CommonStrings::None) && (!GrColor2.isEmpty()))
2708
 
                                        currItem->SetQColor(&tmpc, GrColor2, GrShade2);
2709
 
                                currItem->fill_gradient.addStop(tmpc, 1.0, 0.5, 1.0, GrColor2, GrShade2);
2710
 
                        }
2711
 
                        else
2712
 
                        {
2713
 
                                if ((GrColor2 != CommonStrings::None) && (!GrColor2.isEmpty()))
2714
 
                                        currItem->SetQColor(&tmpc, GrColor2, GrShade2);
2715
 
                                currItem->fill_gradient.addStop(tmpc, 0.0, 0.5, 1.0, GrColor2, GrShade2);
2716
 
                                if ((GrColor != CommonStrings::None) && (!GrColor.isEmpty()))
2717
 
                                        currItem->SetQColor(&tmpc, GrColor, GrShade);
2718
 
                                currItem->fill_gradient.addStop(tmpc, 1.0, 0.5, 1.0, GrColor, GrShade);
2719
 
                        }
2720
 
                }
2721
 
//              currItem->updateGradientVectors();
2722
 
        }
2723
 
        UndoManager::instance()->setUndoEnabled(true);
2724
 
        //currItem->setRedrawBounding();
2725
 
        //currItem->OwnPage = view->OnPage(currItem);
2726
 
        return currItem;
2727
 
}
2728
 
 
2729
 
bool Scribus134Format::loadPage(const QString & fileName, int pageNumber, bool Mpage, QString renamedPageName)
2730
 
{
2731
 
//      qDebug() << QString("loading page %2 from file '%1' from 1.3.x plugin").arg(fileName).arg(pageNumber);
2732
 
        if (m_Doc==0 || m_AvailableFonts==0)
2733
 
        {
2734
 
                Q_ASSERT(m_Doc==0 || m_AvailableFonts==0);
2735
 
                return false;
2736
 
        }
2737
 
        ParagraphStyle vg;
2738
 
        struct ScribusDoc::BookMa bok;
2739
 
        PageItem *Neu;
2740
 
        Page* Apage = NULL;
2741
 
        groupRemap.clear();
2742
 
        itemRemap.clear();
2743
 
        itemNext.clear();
2744
 
        itemCount = 0;
2745
 
        itemRemapM.clear();
2746
 
        itemNextM.clear();
2747
 
        itemCountM = 0;
2748
 
        itemRemapF.clear();
2749
 
        itemNextF.clear();
2750
 
        itemCountF = 0;
2751
 
        QString tmp, tmpf, PgNam, Defont;
2752
 
        QMap<int,int> TableID;
2753
 
        QList<PageItem*> TableItems;
2754
 
        QMap<PageItem*, int> groupID;
2755
 
        int a, counter, baseobj;
2756
 
        double pageX = 0, pageY = 0;
2757
 
        bool newVersion = false;
2758
 
        bool VorLFound = false;
2759
 
        QMap<int,int> layerTrans;
2760
 
        int maxLayer = 0;
2761
 
        int maxLevel = 0;
2762
 
        layerTrans.clear();
2763
 
        uint layerCount=m_Doc->layerCount();
2764
 
        for (uint la2 = 0; la2 < layerCount; ++la2)
2765
 
        {
2766
 
                maxLayer = qMax(m_Doc->Layers[la2].LNr, maxLayer);
2767
 
                maxLevel = qMax(m_Doc->Layers[la2].Level, maxLevel);
2768
 
        }
2769
 
        DoVorl.clear();
2770
 
        DoVorl[0] = "0";
2771
 
        DoVorl[1] = "1";
2772
 
        DoVorl[2] = "2";
2773
 
        DoVorl[3] = "3";
2774
 
        DoVorl[4] = "4";
2775
 
        VorlC = 5;
2776
 
        QDomDocument docu("scridoc");
2777
 
        QString f(readSLA(fileName));
2778
 
        if (f.isEmpty())
2779
 
        {
2780
 
                setFileReadError();
2781
 
                return false;
2782
 
        }
2783
 
        QString errorMsg;
2784
 
        int errorLine, errorColumn;
2785
 
        if (!docu.setContent(f, &errorMsg, &errorLine, &errorColumn))
2786
 
        {
2787
 
                setDomParsingError(errorMsg, errorLine, errorColumn);
2788
 
                return false;
2789
 
        }
2790
 
        QString fileDir = QFileInfo(fileName).absolutePath();
2791
 
        QDomElement elem=docu.documentElement();
2792
 
        if (elem.tagName() != "SCRIBUSUTF8NEW")
2793
 
                return false;
2794
 
        if (elem.hasAttribute("Version"))
2795
 
                newVersion = true;
2796
 
        QDomNode DOC=elem.firstChild();
2797
 
        counter = m_Doc->Items->count();
2798
 
        baseobj = counter;
2799
 
//      PrefsManager* prefsManager=PrefsManager::instance();
2800
 
        while(!DOC.isNull())
2801
 
        {
2802
 
                QDomElement dc=DOC.toElement();
2803
 
                QDomNode PAGE=DOC.firstChild();
2804
 
                while(!PAGE.isNull())
2805
 
                {
2806
 
                        QDomElement pg=PAGE.toElement();
2807
 
                        if(pg.tagName()=="COLOR" && pg.attribute("NAME")!=CommonStrings::None)
2808
 
                        {
2809
 
                                ScColor lf;
2810
 
                                if (pg.hasAttribute("CMYK"))
2811
 
                                        lf.setNamedColor(pg.attribute("CMYK"));
2812
 
                                else
2813
 
                                        lf.fromQColor(QColor(pg.attribute("RGB")));
2814
 
                                if (pg.hasAttribute("Spot"))
2815
 
                                        lf.setSpotColor(static_cast<bool>(pg.attribute("Spot").toInt()));
2816
 
                                else
2817
 
                                        lf.setSpotColor(false);
2818
 
                                if (pg.hasAttribute("Register"))
2819
 
                                        lf.setRegistrationColor(static_cast<bool>(pg.attribute("Register").toInt()));
2820
 
                                else
2821
 
                                        lf.setRegistrationColor(false);
2822
 
                                QString name = pg.attribute("NAME");
2823
 
                                m_Doc->PageColors.insert((name.isEmpty()) ? lf.name() : name, lf);
2824
 
                        }
2825
 
                        if(pg.tagName()=="STYLE")
2826
 
                        {
2827
 
                                GetStyle(&pg, &vg, NULL, m_Doc, true);
2828
 
                                VorLFound = true;
2829
 
                        }
2830
 
                        if(pg.tagName()=="JAVA")
2831
 
                                m_Doc->JavaScripts[pg.attribute("NAME")] = pg.attribute("SCRIPT");
2832
 
                        if(pg.tagName()=="LAYERS")
2833
 
                        {
2834
 
                                int lnr   = pg.attribute("NUMMER").toInt();
2835
 
                                int level = pg.attribute("LEVEL").toInt();
2836
 
                                ScLayer la( pg.attribute("NAME"), level, lnr );
2837
 
                                la.isViewable   = pg.attribute("SICHTBAR").toInt();
2838
 
                                la.isPrintable  = pg.attribute("DRUCKEN").toInt();
2839
 
                                la.isEditable   = pg.attribute("EDIT", "1").toInt();
2840
 
                                la.flowControl  = pg.attribute("FLOW", "1").toInt();
2841
 
                                la.transparency = ScCLocale::toDoubleC( pg.attribute("TRANS"), 1.0);
2842
 
                                la.blendMode    = pg.attribute("BLEND", "0").toInt();
2843
 
                                la.outlineMode  = pg.attribute("OUTL", "0").toInt();
2844
 
                                if (pg.hasAttribute("LAYERC"))
2845
 
                                        la.markerColor =  QColor(pg.attribute("LAYERC","#000000"));
2846
 
                                const ScLayer* la2 = m_Doc->Layers.layerByName(la.Name);
2847
 
                                if (la2)
2848
 
                                        layerTrans.insert(la.LNr, la2->LNr);
2849
 
                                else
2850
 
                                {
2851
 
                                        maxLayer++;
2852
 
                                        maxLevel++;
2853
 
                                        layerTrans.insert(la.LNr, maxLayer);
2854
 
                                        la.LNr = maxLayer;
2855
 
                                        la.Level = maxLevel;
2856
 
                                        m_Doc->Layers.append(la);
2857
 
                                }
2858
 
                        }
2859
 
                        if(pg.tagName()=="MultiLine")
2860
 
                        {
2861
 
                                multiLine ml;
2862
 
                                QDomNode MuLn = PAGE.firstChild();
2863
 
                                while(!MuLn.isNull())
2864
 
                                {
2865
 
                                        QDomElement MuL = MuLn.toElement();
2866
 
                                        struct SingleLine sl;
2867
 
                                        sl.Color = MuL.attribute("Color");
2868
 
                                        sl.Dash = MuL.attribute("Dash").toInt();
2869
 
                                        sl.LineEnd = MuL.attribute("LineEnd").toInt();
2870
 
                                        sl.LineJoin = MuL.attribute("LineJoin").toInt();
2871
 
                                        sl.Shade = MuL.attribute("Shade").toInt();
2872
 
                                        sl.Width = ScCLocale::toDoubleC( MuL.attribute("Width"));
2873
 
                                        ml.shortcut = MuL.attribute("Shortcut");
2874
 
                                        ml.push_back(sl);
2875
 
                                        MuLn = MuLn.nextSibling();
2876
 
                                }
2877
 
                                QString Nam = pg.attribute("Name");
2878
 
                                QString Nam2 = Nam;
2879
 
                                int copyC = 1;
2880
 
                                QMap<QString,multiLine>::ConstIterator mlit = m_Doc->MLineStyles.find(Nam2);
2881
 
                                if (mlit != m_Doc->MLineStyles.end() && ml != mlit.value())
2882
 
                                {
2883
 
                                        while (m_Doc->MLineStyles.contains(Nam2))
2884
 
                                        {
2885
 
                                                Nam2 = QObject::tr("Copy #%1 of ").arg(copyC)+Nam;
2886
 
                                                copyC++;
2887
 
                                        }
2888
 
                                }
2889
 
                                m_Doc->MLineStyles.insert(Nam2, ml);
2890
 
                        }
2891
 
                        if(pg.tagName()=="Arrows")
2892
 
                        {
2893
 
                                struct ArrowDesc arrow;
2894
 
                                arrow.name = pg.attribute("Name");
2895
 
                                arrow.userArrow = true;
2896
 
                                double xa, ya;
2897
 
                                QString tmp = pg.attribute("Points");
2898
 
                                ScTextStream fp(&tmp, QIODevice::ReadOnly);
2899
 
                                for (uint cx = 0; cx < pg.attribute("NumPoints").toUInt(); ++cx)
2900
 
                                {
2901
 
                                        fp >> xa;
2902
 
                                        fp >> ya;
2903
 
                                        arrow.points.addPoint(xa, ya);
2904
 
                                }
2905
 
                                m_Doc->arrowStyles.append(arrow);
2906
 
                        }
2907
 
                        if (((pg.tagName()=="PAGE") || (pg.tagName()=="MASTERPAGE")) && (pg.attribute("NUM").toInt() == pageNumber))
2908
 
                        {
2909
 
                                a = m_Doc->currentPage()->pageNr();
2910
 
                                Apage = m_Doc->Pages->at(a);
2911
 
                                if ((pg.tagName()!="MASTERPAGE") && (Mpage))
2912
 
                                {
2913
 
                                        PAGE=PAGE.nextSibling();
2914
 
                                        continue;
2915
 
                                }
2916
 
                                if (Mpage)
2917
 
                                {
2918
 
                                        Apage->LeftPg=pg.attribute("LEFT", "0").toInt();
2919
 
                                        
2920
 
                                        if (!renamedPageName.isEmpty())
2921
 
                                                Apage->setPageName(renamedPageName);
2922
 
                                        else
2923
 
                                                Apage->setPageName(pg.attribute("NAM",""));
2924
 
                                }
2925
 
                                if (pg.hasAttribute("Size"))
2926
 
                                        Apage->m_pageSize = pg.attribute("Size");
2927
 
                                if (pg.hasAttribute("Orientation"))
2928
 
                                        Apage->PageOri = pg.attribute("Orientation").toInt();
2929
 
                                if (pg.hasAttribute("PAGEWIDTH"))
2930
 
                                        Apage->setWidth(ScCLocale::toDoubleC(pg.attribute("PAGEWIDTH")));
2931
 
                                else
2932
 
                                        Apage->setWidth(ScCLocale::toDoubleC(pg.attribute("PAGEWITH")));
2933
 
                                Apage->setHeight(ScCLocale::toDoubleC(pg.attribute("PAGEHEIGHT")));
2934
 
                                Apage->setInitialHeight(Apage->height());
2935
 
                                Apage->setInitialWidth(Apage->width());
2936
 
                                Apage->initialMargins.Top =  qMax(0.0, ScCLocale::toDoubleC(pg.attribute("BORDERTOP")));
2937
 
                                Apage->initialMargins.Bottom = qMax(0.0,  ScCLocale::toDoubleC(pg.attribute("BORDERBOTTOM")));
2938
 
                                Apage->initialMargins.Left =  qMax(0.0, ScCLocale::toDoubleC(pg.attribute("BORDERLEFT")));
2939
 
                                Apage->initialMargins.Right = qMax(0.0, ScCLocale::toDoubleC( pg.attribute("BORDERRIGHT")));
2940
 
                                Apage->marginPreset = pg.attribute("PRESET", "0").toInt();
2941
 
                                Apage->Margins.Top = Apage->initialMargins.Top;
2942
 
                                Apage->Margins.Bottom = Apage->initialMargins.Bottom;
2943
 
                                pageX = ScCLocale::toDoubleC( pg.attribute("PAGEXPOS"));
2944
 
                                pageY = ScCLocale::toDoubleC( pg.attribute("PAGEYPOS"));
2945
 
                                // guides reading
2946
 
                                tmp = "";
2947
 
                                Apage->guides.setHorizontalAutoGap(ScCLocale::toDoubleC(pg.attribute("AGhorizontalAutoGap"), 0.0));
2948
 
                                Apage->guides.setVerticalAutoGap(ScCLocale::toDoubleC(pg.attribute("AGverticalAutoGap"), 0.0));
2949
 
                                Apage->guides.setHorizontalAutoCount(pg.attribute("AGhorizontalAutoCount", "0").toInt());
2950
 
                                Apage->guides.setVerticalAutoCount(pg.attribute("AGverticalAutoCount", "0").toInt());
2951
 
                                Apage->guides.setHorizontalAutoRefer(pg.attribute("AGhorizontalAutoRefer", "0").toInt());
2952
 
                                Apage->guides.setVerticalAutoRefer(pg.attribute("AGverticalAutoRefer", "0").toInt());
2953
 
                                GuideManagerIO::readVerticalGuides(pg.attribute("VerticalGuides"),
2954
 
                                                                                                Apage,
2955
 
                                                                                                GuideManagerCore::Standard,
2956
 
                                                                                                pg.hasAttribute("NumVGuides"));
2957
 
                                GuideManagerIO::readHorizontalGuides(pg.attribute("HorizontalGuides"),
2958
 
                                                                                                Apage,
2959
 
                                                                                                GuideManagerCore::Standard,
2960
 
                                                                                                pg.hasAttribute("NumHGuides"));
2961
 
                                GuideManagerIO::readSelection(pg.attribute("AGSelection"), Apage);
2962
 
 
2963
 
                                Apage->guides.addHorizontals(Apage->guides.getAutoHorizontals(Apage), GuideManagerCore::Auto);
2964
 
                                Apage->guides.addVerticals(Apage->guides.getAutoVerticals(Apage), GuideManagerCore::Auto);
2965
 
                                
2966
 
                        }
2967
 
                        if ((pg.tagName()=="PAGEOBJECT") || (pg.tagName()=="MASTEROBJECT") || (pg.tagName()=="FRAMEOBJECT"))
2968
 
                        {
2969
 
                                if (Mpage)
2970
 
                                {
2971
 
                                        if (pg.tagName() != "MASTEROBJECT")
2972
 
                                        {
2973
 
                                                PAGE=PAGE.nextSibling();
2974
 
                                                continue;
2975
 
                                        }
2976
 
                                }
2977
 
                                else
2978
 
                                {
2979
 
                                        if (pg.tagName() == "MASTEROBJECT")
2980
 
                                        {
2981
 
                                                PAGE=PAGE.nextSibling();
2982
 
                                                continue;
2983
 
                                        }
2984
 
                                }
2985
 
                                if (pg.attribute("OwnPage").toInt() != pageNumber)
2986
 
                                {                       
2987
 
                                        if (pg.tagName()=="PAGEOBJECT")
2988
 
                                                itemRemap[itemCount++] = -1;
2989
 
                                        else if (pg.tagName()=="MASTEROBJECT")
2990
 
                                                itemRemapM[itemCountM++] = -1;
2991
 
                                }
2992
 
                                else
2993
 
//                              if (pg.attribute("OwnPage").toInt() == pageNumber)
2994
 
                                {
2995
 
                                        // first of linked chain?
2996
 
                                        if (pg.tagName()=="PAGEOBJECT")
2997
 
                                        {
2998
 
                                                itemRemap[itemCount++] = m_Doc->DocItems.count();
2999
 
                                                if (pg.attribute("NEXTITEM").toInt() != -1)
3000
 
                                                        itemNext[m_Doc->DocItems.count()] = pg.attribute("NEXTITEM").toInt();
3001
 
                                        }
3002
 
                                        else if (pg.tagName()=="MASTEROBJECT")
3003
 
                                        {
3004
 
                                                itemRemapM[itemCountM++] = m_Doc->MasterItems.count();
3005
 
                                                if (pg.attribute("NEXTITEM").toInt() != -1)
3006
 
                                                        itemNextM[m_Doc->MasterItems.count()] = pg.attribute("NEXTITEM").toInt();
3007
 
                                        }
3008
 
                                        /* not sure if we want that...
3009
 
                                        else if (pg.tagName()=="FRAMEOBJECT")
3010
 
                                        {
3011
 
                                                itemRemapF[itemCountF++] = m_Doc->FrameItems->count();
3012
 
                                                if (pg.attribute("NEXTITEM").toInt() != -1)
3013
 
                                                        itemNextF[m_Doc->FrameItems->count()] = pg.attribute("NEXTITEM").toInt();
3014
 
                                        }*/
3015
 
                                        //int docGc = m_Doc->GroupCounter;
3016
 
                                        /*m_Doc->GroupCounter = 0;*/
3017
 
                                        Neu = PasteItem(&pg, m_Doc, fileDir);
3018
 
                                        Neu->moveBy(-pageX + Apage->xOffset(), - pageY + Apage->yOffset());
3019
 
                                        Neu->setRedrawBounding();
3020
 
                                        //CB Must run onpage as we cant use pagetoload if the page has been renamed. 
3021
 
                                        //CB TODO Make this accept a page to place onto.
3022
 
                                        //Neu->OwnPage = m_Doc->OnPage(Neu);
3023
 
                                        //Neu->OwnPage = PageToLoad;
3024
 
                                        Neu->OwnPage = m_Doc->currentPageNumber();
3025
 
                                        if (pg.tagName()=="PAGEOBJECT")
3026
 
                                                Neu->OnMasterPage = "";
3027
 
                                        Neu->LayerNr = layerTrans.value(Neu->LayerNr, Neu->LayerNr);
3028
 
                                        /*m_Doc->GroupCounter = docGc;*/
3029
 
                                        tmpf = pg.attribute("IFONT", m_Doc->toolSettings.defFont);
3030
 
                                        m_AvailableFonts->findFont(tmpf, m_Doc);
3031
 
                                        QDomNode IT=pg.firstChild();
3032
 
                                        LastStyles * last = new LastStyles();
3033
 
                                        while(!IT.isNull())
3034
 
                                        {
3035
 
                                                QDomElement it=IT.toElement();
3036
 
                                                if (it.tagName()=="CSTOP")
3037
 
                                                {
3038
 
                                                        QString name = it.attribute("NAME");
3039
 
                                                        double ramp = ScCLocale::toDoubleC( it.attribute("RAMP"), 0.0);
3040
 
                                                        int shade = it.attribute("SHADE", "100").toInt();
3041
 
                                                        double opa = ScCLocale::toDoubleC( it.attribute("TRANS"), 1);
3042
 
                                                        Neu->fill_gradient.addStop(SetColor(m_Doc, name, shade), ramp, 0.5, opa, name, shade);
3043
 
                                                }
3044
 
                                                if (it.tagName()=="ITEXT")
3045
 
                                                        GetItemText(&it, m_Doc, Neu, last, true, VorLFound);
3046
 
                                                else if (it.tagName()=="para")
3047
 
                                                {
3048
 
                                                        Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::PARSEP);
3049
 
                                                        ParagraphStyle newStyle;
3050
 
                                                        PrefsManager* prefsManager=PrefsManager::instance();
3051
 
                                                        readParagraphStyle(newStyle, it, prefsManager->appPrefs.AvailFonts, m_Doc);
3052
 
                                                        Neu->itemText.setStyle(Neu->itemText.length()-1, newStyle);
3053
 
                                                        Neu->itemText.setCharStyle(Neu->itemText.length()-1, 1, last->Style);
3054
 
                                                }
3055
 
                                                else if (it.tagName() == "trail")
3056
 
                                                {
3057
 
                                                        ParagraphStyle newStyle;
3058
 
                                                        PrefsManager* prefsManager = PrefsManager::instance();
3059
 
                                                        readParagraphStyle(newStyle, it, prefsManager->appPrefs.AvailFonts, m_Doc);
3060
 
                                                        Neu->itemText.setStyle(Neu->itemText.length(), newStyle);
3061
 
                                                }
3062
 
                                                else if (it.tagName()=="tab")
3063
 
                                                {
3064
 
                                                        CharStyle newStyle;
3065
 
                                                        Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::TAB);
3066
 
                                                        GetCStyle(&it, m_Doc, newStyle);
3067
 
                                                        Neu->itemText.setCharStyle(Neu->itemText.length()-1, 1, newStyle);
3068
 
                                                        last->StyleStart = Neu->itemText.length()-1;
3069
 
                                                        last->Style = newStyle;
3070
 
                                                }
3071
 
                                                else if (it.tagName()=="breakline")
3072
 
                                                        Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::LINEBREAK);
3073
 
                                                else if (it.tagName()=="breakcol")
3074
 
                                                        Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::COLBREAK);
3075
 
                                                else if (it.tagName()=="breakframe")
3076
 
                                                        Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::FRAMEBREAK);
3077
 
                                                else if (it.tagName()=="nbhyphen")
3078
 
                                                        Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::NBHYPHEN);
3079
 
                                                else if (it.tagName()=="nbspace")
3080
 
                                                        Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::NBSPACE);
3081
 
                                                else if (it.tagName()=="zwnbspace")
3082
 
                                                        Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::ZWNBSPACE);
3083
 
                                                else if (it.tagName()=="zwspace")
3084
 
                                                        Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::ZWSPACE);
3085
 
                                                else if (it.tagName()=="var")
3086
 
                                                {
3087
 
                                                        if (it.attribute("name") == "pgno")
3088
 
                                                                Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::PAGENUMBER);
3089
 
                                                        else
3090
 
                                                                Neu->itemText.insertChars(Neu->itemText.length(), SpecialChars::PAGECOUNT);
3091
 
                                                        CharStyle newStyle;
3092
 
                                                        GetCStyle(&it, m_Doc, newStyle);
3093
 
                                                        Neu->itemText.setCharStyle(Neu->itemText.length()-1, 1, newStyle);
3094
 
                                                        last->StyleStart = Neu->itemText.length()-1;
3095
 
                                                        last->Style = newStyle;
3096
 
                                                }
3097
 
                                                
3098
 
                                                if(it.tagName()=="PageItemAttributes")
3099
 
                                                {
3100
 
                                                        QDomNode PIA = it.firstChild();
3101
 
                                                        ObjAttrVector pageItemAttributes;
3102
 
                                                        while(!PIA.isNull())
3103
 
                                                        {
3104
 
                                                                QDomElement itemAttr = PIA.toElement();
3105
 
                                                                if(itemAttr.tagName() == "ItemAttribute")
3106
 
                                                                {
3107
 
                                                                        ObjectAttribute objattr;
3108
 
                                                                        objattr.name=itemAttr.attribute("Name");
3109
 
                                                                        objattr.type=itemAttr.attribute("Type");
3110
 
                                                                        objattr.value=itemAttr.attribute("Value");
3111
 
                                                                        objattr.parameter=itemAttr.attribute("Parameter");
3112
 
                                                                        objattr.relationship=itemAttr.attribute("Relationship");
3113
 
                                                                        objattr.relationshipto=itemAttr.attribute("RelationshipTo");
3114
 
                                                                        objattr.autoaddto=itemAttr.attribute("AutoAddTo");
3115
 
                                                                        pageItemAttributes.append(objattr);
3116
 
                                                                }
3117
 
                                                                PIA = PIA.nextSibling();
3118
 
                                                        }
3119
 
                                                        Neu->setObjectAttributes(&pageItemAttributes);
3120
 
                                                }
3121
 
                                                IT=IT.nextSibling();
3122
 
                                        }
3123
 
                                        delete last;
3124
 
                                        if (Neu->asPathText())
3125
 
                                        {
3126
 
                                                Neu->updatePolyClip();
3127
 
                                                Neu->Frame = true;
3128
 
                                        }
3129
 
                                        if (Neu->fill_gradient.Stops() == 0)
3130
 
                                        {
3131
 
                                                const ScColor& col1 = m_Doc->PageColors[m_Doc->toolSettings.dBrush];
3132
 
                                                const ScColor& col2 = m_Doc->PageColors[m_Doc->toolSettings.dPen];
3133
 
                                                Neu->fill_gradient.addStop(ScColorEngine::getRGBColor(col1, m_Doc), 0.0, 0.5, 1.0, m_Doc->toolSettings.dBrush, 100);
3134
 
                                                Neu->fill_gradient.addStop(ScColorEngine::getRGBColor(col2, m_Doc), 1.0, 0.5, 1.0, m_Doc->toolSettings.dPen, 100);
3135
 
                                        }
3136
 
//                                      Neu->Language = ScMW->GetLang(pg.attribute("LANGUAGE", m_Doc->Language));
3137
 
//                                      Neu->Language = m_Doc->Language;
3138
 
                                        Neu->isAutoText = static_cast<bool>(pg.attribute("AUTOTEXT").toInt());
3139
 
                                        Neu->isEmbedded = static_cast<bool>(pg.attribute("isInline", "0").toInt());
3140
 
                                        Neu->gXpos = ScCLocale::toDoubleC( pg.attribute("gXpos"), 0.0);
3141
 
                                        Neu->gYpos = ScCLocale::toDoubleC( pg.attribute("gYpos"), 0.0);
3142
 
                                        QString defaultVal;
3143
 
                                        defaultVal.setNum(Neu->width());
3144
 
                                        Neu->gWidth = ScCLocale::toDoubleC( pg.attribute("gWidth",defaultVal));
3145
 
                                        defaultVal.setNum(Neu->height());
3146
 
                                        Neu->gHeight = ScCLocale::toDoubleC( pg.attribute("gHeight",defaultVal));
3147
 
                                        if (Neu->isAutoText)
3148
 
                                                m_Doc->LastAuto = Neu;
3149
 
                                        if (Neu->isTableItem)
3150
 
                                        {
3151
 
                                                TableItems.append(Neu);
3152
 
                                                TableID.insert(pg.attribute("OwnLINK", "0").toInt(), Neu->ItemNr);
3153
 
                                        }
3154
 
                                        Neu->isGroupControl = static_cast<bool>(pg.attribute("isGroupControl", "0").toInt());
3155
 
                                        if (Neu->isGroupControl)
3156
 
                                        {
3157
 
                                                int groupLastItem = pg.attribute("groupsLastItem", "0").toInt();
3158
 
                                                if ((Neu->Groups.count() == 0) || (groupLastItem <= 0)) // Sanity check for some broken files created using buggy development versions.
3159
 
                                                {
3160
 
                                                        Neu->isGroupControl = false;
3161
 
                                                        Neu->setFillColor("None");
3162
 
                                                }
3163
 
                                                else
3164
 
                                                        groupID.insert(Neu, groupLastItem + Neu->ItemNr);
3165
 
                                        }
3166
 
                                        if (pg.tagName()=="FRAMEOBJECT")
3167
 
                                        {
3168
 
                                                m_Doc->FrameItems.append(m_Doc->Items->takeAt(Neu->ItemNr));
3169
 
                                                Neu->ItemNr = m_Doc->FrameItems.count()-1;
3170
 
                                        }
3171
 
                                }
3172
 
                                counter++;
3173
 
                        }
3174
 
                        PAGE=PAGE.nextSibling();
3175
 
                }
3176
 
                PAGE=DOC.firstChild();
3177
 
                while(!PAGE.isNull())
3178
 
                {
3179
 
                        QDomElement pg=PAGE.toElement();
3180
 
                        if(pg.tagName()=="Bookmark")
3181
 
                        {
3182
 
                                int elem = pg.attribute("Element").toInt();
3183
 
                                if (elem < m_Doc->Items->count())
3184
 
                                {
3185
 
                                        bok.Title = pg.attribute("Title");
3186
 
                                        bok.Text = pg.attribute("Text");
3187
 
                                        bok.Aktion = pg.attribute("Aktion");
3188
 
                                        bok.ItemNr = pg.attribute("ItemNr").toInt();
3189
 
                                        bok.PageObject = m_Doc->Items->at(elem);
3190
 
                                        bok.First = pg.attribute("First").toInt();
3191
 
                                        bok.Last = pg.attribute("Last").toInt();
3192
 
                                        bok.Prev = pg.attribute("Prev").toInt();
3193
 
                                        bok.Next = pg.attribute("Next").toInt();
3194
 
                                        bok.Parent = pg.attribute("Parent").toInt();
3195
 
                                        m_Doc->BookMarks.append(bok);
3196
 
                                }
3197
 
                        }
3198
 
                        if(pg.tagName()=="Pattern")
3199
 
                        {
3200
 
                                ScPattern pat;
3201
 
                                QDomNode pa = PAGE.firstChild();
3202
 
                                uint ac = m_Doc->Items->count();
3203
 
                                bool savedAlignGrid = m_Doc->useRaster;
3204
 
                                bool savedAlignGuides = m_Doc->SnapGuides;
3205
 
                                m_Doc->useRaster = false;
3206
 
                                m_Doc->SnapGuides = false;
3207
 
                                while(!pa.isNull())
3208
 
                                {
3209
 
                                        QDomElement pite = pa.toElement();
3210
 
                                        m_Doc->setMasterPageMode(false);
3211
 
                                        // first of linked chain?
3212
 
                                        if (pg.tagName()=="PAGEOBJECT")
3213
 
                                        {
3214
 
                                                itemRemap[itemCount++] = m_Doc->DocItems.count();
3215
 
                                                if (pg.attribute("NEXTITEM").toInt() != -1)
3216
 
                                                        itemNext[m_Doc->DocItems.count()] = pg.attribute("NEXTITEM").toInt();
3217
 
                                        }
3218
 
                                        /* not sure if we want that...
3219
 
                                        else if (pg.tagName()=="MASTEROBJECT")
3220
 
                                        {
3221
 
                                                itemRemapM[itemCountM++] = m_Doc->MasterItems->count();
3222
 
                                                if (pg.attribute("NEXTITEM").toInt() != -1)
3223
 
                                                        itemNextM[m_Doc->MasterItems->count()] = pg.attribute("NEXTITEM").toInt();
3224
 
                                        }
3225
 
                                        else if (pg.tagName()=="FRAMEOBJECT")
3226
 
                                        {
3227
 
                                                        itemRemapF[itemCountF++] = m_Doc->FrameItems->count();
3228
 
                                                        if (pg.attribute("NEXTITEM").toInt() != -1)
3229
 
                                                                itemNextF[m_Doc->FrameItems->count()] = pg.attribute("NEXTITEM").toInt();
3230
 
                                        }*/
3231
 
                                        //int docGc = m_Doc->GroupCounter;
3232
 
                                        /*m_Doc->GroupCounter = 0;*/
3233
 
                                        Neu = PasteItem(&pite, m_Doc, fileDir);
3234
 
                                        Neu->setRedrawBounding();
3235
 
                                        Neu->OwnPage = pite.attribute("OwnPage").toInt();
3236
 
                                        Neu->OnMasterPage = "";
3237
 
                                        Neu->LayerNr = layerTrans.value(Neu->LayerNr, Neu->LayerNr);
3238
 
                                        /*m_Doc->GroupCounter = docGc;*/
3239
 
                                        tmpf = pite.attribute("IFONT", m_Doc->toolSettings.defFont);
3240
 
                                        m_AvailableFonts->findFont(tmpf, m_Doc);
3241
 
                                        QDomNode IT=pite.firstChild();
3242
 
                                        LastStyles * last = new LastStyles();
3243
 
                                        while(!IT.isNull())
3244
 
                                        {
3245
 
                                                QDomElement it=IT.toElement();
3246
 
                                                if (it.tagName()=="CSTOP")
3247
 
                                                {
3248
 
                                                        QString name = it.attribute("NAME");
3249
 
                                                        double ramp = ScCLocale::toDoubleC( it.attribute("RAMP"), 0.0);
3250
 
                                                        int shade = it.attribute("SHADE", "100").toInt();
3251
 
                                                        double opa = ScCLocale::toDoubleC( it.attribute("TRANS"), 1.0);
3252
 
                                                        Neu->fill_gradient.addStop(SetColor(m_Doc, name, shade), ramp, 0.5, opa, name, shade);
3253
 
                                                }
3254
 
                                                if (it.tagName()=="ITEXT")
3255
 
                                                        GetItemText(&it, m_Doc, Neu, last);
3256
 
                                                if(it.tagName()=="PageItemAttributes")
3257
 
                                                {
3258
 
                                                        QDomNode PIA = it.firstChild();
3259
 
                                                        ObjAttrVector pageItemAttributes;
3260
 
                                                        while(!PIA.isNull())
3261
 
                                                        {
3262
 
                                                                QDomElement itemAttr = PIA.toElement();
3263
 
                                                                if(itemAttr.tagName() == "ItemAttribute")
3264
 
                                                                {
3265
 
                                                                        ObjectAttribute objattr;
3266
 
                                                                        objattr.name=itemAttr.attribute("Name");
3267
 
                                                                        objattr.type=itemAttr.attribute("Type");
3268
 
                                                                        objattr.value=itemAttr.attribute("Value");
3269
 
                                                                        objattr.parameter=itemAttr.attribute("Parameter");
3270
 
                                                                        objattr.relationship=itemAttr.attribute("Relationship");
3271
 
                                                                        objattr.relationshipto=itemAttr.attribute("RelationshipTo");
3272
 
                                                                        objattr.autoaddto=itemAttr.attribute("AutoAddTo");
3273
 
                                                                        pageItemAttributes.append(objattr);
3274
 
                                                                }
3275
 
                                                                PIA = PIA.nextSibling();
3276
 
                                                        }
3277
 
                                                        Neu->setObjectAttributes(&pageItemAttributes);
3278
 
                                                }
3279
 
                                                IT=IT.nextSibling();
3280
 
                                        }
3281
 
                                        delete last;
3282
 
                                        if (Neu->asPathText())
3283
 
                                        {
3284
 
                                                Neu->updatePolyClip();
3285
 
                                                Neu->Frame = true;
3286
 
                                        }
3287
 
                                        if (Neu->fill_gradient.Stops() == 0)
3288
 
                                        {
3289
 
                                                const ScColor& col1 = m_Doc->PageColors[m_Doc->toolSettings.dBrush];
3290
 
                                                const ScColor& col2 = m_Doc->PageColors[m_Doc->toolSettings.dPen];
3291
 
                                                Neu->fill_gradient.addStop(ScColorEngine::getRGBColor(col1, m_Doc), 0.0, 0.5, 1.0, m_Doc->toolSettings.dBrush, 100);
3292
 
                                                Neu->fill_gradient.addStop(ScColorEngine::getRGBColor(col2, m_Doc), 1.0, 0.5, 1.0, m_Doc->toolSettings.dPen, 100);
3293
 
                                        }
3294
 
                                        Neu->isAutoText = static_cast<bool>(pite.attribute("AUTOTEXT").toInt());
3295
 
                                        Neu->isEmbedded = static_cast<bool>(pite.attribute("isInline", "0").toInt());
3296
 
                                        Neu->gXpos = ScCLocale::toDoubleC( pite.attribute("gXpos"), 0.0);
3297
 
                                        Neu->gYpos = ScCLocale::toDoubleC( pite.attribute("gYpos"), 0.0);
3298
 
                                        QString defaultVal;
3299
 
                                        defaultVal.setNum(Neu->width());
3300
 
                                        Neu->gWidth = ScCLocale::toDoubleC( pite.attribute("gWidth",defaultVal));
3301
 
                                        defaultVal.setNum(Neu->height());
3302
 
                                        Neu->gHeight = ScCLocale::toDoubleC( pite.attribute("gHeight",defaultVal));
3303
 
                                        if (Neu->isTableItem)
3304
 
                                        {
3305
 
                                                TableItems.append(Neu);
3306
 
                                                TableID.insert(pite.attribute("OwnLINK", "0").toInt(), Neu->ItemNr);
3307
 
                                        }
3308
 
                                        Neu->isGroupControl = static_cast<bool>(pite.attribute("isGroupControl", "0").toInt());
3309
 
                                        if (Neu->isGroupControl)
3310
 
                                        {
3311
 
                                                if (Neu->Groups.count() == 0) // Sanity check for some broken files created using buggy development versions.
3312
 
                                                {
3313
 
                                                        Neu->isGroupControl = false;
3314
 
                                                        Neu->setFillColor("None");
3315
 
                                                }
3316
 
                                                else
3317
 
                                                        groupID.insert(Neu, pite.attribute("groupsLastItem", "0").toInt()+Neu->ItemNr);
3318
 
                                        }
3319
 
                                        pa = pa.nextSibling();
3320
 
                                }
3321
 
                                m_Doc->useRaster = savedAlignGrid;
3322
 
                                m_Doc->SnapGuides = savedAlignGuides;
3323
 
                                pat.setDoc(m_Doc);
3324
 
                                pat.width  = ScCLocale::toDoubleC( pg.attribute("width"), 0.0);
3325
 
                                pat.height = ScCLocale::toDoubleC( pg.attribute("height"), 0.0);
3326
 
                                pat.scaleX = ScCLocale::toDoubleC( pg.attribute("scaleX"), 0.0);
3327
 
                                pat.scaleY = ScCLocale::toDoubleC( pg.attribute("scaleY"), 0.0);
3328
 
                                uint ae = m_Doc->Items->count();
3329
 
                                if (ae > ac)
3330
 
                                {
3331
 
                                        PageItem* currItem = m_Doc->Items->at(ac);
3332
 
                                        pat.pattern = currItem->DrawObj_toImage();
3333
 
                                        for (uint as = ac; as < ae; ++as)
3334
 
                                        {
3335
 
                                                Neu = m_Doc->Items->takeAt(ac);
3336
 
                                                Neu->ItemNr = pat.items.count();
3337
 
                                                pat.items.append(Neu);
3338
 
                                        }
3339
 
                                }
3340
 
                                QString patName = pg.attribute("Name");
3341
 
                                if (!patName.isEmpty())
3342
 
                                        m_Doc->docPatterns.insert(pg.attribute("Name"), pat);
3343
 
                        }
3344
 
                        PAGE=PAGE.nextSibling();
3345
 
                }
3346
 
                DOC=DOC.nextSibling();
3347
 
        }
3348
 
        if (TableItems.count() != 0)
3349
 
        {
3350
 
                for (int ttc = 0; ttc < TableItems.count(); ++ttc)
3351
 
                {
3352
 
                        PageItem* ta = TableItems.at(ttc);
3353
 
                        if (ta->TopLinkID != -1)
3354
 
                                ta->TopLink = m_Doc->Items->at(TableID[ta->TopLinkID]);
3355
 
                        else
3356
 
                                ta->TopLink = 0;
3357
 
                        if (ta->LeftLinkID != -1)
3358
 
                                ta->LeftLink = m_Doc->Items->at(TableID[ta->LeftLinkID]);
3359
 
                        else
3360
 
                                ta->LeftLink = 0;
3361
 
                        if (ta->RightLinkID != -1)
3362
 
                                ta->RightLink = m_Doc->Items->at(TableID[ta->RightLinkID]);
3363
 
                        else
3364
 
                                ta->RightLink = 0;
3365
 
                        if (ta->BottomLinkID != -1)
3366
 
                                ta->BottomLink = m_Doc->Items->at(TableID[ta->BottomLinkID]);
3367
 
                        else
3368
 
                                ta->BottomLink = 0;
3369
 
                }
3370
 
        }
3371
 
        if (groupID.count() != 0)
3372
 
        {
3373
 
                QMap<PageItem*, int>::Iterator it;
3374
 
                for (it = groupID.begin(); it != groupID.end(); ++it)
3375
 
                {
3376
 
                        it.key()->groupsLastItem = m_Doc->Items->at(it.value());
3377
 
                }
3378
 
        }
3379
 
        
3380
 
        // reestablish textframe links
3381
 
        if (itemNext.count() != 0 && !Mpage)
3382
 
        {
3383
 
                QMap<int,int>::Iterator lc;
3384
 
                for (lc = itemNext.begin(); lc != itemNext.end(); ++lc)
3385
 
                {
3386
 
                        if (itemRemap[lc.value()] >= 0)
3387
 
                        {
3388
 
                                if ((lc.key() < m_Doc->Items->count()) && (itemRemap[lc.value()] < m_Doc->Items->count()))
3389
 
                                {
3390
 
                                        PageItem * Its = m_Doc->DocItems.at(lc.key());
3391
 
                                        PageItem * Itn = m_Doc->DocItems.at(itemRemap[lc.value()]);
3392
 
                                        if (Itn->prevInChain() || Its->nextInChain()) 
3393
 
                                        {
3394
 
                                                qDebug() << "scribus134format: corruption in linked textframes detected";
3395
 
                                                continue;
3396
 
                                        }
3397
 
                                        Its->link(Itn);
3398
 
                                }
3399
 
                        }
3400
 
                }
3401
 
        }
3402
 
        else if (itemNextM.count() != 0 && Mpage)
3403
 
        {
3404
 
                QMap<int,int>::Iterator lc;
3405
 
                for (lc = itemNextM.begin(); lc != itemNextM.end(); ++lc)
3406
 
                {
3407
 
                        if (itemRemapM[lc.value()] >= 0)
3408
 
                        {
3409
 
                                if ((lc.key() < m_Doc->MasterItems.count()) && (itemRemapM[lc.value()] < m_Doc->MasterItems.count()))
3410
 
                                {
3411
 
                                        PageItem * Its = m_Doc->MasterItems.at(lc.key());
3412
 
                                        PageItem * Itn = m_Doc->MasterItems.at(itemRemapM[lc.value()]);
3413
 
                                        if (Itn->prevInChain() || Its->nextInChain())
3414
 
                                        {
3415
 
                                                qDebug() << "scribus134format: corruption in linked textframes detected";
3416
 
                                                continue;
3417
 
                                        }
3418
 
                                        Its->link(Itn);
3419
 
                                }
3420
 
                        }
3421
 
                }
3422
 
        }
3423
 
        
3424
 
        // reestablish first/lastAuto
3425
 
        m_Doc->FirstAuto = m_Doc->LastAuto;
3426
 
        if (m_Doc->LastAuto)
3427
 
        {
3428
 
                while (m_Doc->LastAuto->nextInChain())
3429
 
                        m_Doc->LastAuto = m_Doc->LastAuto->nextInChain();
3430
 
                while (m_Doc->FirstAuto->prevInChain())
3431
 
                        m_Doc->FirstAuto = m_Doc->FirstAuto->prevInChain();
3432
 
        }
3433
 
 
3434
 
        return true;
3435
 
}
3436
 
 
3437
 
void Scribus134Format::GetStyle(QDomElement *pg, ParagraphStyle *vg, StyleSet<ParagraphStyle> * tempStyles, ScribusDoc* doc, bool fl)
3438
 
{
3439
 
        bool fou(false);
3440
 
        QString tmV;
3441
 
        const StyleSet<ParagraphStyle> * docParagraphStyles = tempStyles? tempStyles : & doc->paragraphStyles();
3442
 
        PrefsManager* prefsManager=PrefsManager::instance();
3443
 
        readParagraphStyle(*vg, *pg, prefsManager->appPrefs.AvailFonts, doc);
3444
 
        for (int xx=0; xx<docParagraphStyles->count(); ++xx)
3445
 
        {
3446
 
                if (vg->name() == (*docParagraphStyles)[xx].name())
3447
 
                {
3448
 
                        if (vg->equiv((*docParagraphStyles)[xx]))
3449
 
                        {
3450
 
                                if (fl)
3451
 
                                {
3452
 
                                        DoVorl[VorlC] = tmV.setNum(xx);
3453
 
                                        VorlC++;
3454
 
                                }
3455
 
                                fou = true;
3456
 
                        }
3457
 
                        else
3458
 
                        {
3459
 
                                vg->setName("Copy of "+(*docParagraphStyles)[xx].name());
3460
 
                                fou = false;
3461
 
                        }
3462
 
                        break;
3463
 
                }
3464
 
        }
3465
 
        if (!fou)
3466
 
        {
3467
 
                for (int xx=0; xx< docParagraphStyles->count(); ++xx)
3468
 
                {
3469
 
                        if (vg->equiv((*docParagraphStyles)[xx]) && fl)
3470
 
                        {
3471
 
                                vg->setName((*docParagraphStyles)[xx].name());
3472
 
                                fou = true;
3473
 
//                              if (fl)
3474
 
                                {
3475
 
                                        DoVorl[VorlC] = tmV.setNum(xx);
3476
 
                                        VorlC++;
3477
 
                                }
3478
 
                                break;
3479
 
                        }
3480
 
                }
3481
 
        }
3482
 
        if (!fou)
3483
 
        {
3484
 
                if (tempStyles)
3485
 
                        tempStyles->create(*vg);
3486
 
                else
3487
 
                {
3488
 
                        StyleSet<ParagraphStyle> tmp;
3489
 
                        tmp.create(*vg);
3490
 
                        doc->redefineStyles(tmp, false);
3491
 
                }
3492
 
                if (fl)
3493
 
                {
3494
 
                        DoVorl[VorlC] = tmV.setNum(docParagraphStyles->count()-1);
3495
 
                        VorlC++;
3496
 
                }
3497
 
        }
3498
 
}
3499
 
 
3500
 
bool Scribus134Format::readStyles(const QString& fileName, ScribusDoc* doc, StyleSet<ParagraphStyle> &docParagraphStyles)
3501
 
{
3502
 
        ParagraphStyle pstyle;
3503
 
        QDomDocument docu("scridoc");
3504
 
        QString f (readSLA(fileName));
3505
 
        if (f.isEmpty())
3506
 
                return false;
3507
 
        if(!docu.setContent(f))
3508
 
                return false;
3509
 
        QDomElement elem=docu.documentElement();
3510
 
        if (elem.tagName() != "SCRIBUSUTF8NEW")
3511
 
                return false;
3512
 
        QDomNode DOC=elem.firstChild();
3513
 
        while(!DOC.isNull())
3514
 
        {
3515
 
                QDomElement dc=DOC.toElement();
3516
 
                QDomNode PAGE=DOC.firstChild();
3517
 
                while(!PAGE.isNull())
3518
 
                {
3519
 
                        QDomElement pg=PAGE.toElement();
3520
 
                        if(pg.tagName()=="STYLE")
3521
 
                        {
3522
 
                                pstyle.erase();
3523
 
                                GetStyle(&pg, &pstyle, &docParagraphStyles, doc, false);
3524
 
                        }
3525
 
                        PAGE=PAGE.nextSibling();
3526
 
                }
3527
 
                DOC=DOC.nextSibling();
3528
 
        }
3529
 
        return true;
3530
 
}
3531
 
 
3532
 
bool Scribus134Format::readCharStyles(const QString& fileName, ScribusDoc* doc, StyleSet<CharStyle> &docCharStyles)
3533
 
{
3534
 
        CharStyle cstyle;
3535
 
        QDomDocument docu("scridoc");
3536
 
        QString f (readSLA(fileName));
3537
 
        if (f.isEmpty())
3538
 
                return false;
3539
 
        if(!docu.setContent(f))
3540
 
                return false;
3541
 
        QDomElement elem=docu.documentElement();
3542
 
        if (elem.tagName() != "SCRIBUSUTF8NEW")
3543
 
                return false;
3544
 
        QDomNode DOC=elem.firstChild();
3545
 
        while(!DOC.isNull())
3546
 
        {
3547
 
                QDomElement dc=DOC.toElement();
3548
 
                QDomNode PAGE=DOC.firstChild();
3549
 
                while(!PAGE.isNull())
3550
 
                {
3551
 
                        QDomElement pg=PAGE.toElement();
3552
 
                        if(pg.tagName()=="CHARSTYLE")
3553
 
                        {
3554
 
                                cstyle.erase();
3555
 
                                GetCStyle(&pg, doc, cstyle);
3556
 
                                docCharStyles.create(cstyle);
3557
 
                        }
3558
 
                        PAGE=PAGE.nextSibling();
3559
 
                }
3560
 
                DOC=DOC.nextSibling();
3561
 
        }
3562
 
        return true;
3563
 
}
3564
 
 
3565
 
bool Scribus134Format::readLineStyles(const QString& fileName, QMap<QString,multiLine> *Sty)
3566
 
{
3567
 
        QDomDocument docu("scridoc");
3568
 
        QString f(readSLA(fileName));
3569
 
        if (f.isEmpty())
3570
 
                return false;
3571
 
        if(!docu.setContent(f))
3572
 
                return false;
3573
 
        QDomElement elem=docu.documentElement();
3574
 
        if (elem.tagName() != "SCRIBUSUTF8NEW")
3575
 
                return false;
3576
 
        QDomNode DOC=elem.firstChild();
3577
 
        while(!DOC.isNull())
3578
 
        {
3579
 
                QDomElement dc=DOC.toElement();
3580
 
                QDomNode PAGE=DOC.firstChild();
3581
 
                while(!PAGE.isNull())
3582
 
                {
3583
 
                        QDomElement pg=PAGE.toElement();
3584
 
                        if(pg.tagName()=="MultiLine")
3585
 
                        {
3586
 
                                multiLine ml;
3587
 
                                QDomNode MuLn = PAGE.firstChild();
3588
 
                                while(!MuLn.isNull())
3589
 
                                {
3590
 
                                        QDomElement MuL = MuLn.toElement();
3591
 
                                        struct SingleLine sl;
3592
 
                                        sl.Color = MuL.attribute("Color");
3593
 
                                        sl.Dash = MuL.attribute("Dash").toInt();
3594
 
                                        sl.LineEnd = MuL.attribute("LineEnd").toInt();
3595
 
                                        sl.LineJoin = MuL.attribute("LineJoin").toInt();
3596
 
                                        sl.Shade = MuL.attribute("Shade").toInt();
3597
 
                                        sl.Width = ScCLocale::toDoubleC( MuL.attribute("Width"));
3598
 
                                        ml.shortcut = MuL.attribute("Shortcut");
3599
 
                                        ml.push_back(sl);
3600
 
                                        MuLn = MuLn.nextSibling();
3601
 
                                }
3602
 
                                QString Nam = pg.attribute("Name");
3603
 
                                QString Nam2 = Nam;
3604
 
                                int copyC = 1;
3605
 
                                QMap<QString,multiLine>::ConstIterator mlit = Sty->find(Nam2);
3606
 
                                if (mlit != Sty->end() && ml != mlit.value())
3607
 
                                {
3608
 
                                        while (Sty->contains(Nam2))
3609
 
                                        {
3610
 
                                                Nam2 = tr("Copy #%1 of ").arg(copyC)+Nam;
3611
 
                                                copyC++;
3612
 
                                        }
3613
 
                                }
3614
 
                                Sty->insert(Nam2, ml);
3615
 
                        }
3616
 
                        PAGE=PAGE.nextSibling();
3617
 
                }
3618
 
                DOC=DOC.nextSibling();
3619
 
        }
3620
 
        return true;
3621
 
}
3622
 
 
3623
 
bool Scribus134Format::readColors(const QString& fileName, ColorList & colors)
3624
 
{
3625
 
        QString f(readSLA(fileName));
3626
 
        if (f.isEmpty())
3627
 
                return false;
3628
 
        QDomDocument docu("scridoc");
3629
 
        if(!docu.setContent(f))
3630
 
                return false;
3631
 
        colors.clear();
3632
 
        ScColor lf = ScColor();
3633
 
        QDomElement elem=docu.documentElement();
3634
 
        if (elem.tagName() != "SCRIBUSUTF8NEW")
3635
 
                return false;
3636
 
        QDomNode DOC=elem.firstChild();
3637
 
        while(!DOC.isNull())
3638
 
        {
3639
 
                QDomElement dc=DOC.toElement();
3640
 
                QDomNode PAGE=DOC.firstChild();
3641
 
                while(!PAGE.isNull())
3642
 
                {
3643
 
                        QDomElement pg=PAGE.toElement();
3644
 
                        // 10/25/2004 pv - None is "reserved" color. cannot be defined in any file...
3645
 
                        if(pg.tagName()=="COLOR" && pg.attribute("NAME")!=CommonStrings::None)
3646
 
                        {
3647
 
                                if (pg.hasAttribute("CMYK"))
3648
 
                                        lf.setNamedColor(pg.attribute("CMYK"));
3649
 
                                else
3650
 
                                        lf.fromQColor(QColor(pg.attribute("RGB")));
3651
 
                                if (pg.hasAttribute("Spot"))
3652
 
                                        lf.setSpotColor(static_cast<bool>(pg.attribute("Spot").toInt()));
3653
 
                                else
3654
 
                                        lf.setSpotColor(false);
3655
 
                                if (pg.hasAttribute("Register"))
3656
 
                                        lf.setRegistrationColor(static_cast<bool>(pg.attribute("Register").toInt()));
3657
 
                                else
3658
 
                                        lf.setRegistrationColor(false);
3659
 
                                QString name = pg.attribute("NAME");
3660
 
                                colors.insert((name.isEmpty()) ? lf.name() : name, lf);
3661
 
                        }
3662
 
                        PAGE=PAGE.nextSibling();
3663
 
                }
3664
 
                DOC=DOC.nextSibling();
3665
 
        }
3666
 
        return true;
3667
 
}
3668
 
 
3669
 
bool Scribus134Format::readPageCount(const QString& fileName, int *num1, int *num2, QStringList & masterPageNames)
3670
 
{
3671
 
        QString PgNam;
3672
 
        int counter = 0;
3673
 
        int counter2 = 0;
3674
 
        QDomDocument docu("scridoc");
3675
 
        QString f(readSLA(fileName));
3676
 
        if (f.isEmpty())
3677
 
                return false;
3678
 
        if(!docu.setContent(f))
3679
 
                return false;
3680
 
        QDomElement elem=docu.documentElement();
3681
 
        if (elem.tagName() != "SCRIBUSUTF8NEW")
3682
 
                return false;
3683
 
        QDomNode DOC=elem.firstChild();
3684
 
        while(!DOC.isNull())
3685
 
        {
3686
 
                QDomNode PAGE=DOC.firstChild();
3687
 
                while(!PAGE.isNull())
3688
 
                {
3689
 
                        QDomElement pg=PAGE.toElement();
3690
 
                        PgNam = pg.attribute("NAM", "");
3691
 
                        if(pg.tagName()=="PAGE")
3692
 
                                counter++;
3693
 
                        if(pg.tagName()=="MASTERPAGE")
3694
 
                        {
3695
 
                                counter2++;
3696
 
                                masterPageNames.append(PgNam);
3697
 
                        }
3698
 
                        PAGE=PAGE.nextSibling();
3699
 
                }
3700
 
                DOC=DOC.nextSibling();
3701
 
        }
3702
 
        *num1 = counter;
3703
 
        *num2 = counter2;
3704
 
        return true;
3705
 
}
3706
 
 
3707
 
 
3708
 
 
3709
 
 
3710