diff options
-rw-r--r-- | sc/inc/calcconfig.hxx | 1 | ||||
-rw-r--r-- | sc/inc/document.hxx | 6 | ||||
-rw-r--r-- | sc/qa/unit/ucalc.cxx | 12 | ||||
-rw-r--r-- | sc/qa/unit/ucalc_formula.cxx | 6 | ||||
-rw-r--r-- | sc/source/core/data/documen2.cxx | 2 | ||||
-rw-r--r-- | sc/source/core/data/document10.cxx | 10 | ||||
-rw-r--r-- | sc/source/core/inc/interpre.hxx | 5 | ||||
-rw-r--r-- | sc/source/core/tool/calcconfig.cxx | 9 | ||||
-rw-r--r-- | sc/source/core/tool/interpr1.cxx | 4 | ||||
-rw-r--r-- | sc/source/core/tool/interpr4.cxx | 14 | ||||
-rw-r--r-- | sc/source/core/tool/interpr5.cxx | 2 | ||||
-rw-r--r-- | sc/source/ui/app/scmod.cxx | 9 | ||||
-rw-r--r-- | sc/source/ui/docshell/docsh6.cxx | 8 | ||||
-rw-r--r-- | sc/source/ui/inc/docsh.hxx | 1 |
14 files changed, 73 insertions, 16 deletions
diff --git a/sc/inc/calcconfig.hxx b/sc/inc/calcconfig.hxx index c477e726410a..1c0fadf289b4 100644 --- a/sc/inc/calcconfig.hxx +++ b/sc/inc/calcconfig.hxx @@ -47,6 +47,7 @@ struct SC_DLLPUBLIC ScCalcConfig ScCalcConfig(); void reset(); + void MergeDocumentSpecific( const ScCalcConfig& r ); bool operator== (const ScCalcConfig& r) const; bool operator!= (const ScCalcConfig& r) const; diff --git a/sc/inc/document.hxx b/sc/inc/document.hxx index a6af9fb6295f..2d39f5ac175f 100644 --- a/sc/inc/document.hxx +++ b/sc/inc/document.hxx @@ -37,6 +37,7 @@ #include "typedstrdata.hxx" #include "compressedarray.hxx" #include "calcmacros.hxx" +#include "calcconfig.hxx" #include <tools/fract.hxx> #include <tools/gen.hxx> @@ -267,6 +268,8 @@ private: boost::scoped_ptr<sc::FormulaGroupContext> mpFormulaGroupCxt; mutable boost::scoped_ptr<sc::DocumentLinkManager> mpDocLinkMgr; + ScCalcConfig maCalcConfig; + SfxUndoManager* mpUndoManager; ScFieldEditEngine* pEditEngine; // uses pEditPool from xPoolHelper ScNoteEditEngine* pNoteEngine; // uses pEditPool from xPoolHelper @@ -2062,6 +2065,9 @@ public: SC_DLLPUBLIC void DumpFormulaGroups( SCTAB nTab, SCCOL nCol ) const; #endif + void SetCalcConfig( const ScCalcConfig& rConfig ); + const ScCalcConfig& GetCalcConfig() const; + private: // CLOOK-Impl-methods /** diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index e1e95299c5f2..36265021e00d 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -1670,7 +1670,7 @@ void Test::testFuncParam() // With "Convert also locale dependent" and "Empty string as zero"=True option. aConfig.meStringConversion = ScCalcConfig::STRING_CONVERSION_LOCALE_DEPENDENT; aConfig.mbEmptyStringAsZero = true; - ScInterpreter::SetGlobalConfig(aConfig); + m_pDoc->SetCalcConfig(aConfig); m_pDoc->CalcAll(); m_pDoc->GetValue(0, 0, 0, val); CPPUNIT_ASSERT_MESSAGE("incorrect result", val == 3); @@ -1686,7 +1686,7 @@ void Test::testFuncParam() // With "Convert also locale dependent" and "Empty string as zero"=False option. aConfig.meStringConversion = ScCalcConfig::STRING_CONVERSION_LOCALE_DEPENDENT; aConfig.mbEmptyStringAsZero = false; - ScInterpreter::SetGlobalConfig(aConfig); + m_pDoc->SetCalcConfig(aConfig); m_pDoc->CalcAll(); aVal = m_pDoc->GetString( 0, 0, 0); CPPUNIT_ASSERT_MESSAGE("incorrect result", aVal == "#VALUE!"); @@ -1702,7 +1702,7 @@ void Test::testFuncParam() // With "Convert only unambiguous" and "Empty string as zero"=True option. aConfig.meStringConversion = ScCalcConfig::STRING_CONVERSION_UNAMBIGUOUS; aConfig.mbEmptyStringAsZero = true; - ScInterpreter::SetGlobalConfig(aConfig); + m_pDoc->SetCalcConfig(aConfig); m_pDoc->CalcAll(); m_pDoc->GetValue(0, 0, 0, val); CPPUNIT_ASSERT_MESSAGE("incorrect result", val == 3); @@ -1718,7 +1718,7 @@ void Test::testFuncParam() // With "Convert only unambiguous" and "Empty string as zero"=False option. aConfig.meStringConversion = ScCalcConfig::STRING_CONVERSION_UNAMBIGUOUS; aConfig.mbEmptyStringAsZero = false; - ScInterpreter::SetGlobalConfig(aConfig); + m_pDoc->SetCalcConfig(aConfig); m_pDoc->CalcAll(); aVal = m_pDoc->GetString( 0, 0, 0); CPPUNIT_ASSERT_MESSAGE("incorrect result", aVal == "#VALUE!"); @@ -1734,7 +1734,7 @@ void Test::testFuncParam() // With "Treat as zero" ("Empty string as zero" is ignored). aConfig.meStringConversion = ScCalcConfig::STRING_CONVERSION_AS_ZERO; aConfig.mbEmptyStringAsZero = true; - ScInterpreter::SetGlobalConfig(aConfig); + m_pDoc->SetCalcConfig(aConfig); m_pDoc->CalcAll(); m_pDoc->GetValue(0, 0, 0, val); CPPUNIT_ASSERT_MESSAGE("incorrect result", val == 3); @@ -1750,7 +1750,7 @@ void Test::testFuncParam() // With "Generate #VALUE! error" ("Empty string as zero" is ignored). aConfig.meStringConversion = ScCalcConfig::STRING_CONVERSION_AS_ERROR; aConfig.mbEmptyStringAsZero = false; - ScInterpreter::SetGlobalConfig(aConfig); + m_pDoc->SetCalcConfig(aConfig); m_pDoc->CalcAll(); aVal = m_pDoc->GetString( 0, 0, 0); CPPUNIT_ASSERT_MESSAGE("incorrect result", aVal == "#VALUE!"); diff --git a/sc/qa/unit/ucalc_formula.cxx b/sc/qa/unit/ucalc_formula.cxx index 8bf8435db929..4dd1acdec5b7 100644 --- a/sc/qa/unit/ucalc_formula.cxx +++ b/sc/qa/unit/ucalc_formula.cxx @@ -2842,7 +2842,7 @@ void Test::testFuncINDIRECT() ScCalcConfig aConfig; aConfig.meStringRefAddressSyntax = formula::FormulaGrammar::CONV_OOO; - ScInterpreter::SetGlobalConfig(aConfig); + m_pDoc->SetCalcConfig(aConfig); m_pDoc->CalcAll(); { // Explicit Calc A1 syntax @@ -2858,7 +2858,7 @@ void Test::testFuncINDIRECT() } aConfig.meStringRefAddressSyntax = formula::FormulaGrammar::CONV_XL_A1; - ScInterpreter::SetGlobalConfig(aConfig); + m_pDoc->SetCalcConfig(aConfig); m_pDoc->CalcAll(); { // Excel A1 syntax @@ -2874,7 +2874,7 @@ void Test::testFuncINDIRECT() } aConfig.meStringRefAddressSyntax = formula::FormulaGrammar::CONV_XL_R1C1; - ScInterpreter::SetGlobalConfig(aConfig); + m_pDoc->SetCalcConfig(aConfig); m_pDoc->CalcAll(); { // Excel R1C1 syntax diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx index 63635157809a..88775f88be5a 100644 --- a/sc/source/core/data/documen2.cxx +++ b/sc/source/core/data/documen2.cxx @@ -96,6 +96,7 @@ #include "scopetools.hxx" #include "formulagroup.hxx" #include "documentlinkmgr.hxx" +#include "interpre.hxx" #include <tokenstringcontext.hxx> using namespace com::sun::star; @@ -129,6 +130,7 @@ private: ScDocument::ScDocument( ScDocumentMode eMode, SfxObjectShell* pDocShell ) : mpCellStringPool(new svl::SharedStringPool(ScGlobal::pCharClass)), mpFormulaGroupCxt(NULL), + maCalcConfig( ScInterpreter::GetGlobalConfig()), mpUndoManager( NULL ), pEditEngine( NULL ), pNoteEngine( NULL ), diff --git a/sc/source/core/data/document10.cxx b/sc/source/core/data/document10.cxx index 3e1a69bd43e6..5030128236f4 100644 --- a/sc/source/core/data/document10.cxx +++ b/sc/source/core/data/document10.cxx @@ -227,4 +227,14 @@ void ScDocument::CopyCellValuesFrom( const ScAddress& rTopPos, const sc::CellVal pTab->CopyCellValuesFrom(rTopPos.Col(), rTopPos.Row(), rSrc); } +void ScDocument::SetCalcConfig( const ScCalcConfig& rConfig ) +{ + maCalcConfig = rConfig; +} + +const ScCalcConfig& ScDocument::GetCalcConfig() const +{ + return maCalcConfig; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx index 5715e1d86418..bfebfd45a045 100644 --- a/sc/source/core/inc/interpre.hxx +++ b/sc/source/core/inc/interpre.hxx @@ -147,6 +147,7 @@ private: static ScTokenStack* pGlobalStack; static bool bGlobalStackInUse; + ScCalcConfig maCalcConfig; formula::FormulaTokenIterator aCode; ScAddress aPos; ScTokenArray& rArr; @@ -179,6 +180,10 @@ private: VolatileType meVolatileType; + + /// Merge global and document specific settings. + void MergeCalcConfig(); + // nMust <= nAct <= nMax ? ok : PushError inline bool MustHaveParamCount( short nAct, short nMust ); inline bool MustHaveParamCount( short nAct, short nMust, short nMax ); diff --git a/sc/source/core/tool/calcconfig.cxx b/sc/source/core/tool/calcconfig.cxx index d33868f27de2..7975664b75b2 100644 --- a/sc/source/core/tool/calcconfig.cxx +++ b/sc/source/core/tool/calcconfig.cxx @@ -23,6 +23,15 @@ void ScCalcConfig::reset() *this = ScCalcConfig(); } +void ScCalcConfig::MergeDocumentSpecific( const ScCalcConfig& r ) +{ + // String conversion options are per document. + meStringConversion = r.meStringConversion; + mbEmptyStringAsZero = r.mbEmptyStringAsZero; + // INDIRECT ref syntax is per document. + meStringRefAddressSyntax = r.meStringRefAddressSyntax; +} + bool ScCalcConfig::operator== (const ScCalcConfig& r) const { return meStringRefAddressSyntax == r.meStringRefAddressSyntax && diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx index 648271922267..130b074820c9 100644 --- a/sc/source/core/tool/interpr1.cxx +++ b/sc/source/core/tool/interpr1.cxx @@ -3177,7 +3177,7 @@ void ScInterpreter::ScNumberValue() } if ( aInputString.isEmpty() ) { - if ( GetGlobalConfig().mbEmptyStringAsZero ) + if ( maCalcConfig.mbEmptyStringAsZero ) PushDouble( 0.0 ); else PushNoValue(); @@ -7038,7 +7038,7 @@ void ScInterpreter::ScIndirect() if ( MustHaveParamCount( nParamCount, 1, 2 ) ) { // Reference address syntax for INDIRECT is configurable. - FormulaGrammar::AddressConvention eConv = GetGlobalConfig().meStringRefAddressSyntax; + FormulaGrammar::AddressConvention eConv = maCalcConfig.meStringRefAddressSyntax; if (eConv == FormulaGrammar::CONV_UNSPECIFIED) // Use the current address syntax if unspecified. eConv = pDok->GetAddressConvention(); diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx index 232fcdb4d9f2..c641b7ad2327 100644 --- a/sc/source/core/tool/interpr4.cxx +++ b/sc/source/core/tool/interpr4.cxx @@ -251,7 +251,7 @@ double ScInterpreter::ConvertStringToValue( const OUString& rStr ) return fValue; } - switch (GetGlobalConfig().meStringConversion) + switch (maCalcConfig.meStringConversion) { case ScCalcConfig::STRING_CONVERSION_AS_ERROR: SetError( mnStringNoValueError); @@ -260,7 +260,7 @@ double ScInterpreter::ConvertStringToValue( const OUString& rStr ) return fValue; case ScCalcConfig::STRING_CONVERSION_LOCALE_DEPENDENT: { - if (GetGlobalConfig().mbEmptyStringAsZero) + if (maCalcConfig.mbEmptyStringAsZero) { // The number scanner does not accept empty strings or strings // containing only spaces, be on par in these cases with what was @@ -283,7 +283,7 @@ double ScInterpreter::ConvertStringToValue( const OUString& rStr ) break; case ScCalcConfig::STRING_CONVERSION_UNAMBIGUOUS: { - if (!GetGlobalConfig().mbEmptyStringAsZero) + if (!maCalcConfig.mbEmptyStringAsZero) { if (isEmptyString( rStr)) { @@ -3746,6 +3746,7 @@ ScInterpreter::ScInterpreter( ScFormulaCell* pCell, ScDocument* pDoc, bCalcAsShown( pDoc->GetDocOptions().IsCalcAsShown() ), meVolatileType(r.IsRecalcModeAlways() ? VOLATILE : NOT_VOLATILE) { + MergeCalcConfig(); if(pMyFormulaCell) { @@ -3791,6 +3792,13 @@ const ScCalcConfig& ScInterpreter::GetGlobalConfig() return maGlobalConfig; } +void ScInterpreter::MergeCalcConfig() +{ + maCalcConfig = maGlobalConfig; + if (pDok) + maCalcConfig.MergeDocumentSpecific( pDok->GetCalcConfig()); +} + void ScInterpreter::GlobalExit() { OSL_ENSURE(!bGlobalStackInUse, "who is still using the TokenStack?"); diff --git a/sc/source/core/tool/interpr5.cxx b/sc/source/core/tool/interpr5.cxx index b5733f4f3052..2205ed7d9320 100644 --- a/sc/source/core/tool/interpr5.cxx +++ b/sc/source/core/tool/interpr5.cxx @@ -913,7 +913,7 @@ void ScInterpreter::ScMatInv() SCSIZE nC, nR; pMat->GetDimensions(nC, nR); - if (ScInterpreter::GetGlobalConfig().mbOpenCLEnabled) + if (maCalcConfig.mbOpenCLEnabled) { ScMatrixRef xResMat = sc::FormulaGroupInterpreter::getStatic()->inverseMatrix(*pMat); if (xResMat) diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx index 99492d195ce1..b32a280b3862 100644 --- a/sc/source/ui/app/scmod.cxx +++ b/sc/source/ui/app/scmod.cxx @@ -2162,7 +2162,14 @@ SfxItemSet* ScModule::CreateItemSet( sal_uInt16 nId ) pRet->Put( ScTpDefaultsItem( SID_SCDEFAULTSOPTIONS, GetDefaultsOptions() ) ); // TP_FORMULA - pRet->Put( ScTpFormulaItem( SID_SCFORMULAOPTIONS, GetFormulaOptions() ) ); + ScFormulaOptions aOptions = GetFormulaOptions(); + if (pDocSh) + { + ScCalcConfig aConfig( aOptions.GetCalcConfig()); + aConfig.MergeDocumentSpecific( pDocSh->GetDocument()->GetCalcConfig()); + aOptions.SetCalcConfig( aConfig); + } + pRet->Put( ScTpFormulaItem( SID_SCFORMULAOPTIONS, aOptions ) ); } return pRet; } diff --git a/sc/source/ui/docshell/docsh6.cxx b/sc/source/ui/docshell/docsh6.cxx index a0d29a893948..4c573f4cfe7e 100644 --- a/sc/source/ui/docshell/docsh6.cxx +++ b/sc/source/ui/docshell/docsh6.cxx @@ -480,6 +480,14 @@ void ScDocShell::SetFormulaOptions(const ScFormulaOptions& rOpt ) // Global interpreter settings. ScInterpreter::SetGlobalConfig(rOpt.GetCalcConfig()); + + // Per document interpreter settings. + SetCalcConfig( rOpt.GetCalcConfig()); +} + +void ScDocShell::SetCalcConfig( const ScCalcConfig& rConfig ) +{ + aDocument.SetCalcConfig( rConfig); } void ScDocShell::CheckConfigOptions() diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx index 49215fd72426..5227a755a42b 100644 --- a/sc/source/ui/inc/docsh.hxx +++ b/sc/source/ui/inc/docsh.hxx @@ -323,6 +323,7 @@ public: bool ReloadTabLinks(); void SetFormulaOptions(const ScFormulaOptions& rOpt ); + void SetCalcConfig( const ScCalcConfig& rConfig ); virtual void CheckConfigOptions(); void PostEditView( ScEditEngineDefaulter* pEditEngine, const ScAddress& rCursorPos ); |