[Libreoffice-commits] .: 2 commits - sc/inc sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Mon Feb 27 09:13:10 PST 2012


 sc/inc/appoptio.hxx               |   27 ++++
 sc/inc/docoptio.hxx               |   37 ------
 sc/inc/sc.hrc                     |    7 +
 sc/source/core/data/documen3.cxx  |   29 ----
 sc/source/core/tool/appoptio.cxx  |  221 +++++++++++++++++++++++++++++++++++++-
 sc/source/core/tool/docoptio.cxx  |  217 -------------------------------------
 sc/source/ui/app/scmod.cxx        |   98 +++++++++++++++-
 sc/source/ui/docshell/docsh3.cxx  |    2 
 sc/source/ui/docshell/docsh6.cxx  |   41 +++++--
 sc/source/ui/inc/docsh.hxx        |    2 
 sc/source/ui/inc/tpformula.hxx    |   10 -
 sc/source/ui/optdlg/tpformula.cxx |   88 ++++++++-------
 12 files changed, 439 insertions(+), 340 deletions(-)

New commits:
commit 90284a5e7a1e5dcdd8e7473914db1ce6edc19f94
Author: Albert Thuswaldner <albert.thuswaldner at gmail.com>
Date:   Mon Feb 27 00:41:39 2012 +0100

    Splitting ScDocument::SetDocOptions, moved new SetFormulaOptions to ScDocShell

diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index 28eab09..ddacf92 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -52,10 +52,8 @@
 #include "rangelst.hxx"
 #include "chartarr.hxx"
 #include "chartlock.hxx"
-#include "compiler.hxx"
 #include "refupdat.hxx"
 #include "docoptio.hxx"
-#include "appoptio.hxx"
 #include "viewopti.hxx"
 #include "scextopt.hxx"
 #include "brdcst.hxx"
@@ -67,7 +65,6 @@
 #include "dociter.hxx"
 #include "detdata.hxx"
 #include "detfunc.hxx"
-#include "scmod.hxx"        // SC_MOD
 #include "inputopt.hxx"     // GetExpandRefs
 #include "chartlis.hxx"
 #include "sc.hrc"           // SID_LINK
@@ -1938,39 +1935,10 @@ const ScDocOptions& ScDocument::GetDocOptions() const
 
 void ScDocument::SetDocOptions( const ScDocOptions& rOpt )
 {
-    ScAppOptions rAppOpt=SC_MOD()->GetAppOptions();
-
     OSL_ENSURE( pDocOptions, "No DocOptions! :-(" );
-    //    bool bUpdateFuncNames = pDocOptions->GetUseEnglishFuncName() != rOpt.GetUseEnglishFuncName();
 
     *pDocOptions = rOpt;
-
     xPoolHelper->SetFormTableOpt(rOpt);
-
-    SetGrammar( rAppOpt.GetFormulaSyntax() );
-
-    //if (bUpdateFuncNames)
-    {
-        // This needs to be called first since it may re-initialize the entire
-        // opcode map.
-        if (rAppOpt.GetUseEnglishFuncName())
-        {
-            // switch native symbols to English.
-            ScCompiler aComp(NULL, ScAddress());
-            ScCompiler::OpCodeMapPtr xMap = aComp.GetOpCodeMap(::com::sun::star::sheet::FormulaLanguage::ENGLISH);
-            ScCompiler::SetNativeSymbols(xMap);
-        }
-        else
-            // re-initialize native symbols with localized function names.
-            ScCompiler::ResetNativeSymbols();
-
-        // Force re-population of function names for the function wizard, function tip etc.
-        ScGlobal::ResetFunctionList();
-    }
-
-    // Update the separators.
-    ScCompiler::UpdateSeparatorsNative(
-        rAppOpt.GetFormulaSepArg(), rAppOpt.GetFormulaSepArrayCol(), rAppOpt.GetFormulaSepArrayRow());
 }
 
 const ScViewOptions& ScDocument::GetViewOptions() const
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index 9798306..f496211 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -1088,13 +1088,9 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet )
     }
 
     // Do all the format updates on open documents in one go
-    if ( bUpdateDocFormat && pDoc )
+    if ( bUpdateDocFormat && pDocSh )
     {
-        const ScDocOptions& rOpt = pDoc->GetDocOptions(); // Temporary fix to keep
-                                                          // SettDocOption call as is
-
-                                                          // Needs update.
-        pDoc->SetDocOptions( rOpt );
+        pDocSh->SetFormulaOptions( *pAppCfg );
         pDocSh->SetDocumentModified();
     }
 
diff --git a/sc/source/ui/docshell/docsh3.cxx b/sc/source/ui/docshell/docsh3.cxx
index f5692ef..522e9d7 100644
--- a/sc/source/ui/docshell/docsh3.cxx
+++ b/sc/source/ui/docshell/docsh3.cxx
@@ -432,6 +432,7 @@ void ScDocShell::InitOptions(bool bForLoading)      // called from InitNew and L
     ScModule* pScMod = SC_MOD();
 
     ScDocOptions  aDocOpt  = pScMod->GetDocOptions();
+    ScAppOptions  aAppOpt  = pScMod->GetAppOptions();
     ScViewOptions aViewOpt = pScMod->GetViewOptions();
     aDocOpt.SetAutoSpell( bAutoSpell );
 
@@ -448,6 +449,7 @@ void ScDocShell::InitOptions(bool bForLoading)      // called from InitNew and L
 
     aDocument.SetDocOptions( aDocOpt );
     aDocument.SetViewOptions( aViewOpt );
+    SetFormulaOptions( aAppOpt );
 
     //  Druck-Optionen werden jetzt direkt vor dem Drucken gesetzt
 
diff --git a/sc/source/ui/docshell/docsh6.cxx b/sc/source/ui/docshell/docsh6.cxx
index c02956c..9d054bb 100644
--- a/sc/source/ui/docshell/docsh6.cxx
+++ b/sc/source/ui/docshell/docsh6.cxx
@@ -47,9 +47,9 @@
 #include "viewdata.hxx"
 #include "tabvwsh.hxx"
 #include "tablink.hxx"
-#include "appoptio.hxx"
 #include "globstr.hrc"
 #include "scmod.hxx"
+#include "compiler.hxx"
 
 #include "formula/FormulaCompiler.hxx"
 #include "comphelper/processfactory.hxx"
@@ -486,6 +486,31 @@ sal_Bool ScDocShell::ReloadTabLinks()
     return sal_True;        //! Fehler erkennen
 }
 
