Back to index

scribus-ng  1.3.4.dfsg+svn20071115
scribus13format.cpp
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 #include "scribus13format.h"
00008 #include "scribus13format.moc"
00009 #include "scribus13formatimpl.h"
00010 
00011 #include "../../formatidlist.h"
00012 #include "commonstrings.h"
00013 #include "missing.h"
00014 #include "prefsmanager.h"
00015 #include "scconfig.h"
00016 #include "scribusdoc.h"
00017 #include "scribusview.h"
00018 #include "sccolorengine.h"
00019 
00020 #include "units.h"
00021 #include "util.h"
00022 #include "colorutil.h"
00023 #include "scgzfile.h"
00024 #include <qcursor.h>
00025 #include <qfileinfo.h>
00026 #include <qvaluelist.h>
00027 
00028 
00029 // See scplugin.h and pluginmanager.{cpp,h} for detail on what these methods
00030 // do. That documentatation is not duplicated here.
00031 // Please don't implement the functionality of your plugin here; do that
00032 // in scribus13formatimpl.h and scribus13formatimpl.cpp .
00033 
00034 Scribus13Format::Scribus13Format() :
00035        LoadSavePlugin()
00036 {
00037        // Set action info in languageChange, so we only have to do
00038        // it in one place. This includes registering file formats.
00039        languageChange();
00040 }
00041 
00042 Scribus13Format::~Scribus13Format()
00043 {
00044        unregisterAll();
00045 };
00046 
00047 void Scribus13Format::languageChange()
00048 {
00049        //(Re)register file formats.
00050        unregisterAll();
00051        registerFormats();
00052 }
00053 
00054 const QString Scribus13Format::fullTrName() const
00055 {
00056        return QObject::tr("Scribus 1.3.0->1.3.3.x Support");
00057 }
00058 
00059 const ScActionPlugin::AboutData* Scribus13Format::getAboutData() const
00060 {
00061        AboutData* about = new AboutData;
00062        Q_CHECK_PTR(about);
00063        return about;
00064 }
00065 
00066 void Scribus13Format::deleteAboutData(const AboutData* about) const
00067 {
00068        Q_ASSERT(about);
00069        delete about;
00070 }
00071 
00072 void Scribus13Format::registerFormats()
00073 {
00074        FileFormat fmt(this);
00075        fmt.trName = tr("Scribus 1.3.0->1.3.3.7 Document");
00076        fmt.formatId = FORMATID_SLA13XIMPORT;
00077        fmt.load = true;
00078        fmt.save = false; //Only support 134format saving in 134cvs
00079        fmt.filter = fmt.trName + " (*.sla *.SLA *.sla.gz *.SLA.GZ *.scd *.SCD *.scd.gz *.SCD.GZ)";
00080        fmt.nameMatch = QRegExp("\\.(sla|scd)(\\.gz)?", false);
00081        fmt.mimeTypes = QStringList();
00082        fmt.mimeTypes.append("application/x-scribus");
00083        fmt.priority = 64;
00084        registerFormat(fmt);
00085 }
00086 
00087 bool Scribus13Format::fileSupported(QIODevice* /* file */, const QString & fileName) const
00088 {
00089        QCString docBytes("");
00090        if(fileName.right(2) == "gz")
00091        {
00092               ScGzFile gzf(fileName);
00093               if (!gzf.read(4096))
00094               {
00095                      // FIXME: Needs better error return
00096                      return false;
00097               }
00098               docBytes = gzf.data();
00099        }
00100        else
00101        {
00102               // Not gzip encoded, just load it
00103               loadRawText(fileName, docBytes);
00104        }
00105        if (docBytes.left(16) == "<SCRIBUSUTF8NEW " && !docBytes.left(35).contains("Version=\"1.3.4"))
00106               return true;
00107        return false;
00108 }
00109 
00110 QString Scribus13Format::readSLA(const QString & fileName)
00111 {
00112        QCString docBytes("");
00113        if(fileName.right(2) == "gz")
00114        {
00115               ScGzFile gzf(fileName);
00116               if (!gzf.read())
00117               {
00118                      // FIXME: Needs better error return
00119                      return false;
00120               }
00121               docBytes = gzf.data();
00122        }
00123        else
00124        {
00125               // Not gzip encoded, just load it
00126               loadRawText(fileName, docBytes);
00127        }
00128        QString docText("");
00129        if (docBytes.left(16) == "<SCRIBUSUTF8NEW " && !docBytes.left(35).contains("Version=\"1.3.4"))
00130               docText = QString::fromUtf8(docBytes);
00131        else
00132               return QString::null;
00133        if (docText.endsWith(QChar(10)) || docText.endsWith(QChar(13)))
00134               docText.truncate(docText.length()-1);
00135        return docText;
00136 }
00137 
00138 void Scribus13Format::getReplacedFontData(bool & getNewReplacement, QMap<QString,QString> &getReplacedFonts, QValueList<ScFace> &getDummyScFaces)
00139 {
00140        getNewReplacement=newReplacement;
00141        getReplacedFonts=ReplacedFonts;
00142 //     getDummyScFaces=dummyScFaces;
00143 }
00144 
00145 bool Scribus13Format::loadFile(const QString & fileName, const FileFormat & /* fmt */, int /* flags */, int /* index */)
00146 {
00147        if (m_Doc==0 || m_AvailableFonts==0)
00148        {
00149               Q_ASSERT(m_Doc==0 || m_AvailableFonts==0);
00150               return false;
00151        }
00152        ReplacedFonts.clear();
00153        newReplacement = false;
00154        ParagraphStyle vg;
00155        struct Layer la;
00156        struct ScribusDoc::BookMa bok;
00157        int counter;//, Pgc;
00158        //bool AtFl;
00159        bool newVersion = false;
00160        QString tmp, tmpf, tmp2, tmp3, tmp4, PgNam, Defont, tmf;
00161        QFont fo;
00162        QMap<int,int> TableID;
00163        QPtrList<PageItem> TableItems;
00164        QMap<int,int> TableIDM;
00165        QPtrList<PageItem> TableItemsM;
00166        QMap<int,int> TableIDF;
00167        QPtrList<PageItem> TableItemsF;
00168        int a;
00169        PageItem *Neu;
00170        Page* Apage;
00171        itemRemap.clear();
00172        itemNext.clear();
00173        itemCount = 0;
00174        DoVorl.clear();
00175        DoVorl[0] = "";
00176        DoVorl[1] = "";
00177        DoVorl[2] = "";
00178        DoVorl[3] = "";
00179        DoVorl[4] = "";
00180        VorlC = 5;
00181        QDomDocument docu("scridoc");
00182        QString f(readSLA(fileName));
00183        if (f.isEmpty())
00184               return false;
00185        /* 2004/10/02 - petr vanek - bug #1092 - missing <PAGE> crash Scribus. The check constraint moved into IsScribus()
00186        FIXME: I've add test on containig tag PAGE but returning false freezes S. in scribus.cpp need some hack too...  */
00187        if (!docu.setContent(f))
00188               return false;
00189        m_Doc->PageColors.clear();
00190        m_Doc->Layers.clear();
00191        int layerToSetActive=0;
00192        ScColor lf = ScColor();
00193        QDomElement elem=docu.documentElement();
00194        if (elem.tagName() != "SCRIBUSUTF8NEW")
00195               return false;
00196        if (elem.hasAttribute("Version"))
00197               newVersion = true;
00198        QDomNode DOC=elem.firstChild();
00199        if (m_mwProgressBar!=0)
00200        {
00201               m_mwProgressBar->setTotalSteps(DOC.childNodes().count());
00202               m_mwProgressBar->setProgress(0);
00203        }
00204        int ObCount = 0;
00205        TableItems.clear();
00206        TableID.clear();
00207        TableItemsM.clear();
00208        TableIDM.clear();
00209        TableItemsF.clear();
00210        TableIDF.clear();
00211        PrefsManager* prefsManager=PrefsManager::instance();
00212        while(!DOC.isNull())
00213        {
00214               QDomElement dc=DOC.toElement();
00215        /*
00216        * Attribute von DOCUMENT auslesen
00217        */
00218               //CB Add this in to set this in the file in memory. Its saved, why not load it.
00219               //Will of course be replaced by per page settings although we still probably need a document default
00220               m_Doc->m_pageSize = dc.attribute("PAGESIZE");
00221               m_Doc->PageOri = dc.attribute("ORIENTATION", "0").toInt();
00222               m_Doc->FirstPnum = dc.attribute("FIRSTNUM", "1").toInt();
00223               m_Doc->currentPageLayout=dc.attribute("BOOK", "0").toInt();
00224               int fp;
00225               if (m_Doc->currentPageLayout == 0)
00226                      fp = 0;
00227               else
00228               {
00229                      if (dc.attribute("FIRSTLEFT", "0").toInt() == 1)
00230                             fp = 0;
00231                      else
00232                             fp = 1;
00233               }
00234               if (DOC.namedItem("PageSets").isNull())
00235               {
00236                      m_Doc->pageSets[m_Doc->currentPageLayout].FirstPage = fp;
00237                      m_Doc->pageSets[m_Doc->currentPageLayout].GapHorizontal = dc.attribute("GapHorizontal", "0").toDouble();
00238                      m_Doc->pageSets[m_Doc->currentPageLayout].GapVertical = 0.0;
00239                      m_Doc->pageSets[m_Doc->currentPageLayout].GapBelow = dc.attribute("GapVertical", "40").toDouble();
00240               }
00241               m_Doc->setUsesAutomaticTextFrames(dc.attribute("AUTOTEXT").toInt());
00242               m_Doc->PageSp=dc.attribute("AUTOSPALTEN").toInt();
00243               m_Doc->PageSpa=dc.attribute("ABSTSPALTEN").toDouble();
00244               m_Doc->setUnitIndex(dc.attribute("UNITS", "0").toInt());
00245               m_Doc->toolSettings.defSize=qRound(dc.attribute("DSIZE").toDouble() * 10);
00246               Defont=dc.attribute("DFONT");
00247               //findFont will use that if it doesnt find the font:
00248               m_Doc->toolSettings.defFont = prefsManager->appPrefs.toolSettings.defFont;
00249               m_AvailableFonts->findFont(Defont, m_Doc);
00250               m_Doc->toolSettings.defFont = Defont;
00251               m_Doc->toolSettings.dCols=dc.attribute("DCOL", "1").toInt();
00252               m_Doc->toolSettings.dGap=dc.attribute("DGAP", "0.0").toDouble();
00253               m_Doc->documentInfo.setAuthor(dc.attribute("AUTHOR"));
00254               m_Doc->documentInfo.setComments(dc.attribute("COMMENTS"));
00255               m_Doc->documentInfo.setKeywords(dc.attribute("KEYWORDS",""));
00256               m_Doc->documentInfo.setTitle(dc.attribute("TITLE"));
00257               m_Doc->documentInfo.setPublisher(dc.attribute("PUBLISHER", ""));
00258               m_Doc->documentInfo.setDate(dc.attribute("DOCDATE", ""));
00259               m_Doc->documentInfo.setType(dc.attribute("DOCTYPE", ""));
00260               m_Doc->documentInfo.setFormat(dc.attribute("DOCFORMAT", ""));
00261               m_Doc->documentInfo.setIdent(dc.attribute("DOCIDENT", ""));
00262               m_Doc->documentInfo.setSource(dc.attribute("DOCSOURCE", ""));
00263               m_Doc->documentInfo.setLangInfo(dc.attribute("DOCLANGINFO", ""));
00264               m_Doc->documentInfo.setRelation(dc.attribute("DOCRELATION", ""));
00265               m_Doc->documentInfo.setCover(dc.attribute("DOCCOVER", ""));
00266               m_Doc->documentInfo.setRights(dc.attribute("DOCRIGHTS", ""));
00267               m_Doc->documentInfo.setContrib(dc.attribute("DOCCONTRIB", ""));
00268               m_Doc->typographicSettings.valueSuperScript = dc.attribute("VHOCH").toInt();
00269               m_Doc->typographicSettings.scalingSuperScript = dc.attribute("VHOCHSC").toInt();
00270               m_Doc->typographicSettings.valueSubScript = dc.attribute("VTIEF").toInt();
00271               m_Doc->typographicSettings.scalingSubScript = dc.attribute("VTIEFSC").toInt();
00272               m_Doc->typographicSettings.valueSmallCaps = dc.attribute("VKAPIT").toInt();
00273               m_Doc->typographicSettings.valueBaseGrid = dc.attribute("BASEGRID", "12").toDouble();
00274               m_Doc->typographicSettings.offsetBaseGrid = dc.attribute("BASEO", "0").toDouble();
00275               m_Doc->typographicSettings.autoLineSpacing = dc.attribute("AUTOL", "20").toInt();
00276               m_Doc->typographicSettings.valueUnderlinePos = dc.attribute("UnderlinePos", "-1").toInt();
00277               m_Doc->typographicSettings.valueUnderlineWidth = dc.attribute("UnderlineWidth", "-1").toInt();
00278               m_Doc->typographicSettings.valueStrikeThruPos = dc.attribute("StrikeThruPos", "-1").toInt();
00279               m_Doc->typographicSettings.valueStrikeThruWidth = dc.attribute("StrikeThruWidth", "-1").toInt();
00280               m_Doc->GroupCounter=dc.attribute("GROUPC", "1").toInt();
00281               //m_Doc->HasCMS = static_cast<bool>(dc.attribute("HCMS", "0").toInt());
00282               m_Doc->CMSSettings.SoftProofOn = static_cast<bool>(dc.attribute("DPSo", "0").toInt());
00283               m_Doc->CMSSettings.SoftProofFullOn = static_cast<bool>(dc.attribute("DPSFo", "0").toInt());
00284               m_Doc->CMSSettings.CMSinUse = static_cast<bool>(dc.attribute("DPuse", "0").toInt());
00285               m_Doc->CMSSettings.GamutCheck = static_cast<bool>(dc.attribute("DPgam", "0").toInt());
00286               m_Doc->CMSSettings.BlackPoint = static_cast<bool>(dc.attribute("DPbla", "1").toInt());
00287               m_Doc->CMSSettings.DefaultMonitorProfile = dc.attribute("DPMo","");
00288               m_Doc->CMSSettings.DefaultPrinterProfile = dc.attribute("DPPr","");
00289               m_Doc->CMSSettings.DefaultImageRGBProfile = dc.attribute("DPIn","");
00290               m_Doc->CMSSettings.DefaultImageCMYKProfile = dc.attribute("DPInCMYK","");
00291               m_Doc->CMSSettings.DefaultSolidColorRGBProfile = dc.attribute("DPIn2","");
00292               if (dc.hasAttribute("DPIn3"))
00293                      m_Doc->CMSSettings.DefaultSolidColorCMYKProfile = dc.attribute("DPIn3","");
00294               else
00295                      m_Doc->CMSSettings.DefaultSolidColorCMYKProfile = dc.attribute("DPPr","");
00296               //m_Doc->CMSSettings.DefaultIntentPrinter = dc.attribute("DIPr", "0").toInt();
00297               //m_Doc->CMSSettings.DefaultIntentMonitor = dc.attribute("DIMo", "1").toInt();
00298               m_Doc->CMSSettings.DefaultIntentColors = dc.attribute("DISc", "1").toInt();
00299               m_Doc->CMSSettings.DefaultIntentImages = dc.attribute("DIIm", "0").toInt();
00300               layerToSetActive=dc.attribute("ALAYER", "0").toInt();
00301               m_Doc->Language = dc.attribute("LANGUAGE", "");
00302               m_Doc->MinWordLen = dc.attribute("MINWORDLEN", "3").toInt();
00303               m_Doc->HyCount = dc.attribute("HYCOUNT", "2").toInt();
00304               if (dc.hasAttribute("PAGEWIDTH"))
00305                      m_Doc->pageWidth=dc.attribute("PAGEWIDTH").toDouble();
00306               else
00307                      m_Doc->pageWidth=dc.attribute("PAGEWITH").toDouble();
00308               m_Doc->pageHeight=dc.attribute("PAGEHEIGHT").toDouble();
00309               m_Doc->pageMargins.Left=QMAX(0.0, dc.attribute("BORDERLEFT").toDouble());
00310               m_Doc->pageMargins.Right=QMAX(0.0, dc.attribute("BORDERRIGHT").toDouble());
00311               m_Doc->pageMargins.Top=QMAX(0.0, dc.attribute("BORDERTOP").toDouble());
00312               m_Doc->pageMargins.Bottom=QMAX(0.0, dc.attribute("BORDERBOTTOM").toDouble());
00313               m_Doc->Automatic = static_cast<bool>(dc.attribute("AUTOMATIC", "1").toInt());
00314               m_Doc->AutoCheck = static_cast<bool>(dc.attribute("AUTOCHECK", "0").toInt());
00315               m_Doc->GuideLock = static_cast<bool>(dc.attribute("GUIDELOCK", "0").toInt());
00316               m_Doc->guidesSettings.minorGrid = dc.attribute("MINGRID", tmp.setNum(prefsManager->appPrefs.guidesSettings.minorGrid)).toDouble();
00317               m_Doc->guidesSettings.majorGrid = dc.attribute("MAJGRID", tmp.setNum(prefsManager->appPrefs.guidesSettings.majorGrid)).toDouble();
00318               m_Doc->guidesSettings.gridShown = static_cast<bool>(dc.attribute("SHOWGRID", "0").toInt());
00319               m_Doc->guidesSettings.guidesShown = static_cast<bool>(dc.attribute("SHOWGUIDES", "1").toInt());
00320               m_Doc->guidesSettings.colBordersShown = static_cast<bool>(dc.attribute("showcolborders", "0").toInt());
00321               m_Doc->guidesSettings.framesShown = static_cast<bool>(dc.attribute("SHOWFRAME", "1").toInt());
00322               m_Doc->guidesSettings.layerMarkersShown = static_cast<bool>(dc.attribute("SHOWLAYERM", "0").toInt());
00323               m_Doc->guidesSettings.marginsShown = static_cast<bool>(dc.attribute("SHOWMARGIN", "1").toInt());
00324               m_Doc->guidesSettings.baseShown = static_cast<bool>(dc.attribute("SHOWBASE", "0").toInt());
00325               m_Doc->guidesSettings.showPic = static_cast<bool>(dc.attribute("SHOWPICT", "1").toInt());
00326               m_Doc->guidesSettings.linkShown = static_cast<bool>(dc.attribute("SHOWLINK", "0").toInt());
00327               m_Doc->guidesSettings.showControls = static_cast<bool>(dc.attribute("SHOWControl", "0").toInt());
00328               m_Doc->guidesSettings.rulerMode = static_cast<bool>(dc.attribute("rulerMode", "1").toInt());
00329               m_Doc->guidesSettings.rulersShown = static_cast<bool>(dc.attribute("showrulers", "1").toInt());
00330               m_Doc->rulerXoffset = dc.attribute("rulerXoffset", "0").toDouble();
00331               m_Doc->rulerYoffset =dc.attribute("rulerYoffset", "0").toDouble();
00332               m_Doc->SnapGuides = static_cast<bool>(dc.attribute("SnapToGuides", "0").toInt());
00333               m_Doc->useRaster = static_cast<bool>(dc.attribute("SnapToGrid", "0").toInt());
00334               m_Doc->toolSettings.polyC = dc.attribute("POLYC", "4").toInt();
00335               m_Doc->toolSettings.polyF = dc.attribute("POLYF", "0.5").toDouble();
00336               m_Doc->toolSettings.polyR = dc.attribute("POLYR", "0").toDouble();
00337               m_Doc->toolSettings.polyFd = dc.attribute("POLYFD", "0").toInt();
00338               m_Doc->toolSettings.polyS = static_cast<bool>(dc.attribute("POLYS", "0").toInt());
00339               m_Doc->AutoSave = static_cast<bool>(dc.attribute("AutoSave", "0").toInt());
00340               m_Doc->AutoSaveTime = dc.attribute("AutoSaveTime", "600000").toInt();
00341               m_Doc->scratch.Bottom = dc.attribute("ScratchBottom", "20").toDouble();
00342               // FIXME A typo in early 1.3cvs (MAR 05) means we must support loading of
00343               // FIXME 'ScatchLeft' for a while too. This can be removed in a few months.
00344               if (dc.hasAttribute("ScatchLeft"))
00345                      m_Doc->scratch.Left = dc.attribute("ScatchLeft", "100").toDouble();
00346               else
00347                      m_Doc->scratch.Left = dc.attribute("ScratchLeft", "100").toDouble();
00348               m_Doc->scratch.Right = dc.attribute("ScratchRight", "100").toDouble();
00349               m_Doc->scratch.Top = dc.attribute("ScratchTop", "20").toDouble();
00350               m_Doc->toolSettings.dStartArrow = dc.attribute("StartArrow", "0").toInt();
00351               m_Doc->toolSettings.dEndArrow = dc.attribute("EndArrow", "0").toInt();
00352               m_Doc->toolSettings.scaleX = dc.attribute("PICTSCX", "1").toDouble();
00353               m_Doc->toolSettings.scaleY = dc.attribute("PICTSCY", "1").toDouble();
00354               m_Doc->toolSettings.scaleType = static_cast<bool>(dc.attribute("PSCALE", "1").toInt());
00355               m_Doc->toolSettings.aspectRatio = static_cast<bool>(dc.attribute("PASPECT", "0").toInt());
00356               m_Doc->toolSettings.lowResType = dc.attribute("HalfRes", "1").toInt();
00357               m_Doc->toolSettings.useEmbeddedPath = static_cast<bool>(dc.attribute("EmbeddedPath", "0").toInt());
00358               if (dc.hasAttribute("PEN"))
00359                      m_Doc->toolSettings.dPen = dc.attribute("PEN");
00360               if (dc.hasAttribute("BRUSH"))
00361                      m_Doc->toolSettings.dBrush = dc.attribute("BRUSH");
00362               if (dc.hasAttribute("PENLINE"))
00363                      m_Doc->toolSettings.dPenLine = dc.attribute("PENLINE");
00364               if (dc.hasAttribute("PENTEXT"))
00365                      m_Doc->toolSettings.dPenText = dc.attribute("PENTEXT");
00366               if (dc.hasAttribute("StrokeText"))
00367                      m_Doc->toolSettings.dStrokeText = dc.attribute("StrokeText");
00368               m_Doc->toolSettings.dTextBackGround = dc.attribute("TextBackGround", CommonStrings::None);
00369               m_Doc->toolSettings.dTextLineColor = dc.attribute("TextLineColor", CommonStrings::None);
00370               m_Doc->toolSettings.dTextBackGroundShade = dc.attribute("TextBackGroundShade", "100").toInt();
00371               m_Doc->toolSettings.dTextLineShade = dc.attribute("TextLineShade", "100").toInt();
00372               m_Doc->toolSettings.dTextPenShade = dc.attribute("TextPenShade", "100").toInt();
00373               m_Doc->toolSettings.dTextStrokeShade = dc.attribute("TextStrokeShade", "100").toInt();
00374               m_Doc->toolSettings.dLineArt = static_cast<Qt::PenStyle>(dc.attribute("STIL").toInt());
00375               m_Doc->toolSettings.dLstyleLine = static_cast<Qt::PenStyle>(dc.attribute("STILLINE").toInt());
00376               m_Doc->toolSettings.dWidth = dc.attribute("WIDTH", "1").toDouble();
00377               m_Doc->toolSettings.dWidthLine = dc.attribute("WIDTHLINE", "1").toDouble();
00378               m_Doc->toolSettings.dShade2 = dc.attribute("PENSHADE", "100").toInt();
00379               m_Doc->toolSettings.dShadeLine = dc.attribute("LINESHADE", "100").toInt();
00380               m_Doc->toolSettings.dShade = dc.attribute("BRUSHSHADE", "100").toInt();
00381               m_Doc->toolSettings.magMin = dc.attribute("MAGMIN", "10").toInt();
00382               m_Doc->toolSettings.magMax = dc.attribute("MAGMAX", "3200").toInt();
00383               m_Doc->toolSettings.magStep = dc.attribute("MAGSTEP", "200").toInt();
00384               //CB Reset doc zoom step value to 200% instead of old values.
00385               if (m_Doc->toolSettings.magStep<100)
00386                      m_Doc->toolSettings.magStep=200;
00387               m_Doc->toolSettings.tabFillChar = dc.attribute("TabFill","");
00388               m_Doc->toolSettings.dTabWidth=dc.attribute("TabWidth", "36.0").toDouble();
00389               if (dc.hasAttribute("CPICT"))
00390                      m_Doc->toolSettings.dBrushPict = dc.attribute("CPICT");
00391               m_Doc->toolSettings.shadePict = dc.attribute("PICTSHADE", "100").toInt();
00392               if (dc.hasAttribute("PAGEC"))
00393                      m_Doc->papColor = QColor(dc.attribute("PAGEC"));
00394               if (dc.hasAttribute("MARGC"))
00395                      m_Doc->guidesSettings.margColor = QColor(dc.attribute("MARGC"));
00396               if (dc.hasAttribute("MINORC"))
00397                      m_Doc->guidesSettings.minorColor = QColor(dc.attribute("MINORC"));
00398               if (dc.hasAttribute("MAJORC"))
00399                      m_Doc->guidesSettings.majorColor = QColor(dc.attribute("MAJORC"));
00400               if (dc.hasAttribute("GuideC"))
00401                      m_Doc->guidesSettings.guideColor = QColor(dc.attribute("GuideC"));
00402               if (dc.hasAttribute("BaseC"))
00403                      m_Doc->guidesSettings.baseColor = QColor(dc.attribute("BaseC"));
00404               m_Doc->marginColored = static_cast<bool>(dc.attribute("RANDF", "0").toInt());
00405               m_Doc->guidesSettings.before = static_cast<bool>(dc.attribute("BACKG", "1").toInt());
00406               m_Doc->guidesSettings.guideRad = dc.attribute("GuideRad", "10").toDouble();
00407               m_Doc->guidesSettings.grabRad = dc.attribute("GRAB", "4").toInt();
00408               if (dc.hasAttribute("currentProfile"))
00409               {
00410                      m_Doc->checkerProfiles.clear();
00411                      m_Doc->curCheckProfile = dc.attribute("currentProfile");
00412               }
00413               m_Doc->LastAuto = 0;
00414               QDomNode PAGE=DOC.firstChild();
00415               counter = 0;
00416               while(!PAGE.isNull())
00417               {
00418                      ObCount++;
00419                      if (m_mwProgressBar!=0)
00420                             m_mwProgressBar->setProgress(ObCount);
00421                      QDomElement pg=PAGE.toElement();
00422                      if (pg.tagName()=="PageSets")
00423                      {
00424                             QDomNode PGS = PAGE.firstChild();
00425                             m_Doc->pageSets.clear();
00426                             while(!PGS.isNull())
00427                             {
00428                                    QDomElement PgsAttr = PGS.toElement();
00429                                    if(PgsAttr.tagName() == "Set")
00430                                    {
00431                                           struct PageSet pageS;
00432                                           pageS.Name = CommonStrings::untranslatePageSetString(PgsAttr.attribute("Name"));
00433                                           pageS.FirstPage = PgsAttr.attribute("FirstPage", "0").toInt();
00434                                           pageS.Rows = PgsAttr.attribute("Rows", "1").toInt();
00435                                           pageS.Columns = PgsAttr.attribute("Columns", "1").toInt();
00436                                           pageS.GapHorizontal = PgsAttr.attribute("GapHorizontal", "0").toDouble();
00437                                           pageS.GapVertical = PgsAttr.attribute("GapVertical", "0").toDouble();
00438                                           pageS.GapBelow = PgsAttr.attribute("GapBelow", "0").toDouble();
00439                                           pageS.pageNames.clear();
00440                                           QDomNode PGSN = PGS.firstChild();
00441                                           while(!PGSN.isNull())
00442                                           {
00443                                                  QDomElement PgsAttrN = PGSN.toElement();
00444                                                  if(PgsAttrN.tagName() == "PageNames")
00445                                                         pageS.pageNames.append(CommonStrings::untranslatePageSetLocString(PgsAttrN.attribute("Name")));
00446                                                  PGSN = PGSN.nextSibling();
00447                                           }
00448                                           m_Doc->pageSets.append(pageS);
00449                                    }
00450                                    PGS = PGS.nextSibling();
00451                             }
00452                      }
00453                      if (pg.tagName()=="CheckProfile")
00454                      {
00455                             struct checkerPrefs checkerSettings;
00456                             checkerSettings.ignoreErrors = static_cast<bool>(pg.attribute("ignoreErrors", "0").toInt());
00457                             checkerSettings.autoCheck = static_cast<bool>(pg.attribute("autoCheck", "1").toInt());
00458                             checkerSettings.checkGlyphs = static_cast<bool>(pg.attribute("checkGlyphs", "1").toInt());
00459                             checkerSettings.checkOrphans = static_cast<bool>(pg.attribute("checkOrphans", "1").toInt());
00460                             checkerSettings.checkOverflow = static_cast<bool>(pg.attribute("checkOverflow", "1").toInt());
00461                             checkerSettings.checkPictures = static_cast<bool>(pg.attribute("checkPictures", "1").toInt());
00462                             checkerSettings.checkResolution = static_cast<bool>(pg.attribute("checkResolution", "1").toInt());
00463                             checkerSettings.checkTransparency = static_cast<bool>(pg.attribute("checkTransparency", "1").toInt());
00464                             checkerSettings.minResolution = pg.attribute("minResolution", "72").toDouble();
00465                             checkerSettings.maxResolution = pg.attribute("maxResolution", "4800").toDouble();
00466                             checkerSettings.checkAnnotations = static_cast<bool>(pg.attribute("checkAnnotations", "0").toInt());
00467                             checkerSettings.checkRasterPDF = static_cast<bool>(pg.attribute("checkRasterPDF", "1").toInt());
00468                             checkerSettings.checkForGIF = static_cast<bool>(pg.attribute("checkForGIF", "1").toInt());
00469                             checkerSettings.ignoreOffLayers = false;
00470                             m_Doc->checkerProfiles[pg.attribute("Name")] = checkerSettings;
00471                      }
00472                      // 10/25/2004 pv - None is "reserved" color. cannot be defined in any file...
00473                      if(pg.tagName()=="COLOR" && pg.attribute("NAME")!=CommonStrings::None)
00474                      {
00475                             if (pg.hasAttribute("CMYK"))
00476                                    lf.setNamedColor(pg.attribute("CMYK"));
00477                             else
00478                                    lf.fromQColor(QColor(pg.attribute("RGB")));
00479                             if (pg.hasAttribute("Spot"))
00480                                    lf.setSpotColor(static_cast<bool>(pg.attribute("Spot").toInt()));
00481                             else
00482                                    lf.setSpotColor(false);
00483                             if (pg.hasAttribute("Register"))
00484                                    lf.setRegistrationColor(static_cast<bool>(pg.attribute("Register").toInt()));
00485                             else
00486                                    lf.setRegistrationColor(false);
00487                             m_Doc->PageColors.insert(pg.attribute("NAME"), lf);
00488                      }
00489                      if(pg.tagName()=="STYLE")
00490                      {
00491                             readParagraphStyle(vg, pg, m_Doc);
00492                             StyleSet<ParagraphStyle> temp;
00493                             temp.create(vg);
00494                             m_Doc->redefineStyles(temp, false);
00495                             DoVorl[VorlC] = vg.name();
00496                             ++VorlC;
00497                      }
00498                      if(pg.tagName()=="JAVA")
00499                             m_Doc->JavaScripts[pg.attribute("NAME")] = pg.attribute("SCRIPT");
00500                      if(pg.tagName()=="LAYERS")
00501                      {
00502                             la.LNr = pg.attribute("NUMMER").toInt();
00503                             la.Level = pg.attribute("LEVEL").toInt();
00504                             la.Name = pg.attribute("NAME");
00505                             la.isViewable = pg.attribute("SICHTBAR").toInt();
00506                             la.isPrintable = pg.attribute("DRUCKEN").toInt();
00507                             la.isEditable = pg.attribute("EDIT", "1").toInt();
00508                             la.flowControl = pg.attribute("FLOW", "1").toInt();
00509                             la.transparency = pg.attribute("TRANS", "1").toDouble();
00510                             la.blendMode = pg.attribute("BLEND", "0").toInt();
00511                             la.outlineMode = pg.attribute("OUTL", "0").toInt();
00512                             if (pg.hasAttribute("LAYERC"))
00513                                    la.markerColor =  QColor(pg.attribute("LAYERC","#000000"));
00514                             else
00515                             {
00516                                    QColor marker;
00517                                    switch (la.LNr % 7)
00518                                    {
00519                                           case 0:
00520                                                  marker = Qt::black;
00521                                                  break;
00522                                           case 1:
00523                                                  marker = Qt::red;
00524                                                  break;
00525                                           case 2:
00526                                                  marker = Qt::green;
00527                                                  break;
00528                                           case 3:
00529                                                  marker = Qt::blue;
00530                                                  break;
00531                                           case 4:
00532                                                  marker = Qt::cyan;
00533                                                  break;
00534                                           case 5:
00535                                                  marker = Qt::magenta;
00536                                                  break;
00537                                           case 6:
00538                                                  marker = Qt::yellow;;
00539                                                  break;
00540                                    }
00541                                    la.markerColor = marker;
00542                             }
00543                             m_Doc->Layers.append(la);
00544                      }
00545 /*                   if(pg.tagName()=="Bookmark")
00546                      {
00547                             bok.Title = pg.attribute("Title");
00548                             bok.Text = pg.attribute("Text");
00549                             bok.Aktion = pg.attribute("Aktion");
00550                             bok.ItemNr = pg.attribute("ItemNr").toInt();
00551                             bok.Seite = pg.attribute("Seite").toInt();
00552                             bok.Element = pg.attribute("Element").toInt();
00553                             bok.First = pg.attribute("First").toInt();
00554                             bok.Last = pg.attribute("Last").toInt();
00555                             bok.Prev = pg.attribute("Prev").toInt();
00556                             bok.Next = pg.attribute("Next").toInt();
00557                             bok.Parent = pg.attribute("Parent").toInt();
00558                             m_Doc->BookMarks.append(bok);
00559                      } */
00560                      if(pg.tagName()=="MultiLine")
00561                      {
00562                             multiLine ml;
00563                             QDomNode MuLn = PAGE.firstChild();
00564                             while(!MuLn.isNull())
00565                             {
00566                                    QDomElement MuL = MuLn.toElement();
00567                                    struct SingleLine sl;
00568                                    sl.Color = MuL.attribute("Color");
00569                                    sl.Dash = MuL.attribute("Dash").toInt();
00570                                    sl.LineEnd = MuL.attribute("LineEnd").toInt();
00571                                    sl.LineJoin = MuL.attribute("LineJoin").toInt();
00572                                    sl.Shade = MuL.attribute("Shade").toInt();
00573                                    sl.Width = MuL.attribute("Width").toDouble();
00574                                    ml.push_back(sl);
00575                                    MuLn = MuLn.nextSibling();
00576                             }
00577                             m_Doc->MLineStyles.insert(pg.attribute("Name"), ml);
00578                      }
00579                      if(pg.tagName()=="Arrows")
00580                      {
00581                             struct ArrowDesc arrow;
00582                             arrow.name = pg.attribute("Name");
00583                             arrow.userArrow = true;
00584                             double xa, ya;
00585                             QString tmp = pg.attribute("Points");
00586                             QTextStream fp(&tmp, IO_ReadOnly);
00587                             for (uint cx = 0; cx < pg.attribute("NumPoints").toUInt(); ++cx)
00588                             {
00589                                    fp >> xa;
00590                                    fp >> ya;
00591                                    arrow.points.addPoint(xa, ya);
00592                             }
00593                             m_Doc->arrowStyles.append(arrow);
00594                      }
00595                      if(pg.tagName()=="PDF")
00596                      {
00597                             m_Doc->PDF_Options.Articles = static_cast<bool>(pg.attribute("Articles").toInt());
00598                             m_Doc->PDF_Options.Thumbnails = static_cast<bool>(pg.attribute("Thumbnails").toInt());
00599                             m_Doc->PDF_Options.Compress = static_cast<bool>(pg.attribute("Compress").toInt());
00600                             m_Doc->PDF_Options.CompressMethod = pg.attribute("CMethod", "0").toInt();
00601                             m_Doc->PDF_Options.Quality = pg.attribute("Quality", "0").toInt();
00602                             m_Doc->PDF_Options.RecalcPic = static_cast<bool>(pg.attribute("RecalcPic").toInt());
00603                             m_Doc->PDF_Options.Bookmarks = static_cast<bool>(pg.attribute("Bookmarks").toInt());
00604                             if (pg.hasAttribute("MirrorH"))
00605                                    m_Doc->PDF_Options.MirrorH = static_cast<bool>(pg.attribute("MirrorH").toInt());
00606                             else
00607                                    m_Doc->PDF_Options.MirrorH = false;
00608                             if (pg.hasAttribute("MirrorV"))
00609                                    m_Doc->PDF_Options.MirrorV = static_cast<bool>(pg.attribute("MirrorV").toInt());
00610                             else
00611                                    m_Doc->PDF_Options.MirrorV = false;
00612                             if (pg.hasAttribute("RotateDeg"))
00613                                    m_Doc->PDF_Options.RotateDeg = pg.attribute("RotateDeg", "0").toInt();
00614                             else
00615                                    m_Doc->PDF_Options.RotateDeg = 0;
00616                             if (pg.hasAttribute("Clip"))
00617                                    m_Doc->PDF_Options.doClip = static_cast<bool>(pg.attribute("Clip").toInt());
00618                             else
00619                                    m_Doc->PDF_Options.doClip = false;
00620                             m_Doc->PDF_Options.PresentMode = static_cast<bool>(pg.attribute("PresentMode").toInt());
00621                             m_Doc->PDF_Options.PicRes = pg.attribute("PicRes").toInt();
00622                             // Fixme: check input pdf version
00623                             m_Doc->PDF_Options.Version = (PDFOptions::PDFVersion)pg.attribute("Version").toInt();
00624                             m_Doc->PDF_Options.Resolution = pg.attribute("Resolution").toInt();
00625                             m_Doc->PDF_Options.Binding = pg.attribute("Binding").toInt();
00626                             m_Doc->PDF_Options.Datei = "";
00627                             m_Doc->PDF_Options.isGrayscale = static_cast<bool>(pg.attribute("Grayscale", "0").toInt());
00628                             m_Doc->PDF_Options.UseRGB = static_cast<bool>(pg.attribute("RGBMode", "0").toInt());
00629                             m_Doc->PDF_Options.UseProfiles = static_cast<bool>(pg.attribute("UseProfiles", "0").toInt());
00630                             m_Doc->PDF_Options.UseProfiles2 = static_cast<bool>(pg.attribute("UseProfiles2", "0").toInt());
00631                             m_Doc->PDF_Options.Intent = pg.attribute("Intent", "1").toInt();
00632                             m_Doc->PDF_Options.Intent2 = pg.attribute("Intent2", "1").toInt();
00633                             m_Doc->PDF_Options.SolidProf = pg.attribute("SolidP", "");
00634                             m_Doc->PDF_Options.ImageProf = pg.attribute("ImageP", "");
00635                             m_Doc->PDF_Options.PrintProf = pg.attribute("PrintP", "");
00636                             m_Doc->PDF_Options.Info = pg.attribute("InfoString", "");
00637                             m_Doc->PDF_Options.bleeds.Top = pg.attribute("BTop", "0").toDouble();
00638                             m_Doc->PDF_Options.bleeds.Left = pg.attribute("BLeft", "0").toDouble();
00639                             m_Doc->PDF_Options.bleeds.Right = pg.attribute("BRight", "0").toDouble();
00640                             m_Doc->PDF_Options.bleeds.Bottom = pg.attribute("BBottom", "0").toDouble();
00641                             m_Doc->PDF_Options.EmbeddedI = static_cast<bool>(pg.attribute("ImagePr", "0").toInt());
00642                             m_Doc->PDF_Options.PassOwner = pg.attribute("PassOwner", "");
00643                             m_Doc->PDF_Options.PassUser = pg.attribute("PassUser", "");
00644                             m_Doc->PDF_Options.Permissions = pg.attribute("Permissions", "-4").toInt();
00645                             m_Doc->PDF_Options.Encrypt = static_cast<bool>(pg.attribute("Encrypt", "0").toInt());
00646                             m_Doc->PDF_Options.useLayers = static_cast<bool>(pg.attribute("UseLayers", "0").toInt());
00647                             m_Doc->PDF_Options.UseLPI = static_cast<bool>(pg.attribute("UseLpi", "0").toInt());
00648                             m_Doc->PDF_Options.UseSpotColors = static_cast<bool>(pg.attribute("UseSpotColors", "1").toInt());
00649                             m_Doc->PDF_Options.doOverprint = static_cast<bool>(pg.attribute("doOverprint", "0").toInt());
00650                             m_Doc->PDF_Options.doMultiFile = static_cast<bool>(pg.attribute("doMultiFile", "0").toInt());
00651                             m_Doc->PDF_Options.displayBookmarks = static_cast<bool>(pg.attribute("displayBookmarks", "0").toInt());
00652                             m_Doc->PDF_Options.displayFullscreen = static_cast<bool>(pg.attribute("displayFullscreen", "0").toInt());
00653                             m_Doc->PDF_Options.displayLayers = static_cast<bool>(pg.attribute("displayLayers", "0").toInt());
00654                             m_Doc->PDF_Options.displayThumbs = static_cast<bool>(pg.attribute("displayThumbs", "0").toInt());
00655                             m_Doc->PDF_Options.hideMenuBar = static_cast<bool>(pg.attribute("hideMenuBar", "0").toInt());
00656                             m_Doc->PDF_Options.hideToolBar = static_cast<bool>(pg.attribute("hideToolBar", "0").toInt());
00657                             m_Doc->PDF_Options.fitWindow = static_cast<bool>(pg.attribute("fitWindow", "0").toInt());
00658                             m_Doc->PDF_Options.PageLayout = pg.attribute("PageLayout", "0").toInt();
00659                             m_Doc->PDF_Options.openAction = pg.attribute("openAction", "");
00660                             QDomNode PFO = PAGE.firstChild();
00661                             while(!PFO.isNull())
00662                             {
00663                                    QDomElement pdfF = PFO.toElement();
00664                                    if(pdfF.tagName() == "LPI")
00665                                    {
00666                                           struct LPIData lpo;
00667                                           lpo.Angle = pdfF.attribute("Angle").toInt();
00668                                           lpo.Frequency = pdfF.attribute("Frequency").toInt();
00669                                           lpo.SpotFunc = pdfF.attribute("SpotFunction").toInt();
00670                                           m_Doc->PDF_Options.LPISettings[pdfF.attribute("Color")] = lpo;
00671                                    }
00672                                    if(pdfF.tagName() == "Fonts")
00673                                    {
00674                                           if (!m_Doc->PDF_Options.EmbedList.contains(pdfF.attribute("Name")))
00675                                                  m_Doc->PDF_Options.EmbedList.append(pdfF.attribute("Name"));
00676                                    }
00677                                    if(pdfF.tagName() == "Subset")
00678                                    {
00679                                           if (!m_Doc->PDF_Options.SubsetList.contains(pdfF.attribute("Name")))
00680                                                  m_Doc->PDF_Options.SubsetList.append(pdfF.attribute("Name"));
00681                                    }
00682                                    if(pdfF.tagName() == "Effekte")
00683                                    {
00684                                           struct PDFPresentationData ef;
00685                                           ef.pageEffectDuration = pdfF.attribute("pageEffectDuration").toInt();
00686                                           ef.pageViewDuration = pdfF.attribute("pageViewDuration").toInt();
00687                                           ef.effectType = pdfF.attribute("effectType").toInt();
00688                                           ef.Dm = pdfF.attribute("Dm").toInt();
00689                                           ef.M = pdfF.attribute("M").toInt();
00690                                           ef.Di = pdfF.attribute("Di").toInt();
00691                                           m_Doc->PDF_Options.PresentVals.append(ef);
00692                                    }
00693                                    PFO = PFO.nextSibling();
00694                             }
00695                      }
00696                      if(pg.tagName()=="DocItemAttributes")
00697                      {
00698                             QDomNode DIA = PAGE.firstChild();
00699                             m_Doc->docItemAttributes.clear();
00700                             while(!DIA.isNull())
00701                             {
00702                                    QDomElement itemAttr = DIA.toElement();
00703                                    if(itemAttr.tagName() == "ItemAttribute")
00704                                    {
00705                                           ObjectAttribute objattr;
00706                                           objattr.name=itemAttr.attribute("Name");
00707                                           objattr.type=itemAttr.attribute("Type");
00708                                           objattr.value=itemAttr.attribute("Value");
00709                                           objattr.parameter=itemAttr.attribute("Parameter");
00710                                           objattr.relationship=itemAttr.attribute("Relationship");
00711                                           objattr.relationshipto=itemAttr.attribute("RelationshipTo");
00712                                           objattr.autoaddto=itemAttr.attribute("AutoAddTo");
00713                                           m_Doc->docItemAttributes.append(objattr);
00714                                    }
00715                                    DIA = DIA.nextSibling();
00716                             }
00717                      }
00718                      if(pg.tagName()=="TablesOfContents")
00719                      {
00720                             QDomNode TOC = PAGE.firstChild();
00721                             m_Doc->docToCSetups.clear();
00722                             while(!TOC.isNull())
00723                             {
00724                                    QDomElement tocElem = TOC.toElement();
00725                                    if(tocElem.tagName() == "TableOfContents")
00726                                    {
00727                                           ToCSetup tocsetup;
00728                                           tocsetup.name=tocElem.attribute("Name");
00729                                           tocsetup.itemAttrName=tocElem.attribute("ItemAttributeName");
00730                                           tocsetup.frameName=tocElem.attribute("FrameName");
00731                                           tocsetup.listNonPrintingFrames=tocElem.attribute("ListNonPrinting");
00732                                           tocsetup.textStyle=tocElem.attribute("Style");
00733                                           QString numberPlacement=tocElem.attribute("NumberPlacement");
00734                                           if (numberPlacement=="Beginning")
00735                                                  tocsetup.pageLocation=Beginning;
00736                                           if (numberPlacement=="End")
00737                                                  tocsetup.pageLocation=End;
00738                                           if (numberPlacement=="NotShown")
00739                                                  tocsetup.pageLocation=NotShown;
00740                                           m_Doc->docToCSetups.append(tocsetup);
00741                                    }
00742                                    TOC = TOC.nextSibling();
00743                             }
00744                      }
00745                      if(pg.tagName()=="Sections")
00746                      {
00747                             QDomNode Section = PAGE.firstChild();
00748                             while(!Section.isNull())
00749                             {
00750                                    QDomElement sectionElem = Section.toElement();
00751                                    if(sectionElem.tagName() == "Section")
00752                                    {
00753                                           struct DocumentSection newSection;
00754                                           newSection.number=sectionElem.attribute("Number").toInt();
00755                                           newSection.name=sectionElem.attribute("Name");
00756                                           newSection.fromindex=sectionElem.attribute("From").toInt();
00757                                           newSection.toindex=sectionElem.attribute("To").toInt();
00758                                           if (sectionElem.attribute("Type")=="Type_1_2_3")
00759                                                  newSection.type=Type_1_2_3;
00760                                           if (sectionElem.attribute("Type")=="Type_i_ii_iii")
00761                                                  newSection.type=Type_i_ii_iii;
00762                                           if (sectionElem.attribute("Type")=="Type_I_II_III")
00763                                                  newSection.type=Type_I_II_III;
00764                                           if (sectionElem.attribute("Type")=="Type_a_b_c")
00765                                                  newSection.type=Type_a_b_c;
00766                                           if (sectionElem.attribute("Type")=="Type_A_B_C")
00767                                                  newSection.type=Type_A_B_C;
00768                                           newSection.sectionstartindex=sectionElem.attribute("Start").toInt();
00769                                           newSection.reversed=static_cast<bool>(sectionElem.attribute("Reversed").toInt());
00770                                           newSection.active=static_cast<bool>(sectionElem.attribute("Active").toInt());
00771                                           m_Doc->sections.insert(newSection.number, newSection);
00772                                    }
00773                                    Section = Section.nextSibling();
00774                             }
00775                      }
00776                      if ((pg.tagName()=="PAGE") || (pg.tagName()=="MASTERPAGE"))
00777                      {
00778                             a = pg.attribute("NUM").toInt();
00779                             PgNam = "";
00780                             PgNam = pg.attribute("NAM", "");
00781                             //Pgc = m_Doc->pageCount;
00782                             //AtFl = m_Doc->usesAutomaticTextFrames();
00783                             if (PgNam.isEmpty())
00784                             {
00785                                    //m_Doc->pageCount = Pgc;
00786                                    //m_Doc->Pages = &m_Doc->DocPages;
00787                                    //m_Doc->setUsesAutomaticTextFrames(AtFl);
00788                                    m_Doc->setMasterPageMode(false);
00789                             }
00790                             else
00791                             {
00792                                    //m_Doc->pageCount = 0;
00793                                    //m_Doc->setUsesAutomaticTextFrames(false);
00794                                    //m_Doc->Pages = &m_Doc->MasterPages;
00795                                    m_Doc->setMasterPageMode(true);
00796                             }
00797                             //CB: Stop calling damn GUI code in loading docs! IT doesnt *look* like
00798                             //this makes a difference apart from being faster, of course.
00799                             //ScMW->slotNewPage(a);
00800                             //Apage = m_Doc->Pages.at(a);
00801                             if (PgNam.isEmpty())
00802                             {
00803                                    Apage = m_Doc->addPage(a);
00804                                    //m_Doc->DocPages = m_Doc->Pages;
00805                                    //++m_Doc->pageCount;
00806                             }
00807                             else
00808                             {
00809                                    Apage = m_Doc->addMasterPage(a, PgNam);
00810                                    //Apage->setPageName(PgNam);
00811                                    //m_Doc->MasterNames[PgNam] = a;
00812                                    //m_Doc->MasterPages = m_Doc->Pages;
00813                                    //m_Doc->pageCount = Pgc;
00814                             }
00815                             //m_Doc->setUsesAutomaticTextFrames(AtFl);
00816                             Apage->LeftPg=pg.attribute("LEFT", "0").toInt();
00817                             QString Mus = "";
00818                             Mus = pg.attribute("MNAM","Normal");
00819                             if (!m_Doc->masterPageMode())
00820                                    Apage->MPageNam = Mus;
00821                             else
00822                                    Apage->MPageNam = "";
00823                             if (pg.hasAttribute("Size"))
00824                                    Apage->m_pageSize = pg.attribute("Size");
00825                             if (pg.hasAttribute("Orientation"))
00826                                    Apage->PageOri = pg.attribute("Orientation").toInt();
00827                             Apage->setXOffset(pg.attribute("PAGEXPOS").toDouble());
00828                             Apage->setYOffset(pg.attribute("PAGEYPOS").toDouble());
00829                             if (pg.hasAttribute("PAGEWIDTH"))
00830                                    Apage->setWidth(pg.attribute("PAGEWIDTH").toDouble());
00831                             else
00832                                    Apage->setWidth(pg.attribute("PAGEWITH").toDouble());
00833                             Apage->setHeight(pg.attribute("PAGEHEIGHT").toDouble());
00834                             Apage->setInitialHeight(Apage->height());
00835                             Apage->setInitialWidth(Apage->width());
00836                             Apage->initialMargins.Top = QMAX(0.0, pg.attribute("BORDERTOP").toDouble());
00837                             Apage->initialMargins.Bottom = QMAX(0.0, pg.attribute("BORDERBOTTOM").toDouble());
00838                             Apage->initialMargins.Left = QMAX(0.0, pg.attribute("BORDERLEFT").toDouble());
00839                             Apage->initialMargins.Right = QMAX(0.0, pg.attribute("BORDERRIGHT").toDouble());
00840                             Apage->Margins.Top = Apage->initialMargins.Top;
00841                             Apage->Margins.Bottom = Apage->initialMargins.Bottom;
00842                             m_Doc->setMasterPageMode(false);
00843                             //m_Doc->Pages=&m_Doc->DocPages;
00844                             // guides reading
00845                             tmp = "";
00846                             Apage->guides.setHorizontalAutoGap(0.0);
00847                             Apage->guides.setVerticalAutoGap(0.0);
00848                             Apage->guides.setHorizontalAutoCount(0);
00849                             Apage->guides.setVerticalAutoCount(0);
00850                             Apage->guides.setHorizontalAutoRefer(0);
00851                             Apage->guides.setVerticalAutoRefer(0);
00852                             GuideManagerIO::readVerticalGuides(pg.attribute("VerticalGuides"),
00853                                           Apage,
00854                                           GuideManagerCore::Standard,
00855                                           pg.hasAttribute("NumVGuides"));
00856                             GuideManagerIO::readHorizontalGuides(pg.attribute("HorizontalGuides"),
00857                                           Apage,
00858                                           GuideManagerCore::Standard,
00859                                           pg.hasAttribute("NumHGuides"));
00860                      }
00861                      if ((pg.tagName()=="PAGEOBJECT") || (pg.tagName()=="MASTEROBJECT") || (pg.tagName()=="FRAMEOBJECT"))
00862                      {
00863                                    if ((pg.tagName()=="PAGEOBJECT") || (pg.tagName()=="FRAMEOBJECT"))
00864                                    {
00865                                           //m_Doc->Items = m_Doc->DocItems;
00866                                           //m_Doc->Pages = &m_Doc->DocPages;
00867                                           m_Doc->setMasterPageMode(false);
00868                                    }
00869                                    else
00870                                    {
00871                                           //m_Doc->Items = m_Doc->MasterItems;
00872                                           //m_Doc->Pages = &m_Doc->MasterPages;
00873                                           m_Doc->setMasterPageMode(true);
00874                                    }
00875                             if ((!pg.attribute("OnMasterPage").isEmpty()) && (pg.tagName()=="MASTEROBJECT"))
00876                                    m_Doc->setCurrentPage(m_Doc->MasterPages.at(m_Doc->MasterNames[pg.attribute("OnMasterPage")]));
00877 
00878                             if (pg.tagName()=="PAGEOBJECT")
00879                             {
00880                                    itemRemap[itemCount++] = m_Doc->Items->count();
00881                                    // member of linked chain?
00882                                    if ((pg.attribute("NEXTITEM").toInt() != -1) )
00883                                    {
00884                                           itemNext[m_Doc->Items->count()] = pg.attribute("NEXTITEM").toInt();
00885                                    }
00886                             }
00887                                    int docGc = m_Doc->GroupCounter;
00888                                    m_Doc->GroupCounter = 0;
00889                                    Neu = PasteItem(&pg, m_Doc);
00890                                    Neu->setRedrawBounding();
00891                                    if (pg.tagName()=="MASTEROBJECT")
00892                                           Neu->OwnPage = m_Doc->OnPage(Neu);
00893                                    else
00894                                           Neu->OwnPage = pg.attribute("OwnPage").toInt();
00895                                    if (pg.tagName()=="PAGEOBJECT")
00896                                           Neu->OnMasterPage = "";
00897                                    m_Doc->GroupCounter = docGc;
00898                                    QDomNode IT=pg.firstChild();
00899                                    LastStyles * last = new LastStyles();
00900                                    while(!IT.isNull())
00901                                    {
00902                                           QDomElement it=IT.toElement();
00903                                           if (it.tagName()=="CSTOP")
00904                                           {
00905                                                  QString name = it.attribute("NAME");
00906                                                  double ramp = it.attribute("RAMP", "0.0").toDouble();
00907                                                  int shade = it.attribute("SHADE", "100").toInt();
00908                                                  double opa = it.attribute("TRANS", "1").toDouble();
00909                                                  handleOldColorShade(m_Doc, name, shade);
00910                                                  Neu->fill_gradient.addStop(SetColor(m_Doc, name, shade), ramp, 0.5, opa, name, shade);
00911                                           }
00912                                           if (it.tagName()=="ITEXT")
00913                                                  GetItemText(&it, m_Doc, Neu, last);
00914 
00915                                           //CB PageItemAttributes
00916                                           if(it.tagName()=="PageItemAttributes")
00917                                           {
00918                                                  QDomNode PIA = it.firstChild();
00919                                                  ObjAttrVector pageItemAttributes;
00920                                                  while(!PIA.isNull())
00921                                                  {
00922                                                         QDomElement itemAttr = PIA.toElement();
00923                                                         if(itemAttr.tagName() == "ItemAttribute")
00924                                                         {
00925                                                                ObjectAttribute objattr;
00926                                                                objattr.name=itemAttr.attribute("Name");
00927                                                                objattr.type=itemAttr.attribute("Type");
00928                                                                objattr.value=itemAttr.attribute("Value");
00929                                                                objattr.parameter=itemAttr.attribute("Parameter");
00930                                                                objattr.relationship=itemAttr.attribute("Relationship");
00931                                                                objattr.relationshipto=itemAttr.attribute("RelationshipTo");
00932                                                                objattr.autoaddto=itemAttr.attribute("AutoAddTo");
00933                                                                pageItemAttributes.append(objattr);
00934                                                         }
00935                                                         PIA = PIA.nextSibling();
00936                                                  }
00937                                                  Neu->setObjectAttributes(&pageItemAttributes);
00938                                           }
00939                                           IT=IT.nextSibling();
00940                                    }
00941                                    delete last;
00942                                    if (Neu->fill_gradient.Stops() == 0)
00943                                    {
00944                                           const ScColor& col1 = m_Doc->PageColors[m_Doc->toolSettings.dBrush];
00945                                           const ScColor& col2 = m_Doc->PageColors[m_Doc->toolSettings.dPen];
00946                                           Neu->fill_gradient.addStop(ScColorEngine::getRGBColor(col1, m_Doc), 0.0, 0.5, 1.0, m_Doc->toolSettings.dBrush, 100);
00947                                           Neu->fill_gradient.addStop(ScColorEngine::getRGBColor(col2, m_Doc), 1.0, 0.5, 1.0, m_Doc->toolSettings.dPen, 100);
00948                                    }
00949 //                                 Neu->Language = ScMW->GetLang(pg.attribute("LANGUAGE", m_Doc->Language));
00950                                    Neu->isAutoText = static_cast<bool>(pg.attribute("AUTOTEXT").toInt());
00951                                    Neu->isEmbedded = static_cast<bool>(pg.attribute("isInline", "0").toInt());
00952                                    Neu->gXpos = pg.attribute("gXpos", "0.0").toDouble();
00953                                    Neu->gYpos = pg.attribute("gYpos", "0.0").toDouble();
00954                                    QString defaultVal;
00955                                    defaultVal.setNum(Neu->width());
00956                                    Neu->gWidth = pg.attribute("gWidth",defaultVal).toDouble();
00957                                    defaultVal.setNum(Neu->height());
00958                                    Neu->gHeight = pg.attribute("gHeight",defaultVal).toDouble();
00959                                    if (Neu->isAutoText)
00960                                           m_Doc->LastAuto = Neu;
00961                                    if (pg.tagName()=="FRAMEOBJECT")
00962                                    {
00963                                           m_Doc->FrameItems.append(m_Doc->Items->take(Neu->ItemNr));
00964                                           Neu->ItemNr = m_Doc->FrameItems.count()-1;
00965                                    }
00966                                    if (Neu->isTableItem)
00967                                    {
00968                                           if (pg.tagName()=="PAGEOBJECT")
00969                                           {
00970                                                  TableItems.append(Neu);
00971                                                  TableID.insert(pg.attribute("OwnLINK", "0").toInt(), Neu->ItemNr);
00972                                           }
00973                                           else if (pg.tagName()=="FRAMEOBJECT")
00974                                           {
00975                                                  TableItemsF.append(Neu);
00976                                                  TableIDF.insert(pg.attribute("OwnLINK", "0").toInt(), Neu->ItemNr);
00977                                           }
00978                                           else
00979                                           {
00980                                                  TableItemsM.append(Neu);
00981                                                  TableIDM.insert(pg.attribute("OwnLINK", "0").toInt(), Neu->ItemNr);
00982                                           }
00983                                    }
00984                                    /*
00985                                    if ((pg.tagName()=="PAGEOBJECT") || (pg.tagName()=="FRAMEOBJECT"))
00986                                    {
00987                                           //m_Doc->DocItems = m_Doc->Items;
00988                                           //m_Doc->DocPages = m_Doc->Pages;
00989                                    }
00990                                    else
00991                                    {
00992                                           //m_Doc->MasterItems = m_Doc->Items;
00993                                           //m_Doc->MasterPages = m_Doc->Pages;
00994                                    }
00995                                    */
00996                                    m_Doc->setMasterPageMode(false);
00997                                    //m_Doc->Pages=&m_Doc->DocPages;
00998                                    counter++;
00999                             }
01000                      PAGE=PAGE.nextSibling();
01001               }
01002               PAGE=DOC.firstChild();
01003               while(!PAGE.isNull())
01004               {
01005                      QDomElement pg=PAGE.toElement();
01006                      if(pg.tagName()=="Bookmark")
01007                      {
01008                             uint elem = pg.attribute("Element").toInt();
01009                             if (elem < m_Doc->Items->count())
01010                             {
01011                                    bok.Title = pg.attribute("Title");
01012                                    bok.Text = pg.attribute("Text");
01013                                    bok.Aktion = pg.attribute("Aktion");
01014                                    bok.ItemNr = pg.attribute("ItemNr").toInt();
01015                                    bok.PageObject = m_Doc->Items->at(elem);
01016                                    bok.First = pg.attribute("First").toInt();
01017                                    bok.Last = pg.attribute("Last").toInt();
01018                                    bok.Prev = pg.attribute("Prev").toInt();
01019                                    bok.Next = pg.attribute("Next").toInt();
01020                                    bok.Parent = pg.attribute("Parent").toInt();
01021                                    m_Doc->BookMarks.append(bok);
01022                             }
01023                      }
01024                      PAGE=PAGE.nextSibling();
01025               }
01026               DOC=DOC.nextSibling();
01027        }
01028        if (TableItemsF.count() != 0)
01029        {
01030               for (uint ttc = 0; ttc < TableItemsF.count(); ++ttc)
01031               {
01032                      PageItem* ta = TableItemsF.at(ttc);
01033                      if (ta->TopLinkID != -1)
01034                             ta->TopLink = m_Doc->FrameItems.at(TableIDF[ta->TopLinkID]);
01035                      else
01036                             ta->TopLink = 0;
01037                      if (ta->LeftLinkID != -1)
01038                             ta->LeftLink = m_Doc->FrameItems.at(TableIDF[ta->LeftLinkID]);
01039                      else
01040                             ta->LeftLink = 0;
01041                      if (ta->RightLinkID != -1)
01042                             ta->RightLink = m_Doc->FrameItems.at(TableIDF[ta->RightLinkID]);
01043                      else
01044                             ta->RightLink = 0;
01045                      if (ta->BottomLinkID != -1)
01046                             ta->BottomLink = m_Doc->FrameItems.at(TableIDF[ta->BottomLinkID]);
01047                      else
01048                             ta->BottomLink = 0;
01049               }
01050        }
01051        if (TableItemsM.count() != 0)
01052        {
01053               for (uint ttc = 0; ttc < TableItemsM.count(); ++ttc)
01054               {
01055                      PageItem* ta = TableItemsM.at(ttc);
01056                      if (ta->TopLinkID != -1)
01057                             ta->TopLink = m_Doc->MasterItems.at(TableIDM[ta->TopLinkID]);
01058                      else
01059                             ta->TopLink = 0;
01060                      if (ta->LeftLinkID != -1)
01061                             ta->LeftLink = m_Doc->MasterItems.at(TableIDM[ta->LeftLinkID]);
01062                      else
01063                             ta->LeftLink = 0;
01064                      if (ta->RightLinkID != -1)
01065                             ta->RightLink = m_Doc->MasterItems.at(TableIDM[ta->RightLinkID]);
01066                      else
01067                             ta->RightLink = 0;
01068                      if (ta->BottomLinkID != -1)
01069                             ta->BottomLink = m_Doc->MasterItems.at(TableIDM[ta->BottomLinkID]);
01070                      else
01071                             ta->BottomLink = 0;
01072               }
01073        }
01074        if (TableItems.count() != 0)
01075        {
01076               for (uint ttc = 0; ttc < TableItems.count(); ++ttc)
01077               {
01078                      PageItem* ta = TableItems.at(ttc);
01079                      if (ta->TopLinkID != -1)
01080                             ta->TopLink = m_Doc->Items->at(TableID[ta->TopLinkID]);
01081                      else
01082                             ta->TopLink = 0;
01083                      if (ta->LeftLinkID != -1)
01084                             ta->LeftLink = m_Doc->Items->at(TableID[ta->LeftLinkID]);
01085                      else
01086                             ta->LeftLink = 0;
01087                      if (ta->RightLinkID != -1)
01088                             ta->RightLink = m_Doc->Items->at(TableID[ta->RightLinkID]);
01089                      else
01090                             ta->RightLink = 0;
01091                      if (ta->BottomLinkID != -1)
01092                             ta->BottomLink = m_Doc->Items->at(TableID[ta->BottomLinkID]);
01093                      else
01094                             ta->BottomLink = 0;
01095               }
01096        }
01097        m_Doc->setActiveLayer(layerToSetActive);
01098        m_Doc->setMasterPageMode(false);
01099        m_Doc->reformPages();
01100 
01101        if (m_Doc->Layers.count() == 0)
01102        {
01103               la.LNr = 0;
01104               la.Level = 0;
01105               la.Name = QObject::tr("Background");
01106               la.isViewable = true;
01107               la.isPrintable = true;
01108               la.isEditable = true;
01109               la.flowControl = true;
01110               la.transparency = 1.0;
01111               la.blendMode = 0;
01112               la.markerColor = QColor(0, 0, 0);
01113               la.outlineMode = false;
01114               m_Doc->Layers.append(la);
01115        }
01116        
01117        // reestablish textframe links
01118        if (itemNext.count() != 0)
01119        {
01120               QMap<int,int>::Iterator lc;
01121               for (lc = itemNext.begin(); lc != itemNext.end(); ++lc)
01122               {
01123                      if (itemRemap[lc.data()] >= 0)
01124                      {
01125                             PageItem * Its = m_Doc->Items->at(lc.key());
01126                             PageItem * Itn = m_Doc->Items->at(itemRemap[lc.data()]);
01127                             if (Itn->prevInChain() || Its->nextInChain()) 
01128                             {
01129                                    qDebug("scribus13format: corruption in linked textframes detected");
01130                                    continue;
01131                             }
01132                             Its->link(Itn);
01133                      }
01134               }
01135        }
01136 
01137        // reestablish first/lastAuto
01138        m_Doc->FirstAuto = m_Doc->LastAuto;
01139        if (m_Doc->LastAuto)
01140        {
01141               while (m_Doc->LastAuto->nextInChain())
01142                      m_Doc->LastAuto = m_Doc->LastAuto->nextInChain();
01143               while (m_Doc->FirstAuto->prevInChain())
01144                      m_Doc->FirstAuto = m_Doc->FirstAuto->prevInChain();
01145        }
01146        
01147        if (m_mwProgressBar!=0)
01148               m_mwProgressBar->setProgress(DOC.childNodes().count());
01149        return true;
01150 //     return false;
01151 }
01152 
01153 bool Scribus13Format::saveFile(const QString & fileName, const FileFormat & /* fmt */)
01154 {
01155        QString text, tf, tf2, tc, tc2;
01156        QDomDocument docu("scribus");
01157        QString st="<SCRIBUSUTF8NEW></SCRIBUSUTF8NEW>";
01158        docu.setContent(st);
01159        QDomElement elem=docu.documentElement();
01160        elem.setAttribute("Version", QString(VERSION));
01161        QDomElement dc=docu.createElement("DOCUMENT");
01162        dc.setAttribute("ANZPAGES",m_Doc->DocPages.count());
01163        dc.setAttribute("PAGEWIDTH",m_Doc->pageWidth);
01164        dc.setAttribute("PAGEHEIGHT",m_Doc->pageHeight);
01165        dc.setAttribute("BORDERLEFT",m_Doc->pageMargins.Left);
01166        dc.setAttribute("BORDERRIGHT",m_Doc->pageMargins.Right);
01167        dc.setAttribute("BORDERTOP",m_Doc->pageMargins.Top);
01168        dc.setAttribute("BORDERBOTTOM",m_Doc->pageMargins.Bottom);
01169        dc.setAttribute("ORIENTATION",m_Doc->PageOri);
01170        dc.setAttribute("PAGESIZE",m_Doc->m_pageSize);
01171        dc.setAttribute("FIRSTNUM",m_Doc->FirstPnum);
01172        dc.setAttribute("BOOK", m_Doc->currentPageLayout);
01173        if(m_Doc->usesAutomaticTextFrames())
01174               dc.setAttribute("AUTOTEXT",1);
01175        dc.setAttribute("AUTOSPALTEN",m_Doc->PageSp);
01176        dc.setAttribute("ABSTSPALTEN",m_Doc->PageSpa);
01177        dc.setAttribute("UNITS",m_Doc->unitIndex());
01178        dc.setAttribute("DFONT",m_Doc->toolSettings.defFont);
01179        dc.setAttribute("DSIZE",m_Doc->toolSettings.defSize / 10.0);
01180        dc.setAttribute("DCOL",m_Doc->toolSettings.dCols);
01181        dc.setAttribute("DGAP",m_Doc->toolSettings.dGap);
01182        dc.setAttribute("TabFill",m_Doc->toolSettings.tabFillChar);
01183        dc.setAttribute("TabWidth",m_Doc->toolSettings.dTabWidth);
01184        dc.setAttribute("AUTHOR",m_Doc->documentInfo.getAuthor());
01185        dc.setAttribute("COMMENTS",m_Doc->documentInfo.getComments());
01186        dc.setAttribute("KEYWORDS",m_Doc->documentInfo.getKeywords());
01187        dc.setAttribute("PUBLISHER",m_Doc->documentInfo.getPublisher());
01188        dc.setAttribute("DOCDATE",m_Doc->documentInfo.getDate());
01189        dc.setAttribute("DOCTYPE",m_Doc->documentInfo.getType());
01190        dc.setAttribute("DOCFORMAT",m_Doc->documentInfo.getFormat());
01191        dc.setAttribute("DOCIDENT",m_Doc->documentInfo.getIdent());
01192        dc.setAttribute("DOCSOURCE",m_Doc->documentInfo.getSource());
01193        dc.setAttribute("DOCLANGINFO",m_Doc->documentInfo.getLangInfo());
01194        dc.setAttribute("DOCRELATION",m_Doc->documentInfo.getRelation());
01195        dc.setAttribute("DOCCOVER",m_Doc->documentInfo.getCover());
01196        dc.setAttribute("DOCRIGHTS",m_Doc->documentInfo.getRights());
01197        dc.setAttribute("DOCCONTRIB",m_Doc->documentInfo.getContrib());
01198        dc.setAttribute("TITLE",m_Doc->documentInfo.getTitle());
01199        dc.setAttribute("VHOCH",m_Doc->typographicSettings.valueSuperScript);
01200        dc.setAttribute("VHOCHSC",m_Doc->typographicSettings.scalingSuperScript);
01201        dc.setAttribute("VTIEF",m_Doc->typographicSettings.valueSubScript);
01202        dc.setAttribute("VTIEFSC",m_Doc->typographicSettings.scalingSubScript);
01203        dc.setAttribute("VKAPIT",m_Doc->typographicSettings.valueSmallCaps);
01204        dc.setAttribute("BASEGRID",m_Doc->typographicSettings.valueBaseGrid);
01205        dc.setAttribute("BASEO", m_Doc->typographicSettings.offsetBaseGrid);
01206        dc.setAttribute("AUTOL", m_Doc->typographicSettings.autoLineSpacing);
01207        dc.setAttribute("UnderlinePos", m_Doc->typographicSettings.valueUnderlinePos);
01208        dc.setAttribute("UnderlineWidth", m_Doc->typographicSettings.valueUnderlineWidth);
01209        dc.setAttribute("StrikeThruPos", m_Doc->typographicSettings.valueStrikeThruPos);
01210        dc.setAttribute("StrikeThruWidth", m_Doc->typographicSettings.valueStrikeThruWidth);
01211        dc.setAttribute("GROUPC",m_Doc->GroupCounter);
01212        dc.setAttribute("HCMS", static_cast<int>(m_Doc->HasCMS));
01213        dc.setAttribute("DPSo", static_cast<int>(m_Doc->CMSSettings.SoftProofOn));
01214        dc.setAttribute("DPSFo", static_cast<int>(m_Doc->CMSSettings.SoftProofFullOn));
01215        dc.setAttribute("DPuse", static_cast<int>(m_Doc->CMSSettings.CMSinUse));
01216        dc.setAttribute("DPgam", static_cast<int>(m_Doc->CMSSettings.GamutCheck));
01217        dc.setAttribute("DPbla", static_cast<int>(m_Doc->CMSSettings.BlackPoint));
01218        dc.setAttribute("DPMo",m_Doc->CMSSettings.DefaultMonitorProfile);
01219        dc.setAttribute("DPPr",m_Doc->CMSSettings.DefaultPrinterProfile);
01220        dc.setAttribute("DPIn",m_Doc->CMSSettings.DefaultImageRGBProfile);
01221        dc.setAttribute("DPInCMYK",m_Doc->CMSSettings.DefaultImageCMYKProfile);
01222        dc.setAttribute("DPIn2",m_Doc->CMSSettings.DefaultSolidColorRGBProfile);
01223        dc.setAttribute("DPIn3",m_Doc->CMSSettings.DefaultSolidColorCMYKProfile);
01224        dc.setAttribute("DISc",m_Doc->CMSSettings.DefaultIntentColors);
01225        dc.setAttribute("DIIm",m_Doc->CMSSettings.DefaultIntentImages);
01226        dc.setAttribute("ALAYER", m_Doc->activeLayer());
01227        dc.setAttribute("LANGUAGE", m_Doc->Language);
01228        dc.setAttribute("MINWORDLEN", m_Doc->MinWordLen);
01229        dc.setAttribute("HYCOUNT", m_Doc->HyCount);
01230        dc.setAttribute("AUTOMATIC", static_cast<int>(m_Doc->Automatic));
01231        dc.setAttribute("AUTOCHECK", static_cast<int>(m_Doc->AutoCheck));
01232        dc.setAttribute("GUIDELOCK", static_cast<int>(m_Doc->GuideLock));
01233        dc.setAttribute("SnapToGuides", static_cast<int>(m_Doc->SnapGuides));
01234        dc.setAttribute("SnapToGrid", static_cast<int>(m_Doc->useRaster));
01235        dc.setAttribute("MINGRID", m_Doc->guidesSettings.minorGrid);
01236        dc.setAttribute("MAJGRID", m_Doc->guidesSettings.majorGrid);
01237        dc.setAttribute("SHOWGRID", static_cast<int>(m_Doc->guidesSettings.gridShown));
01238        dc.setAttribute("SHOWGUIDES", static_cast<int>(m_Doc->guidesSettings.guidesShown));
01239        dc.setAttribute("showcolborders", static_cast<int>(m_Doc->guidesSettings.colBordersShown));
01240        dc.setAttribute("SHOWFRAME", static_cast<int>(m_Doc->guidesSettings.framesShown));
01241        dc.setAttribute("SHOWLAYERM", static_cast<int>(m_Doc->guidesSettings.layerMarkersShown));
01242        dc.setAttribute("SHOWMARGIN", static_cast<int>(m_Doc->guidesSettings.marginsShown));
01243        dc.setAttribute("SHOWBASE", static_cast<int>(m_Doc->guidesSettings.baseShown));
01244        dc.setAttribute("SHOWPICT", static_cast<int>(m_Doc->guidesSettings.showPic));
01245        dc.setAttribute("SHOWControl", static_cast<int>(m_Doc->guidesSettings.showControls));
01246        dc.setAttribute("SHOWLINK", static_cast<int>(m_Doc->guidesSettings.linkShown));
01247        dc.setAttribute("rulerMode", static_cast<int>(m_Doc->guidesSettings.rulerMode));
01248        dc.setAttribute("showrulers", static_cast<int>(m_Doc->guidesSettings.rulersShown));
01249        dc.setAttribute("rulerXoffset", m_Doc->rulerXoffset);
01250        dc.setAttribute("rulerYoffset", m_Doc->rulerYoffset);
01251        dc.setAttribute("GuideRad", m_Doc->guidesSettings.guideRad);
01252        dc.setAttribute("GRAB",m_Doc->guidesSettings.grabRad);
01253        dc.setAttribute("POLYC", m_Doc->toolSettings.polyC);
01254        dc.setAttribute("POLYF", m_Doc->toolSettings.polyF);
01255        dc.setAttribute("POLYR", m_Doc->toolSettings.polyR);
01256        dc.setAttribute("POLYFD", m_Doc->toolSettings.polyFd);
01257        dc.setAttribute("POLYS", static_cast<int>(m_Doc->toolSettings.polyS));
01258        dc.setAttribute("AutoSave", static_cast<int>(m_Doc->AutoSave));
01259        dc.setAttribute("AutoSaveTime", m_Doc->AutoSaveTime);
01260        dc.setAttribute("ScratchBottom", m_Doc->scratch.Bottom);
01261        dc.setAttribute("ScratchLeft", m_Doc->scratch.Left);
01262        dc.setAttribute("ScratchRight", m_Doc->scratch.Right);
01263        dc.setAttribute("ScratchTop", m_Doc->scratch.Top);
01264        dc.setAttribute("StartArrow", m_Doc->toolSettings.dStartArrow);
01265        dc.setAttribute("EndArrow", m_Doc->toolSettings.dEndArrow);
01266        dc.setAttribute("PEN",m_Doc->toolSettings.dPen);
01267        dc.setAttribute("BRUSH",m_Doc->toolSettings.dBrush);
01268        dc.setAttribute("PENLINE",m_Doc->toolSettings.dPenLine);
01269        dc.setAttribute("PENTEXT",m_Doc->toolSettings.dPenText);
01270        dc.setAttribute("StrokeText",m_Doc->toolSettings.dStrokeText);
01271        dc.setAttribute("TextBackGround", m_Doc->toolSettings.dTextBackGround);
01272        dc.setAttribute("TextLineColor", m_Doc->toolSettings.dTextLineColor);
01273        dc.setAttribute("TextBackGroundShade", m_Doc->toolSettings.dTextBackGroundShade);
01274        dc.setAttribute("TextLineShade", m_Doc->toolSettings.dTextLineShade);
01275        dc.setAttribute("TextPenShade", m_Doc->toolSettings.dTextPenShade);
01276        dc.setAttribute("TextStrokeShade", m_Doc->toolSettings.dTextStrokeShade);
01277        dc.setAttribute("STIL",m_Doc->toolSettings.dLineArt);
01278        dc.setAttribute("STILLINE",m_Doc->toolSettings.dLstyleLine);
01279        dc.setAttribute("WIDTH",m_Doc->toolSettings.dWidth);
01280        dc.setAttribute("WIDTHLINE",m_Doc->toolSettings.dWidthLine);
01281        dc.setAttribute("PENSHADE",m_Doc->toolSettings.dShade2);
01282        dc.setAttribute("LINESHADE",m_Doc->toolSettings.dShadeLine);
01283        dc.setAttribute("BRUSHSHADE",m_Doc->toolSettings.dShade);
01284        dc.setAttribute("MAGMIN",m_Doc->toolSettings.magMin);
01285        dc.setAttribute("MAGMAX",m_Doc->toolSettings.magMax);
01286        dc.setAttribute("MAGSTEP",m_Doc->toolSettings.magStep);
01287        dc.setAttribute("CPICT",m_Doc->toolSettings.dBrushPict);
01288        dc.setAttribute("PICTSHADE",m_Doc->toolSettings.shadePict);
01289        dc.setAttribute("PICTSCX",m_Doc->toolSettings.scaleX);
01290        dc.setAttribute("PICTSCY",m_Doc->toolSettings.scaleY);
01291        dc.setAttribute("PSCALE", static_cast<int>(m_Doc->toolSettings.scaleType));
01292        dc.setAttribute("PASPECT", static_cast<int>(m_Doc->toolSettings.aspectRatio));
01293        dc.setAttribute("EmbeddedPath", static_cast<int>(m_Doc->toolSettings.useEmbeddedPath));
01294        dc.setAttribute("HalfRes", m_Doc->toolSettings.lowResType);
01295        dc.setAttribute("MINORC",m_Doc->guidesSettings.minorColor.name());
01296        dc.setAttribute("MAJORC",m_Doc->guidesSettings.majorColor.name());
01297        dc.setAttribute("GuideC", m_Doc->guidesSettings.guideColor.name());
01298        dc.setAttribute("BaseC", m_Doc->guidesSettings.baseColor.name());
01299        dc.setAttribute("GuideZ", m_Doc->guidesSettings.guideRad);
01300        dc.setAttribute("BACKG", static_cast<int>(m_Doc->guidesSettings.before));
01301        dc.setAttribute("PAGEC",m_Doc->papColor.name());
01302        dc.setAttribute("MARGC",m_Doc->guidesSettings.margColor.name());
01303        dc.setAttribute("RANDF", static_cast<int>(m_Doc->marginColored));
01304        dc.setAttribute("currentProfile", m_Doc->curCheckProfile);
01305        CheckerPrefsList::Iterator itcp;
01306        CheckerPrefsList::Iterator itcpend=m_Doc->checkerProfiles.end();
01307        for (itcp = m_Doc->checkerProfiles.begin(); itcp != itcpend; ++itcp)
01308        {
01309               QDomElement dc79a=docu.createElement("CheckProfile");
01310               dc79a.setAttribute("Name",itcp.key());
01311               dc79a.setAttribute("ignoreErrors", static_cast<int>(itcp.data().ignoreErrors));
01312               dc79a.setAttribute("autoCheck", static_cast<int>(itcp.data().autoCheck));
01313               dc79a.setAttribute("checkGlyphs", static_cast<int>(itcp.data().checkGlyphs));
01314               dc79a.setAttribute("checkOrphans", static_cast<int>(itcp.data().checkOrphans));
01315               dc79a.setAttribute("checkOverflow", static_cast<int>(itcp.data().checkOverflow));
01316               dc79a.setAttribute("checkPictures", static_cast<int>(itcp.data().checkPictures));
01317               dc79a.setAttribute("checkResolution", static_cast<int>(itcp.data().checkResolution));
01318               dc79a.setAttribute("checkTransparency", static_cast<int>(itcp.data().checkTransparency));
01319               dc79a.setAttribute("minResolution",itcp.data().minResolution);
01320               dc79a.setAttribute("maxResolution",itcp.data().maxResolution);
01321               dc79a.setAttribute("checkAnnotations", static_cast<int>(itcp.data().checkAnnotations));
01322               dc79a.setAttribute("checkRasterPDF", static_cast<int>(itcp.data().checkRasterPDF));
01323               dc79a.setAttribute("checkForGIF", static_cast<int>(itcp.data().checkForGIF));
01324               dc.appendChild(dc79a);
01325        }
01326        QMap<QString,multiLine>::Iterator itMU;
01327        for (itMU = m_Doc->MLineStyles.begin(); itMU != m_Doc->MLineStyles.end(); ++itMU)
01328        {
01329               QDomElement MuL=docu.createElement("MultiLine");
01330               MuL.setAttribute("Name",itMU.key());
01331               multiLine ml = itMU.data();
01332               multiLine::iterator itMU2;
01333               for (itMU2 = ml.begin(); itMU2 != ml.end(); ++itMU2)
01334               {
01335                      QDomElement SuL=docu.createElement("SubLine");
01336                      SuL.setAttribute("Color", (*itMU2).Color);
01337                      SuL.setAttribute("Shade", (*itMU2).Shade);
01338                      SuL.setAttribute("Dash", (*itMU2).Dash);
01339                      SuL.setAttribute("LineEnd", (*itMU2).LineEnd);
01340                      SuL.setAttribute("LineJoin", (*itMU2).LineJoin);
01341                      SuL.setAttribute("Width", (*itMU2).Width);
01342                      MuL.appendChild(SuL);
01343               }
01344               dc.appendChild(MuL);
01345        }
01346        QValueList<ArrowDesc>::Iterator itar;
01347        for (itar = m_Doc->arrowStyles.begin(); itar != m_Doc->arrowStyles.end(); ++itar)
01348        {
01349               if ((*itar).userArrow)
01350               {
01351                      QDomElement ar=docu.createElement("Arrows");
01352                      ar.setAttribute("NumPoints", (*itar).points.size());
01353                      QString arp = "";
01354                      QString tmp, tmpy;
01355                      double xa, ya;
01356                      for (uint nxx = 0; nxx < (*itar).points.size(); ++nxx)
01357                      {
01358                             (*itar).points.point(nxx, &xa, &ya);
01359                             arp += tmp.setNum(xa) + " " + tmpy.setNum(ya) + " ";
01360                      }
01361                      ar.setAttribute("Points", arp);
01362                      ar.setAttribute("Name", (*itar).name);
01363                      dc.appendChild(ar);
01364               }
01365        }
01366        QMap<QString,QString>::Iterator itja;
01367        for (itja = m_Doc->JavaScripts.begin(); itja != m_Doc->JavaScripts.end(); ++itja)
01368        {
01369               QDomElement jav=docu.createElement("JAVA");
01370               jav.setAttribute("NAME",itja.key());
01371               jav.setAttribute("SCRIPT",itja.data());
01372               dc.appendChild(jav);
01373        }
01374        QValueList<ScribusDoc::BookMa>::Iterator itbm;
01375        for (itbm = m_Doc->BookMarks.begin(); itbm != m_Doc->BookMarks.end(); ++itbm)
01376        {
01377               QDomElement fn=docu.createElement("Bookmark");
01378               fn.setAttribute("Title",(*itbm).Title);
01379               fn.setAttribute("Text",(*itbm).Text);
01380               fn.setAttribute("Aktion",(*itbm).Aktion);
01381               fn.setAttribute("ItemNr", (*itbm).ItemNr);
01382               fn.setAttribute("Element", (*itbm).PageObject->ItemNr);
01383               fn.setAttribute("First", (*itbm).First);
01384               fn.setAttribute("Last", (*itbm).Last);
01385               fn.setAttribute("Prev", (*itbm).Prev);
01386               fn.setAttribute("Next", (*itbm).Next);
01387               fn.setAttribute("Parent", (*itbm).Parent);
01388               dc.appendChild(fn);
01389        }
01390        ColorList::Iterator itc;
01391        for (itc = m_Doc->PageColors.begin(); itc != m_Doc->PageColors.end(); ++itc)
01392        {
01393               QDomElement co=docu.createElement("COLOR");
01394               co.setAttribute("NAME",itc.key());
01395               if (m_Doc->PageColors[itc.key()].getColorModel() == colorModelRGB)
01396                      co.setAttribute("RGB",m_Doc->PageColors[itc.key()].nameRGB());
01397               else
01398                      co.setAttribute("CMYK",m_Doc->PageColors[itc.key()].nameCMYK());
01399               co.setAttribute("Spot",static_cast<int>(m_Doc->PageColors[itc.key()].isSpotColor()));
01400               co.setAttribute("Register",static_cast<int>(m_Doc->PageColors[itc.key()].isRegistrationColor()));
01401               dc.appendChild(co);
01402        }
01403 //     if (m_Doc->docParagraphStyles.count() > 5)
01404        {
01405               for (uint ff = 0; ff < m_Doc->paragraphStyles().count(); ++ff)
01406               {
01407                      QDomElement fo=docu.createElement("STYLE");
01408                      fo.setAttribute("NAME",m_Doc->paragraphStyles()[ff].name());
01409                      fo.setAttribute("ALIGN",m_Doc->paragraphStyles()[ff].alignment());
01410                      fo.setAttribute("LINESPMode",m_Doc->paragraphStyles()[ff].lineSpacingMode());
01411                      fo.setAttribute("LINESP",m_Doc->paragraphStyles()[ff].lineSpacing());
01412                      fo.setAttribute("INDENT",m_Doc->paragraphStyles()[ff].leftMargin());
01413                      fo.setAttribute("RMARGIN",m_Doc->paragraphStyles()[ff].rightMargin());
01414                      fo.setAttribute("FIRST",m_Doc->paragraphStyles()[ff].firstIndent());
01415                      fo.setAttribute("VOR",m_Doc->paragraphStyles()[ff].gapBefore());
01416                      fo.setAttribute("NACH",m_Doc->paragraphStyles()[ff].gapAfter());
01417                      fo.setAttribute("FONT",m_Doc->paragraphStyles()[ff].charStyle().font().scName());
01418                      fo.setAttribute("FONTSIZE",m_Doc->paragraphStyles()[ff].charStyle().fontSize() / 10.0);
01419                      fo.setAttribute("DROP", static_cast<int>(m_Doc->paragraphStyles()[ff].hasDropCap()));
01420                      fo.setAttribute("DROPLIN", m_Doc->paragraphStyles()[ff].dropCapLines());
01421                      fo.setAttribute("DROPDIST", m_Doc->paragraphStyles()[ff].dropCapOffset());
01422                      fo.setAttribute("EFFECT", m_Doc->paragraphStyles()[ff].charStyle().effects());
01423                      if (m_Doc->paragraphStyles()[ff].tabValues().count() != 0)
01424                      {
01425                             for (uint a = 0; a < m_Doc->paragraphStyles()[ff].tabValues().count(); ++a)
01426                             {
01427                                    QDomElement tabs = docu.createElement("Tabs");
01428                                    tabs.setAttribute("Type", (*m_Doc->paragraphStyles()[ff].tabValues().at(a)).tabType);
01429                                    tabs.setAttribute("Pos", (*m_Doc->paragraphStyles()[ff].tabValues().at(a)).tabPosition);
01430                                    QString tabCh = "";
01431                                    if (!(*m_Doc->paragraphStyles()[ff].tabValues().at(a)).tabFillChar.isNull())
01432                                           tabCh = QString((*m_Doc->paragraphStyles()[ff].tabValues().at(a)).tabFillChar);
01433                                    tabs.setAttribute("Fill", tabCh);
01434                                    fo.appendChild(tabs);
01435                             }
01436                      }
01437                      fo.setAttribute("FCOLOR",m_Doc->paragraphStyles()[ff].charStyle().fillColor());
01438                      fo.setAttribute("FSHADE",m_Doc->paragraphStyles()[ff].charStyle().fillShade());
01439                      fo.setAttribute("SCOLOR",m_Doc->paragraphStyles()[ff].charStyle().strokeColor());
01440                      fo.setAttribute("SSHADE",m_Doc->paragraphStyles()[ff].charStyle().strokeShade());
01441                      fo.setAttribute("BASE", static_cast<int>(m_Doc->paragraphStyles()[ff].lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing));
01442                      fo.setAttribute("TXTSHX",m_Doc->paragraphStyles()[ff].charStyle().shadowXOffset() / 10.0);
01443                      fo.setAttribute("TXTSHY",m_Doc->paragraphStyles()[ff].charStyle().shadowYOffset() / 10.0);
01444                      fo.setAttribute("TXTOUT",m_Doc->paragraphStyles()[ff].charStyle().outlineWidth() / 10.0);
01445                      fo.setAttribute("TXTULP",m_Doc->paragraphStyles()[ff].charStyle().underlineOffset() / 10.0);
01446                      fo.setAttribute("TXTULW",m_Doc->paragraphStyles()[ff].charStyle().underlineWidth() / 10.0);
01447                      fo.setAttribute("TXTSTP",m_Doc->paragraphStyles()[ff].charStyle().strikethruOffset() / 10.0);
01448                      fo.setAttribute("TXTSTW",m_Doc->paragraphStyles()[ff].charStyle().strikethruWidth() / 10.0);
01449                      fo.setAttribute("SCALEH",m_Doc->paragraphStyles()[ff].charStyle().scaleH() / 10.0);
01450                      fo.setAttribute("SCALEV",m_Doc->paragraphStyles()[ff].charStyle().scaleV() / 10.0);
01451                      fo.setAttribute("BASEO",m_Doc->paragraphStyles()[ff].charStyle().baselineOffset() / 10.0);
01452                      fo.setAttribute("KERN",m_Doc->paragraphStyles()[ff].charStyle().tracking() / 10.0);
01453                      dc.appendChild(fo);
01454               }
01455        }
01456        uint layerCount=m_Doc->layerCount();
01457        for (uint lay = 0; lay < layerCount; ++lay)
01458        {
01459               QDomElement la = docu.createElement("LAYERS");
01460               la.setAttribute("NUMMER",m_Doc->Layers[lay].LNr);
01461               la.setAttribute("LEVEL",m_Doc->Layers[lay].Level);
01462               la.setAttribute("NAME",m_Doc->Layers[lay].Name);
01463               la.setAttribute("SICHTBAR", static_cast<int>(m_Doc->Layers[lay].isViewable));
01464               la.setAttribute("DRUCKEN", static_cast<int>(m_Doc->Layers[lay].isPrintable));
01465               la.setAttribute("EDIT", static_cast<int>(m_Doc->Layers[lay].isEditable));
01466               la.setAttribute("FLOW", static_cast<int>(m_Doc->Layers[lay].flowControl));
01467               la.setAttribute("TRANS", m_Doc->Layers[lay].transparency);
01468               la.setAttribute("BLEND", m_Doc->Layers[lay].blendMode);
01469               la.setAttribute("OUTL", static_cast<int>(m_Doc->Layers[lay].outlineMode));
01470               la.setAttribute("LAYERC",m_Doc->Layers[lay].markerColor.name());
01471               dc.appendChild(la);
01472        }
01473        QDomElement pdf = docu.createElement("PDF");
01474        pdf.setAttribute("Thumbnails", static_cast<int>(m_Doc->PDF_Options.Thumbnails));
01475        pdf.setAttribute("Articles", static_cast<int>(m_Doc->PDF_Options.Articles));
01476        pdf.setAttribute("Bookmarks", static_cast<int>(m_Doc->PDF_Options.Bookmarks));
01477        pdf.setAttribute("Compress", static_cast<int>(m_Doc->PDF_Options.Compress));
01478        pdf.setAttribute("CMethod", m_Doc->PDF_Options.CompressMethod);
01479        pdf.setAttribute("Quality", m_Doc->PDF_Options.Quality);
01480        pdf.setAttribute("MirrorH", static_cast<int>(m_Doc->PDF_Options.MirrorH));
01481        pdf.setAttribute("MirrorV", static_cast<int>(m_Doc->PDF_Options.MirrorV));
01482        pdf.setAttribute("Clip", static_cast<int>(m_Doc->PDF_Options.doClip));
01483        pdf.setAttribute("RotateDeg", static_cast<int>(m_Doc->PDF_Options.RotateDeg));
01484        pdf.setAttribute("PresentMode", static_cast<int>(m_Doc->PDF_Options.PresentMode));
01485        pdf.setAttribute("RecalcPic", static_cast<int>(m_Doc->PDF_Options.RecalcPic));
01486        pdf.setAttribute("Grayscale", static_cast<int>(m_Doc->PDF_Options.isGrayscale));
01487        pdf.setAttribute("RGBMode", static_cast<int>(m_Doc->PDF_Options.UseRGB));
01488        pdf.setAttribute("UseProfiles", static_cast<int>(m_Doc->PDF_Options.UseProfiles));
01489        pdf.setAttribute("UseProfiles2", static_cast<int>(m_Doc->PDF_Options.UseProfiles2));
01490        pdf.setAttribute("Binding", m_Doc->PDF_Options.Binding);
01491        pdf.setAttribute("PicRes", m_Doc->PDF_Options.PicRes);
01492        pdf.setAttribute("Resolution", m_Doc->PDF_Options.Resolution);
01493        pdf.setAttribute("Version", m_Doc->PDF_Options.Version);
01494        pdf.setAttribute("Intent", m_Doc->PDF_Options.Intent);
01495        pdf.setAttribute("Intent2", m_Doc->PDF_Options.Intent2);
01496        pdf.setAttribute("SolidP", m_Doc->PDF_Options.SolidProf);
01497        pdf.setAttribute("ImageP", m_Doc->PDF_Options.ImageProf);
01498        pdf.setAttribute("PrintP", m_Doc->PDF_Options.PrintProf);
01499        pdf.setAttribute("InfoString", m_Doc->PDF_Options.Info);
01500        pdf.setAttribute("BTop", m_Doc->PDF_Options.bleeds.Top);
01501        pdf.setAttribute("BLeft", m_Doc->PDF_Options.bleeds.Left);
01502        pdf.setAttribute("BRight", m_Doc->PDF_Options.bleeds.Right);
01503        pdf.setAttribute("BBottom", m_Doc->PDF_Options.bleeds.Bottom);
01504        pdf.setAttribute("ImagePr", static_cast<int>(m_Doc->PDF_Options.EmbeddedI));
01505        pdf.setAttribute("PassOwner", m_Doc->PDF_Options.PassOwner);
01506        pdf.setAttribute("PassUser", m_Doc->PDF_Options.PassUser);
01507        pdf.setAttribute("Permissions", m_Doc->PDF_Options.Permissions);
01508        pdf.setAttribute("Encrypt", static_cast<int>(m_Doc->PDF_Options.Encrypt));
01509        pdf.setAttribute("UseLayers", static_cast<int>(m_Doc->PDF_Options.useLayers));
01510        pdf.setAttribute("UseLpi", static_cast<int>(m_Doc->PDF_Options.UseLPI));
01511        pdf.setAttribute("UseSpotColors", static_cast<int>(m_Doc->PDF_Options.UseSpotColors));
01512        pdf.setAttribute("doOverprint", static_cast<int>(m_Doc->PDF_Options.doOverprint));
01513        pdf.setAttribute("doMultiFile", static_cast<int>(m_Doc->PDF_Options.doMultiFile));
01514        pdf.setAttribute("displayBookmarks", static_cast<int>(m_Doc->PDF_Options.displayBookmarks));
01515        pdf.setAttribute("displayFullscreen", static_cast<int>(m_Doc->PDF_Options.displayFullscreen));
01516        pdf.setAttribute("displayLayers", static_cast<int>(m_Doc->PDF_Options.displayLayers));
01517        pdf.setAttribute("displayThumbs", static_cast<int>(m_Doc->PDF_Options.displayThumbs));
01518        pdf.setAttribute("hideMenuBar", static_cast<int>(m_Doc->PDF_Options.hideMenuBar));
01519        pdf.setAttribute("hideToolBar", static_cast<int>(m_Doc->PDF_Options.hideToolBar));
01520        pdf.setAttribute("fitWindow", static_cast<int>(m_Doc->PDF_Options.fitWindow));
01521        pdf.setAttribute("PageLayout", m_Doc->PDF_Options.PageLayout);
01522        pdf.setAttribute("openAction", m_Doc->PDF_Options.openAction);
01523        for (uint pdoF = 0; pdoF < m_Doc->PDF_Options.EmbedList.count(); ++pdoF)
01524        {
01525               QDomElement pdf2 = docu.createElement("Fonts");
01526               pdf2.setAttribute("Name", m_Doc->PDF_Options.EmbedList[pdoF]);
01527               pdf.appendChild(pdf2);
01528        }
01529        for (uint pdoS = 0; pdoS < m_Doc->PDF_Options.SubsetList.count(); ++pdoS)
01530        {
01531               QDomElement pdf4 = docu.createElement("Subset");
01532               pdf4.setAttribute("Name", m_Doc->PDF_Options.SubsetList[pdoS]);
01533               pdf.appendChild(pdf4);
01534        }
01535        for (uint pdoE = 0; pdoE < m_Doc->PDF_Options.PresentVals.count(); ++pdoE)
01536        {
01537               QDomElement pdf3 = docu.createElement("Effekte");
01538               pdf3.setAttribute("pageEffectDuration", m_Doc->PDF_Options.PresentVals[pdoE].pageEffectDuration);
01539               pdf3.setAttribute("pageViewDuration", m_Doc->PDF_Options.PresentVals[pdoE].pageViewDuration);
01540               pdf3.setAttribute("effectType", m_Doc->PDF_Options.PresentVals[pdoE].effectType);
01541               pdf3.setAttribute("Dm", m_Doc->PDF_Options.PresentVals[pdoE].Dm);
01542               pdf3.setAttribute("M", m_Doc->PDF_Options.PresentVals[pdoE].M);
01543               pdf3.setAttribute("Di", m_Doc->PDF_Options.PresentVals[pdoE].Di);
01544               pdf.appendChild(pdf3);
01545        }
01546        QMap<QString,LPIData>::Iterator itlp;
01547        for (itlp = m_Doc->PDF_Options.LPISettings.begin(); itlp != m_Doc->PDF_Options.LPISettings.end(); ++itlp)
01548        {
01549               QDomElement pdf4 = docu.createElement("LPI");
01550               pdf4.setAttribute("Color", itlp.key());
01551               pdf4.setAttribute("Frequency", itlp.data().Frequency);
01552               pdf4.setAttribute("Angle", itlp.data().Angle);
01553               pdf4.setAttribute("SpotFunction", itlp.data().SpotFunc);
01554               pdf.appendChild(pdf4);
01555        }
01556        dc.appendChild(pdf);
01557        QDomElement docItemAttrs = docu.createElement("DocItemAttributes");
01558        for(ObjAttrVector::Iterator objAttrIt = m_Doc->docItemAttributes.begin() ; objAttrIt != m_Doc->docItemAttributes.end(); ++objAttrIt )
01559        {
01560               QDomElement itemAttr = docu.createElement("ItemAttribute");
01561               itemAttr.setAttribute("Name", (*objAttrIt).name);
01562               itemAttr.setAttribute("Type", (*objAttrIt).type);
01563               itemAttr.setAttribute("Value", (*objAttrIt).value);
01564               itemAttr.setAttribute("Parameter", (*objAttrIt).parameter);
01565               itemAttr.setAttribute("Relationship", (*objAttrIt).relationship);
01566               itemAttr.setAttribute("RelationshipTo", (*objAttrIt).relationshipto);
01567               itemAttr.setAttribute("AutoAddTo", (*objAttrIt).autoaddto);
01568               docItemAttrs.appendChild(itemAttr);
01569        }
01570        dc.appendChild(docItemAttrs);
01571        QDomElement tocElem = docu.createElement("TablesOfContents");
01572        for(ToCSetupVector::Iterator tocSetupIt = m_Doc->docToCSetups.begin() ; tocSetupIt != m_Doc->docToCSetups.end(); ++tocSetupIt )
01573        {
01574               QDomElement tocsetup = docu.createElement("TableOfContents");
01575               tocsetup.setAttribute("Name", (*tocSetupIt).name);
01576               tocsetup.setAttribute("ItemAttributeName", (*tocSetupIt).itemAttrName);
01577               tocsetup.setAttribute("FrameName", (*tocSetupIt).frameName);
01578               tocsetup.setAttribute("ListNonPrinting", (*tocSetupIt).listNonPrintingFrames);
01579               tocsetup.setAttribute("Style", (*tocSetupIt).textStyle);
01580               switch ((*tocSetupIt).pageLocation)
01581               {
01582                      case Beginning:
01583                             tocsetup.setAttribute("NumberPlacement", "Beginning");
01584                             break;
01585                      case End:
01586                             tocsetup.setAttribute("NumberPlacement", "End");
01587                             break;
01588                      case NotShown:
01589                             tocsetup.setAttribute("NumberPlacement", "NotShown");
01590                             break;
01591               }
01592               tocElem.appendChild(tocsetup);
01593        }
01594        dc.appendChild(tocElem);
01595        QDomElement sectionElem = docu.createElement("Sections");
01596        for(DocumentSectionMap::Iterator it = m_Doc->sections.begin() ; it != m_Doc->sections.end(); ++it )
01597        {
01598               QDomElement currsection = docu.createElement("Section");
01599               currsection.setAttribute("Number", (*it).number);
01600               currsection.setAttribute("Name", (*it).name);
01601               currsection.setAttribute("From", (*it).fromindex);
01602               currsection.setAttribute("To", (*it).toindex);
01603               switch ((*it).type)
01604               {
01605                      case Type_1_2_3:
01606                             currsection.setAttribute("Type", "Type_1_2_3");
01607                             break;
01608                      case Type_i_ii_iii:
01609                             currsection.setAttribute("Type", "Type_i_ii_iii");
01610                             break;
01611                      case Type_I_II_III:
01612                             currsection.setAttribute("Type", "Type_I_II_III");
01613                             break;
01614                      case Type_a_b_c:
01615                             currsection.setAttribute("Type", "Type_a_b_c");
01616                             break;
01617                      case Type_A_B_C:
01618                             currsection.setAttribute("Type", "Type_A_B_C");
01619                             break;
01620                      case Type_None:
01621                             currsection.setAttribute("Type", "Type_None");
01622                             break;
01623               }
01624               currsection.setAttribute("Start", (*it).sectionstartindex);
01625               currsection.setAttribute("Reversed", (*it).reversed);
01626               currsection.setAttribute("Active", (*it).active);
01627               sectionElem.appendChild(currsection);
01628        }
01629        dc.appendChild(sectionElem);
01630 
01631        QDomElement pageSetAttr = docu.createElement("PageSets");
01632        QValueList<PageSet>::Iterator itpgset;
01633        for(itpgset = m_Doc->pageSets.begin(); itpgset != m_Doc->pageSets.end(); ++itpgset )
01634        {
01635               QDomElement pgst = docu.createElement("Set");
01636               pgst.setAttribute("Name", (*itpgset).Name);
01637               pgst.setAttribute("FirstPage", (*itpgset).FirstPage);
01638               pgst.setAttribute("Rows", (*itpgset).Rows);
01639               pgst.setAttribute("Columns", (*itpgset).Columns);
01640               pgst.setAttribute("GapHorizontal", (*itpgset).GapHorizontal);
01641               pgst.setAttribute("GapVertical", (*itpgset).GapVertical);
01642               pgst.setAttribute("GapBelow", (*itpgset).GapBelow);
01643               QStringList pNames = (*itpgset).pageNames;
01644               QStringList::Iterator itpgsetN;
01645               for(itpgsetN = pNames.begin(); itpgsetN != pNames.end(); ++itpgsetN )
01646               {
01647                      QDomElement pgstN = docu.createElement("PageNames");
01648                      pgstN.setAttribute("Name", (*itpgsetN));
01649                      pgst.appendChild(pgstN);
01650               }
01651               pageSetAttr.appendChild(pgst);
01652        }
01653        dc.appendChild(pageSetAttr);
01654        if (m_mwProgressBar != 0)
01655        {
01656               m_mwProgressBar->setTotalSteps(m_Doc->DocPages.count()+m_Doc->MasterPages.count()+m_Doc->DocItems.count()+m_Doc->MasterItems.count()+m_Doc->FrameItems.count());
01657               m_mwProgressBar->setProgress(0);
01658        }
01659        WritePages(m_Doc, &docu, &dc, m_mwProgressBar, 0, true);
01660        WritePages(m_Doc, &docu, &dc, m_mwProgressBar, m_Doc->MasterPages.count(), false);
01661        WriteObjects(m_Doc, &docu, &dc, m_mwProgressBar, m_Doc->MasterPages.count()+m_Doc->DocPages.count(), 2);
01662        WriteObjects(m_Doc, &docu, &dc, m_mwProgressBar, m_Doc->MasterPages.count()+m_Doc->DocPages.count()+m_Doc->FrameItems.count(), 0);
01663        WriteObjects(m_Doc, &docu, &dc, m_mwProgressBar, m_Doc->MasterPages.count()+m_Doc->DocPages.count()+m_Doc->MasterItems.count()+m_Doc->FrameItems.count(), 1);
01664        elem.appendChild(dc);
01671        QCString cs = docu.toCString(); // UTF-8 QCString
01672        if(fileName.right(2) == "gz")
01673        {
01674               // zipped saving
01675               // XXX: latin1() should probably be local8Bit()
01676               ScGzFile gzf(fileName, cs);
01677               if (!gzf.write())
01678                      return false;
01679        }
01680        else
01681        {
01682               QFile f(fileName);
01683               if(!f.open(IO_WriteOnly))
01684                      return false;
01685               QTextStream s(&f);
01686               s.writeRawBytes(cs, cs.length());
01687               f.close();
01688        }
01689        return true;
01690 }
01691 
01692 // Low level plugin API
01693 int scribus13format_getPluginAPIVersion()
01694 {
01695        return PLUGIN_API_VERSION;
01696 }
01697 
01698 ScPlugin* scribus13format_getPlugin()
01699 {
01700        Scribus13Format* plug = new Scribus13Format();
01701        Q_CHECK_PTR(plug);
01702        return plug;
01703 }
01704 
01705 void scribus13format_freePlugin(ScPlugin* plugin)
01706 {
01707        Scribus13Format* plug = dynamic_cast<Scribus13Format*>(plugin);
01708        Q_ASSERT(plug);
01709        delete plug;
01710 }
01711 
01712 /*
01713 const ScFace& Scribus13Format::findFont(ScribusDoc *doc, const QString& fontname)
01714 {
01715        if (fontname.isEmpty())
01716               return ScFace::none();
01717        
01718        PrefsManager* prefsManager=PrefsManager::instance();
01719        if (!(*m_AvailableFonts).contains(fontname) || !(*m_AvailableFonts)[fontname].usable())
01720        {
01721               if ((!prefsManager->appPrefs.GFontSub.contains(fontname)) || (!(*m_AvailableFonts)[prefsManager->appPrefs.GFontSub[fontname]].usable()))
01722               {
01723                      newReplacement = true;
01724                      ReplacedFonts.insert(fontname, doc->toolSettings.defFont);
01725               }
01726               else
01727                      ReplacedFonts.insert(fontname, prefsManager->appPrefs.GFontSub[fontname]);
01728               ScFace dummy = (*m_AvailableFonts)[ReplacedFonts[fontname]].mkReplacementFor(fontname, doc->DocName);
01729               (*m_AvailableFonts).insert(fontname, dummy);
01730        }
01731        else if ( !doc->UsedFonts.contains(fontname) )
01732        {
01733               doc->AddFont(fontname, qRound(doc->toolSettings.defSize / 10.0));
01734        }
01735        return (*m_AvailableFonts)[fontname];
01736 }
01737 */
01738 void Scribus13Format::GetItemText(QDomElement *it, ScribusDoc *doc, PageItem* obj, LastStyles* last, bool impo, bool VorLFound)
01739 {
01740        ScFace dummy = ScFace::none();
01741        QString tmp2, tmpf;
01742        CharStyle newStyle;
01743 
01744        tmp2 = it->attribute("CH");
01745        tmp2.replace(QRegExp("\r"), QChar(13));
01746        tmp2.replace(QRegExp("\n"), QChar(13));
01747        tmp2.replace(QRegExp("\t"), QChar(9));
01748        tmp2.replace(SpecialChars::OLD_NBHYPHEN, SpecialChars::NBHYPHEN);
01749        tmp2.replace(SpecialChars::OLD_NBSPACE, SpecialChars::NBSPACE);
01750        tmpf = it->attribute("CFONT", "");
01751 
01752        if (! tmpf.isEmpty() )
01753               newStyle.setFont(m_AvailableFonts->findFont(tmpf, doc));
01754 
01755        if (it->hasAttribute("CSIZE"))
01756               newStyle.setFontSize(qRound(it->attribute("CSIZE").toDouble() * 10));
01757        
01758        if (it->hasAttribute("CCOLOR"))
01759               newStyle.setFillColor(it->attribute("CCOLOR"));
01760 
01761        if (it->hasAttribute("CSHADE"))
01762               newStyle.setFillShade(it->attribute("CSHADE").toInt());
01763 
01764        QString fColor = newStyle.fillColor();
01765        int fShade = newStyle.fillShade();
01766        handleOldColorShade(doc, fColor, fShade);
01767        newStyle.setFillColor(fColor);
01768        newStyle.setFillShade(fShade);
01769        
01770        if (it->hasAttribute("CEXTRA"))
01771               newStyle.setTracking(qRound(it->attribute("CEXTRA").toDouble() / it->attribute("CSIZE").toDouble() * 1000.0));
01772        else if (it->hasAttribute("CKERN"))
01773               newStyle.setTracking(it->attribute("CKERN").toInt());
01774        
01775        if (it->hasAttribute("CSTYLE"))
01776               newStyle.setFeatures(static_cast<StyleFlag>(it->attribute("CSTYLE").toInt()).featureList());
01777 
01778        QString pstylename = it->attribute("PSTYLE", "");
01779        int calign = it->attribute("CALIGN", "-1").toInt();            
01780        
01781        int ab = it->attribute("CAB", "-1").toInt();
01782        if (ab >= 5) {
01783               pstylename = DoVorl[ab];
01784               calign = -1;
01785        }
01786        else if (ab >= 0) {
01787               pstylename = "";
01788               calign = ab;
01789        }
01790        
01791        if (it->hasAttribute("CSTROKE"))
01792               newStyle.setStrokeColor(it->attribute("CSTROKE", CommonStrings::None));
01793        
01794        if (it->hasAttribute("CSHADE2"))
01795               newStyle.setStrokeShade(it->attribute("CSHADE2", "100").toInt());
01796 
01797        QString sColor = newStyle.strokeColor();
01798        int sShade = newStyle.strokeShade();
01799        handleOldColorShade(doc, sColor, sShade);
01800        newStyle.setStrokeColor(sColor);
01801        newStyle.setStrokeShade(sShade);
01802        
01803        if (it->hasAttribute("CSCALE"))
01804               newStyle.setScaleH(QMIN(QMAX(qRound(it->attribute("CSCALE", "100").toDouble() * 10), 100), 4000));
01805        
01806        if (it->hasAttribute("CSCALEV"))
01807               newStyle.setScaleV(QMIN(QMAX(qRound(it->attribute("CSCALEV", "100").toDouble() * 10), 100), 4000));
01808        
01809        if (it->hasAttribute("CBASE"))
01810               newStyle.setBaselineOffset(qRound(it->attribute("CBASE", "0").toDouble() * 10));
01811 
01812        if (it->hasAttribute("CSHX"))
01813        newStyle.setShadowXOffset(qRound(it->attribute("CSHX", "5").toDouble() * 10));
01814 
01815        if (it->hasAttribute("CSHY"))
01816               newStyle.setShadowYOffset(qRound(it->attribute("CSHY", "-5").toDouble() * 10));
01817        
01818        if (it->hasAttribute("COUT"))
01819               newStyle.setOutlineWidth(qRound(it->attribute("COUT", "1").toDouble() * 10));
01820 
01821        if (it->hasAttribute("CULP"))
01822               newStyle.setUnderlineOffset(qRound(it->attribute("CULP", "-0.1").toDouble() * 10));
01823 
01824        if (it->hasAttribute("CULW"))
01825               newStyle.setUnderlineWidth(qRound(it->attribute("CULW", "-0.1").toDouble() * 10));
01826 
01827        
01828        if (it->hasAttribute("CSTP"))
01829               newStyle.setStrikethruOffset(qRound(it->attribute("CSTP", "-0.1").toDouble() * 10));
01830        
01831        if (it->hasAttribute("CSTW"))
01832               newStyle.setStrikethruWidth(qRound(it->attribute("CSTW", "-0.1").toDouble() * 10));
01833 
01834        int iobj = it->attribute("COBJ", "-1").toInt();
01835        for (uint cxx=0; cxx<tmp2.length(); ++cxx)
01836        {
01837               QChar ch = tmp2.at(cxx);           
01838               { // Legacy mode
01839                      if (ch == QChar(5))
01840                             ch = SpecialChars::PARSEP;
01841                      if (ch == QChar(4))
01842                             ch = SpecialChars::TAB;
01843               }
01844               
01845               if (impo && ab >= 0 && VorLFound)
01846                      last->ParaStyle = DoVorl[ab];
01847               else
01848                      last->ParaStyle = pstylename;
01849 
01850               int pos = obj->itemText.length();
01851               if (ch == SpecialChars::OBJECT) {
01852                      if (iobj != -1) {
01853                             obj->itemText.insertObject(pos, doc->FrameItems.at(iobj));
01854                      }
01855               }
01856               else {
01857                      obj->itemText.insertChars(pos, QString(ch));
01858               }
01859               if (newStyle != last->Style) {
01860 //                   qDebug(QString("new style at %1: %2 -> %3").arg(pos).arg(last->Style.asString()).arg(newStyle.asString()));
01861                      obj->itemText.applyCharStyle(last->StyleStart, pos-last->StyleStart, last->Style);
01862                      last->Style = newStyle;
01863                      last->StyleStart = pos;
01864               }
01865               if (ch == SpecialChars::PARSEP) {
01866                      ParagraphStyle pstyle;
01867                      pstyle.setParent( last->ParaStyle );
01868                      if (calign >= 0)
01869                             pstyle.setAlignment(static_cast<ParagraphStyle::AlignmentType>(calign));
01870 //                   qDebug(QString("par style at %1: %2/%3 (%4) calign %5").arg(pos).arg(pstyle.name()).arg(pstyle.parent()).arg(last->ParaStyle).arg(calign));
01871                      obj->itemText.applyStyle(pos, pstyle);
01872               }
01873        }
01874        obj->itemText.applyCharStyle(last->StyleStart, obj->itemText.length()-last->StyleStart, last->Style);
01875        ParagraphStyle pstyle;
01876        pstyle.setParent( last->ParaStyle );
01877        if (calign >= 0)
01878               pstyle.setAlignment(static_cast<ParagraphStyle::AlignmentType>(calign));
01879 //     qDebug(QString("par style at end: %1/%2 (%3) calign %4").arg(pstyle.name()).arg(pstyle.parent()).arg(last->ParaStyle).arg(calign));
01880        obj->itemText.applyStyle(obj->itemText.length()-1, pstyle);
01881        return;
01882 }
01883 
01884 
01885 void Scribus13Format::readParagraphStyle(ParagraphStyle& vg, const QDomElement& pg, ScribusDoc *doc)
01886 {
01887        vg.setName(pg.attribute("NAME"));
01888        vg.setLineSpacingMode(static_cast<ParagraphStyle::LineSpacingMode>(pg.attribute("LINESPMode", "0").toInt()));
01889        vg.setLineSpacing(pg.attribute("LINESP").toDouble());
01890        vg.setLeftMargin(pg.attribute("INDENT", "0").toDouble());
01891        if (pg.hasAttribute("RMARGIN"))
01892               vg.setRightMargin(pg.attribute("RMARGIN", "0").toDouble());
01893        else
01894               vg.setRightMargin(0);
01895        vg.setFirstIndent(pg.attribute("FIRST", "0").toDouble());
01896        vg.setAlignment(static_cast<ParagraphStyle::AlignmentType>(pg.attribute("ALIGN").toInt()));
01897        vg.setGapBefore(pg.attribute("VOR", "0").toDouble());
01898        vg.setGapAfter(pg.attribute("NACH", "0").toDouble());
01899        
01900        vg.charStyle().setFont(m_AvailableFonts->findFont(pg.attribute("FONT", doc->toolSettings.defFont), doc));
01901        vg.charStyle().setFontSize(qRound(pg.attribute("FONTSIZE", "12").toDouble() * 10.0));
01902        vg.setHasDropCap(static_cast<bool>(pg.attribute("DROP", "0").toInt()));
01903        vg.setDropCapLines(pg.attribute("DROPLIN", "2").toInt());
01904        vg.setDropCapOffset(pg.attribute("DROPDIST", "0").toDouble());
01905        vg.charStyle().setFeatures(static_cast<StyleFlag>(pg.attribute("EFFECT", "0").toInt()).featureList());
01906        QString fColor = pg.attribute("FCOLOR", doc->toolSettings.dBrush);
01907        int fShade = pg.attribute("FSHADE", "100").toInt();
01908        handleOldColorShade(doc, fColor, fShade);
01909        QString sColor = pg.attribute("SCOLOR", doc->toolSettings.dPen);
01910        int sShade = pg.attribute("SSHADE", "100").toInt();
01911        handleOldColorShade(doc, sColor, sShade);
01912        vg.charStyle().setFillColor(fColor);
01913        vg.charStyle().setFillShade(fShade);
01914        vg.charStyle().setStrokeColor(sColor);
01915        vg.charStyle().setStrokeShade(sShade);
01916        if (static_cast<bool>(pg.attribute("BASE", "0").toInt()))
01917               vg.setLineSpacingMode(ParagraphStyle::BaselineGridLineSpacing);
01918        vg.charStyle().setShadowXOffset(qRound(pg.attribute("TXTSHX", "5").toDouble() * 10));
01919        vg.charStyle().setShadowYOffset(qRound(pg.attribute("TXTSHY", "-5").toDouble() * 10));
01920        vg.charStyle().setOutlineWidth(qRound(pg.attribute("TXTOUT", "1").toDouble() * 10));
01921        vg.charStyle().setUnderlineOffset(qRound(pg.attribute("TXTULP", "-0.1").toDouble() * 10));
01922        vg.charStyle().setUnderlineWidth(qRound(pg.attribute("TXTULW", "-0.1").toDouble() * 10));
01923        vg.charStyle().setStrikethruOffset(qRound(pg.attribute("TXTSTP", "-0.1").toDouble() * 10));
01924        vg.charStyle().setStrikethruWidth(qRound(pg.attribute("TXTSTW", "-0.1").toDouble() * 10));
01925        vg.charStyle().setScaleH(qRound(pg.attribute("SCALEH", "100").toDouble() * 10));
01926        vg.charStyle().setScaleV(qRound(pg.attribute("SCALEV", "100").toDouble() * 10));
01927        vg.charStyle().setBaselineOffset(qRound(pg.attribute("BASEO", "0").toDouble() * 10));
01928        vg.charStyle().setTracking(qRound(pg.attribute("KERN", "0").toDouble() * 10));
01929 //            vg.tabValues().clear();
01930        if ((pg.hasAttribute("NUMTAB")) && (pg.attribute("NUMTAB", "0").toInt() != 0))
01931        {
01932               QValueList<ParagraphStyle::TabRecord> tbs;
01933               ParagraphStyle::TabRecord tb;
01934               QString tmp = pg.attribute("TABS");
01935               QTextStream tgv(&tmp, IO_ReadOnly);
01936               double xf, xf2;
01937               for (int cxv = 0; cxv < pg.attribute("NUMTAB", "0").toInt(); cxv += 2)
01938               {
01939                      tgv >> xf;
01940                      tgv >> xf2;
01941                      tb.tabPosition = xf2;
01942                      tb.tabType = static_cast<int>(xf);
01943                      tb.tabFillChar =  QChar();
01944                      tbs.append(tb);
01945               }
01946               vg.setTabValues(tbs);
01947               tmp = "";
01948        }
01949        else
01950        {
01951               QValueList<ParagraphStyle::TabRecord> tbs;
01952               vg.setTabValues(tbs);
01953               QDomNode IT = pg.firstChild();
01954               while(!IT.isNull())
01955               {
01956                      QDomElement it = IT.toElement();
01957                      if (it.tagName()=="Tabs")
01958                      {
01959                             ParagraphStyle::TabRecord tb;
01960                             tb.tabPosition = it.attribute("Pos").toDouble();
01961                             tb.tabType = it.attribute("Type").toInt();
01962                             QString tbCh = "";
01963                             tbCh = it.attribute("Fill","");
01964                             if (tbCh.isEmpty())
01965                                    tb.tabFillChar = QChar();
01966                             else
01967                                    tb.tabFillChar = tbCh[0];
01968                             tbs.append(tb);
01969                      }
01970 //                   vg.setTabValues(tbs);
01971                      IT=IT.nextSibling();
01972               }
01973               if (tbs.count() > 0)
01974                      vg.setTabValues(tbs);
01975        }
01976 }
01977 
01978 PageItem* Scribus13Format::PasteItem(QDomElement *obj, ScribusDoc *doc)
01979 {
01980        struct ImageLoadRequest loadingInfo;
01981        int z = 0;
01982        PageItem::ItemType pt = static_cast<PageItem::ItemType>(obj->attribute("PTYPE").toInt());
01983        double x = obj->attribute("XPOS").toDouble();
01984        double y = obj->attribute("YPOS").toDouble();
01985        double w = obj->attribute("WIDTH").toDouble();
01986        double h = obj->attribute("HEIGHT").toDouble();
01987        double pw = obj->attribute("PWIDTH").toDouble();
01988        double scx = obj->attribute("LOCALSCX").toDouble();
01989        double scy = obj->attribute("LOCALSCY").toDouble();
01990        QString Pcolor = obj->attribute("PCOLOR");
01991        QString Pcolor2 = obj->attribute("PCOLOR2");
01992        int Pshade = obj->attribute("SHADE").toInt();
01993        int Pshade2= obj->attribute("SHADE2").toInt();
01994        handleOldColorShade(doc, Pcolor, Pshade);
01995        handleOldColorShade(doc, Pcolor2, Pshade2);
01996        QColor tmpc;
01997        PageItem *currItem=NULL;
01998        QString tmp;
01999        int xi;
02000        double xf, yf, xf2;
02001        QString clPath;
02002        QDomNode IT;
02003        switch (pt)
02004        {
02005        // OBSOLETE CR 2005-02-06
02006        case PageItem::ItemType1:
02007               z = doc->itemAdd(PageItem::Polygon, PageItem::Ellipse, x, y, w, h, pw, Pcolor, Pcolor2, true);
02008               currItem = doc->Items->at(z);
02009               break;
02010        //
02011        case PageItem::ImageFrame:
02012               z = doc->itemAdd(PageItem::ImageFrame, PageItem::Unspecified, x, y, w, h, 1, doc->toolSettings.dBrushPict, CommonStrings::None, true);
02013               currItem = doc->Items->at(z);
02014               currItem->setImageXYScale(scx, scy);
02015               currItem->setImageXYOffset(obj->attribute("LOCALX").toDouble(), obj->attribute("LOCALY").toDouble());
02016               currItem->Pfile = obj->attribute("PFILE");
02017               currItem->IProfile = obj->attribute("PRFILE","");
02018               currItem->EmProfile = obj->attribute("EPROF","");
02019               currItem->IRender = obj->attribute("IRENDER", "1").toInt();
02020               currItem->UseEmbedded = obj->attribute("EMBEDDED", "1").toInt();
02021               currItem->pixm.imgInfo.lowResType = obj->attribute("ImageRes", "1").toInt();
02022               IT = obj->firstChild();
02023               while(!IT.isNull())
02024               {
02025                      QDomElement it = IT.toElement();
02026                      if (it.tagName()=="ImageEffect")
02027                      {
02028                             struct ScImage::imageEffect ef;
02029                             ef.effectParameters = it.attribute("Param");
02030                             ef.effectCode = it.attribute("Code").toInt();
02031                             currItem->effectsInUse.append(ef);
02032                      }
02033                      IT=IT.nextSibling();
02034               }
02035               if (!currItem->Pfile.isEmpty())
02036                      doc->loadPict(currItem->Pfile, currItem, false);
02037               currItem->IProfile = obj->attribute("PRFILE","");
02038               currItem->EmProfile = obj->attribute("EPROF","");
02039               currItem->IRender = obj->attribute("IRENDER", "1").toInt();
02040               currItem->UseEmbedded = obj->attribute("EMBEDDED", "1").toInt();
02041               currItem->setImageXYScale(scx, scy);
02042               clPath = obj->attribute("ImageClip", "");
02043               if (currItem->pixm.imgInfo.PDSpathData.contains(clPath))
02044               {
02045                      currItem->imageClip = currItem->pixm.imgInfo.PDSpathData[clPath].copy();
02046                      currItem->pixm.imgInfo.usedPath = clPath;
02047                      QWMatrix cl;
02048                      cl.translate(currItem->imageXOffset()*currItem->imageXScale(), currItem->imageYOffset()*currItem->imageYScale());
02049                      cl.scale(currItem->imageXScale(), currItem->imageYScale());
02050                      currItem->imageClip.map(cl);
02051               }
02052               currItem->setImageShown(obj->attribute("PICART").toInt());
02053 /*            currItem->BBoxX = obj->attribute("BBOXX").toDouble();
02054               currItem->BBoxH = obj->attribute("BBOXH").toDouble(); */
02055               currItem->ScaleType = obj->attribute("SCALETYPE", "1").toInt();
02056               currItem->AspectRatio = obj->attribute("RATIO", "0").toInt();
02057               currItem->setLineWidth(pw);
02058               if (currItem->pixm.imgInfo.layerInfo.count() != 0)
02059               {
02060                      bool found = false;
02061                      IT = obj->firstChild();
02062                      while(!IT.isNull())
02063                      {
02064                             QDomElement it = IT.toElement();
02065                             if (it.tagName() == "PSDLayer")
02066                             {
02067                                    found = true;
02068                                    loadingInfo.blend = it.attribute("Blend");
02069                                    loadingInfo.opacity = it.attribute("Opacity").toInt();
02070                                    loadingInfo.visible = static_cast<bool>(it.attribute("Visible").toInt());
02071                                    loadingInfo.useMask = static_cast<bool>(it.attribute("useMask", "1").toInt());
02072                                    currItem->pixm.imgInfo.RequestProps.insert(it.attribute("Layer").toInt(), loadingInfo);
02073                             }
02074                             IT=IT.nextSibling();
02075                      }
02076                      if (found)
02077                      {
02078                             currItem->pixm.imgInfo.isRequest = true;
02079                             doc->loadPict(currItem->Pfile, currItem, true);
02080                      }
02081               }
02082               break;
02083        // OBSOLETE CR 2005-02-06
02084        case PageItem::ItemType3:
02085               z = doc->itemAdd(PageItem::Polygon, PageItem::Rectangle, x, y, w, h, pw, Pcolor, Pcolor2, true);
02086               currItem = doc->Items->at(z);
02087               break;
02088        //
02089        case PageItem::PathText:
02090               z = doc->itemAdd(PageItem::PathText, PageItem::Unspecified, x, y, w, h, pw, CommonStrings::None, Pcolor, true);
02091               currItem = doc->Items->at(z);
02092               if ((obj->attribute("ANNOTATION", "0").toInt()) && (static_cast<bool>(obj->attribute("ANICON", "0").toInt())))
02093               {
02094                      currItem->setImageXYScale(scx, scy);
02095                      currItem->setImageXYOffset(obj->attribute("LOCALX").toDouble(), obj->attribute("LOCALY").toDouble());
02096                      currItem->Pfile = obj->attribute("PFILE");
02097                      currItem->Pfile2 = obj->attribute("PFILE2","");
02098                      currItem->Pfile3 = obj->attribute("PFILE3","");
02099                      currItem->IProfile = obj->attribute("PRFILE","");
02100                      currItem->EmProfile = obj->attribute("EPROF","");
02101                      currItem->IRender = obj->attribute("IRENDER", "1").toInt();
02102                      currItem->UseEmbedded = obj->attribute("EMBEDDED", "1").toInt();
02103                      doc->LoadPict(currItem->Pfile, z);
02104                      currItem->setImageXYScale(scx, scy);
02105                      currItem->setImageShown(obj->attribute("PICART").toInt());
02106 /*                   currItem->BBoxX = obj->attribute("BBOXX").toDouble();
02107                      currItem->BBoxH = obj->attribute("BBOXH").toDouble(); */
02108                      currItem->ScaleType = obj->attribute("SCALETYPE", "1").toInt();
02109                      currItem->AspectRatio = obj->attribute("RATIO", "0").toInt();
02110               }
02111               //currItem->convertTo(pt);
02112               break;
02113        case PageItem::TextFrame:
02114               z = doc->itemAdd(PageItem::TextFrame, PageItem::Unspecified, x, y, w, h, pw, CommonStrings::None, Pcolor, true);
02115               currItem = doc->Items->at(z);
02116               if ((obj->attribute("ANNOTATION", "0").toInt()) && (static_cast<bool>(obj->attribute("ANICON", "0").toInt())))
02117               {
02118                      currItem->setImageXYScale(scx, scy);
02119                      currItem->setImageXYOffset(obj->attribute("LOCALX").toDouble(), obj->attribute("LOCALY").toDouble());
02120                      currItem->Pfile = obj->attribute("PFILE");
02121                      currItem->Pfile2 = obj->attribute("PFILE2","");
02122                      currItem->Pfile3 = obj->attribute("PFILE3","");
02123                      currItem->IProfile = obj->attribute("PRFILE","");
02124                      currItem->EmProfile = obj->attribute("EPROF","");
02125                      currItem->IRender = obj->attribute("IRENDER", "1").toInt();
02126                      currItem->UseEmbedded = obj->attribute("EMBEDDED", "1").toInt();
02127                      doc->LoadPict(currItem->Pfile, z);
02128                      currItem->setImageXYScale(scx, scy);
02129                      currItem->setImageShown(obj->attribute("PICART").toInt());
02130 /*                   currItem->BBoxX = obj->attribute("BBOXX").toDouble();
02131                      currItem->BBoxH = obj->attribute("BBOXH").toDouble(); */
02132                      currItem->ScaleType = obj->attribute("SCALETYPE", "1").toInt();
02133                      currItem->AspectRatio = obj->attribute("RATIO", "0").toInt();
02134               }
02135                      //currItem->convertTo(pt);
02136               break;
02137        case PageItem::Line:
02138               z = doc->itemAdd(PageItem::Line, PageItem::Unspecified, x, y, w, h, pw, CommonStrings::None, Pcolor2, true);
02139               currItem = doc->Items->at(z);
02140               break;
02141        case PageItem::Polygon:
02142               z = doc->itemAdd(PageItem::Polygon, PageItem::Unspecified, x, y, w, h, pw, Pcolor, Pcolor2, true);
02143               currItem = doc->Items->at(z);
02144               break;
02145        case PageItem::PolyLine:
02146               z = doc->itemAdd(PageItem::PolyLine, PageItem::Unspecified, x, y, w, h, pw, Pcolor, Pcolor2, true);
02147               currItem = doc->Items->at(z);
02148               break;
02149        case PageItem::Multiple:
02150               Q_ASSERT(false);
02151               break;
02152        }
02153        currItem->FrameType = obj->attribute("FRTYPE", "0").toInt();
02154        int startArrowIndex = obj->attribute("startArrowIndex", "0").toInt();
02155        if ((startArrowIndex < 0) || (startArrowIndex > static_cast<int>(doc->arrowStyles.size())))
02156        {
02157               qDebug(QString("scribus13format: invalid arrow index: %").arg(startArrowIndex));
02158               startArrowIndex = 0;
02159        }
02160        currItem->setStartArrowIndex(startArrowIndex);
02161        int endArrowIndex = obj->attribute("endArrowIndex", "0").toInt();
02162        if ((endArrowIndex < 0) || (endArrowIndex > static_cast<int>(doc->arrowStyles.size())))
02163        {
02164               qDebug(QString("scribus13format: invalid arrow index: %").arg(endArrowIndex));
02165               endArrowIndex = 0;
02166        }
02167        currItem->setEndArrowIndex(endArrowIndex);
02168        currItem->NamedLStyle = obj->attribute("NAMEDLST", "");
02169        currItem->isBookmark = obj->attribute("BOOKMARK").toInt();
02170        if ((currItem->isBookmark) && (doc->BookMarks.count() == 0))
02171               doc->OldBM = true;
02172        currItem->setImageFlippedH(obj->attribute("FLIPPEDH").toInt());
02173        currItem->setImageFlippedV(obj->attribute("FLIPPEDV").toInt());
02174        currItem->setCornerRadius(obj->attribute("RADRECT", "0").toDouble());
02175        currItem->ClipEdited = obj->attribute("CLIPEDIT", "0").toInt();
02176        currItem->setFillColor(Pcolor);
02177        currItem->setLineColor(Pcolor2);
02178        currItem->setFillShade(Pshade);
02179        currItem->setLineShade(Pshade2);
02180        ParagraphStyle pstyle;
02181        pstyle.setLineSpacing(obj->attribute("LINESP").toDouble());
02182        pstyle.setLineSpacingMode(static_cast<ParagraphStyle::LineSpacingMode>(obj->attribute("LINESPMode", "0").toInt()));
02183        int align = obj->attribute("ALIGN", "-1").toInt();
02184        if (align >= 5)
02185               pstyle.setParent(DoVorl[align-5]);
02186        else if (align >= 0)
02187               pstyle.setAlignment(static_cast<ParagraphStyle::AlignmentType>(align));
02188        pstyle.charStyle().setFont(m_AvailableFonts->findFont(obj->attribute("IFONT", m_Doc->toolSettings.defFont), m_Doc));
02189        pstyle.charStyle().setFontSize(qRound(obj->attribute("ISIZE", "12").toDouble() * 10));
02190        pstyle.charStyle().setStrokeColor(obj->attribute("TXTSTROKE", CommonStrings::None));
02191        pstyle.charStyle().setFillColor(obj->attribute("TXTFILL", "Black"));
02192        pstyle.charStyle().setStrokeShade(obj->attribute("TXTSTRSH", "100").toInt());
02193        pstyle.charStyle().setFillShade(obj->attribute("TXTFILLSH", "100").toInt());
02194        pstyle.charStyle().setScaleH(qRound(obj->attribute("TXTSCALE", "100").toDouble() * 10));
02195        pstyle.charStyle().setScaleV(qRound(obj->attribute("TXTSCALEV", "100").toDouble() * 10));
02196        pstyle.charStyle().setBaselineOffset(qRound(obj->attribute("TXTBASE", "0").toDouble() * 10));
02197        pstyle.charStyle().setShadowXOffset(qRound(obj->attribute("TXTSHX", "5").toDouble() * 10));
02198        pstyle.charStyle().setShadowYOffset(qRound(obj->attribute("TXTSHY", "-5").toDouble() * 10));
02199        pstyle.charStyle().setOutlineWidth(qRound(obj->attribute("TXTOUT", "1").toDouble() * 10));
02200        pstyle.charStyle().setUnderlineOffset(qRound(obj->attribute("TXTULP", "-0.1").toDouble() * 10));
02201        pstyle.charStyle().setUnderlineWidth(qRound(obj->attribute("TXTULW", "-0.1").toDouble() * 10));
02202        pstyle.charStyle().setStrikethruOffset(qRound(obj->attribute("TXTSTP", "-0.1").toDouble() * 10));
02203        pstyle.charStyle().setStrikethruWidth(qRound(obj->attribute("TXTSTW", "-0.1").toDouble() * 10));
02204        if (obj->hasAttribute("EXTRAV"))
02205               pstyle.charStyle().setTracking(qRound(obj->attribute("EXTRAV", "0").toDouble() / obj->attribute("ISIZE", "12").toDouble() * 10000.0));
02206        else 
02207               pstyle.charStyle().setTracking(qRound(obj->attribute("TXTKERN", "0").toDouble() * 10));
02208        pstyle.charStyle().setFeatures(static_cast<StyleFlag>(obj->attribute("TXTSTYLE", "0").toInt()).featureList());
02209        tmp = "";
02210        QValueList<ParagraphStyle::TabRecord> tbValues;
02211        if ((obj->hasAttribute("NUMTAB")) && (obj->attribute("NUMTAB", "0").toInt() != 0))
02212        {
02213               ParagraphStyle::TabRecord tb;
02214               tmp = obj->attribute("TABS");
02215               QTextStream tgv(&tmp, IO_ReadOnly);
02216               for (int cxv = 0; cxv < obj->attribute("NUMTAB", "0").toInt(); cxv += 2)
02217               {
02218                      tgv >> xf;
02219                      tgv >> xf2;
02220                      tb.tabPosition = xf2;
02221                      tb.tabType = static_cast<int>(xf);
02222                      tb.tabFillChar = QChar();
02223                      tbValues.append(tb);
02224               }
02225               tmp = "";
02226        }
02227        else
02228        {
02229               IT = obj->firstChild();
02230               while(!IT.isNull())
02231               {
02232                      QDomElement it = IT.toElement();
02233                      if (it.tagName()=="Tabs")
02234                      {
02235                             ParagraphStyle::TabRecord tb;
02236                             tb.tabPosition = it.attribute("Pos").toDouble();
02237                             tb.tabType = it.attribute("Type").toInt();
02238                             QString tbCh = "";
02239                             tbCh = it.attribute("Fill","");
02240                             if (tbCh.isEmpty())
02241                                    tb.tabFillChar = QChar();
02242                             else
02243                                    tb.tabFillChar = tbCh[0];
02244                             tbValues.append(tb);
02245                      }
02246                      IT=IT.nextSibling();
02247               }
02248        }
02249        if (tbValues.size() > 0)
02250               pstyle.setTabValues(tbValues);
02251        //FIXME: what if linked frames have different styles?
02252        currItem->itemText.setDefaultStyle(pstyle);
02253 
02254        currItem->setRotation(obj->attribute("ROT").toDouble());
02255        currItem->setTextToFrameDist(obj->attribute("EXTRA").toDouble(),
02256                                                         obj->attribute("REXTRA", "1").toDouble(),
02257                                                         obj->attribute("TEXTRA", "1").toDouble(),
02258                                                         obj->attribute("BEXTRA", "1").toDouble());
02259 
02260        currItem->PLineArt = Qt::PenStyle(obj->attribute("PLINEART").toInt());
02261        currItem->PLineEnd = Qt::PenCapStyle(obj->attribute("PLINEEND", "0").toInt());
02262        currItem->PLineJoin = Qt::PenJoinStyle(obj->attribute("PLINEJOIN", "0").toInt());
02263        currItem->setPrintEnabled(obj->attribute("PRINTABLE").toInt());
02264        currItem->setIsAnnotation(obj->attribute("ANNOTATION", "0").toInt());
02265        currItem->annotation().setType(obj->attribute("ANTYPE", "0").toInt());
02266        QString AnName = obj->attribute("ANNAME","");
02267        if (!AnName.isEmpty())
02268        {
02269               if (currItem->itemName() == AnName)
02270                      currItem->AutoName = true;
02271               else
02272               {
02273                      currItem->setItemName(AnName);
02274                      currItem->AutoName = false;
02275               }
02276        }
02277        currItem->annotation().setAction(obj->attribute("ANACTION",""));
02278        currItem->annotation().setE_act(obj->attribute("ANEACT",""));
02279        currItem->annotation().setX_act(obj->attribute("ANXACT",""));
02280        currItem->annotation().setD_act(obj->attribute("ANDACT",""));
02281        currItem->annotation().setFo_act(obj->attribute("ANFOACT",""));
02282        currItem->annotation().setBl_act(obj->attribute("ANBLACT",""));
02283        currItem->annotation().setK_act(obj->attribute("ANKACT",""));
02284        currItem->annotation().setF_act(obj->attribute("ANFACT",""));
02285        currItem->annotation().setV_act(obj->attribute("ANVACT",""));
02286        currItem->annotation().setC_act(obj->attribute("ANCACT",""));
02287        currItem->annotation().setActionType(obj->attribute("ANACTYP", "0").toInt());
02288        currItem->annotation().setExtern(obj->attribute("ANEXTERN",""));
02289        if ((!currItem->annotation().Extern().isEmpty()) && (currItem->annotation().ActionType() != 8))
02290        {
02291               QFileInfo efp(currItem->annotation().Extern());
02292               currItem->annotation().setExtern(efp.absFilePath());
02293        }
02294        currItem->annotation().setZiel(obj->attribute("ANZIEL", "0").toInt());
02295        currItem->annotation().setToolTip(obj->attribute("ANTOOLTIP",""));
02296        currItem->annotation().setRollOver(obj->attribute("ANROLL",""));
02297        currItem->annotation().setDown(obj->attribute("ANDOWN",""));
02298        currItem->annotation().setBwid(obj->attribute("ANBWID", "1").toInt());
02299        currItem->annotation().setBsty(obj->attribute("ANBSTY", "0").toInt());
02300        currItem->annotation().setFeed(obj->attribute("ANFEED", "1").toInt());
02301        currItem->annotation().setFlag(obj->attribute("ANFLAG", "0").toInt());
02302        currItem->annotation().setFont(obj->attribute("ANFONT", "4").toInt());
02303        currItem->annotation().setFormat(obj->attribute("ANFORMAT", "0").toInt());
02304        currItem->annotation().setVis(obj->attribute("ANVIS", "0").toInt());
02305        currItem->annotation().setIsChk(static_cast<bool>(obj->attribute("ANCHK", "0").toInt()));
02306        currItem->annotation().setAAact(static_cast<bool>(obj->attribute("ANAA", "0").toInt()));
02307        currItem->annotation().setHTML(static_cast<bool>(obj->attribute("ANHTML", "0").toInt()));
02308        currItem->annotation().setUseIcons(static_cast<bool>(obj->attribute("ANICON", "0").toInt()));
02309        currItem->annotation().setChkStil(obj->attribute("ANCHKS", "0").toInt());
02310        currItem->annotation().setMaxChar(obj->attribute("ANMC", "-1").toInt());
02311        currItem->annotation().setBorderColor(obj->attribute("ANBCOL", CommonStrings::None));
02312        currItem->annotation().setIPlace(obj->attribute("ANPLACE", "1").toInt());
02313        currItem->annotation().setScaleW(obj->attribute("ANSCALE", "0").toInt());
02314        currItem->TopLine = static_cast<bool>(obj->attribute("TopLine", "0").toInt());
02315        currItem->LeftLine = static_cast<bool>(obj->attribute("LeftLine", "0").toInt());
02316        currItem->RightLine = static_cast<bool>(obj->attribute("RightLine", "0").toInt());
02317        currItem->BottomLine = static_cast<bool>(obj->attribute("BottomLine", "0").toInt());
02318        currItem->isTableItem = static_cast<bool>(obj->attribute("isTableItem", "0").toInt());
02319        currItem->TopLinkID =  obj->attribute("TopLINK", "-1").toInt();
02320        currItem->LeftLinkID =  obj->attribute("LeftLINK", "-1").toInt();
02321        currItem->RightLinkID =  obj->attribute("RightLINK", "-1").toInt();
02322        currItem->BottomLinkID =  obj->attribute("BottomLINK", "-1").toInt();
02323        currItem->PoShow = obj->attribute("PLTSHOW", "0").toInt();
02324        currItem->BaseOffs = obj->attribute("BASEOF", "0").toDouble();
02325        if ( obj->hasAttribute("TEXTFLOWMODE") )
02326               currItem->setTextFlowMode((PageItem::TextFlowMode) obj->attribute("TEXTFLOWMODE", "0").toInt());
02327        else if ( obj->attribute("TEXTFLOW").toInt() )
02328        {
02329               if (obj->attribute("TEXTFLOW2", "0").toInt())
02330                      currItem->setTextFlowMode(PageItem::TextFlowUsesBoundingBox);
02331               else if (obj->attribute("TEXTFLOW3", "0").toInt())
02332                      currItem->setTextFlowMode(PageItem::TextFlowUsesContourLine);
02333               else
02334                      currItem->setTextFlowMode(PageItem::TextFlowUsesFrameShape);   
02335        }
02336        else
02337               currItem->setTextFlowMode(PageItem::TextFlowDisabled);
02338        currItem->DashOffset = obj->attribute("DASHOFF", "0.0").toDouble();
02339        currItem->setReversed(static_cast<bool>(obj->attribute("REVERS", "0").toInt()));
02340        currItem->setLocked(static_cast<bool>(obj->attribute("LOCK", "0").toInt()));
02341        currItem->setSizeLocked(static_cast<bool>(obj->attribute("LOCKR", "0").toInt()));
02342        currItem->setFillTransparency(obj->attribute("TransValue", "0.0").toDouble());
02343        currItem->fillRule = static_cast<bool>(obj->attribute("fillRule", "1").toInt());
02344        currItem->doOverprint = static_cast<bool>(obj->attribute("doOverprint", "0").toInt());
02345        if (obj->hasAttribute("TransValueS"))
02346               currItem->setLineTransparency(obj->attribute("TransValueS", "0.0").toDouble());
02347        else
02348               currItem->setLineTransparency(obj->attribute("TransValue", "0.0").toDouble());
02349        currItem->setFillBlendmode(0);
02350        currItem->setLineBlendmode(0);
02351        if (obj->attribute("TRANSPARENT", "0").toInt() == 1)
02352               currItem->setFillColor(CommonStrings::None);
02353        currItem->Cols = obj->attribute("COLUMNS", "1").toInt();
02354        currItem->ColGap = obj->attribute("COLGAP", "0.0").toDouble();
02355        if (obj->attribute("LAYER", "0").toInt() != -1)
02356               currItem->LayerNr = obj->attribute("LAYER", "0").toInt();
02357        tmp = "";
02358        if ((obj->hasAttribute("GROUPS")) && (obj->attribute("NUMGROUP", "0").toInt() != 0))
02359        {
02360               tmp = obj->attribute("GROUPS");
02361               QTextStream fg(&tmp, IO_ReadOnly);
02362               currItem->Groups.clear();
02363               for (int cx = 0; cx < obj->attribute("NUMGROUP", "0").toInt(); ++cx)
02364               {
02365                      fg >> xi;
02366                      currItem->Groups.push(xi);
02367               }
02368               tmp = "";
02369        }
02370        else
02371               currItem->Groups.clear();
02372        if ((obj->hasAttribute("NUMDASH")) && (obj->attribute("NUMDASH", "0").toInt() != 0))
02373        {
02374               tmp = obj->attribute("DASHS");
02375               QTextStream dgv(&tmp, IO_ReadOnly);
02376               currItem->DashValues.clear();
02377               for (int cxv = 0; cxv < obj->attribute("NUMDASH", "0").toInt(); ++cxv)
02378               {
02379                      dgv >> xf;
02380                      currItem->DashValues.append(xf);
02381               }
02382               tmp = "";
02383        }
02384        else
02385               currItem->DashValues.clear();
02386        tmp = "";
02387        if (obj->hasAttribute("NUMPO"))
02388        {
02389               currItem->PoLine.resize(obj->attribute("NUMPO").toUInt());
02390               tmp = obj->attribute("POCOOR");
02391               QTextStream fp(&tmp, IO_ReadOnly);
02392               for (uint cx=0; cx<obj->attribute("NUMPO").toUInt(); ++cx)
02393               {
02394                      fp >> xf;
02395                      fp >> yf;
02396                      currItem->PoLine.setPoint(cx, xf, yf);
02397               }
02398        }
02399        else
02400               currItem->PoLine.resize(0);
02401        tmp = "";
02402        if (obj->hasAttribute("NUMCO"))
02403        {
02404               currItem->ContourLine.resize(obj->attribute("NUMCO").toUInt());
02405               tmp = obj->attribute("COCOOR");
02406               QTextStream fp(&tmp, IO_ReadOnly);
02407               for (uint cx=0; cx<obj->attribute("NUMCO").toUInt(); ++cx)
02408               {
02409                      fp >> xf;
02410                      fp >> yf;
02411                      currItem->ContourLine.setPoint(cx, xf, yf);
02412               }
02413        }
02414        else
02415               currItem->ContourLine = currItem->PoLine.copy();
02416        if (!currItem->asLine())
02417               currItem->Clip = FlattenPath(currItem->PoLine, currItem->Segments);
02418        else
02419        {
02420               int ph = static_cast<int>(QMAX(1.0, currItem->lineWidth() / 2.0));
02421               currItem->Segments.clear();
02422               currItem->PoLine.resize(0);
02423               currItem->Clip.setPoints(4, -ph,-ph, static_cast<int>(currItem->width()+ph),-ph,
02424                                 static_cast<int>(currItem->width()+ph),static_cast<int>(currItem->height()+ph),
02425                                 -ph,static_cast<int>(currItem->height()+ph));
02426               currItem->setHeight(1.0);
02427        }
02428        if (currItem->asImageFrame())
02429               currItem->AdjustPictScale();
02430        if (currItem->asPathText())
02431        {
02432               currItem->updatePolyClip();
02433               currItem->Frame = true;
02434        }
02435        currItem->GrType = obj->attribute("GRTYP", "0").toInt();
02436        QString GrColor;
02437        QString GrColor2;
02438        int GrShade = 0;
02439        int GrShade2 = 0;
02440        if (currItem->GrType != 0)
02441        {
02442               currItem->GrStartX = obj->attribute("GRSTARTX", "0.0").toDouble();
02443               currItem->GrStartY = obj->attribute("GRSTARTY", "0.0").toDouble();
02444               currItem->GrEndX = obj->attribute("GRENDX", "0.0").toDouble();
02445               currItem->GrEndY = obj->attribute("GRENDY", "0.0").toDouble();
02446               GrColor = obj->attribute("GRCOLOR","");
02447               if (!GrColor.isEmpty())
02448               {
02449                      GrColor2 = obj->attribute("GRCOLOR2","");
02450                      GrShade = obj->attribute("GRSHADE", "100").toInt();
02451                      GrShade2 = obj->attribute("GRSHADE2", "100").toInt();
02452               }
02453        }
02454        if (currItem->GrType != 0)
02455        {
02456               currItem->fill_gradient.clearStops();
02457               if ((!GrColor.isEmpty()) && (!GrColor2.isEmpty()))
02458               {
02459                      if (currItem->GrType == 5)
02460                      {
02461                             handleOldColorShade(doc, GrColor, GrShade);
02462                             if ((GrColor != CommonStrings::None) && (!GrColor.isEmpty()))
02463                                    currItem->SetFarbe(&tmpc, GrColor, GrShade);
02464                             currItem->fill_gradient.addStop(tmpc, 0.0, 0.5, 1.0, GrColor, GrShade);
02465                             handleOldColorShade(doc, GrColor2, GrShade2);
02466                             if ((GrColor2 != CommonStrings::None) && (!GrColor2.isEmpty()))
02467                                    currItem->SetFarbe(&tmpc, GrColor2, GrShade2);
02468                             currItem->fill_gradient.addStop(tmpc, 1.0, 0.5, 1.0, GrColor2, GrShade2);
02469                      }
02470                      else
02471                      {
02472                             handleOldColorShade(doc, GrColor2, GrShade2);
02473                             if ((GrColor2 != CommonStrings::None) && (!GrColor2.isEmpty()))
02474                                    currItem->SetFarbe(&tmpc, GrColor2, GrShade2);
02475                             currItem->fill_gradient.addStop(tmpc, 0.0, 0.5, 1.0, GrColor2, GrShade2);
02476                             handleOldColorShade(doc, GrColor, GrShade);
02477                             if ((GrColor != CommonStrings::None) && (!GrColor.isEmpty()))
02478                                    currItem->SetFarbe(&tmpc, GrColor, GrShade);
02479                             currItem->fill_gradient.addStop(tmpc, 1.0, 0.5, 1.0, GrColor, GrShade);
02480                      }
02481               }
02482 //            currItem->updateGradientVectors();
02483        }
02484        //currItem->setRedrawBounding();
02485        //currItem->OwnPage = view->OnPage(currItem);
02486        return currItem;
02487 }
02488 
02489 bool Scribus13Format::loadPage(const QString & fileName, int pageNumber, bool Mpage, QString renamedPageName)
02490 {
02491        qDebug(QString("loading page %2 from file '%1' from 1.3.3.x plugin").arg(fileName).arg(pageNumber));
02492        if (m_Doc==0 || m_AvailableFonts==0)
02493        {
02494               Q_ASSERT(m_Doc==0 || m_AvailableFonts==0);
02495               return false;
02496        }
02497        ParagraphStyle vg;
02498        struct Layer la;
02499        struct ScribusDoc::BookMa bok;
02500        PageItem *Neu;
02501        Page* Apage = NULL;
02502        itemRemap.clear();
02503        itemNext.clear();
02504        itemCount = 0;
02505        QString tmV, tmp, tmpf, tmp2, tmp3, tmp4, PgNam, Defont, tmf;
02506        QFont fo;
02507        ReplacedFonts.clear();
02508        newReplacement = false;
02509        QMap<int,int> TableID;
02510        QPtrList<PageItem> TableItems;
02511        int a, counter, baseobj;
02512        double pageX = 0, pageY = 0;
02513        bool newVersion = false;
02514        bool VorLFound = false;
02515        QMap<int,int> layerTrans;
02516        int maxLayer = 0;
02517        int maxLevel = 0;
02518        layerTrans.clear();
02519        uint layerCount=m_Doc->layerCount();
02520        for (uint la2 = 0; la2 < layerCount; ++la2)
02521        {
02522               maxLayer = QMAX(m_Doc->Layers[la2].LNr, maxLayer);
02523               maxLevel = QMAX(m_Doc->Layers[la2].Level, maxLevel);
02524        }
02525        DoVorl.clear();
02526        DoVorl[0] = "";
02527        DoVorl[1] = "";
02528        DoVorl[2] = "";
02529        DoVorl[3] = "";
02530        DoVorl[4] = "";
02531        VorlC = 5;
02532        QDomDocument docu("scridoc");
02533        QString f(readSLA(fileName));
02534        if (f.isEmpty())
02535               return false;
02536        if(!docu.setContent(f))
02537               return false;
02538        ScColor lf = ScColor();
02539        QDomElement elem=docu.documentElement();
02540        if (elem.tagName() != "SCRIBUSUTF8NEW")
02541               return false;
02542        if (elem.hasAttribute("Version"))
02543               newVersion = true;
02544        QDomNode DOC=elem.firstChild();
02545        counter = m_Doc->Items->count();
02546        baseobj = counter;
02547        while(!DOC.isNull())
02548        {
02549               QDomElement dc=DOC.toElement();
02550               QDomNode PAGE=DOC.firstChild();
02551               while(!PAGE.isNull())
02552               {
02553                      QDomElement pg=PAGE.toElement();
02554                      if(pg.tagName()=="COLOR" && pg.attribute("NAME")!=CommonStrings::None)
02555                      {
02556                             if (pg.hasAttribute("CMYK"))
02557                                    lf.setNamedColor(pg.attribute("CMYK"));
02558                             else
02559                                    lf.fromQColor(QColor(pg.attribute("RGB")));
02560                             if (pg.hasAttribute("Spot"))
02561                                    lf.setSpotColor(static_cast<bool>(pg.attribute("Spot").toInt()));
02562                             else
02563                                    lf.setSpotColor(false);
02564                             if (pg.hasAttribute("Register"))
02565                                    lf.setRegistrationColor(static_cast<bool>(pg.attribute("Register").toInt()));
02566                             else
02567                                    lf.setRegistrationColor(false);
02568                             m_Doc->PageColors.insert(pg.attribute("NAME"), lf);
02569                      }
02570                      if(pg.tagName()=="STYLE")
02571                      {
02572                             GetStyle(&pg, &vg, NULL, m_Doc, true);
02573                             VorLFound = true;
02574                      }
02575                      if(pg.tagName()=="JAVA")
02576                             m_Doc->JavaScripts[pg.attribute("NAME")] = pg.attribute("SCRIPT");
02577                      if(pg.tagName()=="LAYERS")
02578                      {
02579                             la.LNr = pg.attribute("NUMMER").toInt();
02580                             la.Level = pg.attribute("LEVEL").toInt();
02581                             la.Name = pg.attribute("NAME");
02582                             la.isViewable = pg.attribute("SICHTBAR").toInt();
02583                             la.isPrintable = pg.attribute("DRUCKEN").toInt();
02584                             la.isEditable = pg.attribute("EDIT", "1").toInt();
02585                             la.flowControl = pg.attribute("FLOW", "1").toInt();
02586                             la.transparency = pg.attribute("TRANS", "1").toDouble();
02587                             la.blendMode = pg.attribute("BLEND", "0").toInt();
02588                             la.outlineMode = pg.attribute("OUTL", "0").toInt();
02589                             if (pg.hasAttribute("LAYERC"))
02590                                    la.markerColor =  QColor(pg.attribute("LAYERC","#000000"));
02591                             else
02592                             {
02593                                    QColor marker;
02594                                    switch (la.LNr % 7)
02595                                    {
02596                                           case 0:
02597                                                  marker = Qt::black;
02598                                                  break;
02599                                           case 1:
02600                                                  marker = Qt::red;
02601                                                  break;
02602                                           case 2:
02603                                                  marker = Qt::green;
02604                                                  break;
02605                                           case 3:
02606                                                  marker = Qt::blue;
02607                                                  break;
02608                                           case 4:
02609                                                  marker = Qt::cyan;
02610                                                  break;
02611                                           case 5:
02612                                                  marker = Qt::magenta;
02613                                                  break;
02614                                           case 6:
02615                                                  marker = Qt::yellow;;
02616                                                  break;
02617                                    }
02618                                    la.markerColor = marker;
02619                             }
02620                             bool laex = false;
02621                             uint layerCount=m_Doc->layerCount();
02622                             for (uint la2 = 0; la2 < layerCount; ++la2)
02623                             {
02624                                    if (m_Doc->Layers[la2].Name == la.Name)
02625                                    {
02626                                           laex = true;
02627                                           layerTrans.insert(la.LNr, m_Doc->Layers[la2].LNr);
02628                                    }
02629                             }
02630                             if (!laex)
02631                             {
02632                                    maxLayer++;
02633                                    maxLevel++;
02634                                    layerTrans.insert(la.LNr, maxLayer);
02635                                    la.LNr = maxLayer;
02636                                    la.Level = maxLevel;
02637                                    m_Doc->Layers.append(la);
02638                             }
02639                      }
02640                      if(pg.tagName()=="MultiLine")
02641                      {
02642                             multiLine ml;
02643                             QDomNode MuLn = PAGE.firstChild();
02644                             while(!MuLn.isNull())
02645                             {
02646                                    QDomElement MuL = MuLn.toElement();
02647                                    struct SingleLine sl;
02648                                    sl.Color = MuL.attribute("Color");
02649                                    sl.Dash = MuL.attribute("Dash").toInt();
02650                                    sl.LineEnd = MuL.attribute("LineEnd").toInt();
02651                                    sl.LineJoin = MuL.attribute("LineJoin").toInt();
02652                                    sl.Shade = MuL.attribute("Shade").toInt();
02653                                    sl.Width = MuL.attribute("Width").toDouble();
02654                                    ml.push_back(sl);
02655                                    MuLn = MuLn.nextSibling();
02656                             }
02657                             QString Nam = pg.attribute("Name");
02658                             QString Nam2 = Nam;
02659                             int copyC = 1;
02660                             QMap<QString,multiLine>::ConstIterator mlit = m_Doc->MLineStyles.find(Nam2);
02661                             if (mlit != m_Doc->MLineStyles.end() && ml != mlit.data())
02662                             {
02663                                    while (m_Doc->MLineStyles.contains(Nam2))
02664                                    {
02665                                           Nam2 = QObject::tr("Copy #%1 of ").arg(copyC)+Nam;
02666                                           copyC++;
02667                                    }
02668                             }
02669                             m_Doc->MLineStyles.insert(Nam2, ml);
02670                      }
02671                      if(pg.tagName()=="Arrows")
02672                      {
02673                             struct ArrowDesc arrow;
02674                             arrow.name = pg.attribute("Name");
02675                             arrow.userArrow = true;
02676                             double xa, ya;
02677                             QString tmp = pg.attribute("Points");
02678                             QTextStream fp(&tmp, IO_ReadOnly);
02679                             for (uint cx = 0; cx < pg.attribute("NumPoints").toUInt(); ++cx)
02680                             {
02681                                    fp >> xa;
02682                                    fp >> ya;
02683                                    arrow.points.addPoint(xa, ya);
02684                             }
02685                             m_Doc->arrowStyles.append(arrow);
02686                      }
02687                      if (((pg.tagName()=="PAGE") || (pg.tagName()=="MASTERPAGE")) && (pg.attribute("NUM").toInt() == pageNumber))
02688                      {
02689                             a = m_Doc->currentPage()->pageNr();
02690                             Apage = m_Doc->Pages->at(a);
02691                             if ((pg.tagName()!="MASTERPAGE") && (Mpage))
02692                             {
02693                                    PAGE=PAGE.nextSibling();
02694                                    continue;
02695                             }
02696                             if (Mpage)
02697                             {
02698                                    Apage->LeftPg=pg.attribute("LEFT", "0").toInt();
02699                                    
02700                                    if (!renamedPageName.isEmpty())
02701                                           Apage->setPageName(renamedPageName);
02702                                    else
02703                                           Apage->setPageName(pg.attribute("NAM",""));
02704                             }
02705                             if (pg.hasAttribute("Size"))
02706                                    Apage->m_pageSize = pg.attribute("Size");
02707                             if (pg.hasAttribute("Orientation"))
02708                                    Apage->PageOri = pg.attribute("Orientation").toInt();
02709                             if (pg.hasAttribute("PAGEWIDTH"))
02710                                    Apage->setWidth(pg.attribute("PAGEWIDTH").toDouble());
02711                             else
02712                                    Apage->setWidth(pg.attribute("PAGEWITH").toDouble());
02713                             Apage->setHeight(pg.attribute("PAGEHEIGHT").toDouble());
02714                             Apage->setInitialHeight(Apage->height());
02715                             Apage->setInitialWidth(Apage->width());
02716                             Apage->initialMargins.Top = QMAX(0.0, pg.attribute("BORDERTOP").toDouble());
02717                             Apage->initialMargins.Bottom = QMAX(0.0, pg.attribute("BORDERBOTTOM").toDouble());
02718                             Apage->initialMargins.Left = QMAX(0.0, pg.attribute("BORDERLEFT").toDouble());
02719                             Apage->initialMargins.Right = QMAX(0.0, pg.attribute("BORDERRIGHT").toDouble());
02720                             Apage->Margins.Top = Apage->initialMargins.Top;
02721                             Apage->Margins.Bottom = Apage->initialMargins.Bottom;
02722                             pageX = pg.attribute("PAGEXPOS").toDouble();
02723                             pageY = pg.attribute("PAGEYPOS").toDouble();
02724                             // guides reading
02725                             tmp = "";
02726                             GuideManagerIO::readVerticalGuides(pg.attribute("VerticalGuides"),
02727                                                                                     Apage,
02728                                                                                     GuideManagerCore::Standard,
02729                                                                                     pg.hasAttribute("NumVGuides"));
02730                             GuideManagerIO::readHorizontalGuides(pg.attribute("HorizontalGuides"),
02731                                                                                     Apage,
02732                                                                                     GuideManagerCore::Standard,
02733                                                                                     pg.hasAttribute("NumHGuides"));
02734                      }
02735                      if ((pg.tagName()=="PAGEOBJECT") || (pg.tagName()=="MASTEROBJECT") || (pg.tagName()=="FRAMEOBJECT"))
02736                      {
02737                             if (Mpage)
02738                             {
02739                                    if (pg.tagName() != "MASTEROBJECT")
02740                                    {
02741                                           PAGE=PAGE.nextSibling();
02742                                           continue;
02743                                    }
02744                             }
02745                             else
02746                             {
02747                                    if (pg.tagName() == "MASTEROBJECT")
02748                                    {
02749                                           PAGE=PAGE.nextSibling();
02750                                           continue;
02751                                    }
02752                             }
02753                             
02754                             if (pg.attribute("OwnPage").toInt() != pageNumber)
02755                             {                    
02756                                    if (pg.tagName()=="PAGEOBJECT")
02757                                           itemRemap[itemCount++] = -1;
02758                             }
02759                             else
02760                             {
02761                                    // first of linked chain?
02762                                    if (pg.tagName()=="PAGEOBJECT")
02763                                    {
02764                                           itemRemap[itemCount++] = m_Doc->Items->count();
02765                                           if (pg.attribute("NEXTITEM").toInt() != -1)
02766                                           {
02767                                                  itemNext[m_Doc->Items->count()] = pg.attribute("NEXTITEM").toInt();
02768                                           }
02769                                    }
02770                                    int docGc = m_Doc->GroupCounter;
02771                                    m_Doc->GroupCounter = 0;
02772                                    Neu = PasteItem(&pg, m_Doc);
02773                                    Neu->moveBy(-pageX + Apage->xOffset(), - pageY + Apage->yOffset());
02774                                    Neu->setRedrawBounding();
02775                                    //CB Must run onpage as we cant use pagetoload if the page has been renamed. 
02776                                    //CB TODO Make this accept a page to place onto.
02777                                    //Neu->OwnPage = m_Doc->OnPage(Neu);
02778                                    //Neu->OwnPage = PageToLoad;
02779                                    Neu->OwnPage = m_Doc->currentPageNumber();
02780                                    if (pg.tagName()=="PAGEOBJECT")
02781                                           Neu->OnMasterPage = "";
02782                                    m_Doc->GroupCounter = docGc;
02783                                    QDomNode IT=pg.firstChild();
02784                                    LastStyles * last = new LastStyles();
02785                                    while(!IT.isNull())
02786                                    {
02787                                           QDomElement it=IT.toElement();
02788                                           if (it.tagName()=="CSTOP")
02789                                           {
02790                                                  QString name = it.attribute("NAME");
02791                                                  double ramp = it.attribute("RAMP", "0.0").toDouble();
02792                                                  int shade = it.attribute("SHADE", "100").toInt();
02793                                                  double opa = it.attribute("TRANS", "1").toDouble();
02794                                                  handleOldColorShade(m_Doc, name, shade);
02795                                                  Neu->fill_gradient.addStop(SetColor(m_Doc, name, shade), ramp, 0.5, opa, name, shade);
02796                                           }
02797                                           if (it.tagName()=="ITEXT")
02798                                                  GetItemText(&it, m_Doc, Neu, last, true, VorLFound);
02799                                           if(it.tagName()=="PageItemAttributes")
02800                                           {
02801                                                  QDomNode PIA = it.firstChild();
02802                                                  ObjAttrVector pageItemAttributes;
02803                                                  while(!PIA.isNull())
02804                                                  {
02805                                                         QDomElement itemAttr = PIA.toElement();
02806                                                         if(itemAttr.tagName() == "ItemAttribute")
02807                                                         {
02808                                                                ObjectAttribute objattr;
02809                                                                objattr.name=itemAttr.attribute("Name");
02810                                                                objattr.type=itemAttr.attribute("Type");
02811                                                                objattr.value=itemAttr.attribute("Value");
02812                                                                objattr.parameter=itemAttr.attribute("Parameter");
02813                                                                objattr.relationship=itemAttr.attribute("Relationship");
02814                                                                objattr.relationshipto=itemAttr.attribute("RelationshipTo");
02815                                                                objattr.autoaddto=itemAttr.attribute("AutoAddTo");
02816                                                                pageItemAttributes.append(objattr);
02817                                                         }
02818                                                         PIA = PIA.nextSibling();
02819                                                  }
02820                                                  Neu->setObjectAttributes(&pageItemAttributes);
02821                                           }
02822                                           IT=IT.nextSibling();
02823                                    }
02824                                    delete last;
02825                                    if (Neu->fill_gradient.Stops() == 0)
02826                                    {
02827                                           const ScColor& col1 = m_Doc->PageColors[m_Doc->toolSettings.dBrush];
02828                                           const ScColor& col2 = m_Doc->PageColors[m_Doc->toolSettings.dPen];
02829                                           Neu->fill_gradient.addStop(ScColorEngine::getRGBColor(col1, m_Doc), 0.0, 0.5, 1.0, m_Doc->toolSettings.dBrush, 100);
02830                                           Neu->fill_gradient.addStop(ScColorEngine::getRGBColor(col2, m_Doc), 1.0, 0.5, 1.0, m_Doc->toolSettings.dPen, 100);
02831                                    }
02832 //                                 Neu->Language = ScMW->GetLang(pg.attribute("LANGUAGE", m_Doc->Language));
02833 //                                 Neu->Language = m_Doc->Language;
02834                                    Neu->isAutoText = static_cast<bool>(pg.attribute("AUTOTEXT").toInt());
02835                                    Neu->isEmbedded = static_cast<bool>(pg.attribute("isInline", "0").toInt());
02836                                    Neu->gXpos = pg.attribute("gXpos", "0.0").toDouble();
02837                                    Neu->gYpos = pg.attribute("gYpos", "0.0").toDouble();
02838                                    QString defaultVal;
02839                                    defaultVal.setNum(Neu->width());
02840                                    Neu->gWidth = pg.attribute("gWidth",defaultVal).toDouble();
02841                                    defaultVal.setNum(Neu->height());
02842                                    Neu->gHeight = pg.attribute("gHeight",defaultVal).toDouble();
02843                                    if (Neu->isAutoText)
02844                                           m_Doc->LastAuto = Neu;
02845                                    if (Neu->isTableItem)
02846                                    {
02847                                           TableItems.append(Neu);
02848                                           TableID.insert(pg.attribute("OwnLINK", "0").toInt(), Neu->ItemNr);
02849                                    }
02850                                    if (pg.tagName()=="FRAMEOBJECT")
02851                                    {
02852                                           m_Doc->FrameItems.append(m_Doc->Items->take(Neu->ItemNr));
02853                                           Neu->ItemNr = m_Doc->FrameItems.count()-1;
02854                                    }
02855                             }
02856                             counter++;
02857                      }
02858                      PAGE=PAGE.nextSibling();
02859               }
02860               PAGE=DOC.firstChild();
02861               while(!PAGE.isNull())
02862               {
02863                      QDomElement pg=PAGE.toElement();
02864                      if(pg.tagName()=="Bookmark")
02865                      {
02866                             uint elem = pg.attribute("Element").toInt();
02867                             if (elem < m_Doc->Items->count())
02868                             {
02869                                    bok.Title = pg.attribute("Title");
02870                                    bok.Text = pg.attribute("Text");
02871                                    bok.Aktion = pg.attribute("Aktion");
02872                                    bok.ItemNr = pg.attribute("ItemNr").toInt();
02873                                    bok.PageObject = m_Doc->Items->at(elem);
02874                                    bok.First = pg.attribute("First").toInt();
02875                                    bok.Last = pg.attribute("Last").toInt();
02876                                    bok.Prev = pg.attribute("Prev").toInt();
02877                                    bok.Next = pg.attribute("Next").toInt();
02878                                    bok.Parent = pg.attribute("Parent").toInt();
02879                                    m_Doc->BookMarks.append(bok);
02880                             }
02881                      }
02882                      PAGE=PAGE.nextSibling();
02883               }
02884               DOC=DOC.nextSibling();
02885        }
02886        if (TableItems.count() != 0)
02887        {
02888               for (uint ttc = 0; ttc < TableItems.count(); ++ttc)
02889               {
02890                      PageItem* ta = TableItems.at(ttc);
02891                      if (ta->TopLinkID != -1)
02892                             ta->TopLink = m_Doc->Items->at(TableID[ta->TopLinkID]);
02893                      else
02894                             ta->TopLink = 0;
02895                      if (ta->LeftLinkID != -1)
02896                             ta->LeftLink = m_Doc->Items->at(TableID[ta->LeftLinkID]);
02897                      else
02898                             ta->LeftLink = 0;
02899                      if (ta->RightLinkID != -1)
02900                             ta->RightLink = m_Doc->Items->at(TableID[ta->RightLinkID]);
02901                      else
02902                             ta->RightLink = 0;
02903                      if (ta->BottomLinkID != -1)
02904                             ta->BottomLink = m_Doc->Items->at(TableID[ta->BottomLinkID]);
02905                      else
02906                             ta->BottomLink = 0;
02907               }
02908        }
02909        // reestablish textframe links
02910        if (itemNext.count() != 0)
02911        {
02912               QMap<int,int>::Iterator lc;
02913               for (lc = itemNext.begin(); lc != itemNext.end(); ++lc)
02914               {
02915                      if (itemRemap[lc.data()] >= 0)
02916                      {
02917                             if ((static_cast<uint>(lc.key()) < m_Doc->Items->count()) && (static_cast<uint>(itemRemap[lc.data()]) < m_Doc->Items->count()))
02918                             {
02919                                    PageItem * Its = m_Doc->Items->at(lc.key());
02920                                    PageItem * Itn = m_Doc->Items->at(itemRemap[lc.data()]);
02921                                    if (Itn->prevInChain() || Its->nextInChain()) 
02922                                    {
02923                                           qDebug("scribus13format: corruption in linked textframes detected");
02924                                           continue;
02925                                    }
02926                                    Its->link(Itn);
02927                             }
02928                      }
02929               }
02930        }      
02931        
02932        // reestablish first/lastAuto
02933        m_Doc->FirstAuto = m_Doc->LastAuto;
02934        if (m_Doc->LastAuto)
02935        {
02936               while (m_Doc->LastAuto->nextInChain())
02937                      m_Doc->LastAuto = m_Doc->LastAuto->nextInChain();
02938               while (m_Doc->FirstAuto->prevInChain())
02939                      m_Doc->FirstAuto = m_Doc->FirstAuto->prevInChain();
02940        }
02941        
02942        return true;
02943 }
02944 
02945 void Scribus13Format::GetStyle(QDomElement *pg, ParagraphStyle *vg, StyleSet<ParagraphStyle> *tempParagraphStyles, ScribusDoc* doc, bool fl)
02946 {
02947        bool fou;
02948        QString tmpf, tmf, tmV;
02949        fou = false;
02950        readParagraphStyle(*vg, *pg, doc);
02951        const StyleSet<ParagraphStyle> & docParagraphStyles(tempParagraphStyles? *tempParagraphStyles : doc->paragraphStyles());
02952        for (uint xx=0; xx<docParagraphStyles.count(); ++xx)
02953        {
02954               if (vg->name() == docParagraphStyles[xx].name())
02955               {
02956                      if (vg->equiv(docParagraphStyles[xx]))
02957                      {
02958                             if (fl)
02959                             {
02960                                    DoVorl[VorlC] = vg->name();
02961                                    ++VorlC;
02962                             }
02963                             fou = true;
02964                      }
02965                      else
02966                      {
02967                             vg->setName("Copy of "+docParagraphStyles[xx].name());
02968                             fou = false;
02969                      }
02970                      break;
02971               }
02972        }
02973        if (!fou)
02974        {
02975               for (uint xx=0; xx< docParagraphStyles.count(); ++xx)
02976               {
02977                      if (vg->equiv(docParagraphStyles[xx]))
02978                      {
02979                             vg->setName(docParagraphStyles[xx].name());
02980                             fou = true;
02981                             if (fl)
02982                             {
02983                                    DoVorl[VorlC] = vg->name();
02984                                    ++VorlC;
02985                             }
02986                             break;
02987                      }
02988               }
02989        }
02990        if (!fou)
02991        {
02992               if (tempParagraphStyles)
02993                      tempParagraphStyles->create(*vg);
02994               else {
02995                      StyleSet<ParagraphStyle> temp;
02996                      temp.create(*vg);
02997                      doc->redefineStyles(temp, false);
02998               }
02999               if (fl)
03000               {
03001                      DoVorl[VorlC] = vg->name();
03002                      ++VorlC;
03003               }
03004        }
03005 }
03006 
03007 QString Scribus13Format::AskForFont(QString fStr, ScribusDoc *doc)
03008 {
03009        PrefsManager *prefsManager=PrefsManager::instance();
03010 //     QFont fo;
03011        QString tmpf = fStr;
03012        if ((!(*m_AvailableFonts).contains(tmpf)) || (!(*m_AvailableFonts)[tmpf].usable()))
03013        {
03014               if ((!prefsManager->appPrefs.GFontSub.contains(tmpf)) || (!(*m_AvailableFonts)[prefsManager->appPrefs.GFontSub[tmpf]].usable()))
03015               {
03016                      qApp->setOverrideCursor(QCursor(arrowCursor), true);
03017                      MissingFont *dia = new MissingFont(0, tmpf, doc);
03018                      dia->exec();
03019                      tmpf = dia->getReplacementFont();
03020                      delete dia;
03021                      qApp->setOverrideCursor(QCursor(waitCursor), true);
03022                      prefsManager->appPrefs.GFontSub[fStr] = tmpf;
03023               }
03024               else
03025                      tmpf = prefsManager->appPrefs.GFontSub[tmpf];
03026               ReplacedFonts[fStr] = tmpf;
03027        }
03028        if (!doc->UsedFonts.contains(tmpf))
03029        {
03030               doc->AddFont(tmpf);
03031        }
03032 //     DoFonts[fStr] = tmpf;
03033        return tmpf;
03034 }
03035 
03036 bool Scribus13Format::readStyles(const QString& fileName, ScribusDoc* doc, StyleSet<ParagraphStyle> &docParagraphStyles)
03037 {
03038        ParagraphStyle vg;
03039        QDomDocument docu("scridoc");
03040        QString tmpf, tmf;
03041        QString f (readSLA(fileName));
03042        if (f.isEmpty())
03043               return false;
03044        if(!docu.setContent(f))
03045               return false;
03046        QDomElement elem=docu.documentElement();
03047        if (elem.tagName() != "SCRIBUSUTF8NEW")
03048               return false;
03049        QDomNode DOC=elem.firstChild();
03050        while(!DOC.isNull())
03051        {
03052               QDomElement dc=DOC.toElement();
03053               QDomNode PAGE=DOC.firstChild();
03054               while(!PAGE.isNull())
03055               {
03056                      QDomElement pg=PAGE.toElement();
03057                      if(pg.tagName()=="STYLE")
03058                             GetStyle(&pg, &vg, &docParagraphStyles, doc, false);
03059                      PAGE=PAGE.nextSibling();
03060               }
03061               DOC=DOC.nextSibling();
03062        }
03063        return true;
03064 }
03065 
03066 bool Scribus13Format::readLineStyles(const QString& fileName, QMap<QString,multiLine> *Sty)
03067 {
03068        QDomDocument docu("scridoc");
03069        QString f(readSLA(fileName));
03070        if (f.isEmpty())
03071               return false;
03072        if(!docu.setContent(f))
03073               return false;
03074        QDomElement elem=docu.documentElement();
03075        if (elem.tagName() != "SCRIBUSUTF8NEW")
03076               return false;
03077        QDomNode DOC=elem.firstChild();
03078        while(!DOC.isNull())
03079        {
03080               QDomElement dc=DOC.toElement();
03081               QDomNode PAGE=DOC.firstChild();
03082               while(!PAGE.isNull())
03083               {
03084                      QDomElement pg=PAGE.toElement();
03085                      if(pg.tagName()=="MultiLine")
03086                      {
03087                             multiLine ml;
03088                             QDomNode MuLn = PAGE.firstChild();
03089                             while(!MuLn.isNull())
03090                             {
03091                                    QDomElement MuL = MuLn.toElement();
03092                                    struct SingleLine sl;
03093                                    sl.Color = MuL.attribute("Color");
03094                                    sl.Dash = MuL.attribute("Dash").toInt();
03095                                    sl.LineEnd = MuL.attribute("LineEnd").toInt();
03096                                    sl.LineJoin = MuL.attribute("LineJoin").toInt();
03097                                    sl.Shade = MuL.attribute("Shade").toInt();
03098                                    sl.Width = MuL.attribute("Width").toDouble();
03099                                    ml.push_back(sl);
03100                                    MuLn = MuLn.nextSibling();
03101                             }
03102                             QString Nam = pg.attribute("Name");
03103                             QString Nam2 = Nam;
03104                             int copyC = 1;
03105                             QMap<QString,multiLine>::ConstIterator mlit = Sty->find(Nam2);
03106                             if (mlit != Sty->end() && ml != mlit.data())
03107                             {
03108                                    while (Sty->contains(Nam2))
03109                                    {
03110                                           Nam2 = tr("Copy #%1 of ").arg(copyC)+Nam;
03111                                           copyC++;
03112                                    }
03113                             }
03114                             Sty->insert(Nam2, ml);
03115                      }
03116                      PAGE=PAGE.nextSibling();
03117               }
03118               DOC=DOC.nextSibling();
03119        }
03120        return true;
03121 }
03122 
03123 bool Scribus13Format::readColors(const QString& fileName, ColorList & colors)
03124 {
03125        QString f(readSLA(fileName));
03126        if (f.isEmpty())
03127               return false;
03128        QDomDocument docu("scridoc");
03129        if(!docu.setContent(f))
03130               return false;
03131        ScColor lf = ScColor();
03132        colors.clear();
03133        QDomElement elem=docu.documentElement();
03134        if (elem.tagName() != "SCRIBUSUTF8NEW")
03135               return false;
03136        QDomNode DOC=elem.firstChild();
03137        while(!DOC.isNull())
03138        {
03139               QDomElement dc=DOC.toElement();
03140               QDomNode PAGE=DOC.firstChild();
03141               while(!PAGE.isNull())
03142               {
03143                      QDomElement pg=PAGE.toElement();
03144                      // 10/25/2004 pv - None is "reserved" color. cannot be defined in any file...
03145                      if(pg.tagName()=="COLOR" && pg.attribute("NAME")!=CommonStrings::None)
03146                      {
03147                             if (pg.hasAttribute("CMYK"))
03148                                    lf.setNamedColor(pg.attribute("CMYK"));
03149                             else
03150                                    lf.fromQColor(QColor(pg.attribute("RGB")));
03151                             if (pg.hasAttribute("Spot"))
03152                                    lf.setSpotColor(static_cast<bool>(pg.attribute("Spot").toInt()));
03153                             else
03154                                    lf.setSpotColor(false);
03155                             if (pg.hasAttribute("Register"))
03156                                    lf.setRegistrationColor(static_cast<bool>(pg.attribute("Register").toInt()));
03157                             else
03158                                    lf.setRegistrationColor(false);
03159                             colors.insert(pg.attribute("NAME"), lf);
03160                      }
03161                      PAGE=PAGE.nextSibling();
03162               }
03163               DOC=DOC.nextSibling();
03164        }
03165        return true;
03166 }
03167 
03168 bool Scribus13Format::readPageCount(const QString& fileName, int *num1, int *num2, QStringList & masterPageNames)
03169 {
03170        QString PgNam;
03171        int counter = 0;
03172        int counter2 = 0;
03173        QDomDocument docu("scridoc");
03174        QString f(readSLA(fileName));
03175        if (f.isEmpty())
03176               return false;
03177        if(!docu.setContent(f))
03178               return false;
03179        QDomElement elem=docu.documentElement();
03180        if (elem.tagName() != "SCRIBUSUTF8NEW")
03181               return false;
03182        QDomNode DOC=elem.firstChild();
03183        while(!DOC.isNull())
03184        {
03185               QDomNode PAGE=DOC.firstChild();
03186               while(!PAGE.isNull())
03187               {
03188                      QDomElement pg=PAGE.toElement();
03189                      PgNam = pg.attribute("NAM", "");
03190                      if(pg.tagName()=="PAGE")
03191                             counter++;
03192                      if(pg.tagName()=="MASTERPAGE")
03193                      {
03194                             counter2++;
03195                             masterPageNames.append(PgNam);
03196                      }
03197                      PAGE=PAGE.nextSibling();
03198               }
03199               DOC=DOC.nextSibling();
03200        }
03201        *num1 = counter;
03202        *num2 = counter2;
03203        return true;
03204 }
03205 
03206 void Scribus13Format::WritePages(ScribusDoc *doc, QDomDocument *docu, QDomElement *dc, QProgressBar *dia2, uint maxC, bool master)
03207 {
03208        uint ObCount = maxC;
03209        Page *page;
03210        uint pages;
03211        QDomElement pg;
03212        QString tmp;
03213        if (master)
03214               pages = doc->MasterPages.count();
03215        else
03216               pages = doc->DocPages.count();
03217        for(uint i = 0; i < pages; ++i)
03218        {
03219               ObCount++;
03220               if (dia2 != 0)
03221                      dia2->setProgress(ObCount);
03222               if (master)
03223               {
03224                      pg = docu->createElement("MASTERPAGE");
03225                      page = doc->MasterPages.at(i);
03226               }
03227               else
03228               {
03229                      pg = docu->createElement("PAGE");
03230                      page = doc->DocPages.at(i);
03231               }
03232               pg.setAttribute("PAGEXPOS",page->xOffset());
03233               pg.setAttribute("PAGEYPOS",page->yOffset());
03234               pg.setAttribute("PAGEWIDTH",page->width());
03235               pg.setAttribute("PAGEHEIGHT",page->height());
03236               pg.setAttribute("BORDERLEFT",page->initialMargins.Left);
03237               pg.setAttribute("BORDERRIGHT",page->initialMargins.Right);
03238               pg.setAttribute("BORDERTOP",page->initialMargins.Top);
03239               pg.setAttribute("BORDERBOTTOM",page->initialMargins.Bottom);
03240               pg.setAttribute("NUM",page->pageNr());
03241               pg.setAttribute("NAM",page->pageName());
03242               pg.setAttribute("MNAM",page->MPageNam);
03243               pg.setAttribute("Size", page->m_pageSize);
03244               pg.setAttribute("Orientation", page->PageOri);
03245               pg.setAttribute("LEFT", page->LeftPg);
03246               pg.setAttribute("VerticalGuides", GuideManagerIO::writeVerticalGuides(
03247                                                                                            page, GuideManagerCore::Standard));
03248               pg.setAttribute("HorizontalGuides", GuideManagerIO::writeHorizontalGuides(
03249                                                                                            page, GuideManagerCore::Standard));
03250               dc->appendChild(pg);
03251        }
03252 }
03253 
03254 void Scribus13Format::WriteObjects(ScribusDoc *doc, QDomDocument *docu, QDomElement *dc, QProgressBar *dia2, uint maxC, int master)
03255 {
03256        int te, te2, tsh, tsh2, tst, tst2, tsb, tsb2, tshs, tshs2, tobj, tobj2;
03257        QString text, tf, tf2, tc, tc2, tcs, tcs2, tmp, tmpy, Ndir;
03258        double ts, ts2, tsc, tsc2, tscv, tscv2, tb, tb2, tsx, tsx2, tsy, tsy2, tout, tout2, tulp, tulp2, tulw, tulw2, tstp, tstp2, tstw, tstw2;
03259        uint ObCount = maxC;
03260        PageItem *item = NULL;
03261        QDomElement ob;
03262        uint objects = 0;
03263        switch (master)
03264        {
03265               case 0:
03266                      objects = doc->MasterItems.count();
03267                      break;
03268               case 1:
03269                      objects = doc->DocItems.count();
03270                      break;
03271               case 2:
03272                      objects = doc->FrameItems.count();
03273                      break;
03274        }
03275        for(uint j = 0; j < objects;++j)
03276        {
03277               ObCount++;
03278               if (dia2 != 0)
03279                      dia2->setProgress(ObCount);
03280               switch (master)
03281               {
03282                      case 0:
03283                             item = doc->MasterItems.at(j);
03284                             ob = docu->createElement("MASTEROBJECT");
03285                             break;
03286                      case 1:
03287                             item = doc->DocItems.at(j);
03288                             ob = docu->createElement("PAGEOBJECT");
03289                             break;
03290                      case 2:
03291                             item = doc->FrameItems.at(j);
03292                             ob = docu->createElement("FRAMEOBJECT");
03293                             break;
03294               }
03295               SetItemProps(&ob, item, true);
03296               ob.setAttribute("OnMasterPage", item->OnMasterPage);
03297               ob.setAttribute("ImageClip", item->pixm.imgInfo.usedPath);
03298               ob.setAttribute("ImageRes", item->pixm.imgInfo.lowResType);
03299               ob.setAttribute("isInline", static_cast<int>(item->isEmbedded));
03300               ob.setAttribute("fillRule", static_cast<int>(item->fillRule));
03301               ob.setAttribute("doOverprint", static_cast<int>(item->doOverprint));
03302               ob.setAttribute("gXpos", item->gXpos);
03303               ob.setAttribute("gYpos", item->gYpos);
03304               ob.setAttribute("gWidth", item->gWidth);
03305               ob.setAttribute("gHeight", item->gHeight);
03306               if (item->GrType != 0)
03307               {
03308                      QPtrVector<VColorStop> cstops = item->fill_gradient.colorStops();
03309                      for (uint cst = 0; cst < item->fill_gradient.Stops(); ++cst)
03310                      {
03311                             QDomElement itcl = docu->createElement("CSTOP");
03312                             itcl.setAttribute("RAMP", cstops.at(cst)->rampPoint);
03313                             itcl.setAttribute("NAME", cstops.at(cst)->name);
03314                             itcl.setAttribute("SHADE", cstops.at(cst)->shade);
03315                             itcl.setAttribute("TRANS", cstops.at(cst)->opacity);
03316                             ob.appendChild(itcl);
03317                      }
03318                      ob.setAttribute("GRSTARTX", item->GrStartX);
03319                      ob.setAttribute("GRSTARTY", item->GrStartY);
03320                      ob.setAttribute("GRENDX", item->GrEndX);
03321                      ob.setAttribute("GRENDY", item->GrEndY);
03322               }
03323               if (item->effectsInUse.count() != 0)
03324               {
03325                      for (uint a = 0; a < item->effectsInUse.count(); ++a)
03326                      {
03327                             QDomElement imeff = docu->createElement("ImageEffect");
03328                             imeff.setAttribute("Code", (*item->effectsInUse.at(a)).effectCode);
03329                             imeff.setAttribute("Param", (*item->effectsInUse.at(a)).effectParameters);
03330                             ob.appendChild(imeff);
03331                      }
03332               }
03333 /*
03334  if (item->TabValues.count() != 0)
03335               {
03336                      for (uint a = 0; a < item->TabValues.count(); ++a)
03337                      {
03338                             QDomElement tabs = docu->createElement("Tabs");
03339                             tabs.setAttribute("Type", (*item->TabValues.at(a)).tabType);
03340                             tabs.setAttribute("Pos", (*item->TabValues.at(a)).tabPosition);
03341                             QString tabCh = "";
03342                             if (!(*item->TabValues.at(a)).tabFillChar.isNull())
03343                                    tabCh = QString((*item->TabValues.at(a)).tabFillChar);
03344                             tabs.setAttribute("Fill", tabCh);
03345                             ob.appendChild(tabs);
03346                      }
03347               }
03348 */
03349               if (((item->asImageFrame()) || (item->asTextFrame())) && (!item->Pfile.isEmpty()) && (item->pixm.imgInfo.layerInfo.count() != 0) && (item->pixm.imgInfo.isRequest))
03350               {
03351                      QMap<int, ImageLoadRequest>::iterator it2;
03352                      for (it2 = item->pixm.imgInfo.RequestProps.begin(); it2 != item->pixm.imgInfo.RequestProps.end(); ++it2)
03353                      {
03354                             QDomElement psd = docu->createElement("PSDLayer");
03355                             psd.setAttribute("Layer",it2.key());
03356                             psd.setAttribute("Visible", static_cast<int>(it2.data().visible));
03357                             psd.setAttribute("useMask", static_cast<int>(it2.data().useMask));
03358                             psd.setAttribute("Opacity", it2.data().opacity);
03359                             psd.setAttribute("Blend", it2.data().blend);
03360                             ob.appendChild(psd);
03361                      }
03362               }
03363               ob.setAttribute("ALIGN", findParagraphStyle(doc, item->itemText.defaultStyle()));
03364               ob.setAttribute("BOOKMARK", item->isBookmark ? 1 : 0);
03365               for(int k = 0; k < item->itemText.length(); ++k)
03366               {
03367                      const CharStyle& style1(item->itemText.charStyle(k));
03368                      QChar ch = item->itemText.text(k);
03369                      QDomElement it=docu->createElement("ITEXT");
03370                      ts = style1.fontSize() / 10.0;
03371                      tf = style1.font().scName();
03372                      tc = style1.fillColor();
03373                      te = style1.tracking();
03374                      tsh = style1.fillShade();
03375                      tst = style1.effects() & ScStyle_UserStyles;
03376 #ifndef NLS_PROTO
03377                      tsb = findParagraphStyle(doc, item->itemText.paragraphStyle(k));
03378 #else
03379                      tsb = 0;
03380 #endif
03381                      tcs = style1.strokeColor();
03382                      tshs = style1.strokeShade();
03383                      tsc = style1.scaleH() / 10.0;
03384                      tscv = style1.scaleV() / 10.0;
03385                      tb = style1.baselineOffset() / 10.0;
03386                      tsx = style1.shadowXOffset() / 10.0;
03387                      tsy = style1.shadowYOffset() / 10.0;
03388                      tout = style1.outlineWidth() / 10.0;
03389                      tulp = style1.underlineOffset() / 10.0;
03390                      tulw = style1.underlineWidth() / 10.0;
03391                      tstp = style1.strikethruOffset() / 10.0;
03392                      tstw = style1.strikethruWidth() / 10.0;
03393 #ifndef NLS_PROTO
03394                      if ((ch == SpecialChars::OBJECT) && (item->itemText.item(k)->embedded.hasItem()))
03395                             tobj = item->itemText.item(k)->embedded.getItem()->ItemNr;
03396                      else
03397 #endif
03398                             tobj = -1;
03399                      if (ch == SpecialChars::PARSEP)
03400                             text = QChar(5);
03401                      else if (ch == SpecialChars::TAB)
03402                             text = QChar(4);
03403                      else
03404                             text = ch;
03405                      ++k;
03406                      if (k == item->itemText.length())
03407                      {
03408                             it.setAttribute("CH",text);
03409                             it.setAttribute("CSIZE",ts);
03410                             it.setAttribute("CFONT",tf);
03411                             it.setAttribute("CCOLOR",tc);
03412                             it.setAttribute("CKERN",te);
03413                             it.setAttribute("CSHADE",tsh);
03414                             it.setAttribute("CSTYLE",tst);
03415                             it.setAttribute("CAB",tsb);
03416                             it.setAttribute("CSTROKE",tcs);
03417                             it.setAttribute("CSHADE2",tshs);
03418                             it.setAttribute("CSCALE",tsc);
03419                             it.setAttribute("CSCALEV",tscv);
03420                             it.setAttribute("CBASE",tb);
03421                             it.setAttribute("CSHX",tsx);
03422                             it.setAttribute("CSHY",tsy);
03423                             it.setAttribute("COUT",tout);
03424                             it.setAttribute("CULP",tulp);
03425                             it.setAttribute("CULW",tulw);
03426                             it.setAttribute("CSTP",tstp);
03427                             it.setAttribute("CSTW",tstw);
03428                             if (tobj != -1)
03429                                    it.setAttribute("COBJ", tobj);
03430                             ob.appendChild(it);
03431                             break;
03432                      }
03433                      const CharStyle& style2(item->itemText.charStyle(k));
03434                      ch = item->itemText.text(k);
03435                      ts2 = style2.fontSize() / 10.0;
03436                      tf2 = style2.font().scName();
03437                      tc2 = style2.fillColor();
03438                      te2 = style2.tracking();
03439                      tsh2 = style2.fillShade();
03440                      tst2 = style2.effects() & ScStyle_UserStyles;
03441 #ifndef NLS_PROTO
03442                      tsb2 = findParagraphStyle(doc, item->itemText.paragraphStyle(k));
03443 #else
03444                      tsb2 = 0;
03445 #endif
03446                      tcs2 = style2.strokeColor();
03447                      tshs2 = style2.strokeShade();
03448                      tsc2 = style2.scaleH() / 10.0;
03449                      tscv2 = style2.scaleV() / 10.0;
03450                      tb2 = style2.baselineOffset() / 10.0;
03451                      tsx2 = style2.shadowXOffset() / 10.0;
03452                      tsy2 = style2.shadowYOffset() / 10.0;
03453                      tout2 = style2.outlineWidth() / 10.0;
03454                      tulp2 = style2.underlineOffset() / 10.0;
03455                      tulw2 = style2.underlineWidth() / 10.0;
03456                      tstp2 = style2.strikethruOffset() / 10.0;
03457                      tstw2 = style2.strikethruWidth() / 10.0;
03458 #ifndef NLS_PROTO
03459                      if ((ch == SpecialChars::OBJECT) && (item->itemText.item(k)->embedded.hasItem()))
03460                             tobj2 = item->itemText.item(k)->embedded.getItem()->ItemNr;
03461                      else
03462 #endif
03463                             tobj2 = -1;
03464                      while ((ts2 == ts)
03465                                           && (tsb2 == tsb)
03466                                           && (tf2 == tf)
03467                                           && (tc2 == tc)
03468                                           && (te2 == te)
03469                                           && (tsh2 == tsh)
03470                                           && (tshs2 == tshs)
03471                                           && (tsc2 == tsc)
03472                                           && (tscv2 == tscv)
03473                                           && (tcs2 == tcs)
03474                                           && (tb2 == tb)
03475                                           && (tsx2 == tsx)
03476                                           && (tsy2 == tsy)
03477                                           && (tout2 == tout)
03478                                           && (tulp2 == tulp)
03479                                           && (tulw2 == tulw)
03480                                           && (tstp2 == tstp)
03481                                           && (tstw2 == tstw)
03482                                           && (tobj2 == tobj)
03483                                           && (tst2 == tst))
03484                      {
03485                             if (ch == SpecialChars::PARSEP)
03486                                    text += QChar(5);
03487                             else if (ch == SpecialChars::TAB)
03488                                    text += QChar(4);
03489                             else
03490                                    text += ch;
03491                             ++k;
03492                             if (k == item->itemText.length())
03493                                    break;
03494                             const CharStyle& style3(item->itemText.charStyle(k));
03495                             ch = item->itemText.text(k);
03496                             ts2 = style3.fontSize() / 10.0;
03497                             tf2 = style3.font().scName();
03498                             tc2 = style3.fillColor();
03499                             te2 = style3.tracking();
03500                             tsh2 = style3.fillShade();
03501                             tst2 = style3.effects() & ScStyle_UserStyles;
03502 #ifndef NLS_PROTO
03503                             tsb2 = findParagraphStyle(doc, item->itemText.paragraphStyle(k));
03504 #else
03505                             tsb2 = 0;
03506 #endif
03507                             tcs2 = style3.strokeColor();
03508                             tshs2 = style3.strokeShade();
03509                             tsc2 = style3.scaleH() / 10.0;
03510                             tscv2 = style3.scaleV() / 10.0;
03511                             tb2 = style3.baselineOffset() / 10.0;
03512                             tsx2 = style3.shadowXOffset() / 10.0;
03513                             tsy2 = style3.shadowYOffset() / 10.0;
03514                             tout2 = style3.outlineWidth() / 10.0;
03515                             tulp2 = style3.underlineOffset() / 10.0;
03516                             tulw2 = style3.underlineWidth() / 10.0;
03517                             tstp2 = style3.strikethruOffset() / 10.0;
03518                             tstw2 = style3.strikethruWidth() / 10.0;
03519 #ifndef NLS_PROTO
03520                             if ((ch == SpecialChars::OBJECT) && (item->itemText.item(k)->embedded.hasItem()))
03521                                    tobj2 = item->itemText.item(k)->embedded.getItem()->ItemNr;
03522                             else
03523 #endif
03524                                    tobj2 = -1;
03525                      }
03526                      it.setAttribute("CH",text);
03527                      it.setAttribute("CSIZE",ts);
03528                      it.setAttribute("CFONT",tf);
03529                      it.setAttribute("CCOLOR",tc);
03530                      it.setAttribute("CKERN",te);
03531                      it.setAttribute("CSHADE",tsh);
03532                      it.setAttribute("CSTYLE",tst);
03533                      it.setAttribute("CAB",tsb);
03534                      it.setAttribute("CSTROKE",tcs);
03535                      it.setAttribute("CSHADE2",tshs);
03536                      it.setAttribute("CSCALE",tsc);
03537                      it.setAttribute("CSCALEV",tscv);
03538                      it.setAttribute("CBASE",tb);
03539                      it.setAttribute("CSHX",tsx);
03540                      it.setAttribute("CSHY",tsy);
03541                      it.setAttribute("COUT",tout);
03542                      it.setAttribute("CULP",tulp);
03543                      it.setAttribute("CULW",tulw);
03544                      it.setAttribute("CSTP",tstp);
03545                      it.setAttribute("CSTW",tstw);
03546                      if (tobj != -1)
03547                             it.setAttribute("COBJ", tobj);
03548                      k--;
03549                      ob.appendChild(it);
03550               }
03551               if (item->prevInChain() != 0)
03552                      ob.setAttribute("BACKITEM", item->prevInChain()->ItemNr);
03553               else
03554                      ob.setAttribute("BACKITEM", -1);
03555               if (item->nextInChain() != 0)
03556                      ob.setAttribute("NEXTITEM", item->nextInChain()->ItemNr);
03557               else
03558                      ob.setAttribute("NEXTITEM", -1);
03559               ob.setAttribute("LAYER", item->LayerNr);
03560 
03561               //CB PageItemAttributes
03562               QDomElement docItemAttrs = docu->createElement("PageItemAttributes");
03563               ObjAttrVector *attributes=item->getObjectAttributes();
03564               for(ObjAttrVector::Iterator objAttrIt = attributes->begin() ; objAttrIt != attributes->end(); ++objAttrIt )
03565               {
03566                      QDomElement itemAttr = docu->createElement("ItemAttribute");
03567                      itemAttr.setAttribute("Name", (*objAttrIt).name);
03568                      itemAttr.setAttribute("Type", (*objAttrIt).type);
03569                      itemAttr.setAttribute("Value", (*objAttrIt).value);
03570                      itemAttr.setAttribute("Parameter", (*objAttrIt).parameter);
03571                      itemAttr.setAttribute("Relationship", (*objAttrIt).relationship);
03572                      itemAttr.setAttribute("RelationshipTo", (*objAttrIt).relationshipto);
03573                      itemAttr.setAttribute("AutoAddTo", (*objAttrIt).autoaddto);
03574                      docItemAttrs.appendChild(itemAttr);
03575               }
03576               ob.appendChild(docItemAttrs);
03577 
03578               dc->appendChild(ob);
03579        }
03580 }
03581 
03582 void Scribus13Format::SetItemProps(QDomElement *ob, PageItem* item, bool newFormat)
03583 {
03584        double xf, yf;
03585        QString tmp, tmpy;
03586        if (newFormat)
03587               ob->setAttribute("OwnPage", item->OwnPage);
03588        ob->setAttribute("PTYPE",item->itemType());
03589        ob->setAttribute("XPOS",item->xPos());
03590        ob->setAttribute("YPOS",item->yPos());
03591        ob->setAttribute("WIDTH",item->width());
03592        ob->setAttribute("HEIGHT",item->height());
03593        ob->setAttribute("RADRECT",item->cornerRadius());
03594        ob->setAttribute("FRTYPE", item->FrameType);
03595        ob->setAttribute("CLIPEDIT", item->ClipEdited ? 1 : 0);
03596        ob->setAttribute("PWIDTH",item->lineWidth());
03597        ob->setAttribute("PCOLOR",item->fillColor());
03598        ob->setAttribute("PCOLOR2",item->lineColor());
03599        ob->setAttribute("TXTFILL",item->itemText.defaultStyle().charStyle().fillColor());
03600        ob->setAttribute("TXTSTROKE",item->itemText.defaultStyle().charStyle().strokeColor());
03601        ob->setAttribute("TXTSTRSH",item->itemText.defaultStyle().charStyle().strokeShade());
03602        ob->setAttribute("TXTFILLSH",item->itemText.defaultStyle().charStyle().fillShade());
03603        ob->setAttribute("TXTSCALE",item->itemText.defaultStyle().charStyle().scaleH() / 10.0);
03604        ob->setAttribute("TXTSCALEV",item->itemText.defaultStyle().charStyle().scaleV() / 10.0);
03605        ob->setAttribute("TXTBASE",item->itemText.defaultStyle().charStyle().baselineOffset() / 10.0);
03606        ob->setAttribute("TXTSHX",item->itemText.defaultStyle().charStyle().shadowXOffset() / 10.0);
03607        ob->setAttribute("TXTSHY",item->itemText.defaultStyle().charStyle().shadowYOffset() / 10.0);
03608        ob->setAttribute("TXTOUT",item->itemText.defaultStyle().charStyle().outlineWidth() / 10.0);
03609        ob->setAttribute("TXTULP",item->itemText.defaultStyle().charStyle().underlineOffset() / 10.0);
03610        ob->setAttribute("TXTULW",item->itemText.defaultStyle().charStyle().underlineWidth() / 10.0);
03611        ob->setAttribute("TXTSTP",item->itemText.defaultStyle().charStyle().strikethruOffset() / 10.0);
03612        ob->setAttribute("TXTSTW",item->itemText.defaultStyle().charStyle().strikethruWidth() / 10.0);
03613        ob->setAttribute("TXTSTYLE",item->itemText.defaultStyle().charStyle().effects());
03614        ob->setAttribute("COLUMNS", item->columns());
03615        ob->setAttribute("COLGAP", item->columnGap());
03616        ob->setAttribute("NAMEDLST",item->NamedLStyle);
03617        ob->setAttribute("SHADE",item->fillShade());
03618        ob->setAttribute("SHADE2",item->lineShade());
03619        ob->setAttribute("GRTYP",item->GrType);
03620        ob->setAttribute("ROT",item->rotation());
03621        ob->setAttribute("PLINEART",item->PLineArt);
03622        ob->setAttribute("PLINEEND", item->PLineEnd);
03623        ob->setAttribute("PLINEJOIN", item->PLineJoin);
03624        ob->setAttribute("LINESP",item->itemText.defaultStyle().lineSpacing());
03625        ob->setAttribute("LINESPMode", item->itemText.defaultStyle().lineSpacingMode());
03626        ob->setAttribute("TXTKERN",item->itemText.defaultStyle().charStyle().tracking());
03627        ob->setAttribute("LOCALSCX",item->imageXScale());
03628        ob->setAttribute("LOCALSCY",item->imageYScale());
03629        ob->setAttribute("LOCALX",item->imageXOffset());
03630        ob->setAttribute("LOCALY",item->imageYOffset());
03631        ob->setAttribute("PICART", item->imageShown() ? 1 : 0);
03632        ob->setAttribute("PLTSHOW", item->PoShow ? 1 : 0);
03633        ob->setAttribute("BASEOF", item->BaseOffs);
03634        ob->setAttribute("FLIPPEDH", item->imageFlippedH());
03635        ob->setAttribute("FLIPPEDV", item->imageFlippedV());
03636 /*     ob->setAttribute("BBOXX",item->BBoxX);
03637        ob->setAttribute("BBOXH",item->BBoxH); */
03638        ob->setAttribute("IFONT",item->itemText.defaultStyle().charStyle().font().scName());
03639        ob->setAttribute("ISIZE",item->itemText.defaultStyle().charStyle().fontSize() / 10.0 );
03640        ob->setAttribute("SCALETYPE", item->ScaleType ? 1 : 0);
03641        ob->setAttribute("RATIO", item->AspectRatio ? 1 : 0);
03642        ob->setAttribute("PRINTABLE", item->printEnabled() ? 1 : 0);
03643        if(item->isAnnotation())
03644        {
03645               ob->setAttribute("ANNOTATION",1);
03646               ob->setAttribute("ANTYPE", item->annotation().Type());
03647               ob->setAttribute("ANACTION", item->annotation().Action());
03648               ob->setAttribute("ANEACT", item->annotation().E_act());
03649               ob->setAttribute("ANXACT", item->annotation().X_act());
03650               ob->setAttribute("ANDACT", item->annotation().D_act());
03651               ob->setAttribute("ANFOACT", item->annotation().Fo_act());
03652               ob->setAttribute("ANBLACT", item->annotation().Bl_act());
03653               ob->setAttribute("ANKACT", item->annotation().K_act());
03654               ob->setAttribute("ANFACT", item->annotation().F_act());
03655               ob->setAttribute("ANVACT", item->annotation().V_act());
03656               ob->setAttribute("ANCACT", item->annotation().C_act());
03657               if (item->annotation().ActionType() == 8)
03658                      ob->setAttribute("ANEXTERN", item->annotation().Extern());
03659               else
03660                      ob->setAttribute("ANEXTERN", Path2Relative(item->annotation().Extern()));
03661               ob->setAttribute("ANZIEL", item->annotation().Ziel());
03662               ob->setAttribute("ANACTYP", item->annotation().ActionType());
03663               ob->setAttribute("ANTOOLTIP", item->annotation().ToolTip());
03664               ob->setAttribute("ANBWID", item->annotation().Bwid());
03665               ob->setAttribute("ANBSTY", item->annotation().Bsty());
03666               ob->setAttribute("ANFEED", item->annotation().Feed());
03667               ob->setAttribute("ANFLAG", item->annotation().Flag());
03668               ob->setAttribute("ANFONT", item->annotation().Font());
03669               ob->setAttribute("ANFORMAT", item->annotation().Format());
03670               ob->setAttribute("ANROLL", item->annotation().RollOver());
03671               ob->setAttribute("ANDOWN", item->annotation().Down());
03672               ob->setAttribute("ANVIS", item->annotation().Vis());
03673               ob->setAttribute("ANMC", item->annotation().MaxChar());
03674               ob->setAttribute("ANCHK", item->annotation().IsChk());
03675               ob->setAttribute("ANAA", item->annotation().AAact());
03676               ob->setAttribute("ANCHKS", item->annotation().ChkStil());
03677               ob->setAttribute("ANBCOL", item->annotation().borderColor());
03678               ob->setAttribute("ANHTML", item->annotation().HTML());
03679               ob->setAttribute("ANICON", item->annotation().UseIcons());
03680               ob->setAttribute("ANPLACE", item->annotation().IPlace());
03681               ob->setAttribute("ANSCALE", item->annotation().ScaleW());
03682        }
03683        else
03684               ob->setAttribute("ANNOTATION",0);
03685        ob->setAttribute("ANNAME", !item->AutoName ? item->itemName() : QString(""));
03686        // "TEXTFLOWMODE" succeed to "TEXTFLOW" "TEXTFLOW2" and "TEXTFLOW3" attributes
03687        ob->setAttribute("TEXTFLOWMODE", (int) item->textFlowMode() );
03688        // Set "TEXTFLOW" "TEXTFLOW2" and "TEXTFLOW3" attributes for compatibility
03689        // with versions prior to 1.3.4
03690        ob->setAttribute("TEXTFLOW" , item->textFlowAroundObject() ? 1 : 0);
03691        ob->setAttribute("TEXTFLOW2", item->textFlowUsesBoundingBox() ? 1 : 0);
03692        ob->setAttribute("TEXTFLOW3", item->textFlowUsesContourLine() ? 1 : 0);
03693        ob->setAttribute("AUTOTEXT", item->isAutoText ? 1 : 0);
03694        ob->setAttribute("EXTRA",item->textToFrameDistLeft());
03695        ob->setAttribute("TEXTRA",item->textToFrameDistTop());
03696        ob->setAttribute("BEXTRA",item->textToFrameDistBottom());
03697        ob->setAttribute("REXTRA",item->textToFrameDistRight());
03698        if (((item->asImageFrame()) || (item->asTextFrame())) && (!item->Pfile.isEmpty()))
03699               ob->setAttribute("PFILE",Path2Relative(item->Pfile));
03700        else
03701               ob->setAttribute("PFILE","");
03702        if (!item->Pfile2.isEmpty())
03703               ob->setAttribute("PFILE2",Path2Relative(item->Pfile2));
03704        else
03705               ob->setAttribute("PFILE2","");
03706        if (!item->Pfile3.isEmpty())
03707               ob->setAttribute("PFILE3",Path2Relative(item->Pfile3));
03708        else
03709               ob->setAttribute("PFILE3","");
03710        ob->setAttribute("PRFILE",item->IProfile);
03711        ob->setAttribute("EPROF", item->EmProfile);
03712        ob->setAttribute("IRENDER",item->IRender);
03713        ob->setAttribute("EMBEDDED", item->UseEmbedded ? 1 : 0);
03714        ob->setAttribute("LOCK", item->locked() ? 1 : 0);
03715        ob->setAttribute("LOCKR", item->sizeLocked() ? 1 : 0);
03716        ob->setAttribute("REVERS", item->reversed() ? 1 : 0);
03717        ob->setAttribute("TransValue", item->fillTransparency());
03718        ob->setAttribute("TransValueS", item->lineTransparency());
03719        ob->setAttribute("isTableItem", static_cast<int>(item->isTableItem));
03720        ob->setAttribute("TopLine", static_cast<int>(item->TopLine));
03721        ob->setAttribute("LeftLine", static_cast<int>(item->LeftLine));
03722        ob->setAttribute("RightLine", static_cast<int>(item->RightLine));
03723        ob->setAttribute("BottomLine", static_cast<int>(item->BottomLine));
03724        if (item->isTableItem)
03725        {
03726               if (item->TopLink != 0)
03727                      ob->setAttribute("TopLINK", item->TopLink->ItemNr);
03728               else
03729                      ob->setAttribute("TopLINK", -1);
03730               if (item->LeftLink != 0)
03731                      ob->setAttribute("LeftLINK", item->LeftLink->ItemNr);
03732               else
03733                      ob->setAttribute("LeftLINK", -1);
03734               if (item->RightLink != 0)
03735                      ob->setAttribute("RightLINK", item->RightLink->ItemNr);
03736               else
03737                      ob->setAttribute("RightLINK", -1);
03738               if (item->BottomLink != 0)
03739                      ob->setAttribute("BottomLINK", item->BottomLink->ItemNr);
03740               else
03741                      ob->setAttribute("BottomLINK", -1);
03742               ob->setAttribute("OwnLINK", item->ItemNr);
03743        }
03744        ob->setAttribute("NUMDASH", static_cast<int>(item->DashValues.count()));
03745        QString dlp = "";
03746        QValueList<double>::Iterator dax;
03747        for (dax = item->DashValues.begin(); dax != item->DashValues.end(); ++dax)
03748               dlp += tmp.setNum((*dax)) + " ";
03749        ob->setAttribute("DASHS", dlp);
03750        ob->setAttribute("DASHOFF", item->DashOffset);
03751        ob->setAttribute("NUMPO",item->PoLine.size());
03752        QString polp = "";
03753        for (uint nxx=0; nxx<item->PoLine.size(); ++nxx)
03754        {
03755               item->PoLine.point(nxx, &xf, &yf);
03756               polp += tmp.setNum(xf) + " " + tmpy.setNum(yf) + " ";
03757        }
03758        ob->setAttribute("POCOOR", polp);
03759        ob->setAttribute("NUMCO",item->ContourLine.size());
03760        QString colp = "";
03761        for (uint nxx=0; nxx<item->ContourLine.size(); ++nxx)
03762        {
03763               item->ContourLine.point(nxx, &xf, &yf);
03764               colp += tmp.setNum(xf) + " " + tmpy.setNum(yf) + " ";
03765        }
03766        ob->setAttribute("COCOOR", colp);
03767        ob->setAttribute("NUMGROUP", static_cast<int>(item->Groups.count()));
03768        QString glp = "";
03769        QValueStack<int>::Iterator nx;
03770        for (nx = item->Groups.begin(); nx != item->Groups.end(); ++nx)
03771               glp += tmp.setNum((*nx)) + " ";
03772        ob->setAttribute("GROUPS", glp);
03773        ob->setAttribute("LANGUAGE", item->itemText.defaultStyle().charStyle().language());
03774        ob->setAttribute("startArrowIndex", item->startArrowIndex());
03775        ob->setAttribute("endArrowIndex", item->endArrowIndex());
03776 }