summaryrefslogtreecommitdiff
path: root/sc/source/filter/excel/xecontent.cxx
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-05-13 06:11:35 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-05-13 08:44:39 +0200
commit8384032fb757d42bb93f03f70f589d493ea8ef2f (patch)
tree9e5d5ce8330af5b522d2bd6a88d0eb69c4d9e2ec /sc/source/filter/excel/xecontent.cxx
parente3bc45b8079228ca25e70ac5a51b6977afd6f61e (diff)
export color scales to xlsx
Change-Id: I251acbb66a4033f69515c1b078ed5a28d0f0cd76
Diffstat (limited to 'sc/source/filter/excel/xecontent.cxx')
-rw-r--r--sc/source/filter/excel/xecontent.cxx133
1 files changed, 133 insertions, 0 deletions
diff --git a/sc/source/filter/excel/xecontent.cxx b/sc/source/filter/excel/xecontent.cxx
index 6a23166aa09a..c091c799d8b5 100644
--- a/sc/source/filter/excel/xecontent.cxx
+++ b/sc/source/filter/excel/xecontent.cxx
@@ -876,6 +876,76 @@ void XclExpCF::SaveXml( XclExpXmlStream& rStrm )
mxImpl->SaveXml( rStrm );
}
+XclExpCfvo::XclExpCfvo(const XclExpRoot& rRoot, const ScColorScaleEntry& rEntry, const ScAddress& rAddr):
+ XclExpRecord(),
+ XclExpRoot( rRoot ),
+ mrEntry(rEntry),
+ maSrcPos(rAddr)
+{
+}
+
+namespace {
+
+rtl::OString getColorScaleType( const ScColorScaleEntry& rEntry )
+{
+ if (rEntry.GetMin())
+ return "min";
+ if(rEntry.GetMax())
+ return "max";
+ if(rEntry.GetPercent())
+ return "percent";
+ if(rEntry.HasFormula())
+ return "formula";
+
+ return "num";
+}
+
+}
+
+void XclExpCfvo::SaveXml( XclExpXmlStream& rStrm )
+{
+ sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
+
+ rtl::OString aValue;
+ if(mrEntry.HasFormula())
+ {
+ rtl::OUString aFormula = XclXmlUtils::ToOUString( GetRoot().GetDoc(), maSrcPos, mrEntry.GetFormula()->Clone() );
+ aValue = rtl::OUStringToOString(aFormula, RTL_TEXTENCODING_UTF8 );
+ }
+ else
+ {
+ aValue = OString::valueOf( mrEntry.GetValue() );
+ }
+
+ rWorksheet->startElement( XML_cfvo,
+ XML_type, getColorScaleType(mrEntry).getStr(),
+ XML_val, aValue.getStr(),
+ FSEND );
+
+ rWorksheet->endElement( XML_cfvo );
+}
+
+XclExpColScaleCol::XclExpColScaleCol( const XclExpRoot& rRoot, const ScColorScaleEntry& rEntry ):
+ XclExpRecord(),
+ XclExpRoot( rRoot ),
+ mrEntry( rEntry )
+{
+}
+
+XclExpColScaleCol::~XclExpColScaleCol()
+{
+}
+
+void XclExpColScaleCol::SaveXml( XclExpXmlStream& rStrm )
+{
+ sax_fastparser::FSHelperPtr& rWorksheet = rStrm.GetCurrentStream();
+
+ rWorksheet->startElement( XML_color,
+ XML_rgb, XclXmlUtils::ToOString( mrEntry.GetColor() ).getStr(),
+ FSEND );
+
+ rWorksheet->endElement( XML_color );
+}
// ----------------------------------------------------------------------------
XclExpCondfmt::XclExpCondfmt( const XclExpRoot& rRoot, const ScConditionalFormat& rCondFormat ) :
@@ -933,7 +1003,58 @@ void XclExpCondfmt::SaveXml( XclExpXmlStream& rStrm )
XML_sqref, XclXmlUtils::ToOString( msSeqRef ).getStr(),
// OOXTODO: XML_pivot,
FSEND );
+
maCFList.SaveXml( rStrm );
+
+ // OOXTODO: XML_extLst
+ rWorksheet->endElement( XML_conditionalFormatting );
+}
+
+// ----------------------------------------------------------------------------
+
+XclExpColorScale::XclExpColorScale( const XclExpRoot& rRoot, const ScColorScaleFormat& rFormat ):
+ XclExpRecord(),
+ XclExpRoot( rRoot ),
+ mrFormat( rFormat )
+{
+ const ScRange* pRange = rFormat.GetRange().front();
+ ScAddress aAddr = pRange->aStart;
+ for(ScColorScaleFormat::const_iterator itr = rFormat.begin();
+ itr != rFormat.end(); ++itr)
+ {
+ // exact position is not important, we allow only absolute refs
+
+ XclExpCfvoList::RecordRefType xCfvo( new XclExpCfvo( GetRoot(), *itr, aAddr ) );
+ maCfvoList.AppendRecord( xCfvo );
+ XclExpColScaleColList::RecordRefType xClo( new XclExpColScaleCol( GetRoot(), *itr ) );
+ maColList.AppendRecord( xClo );
+ }
+}
+
+void XclExpColorScale::SaveXml( XclExpXmlStream& rStrm )
+{
+ rtl::OUString sSeqRef;
+ 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",
+ FSEND );
+
+ rWorksheet->startElement( XML_colorScale, FSEND );
+
+ maCfvoList.SaveXml(rStrm);
+ maColList.SaveXml(rStrm);
+
+ rWorksheet->endElement( XML_colorScale );
+
+ rWorksheet->endElement( XML_cfRule );
+
// OOXTODO: XML_extLst
rWorksheet->endElement( XML_conditionalFormatting );
}
@@ -953,6 +1074,15 @@ XclExpCondFormatBuffer::XclExpCondFormatBuffer( const XclExpRoot& rRoot ) :
maCondfmtList.AppendRecord( xCondfmtRec );
}
}
+ if( const ScColorScaleFormatList* pColorScaleList = GetDoc().GetColorScaleList() )
+ {
+ for( ScColorScaleFormatList::const_iterator itr = pColorScaleList->begin();
+ itr != pColorScaleList->end(); ++itr)
+ {
+ XclExpColorScaleList::RecordRefType xColorScaleRec( new XclExpColorScale( GetRoot(), *itr ) );
+ maColorScaleList.AppendRecord( xColorScaleRec );
+ }
+ }
}
void XclExpCondFormatBuffer::Save( XclExpStream& rStrm )
@@ -962,7 +1092,10 @@ void XclExpCondFormatBuffer::Save( XclExpStream& rStrm )
void XclExpCondFormatBuffer::SaveXml( XclExpXmlStream& rStrm )
{
+
maCondfmtList.SaveXml( rStrm );
+ maColorScaleList.SaveXml( rStrm );
+
}
// Validation =================================================================