+void ScDocShell::SetFormulaOptions(const ScAppOptions& rAppOpt )
+{
+    aDocument.SetGrammar( rAppOpt.GetFormulaSyntax() );
+
+    // This needs to be called first since it may re-initialize the entire
+    // opcode map.
+    if (rAppOpt.GetUseEnglishFuncName())
+    {
+        // switch native symbols to English.
+        ScCompiler aComp(NULL, ScAddress());
+        ScCompiler::OpCodeMapPtr xMap = aComp.GetOpCodeMap(::com::sun::star::sheet::FormulaLanguage::ENGLISH);
+        ScCompiler::SetNativeSymbols(xMap);
+    }
+    else
+        // re-initialize native symbols with localized function names.
+        ScCompiler::ResetNativeSymbols();
+
+    // Force re-population of function names for the function wizard, function tip etc.
+    ScGlobal::ResetFunctionList();
+
+    // Update the separators.
+    ScCompiler::UpdateSeparatorsNative(
+        rAppOpt.GetFormulaSepArg(), rAppOpt.GetFormulaSepArrayCol(), rAppOpt.GetFormulaSepArrayRow());
+}
+
 void ScDocShell::CheckConfigOptions()
 {
     if (IsConfigOptionsChecked())
@@ -506,6 +531,7 @@ void ScDocShell::CheckConfigOptions()
         // separator.  Reset them to default.
         ScAppOptions aNew = rAppOpt;
         aNew.ResetFormulaSeparators();
+        SetFormulaOptions(aNew);
         pScMod->SetAppOptions(aNew);
 
         // Launch a nice warning dialog to let the users know of this change.
diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx
index 74e12f4..488c202 100644
--- a/sc/source/ui/inc/docsh.hxx
+++ b/sc/source/ui/inc/docsh.hxx
@@ -39,6 +39,7 @@
 #include "scdllapi.h"
 #include "scdll.hxx"
 #include "document.hxx"
+#include "appoptio.hxx"
 #include "shellids.hxx"
 #include "refreshtimer.hxx"
 #include "optutil.hxx"
@@ -320,6 +321,7 @@ public:
     void            UpdateLinks();          // Link-Eintraege aktuallisieren
     sal_Bool            ReloadTabLinks();       // Links ausfuehren (Inhalt aktualisieren)
 
+    void            SetFormulaOptions(const ScAppOptions& rAppOpt );
     virtual void    CheckConfigOptions();
 
     void            PostEditView( ScEditEngineDefaulter* pEditEngine, const ScAddress& rCursorPos );
commit b091acc26d145f2194662df64806f09fb78ef006
Author: Albert Thuswaldner <albert.thuswaldner at gmail.com>
Date:   Sat Feb 25 01:07:18 2012 +0100

    Moving misplaced Formula options from ScDocOptions to ScAppOptions

diff --git a/sc/inc/appoptio.hxx b/sc/inc/appoptio.hxx
index fac4061..65b3676 100644
--- a/sc/inc/appoptio.hxx
+++ b/sc/inc/appoptio.hxx
@@ -91,6 +91,24 @@ public:
     ScOptionsUtil::KeyBindingType GetKeyBindingType() const { return meKeyBindingType; }
     void        SetKeyBindingType( ScOptionsUtil::KeyBindingType e ) { meKeyBindingType = e; }
 
+    void SetFormulaSyntax( ::formula::FormulaGrammar::Grammar eGram ) { eFormulaGrammar = eGram; }
+    ::formula::FormulaGrammar::Grammar GetFormulaSyntax() const { return eFormulaGrammar; }
+
+    void SetUseEnglishFuncName( bool bVal ) { bUseEnglishFuncName = bVal; }
+    bool GetUseEnglishFuncName() const { return bUseEnglishFuncName; }
+
+    void SetFormulaSepArg(const ::rtl::OUString& rSep) { aFormulaSepArg = rSep; }
+    ::rtl::OUString GetFormulaSepArg() const { return aFormulaSepArg; }
+
+    void SetFormulaSepArrayRow(const ::rtl::OUString& rSep) { aFormulaSepArrayRow = rSep; }
+    ::rtl::OUString GetFormulaSepArrayRow() const { return aFormulaSepArrayRow; }
+
+    void SetFormulaSepArrayCol(const ::rtl::OUString& rSep) { aFormulaSepArrayCol = rSep; }
+    ::rtl::OUString GetFormulaSepArrayCol() const { return aFormulaSepArrayCol; }
+
+    void ResetFormulaSeparators();
+
+    static const LocaleDataWrapper& GetLocaleDataWrapper();
 
     const ScAppOptions& operator=   ( const ScAppOptions& rOpt );
 
@@ -114,6 +132,12 @@ private:
     sal_Int32       nDefaultObjectSizeHeight;
     sal_Bool        mbShowSharedDocumentWarning;
     ScOptionsUtil::KeyBindingType meKeyBindingType;
+    bool   bUseEnglishFuncName;     // use English function name even if the locale is not English.
+    ::formula::FormulaGrammar::Grammar eFormulaGrammar;  // formula grammar used to switch different formula syntax
+
+    ::rtl::OUString aFormulaSepArg;
+    ::rtl::OUString aFormulaSepArrayRow;
+    ::rtl::OUString aFormulaSepArrayCol;
 };
 
 
@@ -133,6 +157,7 @@ class ScAppCfg : public ScAppOptions
     ScLinkConfigItem    aSortListItem;
     ScLinkConfigItem    aMiscItem;
     ScLinkConfigItem    aCompatItem;
+    ScLinkConfigItem    aFormulaItem;
 
     DECL_LINK( LayoutCommitHdl, void* );
     DECL_LINK( InputCommitHdl, void* );
@@ -141,6 +166,7 @@ class ScAppCfg : public ScAppOptions
     DECL_LINK( SortListCommitHdl, void* );
     DECL_LINK( MiscCommitHdl, void* );
     DECL_LINK( CompatCommitHdl, void* );
+    DECL_LINK( FormulaCommitHdl, void* );
 
     com::sun::star::uno::Sequence<rtl::OUString> GetLayoutPropertyNames();
     com::sun::star::uno::Sequence<rtl::OUString> GetInputPropertyNames();
@@ -149,6 +175,7 @@ class ScAppCfg : public ScAppOptions
     com::sun::star::uno::Sequence<rtl::OUString> GetSortListPropertyNames();
     com::sun::star::uno::Sequence<rtl::OUString> GetMiscPropertyNames();
     com::sun::star::uno::Sequence<rtl::OUString> GetCompatPropertyNames();
+    com::sun::star::uno::Sequence<rtl::OUString> GetFormulaPropertyNames();
 
 public:
             ScAppCfg();
diff --git a/sc/inc/docoptio.hxx b/sc/inc/docoptio.hxx
index de44cf0..78fd5e9 100644
--- a/sc/inc/docoptio.hxx
+++ b/sc/inc/docoptio.hxx
@@ -57,13 +57,6 @@ class SC_DLLPUBLIC ScDocOptions
     sal_Bool   bDoAutoSpell;            // auto-spelling
     sal_Bool   bLookUpColRowNames;      // determine column-/row titles automagically
     sal_Bool   bFormulaRegexEnabled;    // regular expressions in formulas enabled
-    bool   bUseEnglishFuncName;     // use English function name even if the locale is not English.
-    ::formula::FormulaGrammar::Grammar eFormulaGrammar;  // formula grammar used to switch different formula syntax
-
-    ::rtl::OUString aFormulaSepArg;
-    ::rtl::OUString aFormulaSepArrayRow;
-    ::rtl::OUString aFormulaSepArrayCol;
-
 public:
                 ScDocOptions();
                 ScDocOptions( const ScDocOptions& rCpy );
@@ -113,23 +106,6 @@ public:
     void    SetFormulaRegexEnabled( sal_Bool bVal ) { bFormulaRegexEnabled = bVal; }
     sal_Bool    IsFormulaRegexEnabled() const       { return bFormulaRegexEnabled; }
 
-    void SetFormulaSyntax( ::formula::FormulaGrammar::Grammar eGram ) { eFormulaGrammar = eGram; }
-    ::formula::FormulaGrammar::Grammar GetFormulaSyntax() const { return eFormulaGrammar; }
-
-    void SetUseEnglishFuncName( bool bVal ) { bUseEnglishFuncName = bVal; }
-    bool GetUseEnglishFuncName() const { return bUseEnglishFuncName; }
-
-    void SetFormulaSepArg(const ::rtl::OUString& rSep) { aFormulaSepArg = rSep; }
-    ::rtl::OUString GetFormulaSepArg() const { return aFormulaSepArg; }
-
-    void SetFormulaSepArrayRow(const ::rtl::OUString& rSep) { aFormulaSepArrayRow = rSep; }
-    ::rtl::OUString GetFormulaSepArrayRow() const { return aFormulaSepArrayRow; }
-
-    void SetFormulaSepArrayCol(const ::rtl::OUString& rSep) { aFormulaSepArrayCol = rSep; }
-    ::rtl::OUString GetFormulaSepArrayCol() const { return aFormulaSepArrayCol; }
-
-    void ResetFormulaSeparators();
-    static const LocaleDataWrapper& GetLocaleDataWrapper();
 };
 
 inline const ScDocOptions& ScDocOptions::operator=( const ScDocOptions& rCpy )
@@ -151,11 +127,6 @@ inline const ScDocOptions& ScDocOptions::operator=( const ScDocOptions& rCpy )
     bDoAutoSpell        = rCpy.bDoAutoSpell;
     bLookUpColRowNames  = rCpy.bLookUpColRowNames;
     bFormulaRegexEnabled= rCpy.bFormulaRegexEnabled;
-    bUseEnglishFuncName = rCpy.bUseEnglishFuncName;
-    eFormulaGrammar     = rCpy.eFormulaGrammar;
-    aFormulaSepArg      = rCpy.aFormulaSepArg;
-    aFormulaSepArrayRow = rCpy.aFormulaSepArrayRow;
-    aFormulaSepArrayCol = rCpy.aFormulaSepArrayCol;
 
     return *this;
 }
