Kaydet (Commit) 99f61e9b authored tarafından Markus Mohrhard's avatar Markus Mohrhard

first part for databar export

 # Changes to be committed:

Change-Id: Iffe020d60982c2872c1a451f9d0e4e1d4f5e349f
üst 816f65da
...@@ -216,6 +216,7 @@ public: ...@@ -216,6 +216,7 @@ public:
ScDataBarInfo* GetDataBarInfo(const ScAddress& rAddr) const; ScDataBarInfo* GetDataBarInfo(const ScAddress& rAddr) const;
void SetDataBarData( ScDataBarFormatData* pData ); void SetDataBarData( ScDataBarFormatData* pData );
const ScDataBarFormatData* GetDataBarData() const;
virtual void DataChanged(const ScRange& rRange); virtual void DataChanged(const ScRange& rRange);
virtual void UpdateMoveTab(SCTAB nOldTab, SCTAB nNewTab); virtual void UpdateMoveTab(SCTAB nOldTab, SCTAB nNewTab);
......
...@@ -644,6 +644,11 @@ void ScDataBarFormat::SetDataBarData( ScDataBarFormatData* pData ) ...@@ -644,6 +644,11 @@ void ScDataBarFormat::SetDataBarData( ScDataBarFormatData* pData )
mpFormatData.reset(pData); mpFormatData.reset(pData);
} }
const ScDataBarFormatData* ScDataBarFormat::GetDataBarData() const
{
return mpFormatData.get();
}
ScColorFormat* ScDataBarFormat::Clone(ScDocument* pDoc) const ScColorFormat* ScDataBarFormat::Clone(ScDocument* pDoc) const
{ {
return new ScDataBarFormat(pDoc, *this); return new ScDataBarFormat(pDoc, *this);
......
...@@ -68,6 +68,8 @@ ...@@ -68,6 +68,8 @@
#include "editutil.hxx" #include "editutil.hxx"
#include "tabprotection.hxx" #include "tabprotection.hxx"
#include "cachedattraccess.hxx" #include "cachedattraccess.hxx"
#include "colorscale.hxx"
#include "conditio.hxx"
#include <xmloff/xmltoken.hxx> #include <xmloff/xmltoken.hxx>
#include <xmloff/xmlnmspe.hxx> #include <xmloff/xmlnmspe.hxx>
...@@ -2849,6 +2851,9 @@ void ScXMLExport::WriteTable(sal_Int32 nTable, const Reference<sheet::XSpreadshe ...@@ -2849,6 +2851,9 @@ void ScXMLExport::WriteTable(sal_Int32 nTable, const Reference<sheet::XSpreadshe
WriteNamedRange(pRangeName); WriteNamedRange(pRangeName);
} }
//export new conditional format information
ExportConditionalFormat();
} }
} }
...@@ -3789,6 +3794,97 @@ void ScXMLExport::WriteNamedRange(ScRangeName* pRangeName) ...@@ -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() void ScXMLExport::WriteExternalRefCaches()
{ {
if (!pDoc) if (!pDoc)
......
...@@ -205,6 +205,7 @@ class ScXMLExport : public SvXMLExport ...@@ -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 WriteLabelRanges( const com::sun::star::uno::Reference< com::sun::star::container::XIndexAccess >& xRangesIAccess, bool bColumn );
void WriteNamedExpressions(); void WriteNamedExpressions();
void WriteNamedRange(ScRangeName* pRangeName); void WriteNamedRange(ScRangeName* pRangeName);
void ExportConditionalFormat();
void WriteExternalRefCaches(); void WriteExternalRefCaches();
void WriteConsolidation(); // core implementation void WriteConsolidation(); // core implementation
......
...@@ -425,6 +425,7 @@ namespace xmloff { namespace token { ...@@ -425,6 +425,7 @@ namespace xmloff { namespace token {
XML_COLOR, XML_COLOR,
XML_COLOR_INVERSION, XML_COLOR_INVERSION,
XML_COLOR_MODE, XML_COLOR_MODE,
XML_COLOR_SCALE,
XML_COLUMN, XML_COLUMN,
XML_COLUMN_COUNT, XML_COLUMN_COUNT,
XML_COLUMN_GAP, XML_COLUMN_GAP,
...@@ -446,6 +447,8 @@ namespace xmloff { namespace token { ...@@ -446,6 +447,8 @@ namespace xmloff { namespace token {
XML_CONDITION_SOURCE, XML_CONDITION_SOURCE,
XML_CONDITION_SOURCE_RANGE_ADDRESS, XML_CONDITION_SOURCE_RANGE_ADDRESS,
XML_CONDITIONAL_TEXT, XML_CONDITIONAL_TEXT,
XML_CONDITIONAL_FORMAT,
XML_CONDITIONAL_FORMATS,
XML_CONE, XML_CONE,
XML_CONFERENCE, XML_CONFERENCE,
XML_CONFIG_ITEM, XML_CONFIG_ITEM,
...@@ -528,6 +531,8 @@ namespace xmloff { namespace token { ...@@ -528,6 +531,8 @@ namespace xmloff { namespace token {
XML_DASH, XML_DASH,
XML_DASHED, XML_DASHED,
XML_DATA, XML_DATA,
XML_DATA_BAR,
XML_DATA_BAR_ENTRY,
XML_DATA_CELL_RANGE_ADDRESS, XML_DATA_CELL_RANGE_ADDRESS,
XML_DATA_LABEL_NUMBER, XML_DATA_LABEL_NUMBER,
XML_DATA_LABEL_SYMBOL, XML_DATA_LABEL_SYMBOL,
...@@ -1381,6 +1386,7 @@ namespace xmloff { namespace token { ...@@ -1381,6 +1386,7 @@ namespace xmloff { namespace token {
XML_POSITION_LEFT, XML_POSITION_LEFT,
XML_POSITION_RIGHT, XML_POSITION_RIGHT,
XML_POSITION_TOP, XML_POSITION_TOP,
XML_POSITIVE_COLOR,
XML_POSTURE_ITALIC, XML_POSTURE_ITALIC,
XML_POSTURE_NORMAL, XML_POSTURE_NORMAL,
XML_POSTURE_OBLIQUE, XML_POSTURE_OBLIQUE,
......
...@@ -429,6 +429,7 @@ namespace xmloff { namespace token { ...@@ -429,6 +429,7 @@ namespace xmloff { namespace token {
TOKEN( "color", XML_COLOR ), TOKEN( "color", XML_COLOR ),
TOKEN( "color-inversion", XML_COLOR_INVERSION ), TOKEN( "color-inversion", XML_COLOR_INVERSION ),
TOKEN( "color-mode", XML_COLOR_MODE ), TOKEN( "color-mode", XML_COLOR_MODE ),
TOKEN( "color-scale", XML_COLOR_SCALE ),
TOKEN( "column", XML_COLUMN ), TOKEN( "column", XML_COLUMN ),
TOKEN( "column-count", XML_COLUMN_COUNT ), TOKEN( "column-count", XML_COLUMN_COUNT ),
TOKEN( "column-gap", XML_COLUMN_GAP ), TOKEN( "column-gap", XML_COLUMN_GAP ),
...@@ -450,6 +451,8 @@ namespace xmloff { namespace token { ...@@ -450,6 +451,8 @@ namespace xmloff { namespace token {
TOKEN( "condition-source", XML_CONDITION_SOURCE ), TOKEN( "condition-source", XML_CONDITION_SOURCE ),
TOKEN( "condition-source-range-address", XML_CONDITION_SOURCE_RANGE_ADDRESS ), TOKEN( "condition-source-range-address", XML_CONDITION_SOURCE_RANGE_ADDRESS ),
TOKEN( "conditional-text", XML_CONDITIONAL_TEXT ), TOKEN( "conditional-text", XML_CONDITIONAL_TEXT ),
TOKEN( "conditional-format", XML_CONDITIONAL_FORMAT ),
TOKEN( "conditional-formats", XML_CONDITIONAL_FORMATS ),
TOKEN( "cone", XML_CONE ), TOKEN( "cone", XML_CONE ),
TOKEN( "conference", XML_CONFERENCE ), TOKEN( "conference", XML_CONFERENCE ),
TOKEN( "config-item", XML_CONFIG_ITEM ), TOKEN( "config-item", XML_CONFIG_ITEM ),
...@@ -532,6 +535,8 @@ namespace xmloff { namespace token { ...@@ -532,6 +535,8 @@ namespace xmloff { namespace token {
TOKEN( "dash", XML_DASH ), TOKEN( "dash", XML_DASH ),
TOKEN( "dashed", XML_DASHED ), TOKEN( "dashed", XML_DASHED ),
TOKEN( "data", XML_DATA ), 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-cell-range-address", XML_DATA_CELL_RANGE_ADDRESS ),
TOKEN( "data-label-number", XML_DATA_LABEL_NUMBER ), TOKEN( "data-label-number", XML_DATA_LABEL_NUMBER ),
TOKEN( "data-label-symbol", XML_DATA_LABEL_SYMBOL ), TOKEN( "data-label-symbol", XML_DATA_LABEL_SYMBOL ),
...@@ -1386,6 +1391,7 @@ namespace xmloff { namespace token { ...@@ -1386,6 +1391,7 @@ namespace xmloff { namespace token {
TOKEN( "position-left", XML_POSITION_LEFT ), TOKEN( "position-left", XML_POSITION_LEFT ),
TOKEN( "position-right", XML_POSITION_RIGHT ), TOKEN( "position-right", XML_POSITION_RIGHT ),
TOKEN( "position-top", XML_POSITION_TOP ), TOKEN( "position-top", XML_POSITION_TOP ),
TOKEN( "positive-color", XML_POSITIVE_COLOR ),
TOKEN( "italic", XML_POSTURE_ITALIC ), TOKEN( "italic", XML_POSTURE_ITALIC ),
TOKEN( "normal", XML_POSTURE_NORMAL ), TOKEN( "normal", XML_POSTURE_NORMAL ),
TOKEN( "oblique", XML_POSTURE_OBLIQUE ), TOKEN( "oblique", XML_POSTURE_OBLIQUE ),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment