Back to index

scribus-ng  1.3.4.dfsg+svn20071115
scribusXml.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 /***************************************************************************
00008                      scribusXml.cpp the document xml library for scribus
00009                              -------------------
00010     begin                : Sam Jul 14 10:00:00 CEST 2001
00011     copyright            : (C) 2001 by Christian T�p
00012     email                : christian.toepp@mr-ct@gmx.de
00013  ***************************************************************************/
00014 
00015 #include "scribusXml.h"
00016 #include "scribusXml.moc"
00017 #include <qfile.h>
00018 #include <qtextstream.h>
00019 #include <qapplication.h>
00020 #include <qtl.h>
00021 #include <qcursor.h>
00022 #include <qregexp.h>
00023 #include <qdir.h>
00024 #include <qtextcodec.h>
00025 #include <cstdlib>
00026 #include <cmath>
00027 #include "missing.h"
00028 #include "page.h"
00029 #include "pageitem.h"
00030 #include "units.h"
00031 #include "prefsmanager.h"
00032 #include "scribusview.h"
00033 #include "commonstrings.h"
00034 #include "text/nlsconfig.h"
00035 
00036 #include <iostream>
00037 
00038 #include "scconfig.h"
00039 
00040 #include <zlib.h>
00041 #include "util.h"
00042 #include "colorutil.h"
00043 #include "scpattern.h"
00044 
00045 using namespace std;
00046 
00047 ScriXmlDoc::ScriXmlDoc()
00048 {
00049        prefsManager=PrefsManager::instance();
00050 }
00051 
00052 void ScriXmlDoc::GetItemText(QDomElement *it, ScribusDoc *doc, bool VorLFound, bool impo, PageItem* obj)
00053 {
00054        QString tmp2, tmf, tmpf, tmp3;
00055        tmp2 = it->attribute("CH");
00056        tmp2.replace(QRegExp("\r"), QChar(5));
00057        tmp2.replace(QRegExp("\n"), QChar(5));
00058        tmp2.replace(QRegExp("\t"), QChar(4));
00059        tmpf = it->attribute("CFONT", doc->toolSettings.defFont);
00060        bool unknown = false;
00061        ScFace dummy = ScFace::none();
00062        if ((!prefsManager->appPrefs.AvailFonts.contains(tmpf)) || (!prefsManager->appPrefs.AvailFonts[tmpf].usable()))
00063        {
00064               bool isThere = false;
00065               for (uint dl = 0; dl < dummyScFaces.count(); ++dl)
00066               {
00067                      if ((*dummyScFaces.at(dl)).scName() == tmpf)
00068                      {
00069                             isThere = true;
00070                             dummy = *dummyScFaces.at(dl);
00071                             break;
00072                      }
00073               }
00074               if (!isThere)
00075               {
00076 //FIXME                     dummy = new ScFace(tmpf, "", tmpf, "", "", 1, false);
00077                      dummyScFaces.append(dummy);
00078               }
00079               unknown = true;
00080               if ((!prefsManager->appPrefs.GFontSub.contains(tmpf)) || (!prefsManager->appPrefs.AvailFonts[prefsManager->appPrefs.GFontSub[tmpf]].usable()))
00081               {
00082                      newReplacement = true;
00083                      ReplacedFonts.insert(tmpf, prefsManager->appPrefs.toolSettings.defFont);
00084               }
00085               else
00086                      ReplacedFonts.insert(tmpf, prefsManager->appPrefs.GFontSub[tmpf]);
00087        }
00088        else
00089        {
00090               if (!doc->UsedFonts.contains(tmpf))
00091               {
00092 //                   QFont fo = prefsManager->appPrefs.AvailFonts[tmpf]->Font;
00093 //                   fo.setPointSize(qRound(doc->toolSettings.defSize / 10.0));
00094                      doc->AddFont(tmpf);
00095               }
00096        }
00097        int size = qRound(it->attribute("CSIZE").toDouble() * 10);
00098        QString fcolor = it->attribute("CCOLOR");
00099        int extra;
00100        if (it->hasAttribute("CEXTRA"))
00101               extra = qRound(it->attribute("CEXTRA").toDouble() / it->attribute("CSIZE").toDouble() * 1000.0);
00102        else
00103               extra = it->attribute("CKERN").toInt();
00104        int shade = it->attribute("CSHADE").toInt();
00105        int cstyle = it->attribute("CSTYLE").toInt() & 2047;
00106        QString stroke = it->attribute("CSTROKE",CommonStrings::None);
00107        int shade2 = it->attribute("CSHADE2", "100").toInt();
00108        int scale = qRound(it->attribute("CSCALE", "100").toDouble() * 10);
00109        int scalev = qRound(it->attribute("CSCALEV", "100").toDouble() * 10);
00110        int base = qRound(it->attribute("CBASE", "0").toDouble() * 10);
00111        int shX = qRound(it->attribute("CSHX", "5").toDouble() * 10);
00112        int shY = qRound(it->attribute("CSHY", "-5").toDouble() * 10);
00113        int outL = qRound(it->attribute("COUT", "1").toDouble() * 10);
00114        int ulp = qRound(it->attribute("CULP", "-0.1").toDouble() * 10);
00115        int ulw = qRound(it->attribute("CULW", "-0.1").toDouble() * 10);
00116        int stp = qRound(it->attribute("CSTP", "-0.1").toDouble() * 10);
00117        int stw = qRound(it->attribute("CSTW", "-0.1").toDouble() * 10);
00118        QString pstyleName = it->attribute("PSTYLE", "");
00119        for (uint cxx=0; cxx<tmp2.length(); ++cxx)
00120        {
00121               CharStyle style;
00122               QChar ch = tmp2.at(cxx);
00123               if (ch == QChar(5))
00124                      ch = SpecialChars::PARSEP;
00125               if (ch == QChar(4))
00126                      ch = SpecialChars::TAB;
00127               if (unknown)
00128                      style.setFont(dummy);
00129               else
00130                      style.setFont((*doc->AllFonts)[tmpf]);
00131               style.setFontSize(size);
00132               style.setFillColor(fcolor);
00133               style.setTracking(extra);
00134               style.setFillShade(shade);
00135               style.setFeatures(static_cast<StyleFlag>(cstyle).featureList());
00136 /*
00137  int pstyleNr;
00138               if (impo)
00139               {
00140                             if (VorLFound)
00141                                    pstyleNr = DoVorl[ab].toUInt();
00142                             else
00143                             {
00144                                    if (ab < 5)
00145                                           pstyleNr = ab;
00146                                    else
00147                                           pstyleNr = 0;
00148                             }
00149               }
00150               else
00151                      pstyleNr = ab;
00152 */            
00153               style.setStrokeColor(stroke);
00154               style.setStrokeShade(shade2);
00155               style.setScaleH(QMIN(QMAX(scale, 100), 4000));
00156               style.setScaleV(QMIN(QMAX(scalev, 100), 4000));
00157               style.setBaselineOffset(base);
00158               style.setShadowXOffset(shX);
00159               style.setShadowYOffset(shY);
00160               style.setOutlineWidth(outL);
00161               style.setUnderlineOffset(ulp);
00162               style.setUnderlineWidth(ulw);
00163               style.setStrikethruOffset(stp);
00164               style.setStrikethruWidth(stw);
00165               int pos = obj->itemText.length();
00166               obj->itemText.insertChars(pos, QString(ch));
00167               if (ch == SpecialChars::PARSEP)
00168               {
00169                      ParagraphStyle pstyle;
00170                      pstyle.setParent(pstyleName);
00171                      obj->itemText.applyStyle(pos, pstyle);
00172               }
00173               else
00174                      obj->itemText.applyCharStyle(pos, 1, style);
00175        }
00176        return;
00177 }
00178 
00179 QString ScriXmlDoc::AskForFont(SCFonts &avail, QString fStr, ScribusDoc *doc)
00180 {
00181        PrefsManager *prefsManager=PrefsManager::instance();
00182 //     QFont fo;
00183        QString tmpf = fStr;
00184        if ((!avail.contains(tmpf)) || (!avail[tmpf].usable()))
00185        {
00186               if ((!prefsManager->appPrefs.GFontSub.contains(tmpf)) || (!avail[prefsManager->appPrefs.GFontSub[tmpf]].usable()))
00187               {
00188                      qApp->setOverrideCursor(QCursor(arrowCursor), true);
00189                      MissingFont *dia = new MissingFont(0, tmpf, doc);
00190                      dia->exec();
00191                      tmpf = dia->getReplacementFont();
00192                      delete dia;
00193                      qApp->setOverrideCursor(QCursor(waitCursor), true);
00194                      prefsManager->appPrefs.GFontSub[fStr] = tmpf;
00195               }
00196               else
00197                      tmpf = prefsManager->appPrefs.GFontSub[tmpf];
00198               ReplacedFonts[fStr] = tmpf;
00199        }
00200        if (!doc->UsedFonts.contains(tmpf))
00201        {
00202 //            fo = avail[tmpf]->Font;
00203 //            fo.setPointSize(qRound(doc->toolSettings.defSize / 10.0));
00204               doc->AddFont(tmpf);
00205        }
00206        DoFonts[fStr] = tmpf;
00207        return tmpf;
00208 }
00209 
00210 void ScriXmlDoc::SetItemProps(QDomElement *ob, PageItem* item, bool newFormat)
00211 {
00212        double xf, yf;
00213        QString tmp, tmpy;
00214        if (newFormat)
00215               ob->setAttribute("OwnPage", item->OwnPage);
00216        ob->setAttribute("PTYPE",item->itemType());
00217        ob->setAttribute("XPOS",item->xPos());
00218        ob->setAttribute("YPOS",item->yPos());
00219        ob->setAttribute("WIDTH",item->width());
00220        ob->setAttribute("HEIGHT",item->height());
00221        ob->setAttribute("RADRECT",item->cornerRadius());
00222        ob->setAttribute("FRTYPE", item->FrameType);
00223        ob->setAttribute("CLIPEDIT", item->ClipEdited ? 1 : 0);
00224        ob->setAttribute("PWIDTH",item->lineWidth());
00225        ob->setAttribute("PCOLOR",item->fillColor());
00226        ob->setAttribute("PCOLOR2",item->lineColor());
00227        ob->setAttribute("TXTFILL",item->itemText.defaultStyle().charStyle().fillColor());
00228        ob->setAttribute("TXTSTROKE",item->itemText.defaultStyle().charStyle().strokeColor());
00229        ob->setAttribute("TXTSTRSH",item->itemText.defaultStyle().charStyle().strokeShade());
00230        ob->setAttribute("TXTFILLSH",item->itemText.defaultStyle().charStyle().fillShade());
00231        ob->setAttribute("TXTSCALE",item->itemText.defaultStyle().charStyle().scaleH() / 10.0);
00232        ob->setAttribute("TXTSCALEV",item->itemText.defaultStyle().charStyle().scaleV() / 10.0);
00233        ob->setAttribute("TXTBASE",item->itemText.defaultStyle().charStyle().baselineOffset() / 10.0);
00234        ob->setAttribute("TXTSHX",item->itemText.defaultStyle().charStyle().shadowXOffset() / 10.0);
00235        ob->setAttribute("TXTSHY",item->itemText.defaultStyle().charStyle().shadowYOffset() / 10.0);
00236        ob->setAttribute("TXTOUT",item->itemText.defaultStyle().charStyle().outlineWidth() / 10.0);
00237        ob->setAttribute("TXTULP",item->itemText.defaultStyle().charStyle().underlineOffset() / 10.0);
00238        ob->setAttribute("TXTULW",item->itemText.defaultStyle().charStyle().underlineWidth() / 10.0);
00239        ob->setAttribute("TXTSTP",item->itemText.defaultStyle().charStyle().strikethruOffset() / 10.0);
00240        ob->setAttribute("TXTSTW",item->itemText.defaultStyle().charStyle().strikethruWidth() / 10.0);
00241        ob->setAttribute("TXTSTYLE",item->itemText.defaultStyle().charStyle().effects());
00242        ob->setAttribute("COLUMNS", item->columns());
00243        ob->setAttribute("COLGAP", item->columnGap());
00244        ob->setAttribute("NAMEDLST",item->NamedLStyle);
00245        ob->setAttribute("SHADE",item->fillShade());
00246        ob->setAttribute("SHADE2",item->lineShade());
00247        ob->setAttribute("GRTYP",item->GrType);
00248        ob->setAttribute("ROT",item->rotation());
00249        ob->setAttribute("PLINEART",item->PLineArt);
00250        ob->setAttribute("PLINEEND", item->PLineEnd);
00251        ob->setAttribute("PLINEJOIN", item->PLineJoin);
00252        ob->setAttribute("LINESP",item->itemText.defaultStyle().lineSpacing());
00253        ob->setAttribute("LINESPMode", item->itemText.defaultStyle().lineSpacingMode());
00254        ob->setAttribute("TXTKERN",item->itemText.defaultStyle().charStyle().tracking());
00255        ob->setAttribute("LOCALSCX",item->imageXScale());
00256        ob->setAttribute("LOCALSCY",item->imageYScale());
00257        ob->setAttribute("LOCALX",item->imageXOffset());
00258        ob->setAttribute("LOCALY",item->imageYOffset());
00259        ob->setAttribute("PICART", item->imageShown() ? 1 : 0);
00260        ob->setAttribute("PLTSHOW", item->PoShow ? 1 : 0);
00261        ob->setAttribute("BASEOF", item->BaseOffs);
00262        ob->setAttribute("textPathType", item->textPathType);
00263        ob->setAttribute("textPathFlipped", static_cast<int>(item->textPathFlipped));
00264        ob->setAttribute("FLIPPEDH", item->imageFlippedH());
00265        ob->setAttribute("FLIPPEDV", item->imageFlippedV());
00266 /*     ob->setAttribute("BBOXX",item->BBoxX);
00267        ob->setAttribute("BBOXH",item->BBoxH); */
00268        ob->setAttribute("IFONT",item->itemText.defaultStyle().charStyle().font().scName());
00269        ob->setAttribute("ISIZE",item->itemText.defaultStyle().charStyle().fontSize() / 10.0 );
00270        ob->setAttribute("SCALETYPE", item->ScaleType ? 1 : 0);
00271        ob->setAttribute("RATIO", item->AspectRatio ? 1 : 0);
00272        ob->setAttribute("PRINTABLE", item->printEnabled() ? 1 : 0);
00273        if(item->isAnnotation())
00274        {
00275               ob->setAttribute("ANNOTATION",1);
00276               ob->setAttribute("ANTYPE", item->annotation().Type());
00277               ob->setAttribute("ANACTION", item->annotation().Action());
00278               ob->setAttribute("ANEACT", item->annotation().E_act());
00279               ob->setAttribute("ANXACT", item->annotation().X_act());
00280               ob->setAttribute("ANDACT", item->annotation().D_act());
00281               ob->setAttribute("ANFOACT", item->annotation().Fo_act());
00282               ob->setAttribute("ANBLACT", item->annotation().Bl_act());
00283               ob->setAttribute("ANKACT", item->annotation().K_act());
00284               ob->setAttribute("ANFACT", item->annotation().F_act());
00285               ob->setAttribute("ANVACT", item->annotation().V_act());
00286               ob->setAttribute("ANCACT", item->annotation().C_act());
00287               if (item->annotation().ActionType() == 8)
00288                      ob->setAttribute("ANEXTERN", item->annotation().Extern());
00289               else
00290                      ob->setAttribute("ANEXTERN", Path2Relative(item->annotation().Extern()));
00291               ob->setAttribute("ANZIEL", item->annotation().Ziel());
00292               ob->setAttribute("ANACTYP", item->annotation().ActionType());
00293               ob->setAttribute("ANTOOLTIP", item->annotation().ToolTip());
00294               ob->setAttribute("ANBWID", item->annotation().Bwid());
00295               ob->setAttribute("ANBSTY", item->annotation().Bsty());
00296               ob->setAttribute("ANFEED", item->annotation().Feed());
00297               ob->setAttribute("ANFLAG", item->annotation().Flag());
00298               ob->setAttribute("ANFONT", item->annotation().Font());
00299               ob->setAttribute("ANFORMAT", item->annotation().Format());
00300               ob->setAttribute("ANROLL", item->annotation().RollOver());
00301               ob->setAttribute("ANDOWN", item->annotation().Down());
00302               ob->setAttribute("ANVIS", item->annotation().Vis());
00303               ob->setAttribute("ANMC", item->annotation().MaxChar());
00304               ob->setAttribute("ANCHK", item->annotation().IsChk());
00305               ob->setAttribute("ANAA", item->annotation().AAact());
00306               ob->setAttribute("ANCHKS", item->annotation().ChkStil());
00307               ob->setAttribute("ANBCOL", item->annotation().borderColor());
00308               ob->setAttribute("ANHTML", item->annotation().HTML());
00309               ob->setAttribute("ANICON", item->annotation().UseIcons());
00310               ob->setAttribute("ANPLACE", item->annotation().IPlace());
00311               ob->setAttribute("ANSCALE", item->annotation().ScaleW());
00312        }
00313        else
00314               ob->setAttribute("ANNOTATION",0);
00315        ob->setAttribute("ANNAME", !item->AutoName ? item->itemName() : QString(""));
00316        // "TEXTFLOWMODE" succeed to "TEXTFLOW" "TEXTFLOW2" and "TEXTFLOW3" attributes
00317        ob->setAttribute("TEXTFLOWMODE", (int) item->textFlowMode() );
00318        // Set "TEXTFLOW" "TEXTFLOW2" and "TEXTFLOW3" attributes for compatibility
00319        // with versions prior to 1.3.4
00320        ob->setAttribute("TEXTFLOW" , item->textFlowAroundObject() ? 1 : 0);
00321        ob->setAttribute("TEXTFLOW2", item->textFlowUsesBoundingBox() ? 1 : 0);
00322        ob->setAttribute("TEXTFLOW3", item->textFlowUsesContourLine() ? 1 : 0);
00323        ob->setAttribute("AUTOTEXT", item->isAutoText ? 1 : 0);
00324        ob->setAttribute("EXTRA",item->textToFrameDistLeft());
00325        ob->setAttribute("TEXTRA",item->textToFrameDistTop());
00326        ob->setAttribute("BEXTRA",item->textToFrameDistBottom());
00327        ob->setAttribute("REXTRA",item->textToFrameDistRight());
00328        if (((item->asImageFrame()) || (item->asTextFrame())) && (!item->Pfile.isEmpty()))
00329               ob->setAttribute("PFILE",Path2Relative(item->Pfile));
00330        else
00331               ob->setAttribute("PFILE","");
00332        if (!item->Pfile2.isEmpty())
00333               ob->setAttribute("PFILE2",Path2Relative(item->Pfile2));
00334        else
00335               ob->setAttribute("PFILE2","");
00336        if (!item->Pfile3.isEmpty())
00337               ob->setAttribute("PFILE3",Path2Relative(item->Pfile3));
00338        else
00339               ob->setAttribute("PFILE3","");
00340        ob->setAttribute("PRFILE",item->IProfile);
00341        ob->setAttribute("EPROF", item->EmProfile);
00342        ob->setAttribute("IRENDER",item->IRender);
00343        ob->setAttribute("EMBEDDED", item->UseEmbedded ? 1 : 0);
00344        ob->setAttribute("LOCK", item->locked() ? 1 : 0);
00345        ob->setAttribute("LOCKR", item->sizeLocked() ? 1 : 0);
00346        ob->setAttribute("REVERS", item->reversed() ? 1 : 0);
00347        ob->setAttribute("TransValue", item->fillTransparency());
00348        ob->setAttribute("TransValueS", item->lineTransparency());
00349        ob->setAttribute("TransBlend", item->fillBlendmode());
00350        ob->setAttribute("TransBlendS", item->lineBlendmode());
00351        ob->setAttribute("isTableItem", static_cast<int>(item->isTableItem));
00352        ob->setAttribute("TopLine", static_cast<int>(item->TopLine));
00353        ob->setAttribute("LeftLine", static_cast<int>(item->LeftLine));
00354        ob->setAttribute("RightLine", static_cast<int>(item->RightLine));
00355        ob->setAttribute("BottomLine", static_cast<int>(item->BottomLine));
00356        if (item->isTableItem)
00357        {
00358               if (item->TopLink != 0)
00359                      ob->setAttribute("TopLINK", item->TopLink->ItemNr);
00360               else
00361                      ob->setAttribute("TopLINK", -1);
00362               if (item->LeftLink != 0)
00363                      ob->setAttribute("LeftLINK", item->LeftLink->ItemNr);
00364               else
00365                      ob->setAttribute("LeftLINK", -1);
00366               if (item->RightLink != 0)
00367                      ob->setAttribute("RightLINK", item->RightLink->ItemNr);
00368               else
00369                      ob->setAttribute("RightLINK", -1);
00370               if (item->BottomLink != 0)
00371                      ob->setAttribute("BottomLINK", item->BottomLink->ItemNr);
00372               else
00373                      ob->setAttribute("BottomLINK", -1);
00374               ob->setAttribute("OwnLINK", item->ItemNr);
00375        }
00376        ob->setAttribute("isGroupControl", static_cast<int>(item->isGroupControl));
00377        if (item->isGroupControl)
00378        {
00379               if (item->groupsLastItem != 0)
00380                      ob->setAttribute("groupsLastItem", item->groupsLastItem->ItemNr - item->ItemNr);
00381        }
00382        ob->setAttribute("NUMDASH", static_cast<int>(item->DashValues.count()));
00383        QString dlp = "";
00384        QValueList<double>::Iterator dax;
00385        for (dax = item->DashValues.begin(); dax != item->DashValues.end(); ++dax)
00386               dlp += tmp.setNum((*dax)) + " ";
00387        ob->setAttribute("DASHS", dlp);
00388        ob->setAttribute("DASHOFF", item->DashOffset);
00389        ob->setAttribute("NUMPO",item->PoLine.size());
00390        QString polp = "";
00391        for (uint nxx=0; nxx<item->PoLine.size(); ++nxx)
00392        {
00393               item->PoLine.point(nxx, &xf, &yf);
00394               polp += tmp.setNum(xf) + " " + tmpy.setNum(yf) + " ";
00395        }
00396        ob->setAttribute("POCOOR", polp);
00397        ob->setAttribute("NUMCO",item->ContourLine.size());
00398        QString colp = "";
00399        for (uint nxx=0; nxx<item->ContourLine.size(); ++nxx)
00400        {
00401               item->ContourLine.point(nxx, &xf, &yf);
00402               colp += tmp.setNum(xf) + " " + tmpy.setNum(yf) + " ";
00403        }
00404        ob->setAttribute("COCOOR", colp);
00405        ob->setAttribute("NUMGROUP", static_cast<int>(item->Groups.count()));
00406        QString glp = "";
00407        QValueStack<int>::Iterator nx;
00408        for (nx = item->Groups.begin(); nx != item->Groups.end(); ++nx)
00409               glp += tmp.setNum((*nx)) + " ";
00410        ob->setAttribute("GROUPS", glp);
00411        ob->setAttribute("LANGUAGE", item->itemText.defaultStyle().charStyle().language());
00412        ob->setAttribute("startArrowIndex", item->startArrowIndex());
00413        ob->setAttribute("endArrowIndex", item->endArrowIndex());
00414 }
00415 
00416 //CB: Private only now
00417 void ScriXmlDoc::GetStyle(QDomElement &pg, ParagraphStyle &vg, StyleSet<ParagraphStyle> & docParagraphStyles, ScribusDoc* doc, bool fl)
00418 {
00419        bool fou;
00420        QString tmpf, tmf, tmV;
00421        double xf, xf2;
00422        fou = false;
00423        vg.setName(pg.attribute("NAME"));
00424        vg.setLineSpacingMode(static_cast<ParagraphStyle::LineSpacingMode>(pg.attribute("LINESPMode", "0").toInt()));
00425        vg.setLineSpacing(pg.attribute("LINESP").toDouble());
00426        vg.setLeftMargin(pg.attribute("INDENT", "0").toDouble());
00427        vg.setFirstIndent(pg.attribute("FIRST", "0").toDouble());
00428        vg.setAlignment(static_cast<ParagraphStyle::AlignmentType>(pg.attribute("ALIGN").toInt()));
00429        vg.setGapBefore(pg.attribute("VOR", "0").toDouble());
00430        vg.setGapAfter(pg.attribute("NACH", "0").toDouble());
00431        tmpf = pg.attribute("FONT", doc->toolSettings.defFont);
00432        if (tmpf.isEmpty())
00433               tmpf = doc->toolSettings.defFont;
00434        tmf = tmpf;
00435        if (!DoFonts.contains(tmpf))
00436               tmpf = AskForFont(prefsManager->appPrefs.AvailFonts, tmpf, doc);
00437        else
00438               tmpf = DoFonts[tmf];
00439        vg.charStyle().setFont(prefsManager->appPrefs.AvailFonts[tmpf]);
00440        vg.charStyle().setFontSize(qRound(pg.attribute("FONTSIZE", "12").toDouble() * 10.0));
00441        vg.setHasDropCap(static_cast<bool>(pg.attribute("DROP", "0").toInt()));
00442        vg.setDropCapLines(pg.attribute("DROPLIN", "2").toInt());
00443        vg.setDropCapOffset(pg.attribute("DROPDIST", "0").toDouble());
00444        vg.charStyle().setFeatures(static_cast<StyleFlag>(pg.attribute("EFFECT", "0").toInt()).featureList());
00445        vg.charStyle().setFillColor(pg.attribute("FCOLOR", doc->toolSettings.dBrush));
00446        vg.charStyle().setFillShade(pg.attribute("FSHADE", "100").toInt());
00447        vg.charStyle().setStrokeColor(pg.attribute("SCOLOR", doc->toolSettings.dPen));
00448        vg.charStyle().setStrokeShade(pg.attribute("SSHADE", "100").toInt());
00449        
00450        if (static_cast<bool>(pg.attribute("BASE", "0").toInt()))
00451               vg.setLineSpacingMode(ParagraphStyle::BaselineGridLineSpacing);
00452        vg.charStyle().setShadowXOffset(qRound(pg.attribute("TXTSHX", "5").toDouble() * 10));
00453        vg.charStyle().setShadowYOffset(qRound(pg.attribute("TXTSHY", "-5").toDouble() * 10));
00454        vg.charStyle().setOutlineWidth(qRound(pg.attribute("TXTOUT", "1").toDouble() * 10));
00455        vg.charStyle().setUnderlineOffset(qRound(pg.attribute("TXTULP", "-0.1").toDouble() * 10));
00456        vg.charStyle().setUnderlineWidth(qRound(pg.attribute("TXTULW", "-0.1").toDouble() * 10));
00457        vg.charStyle().setStrikethruOffset(qRound(pg.attribute("TXTSTP", "-0.1").toDouble() * 10));
00458        vg.charStyle().setStrikethruWidth(qRound(pg.attribute("TXTSTW", "-0.1").toDouble() * 10));
00459        vg.charStyle().setScaleH(qRound(pg.attribute("SCALEH", "100").toDouble() * 10));
00460        vg.charStyle().setScaleV(qRound(pg.attribute("SCALEV", "100").toDouble() * 10));
00461        vg.charStyle().setBaselineOffset(qRound(pg.attribute("BASEO", "0").toDouble() * 10));
00462        vg.charStyle().setTracking(qRound(pg.attribute("KERN", "0").toDouble() * 10));
00463 //     vg.tabValues().clear();
00464        if ((pg.hasAttribute("NUMTAB")) && (pg.attribute("NUMTAB", "0").toInt() != 0))
00465        {
00466               QValueList<ParagraphStyle::TabRecord> tbs;
00467               ParagraphStyle::TabRecord tb;
00468               QString tmp = pg.attribute("TABS");
00469               QTextStream tgv(&tmp, IO_ReadOnly);
00470               tbs.clear();
00471               for (int cxv = 0; cxv < pg.attribute("NUMTAB", "0").toInt(); cxv += 2)
00472               {
00473                      tgv >> xf;
00474                      tgv >> xf2;
00475                      tb.tabPosition = xf2;
00476                      tb.tabType = static_cast<int>(xf);
00477                      tb.tabFillChar = QChar();
00478                      tbs.append(tb);
00479               }
00480               vg.setTabValues(tbs);
00481               tmp = "";
00482        }
00483        else
00484        {
00485               QValueList<ParagraphStyle::TabRecord> tbs;
00486               QDomNode IT = pg.firstChild();
00487               while(!IT.isNull())
00488               {
00489                      QDomElement it = IT.toElement();
00490                      if (it.tagName()=="Tabs")
00491                      {
00492                             ParagraphStyle::TabRecord tb;
00493                             tb.tabPosition = it.attribute("Pos").toDouble();
00494                             tb.tabType = it.attribute("Type").toInt();
00495                             QString tbCh = "";
00496                             tbCh = it.attribute("Fill","");
00497                             if (tbCh.isEmpty())
00498                                    tb.tabFillChar = QChar();
00499                             else
00500                                    tb.tabFillChar = tbCh[0];
00501                             tbs.append(tb);
00502                      }
00503                      IT=IT.nextSibling();
00504               }
00505               vg.setTabValues(tbs);
00506        }
00507        for (uint xx=0; xx<docParagraphStyles.count(); ++xx)
00508        {
00509               if (vg.name() == docParagraphStyles[xx].name())
00510               {
00511                      //Compare the attributes of the pasted styles vs existing ones
00512                      if (vg.equiv(docParagraphStyles[xx]))
00513                      {
00514                             if (fl)
00515                             {
00516                                    DoVorl[VorlC] = tmV.setNum(xx);
00517                                    VorlC++;
00518                             }
00519                             fou = true;
00520                      }
00521                      else
00522                      {
00523                             vg.setName("Copy of "+docParagraphStyles[xx].name());
00524                             fou = false;
00525                      }
00526                      break;
00527               }
00528        }
00529        if (!fou)
00530        {
00531               for (uint xx=0; xx< docParagraphStyles.count(); ++xx)
00532               {
00533                      if (vg.equiv(docParagraphStyles[xx]))
00534                      {
00535                             vg.setName(docParagraphStyles[xx].name());
00536                             fou = true;
00537                             if (fl)
00538                             {
00539                                    DoVorl[VorlC] = tmV.setNum(xx);
00540                                    VorlC++;
00541                             }
00542                             break;
00543                      }
00544               }
00545        }
00546        if (!fou)
00547        {
00548               docParagraphStyles.create(vg);
00549               if (fl)
00550               {
00551                      DoVorl[VorlC] = tmV.setNum(docParagraphStyles.count()-1);
00552                      VorlC++;
00553               }
00554        }
00555 }
00556 
00557 bool ScriXmlDoc::ReadElemHeader(QString file, bool isFile, double *x, double *y, double *w, double *h)
00558 {
00559        QString ff = "";
00560        QDomDocument docu("scridoc");
00561        if (isFile)
00562        {
00563               QCString f;
00564               if (!loadRawText(file, f))
00565                      return false;
00566               if (f.left(16) == "<SCRIBUSELEMUTF8")
00567                      ff = QString::fromUtf8(f.data());
00568               else
00569                      ff = f;
00570        }
00571        else
00572        {
00573               // JG Ugly and wrong conversion from an utf8 encoded array
00574               // to a QString using local enconding
00575               /*if (file.startsWith("<SCRIBUSELEMUTF8"))
00576                      ff = QString::fromUtf8(file);
00577               else
00578                      ff = file;*/
00579               ff  = file;
00580        }
00581        if(!docu.setContent(ff))
00582               return false;
00583        QDomElement elem=docu.documentElement();
00584        if ((elem.tagName() != "SCRIBUSELEM") && (elem.tagName() != "SCRIBUSELEMUTF8"))
00585               return false;
00586        *x = elem.attribute("XP").toDouble();
00587        *y = elem.attribute("YP").toDouble();
00588        *w = elem.attribute("W", "0").toDouble();
00589        *h = elem.attribute("H", "0").toDouble();
00590        return true;
00591 }
00592 
00593 bool ScriXmlDoc::ReadElem(QString fileName, SCFonts &avail, ScribusDoc *doc, double Xp, double Yp, bool Fi, bool loc, QMap<QString,QString> &FontSub, ScribusView *view)
00594 {
00595        QString ff = "";
00596        struct CopyPasteBuffer OB;
00597        ParagraphStyle vg;
00598        QString tmp, tmpf, tmp2, tmp3, tmp4, tmV, tmf;
00599        QMap<QString,QString> DoMul;
00600        QMap<int,int> TableID;
00601        QMap<int,int> arrowID;
00602        QMap<PageItem*, int> groupID;
00603        QPtrList<PageItem> TableItems;
00604        bool VorLFound = false;
00605        bool newVersion = false;
00606        int x;
00607        double GrX, GrY;
00608        int GrMax = doc->GroupCounter;
00609        ScColor lf = ScColor();
00610        QDomDocument docu("scridoc");
00611        if (Fi)
00612        {
00613               QCString f;
00614               if (!loadRawText(fileName, f))
00615                      return false;
00616               if (f.left(16) == "<SCRIBUSELEMUTF8")
00617                      ff = QString::fromUtf8(f.data());
00618               else
00619                      ff = f;
00620        }
00621        else
00622        {
00623               ff = fileName;
00624        }
00625        if(!docu.setContent(ff))
00626               return false;
00627        QDomElement elem=docu.documentElement();
00628        if ((elem.tagName() != "SCRIBUSELEM") && (elem.tagName() != "SCRIBUSELEMUTF8"))
00629               return false;
00630        if (loc)
00631        {
00632               GrX = 0.0;
00633               GrY = 0.0;
00634        }
00635        else
00636        {
00637               GrX = elem.attribute("XP").toDouble();
00638               GrY = elem.attribute("YP").toDouble();
00639        }
00640        if (elem.hasAttribute("Version"))
00641               newVersion = true;
00642        QDomNode DOC=elem.firstChild();
00643        DoFonts.clear();
00644        DoFonts[doc->toolSettings.defFont] = doc->toolSettings.defFont;
00645        DoVorl.clear();
00646        DoVorl[0] = "0";
00647        DoVorl[1] = "1";
00648        DoVorl[2] = "2";
00649        DoVorl[3] = "3";
00650        DoVorl[4] = "4";
00651        VorlC = 5;
00652        TableItems.clear();
00653        TableID.clear();
00654        arrowID.clear();
00655        QString CurDirP = QDir::currentDirPath();
00656        QDir::setCurrent(QDir::homeDirPath());
00657        int startNumArrows = doc->arrowStyles.count();
00658        while(!DOC.isNull())
00659        {
00660               QDomElement pg=DOC.toElement();
00661               if(pg.tagName()=="Arrows")
00662               {
00663                      if (pg.attribute("Index").toInt() > startNumArrows)
00664                      {
00665                             struct ArrowDesc arrow;
00666                             double xa, ya;
00667                             arrow.name = pg.attribute("Name");
00668                             arrow.userArrow = true;
00669                             QString tmp = pg.attribute("Points");
00670                             QTextStream fp(&tmp, IO_ReadOnly);
00671                             for (uint cx = 0; cx < pg.attribute("NumPoints").toUInt(); ++cx)
00672                             {
00673                                    fp >> xa;
00674                                    fp >> ya;
00675                                    arrow.points.addPoint(xa, ya);
00676                             }
00677                             doc->arrowStyles.append(arrow);
00678                             arrowID.insert(pg.attribute("Index").toInt(), doc->arrowStyles.count());
00679                      }
00680                      else
00681                             arrowID.insert(pg.attribute("Index").toInt(), pg.attribute("Index").toInt());
00682               }
00683               if(pg.tagName()=="FONT")
00684               {
00685                      tmpf = pg.attribute("NAME");
00686                      if ((!avail.contains(tmpf)) || (!avail[tmpf].usable()))
00687                      {
00688                             if (!FontSub.contains(tmpf) || (!avail[FontSub[tmpf]].usable()))
00689                             {
00690                                    MissingFont *dia = new MissingFont(0, tmpf, doc);
00691                                    dia->exec();
00692                                    tmpf = dia->getReplacementFont();
00693                                    FontSub[pg.attribute("NAME")] = tmpf;
00694                                    delete dia;
00695                             }
00696                             else
00697                                    tmpf = FontSub[tmpf];
00698                      }
00699 //                   fo = avail[tmpf]->Font;
00700 //                   fo.setPointSize(qRound(doc->toolSettings.defSize / 10.0));
00701                      if(!doc->UsedFonts.contains(tmpf))
00702                             doc->AddFont(tmpf);
00703                      DoFonts[pg.attribute("NAME")] = tmpf;
00704               }
00705               // 10/25/2004 pv - None is "reserved" color. cannot be defined in any file...
00706               if(pg.tagName()=="COLOR" && pg.attribute("Name")!=CommonStrings::None)
00707               {
00708                      if (pg.hasAttribute("CMYK"))
00709                             lf.setNamedColor(pg.attribute("CMYK"));
00710                      else
00711                             lf.fromQColor(QColor(pg.attribute("RGB")));
00712                      if (pg.hasAttribute("Spot"))
00713                             lf.setSpotColor(static_cast<bool>(pg.attribute("Spot").toInt()));
00714                      else
00715                             lf.setSpotColor(false);
00716                      if (pg.hasAttribute("Register"))
00717                             lf.setRegistrationColor(static_cast<bool>(pg.attribute("Register").toInt()));
00718                      else
00719                             lf.setRegistrationColor(false);
00720                      if (!doc->PageColors.contains(pg.attribute("NAME")))
00721                             doc->PageColors[pg.attribute("NAME")] = lf;
00722               }
00723               if(pg.tagName()=="MultiLine")
00724               {
00725                      multiLine ml;
00726                      QDomNode MuLn = DOC.firstChild();
00727                      while(!MuLn.isNull())
00728                      {
00729                             QDomElement MuL = MuLn.toElement();
00730                             struct SingleLine sl;
00731                             sl.Color = MuL.attribute("Color");
00732                             sl.Dash = MuL.attribute("Dash").toInt();
00733                             sl.LineEnd = MuL.attribute("LineEnd").toInt();
00734                             sl.LineJoin = MuL.attribute("LineJoin").toInt();
00735                             sl.Shade = MuL.attribute("Shade").toInt();
00736                             sl.Width = MuL.attribute("Width").toDouble();
00737                             ml.push_back(sl);
00738                             MuLn = MuLn.nextSibling();
00739                      }
00740                      if (!doc->MLineStyles.contains(pg.attribute("Name")))
00741                             doc->MLineStyles.insert(pg.attribute("Name"), ml);
00742               }
00743 /*            if(pg.tagName()=="STYLE")
00744               {
00745                      GetStyle(pg, vg, doc->docParagraphStyles, doc, true);
00746                      VorLFound = true;
00747               }
00748 */            if(pg.tagName()=="Pattern")
00749               {
00750                      ScPattern pat;
00751                      QDomNode pa = DOC.firstChild();
00752                      uint ac = doc->Items->count();
00753                      bool savedAlignGrid = doc->useRaster;
00754                      bool savedAlignGuides = doc->SnapGuides;
00755                      doc->useRaster = false;
00756                      doc->SnapGuides = false;
00757                      while(!pa.isNull())
00758                      {
00759                             QDomElement pite = pa.toElement();
00760                             GetItemProps(newVersion, &pite, &OB);
00761                             OB.Xpos = pite.attribute("XPOS").toDouble() + doc->currentPage()->xOffset();
00762                             OB.Ypos = pite.attribute("YPOS").toDouble() + doc->currentPage()->yOffset();
00763                             OB.startArrowIndex =  arrowID[pite.attribute("startArrowIndex", "0").toInt()];
00764                             OB.endArrowIndex =  arrowID[pite.attribute("endArrowIndex", "0").toInt()];
00765                             OB.isBookmark=pite.attribute("BOOKMARK").toInt();
00766                             OB.NamedLStyle = pite.attribute("NAMEDLST", "");
00767                             if (!doc->MLineStyles.contains(OB.NamedLStyle))
00768                                    OB.NamedLStyle = "";
00769                             OB.textAlignment = pite.attribute("ALIGN", "0").toInt();
00770                             tmf = pite.attribute("IFONT", doc->toolSettings.defFont);
00771                             if (tmf.isEmpty())
00772                                    tmf = doc->toolSettings.defFont;
00773                             if (DoFonts[tmf].isEmpty())
00774                                    OB.IFont = doc->toolSettings.defFont;
00775                             else
00776                                    OB.IFont = DoFonts[tmf];
00777                             OB.LayerNr = 0;
00778                             OB.Language = pite.attribute("LANGUAGE", doc->Language);
00779                             tmp = "";
00780                             if ((pite.hasAttribute("GROUPS")) && (pite.attribute("NUMGROUP", "0").toInt() != 0))
00781                             {
00782                                    tmp = pite.attribute("GROUPS");
00783                                    QTextStream fg(&tmp, IO_ReadOnly);
00784                                    OB.Groups.clear();
00785                                    for (int cx = 0; cx < pite.attribute("NUMGROUP", "0").toInt(); ++cx)
00786                                    {
00787                                           fg >> x;
00788                                           OB.Groups.push(x+doc->GroupCounter);
00789                                           GrMax = QMAX(GrMax, x+doc->GroupCounter);
00790                                    }
00791                                    tmp = "";
00792                             }
00793                             else
00794                                    OB.Groups.clear();
00795                             tmp = "";
00796                             QDomNode IT=pite.firstChild();
00797                             while(!IT.isNull())
00798                             {
00799                                    QDomElement it=IT.toElement();
00800                                    if (it.tagName()=="CSTOP")
00801                                    {
00802                                           QString name = it.attribute("NAME");
00803                                           double ramp = it.attribute("RAMP", "0.0").toDouble();
00804                                           int shade = it.attribute("SHADE", "100").toInt();
00805                                           double opa = it.attribute("TRANS", "1").toDouble();
00806                                           OB.fill_gradient.addStop(SetColor(doc, name, shade), ramp, 0.5, opa, name, shade);
00807                                           OB.GrColor = "";
00808                                           OB.GrColor2 = "";
00809                                    }
00810                                    if (it.tagName()=="Tabs")
00811                                    {
00812                                           ParagraphStyle::TabRecord tb;
00813                                           tb.tabPosition = it.attribute("Pos").toDouble();
00814                                           tb.tabType = it.attribute("Type").toInt();
00815                                           QString tbCh = "";
00816                                           tbCh = it.attribute("Fill","");
00817                                           if (tbCh.isEmpty())
00818                                                  tb.tabFillChar = QChar();
00819                                           else
00820                                                  tb.tabFillChar = tbCh[0];
00821                                           OB.TabValues.append(tb);
00822                                    }
00823                                    IT=IT.nextSibling();
00824                             }
00825                             OB.itemText = "";
00826                             OB.LayerNr = -1;
00827                             if ((Fi) && (pite.hasAttribute("relativePaths")))
00828                             {
00829                                    if (static_cast<bool>(pite.attribute("relativePaths", "0").toInt()))
00830                                    {
00831                                           if (!OB.Pfile.isEmpty())
00832                                           {
00833                                                  QFileInfo pfi(fileName);
00834                                                  QString test = QDir::cleanDirPath(QDir::convertSeparators(pfi.dirPath(true)+"/"+OB.Pfile));
00835                                                  QFileInfo pfi2(test);
00836                                                  OB.Pfile = pfi2.absFilePath();
00837                                           }
00838                                           if (!OB.Pfile2.isEmpty())
00839                                           {
00840                                                  QFileInfo pfi(fileName);
00841                                                  QString test = QDir::cleanDirPath(QDir::convertSeparators(pfi.dirPath(true)+"/"+OB.Pfile2));
00842                                                  QFileInfo pfi2(test);
00843                                                  OB.Pfile2 = pfi2.absFilePath();
00844                                           }
00845                                           if (!OB.Pfile3.isEmpty())
00846                                           {
00847                                                  QFileInfo pfi(fileName);
00848                                                  QString test = QDir::cleanDirPath(QDir::convertSeparators(pfi.dirPath(true)+"/"+OB.Pfile3));
00849                                                  QFileInfo pfi2(test);
00850                                                  OB.Pfile3 = pfi2.absFilePath();
00851                                           }
00852                                    }
00853                             }
00854                             view->PasteItem(&OB, true, true, false);
00855                             PageItem* Neu = doc->Items->at(doc->Items->count()-1);
00856                             Neu->setXYPos(Neu->xPos() - doc->currentPage()->xOffset(), Neu->yPos() - doc->currentPage()->yOffset(), true);
00857                             IT=pite.firstChild();
00858                             while(!IT.isNull())
00859                             {
00860                                    QDomElement it=IT.toElement();
00861                                    if (it.tagName()=="ITEXT")
00862                                           GetItemText(&it, doc, VorLFound, true, Neu);
00863                                    if (it.tagName()=="ImageEffect")
00864                                    {
00865                                           struct ScImage::imageEffect ef;
00866                                           ef.effectParameters = it.attribute("Param");
00867                                           ef.effectCode = it.attribute("Code").toInt();
00868                                           Neu->effectsInUse.append(ef);
00869                                    }
00870                                    if (it.tagName() == "PSDLayer")
00871                                    {
00872                                           struct ImageLoadRequest loadingInfo;
00873                                           loadingInfo.blend = it.attribute("Blend");
00874                                           loadingInfo.opacity = it.attribute("Opacity").toInt();
00875                                           loadingInfo.visible = static_cast<bool>(it.attribute("Visible").toInt());
00876                                           loadingInfo.useMask = static_cast<bool>(it.attribute("useMask", "1").toInt());
00877                                           Neu->pixm.imgInfo.RequestProps.insert(it.attribute("Layer").toInt(), loadingInfo);
00878                                           Neu->pixm.imgInfo.isRequest = true;
00879                                    }
00880                                    IT=IT.nextSibling();
00881                             }
00882                             if ((Neu->effectsInUse.count() != 0) || (Neu->pixm.imgInfo.RequestProps.count() != 0))
00883                                    doc->LoadPict(Neu->Pfile, Neu->ItemNr, true);
00884                             QString clPath = pite.attribute("ImageClip", "");
00885                             if (Neu->pixm.imgInfo.PDSpathData.contains(clPath))
00886                             {
00887                                    Neu->imageClip = Neu->pixm.imgInfo.PDSpathData[clPath].copy();
00888                                    Neu->pixm.imgInfo.usedPath = clPath;
00889                                    QWMatrix cl;
00890                                    cl.translate(Neu->imageXOffset()*Neu->imageXScale(), Neu->imageYOffset()*Neu->imageYScale());
00891                                    cl.scale(Neu->imageXScale(), Neu->imageYScale());
00892                                    Neu->imageClip.map(cl);
00893                             }
00894                             if (Neu->isTableItem)
00895                             {
00896                                    TableItems.append(Neu);
00897                                    TableID.insert(pite.attribute("OwnLINK", "0").toInt(), Neu->ItemNr);
00898                             }
00899                             Neu->isGroupControl = static_cast<bool>(pite.attribute("isGroupControl", "0").toInt());
00900                             if (Neu->isGroupControl)
00901                                    groupID.insert(Neu, pite.attribute("groupsLastItem", "0").toInt()+Neu->ItemNr);
00902                             if (Neu->asPathText())
00903                                    Neu->updatePolyClip();
00904                             pa = pa.nextSibling();
00905                      }
00906                      doc->useRaster = savedAlignGrid;
00907                      doc->SnapGuides = savedAlignGuides;
00908                      uint ae = doc->Items->count();
00909                      pat.setDoc(doc);
00910                      PageItem* currItem = doc->Items->at(ac);
00911                      pat.pattern = currItem->DrawObj_toImage();
00912                      for (uint as = ac; as < ae; ++as)
00913                      {
00914                             PageItem* Neu = doc->Items->take(ac);
00915                             Neu->ItemNr = pat.items.count();
00916                             pat.items.append(Neu);
00917                      }
00918                      pat.scaleX = pg.attribute("scaleX", "0").toDouble();
00919                      pat.scaleY = pg.attribute("scaleY", "0").toDouble();
00920                      pat.width = pg.attribute("width", "0").toDouble();
00921                      pat.height = pg.attribute("height", "0").toDouble();
00922                      if (!doc->docPatterns.contains(pg.attribute("Name")))
00923                             doc->docPatterns.insert(pg.attribute("Name"), pat);
00924               }
00925               DOC=DOC.nextSibling();
00926        }
00927        DOC=elem.firstChild();
00928        while(!DOC.isNull())
00929        {
00930               QDomElement pg=DOC.toElement();
00931               if(pg.tagName()=="ITEM")
00932               {
00933                      GetItemProps(newVersion, &pg, &OB);
00934                      OB.Xpos = Xp + pg.attribute("XPOS").toDouble() - GrX;
00935                      OB.Ypos = Yp + pg.attribute("YPOS").toDouble() - GrY;
00936                      OB.startArrowIndex =  arrowID[pg.attribute("startArrowIndex", "0").toInt()];
00937                      OB.endArrowIndex =  arrowID[pg.attribute("endArrowIndex", "0").toInt()];
00938                      OB.isBookmark=pg.attribute("BOOKMARK").toInt();
00939                      OB.NamedLStyle = pg.attribute("NAMEDLST", "");
00940                      if (!doc->MLineStyles.contains(OB.NamedLStyle))
00941                             OB.NamedLStyle = "";
00942                      OB.textAlignment = pg.attribute("ALIGN", "0").toInt();
00943                      tmf = pg.attribute("IFONT", doc->toolSettings.defFont);
00944                      if (tmf.isEmpty())
00945                             tmf = doc->toolSettings.defFont;
00946                      if (DoFonts[tmf].isEmpty())
00947                             OB.IFont = doc->toolSettings.defFont;
00948                      else
00949                             OB.IFont = DoFonts[tmf];
00950                      OB.LayerNr = 0;
00951                      OB.Language = pg.attribute("LANGUAGE", doc->Language);
00952                      tmp = "";
00953                      if ((pg.hasAttribute("GROUPS")) && (pg.attribute("NUMGROUP", "0").toInt() != 0))
00954                      {
00955                             tmp = pg.attribute("GROUPS");
00956                             QTextStream fg(&tmp, IO_ReadOnly);
00957                             OB.Groups.clear();
00958                             for (int cx = 0; cx < pg.attribute("NUMGROUP", "0").toInt(); ++cx)
00959                             {
00960                                    fg >> x;
00961                                    OB.Groups.push(x+doc->GroupCounter);
00962                                    GrMax = QMAX(GrMax, x+doc->GroupCounter);
00963                             }
00964                             tmp = "";
00965                      }
00966                      else
00967                             OB.Groups.clear();
00968                      tmp = "";
00969                      QDomNode IT=DOC.firstChild();
00970                      while(!IT.isNull())
00971                      {
00972                             QDomElement it=IT.toElement();
00973                             if (it.tagName()=="CSTOP")
00974                             {
00975                                    QString name = it.attribute("NAME");
00976                                    double ramp = it.attribute("RAMP", "0.0").toDouble();
00977                                    int shade = it.attribute("SHADE", "100").toInt();
00978                                    double opa = it.attribute("TRANS", "1").toDouble();
00979                                    OB.fill_gradient.addStop(SetColor(doc, name, shade), ramp, 0.5, opa, name, shade);
00980                                    OB.GrColor = "";
00981                                    OB.GrColor2 = "";
00982                             }
00983                             if (it.tagName()=="Tabs")
00984                             {
00985                                    ParagraphStyle::TabRecord tb;
00986                                    tb.tabPosition = it.attribute("Pos").toDouble();
00987                                    tb.tabType = it.attribute("Type").toInt();
00988                                    QString tbCh = "";
00989                                    tbCh = it.attribute("Fill","");
00990                                    if (tbCh.isEmpty())
00991                                           tb.tabFillChar = QChar();
00992                                    else
00993                                           tb.tabFillChar = tbCh[0];
00994                                    OB.TabValues.append(tb);
00995                             }
00996                             IT=IT.nextSibling();
00997                      }
00998                      OB.itemText = "";
00999                      OB.LayerNr = -1;
01000                      if ((Fi) && (pg.hasAttribute("relativePaths")))
01001                      {
01002                             if (static_cast<bool>(pg.attribute("relativePaths", "0").toInt()))
01003                             {
01004                                    if (!OB.Pfile.isEmpty())
01005                                    {
01006                                           QFileInfo pfi(fileName);
01007                                           QString test = QDir::cleanDirPath(QDir::convertSeparators(pfi.dirPath(true)+"/"+OB.Pfile));
01008                                           QFileInfo pfi2(test);
01009                                           OB.Pfile = pfi2.absFilePath();
01010                                    }
01011                                    if (!OB.Pfile2.isEmpty())
01012                                    {
01013                                           QFileInfo pfi(fileName);
01014                                           QString test = QDir::cleanDirPath(QDir::convertSeparators(pfi.dirPath(true)+"/"+OB.Pfile2));
01015                                           QFileInfo pfi2(test);
01016                                           OB.Pfile2 = pfi2.absFilePath();
01017                                    }
01018                                    if (!OB.Pfile3.isEmpty())
01019                                    {
01020                                           QFileInfo pfi(fileName);
01021                                           QString test = QDir::cleanDirPath(QDir::convertSeparators(pfi.dirPath(true)+"/"+OB.Pfile3));
01022                                           QFileInfo pfi2(test);
01023                                           OB.Pfile3 = pfi2.absFilePath();
01024                                    }
01025                             }
01026                      }
01027                      view->PasteItem(&OB, true, true, false);
01028                      PageItem* Neu = doc->Items->at(doc->Items->count()-1);
01029                      IT=DOC.firstChild();
01030                      while(!IT.isNull())
01031                      {
01032                             QDomElement it=IT.toElement();
01033                             if (it.tagName()=="ITEXT")
01034                                    GetItemText(&it, doc, VorLFound, true, Neu);
01035                             if (it.tagName()=="ImageEffect")
01036                             {
01037                                    struct ScImage::imageEffect ef;
01038                                    ef.effectParameters = it.attribute("Param");
01039                                    ef.effectCode = it.attribute("Code").toInt();
01040                                    Neu->effectsInUse.append(ef);
01041                             }
01042                             if (it.tagName() == "PSDLayer")
01043                             {
01044                                    struct ImageLoadRequest loadingInfo;
01045                                    loadingInfo.blend = it.attribute("Blend");
01046                                    loadingInfo.opacity = it.attribute("Opacity").toInt();
01047                                    loadingInfo.visible = static_cast<bool>(it.attribute("Visible").toInt());
01048                                    loadingInfo.useMask = static_cast<bool>(it.attribute("useMask", "1").toInt());
01049                                    Neu->pixm.imgInfo.RequestProps.insert(it.attribute("Layer").toInt(), loadingInfo);
01050                                    Neu->pixm.imgInfo.isRequest = true;
01051                             }
01052                             IT=IT.nextSibling();
01053                      }
01054                      if ((Neu->effectsInUse.count() != 0) || (Neu->pixm.imgInfo.RequestProps.count() != 0))
01055                             doc->LoadPict(Neu->Pfile, Neu->ItemNr, true);
01056                      QString clPath = pg.attribute("ImageClip", "");
01057                      if (Neu->pixm.imgInfo.PDSpathData.contains(clPath))
01058                      {
01059                             Neu->imageClip = Neu->pixm.imgInfo.PDSpathData[clPath].copy();
01060                             Neu->pixm.imgInfo.usedPath = clPath;
01061                             QWMatrix cl;
01062                             cl.translate(Neu->imageXOffset()*Neu->imageXScale(), Neu->imageYOffset()*Neu->imageYScale());
01063                             cl.scale(Neu->imageXScale(), Neu->imageYScale());
01064                             Neu->imageClip.map(cl);
01065                      }
01066                      if (Neu->isTableItem)
01067                      {
01068                             TableItems.append(Neu);
01069                             TableID.insert(pg.attribute("OwnLINK", "0").toInt(), Neu->ItemNr);
01070                      }
01071                      Neu->isGroupControl = static_cast<bool>(pg.attribute("isGroupControl", "0").toInt());
01072                      if (Neu->isGroupControl)
01073                             groupID.insert(Neu, pg.attribute("groupsLastItem", "0").toInt()+Neu->ItemNr);
01074                      if (Neu->asPathText())
01075                             Neu->updatePolyClip();
01076               }
01077               DOC=DOC.nextSibling();
01078        }
01079        if (TableItems.count() != 0)
01080        {
01081               for (uint ttc = 0; ttc < TableItems.count(); ++ttc)
01082               {
01083                      PageItem* ta = TableItems.at(ttc);
01084                      if (ta->TopLinkID != -1)
01085                             ta->TopLink = doc->Items->at(TableID[ta->TopLinkID]);
01086                      else
01087                             ta->TopLink = 0;
01088                      if (ta->LeftLinkID != -1)
01089                             ta->LeftLink = doc->Items->at(TableID[ta->LeftLinkID]);
01090                      else
01091                             ta->LeftLink = 0;
01092                      if (ta->RightLinkID != -1)
01093                             ta->RightLink = doc->Items->at(TableID[ta->RightLinkID]);
01094                      else
01095                             ta->RightLink = 0;
01096                      if (ta->BottomLinkID != -1)
01097                             ta->BottomLink = doc->Items->at(TableID[ta->BottomLinkID]);
01098                      else
01099                             ta->BottomLink = 0;
01100               }
01101        }
01102        if (groupID.count() != 0)
01103        {
01104               QMap<PageItem*, int>::Iterator it;
01105               for (it = groupID.begin(); it != groupID.end(); ++it)
01106               {
01107                      it.key()->groupsLastItem = doc->Items->at(it.data());
01108               }
01109        }
01110        doc->GroupCounter = GrMax + 1;
01111        QDir::setCurrent(CurDirP);
01112        return true;
01113 }
01114 
01115 QString ScriXmlDoc::WriteElem(ScribusDoc *doc, ScribusView *view, Selection* selection)
01116 {
01117        if (selection->count()==0)
01118               return "";
01119        double xp, yp;
01120        QString tmp, tmpy;
01121        PageItem *item;
01122        QDomDocument docu("scribus");
01123        QString st="<SCRIBUSELEMUTF8></SCRIBUSELEMUTF8>";
01124        docu.setContent(st);
01125        QDomElement elem=docu.documentElement();
01126        item = selection->itemAt(0);
01127        QValueList<uint> ELL;
01128        for (uint cor=0; cor<selection->count(); ++cor)
01129               ELL.append(selection->itemAt(cor)->ItemNr);
01130        qHeapSort(ELL);
01131        if (selection->isMultipleSelection())
01132        {
01133               double gx, gy, gw, gh;
01134               selection->getGroupRect(&gx, &gy, &gw, &gh);
01135               xp = gx - doc->currentPage()->xOffset();
01136               yp = gy - doc->currentPage()->yOffset();
01137               elem.setAttribute("W", gw);
01138               elem.setAttribute("H", gh);
01139        }
01140        else
01141        {
01142               if (item->rotation() != 0)
01143               {
01144                      double minx = 99999.9;
01145                      double miny = 99999.9;
01146                      double maxx = -99999.9;
01147                      double maxy = -99999.9;
01148                      double xpo = item->xPos() - doc->currentPage()->xOffset();
01149                      double ypo = item->yPos() - doc->currentPage()->yOffset();
01150                      FPointArray pb(4);
01151                      pb.setPoint(0, FPoint(xpo, ypo));
01152                      pb.setPoint(1, FPoint(item->width(), 0.0, xpo, ypo, item->rotation(), 1.0, 1.0));
01153                      pb.setPoint(2, FPoint(item->width(), item->height(), xpo, ypo, item->rotation(), 1.0, 1.0));
01154                      pb.setPoint(3, FPoint(0.0, item->height(), xpo, ypo, item->rotation(), 1.0, 1.0));
01155                      for (uint pc = 0; pc < 4; ++pc)
01156                      {
01157                             minx = QMIN(minx, pb.point(pc).x());
01158                             miny = QMIN(miny, pb.point(pc).y());
01159                             maxx = QMAX(maxx, pb.point(pc).x());
01160                             maxy = QMAX(maxy, pb.point(pc).y());
01161                      }
01162                      elem.setAttribute("W", maxx - minx);
01163                      elem.setAttribute("H", maxy - miny);
01164               }
01165               else
01166               {
01167                      elem.setAttribute("W", item->width());
01168                      elem.setAttribute("H", item->height());
01169               }
01170               xp = item->xPos() - doc->currentPage()->xOffset();
01171               yp = item->yPos() - doc->currentPage()->yOffset();
01172        }
01173        elem.setAttribute("XP", xp);
01174        elem.setAttribute("YP", yp);
01175        elem.setAttribute("COUNT", selection->count());
01176        elem.setAttribute("Version", QString(VERSION));
01177        QMap<QString,int>::Iterator itf;
01178        for (itf = doc->UsedFonts.begin(); itf != doc->UsedFonts.end(); ++itf)
01179        {
01180               QDomElement fn=docu.createElement("FONT");
01181               fn.setAttribute("NAME",itf.key());
01182               elem.appendChild(fn);
01183        }
01184        ColorList::Iterator itc;
01185        for (itc = doc->PageColors.begin(); itc != doc->PageColors.end(); ++itc)
01186        {
01187               QDomElement co=docu.createElement("COLOR");
01188               co.setAttribute("NAME",itc.key());
01189               if (doc->PageColors[itc.key()].getColorModel() == colorModelRGB)
01190                      co.setAttribute("RGB",doc->PageColors[itc.key()].nameRGB());
01191               else
01192                      co.setAttribute("CMYK",doc->PageColors[itc.key()].nameCMYK());
01193               co.setAttribute("Spot",static_cast<int>(doc->PageColors[itc.key()].isSpotColor()));
01194               co.setAttribute("Register",static_cast<int>(doc->PageColors[itc.key()].isRegistrationColor()));
01195               elem.appendChild(co);
01196        }
01197        QMap<int, ParagraphStyle> UsedStyles;
01198        QMap<int, int> UsedMapped2Saved;
01199 //     int NewStylesNum = 5;
01200        UsedStyles.clear();
01201        UsedMapped2Saved.clear();
01202 /*
01203        ParagraphStyle vg;
01204 //     if (doc->docParagraphStyles.count() > 5)
01205        {
01206               //for (uint co=0; co<Selitems->count(); ++co)
01207               for (uint co=0; co<selection->count(); ++co)
01208               {
01209                      item = doc->Items->at(ELL[co]);
01210                      int parstyle = findParagraphStyle(doc, item->itemText.defaultStyle());
01211                      if (parstyle > 4)
01212                      {
01213                             vg = item->itemText.defaultStyle();
01214                             UsedStyles[parstyle] = vg;
01215                      }
01216                      if (((item->asTextFrame()) || (item->asPathText())) && (item->itemText.length() != 0))
01217                      {
01218 #ifndef NLS_PROTO
01219                             for (int tx = 0; tx < item->itemText.length(); ++tx)
01220                             {
01221                                    if (item->itemText.text(tx) == SpecialChars::PARSEP)
01222                                    {
01223                                           vg = item->itemText.paragraphStyle(tx);
01224                                           UsedStyles[findParagraphStyle(doc, vg)] = vg;
01225                                    }
01226                             }
01227 #endif
01228                      }
01229               }
01230               QValueList<int> StyleNumb = UsedStyles.keys();
01231               qHeapSort(StyleNumb);
01232               for (uint ff = 0; ff < StyleNumb.count(); ++ff)
01233               {
01234                      int actSt = (*StyleNumb.at(ff));
01235                      UsedMapped2Saved.insert(actSt, NewStylesNum);
01236                      NewStylesNum++;
01237                      QDomElement fo=docu.createElement("STYLE");
01238                      fo.setAttribute("NAME",UsedStyles[actSt].name());
01239                      fo.setAttribute("ALIGN",UsedStyles[actSt].alignment());
01240                      fo.setAttribute("LINESPMode",UsedStyles[actSt].lineSpacingMode());
01241                      //CB #2738:
01242                      //UsedStyles[actSt].LineSpa is something like this is using automatic from the font:
01243                      //10.34912109375000000000. Default attribute value is then 10.3491 which then becomes //10.34909999999999996589 and then does not compare. This fixes, should we change our
01244                      //default precision?
01245                      fo.setAttribute("LINESP",QString::number(UsedStyles[actSt].lineSpacing(),'f',13));
01246                      fo.setAttribute("INDENT",UsedStyles[actSt].leftMargin());
01247                      fo.setAttribute("FIRST",UsedStyles[actSt].firstIndent());
01248                      fo.setAttribute("VOR",UsedStyles[actSt].gapBefore());
01249                      fo.setAttribute("NACH",UsedStyles[actSt].gapAfter());
01250                      fo.setAttribute("FONT",UsedStyles[actSt].charStyle().font().scName());
01251                      fo.setAttribute("FONTSIZE",UsedStyles[actSt].charStyle().fontSize() / 10.0);
01252                      fo.setAttribute("DROP", static_cast<int>(UsedStyles[actSt].hasDropCap()));
01253                      fo.setAttribute("DROPLIN", UsedStyles[actSt].dropCapLines());
01254                      fo.setAttribute("DROPDIST", UsedStyles[actSt].dropCapOffset());
01255                      fo.setAttribute("EFFECT", UsedStyles[actSt].charStyle().effects());
01256                      if (UsedStyles[actSt].tabValues().count() != 0)
01257                      {
01258                             for (uint a = 0; a < UsedStyles[actSt].tabValues().count(); ++a)
01259                             {
01260                                    QDomElement tabs = docu.createElement("Tabs");
01261                                    tabs.setAttribute("Type", (*UsedStyles[actSt].tabValues().at(a)).tabType);
01262                                    tabs.setAttribute("Pos", (*UsedStyles[actSt].tabValues().at(a)).tabPosition);
01263                                    QString tabCh = "";
01264                                    if (!(*UsedStyles[actSt].tabValues().at(a)).tabFillChar.isNull())
01265                                           tabCh = QString((*UsedStyles[actSt].tabValues().at(a)).tabFillChar);
01266                                    tabs.setAttribute("Fill", tabCh);
01267                                    fo.appendChild(tabs);
01268                             }
01269                      }
01270                      fo.setAttribute("FCOLOR",UsedStyles[actSt].charStyle().fillColor());
01271                      fo.setAttribute("FSHADE",UsedStyles[actSt].charStyle().fillShade());
01272                      fo.setAttribute("SCOLOR",UsedStyles[actSt].charStyle().strokeColor());
01273                      fo.setAttribute("SSHADE",UsedStyles[actSt].charStyle().strokeShade());
01274                      fo.setAttribute("BASE", static_cast<int>(UsedStyles[actSt].lineSpacingMode() == ParagraphStyle::BaselineGridLineSpacing));
01275                      fo.setAttribute("TXTSHX",UsedStyles[actSt].charStyle().shadowXOffset() / 10.0);
01276                      fo.setAttribute("TXTSHY",UsedStyles[actSt].charStyle().shadowYOffset() / 10.0);
01277                      fo.setAttribute("TXTOUT",UsedStyles[actSt].charStyle().outlineWidth() / 10.0);
01278                      fo.setAttribute("TXTULP",UsedStyles[actSt].charStyle().underlineOffset() / 10.0);
01279                      fo.setAttribute("TXTULW",UsedStyles[actSt].charStyle().underlineWidth() / 10.0);
01280                      fo.setAttribute("TXTSTP",UsedStyles[actSt].charStyle().strikethruOffset() / 10.0);
01281                      fo.setAttribute("TXTSTW",UsedStyles[actSt].charStyle().strikethruWidth() / 10.0);
01282                      fo.setAttribute("SCALEH",UsedStyles[actSt].charStyle().scaleH() / 10.0);
01283                      fo.setAttribute("SCALEV",UsedStyles[actSt].charStyle().scaleV() / 10.0);
01284                      fo.setAttribute("BASEO",UsedStyles[actSt].charStyle().baselineOffset() / 10.0);
01285                      fo.setAttribute("KERN",UsedStyles[actSt].charStyle().tracking() / 10.0);
01286                      elem.appendChild(fo);
01287               }
01288        }
01289  */
01290        QMap<QString,multiLine>::Iterator itMU;
01291        for (itMU = doc->MLineStyles.begin(); itMU != doc->MLineStyles.end(); ++itMU)
01292        {
01293               QDomElement MuL=docu.createElement("MultiLine");
01294               MuL.setAttribute("Name",itMU.key());
01295               multiLine ml = itMU.data();
01296               multiLine::iterator itMU2;
01297               for (itMU2 = ml.begin(); itMU2 != ml.end(); ++itMU2)
01298               {
01299                      QDomElement SuL=docu.createElement("SubLine");
01300                      SuL.setAttribute("Color", (*itMU2).Color);
01301                      SuL.setAttribute("Shade", (*itMU2).Shade);
01302                      SuL.setAttribute("Dash", (*itMU2).Dash);
01303                      SuL.setAttribute("LineEnd", (*itMU2).LineEnd);
01304                      SuL.setAttribute("LineJoin", (*itMU2).LineJoin);
01305                      SuL.setAttribute("Width", (*itMU2).Width);
01306                      MuL.appendChild(SuL);
01307               }
01308               elem.appendChild(MuL);
01309        }
01310        QMap<int, ArrowDesc> usedArrows;
01311        QMap<int, ArrowDesc>::Iterator itar;
01312        struct ArrowDesc arrow;
01313        //for (uint co=0; co<Selitems->count(); ++co)
01314        for (uint co=0; co<selection->count(); ++co)
01315        {
01316               item = doc->Items->at(ELL[co]);
01317               int startIndex = item->startArrowIndex();
01318               int endIndex = item->endArrowIndex();
01319               if (startIndex != 0)
01320               {
01321                      arrow.points = (*doc->arrowStyles.at(startIndex-1)).points.copy();
01322                      arrow.name = (*doc->arrowStyles.at(startIndex-1)).name;
01323                      usedArrows.insert(startIndex, arrow);
01324               }
01325               if (endIndex != 0)
01326               {
01327                      arrow.points = (*doc->arrowStyles.at(endIndex-1)).points.copy();
01328                      arrow.name = (*doc->arrowStyles.at(endIndex-1)).name;
01329                      usedArrows.insert(endIndex, arrow);
01330               }
01331        }
01332        if (usedArrows.count() != 0)
01333        {
01334               for (itar = usedArrows.begin(); itar != usedArrows.end(); ++itar)
01335               {
01336                      if (itar.data().userArrow)
01337                      {
01338                             QDomElement ar=docu.createElement("Arrows");
01339                             ar.setAttribute("NumPoints", itar.data().points.size());
01340                             QString arp = "";
01341                             double xa, ya;
01342                             for (uint nxx = 0; nxx < itar.data().points.size(); ++nxx)
01343                             {
01344                                    itar.data().points.point(nxx, &xa, &ya);
01345                                    arp += tmp.setNum(xa) + " " + tmpy.setNum(ya) + " ";
01346                             }
01347                             ar.setAttribute("Points", arp);
01348                             ar.setAttribute("Name", itar.data().name);
01349                             ar.setAttribute("Index", itar.key());
01350                             elem.appendChild(ar);
01351                      }
01352               }
01353        }
01354        QStringList patterns = doc->getUsedPatternsSelection();
01355        for (uint c = 0; c < patterns.count(); ++c)
01356        {
01357               ScPattern pa = doc->docPatterns[patterns[c]];
01358               QDomElement pat = docu.createElement("Pattern");
01359               pat.setAttribute("Name", patterns[c]);
01360               pat.setAttribute("scaleX", pa.scaleX);
01361               pat.setAttribute("scaleY", pa.scaleY);
01362               pat.setAttribute("width", pa.width);
01363               pat.setAttribute("height", pa.height);
01364               for (uint o = 0; o < pa.items.count(); o++)
01365               {
01366                      QDir::setCurrent(QDir::homeDirPath());
01367                      item = pa.items.at(o);
01368                      QDomElement ob = docu.createElement("PatternItem");
01369                      WriteObject(doc, docu, ob, UsedMapped2Saved, item);
01370                      pat.appendChild(ob);
01371               }
01372               elem.appendChild(pat);
01373        }
01374        for (uint co=0; co<selection->count(); ++co)
01375        {
01376               QDir::setCurrent(QDir::homeDirPath());
01377               item = doc->Items->at(ELL[co]);
01378               QDomElement ob = docu.createElement("ITEM");
01379               WriteObject(doc, docu, ob, UsedMapped2Saved, item);
01380               elem.appendChild(ob);
01381        }
01382        return docu.toString();
01383 }
01384 
01385 void ScriXmlDoc::WriteObject(ScribusDoc *doc, QDomDocument &docu, QDomElement &ob, QMap<int, int> &UsedMapped2Saved, PageItem *item)
01386 {
01387        int te, te2, tsh, tsh2, tst, tst2, tshs, tshs2;
01388        QString text, tf, tf2, tc, tc2, tcs, tcs2, tmp, tmpy;
01389        double ts, ts2, tsc, tsc2, tscv, tscv2, tb, tb2, tsx, tsx2, tsy, tsy2, tout, tout2, tulp, tulp2, tulw, tulw2, tstp, tstp2, tstw, tstw2;
01390        QString CurDirP = QDir::currentDirPath();
01391 
01392        int textAlignment = item->itemText.defaultStyle().alignment();
01393        ob.setAttribute("ALIGN",textAlignment);
01394        SetItemProps(&ob, item, false);
01395        ob.setAttribute("LOCK", 0);
01396        ob.setAttribute("XPOS",item->xPos() - doc->currentPage()->xOffset());
01397        ob.setAttribute("YPOS",item->yPos() - doc->currentPage()->yOffset());
01398        ob.setAttribute("BOOKMARK", item->isBookmark ? 1 : 0);
01399        ob.setAttribute("fillRule", static_cast<int>(item->fillRule));
01400        ob.setAttribute("doOverprint", static_cast<int>(item->doOverprint));
01401        ob.setAttribute("ImageClip", item->pixm.imgInfo.usedPath);
01402        if (item->effectsInUse.count() != 0)
01403        {
01404               for (uint a = 0; a < item->effectsInUse.count(); ++a)
01405               {
01406                      QDomElement imeff = docu.createElement("ImageEffect");
01407                      imeff.setAttribute("Code", (*item->effectsInUse.at(a)).effectCode);
01408                      imeff.setAttribute("Param", (*item->effectsInUse.at(a)).effectParameters);
01409                      ob.appendChild(imeff);
01410               }
01411        }
01412        if (item->itemText.defaultStyle().tabValues().count() != 0)
01413        {
01414               for (uint a = 0; a < item->itemText.defaultStyle().tabValues().count(); ++a)
01415               {
01416                      QDomElement tabs = docu.createElement("Tabs");
01417                      tabs.setAttribute("Type", (*item->itemText.defaultStyle().tabValues().at(a)).tabType);
01418                      tabs.setAttribute("Pos", (*item->itemText.defaultStyle().tabValues().at(a)).tabPosition);
01419                      QString tabCh = "";
01420                      if (!(*item->itemText.defaultStyle().tabValues().at(a)).tabFillChar.isNull())
01421                             tabCh = QString((*item->itemText.defaultStyle().tabValues().at(a)).tabFillChar);
01422                      tabs.setAttribute("Fill", tabCh);
01423                      ob.appendChild(tabs);
01424               }
01425        }
01426        if (((item->asImageFrame()) || (item->asTextFrame())) && (!item->Pfile.isEmpty()) && (item->pixm.imgInfo.layerInfo.count() != 0) && (item->pixm.imgInfo.isRequest))
01427        {
01428               QMap<int, ImageLoadRequest>::iterator it2;
01429               for (it2 = item->pixm.imgInfo.RequestProps.begin(); it2 != item->pixm.imgInfo.RequestProps.end(); ++it2)
01430               {
01431                      QDomElement psd = docu.createElement("PSDLayer");
01432                      psd.setAttribute("Layer",it2.key());
01433                      psd.setAttribute("Visible", static_cast<int>(it2.data().visible));
01434                      psd.setAttribute("useMask", static_cast<int>(it2.data().useMask));
01435                      psd.setAttribute("Opacity", it2.data().opacity);
01436                      psd.setAttribute("Blend", it2.data().blend);
01437                      ob.appendChild(psd);
01438               }
01439        }
01440        if (item->GrType != 0)
01441        {
01442               if (item->GrType == 8)
01443               {
01444                      ob.setAttribute("pattern", item->pattern());
01445                      double patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation;
01446                      item->patternTransform(patternScaleX, patternScaleY, patternOffsetX, patternOffsetY, patternRotation);
01447                      ob.setAttribute("pScaleX", patternScaleX);
01448                      ob.setAttribute("pScaleY", patternScaleY);
01449                      ob.setAttribute("pOffsetX", patternOffsetX);
01450                      ob.setAttribute("pOffsetY", patternOffsetY);
01451                      ob.setAttribute("pRotation", patternRotation);
01452               }
01453               else
01454               {
01455                      QPtrVector<VColorStop> cstops = item->fill_gradient.colorStops();
01456                      for (uint cst = 0; cst < item->fill_gradient.Stops(); ++cst)
01457                      {
01458                             QDomElement itcl = docu.createElement("CSTOP");
01459                             itcl.setAttribute("RAMP", cstops.at(cst)->rampPoint);
01460                             itcl.setAttribute("NAME", cstops.at(cst)->name);
01461                             itcl.setAttribute("SHADE", cstops.at(cst)->shade);
01462                             itcl.setAttribute("TRANS", cstops.at(cst)->opacity);
01463                             ob.appendChild(itcl);
01464                      }
01465                      ob.setAttribute("GRSTARTX", item->GrStartX);
01466                      ob.setAttribute("GRSTARTY", item->GrStartY);
01467                      ob.setAttribute("GRENDX", item->GrEndX);
01468                      ob.setAttribute("GRENDY", item->GrEndY);
01469               }
01470        }
01471        QDir::setCurrent(CurDirP);
01472        for(int k=0;k<item->itemText.length();++k)
01473        {
01474               const CharStyle& style4(item->itemText.charStyle(k));
01475               QChar ch = item->itemText.text(k);
01476               QDomElement it=docu.createElement("ITEXT");
01477               ts = style4.fontSize() / 10.0;
01478               tf = style4.font().scName();
01479               tc = style4.fillColor();
01480               te = style4.tracking();
01481               tsh = style4.fillShade();
01482               tst = style4.effects() & 2047;
01483               tcs = style4.strokeColor();
01484               tshs = style4.strokeShade();
01485               tsc = style4.scaleH() / 10.0;
01486               tscv = style4.scaleV() / 10.0;
01487               tb = style4.baselineOffset() / 10.0;
01488               tsx = style4.shadowXOffset() / 10.0;
01489               tsy = style4.shadowYOffset() / 10.0;
01490               tout = style4.outlineWidth() / 10.0;
01491               tulp = style4.underlineOffset() / 10.0;
01492               tulw = style4.underlineWidth() / 10.0;
01493               tstp = style4.strikethruOffset()/ 10.0;
01494               tstw = style4.strikethruWidth() / 10.0;
01495               if (ch == SpecialChars::PARSEP)
01496                      text = QChar(5);
01497               else if (ch == SpecialChars::TAB)
01498                      text = QChar(4);
01499               else
01500                      text = ch;
01501               QString pstylename = "";
01502               if (ch == SpecialChars::PARSEP)
01503                      pstylename = item->itemText.paragraphStyle(k).parent();
01504               ++k;
01505               if (k == item->itemText.length())
01506               {
01507                      it.setAttribute("CH",text);
01508                      it.setAttribute("CSIZE",ts);
01509                      it.setAttribute("CFONT",tf);
01510                      it.setAttribute("CCOLOR",tc);
01511                      it.setAttribute("CKERN",te);
01512                      it.setAttribute("CSHADE",tsh);
01513                      it.setAttribute("CSTYLE",tst);
01514                      it.setAttribute("CSTROKE",tcs);
01515                      it.setAttribute("CSHADE2",tshs);
01516                      it.setAttribute("CSCALE",tsc);
01517                      it.setAttribute("CSCALEV",tscv);
01518                      it.setAttribute("CBASE",tb);
01519                      it.setAttribute("CSHX",tsx);
01520                      it.setAttribute("CSHY",tsy);
01521                      it.setAttribute("COUT",tout);
01522                      it.setAttribute("CULP",tulp);
01523                      it.setAttribute("CULW",tulw);
01524                      it.setAttribute("CSTP",tstp);
01525                      it.setAttribute("CSTW",tstw);
01526                      it.setAttribute("PSTYLE",pstylename);
01527                      ob.appendChild(it);
01528                      break;
01529               }
01530               const CharStyle& style5(item->itemText.charStyle(k));
01531               ch = item->itemText.text(k);
01532               ts2 = style5.fontSize() / 10.0;
01533               tf2 = style5.font().scName();
01534               tc2 = style5.fillColor();
01535               te2 = style5.tracking();
01536               tsh2 = style5.fillShade();
01537               tst2 = style5.effects() & 2047;
01538               tcs2 = style5.strokeColor();
01539               tshs2 = style5.strokeShade();
01540               tsc2 = style5.scaleH() / 10.0;
01541               tscv2 = style5.scaleV() / 10.0;
01542               tb2 = style5.baselineOffset() / 10.0;
01543               tsx2 = style5.shadowXOffset() / 10.0;
01544               tsy2 = style5.shadowYOffset() / 10.0;
01545               tout2 = style5.outlineWidth() / 10.0;
01546               tulp2 = style5.underlineOffset() / 10.0;
01547               tulw2 = style5.underlineWidth() / 10.0;
01548               tstp2 = style5.strikethruOffset() / 10.0;
01549               tstw2 = style5.strikethruWidth() / 10.0;
01550               QString pstylename2 = "";
01551               if (ch == SpecialChars::PARSEP)
01552                      pstylename2 = item->itemText.paragraphStyle(k).parent();
01553               while ((ts2 == ts)
01554                                           && (tf2 == tf)
01555                                           && (tc2 == tc)
01556                                           && (te2 == te)
01557                                           && (tsh2 == tsh)
01558                                           && (tshs2 == tshs)
01559                                           && (tsc2 == tsc)
01560                                           && (tscv2 == tscv)
01561                                           && (tcs2 == tcs)
01562                                           && (tb2 == tb)
01563                                           && (tsx2 == tsx)
01564                                           && (tsy2 == tsy)
01565                                           && (tout2 == tout)
01566                                           && (tulp2 == tulp)
01567                                           && (tulw2 == tulw)
01568                                           && (tstp2 == tstp)
01569                                           && (tstw2 == tstw)
01570                                           && (tst2 == tst)
01571                         && (pstylename == pstylename2))
01572               {
01573                      if (ch == QChar(13))
01574                             text += QChar(5);
01575                      else if (ch == QChar(9))
01576                             text += QChar(4);
01577                      else
01578                             text += ch;
01579                      ++k;
01580                      if (k == item->itemText.length())
01581                             break;
01582                      const CharStyle& style6(item->itemText.charStyle(k));
01583                      ch = item->itemText.text(k);
01584                      ts2 = style6.fontSize() / 10.0;
01585                      tf2 = style6.font().scName();
01586                      tc2 = style6.fillColor();
01587                      te2 = style6.tracking();
01588                      tsh2 = style6.fillShade();
01589                      tst2 = style6.effects() & 2047;
01590                      tcs2 = style6.strokeColor();
01591                      tshs2 = style6.strokeShade();
01592                      tsc2 = style6.scaleH() / 10.0;
01593                      tscv2 = style6.scaleV() / 10.0;
01594                      tb2 = style6.baselineOffset() / 10.0;
01595                      tsx2 = style6.shadowXOffset() / 10.0;
01596                      tsy2 = style6.shadowYOffset() / 10.0;
01597                      tout2 = style6.outlineWidth() / 10.0;
01598                      tulp2 = style6.underlineOffset() / 10.0;
01599                      tulw2 = style6.underlineWidth() / 10.0;
01600                      tstp2 = style6.strikethruOffset() / 10.0;
01601                      tstw2 = style6.strikethruWidth() / 10.0;
01602                      pstylename2 = "";
01603                      if (ch == SpecialChars::PARSEP)
01604                             pstylename2 = item->itemText.paragraphStyle(k).parent();
01605               }
01606               it.setAttribute("CH",text);
01607               it.setAttribute("CSIZE",ts);
01608               it.setAttribute("CFONT",tf);
01609               it.setAttribute("CCOLOR",tc);
01610               it.setAttribute("CKERN",te);
01611               it.setAttribute("CSHADE",tsh);
01612               it.setAttribute("CSTYLE",tst);
01613               it.setAttribute("CSTROKE",tcs);
01614               it.setAttribute("CSHADE2",tshs);
01615               it.setAttribute("CSCALE",tsc);
01616               it.setAttribute("CSCALEV",tscv);
01617               it.setAttribute("CBASE",tb);
01618               it.setAttribute("CSHX",tsx);
01619               it.setAttribute("CSHY",tsy);
01620               it.setAttribute("COUT",tout);
01621               it.setAttribute("CULP",tulp);
01622               it.setAttribute("CULW",tulw);
01623               it.setAttribute("CSTP",tstp);
01624               it.setAttribute("CSTW",tstw);
01625               it.setAttribute("PSTYLE",pstylename);
01626               k--;
01627               ob.appendChild(it);
01628        }
01629        ob.setAttribute("NUMTEXT",item->itemText.length());
01630        QString txnu = "";
01631        for(int kt = 0; kt < item->itemText.length(); ++kt)
01632 #ifndef NLS_PROTO
01633               txnu += tmp.setNum(item->itemText.item(kt)->glyph.xoffset) + " " + tmpy.setNum(item->itemText.item(kt)->glyph.yoffset) + " ";
01634 #else
01635               txnu += "0 0 ";
01636 #endif
01637        ob.setAttribute("TEXTCOOR", txnu);
01638        ob.setAttribute("BACKITEM", -1);
01639        ob.setAttribute("BACKPAGE", -1);
01640        ob.setAttribute("NEXTITEM", -1);
01641        ob.setAttribute("NEXTPAGE", -1);
01642 }