@@ -180,11 +151,6 @@ inline bool ScDocOptions::operator==( const ScDocOptions& rOpt ) const
             &&  rOpt.bDoAutoSpell           == bDoAutoSpell
             &&  rOpt.bLookUpColRowNames     == bLookUpColRowNames
             &&  rOpt.bFormulaRegexEnabled   == bFormulaRegexEnabled
-            &&  rOpt.bUseEnglishFuncName    == bUseEnglishFuncName
-            &&  rOpt.eFormulaGrammar        == eFormulaGrammar
-            &&  rOpt.aFormulaSepArg         == aFormulaSepArg
-            &&  rOpt.aFormulaSepArrayRow    == aFormulaSepArrayRow
-            &&  rOpt.aFormulaSepArrayCol    == aFormulaSepArrayCol
             );
 }
 
@@ -223,17 +189,14 @@ private:
 class ScDocCfg : public ScDocOptions
 {
     ScLinkConfigItem    aCalcItem;
-    ScLinkConfigItem    aFormulaItem;
     ScLinkConfigItem    aLayoutItem;
     ScLinkConfigItem    aDefaultsItem;
 
     DECL_LINK( CalcCommitHdl, void* );
-    DECL_LINK( FormulaCommitHdl, void* );
     DECL_LINK( LayoutCommitHdl, void* );
     DECL_LINK( DefaultsCommitHdl, void* );
 
     com::sun::star::uno::Sequence<rtl::OUString> GetCalcPropertyNames();
-    com::sun::star::uno::Sequence<rtl::OUString> GetFormulaPropertyNames();
     com::sun::star::uno::Sequence<rtl::OUString> GetLayoutPropertyNames();
     com::sun::star::uno::Sequence<rtl::OUString> GetDefaultsPropertyNames();
 
diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc
index 27cb28b..ad4649e 100644
--- a/sc/inc/sc.hrc
+++ b/sc/inc/sc.hrc
@@ -116,6 +116,13 @@
 #define FID_MARKPAGEUP          (SC_VIEW_START + 18)
 #define FID_MARKPAGEDOWN        (SC_VIEW_START + 19)
 
+// Format options
+#define SID_SC_OPT_FORMULA_ENGLISH_FUNCNAME   (SC_VIEW_START + 20)
+#define SID_SC_OPT_FORMULA_GRAMMAR            (SC_VIEW_START + 21)
+#define SID_SC_OPT_FORMULA_SEP_ARG            (SC_VIEW_START + 22)
+#define SID_SC_OPT_FORMULA_SEP_ARRAY_ROW      (SC_VIEW_START + 23)
+#define SID_SC_OPT_FORMULA_SEP_ARRAY_COL      (SC_VIEW_START + 24)
+
 // slot-IDs for attributes
 
 #define SID_SCATTR_HOR_JUSTIFY  (SC_VIEW_START + 30)    // alignment-page
diff --git a/sc/source/core/data/documen3.cxx b/sc/source/core/data/documen3.cxx
index e9a6653..28eab09 100644
--- a/sc/source/core/data/documen3.cxx
+++ b/sc/source/core/data/documen3.cxx
@@ -55,6 +55,7 @@
 #include "compiler.hxx"
 #include "refupdat.hxx"
 #include "docoptio.hxx"
+#include "appoptio.hxx"
 #include "viewopti.hxx"
 #include "scextopt.hxx"
 #include "brdcst.hxx"
@@ -1937,20 +1938,22 @@ const ScDocOptions& ScDocument::GetDocOptions() const
 
 void ScDocument::SetDocOptions( const ScDocOptions& rOpt )
 {
+    ScAppOptions rAppOpt=SC_MOD()->GetAppOptions();
+
     OSL_ENSURE( pDocOptions, "No DocOptions! :-(" );
-    bool bUpdateFuncNames = pDocOptions->GetUseEnglishFuncName() != rOpt.GetUseEnglishFuncName();
+    //    bool bUpdateFuncNames = pDocOptions->GetUseEnglishFuncName() != rOpt.GetUseEnglishFuncName();
 
     *pDocOptions = rOpt;
 
     xPoolHelper->SetFormTableOpt(rOpt);
 
-    SetGrammar( rOpt.GetFormulaSyntax() );
+    SetGrammar( rAppOpt.GetFormulaSyntax() );
 
-    if (bUpdateFuncNames)
+    //if (bUpdateFuncNames)
     {
         // This needs to be called first since it may re-initialize the entire
         // opcode map.
-        if (rOpt.GetUseEnglishFuncName())
+        if (rAppOpt.GetUseEnglishFuncName())
         {
             // switch native symbols to English.
             ScCompiler aComp(NULL, ScAddress());
@@ -1967,7 +1970,7 @@ void ScDocument::SetDocOptions( const ScDocOptions& rOpt )
 
     // Update the separators.
     ScCompiler::UpdateSeparatorsNative(
-        rOpt.GetFormulaSepArg(), rOpt.GetFormulaSepArrayCol(), rOpt.GetFormulaSepArrayRow());
+        rAppOpt.GetFormulaSepArg(), rAppOpt.GetFormulaSepArrayCol(), rAppOpt.GetFormulaSepArrayRow());
 }
 
 const ScViewOptions& ScDocument::GetViewOptions() const
diff --git a/sc/source/core/tool/appoptio.cxx b/sc/source/core/tool/appoptio.cxx
index d53328b..3df026e 100644
--- a/sc/source/core/tool/appoptio.cxx
+++ b/sc/source/core/tool/appoptio.cxx
@@ -35,6 +35,8 @@
 
 #include <com/sun/star/uno/Any.hxx>
 #include <com/sun/star/uno/Sequence.hxx>
+#include <com/sun/star/lang/Locale.hpp>
+#include <com/sun/star/i18n/LocaleDataItem.hpp>
 
 #include "cfgids.hxx"
 #include "appoptio.hxx"
@@ -48,7 +50,8 @@
 
 using namespace utl;
 using namespace com::sun::star::uno;
-
+using ::com::sun::star::lang::Locale;
+using ::com::sun::star::i18n::LocaleDataItem;
 using ::rtl::OUString;
 
 // STATIC DATA -----------------------------------------------------------
@@ -118,8 +121,71 @@ void ScAppOptions::SetDefaults()
     mbShowSharedDocumentWarning = true;
 
     meKeyBindingType     = ScOptionsUtil::KEY_DEFAULT;
+
+    bUseEnglishFuncName = false;
+    eFormulaGrammar     = ::formula::FormulaGrammar::GRAM_NATIVE;
+
+    ResetFormulaSeparators();
+}
+
+void ScAppOptions::ResetFormulaSeparators()
+{
+    // Defaults to the old separator values.
+    aFormulaSepArg = OUString(RTL_CONSTASCII_USTRINGPARAM(";"));
+    aFormulaSepArrayCol = OUString(RTL_CONSTASCII_USTRINGPARAM(";"));
+    aFormulaSepArrayRow = OUString(RTL_CONSTASCII_USTRINGPARAM("|"));
+
+    const Locale& rLocale = *ScGlobal::GetLocale();
+    const OUString& rLang = rLocale.Language;
+    if (rLang.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ru")))
+        // Don't do automatic guess for these languages, and fall back to
+        // the old separator set.
+        return;
+
+    const LocaleDataWrapper& rLocaleData = GetLocaleDataWrapper();
+    const OUString& rDecSep  = rLocaleData.getNumDecimalSep();
+    const OUString& rListSep = rLocaleData.getListSep();
+
+    if (rDecSep.isEmpty() || rListSep.isEmpty())
+        // Something is wrong.  Stick with the default separators.
+        return;
+
+    sal_Unicode cDecSep  = rDecSep.getStr()[0];
+    sal_Unicode cListSep = rListSep.getStr()[0];
+
+    // Excel by default uses system's list separator as the parameter
+    // separator, which in English locales is a comma.  However, OOo's list
+    // separator value is set to ';' for all English locales.  Because of this
+    // discrepancy, we will hardcode the separator value here, for now.
+    if (cDecSep == sal_Unicode('.'))
+        cListSep = sal_Unicode(',');
+
+    // Special case for de_CH locale.
+    if (rLocale.Language.equalsAsciiL("de", 2) && rLocale.Country.equalsAsciiL("CH", 2))
+        cListSep = sal_Unicode(';');
+
+    // by default, the parameter separator equals the locale-specific
+    // list separator.
+    aFormulaSepArg = OUString(cListSep);
+
+    if (cDecSep == cListSep && cDecSep != sal_Unicode(';'))
+        // if the decimal and list separators are equal, set the
+        // parameter separator to be ';', unless they are both
+        // semicolon in which case don't change the decimal separator.
+        aFormulaSepArg = OUString(RTL_CONSTASCII_USTRINGPARAM(";"));
+
+    aFormulaSepArrayCol = OUString(RTL_CONSTASCII_USTRINGPARAM(","));
+    if (cDecSep == sal_Unicode(','))
+        aFormulaSepArrayCol = OUString(RTL_CONSTASCII_USTRINGPARAM("."));
+    aFormulaSepArrayRow = OUString(RTL_CONSTASCII_USTRINGPARAM(";"));
+}
+
+const LocaleDataWrapper& ScAppOptions::GetLocaleDataWrapper()
+{
+    return *ScGlobal::pLocaleData;
 }
 
+
 const ScAppOptions& ScAppOptions::operator=( const ScAppOptions& rCpy )
 {
     nTabCountInNewSpreadsheet = rCpy.nTabCountInNewSpreadsheet;
@@ -140,6 +206,12 @@ const ScAppOptions& ScAppOptions::operator=( const ScAppOptions& rCpy )
     nDefaultObjectSizeHeight = rCpy.nDefaultObjectSizeHeight;
     mbShowSharedDocumentWarning = rCpy.mbShowSharedDocumentWarning;
     meKeyBindingType  = rCpy.meKeyBindingType;
+    bUseEnglishFuncName = rCpy.bUseEnglishFuncName;
+    eFormulaGrammar     = rCpy.eFormulaGrammar;
+    aFormulaSepArg      = rCpy.aFormulaSepArg;
+    aFormulaSepArrayRow = rCpy.aFormulaSepArrayRow;
+    aFormulaSepArrayCol = rCpy.aFormulaSepArrayCol;
+
     return *this;
 }
 
@@ -295,6 +367,13 @@ void lcl_GetSortList( Any& rDest )
 #define SCCOMPATOPT_KEY_BINDING     0
 #define SCCOMPATOPT_COUNT           1
 
+#define CFGPATH_FORMULA     "Office.Calc/Formula"
+#define SCFORMULAOPT_GRAMMAR           0
+#define SCFORMULAOPT_ENGLISH_FUNCNAME  1
+#define SCFORMULAOPT_SEP_ARG           2
+#define SCFORMULAOPT_SEP_ARRAY_ROW     3
+#define SCFORMULAOPT_SEP_ARRAY_COL     4
+#define SCFORMULAOPT_COUNT             5
 
 Sequence<OUString> ScAppCfg::GetLayoutPropertyNames()
 {
@@ -409,6 +488,24 @@ Sequence<OUString> ScAppCfg::GetCompatPropertyNames()
     return aNames;
 }
 
+Sequence<OUString> ScAppCfg::GetFormulaPropertyNames()
+{
+    static const char* aPropNames[] =
+    {
+        "Syntax/Grammar",             // SCFORMULAOPT_GRAMMAR
+        "Syntax/EnglishFunctionName", // SCFORMULAOPT_ENGLISH_FUNCNAME
+        "Syntax/SeparatorArg",        // SCFORMULAOPT_SEP_ARG
+        "Syntax/SeparatorArrayRow",   // SCFORMULAOPT_SEP_ARRAY_ROW
+        "Syntax/SeparatorArrayCol",   // SCFORMULAOPT_SEP_ARRAY_COL
+    };
+    Sequence<OUString> aNames(SCFORMULAOPT_COUNT);
+    OUString* pNames = aNames.getArray();
+    for (int i = 0; i < SCFORMULAOPT_COUNT; ++i)
+        pNames[i] = OUString::createFromAscii(aPropNames[i]);
+
+    return aNames;
+}
+
 ScAppCfg::ScAppCfg() :
     aLayoutItem( OUString(RTL_CONSTASCII_USTRINGPARAM( CFGPATH_LAYOUT )) ),
     aInputItem( OUString(RTL_CONSTASCII_USTRINGPARAM( CFGPATH_INPUT )) ),
@@ -416,7 +513,9 @@ ScAppCfg::ScAppCfg() :
     aContentItem( OUString(RTL_CONSTASCII_USTRINGPARAM( CFGPATH_CONTENT )) ),
     aSortListItem( OUString(RTL_CONSTASCII_USTRINGPARAM( CFGPATH_SORTLIST )) ),
     aMiscItem( OUString(RTL_CONSTASCII_USTRINGPARAM( CFGPATH_MISC )) ),
-    aCompatItem( OUString(RTL_CONSTASCII_USTRINGPARAM(CFGPATH_COMPAT )) )
+    aCompatItem( OUString(RTL_CONSTASCII_USTRINGPARAM(CFGPATH_COMPAT )) ),
+    aFormulaItem( OUString(RTL_CONSTASCII_USTRINGPARAM(CFGPATH_FORMULA )) )
+
 {
     sal_Int32 nIntVal = 0;
 
@@ -616,6 +715,79 @@ ScAppCfg::ScAppCfg() :
         }
     }
     aCompatItem.SetCommitLink( LINK(this, ScAppCfg, CompatCommitHdl) );
+
+    aNames = GetFormulaPropertyNames();
+    aValues = aFormulaItem.GetProperties(aNames);
+    aFormulaItem.EnableNotification(aNames);
+    pValues = aValues.getConstArray();
+    if (aValues.getLength() == aNames.getLength())
+    {
+        for (int nProp = 0; nProp < aNames.getLength(); ++nProp)
+        {
+            switch (nProp)
+            {
+                case SCFORMULAOPT_GRAMMAR:
+                {
+                    // Get default value in case this option is not set.
+                    ::formula::FormulaGrammar::Grammar eGram = GetFormulaSyntax();
+
+                    do
+                    {
+                        if (!(pValues[nProp] >>= nIntVal))
+                            // extractino failed.
+                            break;
+
+                        switch (nIntVal)
+                        {
+                            case 0: // Calc A1
+                                eGram = ::formula::FormulaGrammar::GRAM_NATIVE;
+                            break;
+                            case 1: // Excel A1
+                                eGram = ::formula::FormulaGrammar::GRAM_NATIVE_XL_A1;
+                            break;
+                            case 2: // Excel R1C1
+                                eGram = ::formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1;
+                            break;
+                            default:
+                                ;
+                        }
+                    }
+                    while (false);
+                    SetFormulaSyntax(eGram);
+                }
+                break;
+                case SCFORMULAOPT_ENGLISH_FUNCNAME:
+                {
+                    sal_Bool bEnglish = false;
+                    if (pValues[nProp] >>= bEnglish)
+                        SetUseEnglishFuncName(bEnglish);
+                }
+                break;
+                case SCFORMULAOPT_SEP_ARG:
+                {
+                    OUString aSep;
+                    if ((pValues[nProp] >>= aSep) && !aSep.isEmpty())
+                        SetFormulaSepArg(aSep);
+                }
+                break;
+                case SCFORMULAOPT_SEP_ARRAY_ROW:
+                {
+                    OUString aSep;
+                    if ((pValues[nProp] >>= aSep) && !aSep.isEmpty())
+                        SetFormulaSepArrayRow(aSep);
+                }
+                break;
+                case SCFORMULAOPT_SEP_ARRAY_COL:
+                {
+                    OUString aSep;
+                    if ((pValues[nProp] >>= aSep) && !aSep.isEmpty())
+                        SetFormulaSepArrayCol(aSep);
+                }
+                break;
+            }
+        }
+    }
+    aFormulaItem.SetCommitLink( LINK(this, ScAppCfg, FormulaCommitHdl) );
 }
 
 IMPL_LINK( ScAppCfg, LayoutCommitHdl, void *, EMPTYARG )
