diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-08-14 22:13:50 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-08-14 22:55:12 +0200 |
commit | 232f2513fc79120ab2625db867f49c35838830ef (patch) | |
tree | b1f05ce1bcf0d58d51bcdca7d822451bf40b2592 /sc | |
parent | c319e6258c34afa70ff0ab1f997ed88d53f94961 (diff) |
correctly export background colors of cond formats to xlsx
Change-Id: I6d4b596ba3d611c8b795d48ca59378c4f4136611
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/filter/excel/xestyle.cxx | 48 | ||||
-rw-r--r-- | sc/source/filter/inc/xestyle.hxx | 13 |
2 files changed, 48 insertions, 13 deletions
diff --git a/sc/source/filter/excel/xestyle.cxx b/sc/source/filter/excel/xestyle.cxx index 5e2e0117c00c..dacbbbc20d97 100644 --- a/sc/source/filter/excel/xestyle.cxx +++ b/sc/source/filter/excel/xestyle.cxx @@ -1885,6 +1885,33 @@ void XclExpCellArea::SaveXml( XclExpXmlStream& rStrm ) const rStyleSheet->endElement( XML_fill ); } + +bool XclExpColor::FillFromItemSet( const SfxItemSet& rItemSet ) +{ + if( !ScfTools::CheckItem( rItemSet, ATTR_BACKGROUND, true ) ) + return false; + + const SvxBrushItem& rBrushItem = GETITEM( rItemSet, SvxBrushItem, ATTR_BACKGROUND ); + maColor = rBrushItem.GetColor(); + + return true; +} + +void XclExpColor::SaveXml( XclExpXmlStream& rStrm ) const +{ + sax_fastparser::FSHelperPtr& rStyleSheet = rStrm.GetCurrentStream(); + rStyleSheet->startElement( XML_fill, + FSEND ); + rStyleSheet->startElement( XML_patternFill, + FSEND ); + rStyleSheet->singleElement( XML_bgColor, + XML_rgb, XclXmlUtils::ToOString(maColor).getStr(), + FSEND ); + + rStyleSheet->endElement( XML_patternFill ); + rStyleSheet->endElement( XML_fill ); +} + // ---------------------------------------------------------------------------- XclExpXFId::XclExpXFId() : @@ -2898,11 +2925,11 @@ XclExpDxfs::XclExpDxfs( const XclExpRoot& rRoot ) pCellProt = NULL; } - XclExpCellArea* pCellArea = new XclExpCellArea; - if(!pCellArea->FillFromItemSet( rSet, GetPalette(), GetBiff() )) + XclExpColor* pColor = new XclExpColor(); + if(!pColor->FillFromItemSet( rSet )) { - delete pCellArea; - pCellArea = NULL; + delete pColor; + pColor = NULL; } XclExpFont* pFont = NULL; @@ -2923,7 +2950,7 @@ XclExpDxfs::XclExpDxfs( const XclExpRoot& rRoot ) ++nNumFmtIndex; } - maDxf.push_back(new XclExpDxf( rRoot, pAlign, pBorder, pFont, pNumFormat, pCellProt, pCellArea )); + maDxf.push_back(new XclExpDxf( rRoot, pAlign, pBorder, pFont, pNumFormat, pCellProt, pColor )); ++nIndex; } @@ -2962,16 +2989,15 @@ void XclExpDxfs::SaveXml( XclExpXmlStream& rStrm ) // ============================================================================ XclExpDxf::XclExpDxf( const XclExpRoot& rRoot, XclExpCellAlign* pAlign, XclExpCellBorder* pBorder, - XclExpFont* pFont, XclExpNumFmt* pNumberFmt, XclExpCellProt* pProt, XclExpCellArea* pCellArea) + XclExpFont* pFont, XclExpNumFmt* pNumberFmt, XclExpCellProt* pProt, XclExpColor* pColor) : XclExpRoot( rRoot ), mpAlign(pAlign), mpBorder(pBorder), mpFont(pFont), mpNumberFmt(pNumberFmt), mpProt(pProt), - mpCellArea(pCellArea) + mpColor(pColor) { - } XclExpDxf::~XclExpDxf() @@ -2981,7 +3007,7 @@ XclExpDxf::~XclExpDxf() delete mpFont; delete mpNumberFmt; delete mpProt; - delete mpCellArea; + delete mpColor; } void XclExpDxf::SaveXml( XclExpXmlStream& rStrm ) @@ -2999,8 +3025,8 @@ void XclExpDxf::SaveXml( XclExpXmlStream& rStrm ) mpNumberFmt->SaveXml(rStrm); if (mpProt) mpProt->SaveXml(rStrm); - if (mpCellArea) - mpCellArea->SaveXml(rStrm); + if (mpColor) + mpColor->SaveXml(rStrm); rStyleSheet->endElement( XML_dxf ); } diff --git a/sc/source/filter/inc/xestyle.hxx b/sc/source/filter/inc/xestyle.hxx index ba7dc67d32c8..a255b98772a1 100644 --- a/sc/source/filter/inc/xestyle.hxx +++ b/sc/source/filter/inc/xestyle.hxx @@ -427,6 +427,15 @@ struct XclExpCellArea : public XclCellArea void SaveXml( XclExpXmlStream& rStrm ) const; }; +struct XclExpColor +{ + Color maColor; + + bool FillFromItemSet( const SfxItemSet& rItemSet ); + + void SaveXml( XclExpXmlStream& rStrm ) const; +}; + // ---------------------------------------------------------------------------- /** A combination of unique XF identifier with real Excel XF index. */ @@ -733,7 +742,7 @@ class XclExpDxf : public XclExpRecordBase, protected XclExpRoot { public: XclExpDxf( const XclExpRoot& rRoot, XclExpCellAlign* pAlign, XclExpCellBorder* pBorder, - XclExpFont* pFont, XclExpNumFmt* pNumberFmt, XclExpCellProt* pProt, XclExpCellArea* pCellArea); + XclExpFont* pFont, XclExpNumFmt* pNumberFmt, XclExpCellProt* pProt, XclExpColor* pColor); virtual ~XclExpDxf(); virtual void SaveXml( XclExpXmlStream& rStrm ); @@ -744,7 +753,7 @@ private: XclExpFont* mpFont; XclExpNumFmt* mpNumberFmt; XclExpCellProt* mpProt; - XclExpCellArea* mpCellArea; + XclExpColor* mpColor; }; class XclExpDxfs : public XclExpRecordBase, protected XclExpRoot |