From 8b9a263a55859a46d301b7ae9574fe0bb5050c55 Mon Sep 17 00:00:00 2001 From: Markus Mohrhard Date: Thu, 1 Nov 2012 22:50:55 +0100 Subject: change ooxml cond format import from API to calc core enums Change-Id: I59b6df511ddab6cb2cb29b8b8b1c635a188594a1 --- sc/source/filter/inc/condformatbuffer.hxx | 1 + sc/source/filter/oox/condformatbuffer.cxx | 33 +++++++++++++++++++++++-------- 2 files changed, 26 insertions(+), 8 deletions(-) (limited to 'sc') diff --git a/sc/source/filter/inc/condformatbuffer.hxx b/sc/source/filter/inc/condformatbuffer.hxx index 9dfe34ecba14..568f09db4a4c 100644 --- a/sc/source/filter/inc/condformatbuffer.hxx +++ b/sc/source/filter/inc/condformatbuffer.hxx @@ -254,6 +254,7 @@ public: /** Converts an OOXML condition operator token to the API constant. */ static sal_Int32 convertToApiOperator( sal_Int32 nToken ); + static sal_Int32 convertToInternalOperator( sal_Int32 nToken ); private: CondFormatRef createCondFormat(); diff --git a/sc/source/filter/oox/condformatbuffer.cxx b/sc/source/filter/oox/condformatbuffer.cxx index aa93f426b104..c1452100e799 100644 --- a/sc/source/filter/oox/condformatbuffer.cxx +++ b/sc/source/filter/oox/condformatbuffer.cxx @@ -639,7 +639,7 @@ void CondFormatRule::importCfRule( SequenceInputStream& rStrm ) void CondFormatRule::finalizeImport() { - sal_Int32 eOperator = ::com::sun::star::sheet::ConditionOperator2::NONE; + ScConditionMode eOperator = SC_COND_NONE; /* Replacement formula for unsupported rule types (text comparison rules, time period rules, cell type rules). The replacement formulas below may @@ -663,14 +663,14 @@ void CondFormatRule::finalizeImport() switch( maModel.mnType ) { case XML_cellIs: - eOperator = CondFormatBuffer::convertToApiOperator( maModel.mnOperator ); + eOperator = static_cast(CondFormatBuffer::convertToInternalOperator( maModel.mnOperator )); break; case XML_duplicateValues: - eOperator = CondFormatBuffer::convertToApiOperator( XML_duplicateValues ); + eOperator = static_cast(CondFormatBuffer::convertToInternalOperator( XML_duplicateValues )); aReplaceFormula = " "; break; case XML_expression: - eOperator = ::com::sun::star::sheet::ConditionOperator2::FORMULA; + eOperator = SC_COND_DIRECT; break; case XML_containsText: OSL_ENSURE( maModel.mnOperator == XML_containsText, "CondFormatRule::finalizeImport - unexpected operator" ); @@ -803,14 +803,14 @@ void CondFormatRule::finalizeImport() // set the replacement formula maModel.maFormulas.clear(); appendFormula( aReplaceFormula ); - if( eOperator != ::com::sun::star::sheet::ConditionOperator2::DUPLICATE ) - eOperator = ::com::sun::star::sheet::ConditionOperator2::FORMULA; + if( eOperator != SC_COND_DUPLICATE ) + eOperator = SC_COND_DIRECT; } CellAddress aBaseAddr = mrCondFormat.getRanges().getBaseAddress(); ScAddress aPos; ScUnoConversion::FillScAddress( aPos, aBaseAddr ); - if( (eOperator != ::com::sun::star::sheet::ConditionOperator2::NONE) && !maModel.maFormulas.empty() ) + if( (eOperator != SC_COND_NONE) && !maModel.maFormulas.empty() ) { ScDocument& rDoc = getScDocument(); boost::scoped_ptr pTokenArray2; @@ -823,7 +823,7 @@ void CondFormatRule::finalizeImport() ScTokenArray aTokenArray; OUString aStyleName = getStyles().createDxfStyle( maModel.mnDxfId ); ScTokenConversion::ConvertToTokenArray( rDoc, aTokenArray, maModel.maFormulas[ 0 ] ); - ScCondFormatEntry* pNewEntry = new ScCondFormatEntry(ScCondFormatEntry::GetModeFromApi(eOperator), + ScCondFormatEntry* pNewEntry = new ScCondFormatEntry(eOperator, &aTokenArray, pTokenArray2.get(), &rDoc, aPos, aStyleName); mpFormat->AddEntry(pNewEntry); } @@ -995,6 +995,23 @@ sal_Int32 CondFormatBuffer::convertToApiOperator( sal_Int32 nToken ) return ConditionOperator2::NONE; } +sal_Int32 CondFormatBuffer::convertToInternalOperator( sal_Int32 nToken ) +{ + switch( nToken ) + { + case XML_between: return SC_COND_BETWEEN; + case XML_equal: return SC_COND_EQUAL; + case XML_greaterThan: return SC_COND_GREATER; + case XML_greaterThanOrEqual: return SC_COND_EQGREATER; + case XML_lessThan: return SC_COND_LESS; + case XML_lessThanOrEqual: return SC_COND_EQLESS; + case XML_notBetween: return SC_COND_NOTBETWEEN; + case XML_notEqual: return SC_COND_NOTEQUAL; + case XML_duplicateValues: return SC_COND_DUPLICATE; + } + return ConditionOperator2::NONE; +} + // private -------------------------------------------------------------------- CondFormatRef CondFormatBuffer::createCondFormat() -- cgit