@@ -790,6 +962,50 @@ IMPL_LINK( ScAppCfg, CompatCommitHdl, void *, EMPTYARG )
     return 0;
 }
 
+IMPL_LINK( ScAppCfg, FormulaCommitHdl, void *, EMPTYARG )
+{
+    Sequence<OUString> aNames = GetFormulaPropertyNames();
+    Sequence<Any> aValues(aNames.getLength());
+    Any* pValues = aValues.getArray();
+
+    for (int nProp = 0; nProp < aNames.getLength(); ++nProp)
+    {
+        switch (nProp)
+        {
+            case SCFORMULAOPT_GRAMMAR :
+            {
+                sal_Int32 nVal = 0;
+                switch (GetFormulaSyntax())
+                {
+                    case ::formula::FormulaGrammar::GRAM_NATIVE_XL_A1:    nVal = 1; break;
+                    case ::formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1:  nVal = 2; break;
+                    default: break;
+                }
+                pValues[nProp] <<= nVal;
+            }
+            break;
+            case SCFORMULAOPT_ENGLISH_FUNCNAME:
+            {
+                sal_Bool b = GetUseEnglishFuncName();
+                pValues[nProp] <<= b;
+            }
+            break;
+            case SCFORMULAOPT_SEP_ARG:
+                pValues[nProp] <<= GetFormulaSepArg();
+            break;
+            case SCFORMULAOPT_SEP_ARRAY_ROW:
+                pValues[nProp] <<= GetFormulaSepArrayRow();
+            break;
+            case SCFORMULAOPT_SEP_ARRAY_COL:
+                pValues[nProp] <<= GetFormulaSepArrayCol();
+            break;
+        }
+    }
+    aFormulaItem.PutProperties(aNames, aValues);
+
+    return 0;
+}
+
 void ScAppCfg::SetOptions( const ScAppOptions& rNew )
 {
     *(ScAppOptions*)this = rNew;
@@ -805,6 +1021,7 @@ void ScAppCfg::OptionsChanged()
     aSortListItem.SetModified();
     aMiscItem.SetModified();
     aCompatItem.SetModified();
+    aFormulaItem.SetModified();
 }
 
 
