diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-08-14 01:23:56 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-08-14 01:26:54 +0200 |
commit | 65457cbaf0acbfb1925c21f2d03ffec8e20e84bd (patch) | |
tree | 0ada11c99f83eeffa5236a370c712f3b9fcf001b /sc | |
parent | 65095170ffa3689d60792e0a9d7aa88471b08704 (diff) |
implement color scale and data bar export to xlsx
Only 2007 versions of DataBars supported yet
Change-Id: Id1d10aae2bb5221246740defa3d4a97a1cd7c908
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/filter/excel/xecontent.cxx | 73 | ||||
-rw-r--r-- | sc/source/filter/inc/xecontent.hxx | 26 |
2 files changed, 77 insertions, 22 deletions
diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx index 0c28a59d6367..d7461cfac852 100644 --- a/sc/source/filter/excel/xecontent.cxx +++ b/sc/source/filter/excel/xecontent.cxx @@ -908,6 +908,12 @@ rtl::OString getColorScaleType( const ScColorScaleEntry& rEntry ) return "percent"; case COLORSCALE_FORMULA: return "formula"; + case COLORSCALE_AUTOMIN: + return "min"; + case COLORSCALE_AUTOMAX: + return "max"; + case COLORSCALE_PERCENTILE: + return "percentile"; default: break; } @@ -940,10 +946,10 @@ void XclExpCfvo::SaveXml( XclExpXmlStream& rStrm ) rWorksheet->endElement( XML_cfvo ); } -XclExpColScaleCol::XclExpColScaleCol( const XclExpRoot& rRoot, const ScColorScaleEntry& rEntry ): +XclExpColScaleCol::XclExpColScaleCol( const XclExpRoot& rRoot, const Color& rColor ): XclExpRecord(), XclExpRoot( rRoot ), - mrEntry( rEntry ) + mrColor( rColor ) { } @@ -956,11 +962,12 @@ void XclExpColScaleCol::SaveXml( XclExpXmlStream& rStrm ) sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream(); rWorksheet->startElement( XML_color, - XML_rgb, XclXmlUtils::ToOString( mrEntry.GetColor() ).getStr(), + XML_rgb, XclXmlUtils::ToOString( mrColor ).getStr(), FSEND ); rWorksheet->endElement( XML_color ); } + // ---------------------------------------------------------------------------- XclExpCondfmt::XclExpCondfmt( const XclExpRoot& rRoot, const ScConditionalFormat& rCondFormat ) : @@ -977,6 +984,10 @@ XclExpCondfmt::XclExpCondfmt( const XclExpRoot& rRoot, const ScConditionalFormat { if(pFormatEntry->GetType() == condformat::CONDITION) maCFList.AppendNewRecord( new XclExpCF( GetRoot(), static_cast<const ScCondFormatEntry&>(*pFormatEntry), nIndex ) ); + else if(pFormatEntry->GetType() == condformat::COLORSCALE) + maCFList.AppendNewRecord( new XclExpColorScale( GetRoot(), static_cast<const ScColorScaleFormat&>(*pFormatEntry), nIndex ) ); + else if(pFormatEntry->GetType() == condformat::DATABAR) + maCFList.AppendNewRecord( new XclExpDataBar( GetRoot(), static_cast<const ScDataBarFormat&>(*pFormatEntry), nIndex ) ); } aScRanges.Format( msSeqRef, SCA_VALID, NULL, formula::FormulaGrammar::CONV_XL_A1 ); } @@ -1030,10 +1041,11 @@ void XclExpCondfmt::SaveXml( XclExpXmlStream& rStrm ) // ---------------------------------------------------------------------------- -XclExpColorScale::XclExpColorScale( const XclExpRoot& rRoot, const ScColorScaleFormat& rFormat ): +XclExpColorScale::XclExpColorScale( const XclExpRoot& rRoot, const ScColorScaleFormat& rFormat, sal_Int32 nPriority ): XclExpRecord(), XclExpRoot( rRoot ), - mrFormat( rFormat ) + mrFormat( rFormat ), + mnPriority( nPriority ) { const ScRange* pRange = rFormat.GetRange().front(); ScAddress aAddr = pRange->aStart; @@ -1044,23 +1056,18 @@ XclExpColorScale::XclExpColorScale( const XclExpRoot& rRoot, const ScColorScaleF XclExpCfvoList::RecordRefType xCfvo( new XclExpCfvo( GetRoot(), *itr, aAddr ) ); maCfvoList.AppendRecord( xCfvo ); - XclExpColScaleColList::RecordRefType xClo( new XclExpColScaleCol( GetRoot(), *itr ) ); + XclExpColScaleColList::RecordRefType xClo( new XclExpColScaleCol( GetRoot(), itr->GetColor() ) ); maColList.AppendRecord( xClo ); } } void XclExpColorScale::SaveXml( XclExpXmlStream& rStrm ) { - const ScRangeList& rRanges = mrFormat.GetRange(); - sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream(); - rWorksheet->startElement( XML_conditionalFormatting, - XML_sqref, XclXmlUtils::ToOString(rRanges).getStr(), - FSEND ); rWorksheet->startElement( XML_cfRule, XML_type, "colorScale", - XML_priority, "1", + XML_priority, OString::valueOf( mnPriority + 1 ).getStr(), FSEND ); rWorksheet->startElement( XML_colorScale, FSEND ); @@ -1073,7 +1080,44 @@ void XclExpColorScale::SaveXml( XclExpXmlStream& rStrm ) rWorksheet->endElement( XML_cfRule ); // OOXTODO: XML_extLst - rWorksheet->endElement( XML_conditionalFormatting ); +} + +XclExpDataBar::XclExpDataBar( const XclExpRoot& rRoot, const ScDataBarFormat& rFormat, sal_Int32 nPriority ): + XclExpRecord(), + XclExpRoot( rRoot ), + mrFormat( rFormat ), + mnPriority( nPriority ) +{ + const ScRange* pRange = rFormat.GetRange().front(); + ScAddress aAddr = pRange->aStart; + // exact position is not important, we allow only absolute refs + mpCfvoLowerLimit.reset( new XclExpCfvo( GetRoot(), *mrFormat.GetDataBarData()->mpLowerLimit.get(), aAddr ) ); + mpCfvoUpperLimit.reset( new XclExpCfvo( GetRoot(), *mrFormat.GetDataBarData()->mpUpperLimit.get(), aAddr ) ); + + mpCol.reset( new XclExpColScaleCol( GetRoot(), mrFormat.GetDataBarData()->maPositiveColor ) ); +} + +void XclExpDataBar::SaveXml( XclExpXmlStream& rStrm ) +{ + sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream(); + + rWorksheet->startElement( XML_cfRule, + XML_type, "dataBar", + XML_priority, OString::valueOf( mnPriority + 1 ).getStr(), + FSEND ); + + rWorksheet->startElement( XML_dataBar, FSEND ); + + mpCfvoLowerLimit->SaveXml(rStrm); + mpCfvoUpperLimit->SaveXml(rStrm); + mpCol->SaveXml(rStrm); + + rWorksheet->endElement( XML_dataBar ); + + rWorksheet->endElement( XML_cfRule ); + + // OOXTODO: XML_extLst + } // ---------------------------------------------------------------------------- @@ -1100,10 +1144,7 @@ void XclExpCondFormatBuffer::Save( XclExpStream& rStrm ) void XclExpCondFormatBuffer::SaveXml( XclExpXmlStream& rStrm ) { - maCondfmtList.SaveXml( rStrm ); - maColorScaleList.SaveXml( rStrm ); - } // Validation ================================================================= diff --git a/sc/source/filter/inc/xecontent.hxx b/sc/source/filter/inc/xecontent.hxx index cf246e797355..498bd103df33 100644 --- a/sc/source/filter/inc/xecontent.hxx +++ b/sc/source/filter/inc/xecontent.hxx @@ -211,12 +211,12 @@ private: class XclExpColScaleCol : public XclExpRecord, protected XclExpRoot { public: - explicit XclExpColScaleCol( const XclExpRoot& rRoot, const ScColorScaleEntry& rFormatEntry); + explicit XclExpColScaleCol( const XclExpRoot& rRoot, const Color& rColor); virtual ~XclExpColScaleCol(); virtual void SaveXml( XclExpXmlStream& rStrm ); private: - const ScColorScaleEntry& mrEntry; + const Color& mrColor; }; // ---------------------------------------------------------------------------- @@ -243,7 +243,7 @@ private: virtual void WriteBody( XclExpStream& rStrm ); private: - typedef XclExpRecordList< XclExpCF > XclExpCFList; + typedef XclExpRecordList< XclExpRecord > XclExpCFList; XclExpCFList maCFList; /// List of CF records. XclRangeList maXclRanges; /// Cell ranges for this conditional format. @@ -253,7 +253,7 @@ private: class XclExpColorScale: public XclExpRecord, protected XclExpRoot { public: - explicit XclExpColorScale( const XclExpRoot& rRoot, const ScColorScaleFormat& rFormat ); + explicit XclExpColorScale( const XclExpRoot& rRoot, const ScColorScaleFormat& rFormat, sal_Int32 nPriority ); virtual void SaveXml( XclExpXmlStream& rStrm ); private: @@ -263,6 +263,22 @@ private: XclExpCfvoList maCfvoList; XclExpColScaleColList maColList; const ScColorScaleFormat& mrFormat; + sal_Int32 mnPriority; +}; + +class XclExpDataBar : public XclExpRecord, protected XclExpRoot +{ +public: + explicit XclExpDataBar( const XclExpRoot& rRoot, const ScDataBarFormat& rFormat, sal_Int32 nPriority ); + + virtual void SaveXml( XclExpXmlStream& rStrm ); +private: + boost::scoped_ptr<XclExpCfvo> mpCfvoLowerLimit; + boost::scoped_ptr<XclExpCfvo> mpCfvoUpperLimit; + boost::scoped_ptr<XclExpColScaleCol> mpCol; + + const ScDataBarFormat& mrFormat; + sal_Int32 mnPriority; }; // ---------------------------------------------------------------------------- @@ -280,9 +296,7 @@ public: private: typedef XclExpRecordList< XclExpCondfmt > XclExpCondfmtList; - typedef XclExpRecordList< XclExpColorScale > XclExpColorScaleList; XclExpCondfmtList maCondfmtList; /// List of CONDFMT records. - XclExpColorScaleList maColorScaleList; // Color scale entries }; // Data Validation ============================================================ |