summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-05-10 10:50:36 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2012-05-10 12:41:46 +0200
commite6e1470c6e9c027aa5794a88280a2b56a5062663 (patch)
tree6a0fe7eebab231910d6015e9a3f670e2332089e8
parentf26bf2ba01fc8ed453f3a42a39c26e2cf809c40f (diff)
import min, max and percent entries for color scales from xlsx
Change-Id: I Icebacfd711851c9223ed8f38d6445c82f575a47d
-rw-r--r--sc/source/filter/inc/condformatbuffer.hxx25
-rw-r--r--sc/source/filter/oox/condformatbuffer.cxx51
-rw-r--r--sc/source/filter/oox/condformatcontext.cxx2
3 files changed, 66 insertions, 12 deletions
diff --git a/sc/source/filter/inc/condformatbuffer.hxx b/sc/source/filter/inc/condformatbuffer.hxx
index 0da0ba0133bf..7eb634291f6e 100644
--- a/sc/source/filter/inc/condformatbuffer.hxx
+++ b/sc/source/filter/inc/condformatbuffer.hxx
@@ -76,20 +76,39 @@ struct CondFormatRuleModel
void setBiff12TextType( sal_Int32 nOperator );
};
+struct ColorScaleRuleModelEntry
+{
+ ::Color maColor;
+ double mnVal;
+
+ bool mbMin;
+ bool mbMax;
+ bool mbPercent;
+
+ ColorScaleRuleModelEntry():
+ maColor(),
+ mnVal(0),
+ mbMin(false),
+ mbMax(false),
+ mbPercent(false) {}
+};
+
class ColorScaleRule : public WorksheetHelper
{
public:
ColorScaleRule( const CondFormat& rFormat );
- void importValue( const AttributeList& rAttribs );
+ void importCfvo( const AttributeList& rAttribs );
void importColor( const AttributeList& rAttribs );
void AddEntries( ScColorScaleFormat* pFormat );
private:
const CondFormat& mrCondFormat;
- std::vector< ::Color > maColors;
- std::vector< double > maValues;
+ std::vector< ColorScaleRuleModelEntry > maColorScaleRuleEntries;
+
+ sal_uInt32 mnCfvo;
+ sal_uInt32 mnCol;
};
diff --git a/sc/source/filter/oox/condformatbuffer.cxx b/sc/source/filter/oox/condformatbuffer.cxx
index 8cc7778d60c9..0b6ddf7b3768 100644
--- a/sc/source/filter/oox/condformatbuffer.cxx
+++ b/sc/source/filter/oox/condformatbuffer.cxx
@@ -145,18 +145,39 @@ void lclAppendProperty( ::std::vector< PropertyValue >& orProps, const OUString&
ColorScaleRule::ColorScaleRule( const CondFormat& rFormat ):
WorksheetHelper( rFormat ),
- mrCondFormat( rFormat )
+ mrCondFormat( rFormat ),
+ mnCfvo(0),
+ mnCol(0)
{
}
-void ColorScaleRule::importValue( const AttributeList& rAttribs )
+void ColorScaleRule::importCfvo( const AttributeList& rAttribs )
{
+ if(mnCfvo >= maColorScaleRuleEntries.size())
+ maColorScaleRuleEntries.push_back(ColorScaleRuleModelEntry());
+
rtl::OUString aType = rAttribs.getString( XML_type, rtl::OUString() );
+
+ double nVal = rAttribs.getDouble( XML_val, 0.0 );
+ maColorScaleRuleEntries[mnCfvo].mnVal = nVal;
if (aType == "num")
{
- double nVal = rAttribs.getDouble( XML_val, 0.0 );
- maValues.push_back(nVal);
+ // nothing to do
+ }
+ else if( aType == "min" )
+ {
+ maColorScaleRuleEntries[mnCfvo].mbMin = true;
}
+ else if( aType == "max" )
+ {
+ maColorScaleRuleEntries[mnCfvo].mbMax = true;
+ }
+ else if( aType == "percent" )
+ {
+ maColorScaleRuleEntries[mnCfvo].mbPercent = true;
+ }
+
+ ++mnCfvo;
}
namespace {
@@ -177,17 +198,31 @@ void ColorScaleRule::importColor( const AttributeList& rAttribs )
sal_Int32 nColor = rAttribs.getIntegerHex( XML_rgb, API_RGB_TRANSPARENT );
::Color aColor = RgbToRgbComponents( nColor );
- maColors.push_back(aColor);
+
+ if(mnCol >= maColorScaleRuleEntries.size())
+ maColorScaleRuleEntries.push_back(ColorScaleRuleModelEntry());
+
+ maColorScaleRuleEntries[mnCol].maColor = aColor;
+ ++mnCol;
}
void ColorScaleRule::AddEntries( ScColorScaleFormat* pFormat )
{
//assume that both vectors contain the same entries
// TODO: check it
- size_t n = std::min<size_t>(maColors.size(), maValues.size());
- for(size_t i = 0; i < n; ++i)
+ for(size_t i = 0; i < maColorScaleRuleEntries.size(); ++i)
{
- pFormat->AddEntry( new ScColorScaleEntry(maValues[i], maColors[i]) );
+ ScColorScaleEntry* pEntry = new ScColorScaleEntry(maColorScaleRuleEntries[i].mnVal, maColorScaleRuleEntries[i].maColor);
+ const ColorScaleRuleModelEntry& rEntry = maColorScaleRuleEntries[i];
+
+ if(rEntry.mbMin)
+ pEntry->SetMin(true);
+ if(rEntry.mbMax)
+ pEntry->SetMax(true);
+ if(rEntry.mbPercent)
+ pEntry->SetPercent(true);
+
+ pFormat->AddEntry( pEntry );
}
}
diff --git a/sc/source/filter/oox/condformatcontext.cxx b/sc/source/filter/oox/condformatcontext.cxx
index 0ba54c712263..ff73a8ee21ab 100644
--- a/sc/source/filter/oox/condformatcontext.cxx
+++ b/sc/source/filter/oox/condformatcontext.cxx
@@ -66,7 +66,7 @@ void ColorScaleContext::onStartElement( const AttributeList& rAttribs )
switch( getCurrentElement() )
{
case XLS_TOKEN( cfvo ):
- mxRule->getColorScale()->importValue( rAttribs );
+ mxRule->getColorScale()->importCfvo( rAttribs );
break;
case XLS_TOKEN( color ):
mxRule->getColorScale()->importColor( rAttribs );