diff --git a/sc/source/core/tool/docoptio.cxx b/sc/source/core/tool/docoptio.cxx
index b8fd587..db5f952 100644
--- a/sc/source/core/tool/docoptio.cxx
+++ b/sc/source/core/tool/docoptio.cxx
@@ -34,8 +34,6 @@
 
 #include <com/sun/star/uno/Any.hxx>
 #include <com/sun/star/uno/Sequence.hxx>
-#include <com/sun/star/lang/Locale.hpp>
-#include <com/sun/star/i18n/LocaleDataItem.hpp>
 
 #include "cfgids.hxx"
 #include "docoptio.hxx"
@@ -48,8 +46,6 @@
 
 using namespace utl;
 using namespace com::sun::star::uno;
-using ::com::sun::star::lang::Locale;
-using ::com::sun::star::i18n::LocaleDataItem;
 using ::rtl::OUString;
 
 //------------------------------------------------------------------------
@@ -102,12 +98,7 @@ ScDocOptions::ScDocOptions( const ScDocOptions& rCpy )
             bMatchWholeCell( rCpy.bMatchWholeCell ),
             bDoAutoSpell( rCpy.bDoAutoSpell ),
             bLookUpColRowNames( rCpy.bLookUpColRowNames ),
-            bFormulaRegexEnabled( rCpy.bFormulaRegexEnabled ),
-            bUseEnglishFuncName( rCpy.bUseEnglishFuncName ),
-            eFormulaGrammar( rCpy.eFormulaGrammar ),
-            aFormulaSepArg( rCpy.aFormulaSepArg ),
-            aFormulaSepArrayRow( rCpy.aFormulaSepArrayRow ),
-            aFormulaSepArrayCol( rCpy.aFormulaSepArrayCol )
+            bFormulaRegexEnabled( rCpy.bFormulaRegexEnabled )
 {
 }
 
@@ -138,67 +129,6 @@ void ScDocOptions::ResetDocOptions()
     bDoAutoSpell        = false;
     bLookUpColRowNames  = true;
     bFormulaRegexEnabled= true;
-    bUseEnglishFuncName = false;
-    eFormulaGrammar     = ::formula::FormulaGrammar::GRAM_NATIVE;
-
-    ResetFormulaSeparators();
-}
-
-void ScDocOptions::ResetFormulaSeparators()
-{
-    // Defaults to the old separator values.
-    aFormulaSepArg = OUString(RTL_CONSTASCII_USTRINGPARAM(";"));
-    aFormulaSepArrayCol = OUString(RTL_CONSTASCII_USTRINGPARAM(";"));
-    aFormulaSepArrayRow = OUString(RTL_CONSTASCII_USTRINGPARAM("|"));
-
-    const Locale& rLocale = *ScGlobal::GetLocale();
-    const OUString& rLang = rLocale.Language;
-    if (rLang.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("ru")))
-        // Don't do automatic guess for these languages, and fall back to
-        // the old separator set.
-        return;
-
-    const LocaleDataWrapper& rLocaleData = GetLocaleDataWrapper();
-    const OUString& rDecSep  = rLocaleData.getNumDecimalSep();
-    const OUString& rListSep = rLocaleData.getListSep();
-
-    if (rDecSep.isEmpty() || rListSep.isEmpty())
-        // Something is wrong.  Stick with the default separators.
-        return;
-
-    sal_Unicode cDecSep  = rDecSep.getStr()[0];
-    sal_Unicode cListSep = rListSep.getStr()[0];
-
-    // Excel by default uses system's list separator as the parameter
-    // separator, which in English locales is a comma.  However, OOo's list
-    // separator value is set to ';' for all English locales.  Because of this
-    // discrepancy, we will hardcode the separator value here, for now.
-    if (cDecSep == sal_Unicode('.'))
-        cListSep = sal_Unicode(',');
-
-    // Special case for de_CH locale.
-    if (rLocale.Language.equalsAsciiL("de", 2) && rLocale.Country.equalsAsciiL("CH", 2))
-        cListSep = sal_Unicode(';');
-
-    // by default, the parameter separator equals the locale-specific
-    // list separator.
-    aFormulaSepArg = OUString(cListSep);
-
-    if (cDecSep == cListSep && cDecSep != sal_Unicode(';'))
-        // if the decimal and list separators are equal, set the
-        // parameter separator to be ';', unless they are both
-        // semicolon in which case don't change the decimal separator.
-        aFormulaSepArg = OUString(RTL_CONSTASCII_USTRINGPARAM(";"));
-
-    aFormulaSepArrayCol = OUString(RTL_CONSTASCII_USTRINGPARAM(","));
-    if (cDecSep == sal_Unicode(','))
-        aFormulaSepArrayCol = OUString(RTL_CONSTASCII_USTRINGPARAM("."));
-    aFormulaSepArrayRow = OUString(RTL_CONSTASCII_USTRINGPARAM(";"));
-}
-
-const LocaleDataWrapper& ScDocOptions::GetLocaleDataWrapper()
-{
-    return *ScGlobal::pLocaleData;
 }
 
 //========================================================================
@@ -272,14 +202,6 @@ SfxPoolItem* ScTpCalcItem::Clone( SfxItemPool * ) const
 #define SCCALCOPT_REGEX             11
 #define SCCALCOPT_COUNT             12
 
-#define CFGPATH_FORMULA     "Office.Calc/Formula"
-#define SCFORMULAOPT_GRAMMAR           0
-#define SCFORMULAOPT_ENGLISH_FUNCNAME  1
-#define SCFORMULAOPT_SEP_ARG           2
-#define SCFORMULAOPT_SEP_ARRAY_ROW     3
-#define SCFORMULAOPT_SEP_ARRAY_COL     4
-#define SCFORMULAOPT_COUNT             5
-
 #define CFGPATH_DOCLAYOUT   "Office.Calc/Layout/Other"
 
 #define SCDOCLAYOUTOPT_TABSTOP      0
@@ -316,24 +238,6 @@ Sequence<OUString> ScDocCfg::GetCalcPropertyNames()
     return aNames;
 }
 
