Scribus Developer Documentation - API
logo-pen

Scribus Developer Documentation - API

scribus12format.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 "scribus12format.h"
00008 #include "scribus12formatimpl.h"
00009 
00010 #include "../../formatidlist.h"
00011 #include "commonstrings.h"
00012 #include "missing.h"
00013 #include "prefsmanager.h"
00014 #include "scconfig.h"
00015 #include "scribusdoc.h"
00016 #include "scribusview.h"
00017 
00018 #include "units.h"
00019 #include "util.h"
00020 #include "util_color.h"
00021 #include "scgzfile.h"
00022 #include <QCursor>
00023 #include <QFileInfo>
00024 #include <QList>
00025 #include <QByteArray>
00026 #include <QTextStream>
00027 #include <QApplication>
00028 
00029 
00030 // See scplugin.h and pluginmanager.{cpp,h} for detail on what these methods
00031 // do. That documentatation is not duplicated here.
00032 // Please don't implement the functionality of your plugin here; do that
00033 // in scribus12formatimpl.h and scribus12formatimpl.cpp .
00034 
00035 Scribus12Format::Scribus12Format() :
00036     LoadSavePlugin()
00037 {
00038     // Set action info in languageChange, so we only have to do
00039     // it in one place. This includes registering file formats.
00040     languageChange();
00041 }
00042 
00043 Scribus12Format::~Scribus12Format()
00044 {
00045     unregisterAll();
00046 };
00047 
00048 void Scribus12Format::languageChange()
00049 {
00050     //(Re)register file formats.
00051     unregisterAll();
00052     registerFormats();
00053 }
00054 
00055 const QString Scribus12Format::fullTrName() const
00056 {
00057     return QObject::tr("Scribus 1.2.x Support");
00058 }
00059 
00060 const ScActionPlugin::AboutData* Scribus12Format::getAboutData() const
00061 {
00062     AboutData* about = new AboutData;
00063     Q_CHECK_PTR(about);
00064     return about;
00065 }
00066 
00067 void Scribus12Format::deleteAboutData(const AboutData* about) const
00068 {
00069     Q_ASSERT(about);
00070     delete about;
00071 }
00072 
00073 // Low level plugin API
00074 int scribus12format_getPluginAPIVersion()
00075 {
00076     return PLUGIN_API_VERSION;
00077 }
00078 
00079 ScPlugin* scribus12format_getPlugin()
00080 {
00081     Scribus12Format* plug = new Scribus12Format();
00082     Q_CHECK_PTR(plug);
00083     return plug;
00084 }
00085 
00086 void scribus12format_freePlugin(ScPlugin* plugin)
00087 {
00088     Scribus12Format* plug = dynamic_cast<Scribus12Format*>(plugin);
00089     Q_ASSERT(plug);
00090     delete plug;
00091 }
00092 
00093 
00094 
00095 void Scribus12Format::registerFormats()
00096 {
00097     FileFormat fmt(this);
00098     fmt.trName = tr("Scribus 1.2.x Document");
00099     fmt.formatId = FORMATID_SLA12XIMPORT;
00100     fmt.load = true;
00101     fmt.save = false;
00102     fmt.filter = fmt.trName + " (*.sla *.SLA *.sla.gz *.SLA.GZ *.scd *.SCD *.scd.gz *.SCD.GZ)";
00103     fmt.nameMatch = QRegExp("\\.(sla|scd)(\\.gz)?", Qt::CaseInsensitive);
00104     fmt.mimeTypes = QStringList();
00105     fmt.mimeTypes.append("application/x-scribus");
00106     fmt.priority = 64;
00107     registerFormat(fmt);
00108 }
00109 
00110 bool Scribus12Format::fileSupported(QIODevice* /* file */, const QString & fileName) const
00111 {
00112     QByteArray docBytes("");
00113     if(fileName.right(2) == "gz")
00114     {
00115         ScGzFile gzf(fileName);
00116         if (!gzf.read(4096))
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     if (docBytes.left(16) != "<SCRIBUSUTF8NEW " && (docBytes.left(12) == "<SCRIBUSUTF8" || docBytes.left(9) == "<SCRIBUS>"))
00129         return true;
00130     return false;
00131 }
00132 
00133 QString Scribus12Format::readSLA(const QString & fileName)
00134 {
00135     QByteArray docBytes("");
00136     if(fileName.right(2) == "gz")
00137     {
00138         ScGzFile gzf(fileName);
00139         if (!gzf.read())
00140         {
00141             // FIXME: Needs better error return
00142             return false;
00143         }
00144         docBytes = gzf.data();
00145     }
00146     else
00147     {
00148         // Not gzip encoded, just load it
00149         loadRawText(fileName, docBytes);
00150     }
00151     QString docText("");
00152     if (docBytes.left(16) != "<SCRIBUSUTF8NEW ") // Not a 1.3.x doc
00153     {
00154         if (docBytes.left(12) == "<SCRIBUSUTF8") // 1.2.x UTF8 doc
00155             docText = QString::fromUtf8(docBytes);
00156         else if (docBytes.left(9) == "<SCRIBUS>") // Older non utf8 doc
00157             docText = QString::fromLocal8Bit(docBytes);
00158         else 
00159             return QString::null;
00160     }
00161     else
00162     {
00163         qDebug("scribus12format: SCRIBUSUTF8NEW");
00164         return QString::null;
00165     }
00166     if (docText.endsWith(QChar(10)) || docText.endsWith(QChar(13)))
00167         docText.truncate(docText.length()-1);
00168     return docText; return docText;
00169 }
00170 
00171 
00172 void Scribus12Format::getReplacedFontData(bool & getNewReplacement, QMap<QString,QString> &getReplacedFonts, QList<ScFace> &getDummyScFaces)
00173 {
00174     getNewReplacement=false;
00175     getReplacedFonts.clear();
00176     getDummyScFaces.clear();
00177 }
00178 
00179 static long long scribus12itemID(int itemNr, int pageNr)
00180 {
00181     return itemNr * 100000 + pageNr; 
00182 }
00183 
00184 bool Scribus12Format::loadFile(const QString & fileName, const FileFormat & /* fmt */, int /* flags */, int /* index */)
00185 {
00186     if (m_Doc==0 || m_View==0 || m_AvailableFonts==0)
00187     {
00188         Q_ASSERT(m_Doc==0 || m_View==0 || m_AvailableFonts==0);
00189         return false;
00190     }
00191 //  ReplacedFonts.clear();
00192 //  newReplacement = false;
00193 //  dummyScFaces.clear();
00194     DoVorl.clear();
00195     DoVorl[0] = "";
00196     DoVorl[1] = "";
00197     DoVorl[2] = "";
00198     DoVorl[3] = "";
00199     DoVorl[4] = "";
00200     VorlC = 5;
00201     
00202 //start old ReadDoc
00203     //Scribus 1.2 docs, see fileloader.cpp for 1.3 docs
00204     struct CopyPasteBuffer OB;
00205     ParagraphStyle vg;
00206     struct ScribusDoc::BookMa bok;
00207     int counter;
00208     bool newVersion = false;
00209     QString tmp, tmpf, tmp2, tmp3, tmp4, PgNam, Defont, tmf;
00210     QMap<int,int> TableID;
00211     QList<PageItem*> TableItems;
00212     int x, a;
00213 //  double xf, xf2;
00214     PageItem *Neu;
00215     itemRemap.clear();
00216     itemNext.clear();
00217     QDomDocument docu("scridoc");
00218     QFile fi(fileName);
00219     // Load the document text
00220     QString f(readSLA(fileName));
00221     if (f.isEmpty())
00222         return false;
00223     // Build the DOM from it
00224     if (!docu.setContent(f))
00225         return false;
00226     // Get file directory
00227     QString fileDir = QFileInfo(fileName).absolutePath();
00228     // and begin loading the doc
00229     m_Doc->PageColors.clear();
00230     m_Doc->Layers.clear();
00231     ScColor lf = ScColor();
00232     QDomElement elem=docu.documentElement();
00233     if ((elem.tagName() != "SCRIBUS") && (elem.tagName() != "SCRIBUSUTF8"))
00234         return false;
00235     if (elem.hasAttribute("Version"))
00236         newVersion = true;
00237     QDomNode DOC=elem.firstChild();
00238     if (m_mwProgressBar!=0)
00239     {
00240         m_mwProgressBar->setMaximum(DOC.childNodes().count());
00241         m_mwProgressBar->setValue(0);
00242     }
00243     int ObCount = 0;
00244     int activeLayer = 0;
00245     PrefsManager* prefsManager=PrefsManager::instance();
00246     while(!DOC.isNull())
00247     {
00248         QDomElement dc=DOC.toElement();
00249     /*
00250     * Attribute von DOCUMENT auslesen
00251     */
00252         if (dc.hasAttribute("PAGEWIDTH"))
00253             m_Doc->pageWidth=dc.attribute("PAGEWIDTH").toDouble();
00254         else
00255             m_Doc->pageWidth=dc.attribute("PAGEWITH").toDouble();
00256         m_Doc->pageHeight=dc.attribute("PAGEHEIGHT").toDouble();
00257         m_Doc->pageMargins.Left=qMax(0.0, dc.attribute("BORDERLEFT").toDouble());
00258         m_Doc->pageMargins.Right=qMax(0.0, dc.attribute("BORDERRIGHT").toDouble());
00259         m_Doc->pageMargins.Top=qMax(0.0, dc.attribute("BORDERTOP").toDouble());
00260         m_Doc->pageMargins.Bottom=qMax(0.0, dc.attribute("BORDERBOTTOM").toDouble());
00261         m_Doc->PageOri = dc.attribute("ORIENTATION", "0").toInt();
00262         m_Doc->m_pageSize = dc.attribute("PAGESIZE");
00263         m_Doc->FirstPnum = dc.attribute("FIRSTNUM", "1").toInt();
00264         m_Doc->currentPageLayout=dc.attribute("BOOK", "0").toInt();
00265         int fp;
00266         if (dc.attribute("FIRSTLEFT", "0").toInt() == 1)
00267             fp = 0;
00268         else
00269             fp = 1;
00270         if (m_Doc->currentPageLayout == 0)
00271             fp = 0;
00272         m_Doc->pageSets[m_Doc->currentPageLayout].FirstPage = fp;
00273         m_Doc->setUsesAutomaticTextFrames(dc.attribute("AUTOTEXT").toInt());
00274         m_Doc->PageSp=dc.attribute("AUTOSPALTEN").toInt();
00275         m_Doc->PageSpa=dc.attribute("ABSTSPALTEN").toDouble();
00276         m_Doc->setUnitIndex(dc.attribute("UNITS", "0").toInt());
00277         m_Doc->guidesSettings.gridShown = prefsManager->appPrefs.guidesSettings.gridShown;
00278         m_Doc->guidesSettings.guidesShown = prefsManager->appPrefs.guidesSettings.guidesShown;
00279         m_Doc->guidesSettings.colBordersShown = prefsManager->appPrefs.guidesSettings.colBordersShown;
00280         m_Doc->guidesSettings.framesShown = prefsManager->appPrefs.guidesSettings.framesShown;
00281         m_Doc->guidesSettings.layerMarkersShown = prefsManager->appPrefs.guidesSettings.layerMarkersShown;
00282         m_Doc->guidesSettings.marginsShown = prefsManager->appPrefs.guidesSettings.marginsShown;
00283         m_Doc->guidesSettings.baseShown = prefsManager->appPrefs.guidesSettings.baseShown;
00284         m_Doc->guidesSettings.linkShown = prefsManager->appPrefs.guidesSettings.linkShown;
00285         m_Doc->guidesSettings.showPic = true;
00286         m_Doc->guidesSettings.showControls = false;
00287 //      DoFonts.clear();
00288         m_Doc->toolSettings.defSize=qRound(dc.attribute("DSIZE").toDouble() * 10);
00289         Defont=dc.attribute("DFONT");
00290         m_Doc->toolSettings.defFont = prefsManager->appPrefs.toolSettings.defFont;
00291         m_AvailableFonts->findFont(Defont, m_Doc);
00292         m_Doc->toolSettings.defFont = Defont;
00293         m_Doc->toolSettings.dCols=dc.attribute("DCOL", "1").toInt();
00294         m_Doc->toolSettings.dGap=dc.attribute("DGAP", "0.0").toDouble();
00295         m_Doc->documentInfo.setAuthor(dc.attribute("AUTHOR"));
00296         m_Doc->documentInfo.setComments(dc.attribute("COMMENTS"));
00297         m_Doc->documentInfo.setKeywords(dc.attribute("KEYWORDS",""));
00298         m_Doc->documentInfo.setTitle(dc.attribute("TITLE"));
00299         m_Doc->documentInfo.setPublisher(dc.attribute("PUBLISHER", ""));
00300         m_Doc->documentInfo.setDate(dc.attribute("DOCDATE", ""));
00301         m_Doc->documentInfo.setType(dc.attribute("DOCTYPE", ""));
00302         m_Doc->documentInfo.setFormat(dc.attribute("DOCFORMAT", ""));
00303         m_Doc->documentInfo.setIdent(dc.attribute("DOCIDENT", ""));
00304         m_Doc->documentInfo.setSource(dc.attribute("DOCSOURCE", ""));
00305         m_Doc->documentInfo.setLangInfo(dc.attribute("DOCLANGINFO", ""));
00306         m_Doc->documentInfo.setRelation(dc.attribute("DOCRELATION", ""));
00307         m_Doc->documentInfo.setCover(dc.attribute("DOCCOVER", ""));
00308         m_Doc->documentInfo.setRights(dc.attribute("DOCRIGHTS", ""));
00309         m_Doc->documentInfo.setContrib(dc.attribute("DOCCONTRIB", ""));
00310         m_Doc->typographicSettings.valueSuperScript = dc.attribute("VHOCH").toInt();
00311         m_Doc->typographicSettings.scalingSuperScript = dc.attribute("VHOCHSC").toInt();
00312         m_Doc->typographicSettings.valueSubScript = dc.attribute("VTIEF").toInt();
00313         m_Doc->typographicSettings.scalingSubScript = dc.attribute("VTIEFSC").toInt();
00314         m_Doc->typographicSettings.valueSmallCaps = dc.attribute("VKAPIT").toInt();
00315         m_Doc->typographicSettings.valueBaseGrid = dc.attribute("BASEGRID", "12").toDouble();
00316         m_Doc->typographicSettings.offsetBaseGrid = dc.attribute("BASEO", "0").toDouble();
00317         m_Doc->typographicSettings.autoLineSpacing = dc.attribute("AUTOL", "20").toInt();
00318         m_Doc->GroupCounter=dc.attribute("GROUPC", "1").toInt();
00319         //m_Doc->HasCMS = static_cast<bool>(dc.attribute("HCMS", "0").toInt());
00320         m_Doc->CMSSettings.SoftProofOn = static_cast<bool>(dc.attribute("DPSo", "0").toInt());
00321         m_Doc->CMSSettings.SoftProofFullOn = static_cast<bool>(dc.attribute("DPSFo", "0").toInt());
00322         m_Doc->CMSSettings.CMSinUse = static_cast<bool>(dc.attribute("DPuse", "0").toInt());
00323         m_Doc->CMSSettings.GamutCheck = static_cast<bool>(dc.attribute("DPgam", "0").toInt());
00324         m_Doc->CMSSettings.BlackPoint = static_cast<bool>(dc.attribute("DPbla", "1").toInt());
00325         m_Doc->CMSSettings.DefaultMonitorProfile = dc.attribute("DPMo","");
00326         m_Doc->CMSSettings.DefaultPrinterProfile = dc.attribute("DPPr","");
00327         m_Doc->CMSSettings.DefaultImageRGBProfile = dc.attribute("DPIn","");
00328         m_Doc->CMSSettings.DefaultImageCMYKProfile = dc.attribute("DPPr",""); // Use DPPr to match 1.2.x behavior
00329         m_Doc->CMSSettings.DefaultSolidColorRGBProfile = dc.attribute("DPIn2","");
00330         m_Doc->CMSSettings.DefaultSolidColorCMYKProfile = dc.attribute("DPPr",""); // Use DPPr to match 1.2.x behavior
00331         //m_Doc->CMSSettings.DefaultIntentPrinter = dc.attribute("DIPr", "0").toInt();
00332         //m_Doc->CMSSettings.DefaultIntentMonitor = dc.attribute("DIMo", "1").toInt();
00333         m_Doc->CMSSettings.DefaultIntentColors = dc.attribute("DISc", "1").toInt();
00334         m_Doc->CMSSettings.DefaultIntentImages = dc.attribute("DIIm", "0").toInt();
00335         activeLayer = dc.attribute("ALAYER", "0").toInt();
00336         m_Doc->Language = dc.attribute("LANGUAGE", "");
00337         m_Doc->MinWordLen = dc.attribute("MINWORDLEN", "3").toInt();
00338         m_Doc->HyCount = dc.attribute("HYCOUNT", "2").toInt();
00339         m_Doc->Automatic = static_cast<bool>(dc.attribute("AUTOMATIC", "1").toInt());
00340         m_Doc->AutoCheck = static_cast<bool>(dc.attribute("AUTOCHECK", "0").toInt());
00341         m_Doc->GuideLock = static_cast<bool>(dc.attribute("GUIDELOCK", "0").toInt());
00342         m_Doc->SnapGuides = static_cast<bool>(dc.attribute("SnapToGuides", "0").toInt());
00343         m_Doc->useRaster = static_cast<bool>(dc.attribute("SnapToGrid", "0").toInt());
00344         m_Doc->guidesSettings.minorGrid = dc.attribute("MINGRID", tmp.setNum(prefsManager->appPrefs.guidesSettings.minorGrid)).toDouble();
00345         m_Doc->guidesSettings.majorGrid = dc.attribute("MAJGRID", tmp.setNum(prefsManager->appPrefs.guidesSettings.majorGrid)).toDouble();
00346         m_Doc->toolSettings.dStartArrow = 0;
00347         m_Doc->toolSettings.dEndArrow = 0;
00348         m_Doc->LastAuto = 0;
00349         QDomNode PAGE=DOC.firstChild();
00350         counter = 0;
00351         while(!PAGE.isNull())
00352         {
00353             ObCount++;
00354             if (m_mwProgressBar!=0)
00355                 m_mwProgressBar->setValue(ObCount);
00356             QDomElement pg=PAGE.toElement();
00357             // 10/25/2004 pv - None is "reserved" color. cannot be defined in any file...
00358             if(pg.tagName()=="COLOR" && pg.attribute("NAME")!=CommonStrings::None)
00359             {
00360                 if (pg.hasAttribute("CMYK"))
00361                     lf.setNamedColor(pg.attribute("CMYK"));
00362                 else
00363                     lf.fromQColor(QColor(pg.attribute("RGB")));
00364                 lf.setSpotColor(false);
00365                 lf.setRegistrationColor(false);
00366                 m_Doc->PageColors.insert(pg.attribute("NAME"), lf);
00367             }
00368             if(pg.tagName()=="STYLE")
00369             {
00370                 vg.erase();
00371                 GetStyle(&pg, &vg, NULL, m_Doc, true);
00372                 StyleSet<ParagraphStyle> temp;
00373                 temp.create(vg);
00374                 m_Doc->redefineStyles(temp, false);
00375             }
00376             if(pg.tagName()=="JAVA")
00377                 m_Doc->JavaScripts[pg.attribute("NAME")] = pg.attribute("SCRIPT");
00378             if(pg.tagName()=="LAYERS")
00379             {
00380                 int lnr   = pg.attribute("NUMMER").toInt();
00381                 int level = pg.attribute("LEVEL").toInt();
00382                 ScLayer la( pg.attribute("NAME"), level, lnr);
00383                 la.isViewable = pg.attribute("SICHTBAR").toInt();
00384                 la.isPrintable = pg.attribute("DRUCKEN").toInt();
00385                 m_Doc->Layers.append(la);
00386             }
00387             if(pg.tagName()=="MultiLine")
00388             {
00389                 multiLine ml;
00390                 QDomNode MuLn = PAGE.firstChild();
00391                 while(!MuLn.isNull())
00392                 {
00393                     QDomElement MuL = MuLn.toElement();
00394                     struct SingleLine sl;
00395                     sl.Color = MuL.attribute("Color");
00396                     sl.Dash = MuL.attribute("Dash").toInt();
00397                     sl.LineEnd = MuL.attribute("LineEnd").toInt();
00398                     sl.LineJoin = MuL.attribute("LineJoin").toInt();
00399                     sl.Shade = MuL.attribute("Shade").toInt();
00400                     sl.Width = MuL.attribute("Width").toDouble();
00401                     ml.push_back(sl);
00402                     MuLn = MuLn.nextSibling();
00403                 }
00404                 m_Doc->MLineStyles.insert(pg.attribute("Name"), ml);
00405             }
00406             if(pg.tagName()=="PAGE")
00407             {
00408                 TableItems.clear();
00409                 TableID.clear();
00410             /*
00411             * Attribute von PAGE auslesen
00412             */
00413                 a = pg.attribute("NUM").toInt();
00414                 PgNam = "";
00415                 PgNam = pg.attribute("NAM", "");
00416                 QString Mus = "";
00417                 Mus = pg.attribute("MNAM","Normal");
00418                 if (PgNam.isEmpty())
00419                 {
00420                     //We store the pages master page but do not apply it now
00421                     //as it may not exist yet. They are applied in scribus.cpp for now.
00422                     m_Doc->setMasterPageMode(false);
00423                     m_Doc->setCurrentPage(m_Doc->addPage(a));
00424                     m_Doc->currentPage()->MPageNam=Mus;
00425                 }
00426                 else
00427                 {
00428                     m_Doc->setMasterPageMode(true);
00429                     m_Doc->setCurrentPage(m_Doc->addMasterPage(a, PgNam));
00430                 }
00431                 //CB: Remove this unnecessarily "slow" slot call when we have no gui for the doc yet!
00432                 //Items dont appear in the right place if we just m_Doc->addPage(a); for <=1.2.x docs
00433                 //so we have to call the view, but we certainly dont need to emit to the mainwindow!
00434                 //This call now picks up the added page and does some view black magic. A must for
00435                 //1.2.x docs!
00436                 m_View->addPage(a);
00437                 //emit NewPage(a);
00438                 m_Doc->Pages->at(a)->LeftPg=pg.attribute("LEFT", "0").toInt();
00439 
00440                 // guides reading
00441                 tmp = "";
00442                 GuideManagerIO::readVerticalGuides(pg.attribute("VerticalGuides"),
00443                             m_Doc->Pages->at(a),
00444                             GuideManagerCore::Standard,
00445                             pg.hasAttribute("NumVGuides"));
00446                 GuideManagerIO::readHorizontalGuides(pg.attribute("HorizontalGuides"),
00447                             m_Doc->Pages->at(a),
00448                             GuideManagerCore::Standard,
00449                             pg.hasAttribute("NumHGuides"));
00450 
00451                 QDomNode OBJ=PAGE.firstChild();
00452                 int pageNo = a;
00453                 int pageItem = 0;
00454                 while(!OBJ.isNull())
00455                 {
00456                     QDomElement obj=OBJ.toElement();
00457                     /*
00458                      * Attribute von OBJECT auslesen
00459                      */
00460                     if (!m_Doc->masterPageMode())
00461                     {
00462                         const long long itemID = scribus12itemID(pageItem++, pageNo);
00463 //                      qDebug(QString("1.2 remap: %1 -> %2 [%3 on page %4]").arg(itemID).arg(m_Doc->Items->count()).arg(pageItem-1).arg(pageNo));
00464                         itemRemap[itemID] = m_Doc->Items->count();
00465                         if (obj.tagName()=="PAGEOBJECT")
00466                         {
00467                             // member of linked chain?
00468                             if (obj.attribute("NEXTITEM").toInt() != -1)
00469                             {
00470                                 itemNext[m_Doc->Items->count()] = scribus12itemID(obj.attribute("NEXTITEM").toInt(), obj.attribute("NEXTPAGE").toInt());
00471                             }
00472                         }
00473                     }
00474                     GetItemProps(&obj, &OB, fileDir, newVersion);
00475                     OB.Xpos = obj.attribute("XPOS").toDouble()+m_Doc->Pages->at(a)->xOffset();
00476                     OB.Ypos=obj.attribute("YPOS").toDouble()+m_Doc->Pages->at(a)->yOffset();
00477                     OB.NamedLStyle = obj.attribute("NAMEDLST", "");
00478                     OB.isBookmark=obj.attribute("BOOKMARK").toInt();
00479                     if ((OB.isBookmark) && (m_Doc->BookMarks.count() == 0))
00480                         m_Doc->OldBM = true;
00481                     OB.textAlignment = obj.attribute("ALIGN", "0").toInt();
00482                     OB.startArrowIndex =  0;
00483                     OB.endArrowIndex =  0;
00484                     tmpf = obj.attribute("IFONT", m_Doc->toolSettings.defFont);
00485                     m_AvailableFonts->findFont(tmpf, m_Doc);
00486                     OB.IFont = tmpf;
00487                     OB.LayerNr = obj.attribute("LAYER", "0").toInt();
00488                     OB.Language = obj.attribute("LANGUAGE", m_Doc->Language);
00489                     tmp = "";
00490                     if ((obj.hasAttribute("GROUPS")) && (obj.attribute("NUMGROUP", "0").toInt() != 0))
00491                     {
00492                         tmp = obj.attribute("GROUPS");
00493                         QTextStream fg(&tmp, QIODevice::ReadOnly);
00494                         OB.Groups.clear();
00495                         for (int cx = 0; cx < obj.attribute("NUMGROUP", "0").toInt(); ++cx)
00496                         {
00497                             fg >> x;
00498                             OB.Groups.push(x);
00499                         }
00500                         tmp = "";
00501                     }
00502                     else
00503                         OB.Groups.clear();
00504                     QDomNode IT=OBJ.firstChild();
00505                     while(!IT.isNull())
00506                     {
00507                         QDomElement it=IT.toElement();
00508                         if (it.tagName()=="CSTOP")
00509                         {
00510                             QString name = it.attribute("NAME");
00511                             double ramp = it.attribute("RAMP", "0.0").toDouble();
00512                             int shade = it.attribute("SHADE", "100").toInt();
00513                             double opa = it.attribute("TRANS", "1").toDouble();
00514                             handleOldColorShade(m_Doc, name, shade);
00515                             OB.fill_gradient.addStop(SetColor(m_Doc, name, shade), ramp, 0.5, opa, name, shade);
00516                             OB.GrColor = "";
00517                             OB.GrColor2 = "";
00518                         }
00519                         IT=IT.nextSibling();
00520                     }
00521                     OB.itemText = "";
00522                     int docGc = m_Doc->GroupCounter;
00523                     m_Doc->GroupCounter = 0;
00524                     uint last = m_Doc->Items->count();
00525                     m_View->PasteItem(&OB, true);
00526                     m_Doc->GroupCounter = docGc;
00527                     Neu = m_Doc->Items->at(last);
00528                     Neu->OnMasterPage = PgNam;
00529                     Neu->OwnPage = a; //No need to scan for OnPage as we know page by page in 1.2.x
00530                     Neu->oldOwnPage = 0;
00531                     Neu->setRedrawBounding();
00532                     IT=OBJ.firstChild();
00533                     LastStyles * lastS = new LastStyles();
00534                     while(!IT.isNull())
00535                     {
00536                         QDomElement it=IT.toElement();
00537                         if (it.tagName()=="ITEXT")
00538                             GetItemText(&it, m_Doc, true, false, Neu, lastS);
00539                         IT=IT.nextSibling();
00540                     }
00541                     delete lastS;
00542                     Neu->isAutoText=static_cast<bool>(obj.attribute("AUTOTEXT").toInt());
00543                     if (Neu->isAutoText)
00544                         m_Doc->LastAuto = Neu;
00545 //                  Neu->NextIt = obj.attribute("NEXTITEM").toInt();
00546 //                  nextPg[Neu->ItemNr] = obj.attribute("NEXTPAGE").toInt();
00547                     if (Neu->isTableItem)
00548                     {
00549                         TableItems.append(Neu);
00550                         TableID.insert(obj.attribute("OwnLINK", "0").toInt(), Neu->ItemNr);
00551                     }
00552                     counter++;
00553                     OBJ=OBJ.nextSibling();
00554                 }
00555                 if (TableItems.count() != 0)
00556                 {
00557                     for (int ttc = 0; ttc < TableItems.count(); ++ttc)
00558                     {
00559                         PageItem* ta = TableItems.at(ttc);
00560                         if (ta->TopLinkID != -1)
00561                             ta->TopLink = m_Doc->Items->at(TableID[ta->TopLinkID]);
00562                         else
00563                             ta->TopLink = 0;
00564                         if (ta->LeftLinkID != -1)
00565                             ta->LeftLink = m_Doc->Items->at(TableID[ta->LeftLinkID]);
00566                         else
00567                             ta->LeftLink = 0;
00568                         if (ta->RightLinkID != -1)
00569                             ta->RightLink = m_Doc->Items->at(TableID[ta->RightLinkID]);
00570                         else
00571                             ta->RightLink = 0;
00572                         if (ta->BottomLinkID != -1)
00573                             ta->BottomLink = m_Doc->Items->at(TableID[ta->BottomLinkID]);
00574                         else
00575                             ta->BottomLink = 0;
00576                     }
00577                 }
00578             }
00579             PAGE=PAGE.nextSibling();
00580         }
00581         m_Doc->setMasterPageMode(false);
00582         PAGE=DOC.firstChild();
00583         while(!PAGE.isNull())
00584         {
00585             QDomElement pg=PAGE.toElement();
00586             if(pg.tagName()=="Bookmark")
00587             {
00588                 int elem = pg.attribute("Element").toInt();
00589                 if (elem < m_Doc->Items->count())
00590                 {
00591                     bok.Title = pg.attribute("Title");
00592                     bok.Text = pg.attribute("Text");
00593                     bok.Aktion = pg.attribute("Aktion");
00594                     bok.ItemNr = pg.attribute("ItemNr").toInt();
00595                     bok.PageObject = m_Doc->Items->at(elem);
00596                     bok.First = pg.attribute("First").toInt();
00597                     bok.Last = pg.attribute("Last").toInt();
00598                     bok.Prev = pg.attribute("Prev").toInt();
00599                     bok.Next = pg.attribute("Next").toInt();
00600                     bok.Parent = pg.attribute("Parent").toInt();
00601                     m_Doc->BookMarks.append(bok);
00602                 }
00603             }
00604             if(pg.tagName()=="PDF")
00605             {
00606                 m_Doc->PDF_Options.Articles = static_cast<bool>(pg.attribute("Articles").toInt());
00607                 m_Doc->PDF_Options.Thumbnails = static_cast<bool>(pg.attribute("Thumbnails").toInt());
00608                 m_Doc->PDF_Options.Compress = static_cast<bool>(pg.attribute("Compress").toInt());
00609                 m_Doc->PDF_Options.CompressMethod = (PDFOptions::PDFCompression) pg.attribute("CMethod", "0").toInt();
00610                 m_Doc->PDF_Options.Quality = pg.attribute("Quality", "0").toInt();
00611                 m_Doc->PDF_Options.RecalcPic = static_cast<bool>(pg.attribute("RecalcPic").toInt());
00612                 m_Doc->PDF_Options.Bookmarks = static_cast<bool>(pg.attribute("Bookmarks").toInt());
00613                 if (pg.hasAttribute("MirrorH"))
00614                     m_Doc->PDF_Options.MirrorH = static_cast<bool>(pg.attribute("MirrorH").toInt());
00615                 else
00616                     m_Doc->PDF_Options.MirrorH = false;
00617                 if (pg.hasAttribute("MirrorV"))
00618                     m_Doc->PDF_Options.MirrorV = static_cast<bool>(pg.attribute("MirrorV").toInt());
00619                 else
00620                     m_Doc->PDF_Options.MirrorV = false;
00621                 if (pg.hasAttribute("RotateDeg"))
00622                     m_Doc->PDF_Options.RotateDeg = pg.attribute("RotateDeg", "0").toInt();
00623                 else
00624                     m_Doc->PDF_Options.RotateDeg = 0;
00625                 m_Doc->PDF_Options.PresentMode = static_cast<bool>(pg.attribute("PresentMode").toInt());
00626                 m_Doc->PDF_Options.PicRes = pg.attribute("PicRes").toInt();
00627                 m_Doc->PDF_Options.Version = (PDFOptions::PDFVersion)pg.attribute("Version").toInt();
00628                 m_Doc->PDF_Options.Resolution = pg.attribute("Resolution").toInt();
00629                 m_Doc->PDF_Options.Binding = pg.attribute("Binding").toInt();
00630                 m_Doc->PDF_Options.Datei = "";
00631                 m_Doc->PDF_Options.isGrayscale = false;
00632                 m_Doc->PDF_Options.UseRGB = static_cast<bool>(pg.attribute("RGBMode", "0").toInt());
00633                 m_Doc->PDF_Options.UseProfiles = static_cast<bool>(pg.attribute("UseProfiles", "0").toInt());
00634                 m_Doc->PDF_Options.UseProfiles2 = static_cast<bool>(pg.attribute("UseProfiles2", "0").toInt());
00635                 m_Doc->PDF_Options.Intent = pg.attribute("Intent", "1").toInt();
00636                 m_Doc->PDF_Options.Intent2 = pg.attribute("Intent2", "1").toInt();
00637                 m_Doc->PDF_Options.SolidProf = pg.attribute("SolidP", "");
00638                 m_Doc->PDF_Options.ImageProf = pg.attribute("ImageP", "");
00639                 m_Doc->PDF_Options.PrintProf = pg.attribute("PrintP", "");
00640                 m_Doc->PDF_Options.Info = pg.attribute("InfoString", "");
00641                 m_Doc->PDF_Options.bleeds.Top = pg.attribute("BTop", "0").toDouble();
00642                 m_Doc->PDF_Options.bleeds.Left = pg.attribute("BLeft", "0").toDouble();
00643                 m_Doc->PDF_Options.bleeds.Right = pg.attribute("BRight", "0").toDouble();
00644                 m_Doc->PDF_Options.bleeds.Bottom = pg.attribute("BBottom", "0").toDouble();
00645                 m_Doc->PDF_Options.EmbeddedI = static_cast<bool>(pg.attribute("ImagePr", "0").toInt());
00646                 m_Doc->PDF_Options.PassOwner = pg.attribute("PassOwner", "");
00647                 m_Doc->PDF_Options.PassUser = pg.attribute("PassUser", "");
00648                 m_Doc->PDF_Options.Permissions = pg.attribute("Permissions", "-4").toInt();
00649                 m_Doc->PDF_Options.Encrypt = static_cast<bool>(pg.attribute("Encrypt", "0").toInt());
00650                 m_Doc->PDF_Options.useLayers = static_cast<bool>(pg.attribute("UseLayers", "0").toInt());
00651                 m_Doc->PDF_Options.UseLPI = static_cast<bool>(pg.attribute("UseLpi", "0"