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

import formulas for color scales from xlsx

Change-Id: If19c6486c95cab0106bf04a4ec68359f7a4ed220
üst caa7f3f5
...@@ -84,6 +84,7 @@ struct ColorScaleRuleModelEntry ...@@ -84,6 +84,7 @@ struct ColorScaleRuleModelEntry
bool mbMin; bool mbMin;
bool mbMax; bool mbMax;
bool mbPercent; bool mbPercent;
rtl::OUString maFormula;
ColorScaleRuleModelEntry(): ColorScaleRuleModelEntry():
maColor(), maColor(),
...@@ -101,7 +102,7 @@ public: ...@@ -101,7 +102,7 @@ public:
void importCfvo( const AttributeList& rAttribs ); void importCfvo( const AttributeList& rAttribs );
void importColor( const AttributeList& rAttribs ); void importColor( const AttributeList& rAttribs );
void AddEntries( ScColorScaleFormat* pFormat ); void AddEntries( ScColorScaleFormat* pFormat, ScDocument* pDoc, const ScAddress& rAddr );
private: private:
const CondFormat& mrCondFormat; const CondFormat& mrCondFormat;
......
...@@ -182,6 +182,11 @@ void ColorScaleRule::importCfvo( const AttributeList& rAttribs ) ...@@ -182,6 +182,11 @@ void ColorScaleRule::importCfvo( const AttributeList& rAttribs )
// between percent and percentile should be when calculating colors // between percent and percentile should be when calculating colors
maColorScaleRuleEntries[mnCfvo].mbPercent = true; maColorScaleRuleEntries[mnCfvo].mbPercent = true;
} }
else if( aType == "formula" )
{
rtl::OUString aFormula = rAttribs.getString( XML_val, rtl::OUString() );
maColorScaleRuleEntries[mnCfvo].maFormula = aFormula;
}
++mnCfvo; ++mnCfvo;
} }
...@@ -212,7 +217,7 @@ void ColorScaleRule::importColor( const AttributeList& rAttribs ) ...@@ -212,7 +217,7 @@ void ColorScaleRule::importColor( const AttributeList& rAttribs )
++mnCol; ++mnCol;
} }
void ColorScaleRule::AddEntries( ScColorScaleFormat* pFormat ) void ColorScaleRule::AddEntries( ScColorScaleFormat* pFormat, ScDocument* pDoc, const ScAddress& rAddr )
{ {
//assume that both vectors contain the same entries //assume that both vectors contain the same entries
// TODO: check it // TODO: check it
...@@ -228,6 +233,9 @@ void ColorScaleRule::AddEntries( ScColorScaleFormat* pFormat ) ...@@ -228,6 +233,9 @@ void ColorScaleRule::AddEntries( ScColorScaleFormat* pFormat )
if(rEntry.mbPercent) if(rEntry.mbPercent)
pEntry->SetPercent(true); pEntry->SetPercent(true);
if(!rEntry.maFormula.isEmpty())
pEntry->SetFormula(rEntry.maFormula, pDoc, rAddr, formula::FormulaGrammar::GRAM_ENGLISH_XL_A1);
pFormat->AddEntry( pEntry ); pFormat->AddEntry( pEntry );
} }
} }
...@@ -699,7 +707,6 @@ void CondFormatRule::finalizeImport( const Reference< XSheetConditionalEntries > ...@@ -699,7 +707,6 @@ void CondFormatRule::finalizeImport( const Reference< XSheetConditionalEntries >
ScDocument& rDoc = getScDocument(); ScDocument& rDoc = getScDocument();
ScColorScaleFormat* pFormat = new ScColorScaleFormat(&rDoc); ScColorScaleFormat* pFormat = new ScColorScaleFormat(&rDoc);
mpColor->AddEntries( pFormat );
sal_Int32 nIndex = rDoc.AddColorScaleFormat(pFormat); sal_Int32 nIndex = rDoc.AddColorScaleFormat(pFormat);
ScRangeList aList; ScRangeList aList;
...@@ -720,6 +727,10 @@ void CondFormatRule::finalizeImport( const Reference< XSheetConditionalEntries > ...@@ -720,6 +727,10 @@ void CondFormatRule::finalizeImport( const Reference< XSheetConditionalEntries >
aList.Append(aRange); aList.Append(aRange);
} }
pFormat->SetRange(aList); pFormat->SetRange(aList);
if(aList.size())
mpColor->AddEntries( pFormat, &rDoc, aList.front()->aStart );
else
mpColor->AddEntries( pFormat, &rDoc, ScAddress() );
} }
} }
......
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