-Sequence<OUString> ScDocCfg::GetFormulaPropertyNames()
-{
-    static const char* aPropNames[] =
-    {
-        "Syntax/Grammar",             // SCFORMULAOPT_GRAMMAR
-        "Syntax/EnglishFunctionName", // SCFORMULAOPT_ENGLISH_FUNCNAME
-        "Syntax/SeparatorArg",        // SCFORMULAOPT_SEP_ARG
-        "Syntax/SeparatorArrayRow",   // SCFORMULAOPT_SEP_ARRAY_ROW
-        "Syntax/SeparatorArrayCol",   // SCFORMULAOPT_SEP_ARRAY_COL
-    };
-    Sequence<OUString> aNames(SCFORMULAOPT_COUNT);
-    OUString* pNames = aNames.getArray();
-    for (int i = 0; i < SCFORMULAOPT_COUNT; ++i)
-        pNames[i] = OUString::createFromAscii(aPropNames[i]);
-
-    return aNames;
-}
-
 Sequence<OUString> ScDocCfg::GetLayoutPropertyNames()
 {
     static const char* aPropNames[] =
@@ -370,7 +274,6 @@ Sequence<OUString> ScDocCfg::GetDefaultsPropertyNames()
 
 ScDocCfg::ScDocCfg() :
     aCalcItem( OUString(RTL_CONSTASCII_USTRINGPARAM( CFGPATH_CALC )) ),
-    aFormulaItem(OUString(RTL_CONSTASCII_USTRINGPARAM(CFGPATH_FORMULA))),
     aLayoutItem(OUString(RTL_CONSTASCII_USTRINGPARAM(CFGPATH_DOCLAYOUT))),
     aDefaultsItem(OUString(RTL_CONSTASCII_USTRINGPARAM(CFGPATH_DEFAULTS)))
 {
@@ -443,79 +346,6 @@ ScDocCfg::ScDocCfg() :
 
     SetDate( nDateDay, nDateMonth, nDateYear );
 
-    aNames = GetFormulaPropertyNames();
-    aValues = aFormulaItem.GetProperties(aNames);
-    aFormulaItem.EnableNotification(aNames);
-    pValues = aValues.getConstArray();
-    if (aValues.getLength() == aNames.getLength())
-    {
-        for (int nProp = 0; nProp < aNames.getLength(); ++nProp)
-        {
-            switch (nProp)
-            {
-                case SCFORMULAOPT_GRAMMAR:
-                {
-                    // Get default value in case this option is not set.
-                    ::formula::FormulaGrammar::Grammar eGram = GetFormulaSyntax();
-
-                    do
-                    {
-                        if (!(pValues[nProp] >>= nIntVal))
-                            // extractino failed.
-                            break;
-
-                        switch (nIntVal)
-                        {
-                            case 0: // Calc A1
-                                eGram = ::formula::FormulaGrammar::GRAM_NATIVE;
-                            break;
-                            case 1: // Excel A1
-                                eGram = ::formula::FormulaGrammar::GRAM_NATIVE_XL_A1;
-                            break;
-                            case 2: // Excel R1C1
-                                eGram = ::formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1;
-                            break;
-                            default:
-                                ;
-                        }
-                    }
-                    while (false);
-                    SetFormulaSyntax(eGram);
-                }
-                break;
-                case SCFORMULAOPT_ENGLISH_FUNCNAME:
-                {
-                    sal_Bool bEnglish = false;
-                    if (pValues[nProp] >>= bEnglish)
-                        SetUseEnglishFuncName(bEnglish);
-                }
-                break;
-                case SCFORMULAOPT_SEP_ARG:
-                {
-                    OUString aSep;
-                    if ((pValues[nProp] >>= aSep) && !aSep.isEmpty())
-                        SetFormulaSepArg(aSep);
-                }
-                break;
-                case SCFORMULAOPT_SEP_ARRAY_ROW:
-                {
-                    OUString aSep;
-                    if ((pValues[nProp] >>= aSep) && !aSep.isEmpty())
-                        SetFormulaSepArrayRow(aSep);
-                }
-                break;
-                case SCFORMULAOPT_SEP_ARRAY_COL:
-                {
-                    OUString aSep;
-                    if ((pValues[nProp] >>= aSep) && !aSep.isEmpty())
-                        SetFormulaSepArrayCol(aSep);
-                }
-                break;
-            }
-        }
-    }
-    aFormulaItem.SetCommitLink( LINK(this, ScDocCfg, FormulaCommitHdl) );
-
     aNames = GetLayoutPropertyNames();
     aValues = aLayoutItem.GetProperties(aNames);
     aLayoutItem.EnableNotification(aNames);
@@ -624,50 +454,6 @@ IMPL_LINK( ScDocCfg, CalcCommitHdl, void *, EMPTYARG )
     return 0;
 }
 
-IMPL_LINK( ScDocCfg, FormulaCommitHdl, void *, EMPTYARG )
-{
-    Sequence<OUString> aNames = GetFormulaPropertyNames();
-    Sequence<Any> aValues(aNames.getLength());
-    Any* pValues = aValues.getArray();
-
-    for (int nProp = 0; nProp < aNames.getLength(); ++nProp)
-    {
-        switch (nProp)
-        {
-            case SCFORMULAOPT_GRAMMAR :
-            {
-                sal_Int32 nVal = 0;
-                switch (GetFormulaSyntax())
-                {
-                    case ::formula::FormulaGrammar::GRAM_NATIVE_XL_A1:    nVal = 1; break;
-                    case ::formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1:  nVal = 2; break;
-                    default: break;
-                }
-                pValues[nProp] <<= nVal;
-            }
-            break;
-            case SCFORMULAOPT_ENGLISH_FUNCNAME:
-            {
-                sal_Bool b = GetUseEnglishFuncName();
-                pValues[nProp] <<= b;
-            }
-            break;
-            case SCFORMULAOPT_SEP_ARG:
-                pValues[nProp] <<= GetFormulaSepArg();
-            break;
-            case SCFORMULAOPT_SEP_ARRAY_ROW:
-                pValues[nProp] <<= GetFormulaSepArrayRow();
-            break;
-            case SCFORMULAOPT_SEP_ARRAY_COL:
-                pValues[nProp] <<= GetFormulaSepArrayCol();
-            break;
-        }
-    }
-    aFormulaItem.PutProperties(aNames, aValues);
-
-    return 0;
-}
-
 IMPL_LINK( ScDocCfg, LayoutCommitHdl, void *, EMPTYARG )
 {
     Sequence<OUString> aNames = GetLayoutPropertyNames();
@@ -718,7 +504,6 @@ void ScDocCfg::SetOptions( const ScDocOptions& rNew )
     *(ScDocOptions*)this = rNew;
 
     aCalcItem.SetModified();
-    aFormulaItem.SetModified();
     aLayoutItem.SetModified();
     aDefaultsItem.SetModified();
 }
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index d34847f..9798306 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -987,6 +987,7 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet )
     sal_Bool                    bCalcAll            = false;
     sal_Bool                    bSaveAppOptions     = false;
     sal_Bool                    bSaveInputOptions   = false;
+    sal_Bool                    bUpdateDocFormat    = false;
 
     //--------------------------------------------------------------------------
 
@@ -1027,6 +1028,77 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet )
     }
 
     //============================================
+    // FormulaOptions
+    //============================================
+
+
+    if (rOptSet.HasItem(SID_SC_OPT_FORMULA_ENGLISH_FUNCNAME, &pItem))
+    {
+        pAppCfg->SetUseEnglishFuncName( static_cast<const SfxBoolItem*>(pItem)->GetValue() );
+        bSaveAppOptions = true;
+        bUpdateDocFormat = true;
+    }
+
+    if (rOptSet.HasItem(SID_SC_OPT_FORMULA_GRAMMAR, &pItem))
+    {
+        sal_uInt16 nVal = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
+        ::formula::FormulaGrammar::Grammar eOld = pAppCfg->GetFormulaSyntax();
+        ::formula::FormulaGrammar::Grammar eNew;
+
+        switch (nVal)
+        {
+        case 0:
+            eNew = ::formula::FormulaGrammar::GRAM_NATIVE;
+            break;
+        case 1:
+            eNew = ::formula::FormulaGrammar::GRAM_NATIVE_XL_A1;
+            break;
+        case 2:
+            eNew = ::formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1;
+            break;
+        }
+
+        if (eOld != eNew)
+        {
+            pAppCfg->SetFormulaSyntax(eNew);
+            bSaveAppOptions = true;
+            bUpdateDocFormat = true;
+        }
+    }
+
+    if (rOptSet.HasItem(SID_SC_OPT_FORMULA_SEP_ARG, &pItem))
+    {
+        pAppCfg->SetFormulaSepArg( static_cast<const SfxStringItem*>(pItem)->GetValue() );
+        bSaveAppOptions = true;
+        bUpdateDocFormat = true;
+    }
+
+    if (rOptSet.HasItem(SID_SC_OPT_FORMULA_SEP_ARRAY_ROW, &pItem))
+    {
+        pAppCfg->SetFormulaSepArrayRow( static_cast<const SfxStringItem*>(pItem)->GetValue() );
+        bSaveAppOptions = true;
+        bUpdateDocFormat = true;
+    }
+
+    if (rOptSet.HasItem(SID_SC_OPT_FORMULA_SEP_ARRAY_COL, &pItem))
+    {
+        pAppCfg->SetFormulaSepArrayCol( static_cast<const SfxStringItem*>(pItem)->GetValue() );
+        bSaveAppOptions = true;
+        bUpdateDocFormat = true;
+    }
+
+    // Do all the format updates on open documents in one go
+    if ( bUpdateDocFormat && pDoc )
+    {
+        const ScDocOptions& rOpt = pDoc->GetDocOptions(); // Temporary fix to keep
+                                                          // SettDocOption call as is
+
+                                                          // Needs update.
+        pDoc->SetDocOptions( rOpt );
+        pDocSh->SetDocumentModified();
+    }
+
+    //============================================
     // ViewOptions
     //============================================
 
