diff options
author | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-05-22 21:57:50 +0200 |
---|---|---|
committer | Markus Mohrhard <markus.mohrhard@googlemail.com> | 2012-05-24 12:38:11 +0200 |
commit | 99f61e9b635a7c30f28192c01a534acb1e2a6ca3 (patch) | |
tree | 2ff1bf256aadce79d5ec23e7862a9d5b3dfe5c02 | |
parent | 816f65da41c8c30e5854e333a6498e58c64303aa (diff) |
first part for databar export
# Changes to be committed:
Change-Id: Iffe020d60982c2872c1a451f9d0e4e1d4f5e349f
-rw-r--r-- | sc/inc/colorscale.hxx | 1 | ||||
-rw-r--r-- | sc/source/core/data/colorscale.cxx | 5 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlexprt.cxx | 96 | ||||
-rw-r--r-- | sc/source/filter/xml/xmlexprt.hxx | 1 | ||||
-rw-r--r-- | xmloff/inc/xmloff/xmltoken.hxx | 6 | ||||
-rw-r--r-- | xmloff/source/core/xmltoken.cxx | 6 |
6 files changed, 115 insertions, 0 deletions
diff --git a/sc/inc/colorscale.hxx b/sc/inc/colorscale.hxx index 24248fef703e..3187f8475809 100644 --- a/sc/inc/colorscale.hxx +++ b/sc/inc/colorscale.hxx @@ -216,6 +216,7 @@ public: ScDataBarInfo* GetDataBarInfo(const ScAddress& rAddr) const; void SetDataBarData( ScDataBarFormatData* pData ); + const ScDataBarFormatData* GetDataBarData() const; virtual void DataChanged(const ScRange& rRange); virtual void UpdateMoveTab(SCTAB nOldTab, SCTAB nNewTab); diff --git a/sc/source/core/data/colorscale.cxx b/sc/source/core/data/colorscale.cxx index 9636365a2b7a..c5db85980a34 100644 --- a/sc/source/core/data/colorscale.cxx +++ b/sc/source/core/data/colorscale.cxx @@ -644,6 +644,11 @@ void ScDataBarFormat::SetDataBarData( ScDataBarFormatData* pData ) mpFormatData.reset(pData); } +const ScDataBarFormatData* ScDataBarFormat::GetDataBarData() const +{ + return mpFormatData.get(); +} + ScColorFormat* ScDataBarFormat::Clone(ScDocument* pDoc) const { return new ScDataBarFormat(pDoc, *this); diff --git a/sc/source/filter/xml/xmlexprt.cxx b/sc/source/filter/xml/xmlexprt.cxx index 1fb9c0ccc1ea..aa4495cd218b 100644 --- a/sc/source/filter/xml/xmlexprt.cxx +++ b/sc/source/filter/xml/xmlexprt.cxx @@ -68,6 +68,8 @@ #include "editutil.hxx" #include "tabprotection.hxx" #include "cachedattraccess.hxx" +#include "colorscale.hxx" +#include "conditio.hxx" #include <xmloff/xmltoken.hxx> #include <xmloff/xmlnmspe.hxx> @@ -2849,6 +2851,9 @@ void ScXMLExport::WriteTable(sal_Int32 nTable, const Reference<sheet::XSpreadshe WriteNamedRange(pRangeName); } + //export new conditional format information + ExportConditionalFormat(); + } } @@ -3789,6 +3794,97 @@ void ScXMLExport::WriteNamedRange(ScRangeName* pRangeName) } } +namespace { + +rtl::OUString getCondFormatEntryType(const ScColorScaleEntry& rEntry) +{ + if(rEntry.GetMin()) + return rtl::OUString("minimum"); + else if(rEntry.GetMax()) + return rtl::OUString("maximum"); + else if(rEntry.GetPercent()) + return rtl::OUString("percent"); + else if(rEntry.GetPercentile()) + return rtl::OUString("percentile"); + else if(rEntry.GetFormula()) + return rtl::OUString("formula"); + else + return rtl::OUString("number"); +} + +} + +void ScXMLExport::ExportConditionalFormat() +{ + ScConditionalFormatList* pCondFormatList = pDoc->GetCondFormList(); + ScColorFormatList* pColorFormatList = pDoc->GetColorScaleList(); + if(pCondFormatList || pColorFormatList) + { + SvXMLElementExport aElementCondFormats(*this, XML_NP_TABLE_EXT, XML_CONDITIONAL_FORMATS, true, true); + + if(pCondFormatList) + { + for(ScConditionalFormatList::const_iterator itr = pCondFormatList->begin(); + itr != pCondFormatList->end(); ++itr) + { + SvXMLElementExport aElementCondFormat(*this, XML_NP_TABLE_EXT, XML_CONDITIONAL_FORMAT, true, true); + rtl::OUString sRangeList; + //ScRangeStringConverter::GetStringFromRangeList( sRanges, rRangeList, pDoc, FormulaGrammar::CONV_OOO ); + AddAttribute(XML_NP_TABLE_EXT, XML_TARGET_RANGE_ADDRESS, sRangeList); + } + } + + if(pColorFormatList) + { + for(ScColorFormatList::const_iterator itr = pColorFormatList->begin(); + itr != pColorFormatList->end(); ++itr) + { + rtl::OUString sRangeList; + const ScRangeList& rRangeList = itr->GetRange(); + ScRangeStringConverter::GetStringFromRangeList( sRangeList, &rRangeList, pDoc, FormulaGrammar::CONV_OOO ); + AddAttribute(XML_NP_TABLE_EXT, XML_TARGET_RANGE_ADDRESS, sRangeList); + SvXMLElementExport aElementColFormat(*this, XML_NP_TABLE_EXT, XML_CONDITIONAL_FORMAT, true, true); + + if(itr->GetType() == COLORSCALE) + { + SvXMLElementExport aElementColorScale(*this, XML_NP_TABLE_EXT, XML_COLOR_SCALE, true, true); + + } + else if(itr->GetType() == DATABAR) + { + const ScDataBarFormatData* pFormatData = static_cast<const ScDataBarFormat&>(*itr).GetDataBarData(); + if(!pFormatData->mbGradient) + AddAttribute(XML_NP_TABLE_EXT, XML_GRADIENT, XML_FALSE); + rtl::OUStringBuffer aBuffer; + ::sax::Converter::convertColor(aBuffer, pFormatData->maPositiveColor.GetColor()); + AddAttribute(XML_NP_TABLE_EXT, XML_POSITIVE_COLOR, aBuffer.makeStringAndClear()); + SvXMLElementExport aElementDataBar(*this, XML_NP_TABLE_EXT, XML_DATA_BAR, true, true); + + if(pFormatData->mpLowerLimit->GetFormula()) + { + rtl::OUString sFormula; + AddAttribute(XML_NP_TABLE_EXT, XML_VALUE, sFormula); + } + else + AddAttribute(XML_NP_TABLE_EXT, XML_VALUE, rtl::OUString::valueOf(pFormatData->mpLowerLimit->GetValue())); + AddAttribute(XML_NP_TABLE_EXT, XML_TYPE, getCondFormatEntryType(*pFormatData->mpLowerLimit)); + SvXMLElementExport aElementDataBarEntryLower(*this, XML_NP_TABLE_EXT, XML_DATA_BAR_ENTRY, true, true); + + if(pFormatData->mpUpperLimit->GetFormula()) + { + rtl::OUString sFormula; + AddAttribute(XML_NP_TABLE_EXT, XML_VALUE, sFormula); + } + else + AddAttribute(XML_NP_TABLE_EXT, XML_VALUE, rtl::OUString::valueOf(pFormatData->mpUpperLimit->GetValue())); + AddAttribute(XML_NP_TABLE_EXT, XML_TYPE, getCondFormatEntryType(*pFormatData->mpUpperLimit)); + SvXMLElementExport aElementDataBarEntryUpper(*this, XML_NP_TABLE_EXT, XML_DATA_BAR_ENTRY, true, true); + } + } + } + } +} + void ScXMLExport::WriteExternalRefCaches() { if (!pDoc) diff --git a/sc/source/filter/xml/xmlexprt.hxx b/sc/source/filter/xml/xmlexprt.hxx index 5e65953c71aa..158e81813e70 100644 --- a/sc/source/filter/xml/xmlexprt.hxx +++ b/sc/source/filter/xml/xmlexprt.hxx @@ -205,6 +205,7 @@ class ScXMLExport : public SvXMLExport void WriteLabelRanges( const com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess >& xRangesIAccess, bool bColumn ); void WriteNamedExpressions(); void WriteNamedRange(ScRangeName* pRangeName); + void ExportConditionalFormat(); void WriteExternalRefCaches(); void WriteConsolidation(); // core implementation diff --git a/xmloff/inc/xmloff/xmltoken.hxx b/xmloff/inc/xmloff/xmltoken.hxx index f24102376e8e..dd0529b6fcbb 100644 --- a/xmloff/inc/xmloff/xmltoken.hxx +++ b/xmloff/inc/xmloff/xmltoken.hxx @@ -425,6 +425,7 @@ namespace xmloff { namespace token { XML_COLOR, XML_COLOR_INVERSION, XML_COLOR_MODE, + XML_COLOR_SCALE, XML_COLUMN, XML_COLUMN_COUNT, XML_COLUMN_GAP, @@ -446,6 +447,8 @@ namespace xmloff { namespace token { XML_CONDITION_SOURCE, XML_CONDITION_SOURCE_RANGE_ADDRESS, XML_CONDITIONAL_TEXT, + XML_CONDITIONAL_FORMAT, + XML_CONDITIONAL_FORMATS, XML_CONE, XML_CONFERENCE, XML_CONFIG_ITEM, @@ -528,6 +531,8 @@ namespace xmloff { namespace token { XML_DASH, XML_DASHED, XML_DATA, + XML_DATA_BAR, + XML_DATA_BAR_ENTRY, XML_DATA_CELL_RANGE_ADDRESS, XML_DATA_LABEL_NUMBER, XML_DATA_LABEL_SYMBOL, @@ -1381,6 +1386,7 @@ namespace xmloff { namespace token { XML_POSITION_LEFT, XML_POSITION_RIGHT, XML_POSITION_TOP, + XML_POSITIVE_COLOR, XML_POSTURE_ITALIC, XML_POSTURE_NORMAL, XML_POSTURE_OBLIQUE, diff --git a/xmloff/source/core/xmltoken.cxx b/xmloff/source/core/xmltoken.cxx index 7c560377eb21..d4e21b2d2bd5 100644 --- a/xmloff/source/core/xmltoken.cxx +++ b/xmloff/source/core/xmltoken.cxx @@ -429,6 +429,7 @@ namespace xmloff { namespace token { TOKEN( "color", XML_COLOR ), TOKEN( "color-inversion", XML_COLOR_INVERSION ), TOKEN( "color-mode", XML_COLOR_MODE ), + TOKEN( "color-scale", XML_COLOR_SCALE ), TOKEN( "column", XML_COLUMN ), TOKEN( "column-count", XML_COLUMN_COUNT ), TOKEN( "column-gap", XML_COLUMN_GAP ), @@ -450,6 +451,8 @@ namespace xmloff { namespace token { TOKEN( "condition-source", XML_CONDITION_SOURCE ), TOKEN( "condition-source-range-address", XML_CONDITION_SOURCE_RANGE_ADDRESS ), TOKEN( "conditional-text", XML_CONDITIONAL_TEXT ), + TOKEN( "conditional-format", XML_CONDITIONAL_FORMAT ), + TOKEN( "conditional-formats", XML_CONDITIONAL_FORMATS ), TOKEN( "cone", XML_CONE ), TOKEN( "conference", XML_CONFERENCE ), TOKEN( "config-item", XML_CONFIG_ITEM ), @@ -532,6 +535,8 @@ namespace xmloff { namespace token { TOKEN( "dash", XML_DASH ), TOKEN( "dashed", XML_DASHED ), TOKEN( "data", XML_DATA ), + TOKEN( "data-bar", XML_DATA_BAR ), + TOKEN( "data-bar-entry", XML_DATA_BAR_ENTRY ), TOKEN( "data-cell-range-address", XML_DATA_CELL_RANGE_ADDRESS ), TOKEN( "data-label-number", XML_DATA_LABEL_NUMBER ), TOKEN( "data-label-symbol", XML_DATA_LABEL_SYMBOL ), @@ -1386,6 +1391,7 @@ namespace xmloff { namespace token { TOKEN( "position-left", XML_POSITION_LEFT ), TOKEN( "position-right", XML_POSITION_RIGHT ), TOKEN( "position-top", XML_POSITION_TOP ), + TOKEN( "positive-color", XML_POSITIVE_COLOR ), TOKEN( "italic", XML_POSTURE_ITALIC ), TOKEN( "normal", XML_POSTURE_NORMAL ), TOKEN( "oblique", XML_POSTURE_OBLIQUE ), |