diff options
author | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2012-03-02 18:48:04 +0100 |
---|---|---|
committer | Fridrich Štrba <fridrich.strba@bluewin.ch> | 2012-03-02 18:52:31 +0100 |
commit | 6c2581db2d2d03e8b12e5adacdf9ca4394ec9cc5 (patch) | |
tree | 8ebb353fd3e8ca024e2c80ac476270855443ded7 /writerperfect | |
parent | d4157cefc5416ebea75a460e7dbff91293bff321 (diff) |
Initial support of bitmap fills in OdgGenerator
Diffstat (limited to 'writerperfect')
-rw-r--r-- | writerperfect/source/filter/OdgGenerator.cxx | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/writerperfect/source/filter/OdgGenerator.cxx b/writerperfect/source/filter/OdgGenerator.cxx index 52f1329f9c1b..ef54b93dbc72 100644 --- a/writerperfect/source/filter/OdgGenerator.cxx +++ b/writerperfect/source/filter/OdgGenerator.cxx @@ -248,6 +248,7 @@ public: // graphics styles std::vector<DocumentElement *> mGraphicsStrokeDashStyles; std::vector<DocumentElement *> mGraphicsGradientStyles; + std::vector<DocumentElement *> mGraphicsBitmapStyles; std::vector<DocumentElement *> mGraphicsMarkerStyles; std::vector<DocumentElement *> mGraphicsAutomaticStyles; @@ -270,6 +271,7 @@ public: ::WPXPropertyListVector mxGradient; ::WPXPropertyListVector mxMarker; int miGradientIndex; + int miBitmapIndex; int miStartMarkerIndex; int miEndMarkerIndex; int miDashIndex; @@ -289,6 +291,7 @@ OdgGeneratorPrivate::OdgGeneratorPrivate(OdfDocumentHandler *pHandler, const Odf mBodyElements(), mGraphicsStrokeDashStyles(), mGraphicsGradientStyles(), + mGraphicsBitmapStyles(), mGraphicsAutomaticStyles(), mPageAutomaticStyles(), mPageMasterStyles(), @@ -299,6 +302,7 @@ OdgGeneratorPrivate::OdgGeneratorPrivate(OdfDocumentHandler *pHandler, const Odf mxStyle(), mxGradient(), mxMarker(), miGradientIndex(1), + miBitmapIndex(1), miStartMarkerIndex(1), miEndMarkerIndex(1), miDashIndex(1), @@ -342,6 +346,12 @@ OdgGeneratorPrivate::~OdgGeneratorPrivate() delete((*iterGraphicsGradientStyles)); } + for (std::vector<DocumentElement *>::iterator iterGraphicsBitmapStyles = mGraphicsBitmapStyles.begin(); + iterGraphicsBitmapStyles != mGraphicsBitmapStyles.end(); ++iterGraphicsBitmapStyles) + { + delete((*iterGraphicsBitmapStyles)); + } + for (std::vector<DocumentElement *>::iterator iterGraphicsMarkerStyles = mGraphicsMarkerStyles.begin(); iterGraphicsMarkerStyles != mGraphicsMarkerStyles.end(); ++iterGraphicsMarkerStyles) { @@ -453,6 +463,12 @@ OdgGenerator::~OdgGenerator() (*iterGraphicsGradientStyles)->write(mpImpl->mpHandler); } + for (std::vector<DocumentElement *>::const_iterator iterGraphicsBitmapStyles = mpImpl->mGraphicsBitmapStyles.begin(); + iterGraphicsBitmapStyles != mpImpl->mGraphicsBitmapStyles.end(); ++iterGraphicsBitmapStyles) + { + (*iterGraphicsBitmapStyles)->write(mpImpl->mpHandler); + } + for (std::vector<DocumentElement *>::const_iterator iterGraphicsMarkerStyles = mpImpl->mGraphicsMarkerStyles.begin(); iterGraphicsMarkerStyles != mpImpl->mGraphicsMarkerStyles.end(); ++iterGraphicsMarkerStyles) { @@ -1234,6 +1250,20 @@ void OdgGeneratorPrivate::_writeGraphicsStyle() delete pDrawOpacityElement; } + if(mxStyle["draw:fill"] && mxStyle["draw:fill"]->getStr() == "bitmap" && + mxStyle["draw:fill-image"] && mxStyle["libwpg:mime-type"]) + { + TagOpenElement *pDrawBitmapElement = new TagOpenElement("draw:fill-image"); + WPXString sValue; + sValue.sprintf("Bitmap_%i", miBitmapIndex++); + pDrawBitmapElement->addAttribute("draw:name", sValue); + mGraphicsBitmapStyles.push_back(pDrawBitmapElement); + mGraphicsBitmapStyles.push_back(new TagOpenElement("office:binary-data")); + mGraphicsBitmapStyles.push_back(new CharDataElement(mxStyle["draw:fill-image"]->getStr())); + mGraphicsBitmapStyles.push_back(new TagCloseElement("office:binary-data")); + mGraphicsBitmapStyles.push_back(new TagCloseElement("draw:fill-image")); + } + TagOpenElement *pStyleStyleElement = new TagOpenElement("style:style"); WPXString sValue; sValue.sprintf("gr%i", miGraphicsStyleIndex); @@ -1327,6 +1357,24 @@ void OdgGeneratorPrivate::_writeGraphicsStyle() } } + if(mxStyle["draw:fill"] && mxStyle["draw:fill"]->getStr() == "bitmap") + { + if (mxStyle["draw:fill-image"] && mxStyle["libwpg:mime-type"]) + { + pStyleGraphicsPropertiesElement->addAttribute("draw:fill", "bitmap"); + sValue.sprintf("Bitmap_%i", miBitmapIndex-1); + pStyleGraphicsPropertiesElement->addAttribute("draw:fill-image-name", sValue); + if (mxStyle["svg:width"]) + pStyleGraphicsPropertiesElement->addAttribute("draw:fill-image-width", mxStyle["svg:width"]->getStr()); + if (mxStyle["svg:height"]) + pStyleGraphicsPropertiesElement->addAttribute("draw:fill-image-height", mxStyle["svg:height"]->getStr()); + if (mxStyle["style:repeat"]) + pStyleGraphicsPropertiesElement->addAttribute("style:repeat", mxStyle["style:repeat"]->getStr()); + } + else + pStyleGraphicsPropertiesElement->addAttribute("draw:fill", "none"); + } + if(mxStyle["draw:marker-start-path"]) { |