@@ -1924,8 +1996,16 @@ SfxItemSet*  ScModule::CreateItemSet( sal_uInt16 nId )
                             SID_ATTR_DEFTABSTOP,    SID_ATTR_DEFTABSTOP,
                             // TP_COMPATIBILITY
                             SID_SC_OPT_KEY_BINDING_COMPAT, SID_SC_OPT_KEY_BINDING_COMPAT,
+                            // TP_FORMULA
+                            SID_SC_OPT_FORMULA_ENGLISH_FUNCNAME, SID_SC_OPT_FORMULA_ENGLISH_FUNCNAME,
+                            SID_SC_OPT_FORMULA_GRAMMAR, SID_SC_OPT_FORMULA_GRAMMAR,
+                            SID_SC_OPT_FORMULA_SEP_ARG, SID_SC_OPT_FORMULA_SEP_ARG,
+                            SID_SC_OPT_FORMULA_SEP_ARRAY_COL, SID_SC_OPT_FORMULA_SEP_ARRAY_COL,
+                            SID_SC_OPT_FORMULA_SEP_ARRAY_ROW, SID_SC_OPT_FORMULA_SEP_ARRAY_ROW,
                             0 );
 
+        const ScAppOptions& rAppOpt = GetAppOptions();
+
         ScDocShell*     pDocSh = PTR_CAST(ScDocShell,
                                             SfxObjectShell::Current());
         ScDocOptions    aCalcOpt = pDocSh
