LCOV - code coverage report
Current view: top level - writerperfect/source/filter - OdgGenerator.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 1029 0.0 %
Date: 2012-08-25 Functions: 0 36 0.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 5698 0.0 %

           Branch data     Line data    Source code
       1                 :            : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
       2                 :            : /*
       3                 :            :  * This Source Code Form is subject to the terms of the Mozilla Public
       4                 :            :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       5                 :            :  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
       6                 :            :  *
       7                 :            :  * For further information visit http://libwpg.sourceforge.net
       8                 :            :  */
       9                 :            : 
      10                 :            : #include "FilterInternal.hxx"
      11                 :            : 
      12                 :            : #include "OdgGenerator.hxx"
      13                 :            : #include "DocumentElement.hxx"
      14                 :            : #include "OdfDocumentHandler.hxx"
      15                 :            : #include "TextRunStyle.hxx"
      16                 :            : #include "FontStyle.hxx"
      17                 :            : #include <locale.h>
      18                 :            : #include <math.h>
      19                 :            : #include <string>
      20                 :            : #include <map>
      21                 :            : 
      22                 :            : #ifndef M_PI
      23                 :            : #define M_PI 3.14159265358979323846
      24                 :            : #endif
      25                 :            : 
      26                 :            : // Workaround for the incapacity of draw to have multiple page
      27                 :            : // sizes in the same document. Once that limitation is lifted,
      28                 :            : // remove this
      29                 :            : #define MULTIPAGE_WORKAROUND 1
      30                 :            : 
      31                 :            : namespace
      32                 :            : {
      33                 :            : 
      34                 :          0 : static inline double getAngle(double bx, double by)
      35                 :            : {
      36         [ #  # ]:          0 :     return fmod(2*M_PI + (by > 0.0 ? 1.0 : -1.0) * acos( bx / sqrt(bx * bx + by * by) ), 2*M_PI);
      37                 :            : }
      38                 :            : 
      39                 :          0 : static void getEllipticalArcBBox(double x0, double y0,
      40                 :            :                                  double rx, double ry, double phi, bool largeArc, bool sweep, double x, double y,
      41                 :            :                                  double &xmin, double &ymin, double &xmax, double &ymax)
      42                 :            : {
      43                 :          0 :     phi *= M_PI/180;
      44         [ #  # ]:          0 :     if (rx < 0.0)
      45                 :          0 :         rx *= -1.0;
      46         [ #  # ]:          0 :     if (ry < 0.0)
      47                 :          0 :         ry *= -1.0;
      48                 :            : 
      49 [ #  # ][ #  # ]:          0 :     if (rx == 0.0 || ry == 0.0)
      50                 :            :     {
      51         [ #  # ]:          0 :         xmin = (x0 < x ? x0 : x);
      52         [ #  # ]:          0 :         xmax = (x0 > x ? x0 : x);
      53         [ #  # ]:          0 :         ymin = (y0 < y ? y0 : y);
      54         [ #  # ]:          0 :         ymax = (y0 > y ? y0 : y);
      55                 :            :         return;
      56                 :            :     }
      57                 :            : 
      58                 :            :     // F.6.5.1
      59                 :          0 :     const double x1prime = cos(phi)*(x0 - x)/2 + sin(phi)*(y0 - y)/2;
      60                 :          0 :     const double y1prime = -sin(phi)*(x0 - x)/2 + cos(phi)*(y0 - y)/2;
      61                 :            : 
      62                 :            :     // F.6.5.2
      63                 :          0 :     double radicant = (rx*rx*ry*ry - rx*rx*y1prime*y1prime - ry*ry*x1prime*x1prime)/(rx*rx*y1prime*y1prime + ry*ry*x1prime*x1prime);
      64                 :          0 :     double cxprime = 0.0;
      65                 :          0 :     double cyprime = 0.0;
      66         [ #  # ]:          0 :     if (radicant < 0.0)
      67                 :            :     {
      68                 :          0 :         double ratio = rx/ry;
      69                 :          0 :         radicant = y1prime*y1prime + x1prime*x1prime/(ratio*ratio);
      70         [ #  # ]:          0 :         if (radicant < 0.0)
      71                 :            :         {
      72         [ #  # ]:          0 :             xmin = (x0 < x ? x0 : x);
      73         [ #  # ]:          0 :             xmax = (x0 > x ? x0 : x);
      74         [ #  # ]:          0 :             ymin = (y0 < y ? y0 : y);
      75         [ #  # ]:          0 :             ymax = (y0 > y ? y0 : y);
      76                 :            :             return;
      77                 :            :         }
      78                 :          0 :         ry=sqrt(radicant);
      79                 :          0 :         rx=ratio*ry;
      80                 :            :     }
      81                 :            :     else
      82                 :            :     {
      83         [ #  # ]:          0 :         double factor = (largeArc==sweep ? -1.0 : 1.0)*sqrt(radicant);
      84                 :            : 
      85                 :          0 :         cxprime = factor*rx*y1prime/ry;
      86                 :          0 :         cyprime = -factor*ry*x1prime/rx;
      87                 :            :     }
      88                 :            : 
      89                 :            :     // F.6.5.3
      90                 :          0 :     double cx = cxprime*cos(phi) - cyprime*sin(phi) + (x0 + x)/2;
      91                 :          0 :     double cy = cxprime*sin(phi) + cyprime*cos(phi) + (y0 + y)/2;
      92                 :            : 
      93                 :            :     // now compute bounding box of the whole ellipse
      94                 :            : 
      95                 :            :     // Parametric equation of an ellipse:
      96                 :            :     // x(theta) = cx + rx*cos(theta)*cos(phi) - ry*sin(theta)*sin(phi)
      97                 :            :     // y(theta) = cy + rx*cos(theta)*sin(phi) + ry*sin(theta)*cos(phi)
      98                 :            : 
      99                 :            :     // Compute local extrems
     100                 :            :     // 0 = -rx*sin(theta)*cos(phi) - ry*cos(theta)*sin(phi)
     101                 :            :     // 0 = -rx*sin(theta)*sin(phi) - ry*cos(theta)*cos(phi)
     102                 :            : 
     103                 :            :     // Local extrems for X:
     104                 :            :     // theta = -atan(ry*tan(phi)/rx)
     105                 :            :     // and
     106                 :            :     // theta = M_PI -atan(ry*tan(phi)/rx)
     107                 :            : 
     108                 :            :     // Local extrems for Y:
     109                 :            :     // theta = atan(ry/(tan(phi)*rx))
     110                 :            :     // and
     111                 :            :     // theta = M_PI + atan(ry/(tan(phi)*rx))
     112                 :            : 
     113                 :            :     double txmin, txmax, tymin, tymax;
     114                 :            : 
     115                 :            :     // First handle special cases
     116 [ #  # ][ #  # ]:          0 :     if (phi == 0 || phi == M_PI)
     117                 :            :     {
     118                 :          0 :         xmin = cx - rx;
     119                 :          0 :         txmin = getAngle(-rx, 0);
     120                 :          0 :         xmax = cx + rx;
     121                 :          0 :         txmax = getAngle(rx, 0);
     122                 :          0 :         ymin = cy - ry;
     123                 :          0 :         tymin = getAngle(0, -ry);
     124                 :          0 :         ymax = cy + ry;
     125                 :          0 :         tymax = getAngle(0, ry);
     126                 :            :     }
     127 [ #  # ][ #  # ]:          0 :     else if (phi == M_PI / 2.0 || phi == 3.0*M_PI/2.0)
     128                 :            :     {
     129                 :          0 :         xmin = cx - ry;
     130                 :          0 :         txmin = getAngle(-ry, 0);
     131                 :          0 :         xmax = cx + ry;
     132                 :          0 :         txmax = getAngle(ry, 0);
     133                 :          0 :         ymin = cy - rx;
     134                 :          0 :         tymin = getAngle(0, -rx);
     135                 :          0 :         ymax = cy + rx;
     136                 :          0 :         tymax = getAngle(0, rx);
     137                 :            :     }
     138                 :            :     else
     139                 :            :     {
     140                 :          0 :         txmin = -atan(ry*tan(phi)/rx);
     141                 :          0 :         txmax = M_PI - atan (ry*tan(phi)/rx);
     142                 :          0 :         xmin = cx + rx*cos(txmin)*cos(phi) - ry*sin(txmin)*sin(phi);
     143                 :          0 :         xmax = cx + rx*cos(txmax)*cos(phi) - ry*sin(txmax)*sin(phi);
     144                 :          0 :         double tmpY = cy + rx*cos(txmin)*sin(phi) + ry*sin(txmin)*cos(phi);
     145                 :          0 :         txmin = getAngle(xmin - cx, tmpY - cy);
     146                 :          0 :         tmpY = cy + rx*cos(txmax)*sin(phi) + ry*sin(txmax)*cos(phi);
     147                 :          0 :         txmax = getAngle(xmax - cx, tmpY - cy);
     148                 :            : 
     149                 :          0 :         tymin = atan(ry/(tan(phi)*rx));
     150                 :          0 :         tymax = atan(ry/(tan(phi)*rx))+M_PI;
     151                 :          0 :         ymin = cy + rx*cos(tymin)*sin(phi) + ry*sin(tymin)*cos(phi);
     152                 :          0 :         ymax = cy + rx*cos(tymax)*sin(phi) + ry*sin(tymax)*cos(phi);
     153                 :          0 :         double tmpX = cx + rx*cos(tymin)*cos(phi) - ry*sin(tymin)*sin(phi);
     154                 :          0 :         tymin = getAngle(tmpX - cx, ymin - cy);
     155                 :          0 :         tmpX = cx + rx*cos(tymax)*cos(phi) - ry*sin(tymax)*sin(phi);
     156                 :          0 :         tymax = getAngle(tmpX - cx, ymax - cy);
     157                 :            :     }
     158         [ #  # ]:          0 :     if (xmin > xmax)
     159                 :            :     {
     160                 :          0 :         std::swap(xmin,xmax);
     161                 :          0 :         std::swap(txmin,txmax);
     162                 :            :     }
     163         [ #  # ]:          0 :     if (ymin > ymax)
     164                 :            :     {
     165                 :          0 :         std::swap(ymin,ymax);
     166                 :          0 :         std::swap(tymin,tymax);
     167                 :            :     }
     168                 :          0 :     double angle1 = getAngle(x0 - cx, y0 - cy);
     169                 :          0 :     double angle2 = getAngle(x - cx, y - cy);
     170                 :            : 
     171                 :            :     // for sweep == 0 it is normal to have delta theta < 0
     172                 :            :     // but we don't care about the rotation direction for bounding box
     173         [ #  # ]:          0 :     if (!sweep)
     174                 :          0 :         std::swap(angle1, angle2);
     175                 :            : 
     176                 :            :     // We cannot check directly for whether an angle is included in
     177                 :            :     // an interval of angles that cross the 360/0 degree boundary
     178                 :            :     // So here we will have to check for their absence in the complementary
     179                 :            :     // angle interval
     180                 :          0 :     bool otherArc = false;
     181         [ #  # ]:          0 :     if (angle1 > angle2)
     182                 :            :     {
     183                 :          0 :         std::swap(angle1, angle2);
     184                 :          0 :         otherArc = true;
     185                 :            :     }
     186                 :            : 
     187                 :            :     // Check txmin
     188 [ #  # ][ #  # ]:          0 :     if ((!otherArc && (angle1 > txmin || angle2 < txmin)) || (otherArc && !(angle1 > txmin || angle2 < txmin)))
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     189         [ #  # ]:          0 :         xmin = x0 < x ? x0 : x;
     190                 :            :     // Check txmax
     191 [ #  # ][ #  # ]:          0 :     if ((!otherArc && (angle1 > txmax || angle2 < txmax)) || (otherArc && !(angle1 > txmax || angle2 < txmax)))
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     192         [ #  # ]:          0 :         xmax = x0 > x ? x0 : x;
     193                 :            :     // Check tymin
     194 [ #  # ][ #  # ]:          0 :     if ((!otherArc && (angle1 > tymin || angle2 < tymin)) || (otherArc && !(angle1 > tymin || angle2 < tymin)))
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     195         [ #  # ]:          0 :         ymin = y0 < y ? y0 : y;
     196                 :            :     // Check tymax
     197 [ #  # ][ #  # ]:          0 :     if ((!otherArc && (angle1 > tymax || angle2 < tymax)) || (otherArc && !(angle1 > tymax || angle2 < tymax)))
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     198         [ #  # ]:          0 :         ymax = y0 > y ? y0 : y;
     199                 :            : }
     200                 :            : 
     201                 :          0 : static inline double quadraticExtreme(double t, double a, double b, double c)
     202                 :            : {
     203                 :          0 :     return (1.0-t)*(1.0-t)*a + 2.0*(1.0-t)*t*b + t*t*c;
     204                 :            : }
     205                 :            : 
     206                 :          0 : static inline double quadraticDerivative(double a, double b, double c)
     207                 :            : {
     208                 :          0 :     double denominator = a - 2.0*b + c;
     209         [ #  # ]:          0 :     if (fabs(denominator) != 0.0)
     210                 :          0 :         return (a - b)/denominator;
     211                 :          0 :     return -1.0;
     212                 :            : }
     213                 :            : 
     214                 :          0 : static void getQuadraticBezierBBox(double x0, double y0, double x1, double y1, double x, double y,
     215                 :            :                                    double &xmin, double &ymin, double &xmax, double &ymax)
     216                 :            : {
     217         [ #  # ]:          0 :     xmin = x0 < x ? x0 : x;
     218         [ #  # ]:          0 :     xmax = x0 > x ? x0 : x;
     219         [ #  # ]:          0 :     ymin = y0 < y ? y0 : y;
     220         [ #  # ]:          0 :     ymax = y0 > y ? y0 : y;
     221                 :            : 
     222                 :          0 :     double t = quadraticDerivative(x0, x1, x);
     223 [ #  # ][ #  # ]:          0 :     if(t>=0 && t<=1)
     224                 :            :     {
     225                 :          0 :         double tmpx = quadraticExtreme(t, x0, x1, x);
     226         [ #  # ]:          0 :         xmin = tmpx < xmin ? tmpx : xmin;
     227         [ #  # ]:          0 :         xmax = tmpx > xmax ? tmpx : xmax;
     228                 :            :     }
     229                 :            : 
     230                 :          0 :     t = quadraticDerivative(y0, y1, y);
     231 [ #  # ][ #  # ]:          0 :     if(t>=0 && t<=1)
     232                 :            :     {
     233                 :          0 :         double tmpy = quadraticExtreme(t, y0, y1, y);
     234         [ #  # ]:          0 :         ymin = tmpy < ymin ? tmpy : ymin;
     235         [ #  # ]:          0 :         ymax = tmpy > ymax ? tmpy : ymax;
     236                 :            :     }
     237                 :          0 : }
     238                 :            : 
     239                 :          0 : static inline double cubicBase(double t, double a, double b, double c, double d)
     240                 :            : {
     241                 :          0 :     return (1.0-t)*(1.0-t)*(1.0-t)*a + 3.0*(1.0-t)*(1.0-t)*t*b + 3.0*(1.0-t)*t*t*c + t*t*t*d;
     242                 :            : }
     243                 :            : 
     244                 :            : #if 0
     245                 :            : static std::vector<double> cubicExtremes(double a, double b, double c, double d)
     246                 :            : {
     247                 :            :     std::vector<double> vec;
     248                 :            :     double u = -a + 2*b - c;
     249                 :            :     double v = sqrt((-a*(c-d) + b*b - b*(c+d) + c*c));
     250                 :            :     double w = -a + 3.0*b - 3.0*c + d;
     251                 :            :     if (w != 0.0)
     252                 :            :     {
     253                 :            :         vec.push_back((u-v)/w);
     254                 :            :         vec.push_back((u+v)/w);
     255                 :            :     }
     256                 :            :     return vec;
     257                 :            : }
     258                 :            : #endif
     259                 :            : 
     260                 :          0 : static void getCubicBezierBBox(double x0, double y0, double x1, double y1, double x2, double y2, double x, double y,
     261                 :            :                                double &xmin, double &ymin, double &xmax, double &ymax)
     262                 :            : {
     263         [ #  # ]:          0 :     xmin = x0 < x ? x0 : x;
     264         [ #  # ]:          0 :     xmax = x0 > x ? x0 : x;
     265         [ #  # ]:          0 :     ymin = y0 < y ? y0 : y;
     266         [ #  # ]:          0 :     ymax = y0 > y ? y0 : y;
     267                 :            : 
     268                 :            : #if 0
     269                 :            :     std::vector<double> extremes = cubicExtremes(x0, x1, x2, x);
     270                 :            :     for(std::vector<double>::iterator iterX = extremes.begin(); iterX != extremes.end(); ++iterX)
     271                 :            :     {
     272                 :            :         if(*iterX >= 0 && *iterX <= 1)
     273                 :            :         {
     274                 :            :             double tmpx = cubicBase(*iterX, x0, x1, x2, x);
     275                 :            :             xmin = tmpx < xmin ? tmpx : xmin;
     276                 :            :             xmax = tmpx > xmax ? tmpx : xmax;
     277                 :            :         }
     278                 :            :     }
     279                 :            : 
     280                 :            :     extremes = cubicExtremes(y0, y1, y2, y);
     281                 :            :     for(std::vector<double>::iterator iterY = extremes.begin(); iterY != extremes.end(); ++iterY)
     282                 :            :     {
     283                 :            :         if(*iterY>=0.0 && *iterY<=1.0)
     284                 :            :         {
     285                 :            :             double tmpy = cubicBase(*iterY, y0, y1, y2, y);
     286                 :            :             ymin = tmpy < ymin ? tmpy : ymin;
     287                 :            :             ymax = tmpy > ymax ? tmpy : ymax;
     288                 :            :         }
     289                 :            :     }
     290                 :            : #else
     291         [ #  # ]:          0 :     for (double t = 0.0; t <= 1.0; t+=0.01)
     292                 :            :     {
     293                 :          0 :         double tmpx = cubicBase(t, x0, x1, x2, x);
     294         [ #  # ]:          0 :         xmin = tmpx < xmin ? tmpx : xmin;
     295         [ #  # ]:          0 :         xmax = tmpx > xmax ? tmpx : xmax;
     296                 :          0 :         double tmpy = cubicBase(t, y0, y1, y2, y);
     297         [ #  # ]:          0 :         ymin = tmpy < ymin ? tmpy : ymin;
     298         [ #  # ]:          0 :         ymax = tmpy > ymax ? tmpy : ymax;
     299                 :            :     }
     300                 :            : #endif
     301                 :          0 : }
     302                 :            : 
     303                 :            : 
     304                 :          0 : static WPXString doubleToString(const double value)
     305                 :            : {
     306         [ #  # ]:          0 :     WPXString tempString;
     307         [ #  # ]:          0 :     tempString.sprintf("%.4f", value);
     308                 :            : #ifndef ANDROID
     309         [ #  # ]:          0 :     std::string decimalPoint(localeconv()->decimal_point);
     310                 :            : #else
     311                 :            :     std::string decimalPoint(".");
     312                 :            : #endif
     313 [ #  # ][ #  # ]:          0 :     if (decimalPoint.empty() || (decimalPoint == "."))
         [ #  # ][ #  # ]
     314         [ #  # ]:          0 :         return tempString;
     315 [ #  # ][ #  # ]:          0 :     std::string stringValue(tempString.cstr());
     316         [ #  # ]:          0 :     if (!stringValue.empty())
     317                 :            :     {
     318                 :            :         std::string::size_type pos;
     319         [ #  # ]:          0 :         while ((pos = stringValue.find(decimalPoint)) != std::string::npos)
     320         [ #  # ]:          0 :             stringValue.replace(pos,decimalPoint.size(),".");
     321                 :            :     }
     322 [ #  # ][ #  # ]:          0 :     return WPXString(stringValue.c_str());
     323                 :            : }
     324                 :            : 
     325                 :            : } // anonymous namespace
     326                 :            : 
     327                 :            : class OdgGeneratorPrivate
     328                 :            : {
     329                 :            : public:
     330                 :            :     OdgGeneratorPrivate(OdfDocumentHandler *pHandler, const OdfStreamType streamType);
     331                 :            :     ~OdgGeneratorPrivate();
     332                 :            :     void _writeGraphicsStyle();
     333                 :            :     void _drawPolySomething(const ::WPXPropertyListVector &vertices, bool isClosed);
     334                 :            :     void _drawPath(const WPXPropertyListVector &path);
     335                 :            :     // body elements
     336                 :            :     std::vector <DocumentElement *> mBodyElements;
     337                 :            : 
     338                 :            :     // graphics styles
     339                 :            :     std::vector<DocumentElement *> mGraphicsStrokeDashStyles;
     340                 :            :     std::vector<DocumentElement *> mGraphicsGradientStyles;
     341                 :            :     std::vector<DocumentElement *> mGraphicsBitmapStyles;
     342                 :            :     std::vector<DocumentElement *> mGraphicsMarkerStyles;
     343                 :            :     std::vector<DocumentElement *> mGraphicsAutomaticStyles;
     344                 :            : 
     345                 :            :     // page styles
     346                 :            :     std::vector<DocumentElement *> mPageAutomaticStyles;
     347                 :            :     std::vector<DocumentElement *> mPageMasterStyles;
     348                 :            : 
     349                 :            :     // paragraph styles
     350                 :            :     ParagraphStyleManager mParagraphManager;
     351                 :            : 
     352                 :            :     // span styles
     353                 :            :     SpanStyleManager mSpanManager;
     354                 :            : 
     355                 :            :     // font styles
     356                 :            :     FontStyleManager mFontManager;
     357                 :            : 
     358                 :            :     OdfDocumentHandler *mpHandler;
     359                 :            : 
     360                 :            :     ::WPXPropertyList mxStyle;
     361                 :            :     ::WPXPropertyListVector mxGradient;
     362                 :            :     ::WPXPropertyListVector mxMarker;
     363                 :            :     int miGradientIndex;
     364                 :            :     int miBitmapIndex;
     365                 :            :     int miStartMarkerIndex;
     366                 :            :     int miEndMarkerIndex;
     367                 :            :     int miDashIndex;
     368                 :            :     int miGraphicsStyleIndex;
     369                 :            :     int miPageIndex;
     370                 :            :     double mfWidth, mfMaxWidth;
     371                 :            :     double mfHeight, mfMaxHeight;
     372                 :            : 
     373                 :            :     const OdfStreamType mxStreamType;
     374                 :            : 
     375                 :            :     bool mbIsTextBox;
     376                 :            :     bool mbIsTextLine;
     377                 :            :     bool mbIsTextOnPath;
     378                 :            : };
     379                 :            : 
     380                 :          0 : OdgGeneratorPrivate::OdgGeneratorPrivate(OdfDocumentHandler *pHandler, const OdfStreamType streamType):
     381                 :            :     mBodyElements(),
     382                 :            :     mGraphicsStrokeDashStyles(),
     383                 :            :     mGraphicsGradientStyles(),
     384                 :            :     mGraphicsBitmapStyles(),
     385                 :            :     mGraphicsAutomaticStyles(),
     386                 :            :     mPageAutomaticStyles(),
     387                 :            :     mPageMasterStyles(),
     388                 :            :     mParagraphManager(),
     389                 :            :     mSpanManager(),
     390                 :            :     mFontManager(),
     391                 :            :     mpHandler(pHandler),
     392                 :            :     mxStyle(), mxGradient(),
     393                 :            :     mxMarker(),
     394                 :            :     miGradientIndex(1),
     395                 :            :     miBitmapIndex(1),
     396                 :            :     miStartMarkerIndex(1),
     397                 :            :     miEndMarkerIndex(1),
     398                 :            :     miDashIndex(1),
     399                 :            :     miGraphicsStyleIndex(1),
     400                 :            :     miPageIndex(1),
     401                 :            :     mfWidth(0.0),
     402                 :            :     mfMaxWidth(0.0),
     403                 :            :     mfHeight(0.0),
     404                 :            :     mfMaxHeight(0.0),
     405                 :            :     mxStreamType(streamType),
     406                 :            :     mbIsTextBox(false),
     407                 :            :     mbIsTextLine(false),
     408 [ #  # ][ #  # ]:          0 :     mbIsTextOnPath(false)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     409                 :            : {
     410                 :          0 : }
     411                 :            : 
     412 [ #  # ][ #  # ]:          0 : OdgGeneratorPrivate::~OdgGeneratorPrivate()
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     413                 :            : {
     414                 :            : 
     415 [ #  # ][ #  # ]:          0 :     for (std::vector<DocumentElement *>::iterator iterBody = mBodyElements.begin(); iterBody != mBodyElements.end(); ++iterBody)
     416                 :            :     {
     417 [ #  # ][ #  # ]:          0 :         delete (*iterBody);
     418                 :          0 :         (*iterBody) = 0;
     419                 :            :     }
     420                 :            : 
     421 [ #  # ][ #  # ]:          0 :     for (std::vector<DocumentElement *>::iterator iterGraphicsAutomaticStyles = mGraphicsAutomaticStyles.begin();
     422                 :          0 :             iterGraphicsAutomaticStyles != mGraphicsAutomaticStyles.end(); ++iterGraphicsAutomaticStyles)
     423                 :            :     {
     424 [ #  # ][ #  # ]:          0 :         delete((*iterGraphicsAutomaticStyles));
     425                 :            :     }
     426                 :            : 
     427 [ #  # ][ #  # ]:          0 :     for (std::vector<DocumentElement *>::iterator iterGraphicsStrokeDashStyles = mGraphicsStrokeDashStyles.begin();
     428                 :          0 :             iterGraphicsStrokeDashStyles != mGraphicsStrokeDashStyles.end(); ++iterGraphicsStrokeDashStyles)
     429                 :            :     {
     430 [ #  # ][ #  # ]:          0 :         delete((*iterGraphicsStrokeDashStyles));
     431                 :            :     }
     432                 :            : 
     433 [ #  # ][ #  # ]:          0 :     for (std::vector<DocumentElement *>::iterator iterGraphicsGradientStyles = mGraphicsGradientStyles.begin();
     434                 :          0 :             iterGraphicsGradientStyles != mGraphicsGradientStyles.end(); ++iterGraphicsGradientStyles)
     435                 :            :     {
     436 [ #  # ][ #  # ]:          0 :         delete((*iterGraphicsGradientStyles));
     437                 :            :     }
     438                 :            : 
     439 [ #  # ][ #  # ]:          0 :     for (std::vector<DocumentElement *>::iterator iterGraphicsBitmapStyles = mGraphicsBitmapStyles.begin();
     440                 :          0 :             iterGraphicsBitmapStyles != mGraphicsBitmapStyles.end(); ++iterGraphicsBitmapStyles)
     441                 :            :     {
     442 [ #  # ][ #  # ]:          0 :         delete((*iterGraphicsBitmapStyles));
     443                 :            :     }
     444                 :            : 
     445 [ #  # ][ #  # ]:          0 :     for (std::vector<DocumentElement *>::iterator iterGraphicsMarkerStyles = mGraphicsMarkerStyles.begin();
     446                 :          0 :             iterGraphicsMarkerStyles != mGraphicsMarkerStyles.end(); ++iterGraphicsMarkerStyles)
     447                 :            :     {
     448 [ #  # ][ #  # ]:          0 :         delete((*iterGraphicsMarkerStyles));
     449                 :            :     }
     450                 :            : 
     451 [ #  # ][ #  # ]:          0 :     for (std::vector<DocumentElement *>::iterator iterPageAutomaticStyles = mPageAutomaticStyles.begin();
     452                 :          0 :             iterPageAutomaticStyles != mPageAutomaticStyles.end(); ++iterPageAutomaticStyles)
     453                 :            :     {
     454 [ #  # ][ #  # ]:          0 :         delete((*iterPageAutomaticStyles));
     455                 :            :     }
     456                 :            : 
     457 [ #  # ][ #  # ]:          0 :     for (std::vector<DocumentElement *>::iterator iterPageMasterStyles = mPageMasterStyles.begin();
     458                 :          0 :             iterPageMasterStyles != mPageMasterStyles.end(); ++iterPageMasterStyles)
     459                 :            :     {
     460 [ #  # ][ #  # ]:          0 :         delete((*iterPageMasterStyles));
     461                 :            :     }
     462                 :            : 
     463         [ #  # ]:          0 :     mParagraphManager.clean();
     464         [ #  # ]:          0 :     mSpanManager.clean();
     465         [ #  # ]:          0 :     mFontManager.clean();
     466                 :          0 : }
     467                 :            : 
     468                 :            : 
     469                 :          0 : OdgGenerator::OdgGenerator(OdfDocumentHandler *pHandler, const OdfStreamType streamType):
     470 [ #  # ][ #  # ]:          0 :     mpImpl(new OdgGeneratorPrivate(pHandler, streamType))
     471                 :            : {
     472         [ #  # ]:          0 :     mpImpl->mpHandler->startDocument();
     473                 :            :     TagOpenElement tmpOfficeDocumentContent(
     474                 :            :         (mpImpl->mxStreamType == ODF_FLAT_XML) ? "office:document" : (
     475                 :            :             (mpImpl->mxStreamType == ODF_CONTENT_XML) ? "office:document-content" : (
     476                 :            :                 (mpImpl->mxStreamType == ODF_STYLES_XML) ? "office:document-styles" : (
     477                 :            :                     (mpImpl->mxStreamType == ODF_SETTINGS_XML) ? "office:document-settings" : (
     478 [ #  # ][ #  # ]:          0 :                         (mpImpl->mxStreamType == ODF_META_XML) ? "office:document-meta" : "office:document" )))));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     479 [ #  # ][ #  # ]:          0 :     tmpOfficeDocumentContent.addAttribute("xmlns:office", "urn:oasis:names:tc:opendocument:xmlns:office:1.0");
         [ #  # ][ #  # ]
                 [ #  # ]
     480 [ #  # ][ #  # ]:          0 :     tmpOfficeDocumentContent.addAttribute("xmlns:style", "urn:oasis:names:tc:opendocument:xmlns:style:1.0");
         [ #  # ][ #  # ]
                 [ #  # ]
     481 [ #  # ][ #  # ]:          0 :     tmpOfficeDocumentContent.addAttribute("xmlns:text", "urn:oasis:names:tc:opendocument:xmlns:text:1.0");
         [ #  # ][ #  # ]
                 [ #  # ]
     482 [ #  # ][ #  # ]:          0 :     tmpOfficeDocumentContent.addAttribute("xmlns:draw", "urn:oasis:names:tc:opendocument:xmlns:drawing:1.0");
         [ #  # ][ #  # ]
                 [ #  # ]
     483 [ #  # ][ #  # ]:          0 :     tmpOfficeDocumentContent.addAttribute("xmlns:dc", "http://purl.org/dc/elements/1.1/");
         [ #  # ][ #  # ]
                 [ #  # ]
     484 [ #  # ][ #  # ]:          0 :     tmpOfficeDocumentContent.addAttribute("xmlns:svg", "urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0");
         [ #  # ][ #  # ]
                 [ #  # ]
     485 [ #  # ][ #  # ]:          0 :     tmpOfficeDocumentContent.addAttribute("xmlns:fo", "urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0");
         [ #  # ][ #  # ]
                 [ #  # ]
     486 [ #  # ][ #  # ]:          0 :     tmpOfficeDocumentContent.addAttribute("xmlns:config", "urn:oasis:names:tc:opendocument:xmlns:config:1.0");
         [ #  # ][ #  # ]
                 [ #  # ]
     487 [ #  # ][ #  # ]:          0 :     tmpOfficeDocumentContent.addAttribute("xmlns:ooo", "http://openoffice.org/2004/office");
         [ #  # ][ #  # ]
                 [ #  # ]
     488 [ #  # ][ #  # ]:          0 :     tmpOfficeDocumentContent.addAttribute("office:version", "1.0");
         [ #  # ][ #  # ]
                 [ #  # ]
     489         [ #  # ]:          0 :     if (mpImpl->mxStreamType == ODF_FLAT_XML)
     490 [ #  # ][ #  # ]:          0 :         tmpOfficeDocumentContent.addAttribute("office:mimetype", "application/vnd.oasis.opendocument.graphics");
         [ #  # ][ #  # ]
                 [ #  # ]
     491 [ #  # ][ #  # ]:          0 :     tmpOfficeDocumentContent.write(mpImpl->mpHandler);
     492                 :          0 : }
     493                 :            : 
     494                 :          0 : OdgGenerator::~OdgGenerator()
     495                 :            : {
     496 [ #  # ][ #  # ]:          0 :     if ((mpImpl->mxStreamType == ODF_FLAT_XML) || (mpImpl->mxStreamType == ODF_SETTINGS_XML))
     497                 :            :     {
     498 [ #  # ][ #  # ]:          0 :         TagOpenElement("office:settings").write(mpImpl->mpHandler);
         [ #  # ][ #  # ]
                 [ #  # ]
     499                 :            : 
     500 [ #  # ][ #  # ]:          0 :         TagOpenElement configItemSetOpenElement("config:config-item-set");
                 [ #  # ]
     501 [ #  # ][ #  # ]:          0 :         configItemSetOpenElement.addAttribute("config:name", "ooo:view-settings");
         [ #  # ][ #  # ]
                 [ #  # ]
     502         [ #  # ]:          0 :         configItemSetOpenElement.write(mpImpl->mpHandler);
     503                 :            : 
     504 [ #  # ][ #  # ]:          0 :         TagOpenElement configItemOpenElement("config:config-item");
                 [ #  # ]
     505                 :            : 
     506 [ #  # ][ #  # ]:          0 :         configItemOpenElement.addAttribute("config:name", "VisibleAreaTop");
         [ #  # ][ #  # ]
                 [ #  # ]
     507 [ #  # ][ #  # ]:          0 :         configItemOpenElement.addAttribute("config:type", "int");
         [ #  # ][ #  # ]
                 [ #  # ]
     508         [ #  # ]:          0 :         configItemOpenElement.write(mpImpl->mpHandler);
     509 [ #  # ][ #  # ]:          0 :         mpImpl->mpHandler->characters("0");
                 [ #  # ]
     510         [ #  # ]:          0 :         mpImpl->mpHandler->endElement("config:config-item");
     511                 :            : 
     512 [ #  # ][ #  # ]:          0 :         configItemOpenElement.addAttribute("config:name", "VisibleAreaLeft");
         [ #  # ][ #  # ]
                 [ #  # ]
     513 [ #  # ][ #  # ]:          0 :         configItemOpenElement.addAttribute("config:type", "int");
         [ #  # ][ #  # ]
                 [ #  # ]
     514         [ #  # ]:          0 :         configItemOpenElement.write(mpImpl->mpHandler);
     515 [ #  # ][ #  # ]:          0 :         mpImpl->mpHandler->characters("0");
                 [ #  # ]
     516         [ #  # ]:          0 :         mpImpl->mpHandler->endElement("config:config-item");
     517                 :            : 
     518 [ #  # ][ #  # ]:          0 :         configItemOpenElement.addAttribute("config:name", "VisibleAreaWidth");
         [ #  # ][ #  # ]
                 [ #  # ]
     519 [ #  # ][ #  # ]:          0 :         configItemOpenElement.addAttribute("config:type", "int");
         [ #  # ][ #  # ]
                 [ #  # ]
     520         [ #  # ]:          0 :         configItemOpenElement.write(mpImpl->mpHandler);
     521         [ #  # ]:          0 :         WPXString sWidth;
     522         [ #  # ]:          0 :         sWidth.sprintf("%li", (unsigned long)(2540 * mpImpl->mfMaxWidth));
     523         [ #  # ]:          0 :         mpImpl->mpHandler->characters(sWidth);
     524         [ #  # ]:          0 :         mpImpl->mpHandler->endElement("config:config-item");
     525                 :            : 
     526 [ #  # ][ #  # ]:          0 :         configItemOpenElement.addAttribute("config:name", "VisibleAreaHeight");
         [ #  # ][ #  # ]
                 [ #  # ]
     527 [ #  # ][ #  # ]:          0 :         configItemOpenElement.addAttribute("config:type", "int");
         [ #  # ][ #  # ]
                 [ #  # ]
     528         [ #  # ]:          0 :         configItemOpenElement.write(mpImpl->mpHandler);
     529         [ #  # ]:          0 :         WPXString sHeight;
     530         [ #  # ]:          0 :         sHeight.sprintf("%li", (unsigned long)(2540 * mpImpl->mfMaxHeight));
     531         [ #  # ]:          0 :         mpImpl->mpHandler->characters(sHeight);
     532         [ #  # ]:          0 :         mpImpl->mpHandler->endElement("config:config-item");
     533                 :            : 
     534         [ #  # ]:          0 :         mpImpl->mpHandler->endElement("config:config-item-set");
     535                 :            : 
     536 [ #  # ][ #  # ]:          0 :         mpImpl->mpHandler->endElement("office:settings");
         [ #  # ][ #  # ]
                 [ #  # ]
     537                 :            :     }
     538                 :            : 
     539                 :            : 
     540 [ #  # ][ #  # ]:          0 :     if ((mpImpl->mxStreamType == ODF_FLAT_XML) || (mpImpl->mxStreamType == ODF_STYLES_XML))
     541                 :            :     {
     542 [ #  # ][ #  # ]:          0 :         TagOpenElement("office:styles").write(mpImpl->mpHandler);
         [ #  # ][ #  # ]
                 [ #  # ]
     543                 :            : 
     544 [ #  # ][ #  # ]:          0 :         for (std::vector<DocumentElement *>::const_iterator iterGraphicsStrokeDashStyles = mpImpl->mGraphicsStrokeDashStyles.begin();
                 [ #  # ]
     545                 :          0 :                 iterGraphicsStrokeDashStyles != mpImpl->mGraphicsStrokeDashStyles.end(); ++iterGraphicsStrokeDashStyles)
     546                 :            :         {
     547         [ #  # ]:          0 :             (*iterGraphicsStrokeDashStyles)->write(mpImpl->mpHandler);
     548                 :            :         }
     549                 :            : 
     550 [ #  # ][ #  # ]:          0 :         for (std::vector<DocumentElement *>::const_iterator iterGraphicsGradientStyles = mpImpl->mGraphicsGradientStyles.begin();
                 [ #  # ]
     551                 :          0 :                 iterGraphicsGradientStyles != mpImpl->mGraphicsGradientStyles.end(); ++iterGraphicsGradientStyles)
     552                 :            :         {
     553         [ #  # ]:          0 :             (*iterGraphicsGradientStyles)->write(mpImpl->mpHandler);
     554                 :            :         }
     555                 :            : 
     556 [ #  # ][ #  # ]:          0 :         for (std::vector<DocumentElement *>::const_iterator iterGraphicsBitmapStyles = mpImpl->mGraphicsBitmapStyles.begin();
                 [ #  # ]
     557                 :          0 :                 iterGraphicsBitmapStyles != mpImpl->mGraphicsBitmapStyles.end(); ++iterGraphicsBitmapStyles)
     558                 :            :         {
     559         [ #  # ]:          0 :             (*iterGraphicsBitmapStyles)->write(mpImpl->mpHandler);
     560                 :            :         }
     561                 :            : 
     562 [ #  # ][ #  # ]:          0 :         for (std::vector<DocumentElement *>::const_iterator iterGraphicsMarkerStyles = mpImpl->mGraphicsMarkerStyles.begin();
                 [ #  # ]
     563                 :          0 :                 iterGraphicsMarkerStyles != mpImpl->mGraphicsMarkerStyles.end(); ++iterGraphicsMarkerStyles)
     564                 :            :         {
     565         [ #  # ]:          0 :             (*iterGraphicsMarkerStyles)->write(mpImpl->mpHandler);
     566                 :            :         }
     567         [ #  # ]:          0 :         mpImpl->mpHandler->endElement("office:styles");
     568                 :            :     }
     569                 :            : 
     570                 :            : 
     571 [ #  # ][ #  # ]:          0 :     if ((mpImpl->mxStreamType == ODF_FLAT_XML) || (mpImpl->mxStreamType == ODF_CONTENT_XML) || (mpImpl->mxStreamType == ODF_STYLES_XML))
                 [ #  # ]
     572                 :            :     {
     573         [ #  # ]:          0 :         mpImpl->mFontManager.writeFontsDeclaration(mpImpl->mpHandler);
     574                 :            : 
     575 [ #  # ][ #  # ]:          0 :         TagOpenElement("office:automatic-styles").write(mpImpl->mpHandler);
         [ #  # ][ #  # ]
                 [ #  # ]
     576                 :            :     }
     577                 :            : 
     578 [ #  # ][ #  # ]:          0 :     if ((mpImpl->mxStreamType == ODF_FLAT_XML) || (mpImpl->mxStreamType == ODF_CONTENT_XML))
     579                 :            :     {
     580                 :            :         // writing out the graphics automatic styles
     581 [ #  # ][ #  # ]:          0 :         for (std::vector<DocumentElement *>::iterator iterGraphicsAutomaticStyles = mpImpl->mGraphicsAutomaticStyles.begin();
     582                 :          0 :                 iterGraphicsAutomaticStyles != mpImpl->mGraphicsAutomaticStyles.end(); ++iterGraphicsAutomaticStyles)
     583                 :            :         {
     584         [ #  # ]:          0 :             (*iterGraphicsAutomaticStyles)->write(mpImpl->mpHandler);
     585                 :            :         }
     586         [ #  # ]:          0 :         mpImpl->mParagraphManager.write(mpImpl->mpHandler);
     587         [ #  # ]:          0 :         mpImpl->mSpanManager.write(mpImpl->mpHandler);
     588                 :            :     }
     589                 :            : #ifdef MULTIPAGE_WORKAROUND
     590 [ #  # ][ #  # ]:          0 :     if ((mpImpl->mxStreamType == ODF_FLAT_XML) || (mpImpl->mxStreamType == ODF_STYLES_XML))
     591                 :            :     {
     592 [ #  # ][ #  # ]:          0 :         TagOpenElement tmpStylePageLayoutOpenElement("style:page-layout");
                 [ #  # ]
     593 [ #  # ][ #  # ]:          0 :         tmpStylePageLayoutOpenElement.addAttribute("style:name", "PM0");
         [ #  # ][ #  # ]
                 [ #  # ]
     594         [ #  # ]:          0 :         tmpStylePageLayoutOpenElement.write(mpImpl->mpHandler);
     595                 :            : 
     596 [ #  # ][ #  # ]:          0 :         TagOpenElement tmpStylePageLayoutPropertiesOpenElement("style:page-layout-properties");
                 [ #  # ]
     597 [ #  # ][ #  # ]:          0 :         tmpStylePageLayoutPropertiesOpenElement.addAttribute("fo:margin-top", "0in");
         [ #  # ][ #  # ]
                 [ #  # ]
     598 [ #  # ][ #  # ]:          0 :         tmpStylePageLayoutPropertiesOpenElement.addAttribute("fo:margin-bottom", "0in");
         [ #  # ][ #  # ]
                 [ #  # ]
     599 [ #  # ][ #  # ]:          0 :         tmpStylePageLayoutPropertiesOpenElement.addAttribute("fo:margin-left", "0in");
         [ #  # ][ #  # ]
                 [ #  # ]
     600 [ #  # ][ #  # ]:          0 :         tmpStylePageLayoutPropertiesOpenElement.addAttribute("fo:margin-right", "0in");
         [ #  # ][ #  # ]
                 [ #  # ]
     601         [ #  # ]:          0 :         WPXString sValue;
     602 [ #  # ][ #  # ]:          0 :         sValue = doubleToString(mpImpl->mfMaxWidth);
                 [ #  # ]
     603         [ #  # ]:          0 :         sValue.append("in");
     604 [ #  # ][ #  # ]:          0 :         tmpStylePageLayoutPropertiesOpenElement.addAttribute("fo:page-width", sValue);
                 [ #  # ]
     605 [ #  # ][ #  # ]:          0 :         sValue = doubleToString(mpImpl->mfMaxHeight);
                 [ #  # ]
     606         [ #  # ]:          0 :         sValue.append("in");
     607 [ #  # ][ #  # ]:          0 :         tmpStylePageLayoutPropertiesOpenElement.addAttribute("fo:page-height", sValue);
                 [ #  # ]
     608 [ #  # ][ #  # ]:          0 :         tmpStylePageLayoutPropertiesOpenElement.addAttribute("style:print-orientation", "portrait");
         [ #  # ][ #  # ]
                 [ #  # ]
     609         [ #  # ]:          0 :         tmpStylePageLayoutPropertiesOpenElement.write(mpImpl->mpHandler);
     610                 :            : 
     611         [ #  # ]:          0 :         mpImpl->mpHandler->endElement("style:page-layout-properties");
     612                 :            : 
     613         [ #  # ]:          0 :         mpImpl->mpHandler->endElement("style:page-layout");
     614                 :            : 
     615 [ #  # ][ #  # ]:          0 :         TagOpenElement tmpStyleStyleOpenElement("style:style");
                 [ #  # ]
     616 [ #  # ][ #  # ]:          0 :         tmpStyleStyleOpenElement.addAttribute("style:name", "dp1");
         [ #  # ][ #  # ]
                 [ #  # ]
     617 [ #  # ][ #  # ]:          0 :         tmpStyleStyleOpenElement.addAttribute("style:family", "drawing-page");
         [ #  # ][ #  # ]
                 [ #  # ]
     618         [ #  # ]:          0 :         tmpStyleStyleOpenElement.write(mpImpl->mpHandler);
     619                 :            : 
     620 [ #  # ][ #  # ]:          0 :         TagOpenElement tmpStyleDrawingPagePropertiesOpenElement("style:drawing-page-properties");
                 [ #  # ]
     621                 :            :         // tmpStyleDrawingPagePropertiesOpenElement.addAttribute("draw:background-size", "border");
     622 [ #  # ][ #  # ]:          0 :         tmpStyleDrawingPagePropertiesOpenElement.addAttribute("draw:fill", "none");
         [ #  # ][ #  # ]
                 [ #  # ]
     623         [ #  # ]:          0 :         tmpStyleDrawingPagePropertiesOpenElement.write(mpImpl->mpHandler);
     624                 :            : 
     625         [ #  # ]:          0 :         mpImpl->mpHandler->endElement("style:drawing-page-properties");
     626                 :            : 
     627 [ #  # ][ #  # ]:          0 :         mpImpl->mpHandler->endElement("style:style");
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     628                 :            :     }
     629                 :            : #else
     630                 :            :     if ((mpImpl->mxStreamType == ODF_FLAT_XML) || (mpImpl->mxStreamType == ODF_STYLES_XML))
     631                 :            :     {
     632                 :            :         // writing out the page automatic styles
     633                 :            :         for (std::vector<DocumentElement *>::iterator iterPageAutomaticStyles = mpImpl->mPageAutomaticStyles.begin();
     634                 :            :                 iterPageAutomaticStyles != mpImpl->mPageAutomaticStyles.end(); ++iterPageAutomaticStyles)
     635                 :            :         {
     636                 :            :             (*iterPageAutomaticStyles)->write(mpImpl->mpHandler);
     637                 :            :         }
     638                 :            :     }
     639                 :            : #endif
     640 [ #  # ][ #  # ]:          0 :     if ((mpImpl->mxStreamType == ODF_FLAT_XML) || (mpImpl->mxStreamType == ODF_CONTENT_XML) || (mpImpl->mxStreamType == ODF_STYLES_XML))
                 [ #  # ]
     641                 :            :     {
     642         [ #  # ]:          0 :         mpImpl->mpHandler->endElement("office:automatic-styles");
     643                 :            :     }
     644                 :            : 
     645 [ #  # ][ #  # ]:          0 :     if ((mpImpl->mxStreamType == ODF_FLAT_XML) || (mpImpl->mxStreamType == ODF_STYLES_XML))
     646                 :            :     {
     647 [ #  # ][ #  # ]:          0 :         TagOpenElement("office:master-styles").write(mpImpl->mpHandler);
         [ #  # ][ #  # ]
                 [ #  # ]
     648                 :            : 
     649 [ #  # ][ #  # ]:          0 :         for (std::vector<DocumentElement *>::const_iterator pageMasterIter = mpImpl->mPageMasterStyles.begin();
                 [ #  # ]
     650                 :          0 :                 pageMasterIter != mpImpl->mPageMasterStyles.end(); ++pageMasterIter)
     651                 :            :         {
     652         [ #  # ]:          0 :             (*pageMasterIter)->write(mpImpl->mpHandler);
     653                 :            :         }
     654         [ #  # ]:          0 :         mpImpl->mpHandler->endElement("office:master-styles");
     655                 :            :     }
     656                 :            : 
     657 [ #  # ][ #  # ]:          0 :     if ((mpImpl->mxStreamType == ODF_FLAT_XML) || (mpImpl->mxStreamType == ODF_CONTENT_XML))
     658                 :            :     {
     659 [ #  # ][ #  # ]:          0 :         TagOpenElement("office:body").write(mpImpl->mpHandler);
         [ #  # ][ #  # ]
                 [ #  # ]
     660                 :            : 
     661 [ #  # ][ #  # ]:          0 :         TagOpenElement("office:drawing").write(mpImpl->mpHandler);
         [ #  # ][ #  # ]
                 [ #  # ]
     662                 :            : 
     663 [ #  # ][ #  # ]:          0 :         for (std::vector<DocumentElement *>::const_iterator bodyIter = mpImpl->mBodyElements.begin();
                 [ #  # ]
     664                 :          0 :                 bodyIter != mpImpl->mBodyElements.end(); ++bodyIter)
     665                 :            :         {
     666         [ #  # ]:          0 :             (*bodyIter)->write(mpImpl->mpHandler);
     667                 :            :         }
     668                 :            : 
     669         [ #  # ]:          0 :         mpImpl->mpHandler->endElement("office:drawing");
     670         [ #  # ]:          0 :         mpImpl->mpHandler->endElement("office:body");
     671                 :            :     }
     672                 :            : 
     673                 :            :     mpImpl->mpHandler->endElement(
     674                 :            :         (mpImpl->mxStreamType == ODF_FLAT_XML) ? "office:document" : (
     675                 :            :             (mpImpl->mxStreamType == ODF_CONTENT_XML) ? "office:document-content" : (
     676                 :            :                 (mpImpl->mxStreamType == ODF_STYLES_XML) ? "office:document-styles" : (
     677                 :            :                     (mpImpl->mxStreamType == ODF_SETTINGS_XML) ? "office:document-settings" : (
     678 [ #  # ][ #  # ]:          0 :                         (mpImpl->mxStreamType == ODF_META_XML) ? "office:document-meta" : "office:document" )))));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     679                 :            : 
     680         [ #  # ]:          0 :     mpImpl->mpHandler->endDocument();
     681                 :            : 
     682         [ #  # ]:          0 :     if (mpImpl)
     683 [ #  # ][ #  # ]:          0 :         delete mpImpl;
     684         [ #  # ]:          0 : }
     685                 :            : 
     686                 :          0 : void OdgGenerator::startGraphics(const ::WPXPropertyList &propList)
     687                 :            : {
     688 [ #  # ][ #  # ]:          0 :     if (propList["svg:width"])
     689                 :            :     {
     690 [ #  # ][ #  # ]:          0 :         mpImpl->mfWidth = propList["svg:width"]->getDouble();
     691         [ #  # ]:          0 :         mpImpl->mfMaxWidth = mpImpl->mfMaxWidth < mpImpl->mfWidth ? mpImpl->mfWidth : mpImpl->mfMaxWidth;
     692                 :            :     }
     693                 :            : 
     694 [ #  # ][ #  # ]:          0 :     if (propList["svg:height"])
     695                 :            :     {
     696 [ #  # ][ #  # ]:          0 :         mpImpl->mfHeight = propList["svg:height"]->getDouble();
     697         [ #  # ]:          0 :         mpImpl->mfMaxHeight = mpImpl->mfMaxHeight < mpImpl->mfHeight ? mpImpl->mfHeight : mpImpl->mfMaxHeight;
     698                 :            :     }
     699                 :            : 
     700 [ #  # ][ #  # ]:          0 :     TagOpenElement *pStyleMasterPageOpenElement = new TagOpenElement("style:master-page");
         [ #  # ][ #  # ]
     701                 :            : 
     702 [ #  # ][ #  # ]:          0 :     TagOpenElement *pDrawPageOpenElement = new TagOpenElement("draw:page");
         [ #  # ][ #  # ]
     703                 :            : 
     704 [ #  # ][ #  # ]:          0 :     TagOpenElement *pStylePageLayoutOpenElement = new TagOpenElement("style:page-layout");
         [ #  # ][ #  # ]
     705                 :            : 
     706         [ #  # ]:          0 :     WPXString sValue;
     707         [ #  # ]:          0 :     sValue.sprintf("page%i", mpImpl->miPageIndex);
     708 [ #  # ][ #  # ]:          0 :     pDrawPageOpenElement->addAttribute("draw:name", sValue);
                 [ #  # ]
     709                 :            : #ifdef MULTIPAGE_WORKAROUND
     710 [ #  # ][ #  # ]:          0 :     pStyleMasterPageOpenElement->addAttribute("style:page-layout-name", "PM0");
         [ #  # ][ #  # ]
                 [ #  # ]
     711 [ #  # ][ #  # ]:          0 :     pStylePageLayoutOpenElement->addAttribute("style:page-layout-name", "PM0");
         [ #  # ][ #  # ]
                 [ #  # ]
     712                 :            : #else
     713                 :            :     sValue.sprintf("PM%i", mpImpl->miPageIndex);
     714                 :            :     pStyleMasterPageOpenElement->addAttribute("style:page-layout-name", sValue);
     715                 :            :     pStylePageLayoutOpenElement->addAttribute("style:name", sValue);
     716                 :            : #endif
     717                 :            : 
     718         [ #  # ]:          0 :     mpImpl->mPageAutomaticStyles.push_back(pStylePageLayoutOpenElement);
     719                 :            : 
     720 [ #  # ][ #  # ]:          0 :     TagOpenElement *pStylePageLayoutPropertiesOpenElement = new TagOpenElement("style:page-layout-properties");
         [ #  # ][ #  # ]
     721 [ #  # ][ #  # ]:          0 :     pStylePageLayoutPropertiesOpenElement->addAttribute("fo:margin-top", "0in");
         [ #  # ][ #  # ]
                 [ #  # ]
     722 [ #  # ][ #  # ]:          0 :     pStylePageLayoutPropertiesOpenElement->addAttribute("fo:margin-bottom", "0in");
         [ #  # ][ #  # ]
                 [ #  # ]
     723 [ #  # ][ #  # ]:          0 :     pStylePageLayoutPropertiesOpenElement->addAttribute("fo:margin-left", "0in");
         [ #  # ][ #  # ]
                 [ #  # ]
     724 [ #  # ][ #  # ]:          0 :     pStylePageLayoutPropertiesOpenElement->addAttribute("fo:margin-right", "0in");
         [ #  # ][ #  # ]
                 [ #  # ]
     725 [ #  # ][ #  # ]:          0 :     sValue.sprintf("%s%s", doubleToString(mpImpl->mfWidth).cstr(), "in");
         [ #  # ][ #  # ]
     726 [ #  # ][ #  # ]:          0 :     pStylePageLayoutPropertiesOpenElement->addAttribute("fo:page-width", sValue);
                 [ #  # ]
     727 [ #  # ][ #  # ]:          0 :     sValue.sprintf("%s%s", doubleToString(mpImpl->mfHeight).cstr(), "in");
         [ #  # ][ #  # ]
     728 [ #  # ][ #  # ]:          0 :     pStylePageLayoutPropertiesOpenElement->addAttribute("fo:page-height", sValue);
                 [ #  # ]
     729 [ #  # ][ #  # ]:          0 :     pStylePageLayoutPropertiesOpenElement->addAttribute("style:print-orientation", "portrait");
         [ #  # ][ #  # ]
                 [ #  # ]
     730         [ #  # ]:          0 :     mpImpl->mPageAutomaticStyles.push_back(pStylePageLayoutPropertiesOpenElement);
     731                 :            : 
     732 [ #  # ][ #  # ]:          0 :     mpImpl->mPageAutomaticStyles.push_back(new TagCloseElement("style:page-layout-properties"));
         [ #  # ][ #  # ]
                 [ #  # ]
     733                 :            : 
     734 [ #  # ][ #  # ]:          0 :     mpImpl->mPageAutomaticStyles.push_back(new TagCloseElement("style:page-layout"));
         [ #  # ][ #  # ]
                 [ #  # ]
     735                 :            : 
     736                 :            : #ifdef MULTIPAGE_WORKAROUND
     737 [ #  # ][ #  # ]:          0 :     pDrawPageOpenElement->addAttribute("draw:style-name", "dp1");
         [ #  # ][ #  # ]
                 [ #  # ]
     738 [ #  # ][ #  # ]:          0 :     pStyleMasterPageOpenElement->addAttribute("draw:style-name", "dp1");
         [ #  # ][ #  # ]
                 [ #  # ]
     739                 :            : #else
     740                 :            :     sValue.sprintf("dp%i", mpImpl->miPageIndex);
     741                 :            :     pDrawPageOpenElement->addAttribute("draw:style-name", sValue);
     742                 :            :     pStyleMasterPageOpenElement->addAttribute("draw:style-name", sValue);
     743                 :            : #endif
     744                 :            : 
     745 [ #  # ][ #  # ]:          0 :     TagOpenElement *pStyleStyleOpenElement = new TagOpenElement("style:style");
         [ #  # ][ #  # ]
     746 [ #  # ][ #  # ]:          0 :     pStyleStyleOpenElement->addAttribute("style:name", sValue);
                 [ #  # ]
     747 [ #  # ][ #  # ]:          0 :     pStyleStyleOpenElement->addAttribute("style:family", "drawing-page");
         [ #  # ][ #  # ]
                 [ #  # ]
     748         [ #  # ]:          0 :     mpImpl->mPageAutomaticStyles.push_back(pStyleStyleOpenElement);
     749                 :            : 
     750                 :            : #ifdef MULTIPAGE_WORKAROUND
     751 [ #  # ][ #  # ]:          0 :     pDrawPageOpenElement->addAttribute("draw:master-page-name", "Default");
         [ #  # ][ #  # ]
                 [ #  # ]
     752 [ #  # ][ #  # ]:          0 :     pStyleMasterPageOpenElement->addAttribute("style:name", "Default");
         [ #  # ][ #  # ]
                 [ #  # ]
     753                 :            : #else
     754                 :            :     sValue.sprintf("Page%i", mpImpl->miPageIndex);
     755                 :            :     pDrawPageOpenElement->addAttribute("draw:master-page-name", sValue);
     756                 :            :     pStyleMasterPageOpenElement->addAttribute("style:name", sValue);
     757                 :            : #endif
     758                 :            : 
     759         [ #  # ]:          0 :     mpImpl->mBodyElements.push_back(pDrawPageOpenElement);
     760                 :            : 
     761         [ #  # ]:          0 :     mpImpl->mPageMasterStyles.push_back(pStyleMasterPageOpenElement);
     762 [ #  # ][ #  # ]:          0 :     mpImpl->mPageMasterStyles.push_back(new TagCloseElement("style:master-page"));
         [ #  # ][ #  # ]
                 [ #  # ]
     763                 :            : 
     764                 :            : 
     765 [ #  # ][ #  # ]:          0 :     TagOpenElement *pStyleDrawingPagePropertiesOpenElement = new TagOpenElement("style:drawing-page-properties");
         [ #  # ][ #  # ]
     766                 :            :     // pStyleDrawingPagePropertiesOpenElement->addAttribute("draw:background-size", "border");
     767 [ #  # ][ #  # ]:          0 :     pStyleDrawingPagePropertiesOpenElement->addAttribute("draw:fill", "none");
         [ #  # ][ #  # ]
                 [ #  # ]
     768         [ #  # ]:          0 :     mpImpl->mPageAutomaticStyles.push_back(pStyleDrawingPagePropertiesOpenElement);
     769                 :            : 
     770 [ #  # ][ #  # ]:          0 :     mpImpl->mPageAutomaticStyles.push_back(new TagCloseElement("style:drawing-page-properties"));
         [ #  # ][ #  # ]
                 [ #  # ]
     771                 :            : 
     772 [ #  # ][ #  # ]:          0 :     mpImpl->mPageAutomaticStyles.push_back(new TagCloseElement("style:style"));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     773                 :          0 : }
     774                 :            : 
     775                 :          0 : void OdgGenerator::endGraphics()
     776                 :            : {
     777 [ #  # ][ #  # ]:          0 :     mpImpl->mBodyElements.push_back(new TagCloseElement("draw:page"));
                 [ #  # ]
     778                 :          0 :     mpImpl->miPageIndex++;
     779                 :          0 : }
     780                 :            : 
     781                 :          0 : void OdgGenerator::setStyle(const ::WPXPropertyList &propList, const ::WPXPropertyListVector &gradient)
     782                 :            : {
     783                 :          0 :     mpImpl->mxStyle.clear();
     784                 :          0 :     mpImpl->mxStyle = propList;
     785                 :          0 :     mpImpl->mxGradient = gradient;
     786                 :          0 : }
     787                 :            : 
     788                 :          0 : void OdgGenerator::startLayer(const ::WPXPropertyList & /* propList */)
     789                 :            : {
     790 [ #  # ][ #  # ]:          0 :     mpImpl->mBodyElements.push_back(new TagOpenElement("draw:g"));
                 [ #  # ]
     791                 :          0 : }
     792                 :            : 
     793                 :          0 : void OdgGenerator::endLayer()
     794                 :            : {
     795 [ #  # ][ #  # ]:          0 :     mpImpl->mBodyElements.push_back(new TagCloseElement("draw:g"));
                 [ #  # ]
     796                 :          0 : }
     797                 :            : 
     798                 :          0 : void OdgGenerator::drawRectangle(const ::WPXPropertyList &propList)
     799                 :            : {
     800         [ #  # ]:          0 :     mpImpl->_writeGraphicsStyle();
     801 [ #  # ][ #  # ]:          0 :     TagOpenElement *pDrawRectElement = new TagOpenElement("draw:rect");
         [ #  # ][ #  # ]
     802         [ #  # ]:          0 :     WPXString sValue;
     803         [ #  # ]:          0 :     sValue.sprintf("gr%i", mpImpl->miGraphicsStyleIndex-1);
     804 [ #  # ][ #  # ]:          0 :     pDrawRectElement->addAttribute("draw:style-name", sValue);
                 [ #  # ]
     805 [ #  # ][ #  # ]:          0 :     pDrawRectElement->addAttribute("svg:x", propList["svg:x"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     806 [ #  # ][ #  # ]:          0 :     pDrawRectElement->addAttribute("svg:y", propList["svg:y"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     807 [ #  # ][ #  # ]:          0 :     pDrawRectElement->addAttribute("svg:width", propList["svg:width"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     808 [ #  # ][ #  # ]:          0 :     pDrawRectElement->addAttribute("svg:height", propList["svg:height"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     809                 :            :     // FIXME: what to do when rx != ry ?
     810 [ #  # ][ #  # ]:          0 :     if (propList["svg:rx"])
     811 [ #  # ][ #  # ]:          0 :         pDrawRectElement->addAttribute("draw:corner-radius", propList["svg:rx"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     812                 :            :     else
     813 [ #  # ][ #  # ]:          0 :         pDrawRectElement->addAttribute("draw:corner-radius", "0.0000in");
         [ #  # ][ #  # ]
                 [ #  # ]
     814         [ #  # ]:          0 :     mpImpl->mBodyElements.push_back(pDrawRectElement);
     815 [ #  # ][ #  # ]:          0 :     mpImpl->mBodyElements.push_back(new TagCloseElement("draw:rect"));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     816                 :          0 : }
     817                 :            : 
     818                 :          0 : void OdgGenerator::drawEllipse(const ::WPXPropertyList &propList)
     819                 :            : {
     820         [ #  # ]:          0 :     mpImpl->_writeGraphicsStyle();
     821 [ #  # ][ #  # ]:          0 :     TagOpenElement *pDrawEllipseElement = new TagOpenElement("draw:ellipse");
         [ #  # ][ #  # ]
     822         [ #  # ]:          0 :     WPXString sValue;
     823         [ #  # ]:          0 :     sValue.sprintf("gr%i", mpImpl->miGraphicsStyleIndex-1);
     824 [ #  # ][ #  # ]:          0 :     pDrawEllipseElement->addAttribute("draw:style-name", sValue);
                 [ #  # ]
     825 [ #  # ][ #  # ]:          0 :     sValue = doubleToString(2 * propList["svg:rx"]->getDouble());
         [ #  # ][ #  # ]
                 [ #  # ]
     826         [ #  # ]:          0 :     sValue.append("in");
     827 [ #  # ][ #  # ]:          0 :     pDrawEllipseElement->addAttribute("svg:width", sValue);
                 [ #  # ]
     828 [ #  # ][ #  # ]:          0 :     sValue = doubleToString(2 * propList["svg:ry"]->getDouble());
         [ #  # ][ #  # ]
                 [ #  # ]
     829         [ #  # ]:          0 :     sValue.append("in");
     830 [ #  # ][ #  # ]:          0 :     pDrawEllipseElement->addAttribute("svg:height", sValue);
                 [ #  # ]
     831 [ #  # ][ #  # ]:          0 :     if (propList["libwpg:rotate"] && propList["libwpg:rotate"]->getDouble() != 0.0)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     832                 :            :     {
     833 [ #  # ][ #  # ]:          0 :         double rotation = propList["libwpg:rotate"]->getDouble();
     834         [ #  # ]:          0 :         while(rotation < -180)
     835                 :          0 :             rotation += 360;
     836         [ #  # ]:          0 :         while(rotation > 180)
     837                 :          0 :             rotation -= 360;
     838                 :          0 :         double radrotation = rotation*M_PI/180.0;
     839 [ #  # ][ #  # ]:          0 :         double deltax = sqrt(pow(propList["svg:rx"]->getDouble(), 2.0)
     840 [ #  # ][ #  # ]:          0 :                              + pow(propList["svg:ry"]->getDouble(), 2.0))*cos(atan(propList["svg:ry"]->getDouble()/propList["svg:rx"]->getDouble())
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     841 [ #  # ][ #  # ]:          0 :                                      - radrotation ) - propList["svg:rx"]->getDouble();
     842 [ #  # ][ #  # ]:          0 :         double deltay = sqrt(pow(propList["svg:rx"]->getDouble(), 2.0)
     843 [ #  # ][ #  # ]:          0 :                              + pow(propList["svg:ry"]->getDouble(), 2.0))*sin(atan(propList["svg:ry"]->getDouble()/propList["svg:rx"]->getDouble())
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     844 [ #  # ][ #  # ]:          0 :                                      - radrotation ) - propList["svg:ry"]->getDouble();
     845         [ #  # ]:          0 :         sValue = "rotate(";
     846 [ #  # ][ #  # ]:          0 :         sValue.append(doubleToString(radrotation));
                 [ #  # ]
     847         [ #  # ]:          0 :         sValue.append(") ");
     848         [ #  # ]:          0 :         sValue.append("translate(");
     849 [ #  # ][ #  # ]:          0 :         sValue.append(doubleToString(propList["svg:cx"]->getDouble() - propList["svg:rx"]->getDouble() - deltax));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     850         [ #  # ]:          0 :         sValue.append("in, ");
     851 [ #  # ][ #  # ]:          0 :         sValue.append(doubleToString(propList["svg:cy"]->getDouble() - propList["svg:ry"]->getDouble() - deltay));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     852         [ #  # ]:          0 :         sValue.append("in)");
     853 [ #  # ][ #  # ]:          0 :         pDrawEllipseElement->addAttribute("draw:transform", sValue);
                 [ #  # ]
     854                 :            :     }
     855                 :            :     else
     856                 :            :     {
     857 [ #  # ][ #  # ]:          0 :         sValue = doubleToString(propList["svg:cx"]->getDouble()-propList["svg:rx"]->getDouble());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     858         [ #  # ]:          0 :         sValue.append("in");
     859 [ #  # ][ #  # ]:          0 :         pDrawEllipseElement->addAttribute("svg:x", sValue);
                 [ #  # ]
     860 [ #  # ][ #  # ]:          0 :         sValue = doubleToString(propList["svg:cy"]->getDouble()-propList["svg:ry"]->getDouble());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     861         [ #  # ]:          0 :         sValue.append("in");
     862 [ #  # ][ #  # ]:          0 :         pDrawEllipseElement->addAttribute("svg:y", sValue);
                 [ #  # ]
     863                 :            :     }
     864         [ #  # ]:          0 :     mpImpl->mBodyElements.push_back(pDrawEllipseElement);
     865 [ #  # ][ #  # ]:          0 :     mpImpl->mBodyElements.push_back(new TagCloseElement("draw:ellipse"));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     866                 :          0 : }
     867                 :            : 
     868                 :          0 : void OdgGenerator::drawPolyline(const ::WPXPropertyListVector &vertices)
     869                 :            : {
     870                 :          0 :     mpImpl->_drawPolySomething(vertices, false);
     871                 :          0 : }
     872                 :            : 
     873                 :          0 : void OdgGenerator::drawPolygon(const ::WPXPropertyListVector &vertices)
     874                 :            : {
     875                 :          0 :     mpImpl->_drawPolySomething(vertices, true);
     876                 :          0 : }
     877                 :            : 
     878                 :          0 : void OdgGeneratorPrivate::_drawPolySomething(const ::WPXPropertyListVector &vertices, bool isClosed)
     879                 :            : {
     880         [ #  # ]:          0 :     if(vertices.count() < 2)
     881                 :          0 :         return;
     882                 :            : 
     883         [ #  # ]:          0 :     if(vertices.count() == 2)
     884                 :            :     {
     885         [ #  # ]:          0 :         _writeGraphicsStyle();
     886 [ #  # ][ #  # ]:          0 :         TagOpenElement *pDrawLineElement = new TagOpenElement("draw:line");
         [ #  # ][ #  # ]
     887         [ #  # ]:          0 :         WPXString sValue;
     888         [ #  # ]:          0 :         sValue.sprintf("gr%i", miGraphicsStyleIndex-1);
     889 [ #  # ][ #  # ]:          0 :         pDrawLineElement->addAttribute("draw:style-name", sValue);
                 [ #  # ]
     890 [ #  # ][ #  # ]:          0 :         pDrawLineElement->addAttribute("draw:layer", "layout");
         [ #  # ][ #  # ]
                 [ #  # ]
     891 [ #  # ][ #  # ]:          0 :         pDrawLineElement->addAttribute("svg:x1", vertices[0]["svg:x"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     892 [ #  # ][ #  # ]:          0 :         pDrawLineElement->addAttribute("svg:y1", vertices[0]["svg:y"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     893 [ #  # ][ #  # ]:          0 :         pDrawLineElement->addAttribute("svg:x2", vertices[1]["svg:x"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     894 [ #  # ][ #  # ]:          0 :         pDrawLineElement->addAttribute("svg:y2", vertices[1]["svg:y"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     895         [ #  # ]:          0 :         mBodyElements.push_back(pDrawLineElement);
     896 [ #  # ][ #  # ]:          0 :         mBodyElements.push_back(new TagCloseElement("draw:line"));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     897                 :            :     }
     898                 :            :     else
     899                 :            :     {
     900         [ #  # ]:          0 :         ::WPXPropertyListVector path;
     901         [ #  # ]:          0 :         ::WPXPropertyList element;
     902                 :            : 
     903 [ #  # ][ #  # ]:          0 :         for (unsigned long ii = 0; ii < vertices.count(); ++ii)
     904                 :            :         {
     905 [ #  # ][ #  # ]:          0 :             element = vertices[ii];
     906         [ #  # ]:          0 :             if (ii == 0)
     907         [ #  # ]:          0 :                 element.insert("libwpg:path-action", "M");
     908                 :            :             else
     909         [ #  # ]:          0 :                 element.insert("libwpg:path-action", "L");
     910         [ #  # ]:          0 :             path.append(element);
     911         [ #  # ]:          0 :             element.clear();
     912                 :            :         }
     913         [ #  # ]:          0 :         if (isClosed)
     914                 :            :         {
     915         [ #  # ]:          0 :             element.insert("libwpg:path-action", "Z");
     916         [ #  # ]:          0 :             path.append(element);
     917                 :            :         }
     918 [ #  # ][ #  # ]:          0 :         _drawPath(path);
                 [ #  # ]
     919                 :            :     }
     920                 :            : }
     921                 :            : 
     922                 :          0 : void OdgGeneratorPrivate::_drawPath(const WPXPropertyListVector &path)
     923                 :            : {
     924 [ #  # ][ #  # ]:          0 :     if(path.count() == 0)
     925                 :            :         return;
     926                 :            :     // This must be a mistake and we do not want to crash lower
     927 [ #  # ][ #  # ]:          0 :     if(path[0]["libwpg:path-action"]->getStr() == "Z")
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     928                 :            :         return;
     929                 :            : 
     930                 :            :     // try to find the bounding box
     931                 :            :     // this is simple convex hull technique, the bounding box might not be
     932                 :            :     // accurate but that should be enough for this purpose
     933                 :          0 :     bool isFirstPoint = true;
     934                 :            : 
     935                 :          0 :     double px = 0.0, py = 0.0, qx = 0.0, qy = 0.0;
     936                 :          0 :     double lastX = 0.0;
     937                 :          0 :     double lastY = 0.0;
     938                 :            : 
     939 [ #  # ][ #  # ]:          0 :     for(unsigned k = 0; k < path.count(); ++k)
     940                 :            :     {
     941 [ #  # ][ #  # ]:          0 :         if (!path[k]["svg:x"] || !path[k]["svg:y"])
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     942                 :          0 :             continue;
     943         [ #  # ]:          0 :         if (isFirstPoint)
     944                 :            :         {
     945 [ #  # ][ #  # ]:          0 :             px = path[k]["svg:x"]->getDouble();
                 [ #  # ]
     946 [ #  # ][ #  # ]:          0 :             py = path[k]["svg:y"]->getDouble();
                 [ #  # ]
     947                 :          0 :             qx = px;
     948                 :          0 :             qy = py;
     949                 :          0 :             lastX = px;
     950                 :          0 :             lastY = py;
     951                 :          0 :             isFirstPoint = false;
     952                 :            :         }
     953 [ #  # ][ #  # ]:          0 :         px = (px > path[k]["svg:x"]->getDouble()) ? path[k]["svg:x"]->getDouble() : px;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     954 [ #  # ][ #  # ]:          0 :         py = (py > path[k]["svg:y"]->getDouble()) ? path[k]["svg:y"]->getDouble() : py;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     955 [ #  # ][ #  # ]:          0 :         qx = (qx < path[k]["svg:x"]->getDouble()) ? path[k]["svg:x"]->getDouble() : qx;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     956 [ #  # ][ #  # ]:          0 :         qy = (qy < path[k]["svg:y"]->getDouble()) ? path[k]["svg:y"]->getDouble() : qy;
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     957                 :            : 
     958                 :            :         double xmin, xmax, ymin, ymax;
     959                 :            : 
     960 [ #  # ][ #  # ]:          0 :         if(path[k]["libwpg:path-action"]->getStr() == "C")
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     961                 :            :         {
     962 [ #  # ][ #  # ]:          0 :             getCubicBezierBBox(lastX, lastY, path[k]["svg:x1"]->getDouble(), path[k]["svg:y1"]->getDouble(),
         [ #  # ][ #  # ]
     963 [ #  # ][ #  # ]:          0 :                                path[k]["svg:x2"]->getDouble(), path[k]["svg:y2"]->getDouble(),
         [ #  # ][ #  # ]
     964 [ #  # ][ #  # ]:          0 :                                path[k]["svg:x"]->getDouble(), path[k]["svg:y"]->getDouble(), xmin, ymin, xmax, ymax);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     965                 :            : 
     966         [ #  # ]:          0 :             px = (px > xmin ? xmin : px);
     967         [ #  # ]:          0 :             py = (py > ymin ? ymin : py);
     968         [ #  # ]:          0 :             qx = (qx < xmax ? xmax : qx);
     969         [ #  # ]:          0 :             qy = (qy < ymax ? ymax : qy);
     970                 :            :         }
     971 [ #  # ][ #  # ]:          0 :         if(path[k]["libwpg:path-action"]->getStr() == "Q")
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     972                 :            :         {
     973 [ #  # ][ #  # ]:          0 :             getQuadraticBezierBBox(lastX, lastY, path[k]["svg:x1"]->getDouble(), path[k]["svg:y1"]->getDouble(),
         [ #  # ][ #  # ]
     974 [ #  # ][ #  # ]:          0 :                                    path[k]["svg:x"]->getDouble(), path[k]["svg:y"]->getDouble(), xmin, ymin, xmax, ymax);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     975                 :            : 
     976         [ #  # ]:          0 :             px = (px > xmin ? xmin : px);
     977         [ #  # ]:          0 :             py = (py > ymin ? ymin : py);
     978         [ #  # ]:          0 :             qx = (qx < xmax ? xmax : qx);
     979         [ #  # ]:          0 :             qy = (qy < ymax ? ymax : qy);
     980                 :            :         }
     981 [ #  # ][ #  # ]:          0 :         if(path[k]["libwpg:path-action"]->getStr() == "A")
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     982                 :            :         {
     983 [ #  # ][ #  # ]:          0 :             getEllipticalArcBBox(lastX, lastY, path[k]["svg:rx"]->getDouble(), path[k]["svg:ry"]->getDouble(),
         [ #  # ][ #  # ]
     984 [ #  # ][ #  # ]:          0 :                                  path[k]["libwpg:rotate"] ? path[k]["libwpg:rotate"]->getDouble() : 0.0,
         [ #  # ][ #  # ]
     985 [ #  # ][ #  # ]:          0 :                                  path[k]["libwpg:large-arc"] ? path[k]["libwpg:large-arc"]->getInt() : 1,
         [ #  # ][ #  # ]
                 [ #  # ]
     986 [ #  # ][ #  # ]:          0 :                                  path[k]["libwpg:sweep"] ? path[k]["libwpg:sweep"]->getInt() : 1,
         [ #  # ][ #  # ]
                 [ #  # ]
     987 [ #  # ][ #  # ]:          0 :                                  path[k]["svg:x"]->getDouble(), path[k]["svg:y"]->getDouble(), xmin, ymin, xmax, ymax);
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     988                 :            : 
     989         [ #  # ]:          0 :             px = (px > xmin ? xmin : px);
     990         [ #  # ]:          0 :             py = (py > ymin ? ymin : py);
     991         [ #  # ]:          0 :             qx = (qx < xmax ? xmax : qx);
     992         [ #  # ]:          0 :             qy = (qy < ymax ? ymax : qy);
     993                 :            :         }
     994 [ #  # ][ #  # ]:          0 :         lastX = path[k]["svg:x"]->getDouble();
                 [ #  # ]
     995 [ #  # ][ #  # ]:          0 :         lastY = path[k]["svg:y"]->getDouble();
                 [ #  # ]
     996                 :            :     }
     997                 :            : 
     998                 :            : 
     999         [ #  # ]:          0 :     WPXString sValue;
    1000         [ #  # ]:          0 :     _writeGraphicsStyle();
    1001 [ #  # ][ #  # ]:          0 :     TagOpenElement *pDrawPathElement = new TagOpenElement("draw:path");
         [ #  # ][ #  # ]
    1002         [ #  # ]:          0 :     sValue.sprintf("gr%i", miGraphicsStyleIndex-1);
    1003 [ #  # ][ #  # ]:          0 :     pDrawPathElement->addAttribute("draw:style-name", sValue);
                 [ #  # ]
    1004 [ #  # ][ #  # ]:          0 :     pDrawPathElement->addAttribute("draw:layer", "layout");
         [ #  # ][ #  # ]
                 [ #  # ]
    1005 [ #  # ][ #  # ]:          0 :     sValue = doubleToString(px);
                 [ #  # ]
    1006         [ #  # ]:          0 :     sValue.append("in");
    1007 [ #  # ][ #  # ]:          0 :     pDrawPathElement->addAttribute("svg:x", sValue);
                 [ #  # ]
    1008 [ #  # ][ #  # ]:          0 :     sValue = doubleToString(py);
                 [ #  # ]
    1009         [ #  # ]:          0 :     sValue.append("in");
    1010 [ #  # ][ #  # ]:          0 :     pDrawPathElement->addAttribute("svg:y", sValue);
                 [ #  # ]
    1011 [ #  # ][ #  # ]:          0 :     sValue = doubleToString((qx - px));
                 [ #  # ]
    1012         [ #  # ]:          0 :     sValue.append("in");
    1013 [ #  # ][ #  # ]:          0 :     pDrawPathElement->addAttribute("svg:width", sValue);
                 [ #  # ]
    1014 [ #  # ][ #  # ]:          0 :     sValue = doubleToString((qy - py));
                 [ #  # ]
    1015         [ #  # ]:          0 :     sValue.append("in");
    1016 [ #  # ][ #  # ]:          0 :     pDrawPathElement->addAttribute("svg:height", sValue);
                 [ #  # ]
    1017         [ #  # ]:          0 :     sValue.sprintf("%i %i %i %i", 0, 0, (unsigned)(2540*(qx - px)), (unsigned)(2540*(qy - py)));
    1018 [ #  # ][ #  # ]:          0 :     pDrawPathElement->addAttribute("svg:viewBox", sValue);
                 [ #  # ]
    1019                 :            : 
    1020         [ #  # ]:          0 :     sValue.clear();
    1021 [ #  # ][ #  # ]:          0 :     for(unsigned i = 0; i < path.count(); ++i)
    1022                 :            :     {
    1023         [ #  # ]:          0 :         WPXString sElement;
    1024 [ #  # ][ #  # ]:          0 :         if (path[i]["libwpg:path-action"]->getStr() == "M")
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1025                 :            :         {
    1026                 :            :             // 2540 is 2.54*1000, 2.54 in = 1 inch
    1027 [ #  # ][ #  # ]:          0 :             sElement.sprintf("M%i %i", (unsigned)((path[i]["svg:x"]->getDouble()-px)*2540),
                 [ #  # ]
    1028 [ #  # ][ #  # ]:          0 :                              (unsigned)((path[i]["svg:y"]->getDouble()-py)*2540));
         [ #  # ][ #  # ]
    1029         [ #  # ]:          0 :             sValue.append(sElement);
    1030                 :            :         }
    1031 [ #  # ][ #  # ]:          0 :         else if (path[i]["libwpg:path-action"]->getStr() == "L")
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1032                 :            :         {
    1033 [ #  # ][ #  # ]:          0 :             sElement.sprintf("L%i %i", (unsigned)((path[i]["svg:x"]->getDouble()-px)*2540),
                 [ #  # ]
    1034 [ #  # ][ #  # ]:          0 :                              (unsigned)((path[i]["svg:y"]->getDouble()-py)*2540));
         [ #  # ][ #  # ]
    1035         [ #  # ]:          0 :             sValue.append(sElement);
    1036                 :            :         }
    1037 [ #  # ][ #  # ]:          0 :         else if (path[i]["libwpg:path-action"]->getStr() == "C")
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1038                 :            :         {
    1039 [ #  # ][ #  # ]:          0 :             sElement.sprintf("C%i %i %i %i %i %i", (unsigned)((path[i]["svg:x1"]->getDouble()-px)*2540),
                 [ #  # ]
    1040 [ #  # ][ #  # ]:          0 :                              (unsigned)((path[i]["svg:y1"]->getDouble()-py)*2540), (unsigned)((path[i]["svg:x2"]->getDouble()-px)*2540),
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1041 [ #  # ][ #  # ]:          0 :                              (unsigned)((path[i]["svg:y2"]->getDouble()-py)*2540), (unsigned)((path[i]["svg:x"]->getDouble()-px)*2540),
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1042 [ #  # ][ #  # ]:          0 :                              (unsigned)((path[i]["svg:y"]->getDouble()-py)*2540));
         [ #  # ][ #  # ]
    1043         [ #  # ]:          0 :             sValue.append(sElement);
    1044                 :            :         }
    1045 [ #  # ][ #  # ]:          0 :         else if (path[i]["libwpg:path-action"]->getStr() == "Q")
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1046                 :            :         {
    1047 [ #  # ][ #  # ]:          0 :             sElement.sprintf("Q%i %i %i %i", (unsigned)((path[i]["svg:x1"]->getDouble()-px)*2540),
                 [ #  # ]
    1048 [ #  # ][ #  # ]:          0 :                              (unsigned)((path[i]["svg:y1"]->getDouble()-py)*2540), (unsigned)((path[i]["svg:x"]->getDouble()-px)*2540),
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1049 [ #  # ][ #  # ]:          0 :                              (unsigned)((path[i]["svg:y"]->getDouble()-py)*2540));
         [ #  # ][ #  # ]
    1050         [ #  # ]:          0 :             sValue.append(sElement);
    1051                 :            :         }
    1052 [ #  # ][ #  # ]:          0 :         else if (path[i]["libwpg:path-action"]->getStr() == "A")
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1053                 :            :         {
    1054 [ #  # ][ #  # ]:          0 :             sElement.sprintf("A%i %i %i %i %i %i %i", (unsigned)((path[i]["svg:rx"]->getDouble())*2540),
                 [ #  # ]
    1055 [ #  # ][ #  # ]:          0 :                              (unsigned)((path[i]["svg:ry"]->getDouble())*2540), (path[i]["libwpg:rotate"] ? path[i]["libwpg:rotate"]->getInt() : 0),
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1056 [ #  # ][ #  # ]:          0 :                              (path[i]["libwpg:large-arc"] ? path[i]["libwpg:large-arc"]->getInt() : 1),
         [ #  # ][ #  # ]
    1057 [ #  # ][ #  # ]:          0 :                              (path[i]["libwpg:sweep"] ? path[i]["libwpg:sweep"]->getInt() : 1),
         [ #  # ][ #  # ]
    1058 [ #  # ][ #  # ]:          0 :                              (unsigned)((path[i]["svg:x"]->getDouble()-px)*2540), (unsigned)((path[i]["svg:y"]->getDouble()-py)*2540));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1059         [ #  # ]:          0 :             sValue.append(sElement);
    1060                 :            :         }
    1061 [ #  # ][ #  # ]:          0 :         else if (path[i]["libwpg:path-action"]->getStr() == "Z")
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1062         [ #  # ]:          0 :             sValue.append(" Z");
    1063         [ #  # ]:          0 :     }
    1064 [ #  # ][ #  # ]:          0 :     pDrawPathElement->addAttribute("svg:d", sValue);
                 [ #  # ]
    1065         [ #  # ]:          0 :     mBodyElements.push_back(pDrawPathElement);
    1066 [ #  # ][ #  # ]:          0 :     mBodyElements.push_back(new TagCloseElement("draw:path"));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1067                 :            : }
    1068                 :            : 
    1069                 :          0 : void OdgGenerator::drawPath(const WPXPropertyListVector &path)
    1070                 :            : {
    1071                 :          0 :     mpImpl->_drawPath(path);
    1072                 :          0 : }
    1073                 :            : 
    1074                 :          0 : void OdgGenerator::drawGraphicObject(const ::WPXPropertyList &propList, const ::WPXBinaryData &binaryData)
    1075                 :            : {
    1076 [ #  # ][ #  # ]:          0 :     if (!propList["libwpg:mime-type"] || propList["libwpg:mime-type"]->getStr().len() <= 0)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    1077                 :            :         return;
    1078 [ #  # ][ #  # ]:          0 :     if (!propList["svg:x"] || !propList["svg:y"] || !propList["svg:width"] || !propList["svg:height"])
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1079                 :            :         return;
    1080                 :            : 
    1081 [ #  # ][ #  # ]:          0 :     bool flipX(propList["draw:mirror-horizontal"] && propList["draw:mirror-horizontal"]->getInt());
         [ #  # ][ #  # ]
                 [ #  # ]
    1082 [ #  # ][ #  # ]:          0 :     bool flipY(propList["draw:mirror-vertical"] && propList["draw:mirror-vertical"]->getInt());
         [ #  # ][ #  # ]
                 [ #  # ]
    1083 [ #  # ][ #  # ]:          0 :     if ((flipX && !flipY) || (!flipX && flipY))
         [ #  # ][ #  # ]
    1084         [ #  # ]:          0 :         mpImpl->mxStyle.insert("style:mirror", "horizontal");
    1085                 :            :     else
    1086         [ #  # ]:          0 :         mpImpl->mxStyle.insert("style:mirror", "none");
    1087 [ #  # ][ #  # ]:          0 :     if (propList["draw:color-mode"])
    1088 [ #  # ][ #  # ]:          0 :         mpImpl->mxStyle.insert("draw:color-mode", propList["draw:color-mode"]->getStr());
         [ #  # ][ #  # ]
    1089 [ #  # ][ #  # ]:          0 :     if (propList["draw:luminance"])
    1090 [ #  # ][ #  # ]:          0 :         mpImpl->mxStyle.insert("draw:luminance", propList["draw:luminance"]->getStr());
         [ #  # ][ #  # ]
    1091 [ #  # ][ #  # ]:          0 :     if (propList["draw:contrast"])
    1092 [ #  # ][ #  # ]:          0 :         mpImpl->mxStyle.insert("draw:contrast", propList["draw:contrast"]->getStr());
         [ #  # ][ #  # ]
    1093 [ #  # ][ #  # ]:          0 :     if (propList["draw:gamma"])
    1094 [ #  # ][ #  # ]:          0 :         mpImpl->mxStyle.insert("draw:gamma", propList["draw:gamma"]->getStr());
         [ #  # ][ #  # ]
    1095 [ #  # ][ #  # ]:          0 :     if (propList["draw:red"])
    1096 [ #  # ][ #  # ]:          0 :         mpImpl->mxStyle.insert("draw:red", propList["draw:red"]->getStr());
         [ #  # ][ #  # ]
    1097 [ #  # ][ #  # ]:          0 :     if (propList["draw:green"])
    1098 [ #  # ][ #  # ]:          0 :         mpImpl->mxStyle.insert("draw:green", propList["draw:green"]->getStr());
         [ #  # ][ #  # ]
    1099 [ #  # ][ #  # ]:          0 :     if (propList["draw:blue"])
    1100 [ #  # ][ #  # ]:          0 :         mpImpl->mxStyle.insert("draw:blue", propList["draw:blue"]->getStr());
         [ #  # ][ #  # ]
    1101                 :            : 
    1102                 :            : 
    1103         [ #  # ]:          0 :     mpImpl->_writeGraphicsStyle();
    1104                 :            : 
    1105 [ #  # ][ #  # ]:          0 :     double x = propList["svg:x"]->getDouble();
    1106 [ #  # ][ #  # ]:          0 :     double y = propList["svg:y"]->getDouble();
    1107 [ #  # ][ #  # ]:          0 :     double height = propList["svg:height"]->getDouble();
    1108 [ #  # ][ #  # ]:          0 :     double width = propList["svg:width"]->getDouble();
    1109                 :            : 
    1110         [ #  # ]:          0 :     if (flipY)
    1111                 :            :     {
    1112                 :          0 :         x += width;
    1113                 :          0 :         y += height;
    1114                 :          0 :         width *= -1.0;
    1115                 :          0 :         height *= -1.0;
    1116                 :            :     }
    1117                 :            : 
    1118 [ #  # ][ #  # ]:          0 :     double angle(propList["libwpg:rotate"] ? - M_PI * propList["libwpg:rotate"]->getDouble() / 180.0 : 0.0);
         [ #  # ][ #  # ]
    1119         [ #  # ]:          0 :     if (angle != 0.0)
    1120                 :            :     {
    1121                 :          0 :         double deltax((width*cos(angle)+height*sin(angle)-width)/2.0);
    1122                 :          0 :         double deltay((-width*sin(angle)+height*cos(angle)-height)/2.0);
    1123                 :          0 :         x -= deltax;
    1124                 :          0 :         y -= deltay;
    1125                 :            :     }
    1126                 :            : 
    1127         [ #  # ]:          0 :     WPXPropertyList framePropList;
    1128                 :            : 
    1129         [ #  # ]:          0 :     framePropList.insert("svg:x", x);
    1130         [ #  # ]:          0 :     framePropList.insert("svg:y", y);
    1131         [ #  # ]:          0 :     framePropList.insert("svg:height", height);
    1132         [ #  # ]:          0 :     framePropList.insert("svg:width", width);
    1133                 :            : 
    1134 [ #  # ][ #  # ]:          0 :     TagOpenElement *pDrawFrameElement = new TagOpenElement("draw:frame");
         [ #  # ][ #  # ]
    1135                 :            : 
    1136         [ #  # ]:          0 :     WPXString sValue;
    1137         [ #  # ]:          0 :     sValue.sprintf("gr%i", mpImpl->miGraphicsStyleIndex-1);
    1138 [ #  # ][ #  # ]:          0 :     pDrawFrameElement->addAttribute("draw:style-name", sValue);
                 [ #  # ]
    1139                 :            : 
    1140 [ #  # ][ #  # ]:          0 :     pDrawFrameElement->addAttribute("svg:height", framePropList["svg:height"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1141 [ #  # ][ #  # ]:          0 :     pDrawFrameElement->addAttribute("svg:width", framePropList["svg:width"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1142                 :            : 
    1143         [ #  # ]:          0 :     if (angle != 0.0)
    1144                 :            :     {
    1145         [ #  # ]:          0 :         framePropList.insert("libwpg:rotate", angle, WPX_GENERIC);
    1146                 :            :         sValue.sprintf("rotate (%s) translate(%s, %s)",
    1147         [ #  # ]:          0 :                        framePropList["libwpg:rotate"]->getStr().cstr(),
    1148         [ #  # ]:          0 :                        framePropList["svg:x"]->getStr().cstr(),
    1149 [ #  # ][ #  # ]:          0 :                        framePropList["svg:y"]->getStr().cstr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1150 [ #  # ][ #  # ]:          0 :         pDrawFrameElement->addAttribute("draw:transform", sValue);
                 [ #  # ]
    1151                 :            :     }
    1152                 :            :     else
    1153                 :            :     {
    1154 [ #  # ][ #  # ]:          0 :         pDrawFrameElement->addAttribute("svg:x", framePropList["svg:x"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1155 [ #  # ][ #  # ]:          0 :         pDrawFrameElement->addAttribute("svg:y", framePropList["svg:y"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1156                 :            :     }
    1157         [ #  # ]:          0 :     mpImpl->mBodyElements.push_back(pDrawFrameElement);
    1158                 :            : 
    1159 [ #  # ][ #  # ]:          0 :     if (propList["libwpg:mime-type"]->getStr() == "object/ole")
         [ #  # ][ #  # ]
                 [ #  # ]
    1160 [ #  # ][ #  # ]:          0 :         mpImpl->mBodyElements.push_back(new TagOpenElement("draw:object-ole"));
         [ #  # ][ #  # ]
                 [ #  # ]
    1161                 :            :     else
    1162 [ #  # ][ #  # ]:          0 :         mpImpl->mBodyElements.push_back(new TagOpenElement("draw:image"));
         [ #  # ][ #  # ]
                 [ #  # ]
    1163                 :            : 
    1164 [ #  # ][ #  # ]:          0 :     mpImpl->mBodyElements.push_back(new TagOpenElement("office:binary-data"));
         [ #  # ][ #  # ]
                 [ #  # ]
    1165                 :            : 
    1166         [ #  # ]:          0 :     ::WPXString base64Binary = binaryData.getBase64Data();
    1167 [ #  # ][ #  # ]:          0 :     mpImpl->mBodyElements.push_back(new CharDataElement(base64Binary.cstr()));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1168                 :            : 
    1169 [ #  # ][ #  # ]:          0 :     mpImpl->mBodyElements.push_back(new TagCloseElement("office:binary-data"));
         [ #  # ][ #  # ]
                 [ #  # ]
    1170                 :            : 
    1171 [ #  # ][ #  # ]:          0 :     if (propList["libwpg:mime-type"]->getStr() == "object/ole")
         [ #  # ][ #  # ]
                 [ #  # ]
    1172 [ #  # ][ #  # ]:          0 :         mpImpl->mBodyElements.push_back(new TagCloseElement("draw:object-ole"));
         [ #  # ][ #  # ]
                 [ #  # ]
    1173                 :            :     else
    1174 [ #  # ][ #  # ]:          0 :         mpImpl->mBodyElements.push_back(new TagCloseElement("draw:image"));
         [ #  # ][ #  # ]
                 [ #  # ]
    1175                 :            : 
    1176 [ #  # ][ #  # ]:          0 :     mpImpl->mBodyElements.push_back(new TagCloseElement("draw:frame"));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1177                 :            : }
    1178                 :            : 
    1179                 :          0 : void OdgGeneratorPrivate::_writeGraphicsStyle()
    1180                 :            : {
    1181                 :          0 :     bool bUseOpacityGradient = false;
    1182                 :            : 
    1183 [ #  # ][ #  # ]:          0 :     if (mxStyle["draw:stroke"] && mxStyle["draw:stroke"]->getStr() == "dash")
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    1184                 :            :     {
    1185 [ #  # ][ #  # ]:          0 :         TagOpenElement *pDrawStrokeDashElement = new TagOpenElement("draw:stroke-dash");
         [ #  # ][ #  # ]
    1186         [ #  # ]:          0 :         WPXString sValue;
    1187         [ #  # ]:          0 :         sValue.sprintf("Dash_%i", miDashIndex++);
    1188 [ #  # ][ #  # ]:          0 :         pDrawStrokeDashElement->addAttribute("draw:name", sValue);
                 [ #  # ]
    1189 [ #  # ][ #  # ]:          0 :         if (mxStyle["svg:stoke-linecap"])
    1190 [ #  # ][ #  # ]:          0 :             pDrawStrokeDashElement->addAttribute("draw:style", mxStyle["svg:stroke-linecap"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1191                 :            :         else
    1192 [ #  # ][ #  # ]:          0 :             pDrawStrokeDashElement->addAttribute("draw:style", "rect");
         [ #  # ][ #  # ]
                 [ #  # ]
    1193 [ #  # ][ #  # ]:          0 :         if (mxStyle["draw:distance"])
    1194 [ #  # ][ #  # ]:          0 :             pDrawStrokeDashElement->addAttribute("draw:distance", mxStyle["draw:distance"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1195 [ #  # ][ #  # ]:          0 :         if (mxStyle["draw:dots1"])
    1196 [ #  # ][ #  # ]:          0 :             pDrawStrokeDashElement->addAttribute("draw:dots1", mxStyle["draw:dots1"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1197 [ #  # ][ #  # ]:          0 :         if (mxStyle["draw:dots1-length"])
    1198 [ #  # ][ #  # ]:          0 :             pDrawStrokeDashElement->addAttribute("draw:dots1-length", mxStyle["draw:dots1-length"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1199 [ #  # ][ #  # ]:          0 :         if (mxStyle["draw:dots2"])
    1200 [ #  # ][ #  # ]:          0 :             pDrawStrokeDashElement->addAttribute("draw:dots2", mxStyle["draw:dots2"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1201 [ #  # ][ #  # ]:          0 :         if (mxStyle["draw:dots2-length"])
    1202 [ #  # ][ #  # ]:          0 :             pDrawStrokeDashElement->addAttribute("draw:dots2-length", mxStyle["draw:dots2-length"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1203         [ #  # ]:          0 :         mGraphicsStrokeDashStyles.push_back(pDrawStrokeDashElement);
    1204 [ #  # ][ #  # ]:          0 :         mGraphicsStrokeDashStyles.push_back(new TagCloseElement("draw:stroke-dash"));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1205                 :            :     }
    1206                 :            : 
    1207 [ #  # ][ #  # ]:          0 :     if (mxStyle["draw:marker-start-path"])
    1208                 :            :     {
    1209         [ #  # ]:          0 :         WPXString sValue;
    1210 [ #  # ][ #  # ]:          0 :         TagOpenElement *pDrawMarkerElement = new TagOpenElement("draw:marker");
         [ #  # ][ #  # ]
    1211         [ #  # ]:          0 :         sValue.sprintf("StartMarker_%i", miStartMarkerIndex);
    1212 [ #  # ][ #  # ]:          0 :         pDrawMarkerElement->addAttribute("draw:name", sValue);
                 [ #  # ]
    1213 [ #  # ][ #  # ]:          0 :         if (mxStyle["draw:marker-start-viewbox"])
    1214 [ #  # ][ #  # ]:          0 :             pDrawMarkerElement->addAttribute("svg:viewBox", mxStyle["draw:marker-start-viewbox"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1215 [ #  # ][ #  # ]:          0 :         pDrawMarkerElement->addAttribute("svg:d", mxStyle["draw:marker-start-path"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1216         [ #  # ]:          0 :         mGraphicsMarkerStyles.push_back(pDrawMarkerElement);
    1217 [ #  # ][ #  # ]:          0 :         mGraphicsMarkerStyles.push_back(new TagCloseElement("draw:marker"));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1218                 :            :     }
    1219 [ #  # ][ #  # ]:          0 :     if(mxStyle["draw:marker-end-path"])
    1220                 :            :     {
    1221         [ #  # ]:          0 :         WPXString sValue;
    1222 [ #  # ][ #  # ]:          0 :         TagOpenElement *pDrawMarkerElement = new TagOpenElement("draw:marker");
         [ #  # ][ #  # ]
    1223         [ #  # ]:          0 :         sValue.sprintf("EndMarker_%i", miEndMarkerIndex);
    1224 [ #  # ][ #  # ]:          0 :         pDrawMarkerElement->addAttribute("draw:name", sValue);
                 [ #  # ]
    1225 [ #  # ][ #  # ]:          0 :         if (mxStyle["draw:marker-end-viewbox"])
    1226 [ #  # ][ #  # ]:          0 :             pDrawMarkerElement->addAttribute("svg:viewBox", mxStyle["draw:marker-end-viewbox"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1227 [ #  # ][ #  # ]:          0 :         pDrawMarkerElement->addAttribute("svg:d", mxStyle["draw:marker-end-path"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1228         [ #  # ]:          0 :         mGraphicsMarkerStyles.push_back(pDrawMarkerElement);
    1229 [ #  # ][ #  # ]:          0 :         mGraphicsMarkerStyles.push_back(new TagCloseElement("draw:marker"));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1230                 :            :     }
    1231                 :            : 
    1232 [ #  # ][ #  # ]:          0 :     if(mxStyle["draw:fill"] && mxStyle["draw:fill"]->getStr() == "gradient")
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    1233                 :            :     {
    1234 [ #  # ][ #  # ]:          0 :         TagOpenElement *pDrawGradientElement = new TagOpenElement("draw:gradient");
         [ #  # ][ #  # ]
    1235 [ #  # ][ #  # ]:          0 :         TagOpenElement *pDrawOpacityElement = new TagOpenElement("draw:opacity");
         [ #  # ][ #  # ]
    1236 [ #  # ][ #  # ]:          0 :         if (mxStyle["draw:style"])
    1237                 :            :         {
    1238 [ #  # ][ #  # ]:          0 :             pDrawGradientElement->addAttribute("draw:style", mxStyle["draw:style"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1239 [ #  # ][ #  # ]:          0 :             pDrawOpacityElement->addAttribute("draw:style", mxStyle["draw:style"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1240                 :            :         }
    1241                 :            :         else
    1242                 :            :         {
    1243 [ #  # ][ #  # ]:          0 :             pDrawGradientElement->addAttribute("draw:style", "linear");
         [ #  # ][ #  # ]
                 [ #  # ]
    1244 [ #  # ][ #  # ]:          0 :             pDrawOpacityElement->addAttribute("draw:style", "linear");
         [ #  # ][ #  # ]
                 [ #  # ]
    1245                 :            :         }
    1246         [ #  # ]:          0 :         WPXString sValue;
    1247         [ #  # ]:          0 :         sValue.sprintf("Gradient_%i", miGradientIndex);
    1248 [ #  # ][ #  # ]:          0 :         pDrawGradientElement->addAttribute("draw:name", sValue);
                 [ #  # ]
    1249         [ #  # ]:          0 :         sValue.sprintf("Transparency_%i", miGradientIndex++);
    1250 [ #  # ][ #  # ]:          0 :         pDrawOpacityElement->addAttribute("draw:name", sValue);
                 [ #  # ]
    1251                 :            : 
    1252                 :            :         // ODG angle unit is 0.1 degree
    1253 [ #  # ][ #  # ]:          0 :         double angle = mxStyle["draw:angle"] ? mxStyle["draw:angle"]->getDouble() : 0.0;
         [ #  # ][ #  # ]
    1254         [ #  # ]:          0 :         while(angle < 0)
    1255                 :          0 :             angle += 360;
    1256         [ #  # ]:          0 :         while(angle > 360)
    1257                 :          0 :             angle -= 360;
    1258         [ #  # ]:          0 :         sValue.sprintf("%i", (unsigned)(angle*10));
    1259 [ #  # ][ #  # ]:          0 :         pDrawGradientElement->addAttribute("draw:angle", sValue);
                 [ #  # ]
    1260 [ #  # ][ #  # ]:          0 :         pDrawOpacityElement->addAttribute("draw:angle", sValue);
                 [ #  # ]
    1261                 :            : 
    1262 [ #  # ][ #  # ]:          0 :         if (!mxGradient.count())
    1263                 :            :         {
    1264 [ #  # ][ #  # ]:          0 :             if (mxStyle["draw:start-color"])
    1265 [ #  # ][ #  # ]:          0 :                 pDrawGradientElement->addAttribute("draw:start-color", mxStyle["draw:start-color"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1266 [ #  # ][ #  # ]:          0 :             if (mxStyle["draw:end-color"])
    1267 [ #  # ][ #  # ]:          0 :                 pDrawGradientElement->addAttribute("draw:end-color", mxStyle["draw:end-color"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1268                 :            : 
    1269 [ #  # ][ #  # ]:          0 :             if (mxStyle["draw:border"])
    1270                 :            :             {
    1271 [ #  # ][ #  # ]:          0 :                 pDrawGradientElement->addAttribute("draw:border", mxStyle["draw:border"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1272 [ #  # ][ #  # ]:          0 :                 pDrawOpacityElement->addAttribute("draw:border", mxStyle["draw:border"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1273                 :            :             }
    1274                 :            :             else
    1275                 :            :             {
    1276 [ #  # ][ #  # ]:          0 :                 pDrawGradientElement->addAttribute("draw:border", "0%");
         [ #  # ][ #  # ]
                 [ #  # ]
    1277 [ #  # ][ #  # ]:          0 :                 pDrawOpacityElement->addAttribute("draw:border", "0%");
         [ #  # ][ #  # ]
                 [ #  # ]
    1278                 :            :             }
    1279                 :            : 
    1280 [ #  # ][ #  # ]:          0 :             if (mxStyle["svg:cx"])
    1281                 :            :             {
    1282 [ #  # ][ #  # ]:          0 :                 pDrawGradientElement->addAttribute("draw:cx", mxStyle["svg:cx"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1283 [ #  # ][ #  # ]:          0 :                 pDrawOpacityElement->addAttribute("draw:cx", mxStyle["svg:cx"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1284                 :            :             }
    1285 [ #  # ][ #  # ]:          0 :             else if (mxStyle["draw:cx"])
    1286                 :            :             {
    1287 [ #  # ][ #  # ]:          0 :                 pDrawGradientElement->addAttribute("draw:cx", mxStyle["draw:cx"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1288 [ #  # ][ #  # ]:          0 :                 pDrawOpacityElement->addAttribute("draw:cx", mxStyle["draw:cx"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1289                 :            :             }
    1290                 :            : 
    1291 [ #  # ][ #  # ]:          0 :             if (mxStyle["svg:cy"])
    1292                 :            :             {
    1293 [ #  # ][ #  # ]:          0 :                 pDrawGradientElement->addAttribute("draw:cy", mxStyle["svg:cy"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1294 [ #  # ][ #  # ]:          0 :                 pDrawOpacityElement->addAttribute("draw:cy", mxStyle["svg:cy"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1295                 :            :             }
    1296 [ #  # ][ #  # ]:          0 :             else if (mxStyle["draw:cx"])
    1297                 :            :             {
    1298 [ #  # ][ #  # ]:          0 :                 pDrawGradientElement->addAttribute("draw:cx", mxStyle["svg:cx"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1299 [ #  # ][ #  # ]:          0 :                 pDrawOpacityElement->addAttribute("draw:cx", mxStyle["svg:cx"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1300                 :            :             }
    1301                 :            : 
    1302 [ #  # ][ #  # ]:          0 :             if (mxStyle["draw:start-intensity"])
    1303 [ #  # ][ #  # ]:          0 :                 pDrawGradientElement->addAttribute("draw:start-intensity", mxStyle["draw:start-intensity"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1304                 :            :             else
    1305 [ #  # ][ #  # ]:          0 :                 pDrawGradientElement->addAttribute("draw:start-intensity", "100%");
         [ #  # ][ #  # ]
                 [ #  # ]
    1306                 :            : 
    1307 [ #  # ][ #  # ]:          0 :             if (mxStyle["draw:end-intensity"])
    1308 [ #  # ][ #  # ]:          0 :                 pDrawGradientElement->addAttribute("draw:end-intensity", mxStyle["draw:end-intensity"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1309                 :            :             else
    1310 [ #  # ][ #  # ]:          0 :                 pDrawGradientElement->addAttribute("draw:end-intensity", "100%");
         [ #  # ][ #  # ]
                 [ #  # ]
    1311                 :            : 
    1312 [ #  # ][ #  # ]:          0 :             if (mxStyle["libwpg:start-opacity"])
    1313 [ #  # ][ #  # ]:          0 :                 pDrawOpacityElement->addAttribute("draw:start", mxStyle["libwpg:start-opacity"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1314                 :            :             else
    1315 [ #  # ][ #  # ]:          0 :                 pDrawOpacityElement->addAttribute("draw:start", "100%");
         [ #  # ][ #  # ]
                 [ #  # ]
    1316                 :            : 
    1317 [ #  # ][ #  # ]:          0 :             if (mxStyle["libwpg:end-opacity"])
    1318 [ #  # ][ #  # ]:          0 :                 pDrawOpacityElement->addAttribute("draw:end", mxStyle["libwpg:end-opacity"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1319                 :            :             else
    1320 [ #  # ][ #  # ]:          0 :                 pDrawOpacityElement->addAttribute("draw:end", "100%");
         [ #  # ][ #  # ]
                 [ #  # ]
    1321                 :            : 
    1322         [ #  # ]:          0 :             mGraphicsGradientStyles.push_back(pDrawGradientElement);
    1323 [ #  # ][ #  # ]:          0 :             mGraphicsGradientStyles.push_back(new TagCloseElement("draw:gradient"));
         [ #  # ][ #  # ]
                 [ #  # ]
    1324                 :            : 
    1325                 :            :             // Work around a mess in LibreOffice where both opacities of 100% are interpreted as complete transparency
    1326                 :            :             // Nevertheless, when one is different, immediately, they are interpreted correctly
    1327 [ #  # ][ #  # ]:          0 :             if (mxStyle["libwpg:start-opacity"] && mxStyle["libwpg:end-opacity"]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1328 [ #  # ][ #  # ]:          0 :                     && (mxStyle["libwpg:start-opacity"]->getDouble() != 1.0 || mxStyle["libwpg:end-opacity"]->getDouble() != 1.0))
         [ #  # ][ #  # ]
    1329                 :            :             {
    1330                 :          0 :                 bUseOpacityGradient = true;
    1331         [ #  # ]:          0 :                 mGraphicsGradientStyles.push_back(pDrawOpacityElement);
    1332 [ #  # ][ #  # ]:          0 :                 mGraphicsGradientStyles.push_back(new TagCloseElement("draw:opacity"));
         [ #  # ][ #  # ]
                 [ #  # ]
    1333                 :            :             }
    1334                 :            :         }
    1335 [ #  # ][ #  # ]:          0 :         else if(mxGradient.count() >= 2)
    1336                 :            :         {
    1337         [ #  # ]:          0 :             sValue.sprintf("%i", (unsigned)(angle*10));
    1338 [ #  # ][ #  # ]:          0 :             pDrawGradientElement->addAttribute("draw:angle", sValue);
                 [ #  # ]
    1339                 :            : 
    1340 [ #  # ][ #  # ]:          0 :             pDrawGradientElement->addAttribute("draw:start-color", mxGradient[1]["svg:stop-color"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1341 [ #  # ][ #  # ]:          0 :             pDrawGradientElement->addAttribute("draw:end-color", mxGradient[0]["svg:stop-color"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1342 [ #  # ][ #  # ]:          0 :             if (mxStyle["svg:cx"])
    1343 [ #  # ][ #  # ]:          0 :                 pDrawGradientElement->addAttribute("draw:cx", mxStyle["svg:cx"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1344 [ #  # ][ #  # ]:          0 :             if (mxStyle["svg:cy"])
    1345 [ #  # ][ #  # ]:          0 :                 pDrawGradientElement->addAttribute("draw:cy", mxStyle["svg:cy"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1346 [ #  # ][ #  # ]:          0 :             if (mxGradient[1]["svg:stop-opacity"])
                 [ #  # ]
    1347                 :            :             {
    1348 [ #  # ][ #  # ]:          0 :                 pDrawOpacityElement->addAttribute("draw:start", mxGradient[1]["svg:stop-opacity"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1349                 :          0 :                 bUseOpacityGradient = true;
    1350                 :            :             }
    1351                 :            :             else
    1352 [ #  # ][ #  # ]:          0 :                 pDrawOpacityElement->addAttribute("draw:start", "100%");
         [ #  # ][ #  # ]
                 [ #  # ]
    1353 [ #  # ][ #  # ]:          0 :             if (mxGradient[0]["svg:stop-opacity"])
                 [ #  # ]
    1354                 :            :             {
    1355 [ #  # ][ #  # ]:          0 :                 pDrawOpacityElement->addAttribute("draw:end", mxGradient[0]["svg:stop-opacity"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1356                 :          0 :                 bUseOpacityGradient = true;
    1357                 :            :             }
    1358                 :            :             else
    1359 [ #  # ][ #  # ]:          0 :                 pDrawOpacityElement->addAttribute("draw:end", "100%");
         [ #  # ][ #  # ]
                 [ #  # ]
    1360 [ #  # ][ #  # ]:          0 :             pDrawGradientElement->addAttribute("draw:border", "0%");
         [ #  # ][ #  # ]
                 [ #  # ]
    1361         [ #  # ]:          0 :             mGraphicsGradientStyles.push_back(pDrawGradientElement);
    1362 [ #  # ][ #  # ]:          0 :             mGraphicsGradientStyles.push_back(new TagCloseElement("draw:gradient"));
         [ #  # ][ #  # ]
                 [ #  # ]
    1363         [ #  # ]:          0 :             if (bUseOpacityGradient)
    1364                 :            :             {
    1365         [ #  # ]:          0 :                 mGraphicsGradientStyles.push_back(pDrawOpacityElement);
    1366 [ #  # ][ #  # ]:          0 :                 mGraphicsGradientStyles.push_back(new TagCloseElement("draw:opacity"));
         [ #  # ][ #  # ]
                 [ #  # ]
    1367                 :            :             }
    1368                 :            :         }
    1369                 :            : 
    1370         [ #  # ]:          0 :         if(!bUseOpacityGradient)
    1371 [ #  # ][ #  # ]:          0 :             delete pDrawOpacityElement;
                 [ #  # ]
    1372                 :            :     }
    1373                 :            : 
    1374 [ #  # ][ #  # ]:          0 :     if(mxStyle["draw:fill"] && mxStyle["draw:fill"]->getStr() == "bitmap" &&
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    1375 [ #  # ][ #  # ]:          0 :             mxStyle["draw:fill-image"] && mxStyle["libwpg:mime-type"])
    1376                 :            :     {
    1377 [ #  # ][ #  # ]:          0 :         TagOpenElement *pDrawBitmapElement = new TagOpenElement("draw:fill-image");
         [ #  # ][ #  # ]
    1378         [ #  # ]:          0 :         WPXString sValue;
    1379         [ #  # ]:          0 :         sValue.sprintf("Bitmap_%i", miBitmapIndex++);
    1380 [ #  # ][ #  # ]:          0 :         pDrawBitmapElement->addAttribute("draw:name", sValue);
                 [ #  # ]
    1381         [ #  # ]:          0 :         mGraphicsBitmapStyles.push_back(pDrawBitmapElement);
    1382 [ #  # ][ #  # ]:          0 :         mGraphicsBitmapStyles.push_back(new TagOpenElement("office:binary-data"));
         [ #  # ][ #  # ]
                 [ #  # ]
    1383 [ #  # ][ #  # ]:          0 :         mGraphicsBitmapStyles.push_back(new CharDataElement(mxStyle["draw:fill-image"]->getStr()));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1384 [ #  # ][ #  # ]:          0 :         mGraphicsBitmapStyles.push_back(new TagCloseElement("office:binary-data"));
         [ #  # ][ #  # ]
                 [ #  # ]
    1385 [ #  # ][ #  # ]:          0 :         mGraphicsBitmapStyles.push_back(new TagCloseElement("draw:fill-image"));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1386                 :            :     }
    1387                 :            : 
    1388 [ #  # ][ #  # ]:          0 :     TagOpenElement *pStyleStyleElement = new TagOpenElement("style:style");
         [ #  # ][ #  # ]
    1389         [ #  # ]:          0 :     WPXString sValue;
    1390         [ #  # ]:          0 :     sValue.sprintf("gr%i",  miGraphicsStyleIndex);
    1391 [ #  # ][ #  # ]:          0 :     pStyleStyleElement->addAttribute("style:name", sValue);
                 [ #  # ]
    1392 [ #  # ][ #  # ]:          0 :     pStyleStyleElement->addAttribute("style:family", "graphic");
         [ #  # ][ #  # ]
                 [ #  # ]
    1393 [ #  # ][ #  # ]:          0 :     pStyleStyleElement->addAttribute("style:parent-style-name", "standard");
         [ #  # ][ #  # ]
                 [ #  # ]
    1394         [ #  # ]:          0 :     mGraphicsAutomaticStyles.push_back(pStyleStyleElement);
    1395                 :            : 
    1396 [ #  # ][ #  # ]:          0 :     TagOpenElement *pStyleGraphicsPropertiesElement = new TagOpenElement("style:graphic-properties");
         [ #  # ][ #  # ]
    1397                 :            : 
    1398 [ #  # ][ #  # ]:          0 :     if (mxStyle["draw:color-mode"] && mxStyle["draw:color-mode"]->getStr().len() > 0)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    1399 [ #  # ][ #  # ]:          0 :         pStyleGraphicsPropertiesElement->addAttribute("draw:color-mode", mxStyle["draw:color-mode"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1400 [ #  # ][ #  # ]:          0 :     if (mxStyle["draw:luminance"] && mxStyle["draw:luminance"]->getStr().len() > 0)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    1401 [ #  # ][ #  # ]:          0 :         pStyleGraphicsPropertiesElement->addAttribute("draw:luminance", mxStyle["draw:luminance"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1402 [ #  # ][ #  # ]:          0 :     if (mxStyle["draw:contrast"] && mxStyle["draw:contrast"]->getStr().len() > 0)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    1403 [ #  # ][ #  # ]:          0 :         pStyleGraphicsPropertiesElement->addAttribute("draw:contrast", mxStyle["draw:contrast"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1404 [ #  # ][ #  # ]:          0 :     if (mxStyle["draw:gamma"] && mxStyle["draw:gamma"]->getStr().len() > 0)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    1405 [ #  # ][ #  # ]:          0 :         pStyleGraphicsPropertiesElement->addAttribute("draw:gamma", mxStyle["draw:gamma"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1406 [ #  # ][ #  # ]:          0 :     if (mxStyle["draw:red"] && mxStyle["draw:red"]->getStr().len() > 0)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    1407 [ #  # ][ #  # ]:          0 :         pStyleGraphicsPropertiesElement->addAttribute("draw:red", mxStyle["draw:red"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1408 [ #  # ][ #  # ]:          0 :     if (mxStyle["draw:green"] && mxStyle["draw:green"]->getStr().len() > 0)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    1409 [ #  # ][ #  # ]:          0 :         pStyleGraphicsPropertiesElement->addAttribute("draw:green", mxStyle["draw:green"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1410 [ #  # ][ #  # ]:          0 :     if (mxStyle["draw:blue"] && mxStyle["draw:blue"]->getStr().len() > 0)
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    1411 [ #  # ][ #  # ]:          0 :         pStyleGraphicsPropertiesElement->addAttribute("draw:blue", mxStyle["draw:blue"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1412                 :            : 
    1413 [ #  # ][ #  # ]:          0 :     if (mxStyle["draw:stroke"] && mxStyle["draw:stroke"]->getStr() == "none")
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    1414 [ #  # ][ #  # ]:          0 :         pStyleGraphicsPropertiesElement->addAttribute("draw:stroke", "none");
         [ #  # ][ #  # ]
                 [ #  # ]
    1415                 :            :     else
    1416                 :            :     {
    1417 [ #  # ][ #  # ]:          0 :         if (mxStyle["svg:stroke-width"])
    1418 [ #  # ][ #  # ]:          0 :             pStyleGraphicsPropertiesElement->addAttribute("svg:stroke-width", mxStyle["svg:stroke-width"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1419                 :            : 
    1420 [ #  # ][ #  # ]:          0 :         if (mxStyle["svg:stroke-color"])
    1421 [ #  # ][ #  # ]:          0 :             pStyleGraphicsPropertiesElement->addAttribute("svg:stroke-color", mxStyle["svg:stroke-color"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1422                 :            : 
    1423 [ #  # ][ #  # ]:          0 :         if (mxStyle["svg:stroke-opacity"])
    1424 [ #  # ][ #  # ]:          0 :             pStyleGraphicsPropertiesElement->addAttribute("svg:stroke-opacity", mxStyle["svg:stroke-opacity"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1425                 :            : 
    1426 [ #  # ][ #  # ]:          0 :         if (mxStyle["svg:stroke-linejoin"])
    1427 [ #  # ][ #  # ]:          0 :             pStyleGraphicsPropertiesElement->addAttribute("draw:stroke-linejoin", mxStyle["svg:stroke-linejoin"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1428                 :            : 
    1429 [ #  # ][ #  # ]:          0 :         if (mxStyle["svg:stroke-linecap"])
    1430 [ #  # ][ #  # ]:          0 :             pStyleGraphicsPropertiesElement->addAttribute("svg:stoke-linecap", mxStyle["svg:stroke-linecap"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1431                 :            : 
    1432 [ #  # ][ #  # ]:          0 :         if (mxStyle["draw:stroke"] && mxStyle["draw:stroke"]->getStr() == "dash")
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    1433                 :            :         {
    1434 [ #  # ][ #  # ]:          0 :             pStyleGraphicsPropertiesElement->addAttribute("draw:stroke", "dash");
         [ #  # ][ #  # ]
                 [ #  # ]
    1435         [ #  # ]:          0 :             sValue.sprintf("Dash_%i", miDashIndex-1);
    1436 [ #  # ][ #  # ]:          0 :             pStyleGraphicsPropertiesElement->addAttribute("draw:stroke-dash", sValue);
                 [ #  # ]
    1437                 :            :         }
    1438                 :            :         else
    1439 [ #  # ][ #  # ]:          0 :             pStyleGraphicsPropertiesElement->addAttribute("draw:stroke", "solid");
         [ #  # ][ #  # ]
                 [ #  # ]
    1440                 :            :     }
    1441                 :            : 
    1442 [ #  # ][ #  # ]:          0 :     if(mxStyle["draw:fill"] && mxStyle["draw:fill"]->getStr() == "none")
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    1443 [ #  # ][ #  # ]:          0 :         pStyleGraphicsPropertiesElement->addAttribute("draw:fill", "none");
         [ #  # ][ #  # ]
                 [ #  # ]
    1444                 :            :     else
    1445                 :            :     {
    1446 [ #  # ][ #  # ]:          0 :         if (mxStyle["draw:shadow"])
    1447 [ #  # ][ #  # ]:          0 :             pStyleGraphicsPropertiesElement->addAttribute("draw:shadow", mxStyle["draw:shadow"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1448                 :            :         else
    1449 [ #  # ][ #  # ]:          0 :             pStyleGraphicsPropertiesElement->addAttribute("draw:shadow", "hidden");
         [ #  # ][ #  # ]
                 [ #  # ]
    1450 [ #  # ][ #  # ]:          0 :         if (mxStyle["draw:shadow-offset-x"])
    1451 [ #  # ][ #  # ]:          0 :             pStyleGraphicsPropertiesElement->addAttribute("draw:shadow-offset-x", mxStyle["draw:shadow-offset-x"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1452 [ #  # ][ #  # ]:          0 :         if (mxStyle["draw:shadow-offset-y"])
    1453 [ #  # ][ #  # ]:          0 :             pStyleGraphicsPropertiesElement->addAttribute("draw:shadow-offset-y", mxStyle["draw:shadow-offset-y"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1454 [ #  # ][ #  # ]:          0 :         if (mxStyle["draw:shadow-color"])
    1455 [ #  # ][ #  # ]:          0 :             pStyleGraphicsPropertiesElement->addAttribute("draw:shadow-color", mxStyle["draw:shadow-color"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1456 [ #  # ][ #  # ]:          0 :         if (mxStyle["draw:shadow-opacity"])
    1457 [ #  # ][ #  # ]:          0 :             pStyleGraphicsPropertiesElement->addAttribute("draw:shadow-opacity", mxStyle["draw:shadow-opacity"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1458 [ #  # ][ #  # ]:          0 :         if (mxStyle["svg:fill-rule"])
    1459 [ #  # ][ #  # ]:          0 :             pStyleGraphicsPropertiesElement->addAttribute("svg:fill-rule", mxStyle["svg:fill-rule"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1460                 :            :     }
    1461                 :            : 
    1462 [ #  # ][ #  # ]:          0 :     if(mxStyle["draw:fill"] && mxStyle["draw:fill"]->getStr() == "solid")
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    1463                 :            :     {
    1464 [ #  # ][ #  # ]:          0 :         pStyleGraphicsPropertiesElement->addAttribute("draw:fill", "solid");
         [ #  # ][ #  # ]
                 [ #  # ]
    1465 [ #  # ][ #  # ]:          0 :         if (mxStyle["draw:fill-color"])
    1466 [ #  # ][ #  # ]:          0 :             pStyleGraphicsPropertiesElement->addAttribute("draw:fill-color", mxStyle["draw:fill-color"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1467 [ #  # ][ #  # ]:          0 :         if (mxStyle["draw:opacity"])
    1468 [ #  # ][ #  # ]:          0 :             pStyleGraphicsPropertiesElement->addAttribute("draw:opacity", mxStyle["draw:opacity"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1469                 :            :     }
    1470                 :            : 
    1471 [ #  # ][ #  # ]:          0 :     if(mxStyle["draw:fill"] && mxStyle["draw:fill"]->getStr() == "gradient")
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    1472                 :            :     {
    1473 [ #  # ][ #  # ]:          0 :         if (!mxGradient.count() || mxGradient.count() >= 2)
         [ #  # ][ #  # ]
                 [ #  # ]
    1474                 :            :         {
    1475 [ #  # ][ #  # ]:          0 :             pStyleGraphicsPropertiesElement->addAttribute("draw:fill", "gradient");
         [ #  # ][ #  # ]
                 [ #  # ]
    1476         [ #  # ]:          0 :             sValue.sprintf("Gradient_%i", miGradientIndex-1);
    1477 [ #  # ][ #  # ]:          0 :             pStyleGraphicsPropertiesElement->addAttribute("draw:fill-gradient-name", sValue);
                 [ #  # ]
    1478         [ #  # ]:          0 :             if (bUseOpacityGradient)
    1479                 :            :             {
    1480         [ #  # ]:          0 :                 sValue.sprintf("Transparency_%i", miGradientIndex-1);
    1481 [ #  # ][ #  # ]:          0 :                 pStyleGraphicsPropertiesElement->addAttribute("draw:opacity-name", sValue);
                 [ #  # ]
    1482                 :            :             }
    1483                 :            :         }
    1484                 :            :         else
    1485                 :            :         {
    1486 [ #  # ][ #  # ]:          0 :             if (mxGradient[0]["svg:stop-color"])
                 [ #  # ]
    1487                 :            :             {
    1488 [ #  # ][ #  # ]:          0 :                 pStyleGraphicsPropertiesElement->addAttribute("draw:fill", "solid");
         [ #  # ][ #  # ]
                 [ #  # ]
    1489 [ #  # ][ #  # ]:          0 :                 pStyleGraphicsPropertiesElement->addAttribute("draw:fill-color", mxGradient[0]["svg:stop-color"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1490                 :            :             }
    1491                 :            :             else
    1492 [ #  # ][ #  # ]:          0 :                 pStyleGraphicsPropertiesElement->addAttribute("draw:fill", "solid");
         [ #  # ][ #  # ]
                 [ #  # ]
    1493                 :            :         }
    1494                 :            :     }
    1495                 :            : 
    1496 [ #  # ][ #  # ]:          0 :     if(mxStyle["draw:fill"] && mxStyle["draw:fill"]->getStr() == "bitmap")
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    1497                 :            :     {
    1498 [ #  # ][ #  # ]:          0 :         if (mxStyle["draw:fill-image"] && mxStyle["libwpg:mime-type"])
         [ #  # ][ #  # ]
                 [ #  # ]
    1499                 :            :         {
    1500 [ #  # ][ #  # ]:          0 :             pStyleGraphicsPropertiesElement->addAttribute("draw:fill", "bitmap");
         [ #  # ][ #  # ]
                 [ #  # ]
    1501         [ #  # ]:          0 :             sValue.sprintf("Bitmap_%i", miBitmapIndex-1);
    1502 [ #  # ][ #  # ]:          0 :             pStyleGraphicsPropertiesElement->addAttribute("draw:fill-image-name", sValue);
                 [ #  # ]
    1503 [ #  # ][ #  # ]:          0 :             if (mxStyle["svg:width"])
    1504 [ #  # ][ #  # ]:          0 :                 pStyleGraphicsPropertiesElement->addAttribute("draw:fill-image-width", mxStyle["svg:width"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1505 [ #  # ][ #  # ]:          0 :             if (mxStyle["svg:height"])
    1506 [ #  # ][ #  # ]:          0 :                 pStyleGraphicsPropertiesElement->addAttribute("draw:fill-image-height", mxStyle["svg:height"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1507 [ #  # ][ #  # ]:          0 :             if (mxStyle["style:repeat"])
    1508 [ #  # ][ #  # ]:          0 :                 pStyleGraphicsPropertiesElement->addAttribute("style:repeat", mxStyle["style:repeat"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1509 [ #  # ][ #  # ]:          0 :             if (mxStyle["draw:fill-image-ref-point"])
    1510 [ #  # ][ #  # ]:          0 :                 pStyleGraphicsPropertiesElement->addAttribute("draw:fill-image-ref-point", mxStyle["draw:fill-image-ref-point"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1511 [ #  # ][ #  # ]:          0 :             if (mxStyle["draw:fill-image-ref-point-x"])
    1512 [ #  # ][ #  # ]:          0 :                 pStyleGraphicsPropertiesElement->addAttribute("draw:fill-image-ref-point-x", mxStyle["draw:fill-image-ref-point-x"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1513 [ #  # ][ #  # ]:          0 :             if (mxStyle["draw:fill-image-ref-point-y"])
    1514 [ #  # ][ #  # ]:          0 :                 pStyleGraphicsPropertiesElement->addAttribute("draw:fill-image-ref-point-y", mxStyle["draw:fill-image-ref-point-y"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1515                 :            :         }
    1516                 :            :         else
    1517 [ #  # ][ #  # ]:          0 :             pStyleGraphicsPropertiesElement->addAttribute("draw:fill", "none");
         [ #  # ][ #  # ]
                 [ #  # ]
    1518                 :            :     }
    1519                 :            : 
    1520                 :            : 
    1521 [ #  # ][ #  # ]:          0 :     if(mxStyle["draw:marker-start-path"])
    1522                 :            :     {
    1523         [ #  # ]:          0 :         sValue.sprintf("StartMarker_%i", miStartMarkerIndex++);
    1524 [ #  # ][ #  # ]:          0 :         pStyleGraphicsPropertiesElement->addAttribute("draw:marker-start", sValue);
                 [ #  # ]
    1525 [ #  # ][ #  # ]:          0 :         if (mxStyle["draw:marker-start-width"])
    1526 [ #  # ][ #  # ]:          0 :             pStyleGraphicsPropertiesElement->addAttribute("draw:marker-start-width", mxStyle["draw:marker-start-width"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1527                 :            :         else
    1528 [ #  # ][ #  # ]:          0 :             pStyleGraphicsPropertiesElement->addAttribute("draw:marker-start-width", "0.118in");
         [ #  # ][ #  # ]
                 [ #  # ]
    1529                 :            :     }
    1530 [ #  # ][ #  # ]:          0 :     if (mxStyle["draw:marker-end-path"])
    1531                 :            :     {
    1532         [ #  # ]:          0 :         sValue.sprintf("EndMarker_%i", miEndMarkerIndex++);
    1533 [ #  # ][ #  # ]:          0 :         pStyleGraphicsPropertiesElement->addAttribute("draw:marker-end", sValue);
                 [ #  # ]
    1534 [ #  # ][ #  # ]:          0 :         if (mxStyle["draw:marker-end-width"])
    1535 [ #  # ][ #  # ]:          0 :             pStyleGraphicsPropertiesElement->addAttribute("draw:marker-end-width", mxStyle["draw:marker-end-width"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1536                 :            :         else
    1537 [ #  # ][ #  # ]:          0 :             pStyleGraphicsPropertiesElement->addAttribute("draw:marker-end-width", "0.118in");
         [ #  # ][ #  # ]
                 [ #  # ]
    1538                 :            :     }
    1539 [ #  # ][ #  # ]:          0 :     if (mxStyle["style:mirror"])
    1540 [ #  # ][ #  # ]:          0 :         pStyleGraphicsPropertiesElement->addAttribute("style:mirror", mxStyle["style:mirror"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1541                 :            : 
    1542         [ #  # ]:          0 :     mGraphicsAutomaticStyles.push_back(pStyleGraphicsPropertiesElement);
    1543 [ #  # ][ #  # ]:          0 :     mGraphicsAutomaticStyles.push_back(new TagCloseElement("style:graphic-properties"));
         [ #  # ][ #  # ]
                 [ #  # ]
    1544                 :            : 
    1545 [ #  # ][ #  # ]:          0 :     mGraphicsAutomaticStyles.push_back(new TagCloseElement("style:style"));
         [ #  # ][ #  # ]
                 [ #  # ]
    1546         [ #  # ]:          0 :     miGraphicsStyleIndex++;
    1547                 :          0 : }
    1548                 :            : 
    1549                 :          0 : void OdgGenerator::startEmbeddedGraphics(const WPXPropertyList &)
    1550                 :            : {
    1551                 :          0 : }
    1552                 :            : 
    1553                 :          0 : void OdgGenerator::endEmbeddedGraphics()
    1554                 :            : {
    1555                 :          0 : }
    1556                 :            : 
    1557                 :          0 : void OdgGenerator::startTextObject(const WPXPropertyList &propList, const WPXPropertyListVector &)
    1558                 :            : {
    1559 [ #  # ][ #  # ]:          0 :     TagOpenElement *pDrawFrameOpenElement = new TagOpenElement("draw:frame");
         [ #  # ][ #  # ]
    1560 [ #  # ][ #  # ]:          0 :     TagOpenElement *pStyleStyleOpenElement = new TagOpenElement("style:style");
         [ #  # ][ #  # ]
    1561                 :            : 
    1562         [ #  # ]:          0 :     WPXString sValue;
    1563         [ #  # ]:          0 :     sValue.sprintf("gr%i",  mpImpl->miGraphicsStyleIndex++);
    1564 [ #  # ][ #  # ]:          0 :     pStyleStyleOpenElement->addAttribute("style:name", sValue);
                 [ #  # ]
    1565 [ #  # ][ #  # ]:          0 :     pStyleStyleOpenElement->addAttribute("style:family", "graphic");
         [ #  # ][ #  # ]
                 [ #  # ]
    1566 [ #  # ][ #  # ]:          0 :     pStyleStyleOpenElement->addAttribute("style:parent-style-name", "standard");
         [ #  # ][ #  # ]
                 [ #  # ]
    1567         [ #  # ]:          0 :     mpImpl->mGraphicsAutomaticStyles.push_back(pStyleStyleOpenElement);
    1568                 :            : 
    1569 [ #  # ][ #  # ]:          0 :     pDrawFrameOpenElement->addAttribute("draw:style-name", sValue);
                 [ #  # ]
    1570 [ #  # ][ #  # ]:          0 :     pDrawFrameOpenElement->addAttribute("draw:layer", "layout");
         [ #  # ][ #  # ]
                 [ #  # ]
    1571                 :            : 
    1572 [ #  # ][ #  # ]:          0 :     TagOpenElement *pStyleGraphicPropertiesOpenElement = new TagOpenElement("style:graphic-properties");
         [ #  # ][ #  # ]
    1573 [ #  # ][ #  # ]:          0 :     pStyleGraphicPropertiesOpenElement->addAttribute("draw:stroke", "none");
         [ #  # ][ #  # ]
                 [ #  # ]
    1574 [ #  # ][ #  # ]:          0 :     pStyleGraphicPropertiesOpenElement->addAttribute("svg:stroke-color", "#000000");
         [ #  # ][ #  # ]
                 [ #  # ]
    1575 [ #  # ][ #  # ]:          0 :     pStyleGraphicPropertiesOpenElement->addAttribute("draw:fill", "none");
         [ #  # ][ #  # ]
                 [ #  # ]
    1576 [ #  # ][ #  # ]:          0 :     pStyleGraphicPropertiesOpenElement->addAttribute("draw:fill-color", "#ffffff");
         [ #  # ][ #  # ]
                 [ #  # ]
    1577                 :            : 
    1578                 :          0 :     double x = 0.0;
    1579                 :          0 :     double y = 0.0;
    1580                 :          0 :     double height = 0.0;
    1581                 :          0 :     double width = 0.0;
    1582 [ #  # ][ #  # ]:          0 :     if (propList["svg:x"])
    1583 [ #  # ][ #  # ]:          0 :         x = propList["svg:x"]->getDouble();
    1584 [ #  # ][ #  # ]:          0 :     if (propList["svg:y"])
    1585 [ #  # ][ #  # ]:          0 :         y = propList["svg:y"]->getDouble();
    1586 [ #  # ][ #  # ]:          0 :     if (propList["svg:width"])
    1587 [ #  # ][ #  # ]:          0 :         width = propList["svg:width"]->getDouble();
    1588 [ #  # ][ #  # ]:          0 :     if (propList["svg:height"])
    1589 [ #  # ][ #  # ]:          0 :         height = propList["svg:height"]->getDouble();
    1590                 :            : 
    1591 [ #  # ][ #  # ]:          0 :     double angle(propList["libwpg:rotate"] ? - M_PI * propList["libwpg:rotate"]->getDouble() / 180.0 : 0.0);
         [ #  # ][ #  # ]
    1592         [ #  # ]:          0 :     if (angle != 0.0)
    1593                 :            :     {
    1594                 :          0 :         double deltax((width*cos(angle)+height*sin(angle)-width)/2.0);
    1595                 :          0 :         double deltay((-width*sin(angle)+height*cos(angle)-height)/2.0);
    1596                 :          0 :         x -= deltax;
    1597                 :          0 :         y -= deltay;
    1598                 :            :     }
    1599                 :            : 
    1600 [ #  # ][ #  # ]:          0 :     if (!propList["svg:width"] && !propList["svg:height"])
         [ #  # ][ #  # ]
                 [ #  # ]
    1601                 :            :     {
    1602 [ #  # ][ #  # ]:          0 :         if (!propList["fo:min-width"])
    1603                 :            :         {
    1604 [ #  # ][ #  # ]:          0 :             pDrawFrameOpenElement->addAttribute("fo:min-width", "1in");
         [ #  # ][ #  # ]
                 [ #  # ]
    1605 [ #  # ][ #  # ]:          0 :             pStyleGraphicPropertiesOpenElement->addAttribute("fo:min-width", "1in");
         [ #  # ][ #  # ]
                 [ #  # ]
    1606                 :            :         }
    1607 [ #  # ][ #  # ]:          0 :         pDrawFrameOpenElement->addAttribute("svg:width", "10in");
         [ #  # ][ #  # ]
                 [ #  # ]
    1608                 :            :     }
    1609                 :            :     else
    1610                 :            :     {
    1611 [ #  # ][ #  # ]:          0 :         if(propList["svg:width"])
    1612 [ #  # ][ #  # ]:          0 :             pDrawFrameOpenElement->addAttribute("svg:width", propList["svg:width"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1613 [ #  # ][ #  # ]:          0 :         if(propList["svg:height"])
    1614 [ #  # ][ #  # ]:          0 :             pDrawFrameOpenElement->addAttribute("svg:height", propList["svg:height"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1615                 :            :     }
    1616 [ #  # ][ #  # ]:          0 :     if (propList["fo:min-width"])
    1617                 :            :     {
    1618 [ #  # ][ #  # ]:          0 :         pDrawFrameOpenElement->addAttribute("fo:min-width", propList["fo:min-width"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1619 [ #  # ][ #  # ]:          0 :         pStyleGraphicPropertiesOpenElement->addAttribute("fo:min-width", propList["fo:min-width"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1620                 :            :     }
    1621 [ #  # ][ #  # ]:          0 :     if (propList["fo:min-height"])
    1622                 :            :     {
    1623 [ #  # ][ #  # ]:          0 :         pDrawFrameOpenElement->addAttribute("fo:min-height", propList["fo:min-height"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1624 [ #  # ][ #  # ]:          0 :         pStyleGraphicPropertiesOpenElement->addAttribute("fo:min-height", propList["fo:min-height"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1625                 :            :     }
    1626 [ #  # ][ #  # ]:          0 :     if (propList["fo:max-width"])
    1627                 :            :     {
    1628 [ #  # ][ #  # ]:          0 :         pDrawFrameOpenElement->addAttribute("fo:max-width", propList["fo:max-height"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1629 [ #  # ][ #  # ]:          0 :         pStyleGraphicPropertiesOpenElement->addAttribute("fo:max-width", propList["fo:max-width"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1630                 :            :     }
    1631 [ #  # ][ #  # ]:          0 :     if (propList["fo:max-height"])
    1632                 :            :     {
    1633 [ #  # ][ #  # ]:          0 :         pDrawFrameOpenElement->addAttribute("fo:max-height", propList["fo:max-height"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1634 [ #  # ][ #  # ]:          0 :         pStyleGraphicPropertiesOpenElement->addAttribute("fo:max-height", propList["fo:max-height"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1635                 :            :     }
    1636 [ #  # ][ #  # ]:          0 :     if (propList["fo:padding-top"])
    1637                 :            :     {
    1638 [ #  # ][ #  # ]:          0 :         pDrawFrameOpenElement->addAttribute("fo:padding-top", propList["fo:padding-top"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1639 [ #  # ][ #  # ]:          0 :         pStyleGraphicPropertiesOpenElement->addAttribute("fo:padding-top", propList["fo:padding-top"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1640                 :            :     }
    1641 [ #  # ][ #  # ]:          0 :     if (propList["fo:padding-bottom"])
    1642                 :            :     {
    1643 [ #  # ][ #  # ]:          0 :         pDrawFrameOpenElement->addAttribute("fo:padding-bottom", propList["fo:padding-bottom"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1644 [ #  # ][ #  # ]:          0 :         pStyleGraphicPropertiesOpenElement->addAttribute("fo:padding-bottom", propList["fo:padding-bottom"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1645                 :            :     }
    1646 [ #  # ][ #  # ]:          0 :     if (propList["fo:padding-left"])
    1647                 :            :     {
    1648 [ #  # ][ #  # ]:          0 :         pDrawFrameOpenElement->addAttribute("fo:padding-left", propList["fo:padding-left"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1649 [ #  # ][ #  # ]:          0 :         pStyleGraphicPropertiesOpenElement->addAttribute("fo:padding-left", propList["fo:padding-left"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1650                 :            :     }
    1651 [ #  # ][ #  # ]:          0 :     if (propList["fo:padding-right"])
    1652                 :            :     {
    1653 [ #  # ][ #  # ]:          0 :         pDrawFrameOpenElement->addAttribute("fo:padding-right", propList["fo:padding-right"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1654 [ #  # ][ #  # ]:          0 :         pStyleGraphicPropertiesOpenElement->addAttribute("fo:padding-right", propList["fo:padding-right"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1655                 :            :     }
    1656 [ #  # ][ #  # ]:          0 :     if (propList["draw:textarea-vertical-align"])
    1657                 :            :     {
    1658 [ #  # ][ #  # ]:          0 :         pDrawFrameOpenElement->addAttribute("draw:textarea-vertical-align", propList["draw:textarea-vertical-align"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1659 [ #  # ][ #  # ]:          0 :         pStyleGraphicPropertiesOpenElement->addAttribute("draw:textarea-vertical-align", propList["draw:textarea-vertical-align"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1660                 :            :     }
    1661 [ #  # ][ #  # ]:          0 :     if (propList["draw:fill"])
    1662                 :            :     {
    1663 [ #  # ][ #  # ]:          0 :         pDrawFrameOpenElement->addAttribute("draw:fill", propList["draw:fill"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1664 [ #  # ][ #  # ]:          0 :         pStyleGraphicPropertiesOpenElement->addAttribute("draw:fill", propList["draw:fill"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1665                 :            :     }
    1666 [ #  # ][ #  # ]:          0 :     if (propList["draw:fill-color"])
    1667                 :            :     {
    1668 [ #  # ][ #  # ]:          0 :         pDrawFrameOpenElement->addAttribute("draw:fill-color", propList["draw:fill-color"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1669 [ #  # ][ #  # ]:          0 :         pStyleGraphicPropertiesOpenElement->addAttribute("draw:fill-color", propList["draw:fill-color"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1670                 :            :     }
    1671 [ #  # ][ #  # ]:          0 :     if (propList["draw:opacity"])
    1672                 :            :     {
    1673 [ #  # ][ #  # ]:          0 :         pDrawFrameOpenElement->addAttribute("draw:opacity", propList["draw:opacity"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1674 [ #  # ][ #  # ]:          0 :         pStyleGraphicPropertiesOpenElement->addAttribute("draw:opacity", propList["draw:opacity"]->getStr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1675                 :            :     }
    1676                 :            : 
    1677         [ #  # ]:          0 :     WPXProperty *svg_x = WPXPropertyFactory::newInchProp(x);
    1678         [ #  # ]:          0 :     WPXProperty *svg_y = WPXPropertyFactory::newInchProp(y);
    1679         [ #  # ]:          0 :     if (angle != 0.0)
    1680                 :            :     {
    1681         [ #  # ]:          0 :         WPXProperty *libwpg_rotate = WPXPropertyFactory::newDoubleProp(angle);
    1682                 :            :         sValue.sprintf("rotate (%s) translate(%s, %s)",
    1683                 :          0 :                        libwpg_rotate->getStr().cstr(),
    1684                 :          0 :                        svg_x->getStr().cstr(),
    1685 [ #  # ][ #  # ]:          0 :                        svg_y->getStr().cstr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1686 [ #  # ][ #  # ]:          0 :         delete libwpg_rotate;
    1687 [ #  # ][ #  # ]:          0 :         pDrawFrameOpenElement->addAttribute("draw:transform", sValue);
                 [ #  # ]
    1688                 :            :     }
    1689                 :            :     else
    1690                 :            :     {
    1691 [ #  # ][ #  # ]:          0 :         if (propList["svg:x"])
    1692 [ #  # ][ #  # ]:          0 :             pDrawFrameOpenElement->addAttribute("svg:x", svg_x->getStr());
         [ #  # ][ #  # ]
                 [ #  # ]
    1693 [ #  # ][ #  # ]:          0 :         if (propList["svg:y"])
    1694 [ #  # ][ #  # ]:          0 :             pDrawFrameOpenElement->addAttribute("svg:y", svg_y->getStr());
         [ #  # ][ #  # ]
                 [ #  # ]
    1695                 :            :     }
    1696 [ #  # ][ #  # ]:          0 :     delete svg_x;
    1697 [ #  # ][ #  # ]:          0 :     delete svg_y;
    1698         [ #  # ]:          0 :     mpImpl->mBodyElements.push_back(pDrawFrameOpenElement);
    1699 [ #  # ][ #  # ]:          0 :     mpImpl->mBodyElements.push_back(new TagOpenElement("draw:text-box"));
         [ #  # ][ #  # ]
                 [ #  # ]
    1700         [ #  # ]:          0 :     mpImpl->mGraphicsAutomaticStyles.push_back(pStyleGraphicPropertiesOpenElement);
    1701 [ #  # ][ #  # ]:          0 :     mpImpl->mGraphicsAutomaticStyles.push_back(new TagCloseElement("style:graphic-properties"));
         [ #  # ][ #  # ]
                 [ #  # ]
    1702 [ #  # ][ #  # ]:          0 :     mpImpl->mGraphicsAutomaticStyles.push_back(new TagCloseElement("style:style"));
         [ #  # ][ #  # ]
                 [ #  # ]
    1703         [ #  # ]:          0 :     mpImpl->mbIsTextBox = true;
    1704                 :          0 : }
    1705                 :            : 
    1706                 :          0 : void OdgGenerator::endTextObject()
    1707                 :            : {
    1708         [ #  # ]:          0 :     if (mpImpl->mbIsTextBox)
    1709                 :            :     {
    1710 [ #  # ][ #  # ]:          0 :         mpImpl->mBodyElements.push_back(new TagCloseElement("draw:text-box"));
                 [ #  # ]
    1711 [ #  # ][ #  # ]:          0 :         mpImpl->mBodyElements.push_back(new TagCloseElement("draw:frame"));
                 [ #  # ]
    1712                 :          0 :         mpImpl->mbIsTextBox = false;
    1713                 :            :     }
    1714                 :          0 : }
    1715                 :            : 
    1716                 :          0 : void OdgGenerator::startTextLine(const WPXPropertyList &propList)
    1717                 :            : {
    1718         [ #  # ]:          0 :     WPXPropertyList finalPropList(propList);
    1719         [ #  # ]:          0 :     finalPropList.insert("style:parent-style-name", "Standard");
    1720 [ #  # ][ #  # ]:          0 :     WPXString paragName = mpImpl->mParagraphManager.findOrAdd(finalPropList, WPXPropertyListVector());
                 [ #  # ]
    1721                 :            : 
    1722                 :            : 
    1723                 :            :     // create a document element corresponding to the paragraph, and append it to our list of document elements
    1724 [ #  # ][ #  # ]:          0 :     TagOpenElement *pParagraphOpenElement = new TagOpenElement("text:p");
         [ #  # ][ #  # ]
    1725 [ #  # ][ #  # ]:          0 :     pParagraphOpenElement->addAttribute("text:style-name", paragName);
                 [ #  # ]
    1726 [ #  # ][ #  # ]:          0 :     mpImpl->mBodyElements.push_back(pParagraphOpenElement);
                 [ #  # ]
    1727                 :          0 : }
    1728                 :            : 
    1729                 :          0 : void OdgGenerator::endTextLine()
    1730                 :            : {
    1731 [ #  # ][ #  # ]:          0 :     mpImpl->mBodyElements.push_back(new TagCloseElement("text:p"));
                 [ #  # ]
    1732                 :          0 : }
    1733                 :            : 
    1734                 :          0 : void OdgGenerator::startTextSpan(const WPXPropertyList &propList)
    1735                 :            : {
    1736 [ #  # ][ #  # ]:          0 :     if (propList["style:font-name"])
    1737 [ #  # ][ #  # ]:          0 :         mpImpl->mFontManager.findOrAdd(propList["style:font-name"]->getStr().cstr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1738                 :            : 
    1739         [ #  # ]:          0 :     WPXString sName = mpImpl->mSpanManager.findOrAdd(propList);
    1740                 :            : 
    1741 [ #  # ][ #  # ]:          0 :     TagOpenElement *pSpanOpenElement = new TagOpenElement("text:span");
         [ #  # ][ #  # ]
    1742 [ #  # ][ #  # ]:          0 :     pSpanOpenElement->addAttribute("text:style-name", sName.cstr());
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1743 [ #  # ][ #  # ]:          0 :     mpImpl->mBodyElements.push_back(pSpanOpenElement);
    1744                 :          0 : }
    1745                 :            : 
    1746                 :          0 : void OdgGenerator::endTextSpan()
    1747                 :            : {
    1748 [ #  # ][ #  # ]:          0 :     mpImpl->mBodyElements.push_back(new TagCloseElement("text:span"));
                 [ #  # ]
    1749                 :          0 : }
    1750                 :            : 
    1751                 :          0 : void OdgGenerator::insertText(const WPXString &text)
    1752                 :            : {
    1753         [ #  # ]:          0 :     WPXString out;
    1754         [ #  # ]:          0 :     WPXString::Iter i(text);
    1755 [ #  # ][ #  # ]:          0 :     for (i.rewind(); i.next();)
                 [ #  # ]
    1756                 :            :     {
    1757 [ #  # ][ #  # ]:          0 :         if ((*i()) == '\n' || (*i()) == '\t')
         [ #  # ][ #  # ]
                 [ #  # ]
    1758                 :            :         {
    1759 [ #  # ][ #  # ]:          0 :             if (out.len() != 0)
    1760                 :            :             {
    1761 [ #  # ][ #  # ]:          0 :                 DocumentElement *pText = new TextElement(out);
    1762         [ #  # ]:          0 :                 mpImpl->mBodyElements.push_back(pText);
    1763         [ #  # ]:          0 :                 out.clear();
    1764                 :            :             }
    1765 [ #  # ][ #  # ]:          0 :             if ((*i()) == '\n')
    1766                 :            :             {
    1767 [ #  # ][ #  # ]:          0 :                 mpImpl->mBodyElements.push_back(new TagOpenElement("text:line-break"));
         [ #  # ][ #  # ]
                 [ #  # ]
    1768 [ #  # ][ #  # ]:          0 :                 mpImpl->mBodyElements.push_back(new TagCloseElement("text:line-break"));
         [ #  # ][ #  # ]
                 [ #  # ]
    1769                 :            :             }
    1770 [ #  # ][ #  # ]:          0 :             else if ((*i()) == '\t')
    1771                 :            :             {
    1772 [ #  # ][ #  # ]:          0 :                 mpImpl->mBodyElements.push_back(new TagOpenElement("text:tab"));
         [ #  # ][ #  # ]
                 [ #  # ]
    1773 [ #  # ][ #  # ]:          0 :                 mpImpl->mBodyElements.push_back(new TagCloseElement("text:tab"));
         [ #  # ][ #  # ]
                 [ #  # ]
    1774                 :            :             }
    1775                 :            :         }
    1776                 :            :         else
    1777                 :            :         {
    1778 [ #  # ][ #  # ]:          0 :             out.append(i());
    1779                 :            :         }
    1780                 :            :     }
    1781 [ #  # ][ #  # ]:          0 :     if (out.len() != 0)
    1782                 :            :     {
    1783 [ #  # ][ #  # ]:          0 :         DocumentElement *pText = new TextElement(out);
    1784         [ #  # ]:          0 :         mpImpl->mBodyElements.push_back(pText);
    1785 [ #  # ][ #  # ]:          0 :     }
    1786                 :          0 : }
    1787                 :            : 
    1788                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10