summaryrefslogtreecommitdiffstats
path: root/sc
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-05-22 21:57:50 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-05-24 12:38:11 +0200
commit99f61e9b635a7c30f28192c01a534acb1e2a6ca3 (patch)
tree2ff1bf256aadce79d5ec23e7862a9d5b3dfe5c02 /sc
parentresolved fdo#41214 crash due to offset error (diff)
downloadcore-99f61e9b635a7c30f28192c01a534acb1e2a6ca3.tar.gz
core-99f61e9b635a7c30f28192c01a534acb1e2a6ca3.zip
first part for databar export
# Changes to be committed: Change-Id: Iffe020d60982c2872c1a451f9d0e4e1d4f5e349f
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/colorscale.hxx1
-rw-r--r--sc/source/core/data/colorscale.cxx5
-rw-r--r--sc/source/filter/xml/xmlexprt.cxx96
-rw-r--r--sc/source/filter/xml/xmlexprt.hxx1
4 files changed, 103 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