@@ -1944,7 +2024,7 @@ SfxItemSet*  ScModule::CreateItemSet( sal_uInt16 nId )
         //  SFX_APP()->GetOptions( aSet );
 
         pRet->Put( SfxUInt16Item( SID_ATTR_METRIC,
-                        sal::static_int_cast<sal_uInt16>(GetAppOptions().GetAppMetric()) ) );
+                        sal::static_int_cast<sal_uInt16>(rAppOpt.GetAppMetric()) ) );
 
         // TP_CALC
         pRet->Put( SfxUInt16Item( SID_ATTR_DEFTABSTOP,
@@ -1953,7 +2033,7 @@ SfxItemSet*  ScModule::CreateItemSet( sal_uInt16 nId )
 
         // TP_VIEW
         pRet->Put( ScTpViewItem( SID_SCVIEWOPTIONS, aViewOpt ) );
-        pRet->Put( SfxBoolItem( SID_SC_OPT_SYNCZOOM, GetAppOptions().GetSynchronizeZoom() ) );
+        pRet->Put( SfxBoolItem( SID_SC_OPT_SYNCZOOM, rAppOpt.GetSynchronizeZoom() ) );
 
         // TP_INPUT
         const ScInputOptions& rInpOpt = GetInputOptions();
@@ -1989,10 +2069,22 @@ SfxItemSet*  ScModule::CreateItemSet( sal_uInt16 nId )
             aULItem.SetUserList( *pUL );
 
         // TP_COMPATIBILITY
-        pRet->Put(
-            SfxUInt16Item(
-                SID_SC_OPT_KEY_BINDING_COMPAT, GetAppOptions().GetKeyBindingType()));
+        pRet->Put( SfxUInt16Item( SID_SC_OPT_KEY_BINDING_COMPAT,
+                                   rAppOpt.GetKeyBindingType() ) );
+
+        // TP_FORMULA
+        pRet->Put( SfxBoolItem( SID_SC_OPT_FORMULA_ENGLISH_FUNCNAME,
+                                rAppOpt.GetUseEnglishFuncName() ) );
+        pRet->Put( SfxUInt16Item( SID_SC_OPT_FORMULA_GRAMMAR,
+                                  rAppOpt.GetFormulaSyntax() ) );
+        pRet->Put( SfxStringItem( SID_SC_OPT_FORMULA_SEP_ARG,
+                                  rAppOpt.GetFormulaSepArg() ) );
+        pRet->Put( SfxStringItem( SID_SC_OPT_FORMULA_SEP_ARRAY_COL,
+                                  rAppOpt.GetFormulaSepArrayCol() ) );
+        pRet->Put( SfxStringItem( SID_SC_OPT_FORMULA_SEP_ARRAY_ROW,
+                                  rAppOpt.GetFormulaSepArrayRow() ) );
 
+//
         pRet->Put( aULItem );
 
     }
diff --git a/sc/source/ui/docshell/docsh6.cxx b/sc/source/ui/docshell/docsh6.cxx
index afbbf21..c02956c 100644
--- a/sc/source/ui/docshell/docsh6.cxx
+++ b/sc/source/ui/docshell/docsh6.cxx
@@ -47,7 +47,7 @@
 #include "viewdata.hxx"
 #include "tabvwsh.hxx"
 #include "tablink.hxx"
-#include "docoptio.hxx"
+#include "appoptio.hxx"
 #include "globstr.hrc"
 #include "scmod.hxx"
 
@@ -495,19 +495,18 @@ void ScDocShell::CheckConfigOptions()
     OUString aDecSep = ScGlobal::GetpLocaleData()->getNumDecimalSep();
 
     ScModule* pScMod = SC_MOD();
-    const ScDocOptions& rOpt = pScMod->GetDocOptions();
-    OUString aSepArg = rOpt.GetFormulaSepArg();
-    OUString aSepArrRow = rOpt.GetFormulaSepArrayRow();
-    OUString aSepArrCol = rOpt.GetFormulaSepArrayCol();
+    const ScAppOptions& rAppOpt=pScMod->GetAppOptions();
+    OUString aSepArg = rAppOpt.GetFormulaSepArg();
+    OUString aSepArrRow = rAppOpt.GetFormulaSepArrayRow();
+    OUString aSepArrCol = rAppOpt.GetFormulaSepArrayCol();
 
     if (aDecSep == aSepArg || aDecSep == aSepArrRow || aDecSep == aSepArrCol)
     {
         // One of arg separators conflicts with the current decimal
         // separator.  Reset them to default.
-        ScDocOptions aNew = rOpt;
+        ScAppOptions aNew = rAppOpt;
         aNew.ResetFormulaSeparators();
-        aDocument.SetDocOptions(aNew);
-        pScMod->SetDocOptions(aNew);
+        pScMod->SetAppOptions(aNew);
 
         // Launch a nice warning dialog to let the users know of this change.
         ScTabViewShell* pViewShell = GetBestViewShell();
diff --git a/sc/source/ui/inc/tpformula.hxx b/sc/source/ui/inc/tpformula.hxx
index b3d61a3..83abbb9 100644
--- a/sc/source/ui/inc/tpformula.hxx
+++ b/sc/source/ui/inc/tpformula.hxx
@@ -37,7 +37,9 @@
 
 #include <memory>
 
-class ScDocOptions;
+#include <boost/shared_ptr.hpp>
+
+class ScAppOptions;
 class SfxItemSet;
 class Window;
 
@@ -57,7 +59,6 @@ private:
     explicit ScTpFormulaOptions(Window* pParent, const SfxItemSet& rCoreSet);
     virtual ~ScTpFormulaOptions();
 
-    void Init();
     void ResetSeparators();
     void OnFocusSeparatorInput(Edit* pEdit);
 
@@ -83,10 +84,7 @@ private:
     Edit       maEdSepArrayRow;
     PushButton maBtnSepReset;
 
-    SAL_WNODEPRECATED_DECLARATIONS_PUSH
-    ::std::auto_ptr<ScDocOptions> mpOldOptions;
-    ::std::auto_ptr<ScDocOptions> mpNewOptions;
-    SAL_WNODEPRECATED_DECLARATIONS_POP
+    ::boost::shared_ptr<ScAppOptions> mpOptions;
 
     /** Stores old separator value of currently focused separator edit box.
         This value is used to revert undesired value change. */
diff --git a/sc/source/ui/optdlg/tpformula.cxx b/sc/source/ui/optdlg/tpformula.cxx
index 5d62593..241cac0 100644
--- a/sc/source/ui/optdlg/tpformula.cxx
+++ b/sc/source/ui/optdlg/tpformula.cxx
@@ -33,11 +33,15 @@
 
 //------------------------------------------------------------------
 
+#include <scmod.hxx>
+#include <svl/eitem.hxx>
+#include <svl/stritem.hxx>
+
 #include "tpformula.hxx"
 #include "optdlg.hrc"
 #include "scresid.hxx"
 #include "formula/grammar.hxx"
-#include "docoptio.hxx"
+#include "appoptio.hxx"
 #include "global.hxx"
 
 #include <unotools/localedatawrapper.hxx>
@@ -65,26 +69,12 @@ ScTpFormulaOptions::ScTpFormulaOptions(Window* pParent, const SfxItemSet& rCoreA
     maEdSepArrayRow(this, ScResId(ED_FORMULA_SEP_ARRAY_R)),
     maBtnSepReset(this, ScResId(BTN_FORMULA_SEP_RESET)),
 
-    mpOldOptions(NULL),
-    mpNewOptions(NULL),
     mnDecSep(0)
 {
     FreeResource();
 
-    const ScTpCalcItem& rItem = static_cast<const ScTpCalcItem&>(
-        rCoreAttrs.Get(GetWhich(SID_SCDOCOPTIONS)));
-    mpOldOptions.reset(new ScDocOptions(rItem.GetDocOptions()));
-    mpNewOptions.reset(new ScDocOptions(rItem.GetDocOptions()));
-
-    Init();
-}
-
-ScTpFormulaOptions::~ScTpFormulaOptions()
-{
-}
+    mpOptions.reset( new ScAppOptions( SC_MOD()->GetAppOptions() ) );
 
-void ScTpFormulaOptions::Init()
-{
     Link aLink = LINK( this, ScTpFormulaOptions, ButtonHdl );
     maBtnSepReset.SetClickHdl(aLink);
 
@@ -99,16 +89,20 @@ void ScTpFormulaOptions::Init()
     maEdSepArrayRow.SetGetFocusHdl(aLink);
 
     // Get the decimal separator for current locale.
-    String aSep = mpOldOptions->GetLocaleDataWrapper().getNumDecimalSep();
+    String aSep = mpOptions->GetLocaleDataWrapper().getNumDecimalSep();
     mnDecSep = aSep.Len() ? aSep.GetChar(0) : sal_Unicode('.');
 }
 
+ScTpFormulaOptions::~ScTpFormulaOptions()
+{
+}
+
 void ScTpFormulaOptions::ResetSeparators()
 {
-    ScDocOptions aOpt;
-    maEdSepFuncArg.SetText(aOpt.GetFormulaSepArg());
-    maEdSepArrayCol.SetText(aOpt.GetFormulaSepArrayCol());
-    maEdSepArrayRow.SetText(aOpt.GetFormulaSepArrayRow());
+    ScAppOptions rAppOpt=SC_MOD()->GetAppOptions();
+    maEdSepFuncArg.SetText(rAppOpt.GetFormulaSepArg());
+    maEdSepArrayCol.SetText(rAppOpt.GetFormulaSepArrayCol());
+    maEdSepArrayRow.SetText(rAppOpt.GetFormulaSepArrayRow());
 }
 
 void ScTpFormulaOptions::OnFocusSeparatorInput(Edit* pEdit)
@@ -215,7 +209,13 @@ SfxTabPage* ScTpFormulaOptions::Create(Window* pParent, const SfxItemSet& rCoreS
 
 sal_Bool ScTpFormulaOptions::FillItemSet(SfxItemSet& rCoreSet)
 {
+    sal_Bool bRet = false;
+    sal_Bool bEnglishFuncName = maCbEnglishFuncName.IsChecked();
     ::formula::FormulaGrammar::Grammar eGram = ::formula::FormulaGrammar::GRAM_DEFAULT;
+    OUString aSep = maEdSepFuncArg.GetText();
+    OUString aSepArrayCol = maEdSepArrayCol.GetText();
+    OUString aSepArrayRow = maEdSepArrayRow.GetText();
+
     switch (maLbFormulaSyntax.GetSelectEntryPos())
     {
         case 0:
@@ -229,24 +229,38 @@ sal_Bool ScTpFormulaOptions::FillItemSet(SfxItemSet& rCoreSet)
         break;
     }
 
-    mpNewOptions->SetFormulaSyntax(eGram);
-    mpNewOptions->SetUseEnglishFuncName(maCbEnglishFuncName.IsChecked());
-    mpNewOptions->SetFormulaSepArg(maEdSepFuncArg.GetText());
-    mpNewOptions->SetFormulaSepArrayCol(maEdSepArrayCol.GetText());
-    mpNewOptions->SetFormulaSepArrayRow(maEdSepArrayRow.GetText());
-
-    if (*mpNewOptions != *mpOldOptions)
+    if ( bEnglishFuncName != mpOptions->GetUseEnglishFuncName() )
     {
-        rCoreSet.Put(ScTpCalcItem(GetWhich(SID_SCDOCOPTIONS), *mpNewOptions));
-        return true;
+        rCoreSet.Put( SfxBoolItem( SID_SC_OPT_FORMULA_ENGLISH_FUNCNAME, bEnglishFuncName ) );
+        bRet = true;
     }
-    else
-        return false;
+    if ( eGram != mpOptions->GetFormulaSyntax() )
+    {
+        rCoreSet.Put( SfxUInt16Item( SID_SC_OPT_FORMULA_GRAMMAR, eGram ) );
+        bRet = true;
+    }
+    if ( aSep != mpOptions->GetFormulaSepArg() )
+    {
+        rCoreSet.Put( SfxStringItem( SID_SC_OPT_FORMULA_SEP_ARG, aSep ) );
+        bRet = true;
+    }
+    if ( aSepArrayCol != mpOptions->GetFormulaSepArrayCol() )
+    {
+        rCoreSet.Put( SfxStringItem( SID_SC_OPT_FORMULA_SEP_ARRAY_ROW, aSepArrayCol ) );
+        bRet = true;
+    }
+    if ( aSepArrayRow != mpOptions->GetFormulaSepArrayRow() )
+    {
+        rCoreSet.Put( SfxStringItem( SID_SC_OPT_FORMULA_SEP_ARRAY_COL, aSepArrayRow ) );
+        bRet = true;
+    }
+
+    return bRet;
 }
 
 void ScTpFormulaOptions::Reset(const SfxItemSet& /*rCoreSet*/)
 {
-    ::formula::FormulaGrammar::Grammar eGram = mpNewOptions->GetFormulaSyntax();
+    ::formula::FormulaGrammar::Grammar eGram = mpOptions->GetFormulaSyntax();
     switch (eGram)
     {
         case ::formula::FormulaGrammar::GRAM_NATIVE:
@@ -262,11 +276,11 @@ void ScTpFormulaOptions::Reset(const SfxItemSet& /*rCoreSet*/)
             maLbFormulaSyntax.SelectEntryPos(0);
     }
 
-    maCbEnglishFuncName.Check(mpNewOptions->GetUseEnglishFuncName());
+    maCbEnglishFuncName.Check(mpOptions->GetUseEnglishFuncName());
 
-    OUString aSep = mpNewOptions->GetFormulaSepArg();
-    OUString aSepArrayRow = mpNewOptions->GetFormulaSepArrayRow();
-    OUString aSepArrayCol = mpNewOptions->GetFormulaSepArrayCol();
+    OUString aSep = mpOptions->GetFormulaSepArg();
+    OUString aSepArrayRow = mpOptions->GetFormulaSepArrayRow();
+    OUString aSepArrayCol = mpOptions->GetFormulaSepArrayCol();
 
     if (aSep.getLength() == 1 && aSepArrayRow.getLength() == 1 && aSepArrayCol.getLength() == 1)
     {


More information about the Libreoffice-commits mailing list