diff options
author | Eike Rathke <erack@redhat.com> | 2013-11-13 18:35:05 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2013-11-13 18:38:52 +0100 |
commit | 10515c6c6f2d7257b1e9f17b16f18a637dcbf5c8 (patch) | |
tree | fd166533da5edd6b891a01b16c80719bdf025dfc | |
parent | configure: NSS_MAJOR etc. unused since cffad630 (diff) | |
download | core-10515c6c6f2d7257b1e9f17b16f18a637dcbf5c8.tar.gz core-10515c6c6f2d7257b1e9f17b16f18a637dcbf5c8.zip |
fixed file format mappings always have RESOURCE_BASE separators
Change-Id: I7ac93f742b469156cd8eb3f8171c7e05a98598ad
-rw-r--r-- | formula/source/core/api/FormulaCompiler.cxx | 58 | ||||
-rw-r--r-- | include/formula/FormulaCompiler.hxx | 16 |
2 files changed, 46 insertions, 28 deletions
diff --git a/formula/source/core/api/FormulaCompiler.cxx b/formula/source/core/api/FormulaCompiler.cxx index b5f12679feec..d0990423eb86 100644 --- a/formula/source/core/api/FormulaCompiler.cxx +++ b/formula/source/core/api/FormulaCompiler.cxx @@ -144,33 +144,40 @@ void lclPushOpCodeMapEntries( ::std::vector< sheet::FormulaOpCodeMapEntry >& rVe class OpCodeList : public Resource // temp object for resource { public: - enum SeparatorType - { - SEMICOLON_BASE, - COMMA_BASE - }; - OpCodeList( sal_uInt16, FormulaCompiler::NonConstOpCodeMapPtr, SeparatorType = SEMICOLON_BASE ); + OpCodeList( sal_uInt16, FormulaCompiler::NonConstOpCodeMapPtr, + FormulaCompiler::SeparatorType = FormulaCompiler::SEMICOLON_BASE ); private: bool getOpCodeString( OUString& rStr, sal_uInt16 nOp ); void putDefaultOpCode( FormulaCompiler::NonConstOpCodeMapPtr xMap, sal_uInt16 nOp ); private: - SeparatorType meSepType; + FormulaCompiler::SeparatorType meSepType; }; -OpCodeList::OpCodeList( sal_uInt16 nRID, FormulaCompiler::NonConstOpCodeMapPtr xMap, SeparatorType eSepType ) : +OpCodeList::OpCodeList( sal_uInt16 nRID, FormulaCompiler::NonConstOpCodeMapPtr xMap, + FormulaCompiler::SeparatorType eSepType ) : Resource( ResId( nRID, *ResourceManager::getResManager())) , meSepType( eSepType) { - for (sal_uInt16 i = 0; i <= SC_OPCODE_LAST_OPCODE_ID; ++i) + if (meSepType == FormulaCompiler::RESOURCE_BASE) { - OUString aOpStr; - if ( getOpCodeString( aOpStr, i) ) - xMap->putOpCode( aOpStr, OpCode(i)); - else + for (sal_uInt16 i = 0; i <= SC_OPCODE_LAST_OPCODE_ID; ++i) + { putDefaultOpCode( xMap, i); + } + } + else + { + for (sal_uInt16 i = 0; i <= SC_OPCODE_LAST_OPCODE_ID; ++i) + { + OUString aOpStr; + if ( getOpCodeString( aOpStr, i) ) + xMap->putOpCode( aOpStr, OpCode(i)); + else + putDefaultOpCode( xMap, i); + } } FreeResource(); @@ -182,12 +189,12 @@ bool OpCodeList::getOpCodeString( OUString& rStr, sal_uInt16 nOp ) { case SC_OPCODE_SEP: { - if (meSepType == COMMA_BASE) + if (meSepType == FormulaCompiler::COMMA_BASE) { rStr = ","; return true; } - else if (meSepType == SEMICOLON_BASE) + else if (meSepType == FormulaCompiler::SEMICOLON_BASE) { rStr = ";"; return true; @@ -196,12 +203,12 @@ bool OpCodeList::getOpCodeString( OUString& rStr, sal_uInt16 nOp ) break; case SC_OPCODE_ARRAY_COL_SEP: { - if (meSepType == COMMA_BASE) + if (meSepType == FormulaCompiler::COMMA_BASE) { rStr = ","; return true; } - else if (meSepType == SEMICOLON_BASE) + else if (meSepType == FormulaCompiler::SEMICOLON_BASE) { rStr = ";"; return true; @@ -210,12 +217,12 @@ bool OpCodeList::getOpCodeString( OUString& rStr, sal_uInt16 nOp ) break; case SC_OPCODE_ARRAY_ROW_SEP: { - if (meSepType == COMMA_BASE) + if (meSepType == FormulaCompiler::COMMA_BASE) { rStr = ";"; return true; } - else if (meSepType == SEMICOLON_BASE) + else if (meSepType == FormulaCompiler::SEMICOLON_BASE) { rStr = "|"; return true; @@ -690,7 +697,7 @@ void FormulaCompiler::InitSymbolsPODF() const static OpCodeMapData aMap; osl::MutexGuard aGuard(&aMap.maMtx); if (!aMap.mxSymbolMap) - loadSymbols(RID_STRLIST_FUNCTION_NAMES_ENGLISH, FormulaGrammar::GRAM_PODF, aMap.mxSymbolMap); + loadSymbols(RID_STRLIST_FUNCTION_NAMES_ENGLISH, FormulaGrammar::GRAM_PODF, aMap.mxSymbolMap, RESOURCE_BASE); mxSymbolsPODF = aMap.mxSymbolMap; } @@ -699,7 +706,7 @@ void FormulaCompiler::InitSymbolsODFF() const static OpCodeMapData aMap; osl::MutexGuard aGuard(&aMap.maMtx); if (!aMap.mxSymbolMap) - loadSymbols(RID_STRLIST_FUNCTION_NAMES_ENGLISH_ODFF, FormulaGrammar::GRAM_ODFF, aMap.mxSymbolMap); + loadSymbols(RID_STRLIST_FUNCTION_NAMES_ENGLISH_ODFF, FormulaGrammar::GRAM_ODFF, aMap.mxSymbolMap, RESOURCE_BASE); mxSymbolsODFF = aMap.mxSymbolMap; } @@ -724,23 +731,20 @@ void FormulaCompiler::InitSymbolsOOXML() const static OpCodeMapData aMap; osl::MutexGuard aGuard(&aMap.maMtx); if (!aMap.mxSymbolMap) - loadSymbols(RID_STRLIST_FUNCTION_NAMES_ENGLISH_OOXML, FormulaGrammar::GRAM_OOXML, aMap.mxSymbolMap); + loadSymbols(RID_STRLIST_FUNCTION_NAMES_ENGLISH_OOXML, FormulaGrammar::GRAM_OOXML, aMap.mxSymbolMap, RESOURCE_BASE); mxSymbolsOOXML = aMap.mxSymbolMap; } void FormulaCompiler::loadSymbols( sal_uInt16 nSymbols, FormulaGrammar::Grammar eGrammar, - NonConstOpCodeMapPtr& rxMap) const + NonConstOpCodeMapPtr& rxMap, SeparatorType eSepType) const { if ( !rxMap.get() ) { // not Core rxMap.reset( new OpCodeMap( SC_OPCODE_LAST_OPCODE_ID + 1, eGrammar != FormulaGrammar::GRAM_ODFF, eGrammar )); OModuleClient aModuleClient; - OpCodeList aOpCodeList( nSymbols, rxMap, - ((eGrammar == FormulaGrammar::GRAM_OOXML) ? - OpCodeList::COMMA_BASE : - OpCodeList::SEMICOLON_BASE)); + OpCodeList aOpCodeList( nSymbols, rxMap, eSepType); fillFromAddInMap( rxMap, eGrammar); // Fill from collection for AddIns not already present. diff --git a/include/formula/FormulaCompiler.hxx b/include/formula/FormulaCompiler.hxx index 5ce3c2dc3b2b..ff2ebf35b9ad 100644 --- a/include/formula/FormulaCompiler.hxx +++ b/include/formula/FormulaCompiler.hxx @@ -256,6 +256,18 @@ public: static void UpdateSeparatorsNative( const OUString& rSep, const OUString& rArrayColSep, const OUString& rArrayRowSep ); static void ResetNativeSymbols(); static void SetNativeSymbols( const OpCodeMapPtr& xMap ); + + /** Separators mapped when loading opcodes from the resource, values other + than RESOURCE_BASE may override the resource strings. Used by OpCodeList + implementation via loadSymbols(). + */ + enum SeparatorType + { + RESOURCE_BASE, + SEMICOLON_BASE, + COMMA_BASE + }; + protected: virtual OUString FindAddInFunction( const OUString& rUpperName, bool bLocalFirst ) const; virtual void fillFromAddInCollectionUpperName( NonConstOpCodeMapPtr xMap ) const; @@ -327,6 +339,7 @@ protected: bool bIgnoreErrors; // on AutoCorrect and CompileForFAP // ignore errors and create RPN nevertheless bool glSubTotal; // if code contains one or more subtotal functions + private: void InitSymbolsNative() const; /// only SymbolsNative, on first document creation void InitSymbolsEnglish() const; /// only SymbolsEnglish, maybe later @@ -335,7 +348,8 @@ private: void InitSymbolsEnglishXL() const; /// only SymbolsEnglishXL, on demand void InitSymbolsOOXML() const; /// only SymbolsOOXML, on demand - void loadSymbols(sal_uInt16 _nSymbols,FormulaGrammar::Grammar _eGrammar,NonConstOpCodeMapPtr& _xMap) const; + void loadSymbols( sal_uInt16 nSymbols, FormulaGrammar::Grammar eGrammar, NonConstOpCodeMapPtr& rxMap, + SeparatorType eSepType = SEMICOLON_BASE ) const; static inline void ForceArrayOperator( FormulaTokenRef& rCurr, const FormulaTokenRef& rPrev ) { |