summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorNoel Power <noel.power@suse.com>2013-05-27 14:53:49 +0100
committerNoel Power <noel.power@suse.com>2013-05-27 19:44:49 +0100
commit10ceb0c3a27a9052e84582aef9e98dd2e206c195 (patch)
tree5383b34ce9c853008b604e9086c734f60966d190 /sc
parent96b8aa8ed659ef0501bcbc01f01c9013dbe4bc77 (diff)
buffer ExtCfRuleContext startElement processing
ExtCfRuleContext::onStartElement processing depends on some data now buffered until CondFormatBuffer::finalizeImport runs. We now need to wait for this data to be available. This change buffers up the processing that used happen in ExtCfRuleContext startElement so it is now done as part of CondFormatBuffer::finalizeImport Change-Id: Ifbfe12740e6c4bc9791183dba89acb79cbbb6ef6
Diffstat (limited to 'sc')
-rw-r--r--sc/source/filter/inc/condformatbuffer.hxx43
-rw-r--r--sc/source/filter/oox/condformatbuffer.cxx107
-rw-r--r--sc/source/filter/oox/extlstcontext.cxx24
3 files changed, 169 insertions, 5 deletions
diff --git a/sc/source/filter/inc/condformatbuffer.hxx b/sc/source/filter/inc/condformatbuffer.hxx
index 8420aaf7b519..2ea0f93c1cdc 100644
--- a/sc/source/filter/inc/condformatbuffer.hxx
+++ b/sc/source/filter/inc/condformatbuffer.hxx
@@ -231,7 +231,47 @@ private:
bool mbReadyForFinalize;
};
+struct ExCfRuleModel
+{
+ ExCfRuleModel() : mbGradient( false ), mbNegativeBarColorSameAsPositive( false ), mnAxisColor( API_RGB_TRANSPARENT ), mnNegativeColor( API_RGB_TRANSPARENT ), mbIsLower( true ) {}
+ // DataBar
+ bool mbGradient;
+ OUString maAxisPosition;
+ bool mbNegativeBarColorSameAsPositive;
+ // AxisColor
+ sal_Int32 mnAxisColor;
+ // NegativeFillColor
+ sal_Int32 mnNegativeColor;
+ // Cfvo
+ bool mbIsLower;
+ OUString maColorScaleType;
+};
+
+class ExtCfRule
+{
+ enum RuleType
+ {
+ DATABAR,
+ NEGATIVEFILLCOLOR,
+ AXISCOLOR,
+ CFVO,
+ UNKNOWN,
+ };
+ ExCfRuleModel maModel;
+ RuleType mnRuleType;
+ void* mpTarget;
+public:
+ ExtCfRule(void* pTarget = NULL ) : mnRuleType( ExtCfRule::RuleType::UNKNOWN ), mpTarget(pTarget) {}
+ void finalizeImport();
+ void importDataBar( const AttributeList& rAttribs );
+ void importNegativeFillColor( const AttributeList& rAttribs );
+ void importAxisColor( const AttributeList& rAttribs );
+ void importCfvo( const AttributeList& rAttribs );
+ ExCfRuleModel& getModel() { return maModel; }
+};
+
typedef ::boost::shared_ptr< CondFormat > CondFormatRef;
+typedef ::boost::shared_ptr< ExtCfRule > ExtCfRuleRef;
// ============================================================================
@@ -244,6 +284,7 @@ public:
CondFormatRef importConditionalFormatting( const AttributeList& rAttribs );
/** Imports settings from the CONDFORMATTING record. */
CondFormatRef importCondFormatting( SequenceInputStream& rStrm );
+ ExtCfRuleRef createExtCfRule( void* pTarget );
/** Converts an OOXML condition operator token to the API constant. */
static sal_Int32 convertToApiOperator( sal_Int32 nToken );
@@ -254,7 +295,9 @@ private:
private:
typedef RefVector< CondFormat > CondFormatVec;
+ typedef RefVector< ExtCfRule > ExtCfRuleVec;
CondFormatVec maCondFormats; /// All conditional formatting in a sheet.
+ ExtCfRuleVec maCfRules; /// All external conditional formatting rules in a sheet.
};
// ============================================================================
diff --git a/sc/source/filter/oox/condformatbuffer.cxx b/sc/source/filter/oox/condformatbuffer.cxx
index 6660ac9c5784..70a8b65279f9 100644
--- a/sc/source/filter/oox/condformatbuffer.cxx
+++ b/sc/source/filter/oox/condformatbuffer.cxx
@@ -1023,6 +1023,13 @@ void CondFormatBuffer::finalizeImport()
if ( (*it).get() )
(*it).get()->finalizeImport();
}
+ ExtCfRuleVec::iterator ext_it = maCfRules.begin();
+ ExtCfRuleVec::iterator ext_end = maCfRules.end();
+ for ( ; ext_it != ext_end; ++ext_it )
+ {
+ if ( (*ext_it).get() )
+ (*ext_it).get()->finalizeImport();
+ }
}
CondFormatRef CondFormatBuffer::importCondFormatting( SequenceInputStream& rStrm )
@@ -1032,6 +1039,13 @@ CondFormatRef CondFormatBuffer::importCondFormatting( SequenceInputStream& rStrm
return xCondFmt;
}
+ExtCfRuleRef CondFormatBuffer::createExtCfRule( void* pTarget )
+{
+ ExtCfRuleRef extRule( new ExtCfRule( pTarget ) );
+ maCfRules.push_back( extRule );
+ return extRule;
+}
+
sal_Int32 CondFormatBuffer::convertToApiOperator( sal_Int32 nToken )
{
switch( nToken )
@@ -1075,7 +1089,100 @@ CondFormatRef CondFormatBuffer::createCondFormat()
maCondFormats.push_back( xCondFmt );
return xCondFmt;
}
+/*
+::Color RgbToRgbComponents( sal_Int32 nRgb )
+{
+ sal_Int32 ornR = (nRgb >> 16) & 0xFF;
+ sal_Int32 ornG = (nRgb >> 8) & 0xFF;
+ sal_Int32 ornB = nRgb & 0xFF;
+
+ return ::Color(ornR, ornG, ornB);
+}
+*/
+
+void ExtCfRule::finalizeImport()
+{
+ switch ( mnRuleType )
+ {
+ case DATABAR:
+ {
+ ScDataBarFormatData* pDataBar = static_cast<ScDataBarFormatData*>(mpTarget);
+ if( maModel.maAxisPosition == "none" )
+ pDataBar->meAxisPosition = databar::NONE;
+ else if( maModel.maAxisPosition == "middle" )
+ pDataBar->meAxisPosition = databar::MIDDLE;
+ else
+ pDataBar->meAxisPosition = databar::AUTOMATIC;
+ pDataBar->mbNeg = !maModel.mbGradient;
+ break;
+ }
+ case AXISCOLOR:
+ {
+ ScDataBarFormatData* pDataBar = static_cast<ScDataBarFormatData*>(mpTarget);
+ pDataBar->maAxisColor = RgbToRgbComponents(maModel.mnAxisColor);
+ break;
+ }
+ case NEGATIVEFILLCOLOR:
+ {
+ ScDataBarFormatData* pDataBar = static_cast<ScDataBarFormatData*>(mpTarget);
+ pDataBar->mpNegativeColor.reset( new ::Color( RgbToRgbComponents(maModel.mnNegativeColor) ) );
+ break;
+ }
+ case CFVO:
+ {
+ ScDataBarFormatData* pDataBar = static_cast<ScDataBarFormatData*>(mpTarget);
+ ScColorScaleEntry* pEntry = NULL;
+ if(maModel.mbIsLower)
+ pEntry = pDataBar->mpLowerLimit.get();
+ else
+ pEntry = pDataBar->mpUpperLimit.get();
+
+ if(maModel.maColorScaleType == "min")
+ pEntry->SetType(COLORSCALE_MIN);
+ else if (maModel.maColorScaleType == "max")
+ pEntry->SetType(COLORSCALE_MAX);
+ else if (maModel.maColorScaleType == "autoMin")
+ pEntry->SetType(COLORSCALE_AUTO);
+ else if (maModel.maColorScaleType == "autoMax")
+ pEntry->SetType(COLORSCALE_AUTO);
+ else if (maModel.maColorScaleType == "percentile")
+ pEntry->SetType(COLORSCALE_PERCENTILE);
+ else if (maModel.maColorScaleType == "percent")
+ pEntry->SetType(COLORSCALE_PERCENT);
+ else if (maModel.maColorScaleType == "formula")
+ pEntry->SetType(COLORSCALE_FORMULA);
+ break;
+ }
+ case UNKNOWN: // nothing to do
+ default:
+ break;
+ };
+}
+void ExtCfRule::importDataBar( const AttributeList& rAttribs )
+{
+ mnRuleType = DATABAR;
+ maModel.mbGradient = rAttribs.getBool( XML_gradient, true );
+ maModel.maAxisPosition = rAttribs.getString( XML_axisPosition, "automatic" );
+}
+
+void ExtCfRule::importNegativeFillColor( const AttributeList& rAttribs )
+{
+ mnRuleType = NEGATIVEFILLCOLOR;
+ maModel.mnNegativeColor = rAttribs.getIntegerHex( XML_rgb, API_RGB_TRANSPARENT );
+}
+
+void ExtCfRule::importAxisColor( const AttributeList& rAttribs )
+{
+ mnRuleType = AXISCOLOR;
+ maModel.mnAxisColor = rAttribs.getIntegerHex( XML_rgb, API_RGB_TRANSPARENT );
+}
+
+void ExtCfRule::importCfvo( const AttributeList& rAttribs )
+{
+ mnRuleType = CFVO;
+ maModel.maColorScaleType = rAttribs.getString( XML_type, OUString() );
+}
// ============================================================================
} // namespace xls
diff --git a/sc/source/filter/oox/extlstcontext.cxx b/sc/source/filter/oox/extlstcontext.cxx
index b949288cfb7d..8d83845b7efd 100644
--- a/sc/source/filter/oox/extlstcontext.cxx
+++ b/sc/source/filter/oox/extlstcontext.cxx
@@ -11,6 +11,7 @@
#include "worksheethelper.hxx"
#include <oox/core/contexthandler.hxx>
#include "colorscale.hxx"
+#include "condformatbuffer.hxx"
using ::oox::core::ContextHandlerRef;
@@ -34,18 +35,31 @@ void ExtCfRuleContext::onStartElement( const AttributeList& rAttribs )
switch( getCurrentElement() )
{
case XLS_EXT_TOKEN( dataBar ):
- importDataBar( rAttribs );
+ {
+ ExtCfRuleRef xRule = getCondFormats().createExtCfRule(mpTarget);
+ xRule->importDataBar( rAttribs );
break;
+ }
case XLS_EXT_TOKEN( negativeFillColor ):
- importNegativeFillColor( rAttribs );
+ {
+ ExtCfRuleRef xRule = getCondFormats().createExtCfRule(mpTarget);
+ xRule->importNegativeFillColor( rAttribs );
break;
+ }
case XLS_EXT_TOKEN( axisColor ):
- importAxisColor( rAttribs );
+ {
+ ExtCfRuleRef xRule = getCondFormats().createExtCfRule(mpTarget);
+ xRule->importAxisColor( rAttribs );
break;
+ }
case XLS_EXT_TOKEN( cfvo ):
- importCfvo( rAttribs );
+ {
+ ExtCfRuleRef xRule = getCondFormats().createExtCfRule(mpTarget);
+ xRule->importCfvo( rAttribs );
+ xRule->getModel().mbIsLower = mbFirstEntry;
+ mbFirstEntry = false;
break;
-
+ }
default:
break;
}