sc/source/filter/excel/xestyle.cxx | 48 ++++++++++++++++++++++++++++--------- sc/source/filter/inc/xestyle.hxx | 13 ++++++++-- 2 files changed, 48 insertions(+), 13 deletions(-)
New commits: commit ad9f60fc4ccc17b99bd104e4dc1a64bbd7b73132 Author: Markus Mohrhard <markus.mohrh...@googlemail.com> Date: Tue Aug 14 22:13:50 2012 +0200 correctly export background colors of cond formats to xlsx Change-Id: I6d4b596ba3d611c8b795d48ca59378c4f4136611 Signed-off-by: Kohei Yoshida <kohei.yosh...@gmail.com> diff --git a/sc/source/filter/excel/xestyle.cxx b/sc/source/filter/excel/xestyle.cxx index 0a5de22..13b7d40 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() : @@ -2902,11 +2929,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; @@ -2927,7 +2954,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; } @@ -2966,16 +2993,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() @@ -2985,7 +3011,7 @@ XclExpDxf::~XclExpDxf() delete mpFont; delete mpNumberFmt; delete mpProt; - delete mpCellArea; + delete mpColor; } void XclExpDxf::SaveXml( XclExpXmlStream& rStrm ) @@ -3003,8 +3029,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 ba7dc67..a255b98 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 _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits