Back to index

scribus-ng  1.3.4.dfsg+svn20071115
scpreview.cpp
Go to the documentation of this file.
00001 /*
00002 For general Scribus (>=1.3.2) copyright and licensing information please refer
00003 to the COPYING file provided with the program. Following this notice may exist
00004 a copyright and/or license notice that predates the release of Scribus 1.3.2
00005 for which a new license (GPL+exception) is in place.
00006 */
00007 #include "scpreview.h"
00008 #include <qtextstream.h>
00009 #include <qdom.h>
00010 #include <qmap.h>
00011 #include <qpainter.h>
00012 #include <qrect.h>
00013 #include <qimage.h>
00014 #include <qregion.h>
00015 #include <qregexp.h>
00016 #include <qfileinfo.h>
00017 #include <qbitmap.h>
00018 #include <qdir.h>
00019 #include <cmath>
00020 #include <cstdlib>
00021 
00022 #include "missing.h"
00023 #include "sccolor.h"
00024 #include "scribus.h"
00025 #include "scribuscore.h"
00026 #include "splash.h"
00027 #include "util.h"
00028 #include "prefsmanager.h"
00029 #include "scpainter.h"
00030 #include "commonstrings.h"
00031 #include "sccolorengine.h"
00032 
00033 
00034 using namespace std;
00035 
00036 
00037 ScPreview::ScPreview()
00038 {
00039        prefsManager = PrefsManager::instance();
00040        Farben.clear();
00041        MLineStyles.clear();
00042        Segments.clear();
00043 }
00044 
00045 QPixmap ScPreview::createPreview(QString data)
00046 {
00047        struct CopyPasteBuffer OB;
00048        ScText *hg;
00049        ScText *hl;
00050        QPtrList<ScText> Ptexti;
00051        ScColor lf = ScColor();
00052        QFont fo;
00053        QMap<QString,QString> DoFonts;
00054        QMap<int,int> arrowID;
00055        QString tmpf, tmpx, tmp2, tmp3;
00056        int x, y;
00057        double xf, yf, asce;
00058        FPoint gv;
00059        int chs, currItem, fillBlendmode, strokeBlendmode;
00060        QPointArray cl;
00061        QColor tmpfa;
00062        QString chstr;
00063        uint a, zae;
00064        double CurY, EndX, CurX, wide, rota, wid;
00065        QValueList<ArrowDesc> arrowStyles;
00066        QValueStack<int> groupStack;
00067        arrowStyles = prefsManager->appPrefs.arrowStyles;
00068        QDomDocument docu("scridoc");
00069        docu.setContent(data);
00070        QDomElement elem=docu.documentElement();
00071        if ((elem.tagName() != "SCRIBUSELEM") && (elem.tagName() != "SCRIBUSELEMUTF8"))
00072        {
00073               QPixmap tmp = QPixmap(0, 0);
00074               return tmp;
00075        }
00076        double GrX = elem.attribute("XP").toDouble();
00077        double GrY = elem.attribute("YP").toDouble();
00078        double GrW = elem.attribute("W").toDouble();
00079        double GrH = elem.attribute("H").toDouble();
00080        double pmmax = 60 / QMAX(GrW+50, GrH+50);
00081 #ifdef HAVE_CAIRO
00082        QImage tmp = QImage(static_cast<int>(GrW)+50, static_cast<int>(GrH)+50, 32);
00083        tmp.fill( qRgba(255, 255, 255, 0) );
00084        ScPainter *pS = new ScPainter(&tmp, tmp.width(), tmp.height(), 1.0, 0);
00085        pS->beginLayer(1.0, 0);
00086 #else
00087        QPixmap tmp(static_cast<int>(GrW)+50, static_cast<int>(GrH)+50);
00088        ScPainter *pS = new ScPainter(&tmp, tmp.width(), tmp.height());
00089 #endif
00090        pS->translate(25,25);
00091        QDomNode DOC=elem.firstChild();
00092        DoFonts.clear();
00093        while(!DOC.isNull())
00094        {
00095               QDomElement pg=DOC.toElement();
00096               if(pg.tagName()=="Arrows")
00097               {
00098                      struct ArrowDesc arrow;
00099                      double xa, ya;
00100                      arrow.name = pg.attribute("Name");
00101                      QString tmp = pg.attribute("Points");
00102                      QTextStream fp(&tmp, IO_ReadOnly);
00103                      for (uint cx = 0; cx < pg.attribute("NumPoints").toUInt(); ++cx)
00104                      {
00105                             fp >> xa;
00106                             fp >> ya;
00107                             arrow.points.addPoint(xa, ya);
00108                      }
00109                      arrowStyles.append(arrow);
00110                      arrowID.insert(pg.attribute("Index").toInt(), arrowStyles.count());
00111               }
00112               if(pg.tagName()=="FONT")
00113               {
00114                      tmpf = GetAttr(&pg, "NAME");
00115                      if ((!prefsManager->appPrefs.AvailFonts.contains(tmpf)) || (!prefsManager->appPrefs.AvailFonts[tmpf].usable()))
00116                      {
00117                             if ((!prefsManager->appPrefs.GFontSub.contains(tmpf)) || (!prefsManager->appPrefs.AvailFonts[prefsManager->appPrefs.GFontSub[tmpf]].usable()))
00118                             {
00119                                    ScCore->showSplash(false);
00120                                    MissingFont *dia = new MissingFont(0, tmpf, 0);
00121                                    dia->exec();
00122                                    tmpf = dia->getReplacementFont();
00123                                    delete dia;
00124                                    ScCore->showSplash(true);
00125                                    prefsManager->appPrefs.GFontSub[pg.attribute("NAME")] = tmpf;
00126                             }
00127                             else
00128                                    tmpf = prefsManager->appPrefs.GFontSub[tmpf];
00129                      }
00130                      if (!DoFonts.contains(tmpf))
00131                      {
00132 //                          FT_Face face;
00133 //                          error = FT_New_Face( library, prefsManager->appPrefs.AvailFonts[tmpf].fontFilePath(), prefsManager->appPrefs.AvailFonts[tmpf].faceIndex(), &face );
00134                             if ( prefsManager->appPrefs.AvailFonts[tmpf].usable() )
00135                                    tmpf = prefsManager->appPrefs.toolSettings.defFont;
00136 /*                          if (prefsManager->appPrefs.AvailFonts[tmpf]->ReadMetrics()) {
00137 //already done in ScFonts::addScalaableFont():
00138 //                                 prefsManager->appPrefs.AvailFonts[tmpf]->CharWidth[13] = 0;
00139                             }
00140                             else
00141                             {
00142                                    tmpf = prefsManager->appPrefs.toolSettings.defFont;
00143 //                                 prefsManager->appPrefs.AvailFonts[tmpf]->ReadMetrics();
00144 //already done in ScFonts::addScalaableFont():
00145 //                                 prefsManager->appPrefs.AvailFonts[tmpf]->CharWidth[13] = 0;
00146                             }
00147 */
00148                      }
00149 //                   fo = prefsManager->appPrefs.AvailFonts[tmpf]->Font;
00150 //                   fo.setPointSize(12);
00151                      DoFonts[GetAttr(&pg, "NAME")] = tmpf;
00152 //                   DoFonts2[GetAttr(&pg, "NAME")] = fo;
00153               }
00154               if(pg.tagName()=="COLOR")
00155               {
00156                      if (pg.hasAttribute("CMYK"))
00157                             lf.setNamedColor(GetAttr(&pg, "CMYK"));
00158                      else
00159                             lf.fromQColor(QColor(GetAttr(&pg, "RGB")));
00160                      Farben[GetAttr(&pg, "NAME")] = lf;
00161               }
00162               if(pg.tagName()=="MultiLine")
00163               {
00164                      multiLine ml;
00165                      QDomNode MuLn = DOC.firstChild();
00166                      while(!MuLn.isNull())
00167                      {
00168                             QDomElement MuL = MuLn.toElement();
00169                             struct SingleLine sl;
00170                             sl.Color = MuL.attribute("Color");
00171                             sl.Dash = MuL.attribute("Dash").toInt();
00172                             sl.LineEnd = MuL.attribute("LineEnd").toInt();
00173                             sl.LineJoin = MuL.attribute("LineJoin").toInt();
00174                             sl.Shade = MuL.attribute("Shade").toInt();
00175                             sl.Width = MuL.attribute("Width").toDouble();
00176                             ml.push_back(sl);
00177                             MuLn = MuLn.nextSibling();
00178                      }
00179                      if (!MLineStyles.contains(pg.attribute("Name")))
00180                             MLineStyles.insert(pg.attribute("Name"), ml);
00181               }
00182               DOC=DOC.nextSibling();
00183        }
00184        DOC=elem.firstChild();
00185        currItem = -1;
00186        while(!DOC.isNull())
00187        {
00188               QDomElement pg=DOC.toElement();
00189               if(pg.tagName()=="ITEM")
00190               {
00191                      currItem++;
00192                      QString CurDirP = QDir::currentDirPath();
00193                      QDir::setCurrent(QDir::homeDirPath());
00194                      Segments.clear();
00195                      // TODO: Nicer conversion
00196                      OB.PType = static_cast<PageItem::ItemType>(pg.attribute("PTYPE").toInt());
00197                      OB.Xpos = pg.attribute("XPOS").toDouble() - GrX;
00198                      OB.Ypos = pg.attribute("YPOS").toDouble() - GrY;
00199                      OB.Width = pg.attribute("WIDTH").toDouble();
00200                      OB.Height = pg.attribute("HEIGHT").toDouble();
00201                      OB.RadRect = pg.attribute("RADRECT", "0").toDouble();
00202                      OB.ClipEdited = pg.attribute("CLIPEDIT", "0").toInt();
00203                      OB.FrameType = pg.attribute("FRTYPE", "0").toInt();
00204                      OB.Pwidth = pg.attribute("PWIDTH").toDouble();
00205                      OB.Pcolor = pg.attribute("PCOLOR");
00206                      OB.Pcolor2 = pg.attribute("PCOLOR2");
00207                      OB.NamedLStyle = pg.attribute("NAMEDLST", "");
00208                      if (!MLineStyles.contains(OB.NamedLStyle))
00209                             OB.NamedLStyle = "";
00210                      OB.Shade = pg.attribute("SHADE").toInt();
00211                      OB.Shade2 = pg.attribute("SHADE2").toInt();
00212                      OB.TxtFill = pg.attribute("TXTFILL", "Black");
00213                      OB.TxtStroke = pg.attribute("TXTSTROKE", CommonStrings::None);
00214                      OB.ShTxtFill = pg.attribute("TXTFILLSH", "100").toInt();
00215                      OB.ShTxtStroke = pg.attribute("TXTSTRSH", "100").toInt();
00216                      OB.TxtScale = qRound(pg.attribute("TXTSCALE", "100").toDouble() * 10);
00217                      OB.TxtScaleV = qRound(pg.attribute("TXTSCALEV", "100").toDouble() * 10);
00218                      OB.TxTBase = qRound(pg.attribute("TXTBASE", "0").toDouble() * 10);
00219                      OB.TxTStyle = pg.attribute("TXTSTYLE", "0").toInt();
00220                      OB.GrType = pg.attribute("GRTYP", "0").toInt();
00221                      OB.fill_gradient.clearStops();
00222                      if (OB.GrType != 0)
00223                      {
00224                             OB.GrStartX = pg.attribute("GRSTARTX", "0.0").toDouble();
00225                             OB.GrStartY = pg.attribute("GRSTARTY", "0.0").toDouble();
00226                             OB.GrEndX = pg.attribute("GRENDX", "0.0").toDouble();
00227                             OB.GrEndY = pg.attribute("GRENDY", "0.0").toDouble();
00228                             OB.GrColor = pg.attribute("GRCOLOR","");
00229                             if (!OB.GrColor.isEmpty())
00230                             {
00231                                    OB.GrColor2 = pg.attribute("GRCOLOR2","");
00232                                    OB.GrShade = pg.attribute("GRSHADE", "100").toInt();
00233                                    OB.GrShade2 = pg.attribute("GRSHADE2", "100").toInt();
00234                             }
00235                      }
00236                      OB.Rot = pg.attribute("ROT").toDouble();
00237                      OB.PLineArt = Qt::PenStyle(pg.attribute("PLINEART").toInt());
00238                      OB.PLineEnd = Qt::PenCapStyle(pg.attribute("PLINEEND", "0").toInt());
00239                      OB.PLineJoin = Qt::PenJoinStyle(pg.attribute("PLINEJOIN", "0").toInt());
00240                      OB.LineSp = pg.attribute("LINESP").toDouble();
00241                      OB.ExtraV = static_cast<int>(pg.attribute("EXTRAV", "0").toDouble()); // temporary compiler silencing
00242                      OB.LocalScX = pg.attribute("LOCALSCX").toDouble();
00243                      OB.LocalScY = pg.attribute("LOCALSCY").toDouble();
00244                      OB.LocalX = pg.attribute("LOCALX").toDouble();
00245                      OB.LocalY = pg.attribute("LOCALY").toDouble();
00246                      OB.PicArt = pg.attribute("PICART").toInt();
00247                      OB.flippedH = pg.attribute("FLIPPEDH").toInt();
00248                      OB.flippedV = pg.attribute("FLIPPEDV").toInt();
00249                      OB.ScaleType = pg.attribute("SCALETYPE", "1").toInt();
00250                      OB.AspectRatio = pg.attribute("RATIO", "0").toInt();
00251                      OB.isPrintable = pg.attribute("PRINTABLE").toInt();
00252                      OB.isBookmark = false;
00253                      OB.m_isAnnotation = pg.attribute("ANNOTATION", "0").toInt();
00254                      if (pg.attribute("TRANSPARENT", "0").toInt() == 1)
00255                             OB.Pcolor = CommonStrings::None;
00256                      //OB.Textflow = pg.attribute("TEXTFLOW").toInt();
00257                      //OB.Textflow2 = pg.attribute("TEXTFLOW2", "0").toInt();
00258                      if ( pg.hasAttribute("TEXTFLOWMODE") )
00259                             OB.TextflowMode = (PageItem::TextFlowMode) pg.attribute("TEXTFLOWMODE", "0").toInt();
00260                      else if ( pg.attribute("TEXTFLOW").toInt() )
00261                      {
00262                             if (pg.attribute("TEXTFLOW2", "0").toInt())
00263                                    OB.TextflowMode = PageItem::TextFlowUsesBoundingBox;
00264                             else if (pg.attribute("TEXTFLOW3", "0").toInt())
00265                                    OB.TextflowMode = PageItem::TextFlowUsesContourLine;
00266                             else
00267                                    OB.TextflowMode = PageItem::TextFlowUsesFrameShape;     
00268                      }
00269                      else
00270                             OB.TextflowMode = PageItem::TextFlowDisabled;
00271                      OB.Extra = pg.attribute("EXTRA").toDouble();
00272                      OB.TExtra = pg.attribute("TEXTRA", "1").toDouble();
00273                      OB.BExtra = pg.attribute("BEXTRA", "1").toDouble();
00274                      OB.RExtra = pg.attribute("REXTRA", "1").toDouble();
00275                      OB.PoShow = pg.attribute("PTLSHOW", "0").toInt();
00276                      OB.BaseOffs = pg.attribute("BASEOF", "0").toDouble();
00277                      OB.textAlignment = pg.attribute("ALIGN", "0").toInt();
00278                      OB.IFont = DoFonts[pg.attribute("IFONT")];
00279                      OB.ISize = qRound(pg.attribute("ISIZE", "12").toDouble() * 10.0);
00280                      OB.Pfile = pg.attribute("PFILE");
00281                      OB.Pfile2 = pg.attribute("PFILE2","");
00282                      OB.Pfile3 = pg.attribute("PFILE3","");
00283                      OB.IProfile = pg.attribute("PRFILE","");
00284                      OB.EmProfile = pg.attribute("EPROF","");
00285                      OB.IRender = pg.attribute("IRENDER", "1").toInt();
00286                      OB.UseEmbedded = pg.attribute("EMBEDDED", "1").toInt();
00287                      OB.Locked = static_cast<bool>(pg.attribute("LOCK", "0").toInt());
00288                      OB.Reverse = static_cast<bool>(pg.attribute("REVERS", "0").toInt());
00289                      OB.Transparency = pg.attribute("TransValue", "0.0").toDouble();
00290                      if (pg.hasAttribute("TransValueS"))
00291                             OB.TranspStroke = pg.attribute("TransValueS", "0.0").toDouble();
00292                      else
00293                             OB.TranspStroke = OB.Transparency;
00294                      fillBlendmode = pg.attribute("TransBlend", "0").toInt();
00295                      strokeBlendmode = pg.attribute("TransBlendS", "0").toInt();
00296                      if (pg.hasAttribute("NUMCLIP"))
00297                      {
00298                             OB.Clip.resize(pg.attribute("NUMCLIP").toUInt());
00299                             tmpx = pg.attribute("CLIPCOOR");
00300                             QTextStream f(&tmpx, IO_ReadOnly);
00301                             for (uint c=0; c<pg.attribute("NUMCLIP").toUInt(); ++c)
00302                             {
00303                                    f >> x;
00304                                    f >> y;
00305                                    OB.Clip.setPoint(c, x, y);
00306                             }
00307                      }
00308                      else
00309                             OB.Clip.resize(0);
00310                      if (pg.hasAttribute("NUMPO"))
00311                      {
00312                             OB.PoLine.resize(pg.attribute("NUMPO").toUInt());
00313                             tmpx = pg.attribute("POCOOR");
00314                             QTextStream fp(&tmpx, IO_ReadOnly);
00315                             for (uint cx=0; cx<pg.attribute("NUMPO").toUInt(); ++cx)
00316                             {
00317                                    fp >> xf;
00318                                    fp >> yf;
00319                                    OB.PoLine.setPoint(cx, xf, yf);
00320                             }
00321                      }
00322                      else
00323                             OB.PoLine.resize(0);
00324                      OB.Groups.clear();
00325                      if (OB.Clip.size() == 0)
00326                             OB.Clip = FlattenPath(OB.PoLine, Segments);
00327                      tmpx = "";
00328                      QDomNode IT=DOC.firstChild();
00329                      while(!IT.isNull())
00330                      {
00331                             QDomElement it=IT.toElement();
00332                             if (it.tagName()=="CSTOP")
00333                             {
00334                                    QString name = it.attribute("NAME");
00335                                    double ramp = it.attribute("RAMP", "0.0").toDouble();
00336                                    int shade = it.attribute("SHADE", "100").toInt();
00337                                    SetFarbe(&tmpfa, name, shade);
00338                                    OB.fill_gradient.addStop(tmpfa, ramp, 0.5, 1.0, name, shade);
00339                             }
00340                             if (it.tagName()=="ITEXT")
00341                             {
00342                                    tmp2 = it.attribute("CH");
00343                                    tmp2.replace(QRegExp("\r"), QChar(5));
00344                                    tmp2.replace(QRegExp("\n"), QChar(5));
00345                                    tmp3 = "\t" + DoFonts[it.attribute("CFONT")] + "\t";
00346                                    tmp3 += it.attribute("CSIZE") + "\t";
00347                                    tmp3 += it.attribute("CCOLOR") + "\t";
00348 //                                 tmp3 += it.attribute("CEXTRA") + "\t";
00349                                    tmp3 += "0\t";
00350                                    tmp3 += it.attribute("CSHADE") + "\t";
00351                                    tmp3 += it.attribute("CSTYLE") + "\t";
00352                                    tmp3 += "0\t";
00353                                    tmp3 += it.attribute("CSTROKE",CommonStrings::None) + "\t";
00354                                    tmp3 += it.attribute("CSHADE2","100") + "\t";
00355                                    tmp3 += it.attribute("CSCALE","100") + "\n";
00356                                    for (uint cxx=0; cxx<tmp2.length(); cxx++)
00357                                    {
00358                                           tmpx += tmp2.at(cxx)+tmp3;
00359                                    }
00360                             }
00361                             IT=IT.nextSibling();
00362                      }
00363                      OB.itemText = tmpx;
00364                      if (!OB.itemText.isEmpty())
00365                      {
00366                             QTextStream t(&OB.itemText, IO_ReadOnly);
00367                             QString cc;
00368 #ifndef NLS_PROTO
00369                             while (!t.atEnd())
00370                             {
00371                                    cc = t.readLine();
00372                                    if (cc.isEmpty())
00373                                           continue;
00374                                    QStringList wt;
00375                                    QStringList::Iterator it;
00376                                    wt = QStringList::split("\t", cc);
00377                                    it = wt.begin();
00378                                    hg = new ScText;
00379                                    hg->ch = (*it);
00380                                    if (hg->ch == QChar(5))
00381                                           hg->ch = QChar(13);
00382                                    it++;
00383                                    hg->setFont(prefsManager->appPrefs.AvailFonts[*it]);
00384                                    it++;
00385                                    hg->setFontSize(qRound((*it).toDouble() * 10.0));
00386                                    it++;
00387                                    hg->setFillColor(*it);
00388                                    it++;
00389                                    hg->setTracking((*it).toInt());
00390                                    it++;
00391                                    hg->setFillShade((*it).toInt());
00392                                    it++;
00393                                    if (it == NULL)
00394                                           hg->setFeatures(QStringList(CharStyle::INHERIT));
00395                                    else
00396                                           hg->setFeatures(static_cast<StyleFlag>((*it).toInt()).featureList());
00397                                    it++;
00398 //                                 if (it == NULL)
00399 //                                        hg->cab = 0;
00400 //                                 else
00401 //                                        hg->cab = (*it).toInt();
00402                                    it++;
00403                                    if (it == NULL)
00404                                           hg->setStrokeColor(CommonStrings::None);
00405                                    else
00406                                           hg->setStrokeColor(*it);
00407                                    it++;
00408                                    if (it == NULL)
00409                                           hg->setStrokeShade(100);
00410                                    else
00411                                           hg->setStrokeShade((*it).toInt());
00412                                    it++;
00413                                    if (it == NULL)
00414                                           hg->setScaleH(100);
00415                                    else
00416                                           hg->setScaleH((*it).toInt());
00417 
00418                                    Ptexti.append(hg);
00419                             }
00420 #endif
00421                      }
00422                      tmpx = GetAttr(&pg, "TEXTCOOR","0 0");
00423                      QTextStream ft(&tmpx, IO_ReadOnly);
00424                      for (uint ct=0; ct<GetAttr(&pg, "NUMTEXT","0").toUInt(); ct++)
00425                      {
00426 #ifndef NLS_PROTO
00427                             ft >> Ptexti.at(ct)->glyph.xoffset;
00428                             ft >> Ptexti.at(ct)->glyph.yoffset;
00429 #endif
00430                      }
00431                      tmpx = "";
00432                      if ((OB.PType == 5) && (OB.Height != 0))
00433                      {
00434                             OB.Rot += atan2(OB.Height,OB.Width)*(180.0/M_PI);
00435                             OB.Width = sqrt(pow(OB.Width,2)+pow(OB.Height,2));
00436                             OB.Height = 0;
00437                             OB.Clip.setPoints(4, -1,-1, static_cast<int>(OB.Width+1),-1, static_cast<int>(OB.Width+1), static_cast<int>(OB.Height+1), -1, static_cast<int>(OB.Height+1));
00438                      }
00439                      OB.LayerNr = -1;
00440                      OB.startArrowIndex =  arrowID[pg.attribute("startArrowIndex", "0").toInt()];
00441                      OB.endArrowIndex =  arrowID[pg.attribute("endArrowIndex", "0").toInt()];
00442                      if(static_cast<bool>(pg.attribute("isGroupControl", "0").toInt()))
00443                      {
00444                             pS->save();
00445 #ifdef HAVE_CAIRO
00446                             FPointArray cl = OB.PoLine.copy();
00447                             QWMatrix mm;
00448                             mm.translate(OB.Xpos, OB.Ypos);
00449                             mm.rotate(static_cast<double>(OB.Rot));
00450                             cl.map( mm );
00451                             pS->beginLayer(1.0 - OB.Transparency, pg.attribute("TransBlend", "0").toInt(), &cl);
00452 #endif
00453                             groupStack.push(pg.attribute("groupsLastItem", "0").toInt() + currItem);
00454                             DOC=DOC.nextSibling();
00455                             continue;
00456                      }
00457                      pS->save();
00458 #ifdef HAVE_CAIRO
00459                      if (fillBlendmode != 0)
00460                             pS->beginLayer(1.0 - OB.Transparency, fillBlendmode);
00461                      else
00462 #endif
00463                             pS->setBrushOpacity(1.0 - OB.Transparency);
00464                      pS->translate(OB.Xpos, OB.Ypos);
00465                      pS->rotate(static_cast<double>(OB.Rot));
00466                      if (OB.Pcolor != CommonStrings::None)
00467                      {
00468                             SetFarbe(&tmpfa, OB.Pcolor, OB.Shade);
00469                             pS->setBrush(tmpfa);
00470                             pS->setFillMode(1);
00471                      }
00472                      else
00473                             pS->setFillMode(0);
00474                      if (OB.GrType != 0)
00475                      {
00476                             pS->setFillMode(2);
00477                             pS->fill_gradient.clearStops();
00478                             if ((!OB.GrColor.isEmpty()) && (!OB.GrColor2.isEmpty()))
00479                             {
00480                                    if (OB.GrType == 5)
00481                                    {
00482                                           if ((OB.GrColor != CommonStrings::None) && (!OB.GrColor.isEmpty()))
00483                                                  SetFarbe(&tmpfa, OB.GrColor, OB.GrShade);
00484                                           pS->fill_gradient.addStop(tmpfa, 0.0, 0.5, 1.0);
00485                                           if ((OB.GrColor2 != CommonStrings::None) && (!OB.GrColor2.isEmpty()))
00486                                                  SetFarbe(&tmpfa, OB.GrColor2, OB.GrShade2);
00487                                           pS->fill_gradient.addStop(tmpfa, 1.0, 0.5, 1.0);
00488                                    }
00489                                    else
00490                                    {
00491                                           if ((OB.GrColor2 != CommonStrings::None) && (!OB.GrColor2.isEmpty()))
00492                                                  SetFarbe(&tmpfa, OB.GrColor2, OB.GrShade2);
00493                                           pS->fill_gradient.addStop(tmpfa, 0.0, 0.5, 1.0);
00494                                           if ((OB.GrColor != CommonStrings::None) && (!OB.GrColor.isEmpty()))
00495                                                  SetFarbe(&tmpfa, OB.GrColor, OB.GrShade);
00496                                           pS->fill_gradient.addStop(tmpfa, 1.0, 0.5, 1.0);
00497                                    }
00498                             }
00499                             else
00500                                    pS->fill_gradient = OB.fill_gradient;
00501                             QWMatrix grm;
00502                             grm.rotate(OB.Rot);
00503                             FPointArray gra;
00504                             switch (OB.GrType)
00505                             {
00506                             case 1:
00507                                    gra.setPoints(2, 0, 0, OB.Width, 0);
00508                                    gra.map(grm);
00509                                    pS->setGradient(VGradient::linear, gra.point(0), gra.point(1));
00510                                    break;
00511                             case 2:
00512                                    gra.setPoints(2, 0, 0, OB.Height, 0);
00513                                    grm.rotate(90);
00514                                    gra.map(grm);
00515                                    pS->setGradient(VGradient::linear, gra.point(0), gra.point(1));
00516                                    break;
00517                             case 3:
00518                                    gra.setPoints(2, 0, 0, OB.Width, OB.Height);
00519                                    gra.map(grm);
00520                                    pS->setGradient(VGradient::linear, gra.point(0), gra.point(1));
00521                                    break;
00522                             case 4:
00523                                    gra.setPoints(2, 0, OB.Height, OB.Width, 0);
00524                                    gra.map(grm);
00525                                    pS->setGradient(VGradient::linear, gra.point(0), gra.point(1));
00526                                    break;
00527                             case 5:
00528                                    if (OB.Width > OB.Height)
00529                                           gv = FPoint(OB.Width, OB.Height / 2.0);
00530                                    else
00531                                           gv = FPoint(OB.Width / 2.0, OB.Height);
00532                                    pS->setGradient(VGradient::radial, FPoint(OB.Width / 2.0,OB.Height / 2.0), gv, FPoint(OB.Width / 2.0,OB.Height / 2.0));
00533                                    break;
00534                             case 6:
00535                                    gra.setPoints(2, OB.GrStartX, OB.GrStartY, OB.GrEndX, OB.GrEndY);
00536                                    gra.map(grm);
00537                                    pS->setGradient(VGradient::linear, gra.point(0), gra.point(1));
00538                                    break;
00539                             }
00540                      }
00541                      if (OB.Pcolor2 != CommonStrings::None)
00542                      {
00543                             SetFarbe(&tmpfa, OB.Pcolor2, OB.Shade2);
00544                             if ((OB.Pwidth == 0) && (OB.PType != 5))
00545                                    pS->setLineWidth(0);
00546                             else
00547                                    pS->setPen(tmpfa, OB.Pwidth, Qt::PenStyle(OB.PLineArt), Qt::PenCapStyle(OB.PLineEnd), Qt::PenJoinStyle(OB.PLineJoin));
00548                      }
00549                      else
00550                             pS->setLineWidth(0);
00551                      bool doStroke;
00552                      int mode;
00553                      doStroke = true;
00554                      switch (OB.PType)
00555                      {
00556                      case PageItem::ImageFrame:
00557                             if ((OB.Pcolor != CommonStrings::None) || (OB.GrType != 0))
00558                             {
00559                                    pS->setupPolygon(&OB.PoLine);
00560                                    pS->drawPolygon();
00561                             }
00562                             if (!OB.Pfile.isEmpty())
00563                             {
00564                                    QFileInfo fi = QFileInfo(OB.Pfile);
00565                                    if (fi.exists())
00566                                    {
00567                                           pS->setupPolygon(&OB.PoLine);
00568                                           pS->setClipPath();
00569                                           pS->save();
00570                                           if (OB.flippedH)
00571                                           {
00572                                                  pS->translate(OB.Width, 0);
00573                                                  pS->scale(-1, 1);
00574                                           }
00575                                           if (OB.flippedV)
00576                                           {
00577                                                  pS->translate(0, OB.Height);
00578                                                  pS->scale(1, -1);
00579                                           }
00580                                           ScImage pixm;
00581                                           CMSettings cms(0, "", 0);
00582                                           pixm.LoadPicture(OB.Pfile, cms, false, false, ScImage::RGBData, 72);
00583                                           pS->scale(OB.LocalScX, OB.LocalScY);
00584                                           pS->translate(static_cast<int>(OB.LocalX), static_cast<int>(OB.LocalY));
00585                                           QImage img(pixm.qImage());
00586                                           pS->drawImage(&img);
00587                                           pS->restore();
00588                                    }
00589                             }
00590                             break;
00591                      case PageItem::TextFrame:
00592 #ifndef NLS_PROTO
00593                             if (Ptexti.count() != 0)
00594                             {
00595                                    pS->save();
00596                                    if (OB.Pcolor != CommonStrings::None)
00597                                    {
00598                                           pS->setupPolygon(&OB.PoLine);
00599                                           pS->drawPolygon();
00600                                    }
00601                                    if (OB.flippedH)
00602                                    {
00603                                           pS->translate(OB.Width, 0);
00604                                           pS->scale(-1, 1);
00605                                    }
00606                                    if (OB.flippedV)
00607                                    {
00608                                           pS->translate(0, OB.Height);
00609                                           pS->scale(1, -1);
00610                                    }
00611                                    if ((OB.Width < 4) || (OB.Height < 4))
00612                                           break;
00613                                    for (uint a = 0; a < Ptexti.count(); a++)
00614                                    {
00615                                           hl = Ptexti.at(a);
00616                                           if (hl->ch == QChar(13))
00617                                                  continue;
00618                                           chstr = hl->ch;
00619                                           chs = hl->fontSize();
00620                                           if (chs < 10)
00621                                                  continue;
00622                                           if (hl->effects() != ScStyle_Default)
00623                                           {
00624                                                  if (hl->effects() & 1)
00625                                                         chs = static_cast<int>(hl->fontSize() * prefsManager->appPrefs.typographicSettings.scalingSuperScript / 100);
00626                                                  if (hl->effects() & 2)
00627                                                         chs = static_cast<int>(hl->fontSize() * prefsManager->appPrefs.typographicSettings.scalingSubScript / 100);
00628                                                  if (hl->effects() & 64)
00629                                                  {
00630                                                         if (chstr.upper() != chstr)
00631                                                         {
00632                                                                chs = static_cast<int>(hl->fontSize() * prefsManager->appPrefs.typographicSettings.valueSmallCaps / 100);
00633                                                                chstr = chstr.upper();
00634                                                         }
00635                                                  }
00636                                           }
00637                                           mode = 0;
00638                                           if (hl->fillColor() != CommonStrings::None)
00639                                           {
00640                                                  SetFarbe(&tmpfa, hl->fillColor(), hl->fillShade());
00641                                                  pS->setBrush(tmpfa);
00642                                                  mode = 2;
00643                                           }
00644                                           if (hl->strokeColor() != CommonStrings::None)
00645                                           {
00646                                                  SetFarbe(&tmpfa, hl->strokeColor(), hl->strokeShade());
00647                                                  pS->setPen(tmpfa, 1, Qt::SolidLine, Qt::FlatCap, Qt::MiterJoin);
00648                                                  mode += 1;
00649                                           }
00650                                           DrawZeichenS(pS, hl->glyph.xoffset, hl->glyph.yoffset, chstr, hl->font().scName(), OB.Reverse, hl->effects(), mode, chs);
00651                                    }
00652                                    pS->restore();
00653                             }
00654                             break;
00655 #endif
00656                      case PageItem::Line:
00657                             if (OB.NamedLStyle.isEmpty())
00658                                    pS->drawLine(FPoint(0, 0), FPoint(OB.Width, 0));
00659                             else
00660                             {
00661                                    multiLine ml = MLineStyles[OB.NamedLStyle];
00662                                    for (int it = ml.size()-1; it > -1; it--)
00663                                    {
00664                                           SetFarbe(&tmpfa, ml[it].Color, ml[it].Shade);
00665                                           pS->setPen(tmpfa,
00666                                                      QMAX(static_cast<int>(ml[it].Width), 1),
00667                                                      static_cast<Qt::PenStyle>(ml[it].Dash),
00668                                                      static_cast<Qt::PenCapStyle>(ml[it].LineEnd),
00669                                                      static_cast<Qt::PenJoinStyle>(ml[it].LineJoin));
00670                                           pS->drawLine(FPoint(0, 0), FPoint(OB.Width, 0));
00671                                    }
00672                             }
00673                             if (OB.startArrowIndex != 0)
00674                             {
00675                                    QWMatrix arrowTrans;
00676                                    FPointArray arrow = (*arrowStyles.at(OB.startArrowIndex-1)).points.copy();
00677                                    arrowTrans.translate(0, 0);
00678                                    arrowTrans.scale(OB.Pwidth, OB.Pwidth);
00679                                    arrowTrans.scale(-1,1);
00680                                    arrow.map(arrowTrans);
00681                                    pS->setBrush(pS->pen());
00682                                    pS->setLineWidth(0);
00683                                    pS->setFillMode(ScPainter::Solid);
00684                                    pS->setupPolygon(&arrow);
00685                                    pS->drawPolygon();
00686                             }
00687                             if (OB.endArrowIndex != 0)
00688                             {
00689                                    QWMatrix arrowTrans;
00690                                    FPointArray arrow = (*arrowStyles.at(OB.endArrowIndex-1)).points.copy();
00691                                    arrowTrans.translate(OB.Width, 0);
00692                                    arrowTrans.scale(OB.Pwidth, OB.Pwidth);
00693                                    arrow.map(arrowTrans);
00694                                    pS->setBrush(pS->pen());
00695                                    pS->setLineWidth(0);
00696                                    pS->setFillMode(ScPainter::Solid);
00697                                    pS->setupPolygon(&arrow);
00698                                    pS->drawPolygon();
00699                             }
00700                             doStroke = false;
00701                             break;
00702                      /* OBSOLETE Craig R 2005-02-06
00703                      case 1:
00704                      case 3:
00705                      */
00706                      case PageItem::ItemType1:
00707                      case PageItem::ItemType3:
00708                      case PageItem::Polygon:
00709                             pS->setupPolygon(&OB.PoLine);
00710                             pS->drawPolygon();
00711                             break;
00712                      case PageItem::PolyLine:
00713                             if ((OB.Pcolor != CommonStrings::None) || (OB.GrType != 0))
00714                             {
00715                                    FPointArray cli;
00716                                    FPoint Start;
00717                                    bool firstp = true;
00718                                    for (uint n = 0; n < OB.PoLine.size()-3; n += 4)
00719                                    {
00720                                           if (firstp)
00721                                           {
00722                                                  Start = OB.PoLine.point(n);
00723                                                  firstp = false;
00724                                           }
00725                                           if (OB.PoLine.point(n).x() > 900000)
00726                                           {
00727                                                  cli.addPoint(OB.PoLine.point(n-2));
00728                                                  cli.addPoint(OB.PoLine.point(n-2));
00729                                                  cli.addPoint(Start);
00730                                                  cli.addPoint(Start);
00731                                                  cli.setMarker();
00732                                                  firstp = true;
00733                                                  continue;
00734                                           }
00735                                           cli.addPoint(OB.PoLine.point(n));
00736                                           cli.addPoint(OB.PoLine.point(n+1));
00737                                           cli.addPoint(OB.PoLine.point(n+2));
00738                                           cli.addPoint(OB.PoLine.point(n+3));
00739                                    }
00740                                    if (cli.size() > 2)
00741                                    {
00742                                           FPoint l1 = cli.point(cli.size()-2);
00743                                           cli.addPoint(l1);
00744                                           cli.addPoint(l1);
00745                                           cli.addPoint(Start);
00746                                           cli.addPoint(Start);
00747                                    }
00748                                    pS->setupPolygon(&cli);
00749                                    pS->fillPath();
00750                             }
00751                             pS->setupPolygon(&OB.PoLine, false);
00752                             if (OB.NamedLStyle.isEmpty())
00753                                    pS->strokePath();
00754                             else
00755                             {
00756                                    multiLine ml = MLineStyles[OB.NamedLStyle];
00757                                    for (int it = ml.size()-1; it > -1; it--)
00758                                    {
00759                                           SetFarbe(&tmpfa, ml[it].Color, ml[it].Shade);
00760                                           pS->setPen(tmpfa, ml[it].Width,
00761                                                      static_cast<Qt::PenStyle>(ml[it].Dash),
00762                                                      static_cast<Qt::PenCapStyle>(ml[it].LineEnd),
00763                                                      static_cast<Qt::PenJoinStyle>(ml[it].LineJoin));
00764                                           pS->drawPolyLine();
00765                                    }
00766                             }
00767                             if (OB.startArrowIndex != 0)
00768                             {
00769                                    FPoint Start = OB.PoLine.point(0);
00770                                    for (uint xx = 1; xx < OB.PoLine.size(); xx += 2)
00771                                    {
00772                                           FPoint Vector = OB.PoLine.point(xx);
00773                                           if ((Start.x() != Vector.x()) || (Start.y() != Vector.y()))
00774                                           {
00775                                                  double r = atan2(Start.y()-Vector.y(),Start.x()-Vector.x())*(180.0/M_PI);
00776                                                  QWMatrix arrowTrans;
00777                                                  FPointArray arrow = (*arrowStyles.at(OB.startArrowIndex-1)).points.copy();
00778                                                  arrowTrans.translate(Start.x(), Start.y());
00779                                                  arrowTrans.rotate(r);
00780                                                  arrowTrans.scale(OB.Pwidth, OB.Pwidth);
00781                                                  arrow.map(arrowTrans);
00782                                                  pS->setBrush(pS->pen());
00783                                                  pS->setLineWidth(0);
00784                                                  pS->setFillMode(ScPainter::Solid);
00785                                                  pS->setupPolygon(&arrow);
00786                                                  pS->drawPolygon();
00787                                                  break;
00788                                           }
00789                                    }
00790                             }
00791                             if (OB.endArrowIndex != 0)
00792                             {
00793                                    FPoint End = OB.PoLine.point(OB.PoLine.size()-2);
00794                                    for (uint xx = OB.PoLine.size()-1; xx > 0; xx -= 2)
00795                                    {
00796                                           FPoint Vector = OB.PoLine.point(xx);
00797                                           if ((End.x() != Vector.x()) || (End.y() != Vector.y()))
00798                                           {
00799                                                  double r = atan2(End.y()-Vector.y(),End.x()-Vector.x())*(180.0/M_PI);
00800                                                  QWMatrix arrowTrans;
00801                                                  FPointArray arrow = (*arrowStyles.at(OB.endArrowIndex-1)).points.copy();
00802                                                  arrowTrans.translate(End.x(), End.y());
00803                                                  arrowTrans.rotate(r);
00804                                                  arrowTrans.scale(OB.Pwidth, OB.Pwidth);
00805                                                  arrow.map(arrowTrans);
00806                                                  pS->setBrush(pS->pen());
00807                                                  pS->setLineWidth(0);
00808                                                  pS->setFillMode(ScPainter::Solid);
00809                                                  pS->setupPolygon(&arrow);
00810                                                  pS->drawPolygon();
00811                                                  break;
00812                                           }
00813                                    }
00814                             }
00815                             doStroke = false;
00816                             break;
00817                      case PageItem::PathText:
00818 #ifndef NLS_PROTO
00819                             if (!OB.PoShow)
00820                                    doStroke = false;
00821                             cl = FlattenPath(OB.PoLine, Segments);
00822                             CurX = OB.Extra;
00823                             if (Ptexti.count() != 0)
00824                                    CurX += Ptexti.at(0)->fontSize() * Ptexti.at(0)->tracking() / 10000.0;
00825                             zae = 0;
00826                             wid = sqrt(pow(cl.point(zae+1).x()-cl.point(zae).x(),2.0)+pow(cl.point(zae+1).y()-cl.point(zae).y(),2.0));
00827                             while (wid < 1)
00828                             {
00829                                    zae++;
00830                                    if (zae == cl.size()-1)
00831                                           goto PfadEnd;
00832                                    wid = sqrt(pow(cl.point(zae+1).x()-cl.point(zae).x(),2.0)+pow(cl.point(zae+1).y()-cl.point(zae).y(),2.0));
00833                             }
00834                             rota = xy2Deg(cl.point(zae+1).x()-cl.point(zae).x(),cl.point(zae+1).y()-cl.point(zae).y());
00835                             for (a = 0; a < Ptexti.count(); a++)
00836                             {
00837                                    CurY = 0;
00838                                    hl = Ptexti.at(a);
00839                                    chstr = hl->ch;
00840                                    if ((chstr == QChar(30)) || (chstr == QChar(13)))
00841                                           continue;
00842                                    if (hl->fillColor() != CommonStrings::None)
00843                                    {
00844                                           SetFarbe(&tmpfa, hl->fillColor(), hl->fillShade());
00845                                           pS->setPen(tmpfa);
00846                                    }
00847                                    chs = hl->fontSize();
00848                                    asce = hl->font().ascent(hl->fontSize() / 10.0);
00849                                    int chst = hl->effects() & 127;
00850                                    if (chst != 0)
00851                                    {
00852                                           if (chst & 1)
00853                                           {
00854                                                  CurY -= asce * prefsManager->appPrefs.typographicSettings.valueSuperScript / 100;
00855                                                  chs = static_cast<int>(hl->fontSize() * prefsManager->appPrefs.typographicSettings.scalingSuperScript / 100);
00856                                           }
00857                                           if (chst & 2)
00858                                           {
00859                                                  CurY += asce * prefsManager->appPrefs.typographicSettings.valueSubScript / 100;
00860                                                  chs = static_cast<int>(hl->fontSize() * prefsManager->appPrefs.typographicSettings.scalingSubScript / 100);
00861                                           }
00862                                           if (chst & 64)
00863                                           {
00864                                                  if (chstr.upper() != chstr)
00865                                                  {
00866                                                         chs = static_cast<int>(hl->fontSize() * prefsManager->appPrefs.typographicSettings.valueSmallCaps / 100);
00867                                                         chstr = chstr.upper();
00868                                                  }
00869                                           }
00870                                    }
00871                                    wide = hl->font().charWidth(chstr[0], chs / 10.0);
00872                                    if ((CurX+(wide+chs * hl->tracking() / 10000.0)/2) >= wid)
00873                                    {
00874                                           if (zae < cl.size()-1)
00875                                           {
00876                                                  CurX = CurX - wid;
00877                                                  wid = 0;
00878                                                  EndX = CurX;
00879                                                  do
00880                                                  {
00881                                                         do
00882                                                         {
00883                                                                zae++;
00884                                                                if (zae == cl.size()-1)
00885                                                                       goto PfadEnd;
00886                                                                wid = sqrt(pow(cl.point(zae+1).x()-cl.point(zae).x(),2.0)+pow(cl.point(zae+1).y()-cl.point(zae).y(),2.0));
00887                                                                rota = xy2Deg(cl.point(zae+1).x()-cl.point(zae).x(),cl.point(zae+1).y()-cl.point(zae).y());
00888                                                         }
00889                                                         while (wid == 0);
00890                                                         EndX -= wid;
00891                                                  }
00892                                                  while (wid < EndX);
00893                                                  CurX = EndX + wid;
00894                                           }
00895                                           else
00896                                                  goto PfadEnd;
00897                                    }
00898                                    pS->save();
00899                                    pS->translate(cl.point(zae).x(), cl.point(zae).y());
00900                                    pS->rotate(rota);
00901                                    DrawZeichenS(pS, CurX+chs * hl->tracking() / 10000.0, CurY+OB.BaseOffs, chstr, hl->font().scName(), OB.Reverse, hl->effects(), 2, chs);
00902                                    pS->restore();
00903                                    CurX += wide+chs * hl->tracking() / 10000.0;
00904                             }
00905 #endif
00906                      PfadEnd:      break;
00907                      case PageItem::Multiple:
00908                             Q_ASSERT(false);
00909                             break;
00910                      }
00911 #ifdef HAVE_CAIRO
00912                      if (fillBlendmode != 0)
00913                             pS->endLayer();
00914 #endif
00915                      if (doStroke)
00916                      {
00917 #ifdef HAVE_CAIRO
00918                             if (strokeBlendmode != 0)
00919                                    pS->beginLayer(1.0 - OB.TranspStroke, strokeBlendmode);
00920                             else
00921 #endif
00922                                    pS->setPenOpacity(1.0 - OB.TranspStroke);
00923                             if (OB.Pcolor2 != CommonStrings::None)
00924                             {
00925                                    SetFarbe(&tmpfa, OB.Pcolor2, OB.Shade2);
00926                                    pS->setPen(tmpfa, OB.Pwidth, Qt::PenStyle(OB.PLineArt), Qt::PenCapStyle(OB.PLineEnd), Qt::PenJoinStyle(OB.PLineJoin));
00927                                    //                                 if (DashValues.count() != 0)
00928                                    //                                        pS->setDash(DashValues, DashOffset);
00929                             }
00930                             else
00931                                    pS->setLineWidth(0);
00932                             pS->setupPolygon(&OB.PoLine);
00933                             if (OB.NamedLStyle.isEmpty())
00934                                    pS->drawPolyLine();
00935                             else
00936                             {
00937                                    multiLine ml = MLineStyles[OB.NamedLStyle];
00938                                    for (int it = ml.size()-1; it > -1; it--)
00939                                    {
00940                                           SetFarbe(&tmpfa, ml[it].Color, ml[it].Shade);
00941                                           pS->setPen(tmpfa, ml[it].Width,
00942                                                      static_cast<Qt::PenStyle>(ml[it].Dash),
00943                                                      static_cast<Qt::PenCapStyle>(ml[it].LineEnd),
00944                                                      static_cast<Qt::PenJoinStyle>(ml[it].LineJoin));
00945                                           pS->drawPolyLine();
00946                                    }
00947                             }
00948 #ifdef HAVE_CAIRO
00949                             if (strokeBlendmode != 0)
00950                                    pS->endLayer();
00951 #endif
00952                      }
00953                      pS->restore();
00954                      if (groupStack.count() != 0)
00955                      {
00956                             while (currItem == groupStack.top())
00957                             {
00958 #ifdef HAVE_CAIRO
00959                                    pS->endLayer();
00960 #endif
00961                                    pS->restore();
00962                                    groupStack.pop();
00963                             }
00964                      }
00965                      QDir::setCurrent(CurDirP);
00966               }
00967               DOC=DOC.nextSibling();
00968        }
00969 #ifdef HAVE_CAIRO
00970        pS->endLayer();
00971 #endif
00972        pS->end();
00973 #ifdef HAVE_CAIRO
00974        QImage tmpi = tmp.smoothScale(static_cast<int>(tmp.width()*pmmax), static_cast<int>(tmp.height()*pmmax));
00975 #else
00976        QImage tmpi1 = tmp.convertToImage();
00977        QImage tmpi = tmpi1.smoothScale(static_cast<int>(tmp.width()*pmmax), static_cast<int>(tmp.height()*pmmax));
00978 #endif
00979        QPixmap ret;
00980        ret.convertFromImage(tmpi);
00981        delete pS;
00982 //     FT_Done_FreeType( library );
00983        return ret;
00984 }
00985 
00986 void ScPreview::SetFarbe(QColor *tmp, const QString& farbe, int shad)
00987 {
00988        *tmp = ScColorEngine::getShadeColorProof(Farben[farbe], NULL, shad);
00989 }
00990 
00991 void ScPreview::DrawZeichenS(ScPainter *p, double xco, double yco, QString ch, QString ZFo, bool Reverse, int Style, int mod, int Siz)
00992 {
00993        if (mod == 0)
00994               return;
00995        QString ccx = ch;
00996        if (ccx == QChar(29))
00997               ccx = " ";
00998        double wide;
00999        double csi = static_cast<double>(Siz) / 100.0;
01000 //     uint chr = ccx[0].unicode();
01001        if (prefsManager->appPrefs.AvailFonts[ZFo].canRender(ccx[0]))
01002        {
01003               wide = prefsManager->appPrefs.AvailFonts[ZFo].charWidth(ccx[0])*(Siz / 10.0);
01004               QWMatrix chma;
01005               chma.scale(csi, csi);
01006               uint gl = prefsManager->appPrefs.AvailFonts[ZFo].char2CMap(ccx[0]);
01007               FPointArray gly = prefsManager->appPrefs.AvailFonts[ZFo].glyphOutline(gl);
01008               if (gly.size() < 4)
01009                      return;
01010               gly.map(chma);
01011               chma = QWMatrix();
01012               p->setFillMode(1);
01013               if (Reverse)
01014               {
01015                      chma.scale(-1, 1);
01016                      chma.translate(-wide, 0);
01017                      gly.map(chma);
01018                      chma = QWMatrix();
01019                      chma.translate(xco, yco-(Siz / 10.0));
01020               }
01021               else
01022                      chma.translate(xco, yco-(Siz / 10.0));
01023               gly.map(chma);
01024               p->setupPolygon(&gly);
01025               p->setFillMode(1);
01026               if (mod > 1)
01027                      p->fillPath();
01028               if ((Style & 4) && ((mod % 2) != 0))
01029               {
01030                      p->setLineWidth(prefsManager->appPrefs.AvailFonts[ZFo].strokeWidth() * Siz / 20);
01031                      p->strokePath();
01032               }
01033               if (Style & 16)
01034               {
01035                      double st = prefsManager->appPrefs.AvailFonts[ZFo].strikeoutPos() * (Siz / 10.0);
01036                      p->setLineWidth(QMAX(prefsManager->appPrefs.AvailFonts[ZFo].strokeWidth() * (Siz / 10.0), 1));
01037                      p->drawLine(FPoint(xco, yco-st), FPoint(xco+wide, yco-st));
01038               }
01039               if (Style & 8)
01040               {
01041                      double st = prefsManager->appPrefs.AvailFonts[ZFo].underlinePos() * (Siz / 10.0);
01042                      p->setLineWidth(QMAX(prefsManager->appPrefs.AvailFonts[ZFo].strokeWidth() * (Siz / 10.0), 1));
01043                      p->drawLine(FPoint(xco, yco-st), FPoint(xco+wide, yco-st));
01044               }
01045        }
01046        else
01047        {
01048               p->setLineWidth(1);
01049               p->setPen(Qt::black);
01050               p->setFillMode(0);
01051               p->drawRect(xco, yco-Siz, (Siz / 10.0), (Siz / 10.0));
01052        }
01053 }