Date: prev next · Thread: first prev next last
2012 Archives by date, by thread · List index


Hi Kohei,
As said back in February:
http://lists.freedesktop.org/archives/libreoffice/2012-February/027009.html
here is a follow-on patch that "groups" the formula options in the
same fashion as the print options.

This is a quite straight-forward re-factoring of the code so it
shouldn't be too hard to review.

One thing that you might object to is the use of temporary variables in
ScTpFormulaOptions::FillItemSet

If this is the case, please let me know (and why ;) ) and I re-work it.

Once this is pushed, I'll do the same conversion of the defaults options.

/Albert
From 31c8c2667e592e03dc627b6c8c07dc852910a45f Mon Sep 17 00:00:00 2001
From: Albert Thuswaldner <albert.thuswaldner@gmail.com>
Date: Tue, 10 Apr 2012 00:09:40 +0200
Subject: [PATCH] Grouping ScFormulaOptions

---
 sc/Library_sc.mk                   |    1 +
 sc/inc/appoptio.hxx                |   29 ---
 sc/inc/formulaopt.hxx              |  124 ++++++++++++
 sc/inc/sc.hrc                      |    6 +-
 sc/inc/scmod.hxx                   |    5 +
 sc/source/core/tool/appoptio.cxx   |  226 +----------------------
 sc/source/core/tool/formulaopt.cxx |  361 ++++++++++++++++++++++++++++++++++++
 sc/source/ui/app/scmod.cxx         |  120 +++---------
 sc/source/ui/docshell/docsh3.cxx   |    4 +-
 sc/source/ui/docshell/docsh6.cxx   |   20 +-
 sc/source/ui/inc/docsh.hxx         |    3 +-
 sc/source/ui/optdlg/tpformula.cxx  |  153 ++++++++--------
 12 files changed, 613 insertions(+), 439 deletions(-)
 create mode 100644 sc/inc/formulaopt.hxx
 create mode 100644 sc/source/core/tool/formulaopt.cxx

diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index 3856a08..a47b094 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -177,6 +177,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
        sc/source/core/tool/doubleref \
        sc/source/core/tool/editutil \
        sc/source/core/tool/filtopt \
+       sc/source/core/tool/formulaopt \
        sc/source/core/tool/formulaparserpool \
        sc/source/core/tool/hints \
        sc/source/core/tool/inputopt \
diff --git a/sc/inc/appoptio.hxx b/sc/inc/appoptio.hxx
index 7c69f88..b7f5fe8 100644
--- a/sc/inc/appoptio.hxx
+++ b/sc/inc/appoptio.hxx
@@ -91,26 +91,6 @@ 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 void GetDefaultFormulaSeparators(rtl::OUString& rSepArg, rtl::OUString& rSepArrayCol, 
rtl::OUString& rSepArrayRow);
-    static const LocaleDataWrapper& GetLocaleDataWrapper();
-
     const ScAppOptions& operator=   ( const ScAppOptions& rOpt );
 
 private:
@@ -133,12 +113,6 @@ 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;
 };
 
 
@@ -158,7 +132,6 @@ class ScAppCfg : public ScAppOptions
     ScLinkConfigItem    aSortListItem;
     ScLinkConfigItem    aMiscItem;
     ScLinkConfigItem    aCompatItem;
-    ScLinkConfigItem    aFormulaItem;
 
     DECL_LINK( LayoutCommitHdl, void* );
     DECL_LINK( InputCommitHdl, void* );
@@ -167,7 +140,6 @@ 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();
@@ -176,7 +148,6 @@ 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/formulaopt.hxx b/sc/inc/formulaopt.hxx
new file mode 100644
index 0000000..da39fab
--- /dev/null
+++ b/sc/inc/formulaopt.hxx
@@ -0,0 +1,124 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ *       Albert Thuswaldner <albert.thuswaldner@gmail.com>
+ * Portions created by the Initial Developer are Copyright (C) 2012 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#ifndef SC_FORMULAOPT_HXX
+#define SC_FORMULAOPT_HXX
+
+#include <svl/poolitem.hxx>
+#include <unotools/configitem.hxx>
+#include <unotools/localedatawrapper.hxx>
+#include "formula/grammar.hxx"
+#include "scdllapi.h"
+#include "global.hxx"
+
+class SC_DLLPUBLIC ScFormulaOptions
+{
+private:
+    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:
+                ScFormulaOptions();
+                ScFormulaOptions( const ScFormulaOptions& rCpy );
+                ~ScFormulaOptions();
+
+    void    SetDefaults();
+
+    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 void GetDefaultFormulaSeparators(rtl::OUString& rSepArg, rtl::OUString& rSepArrayCol, 
rtl::OUString& rSepArrayRow);
+
+    static const LocaleDataWrapper& GetLocaleDataWrapper();
+
+    const ScFormulaOptions&  operator=  ( const ScFormulaOptions& rCpy );
+    int                      operator== ( const ScFormulaOptions& rOpt ) const;
+    int                      operator!= ( const ScFormulaOptions& rOpt ) const;
+
+};
+
+//==================================================================
+// item for the dialog / options page
+//==================================================================
+
+class SC_DLLPUBLIC ScTpFormulaItem : public SfxPoolItem
+{
+public:
+                TYPEINFO();
+                ScTpFormulaItem( sal_uInt16 nWhich,
+                               const ScFormulaOptions& rOpt );
+                ScTpFormulaItem( const ScTpFormulaItem& rItem );
+                ~ScTpFormulaItem();
+
+    virtual String          GetValueText() const;
+    virtual int             operator==( const SfxPoolItem& ) const;
+    virtual SfxPoolItem*    Clone( SfxItemPool *pPool = 0 ) const;
+
+    const ScFormulaOptions&   GetFormulaOptions() const { return theOptions; }
+
+private:
+    ScFormulaOptions   theOptions;
+};
+
+//==================================================================
+// config item
+//==================================================================
+
+class ScFormulaCfg : public ScFormulaOptions, public utl::ConfigItem
+{
+    com::sun::star::uno::Sequence<rtl::OUString> GetPropertyNames();
+public:
+            ScFormulaCfg();
+
+    void            SetOptions( const ScFormulaOptions& rNew );
+
+    virtual void    Commit();
+    virtual void Notify( const ::com::sun::star::uno::Sequence< rtl::OUString >& aPropertyNames );
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/sc.hrc b/sc/inc/sc.hrc
index ad4649e..6b7d568 100644
--- a/sc/inc/sc.hrc
+++ b/sc/inc/sc.hrc
@@ -117,11 +117,7 @@
 #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)
+#define SID_SCFORMULAOPTIONS    (SC_VIEW_START + 20)
 
 // slot-IDs for attributes
 
diff --git a/sc/inc/scmod.hxx b/sc/inc/scmod.hxx
index 823eaba..22171c8 100644
--- a/sc/inc/scmod.hxx
+++ b/sc/inc/scmod.hxx
@@ -60,11 +60,13 @@ class ScDocument;
 class ScViewCfg;
 class ScDocCfg;
 class ScAppCfg;
+class ScFormulaCfg;
 class ScInputCfg;
 class ScPrintCfg;
 class ScViewOptions;
 class ScDocOptions;
 class ScAppOptions;
+class ScFormulaOptions;
 class ScInputOptions;
 class ScPrintOptions;
 class ScInputHandler;
@@ -104,6 +106,7 @@ class ScModule: public SfxModule, public SfxListener, utl::ConfigurationListener
     ScViewCfg*          pViewCfg;
     ScDocCfg*           pDocCfg;
     ScAppCfg*           pAppCfg;
+    ScFormulaCfg*       pFormulaCfg;
     ScInputCfg*         pInputCfg;
     ScPrintCfg*         pPrintCfg;
     ScNavipiCfg*        pNavipiCfg;
@@ -176,11 +179,13 @@ public:
     const ScViewOptions&    GetViewOptions  ();
 SC_DLLPUBLIC    const ScDocOptions&     GetDocOptions   ();
 SC_DLLPUBLIC    const ScAppOptions&     GetAppOptions   ();
+    const ScFormulaOptions&   GetFormulaOptions ();
     const ScInputOptions&   GetInputOptions ();
 SC_DLLPUBLIC    const ScPrintOptions&   GetPrintOptions ();
     void                    SetViewOptions  ( const ScViewOptions& rOpt );
 SC_DLLPUBLIC    void                    SetDocOptions   ( const ScDocOptions& rOpt );
 SC_DLLPUBLIC    void                    SetAppOptions   ( const ScAppOptions& rOpt );
+    void                    SetFormulaOptions ( const ScFormulaOptions& rOpt );
     void                    SetInputOptions ( const ScInputOptions& rOpt );
     void                    SetPrintOptions ( const ScPrintOptions& rOpt );
     void                    InsertEntryToLRUList(sal_uInt16 nFIndex);
diff --git a/sc/source/core/tool/appoptio.cxx b/sc/source/core/tool/appoptio.cxx
index 9b0e48f..f6a14d4 100644
--- a/sc/source/core/tool/appoptio.cxx
+++ b/sc/source/core/tool/appoptio.cxx
@@ -35,8 +35,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 "appoptio.hxx"
@@ -50,8 +48,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;
 
 // STATIC DATA -----------------------------------------------------------
@@ -121,77 +117,8 @@ void ScAppOptions::SetDefaults()
     mbShowSharedDocumentWarning = true;
 
     meKeyBindingType     = ScOptionsUtil::KEY_DEFAULT;
-
-    bUseEnglishFuncName = false;
-    eFormulaGrammar     = ::formula::FormulaGrammar::GRAM_NATIVE;
-
-    ResetFormulaSeparators();
-}
-
-void ScAppOptions::ResetFormulaSeparators()
-{
-    GetDefaultFormulaSeparators(aFormulaSepArg, aFormulaSepArrayCol, aFormulaSepArrayRow);
 }
 
-void ScAppOptions::GetDefaultFormulaSeparators(
-    rtl::OUString& rSepArg, rtl::OUString& rSepArrayCol, rtl::OUString& rSepArrayRow)
-{
-    // Defaults to the old separator values.
-    rSepArg = OUString(RTL_CONSTASCII_USTRINGPARAM(";"));
-    rSepArrayCol = OUString(RTL_CONSTASCII_USTRINGPARAM(";"));
-    rSepArrayRow = 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.
-    rSepArg = 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.
-        rSepArg = OUString(RTL_CONSTASCII_USTRINGPARAM(";"));
-
-    rSepArrayCol = OUString(RTL_CONSTASCII_USTRINGPARAM(","));
-    if (cDecSep == sal_Unicode(','))
-        rSepArrayCol = OUString(RTL_CONSTASCII_USTRINGPARAM("."));
-    rSepArrayRow = OUString(RTL_CONSTASCII_USTRINGPARAM(";"));
-}
-
-const LocaleDataWrapper& ScAppOptions::GetLocaleDataWrapper()
-{
-    return *ScGlobal::pLocaleData;
-}
-
-
 const ScAppOptions& ScAppOptions::operator=( const ScAppOptions& rCpy )
 {
     nTabCountInNewSpreadsheet = rCpy.nTabCountInNewSpreadsheet;
@@ -212,11 +139,6 @@ 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;
 }
@@ -373,14 +295,6 @@ 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()
 {
     static const char* aPropNames[] =
@@ -494,24 +408,6 @@ 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 )) ),
@@ -519,9 +415,7 @@ 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 )) ),
-    aFormulaItem( OUString(RTL_CONSTASCII_USTRINGPARAM(CFGPATH_FORMULA )) )
-
+    aCompatItem( OUString(RTL_CONSTASCII_USTRINGPARAM(CFGPATH_COMPAT )) )
 {
     sal_Int32 nIntVal = 0;
 
@@ -721,79 +615,6 @@ 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_NOARG(ScAppCfg, LayoutCommitHdl)
@@ -968,50 +789,6 @@ IMPL_LINK_NOARG(ScAppCfg, CompatCommitHdl)
     return 0;
 }
 
-IMPL_LINK_NOARG(ScAppCfg, FormulaCommitHdl)
-{
-    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;
@@ -1027,7 +804,6 @@ void ScAppCfg::OptionsChanged()
     aSortListItem.SetModified();
     aMiscItem.SetModified();
     aCompatItem.SetModified();
-    aFormulaItem.SetModified();
 }
 
 
diff --git a/sc/source/core/tool/formulaopt.cxx b/sc/source/core/tool/formulaopt.cxx
new file mode 100644
index 0000000..f24adc6
--- /dev/null
+++ b/sc/source/core/tool/formulaopt.cxx
@@ -0,0 +1,361 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * The Initial Developer of the Original Code is
+ *       Albert Thuswaldner <albert.thuswaldner@gmail.com>
+ * Portions created by the Initial Developer are Copyright (C) 2012 the
+ * Initial Developer. All Rights Reserved.
+ *
+ * Contributor(s):
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#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 "formulaopt.hxx"
+#include "miscuno.hxx"
+#include "global.hxx"
+
+using namespace utl;
+using namespace com::sun::star::uno;
+using ::com::sun::star::lang::Locale;
+using ::com::sun::star::i18n::LocaleDataItem;
+using ::rtl::OUString;
+
+// -----------------------------------------------------------------------
+
+TYPEINIT1(ScTpFormulaItem, SfxPoolItem);
+
+// -----------------------------------------------------------------------
+
+ScFormulaOptions::ScFormulaOptions()
+{
+    SetDefaults();
+}
+
+ScFormulaOptions::ScFormulaOptions( const ScFormulaOptions& rCpy ) :
+    bUseEnglishFuncName ( rCpy.bUseEnglishFuncName ),
+    eFormulaGrammar     ( rCpy.eFormulaGrammar ),
+    aFormulaSepArg      ( rCpy.aFormulaSepArg ),
+    aFormulaSepArrayRow ( rCpy.aFormulaSepArrayRow ),
+    aFormulaSepArrayCol ( rCpy.aFormulaSepArrayCol )
+{
+}
+
+ScFormulaOptions::~ScFormulaOptions()
+{
+}
+
+void ScFormulaOptions::SetDefaults()
+{
+    bUseEnglishFuncName = false;
+    eFormulaGrammar     = ::formula::FormulaGrammar::GRAM_NATIVE;
+
+    ResetFormulaSeparators();
+}
+
+void ScFormulaOptions::ResetFormulaSeparators()
+{
+    GetDefaultFormulaSeparators(aFormulaSepArg, aFormulaSepArrayCol, aFormulaSepArrayRow);
+}
+
+void ScFormulaOptions::GetDefaultFormulaSeparators(
+    rtl::OUString& rSepArg, rtl::OUString& rSepArrayCol, rtl::OUString& rSepArrayRow)
+{
+    // Defaults to the old separator values.
+    rSepArg = OUString(RTL_CONSTASCII_USTRINGPARAM(";"));
+    rSepArrayCol = OUString(RTL_CONSTASCII_USTRINGPARAM(";"));
+    rSepArrayRow = 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.
+    rSepArg = 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.
+        rSepArg = OUString(RTL_CONSTASCII_USTRINGPARAM(";"));
+
+    rSepArrayCol = OUString(RTL_CONSTASCII_USTRINGPARAM(","));
+    if (cDecSep == sal_Unicode(','))
+        rSepArrayCol = OUString(RTL_CONSTASCII_USTRINGPARAM("."));
+    rSepArrayRow = OUString(RTL_CONSTASCII_USTRINGPARAM(";"));
+}
+
+const LocaleDataWrapper& ScFormulaOptions::GetLocaleDataWrapper()
+{
+    return *ScGlobal::pLocaleData;
+}
+
+const ScFormulaOptions& ScFormulaOptions::operator=( const ScFormulaOptions& rCpy )
+{
+    bUseEnglishFuncName = rCpy.bUseEnglishFuncName;
+    eFormulaGrammar     = rCpy.eFormulaGrammar;
+    aFormulaSepArg      = rCpy.aFormulaSepArg;
+    aFormulaSepArrayRow = rCpy.aFormulaSepArrayRow;
+    aFormulaSepArrayCol = rCpy.aFormulaSepArrayCol;
+    return *this;
+}
+
+int ScFormulaOptions::operator==( const ScFormulaOptions& rOpt ) const
+{
+    return bUseEnglishFuncName == rOpt.bUseEnglishFuncName
+        && eFormulaGrammar     == rOpt.eFormulaGrammar
+        && aFormulaSepArg      == rOpt.aFormulaSepArg
+        && aFormulaSepArrayRow == rOpt.aFormulaSepArrayRow
+        && aFormulaSepArrayCol == rOpt.aFormulaSepArrayCol;
+}
+
+int ScFormulaOptions::operator!=( const ScFormulaOptions& rOpt ) const
+{
+    return !(operator==(rOpt));
+}
+
+// -----------------------------------------------------------------------
+
+
+ScTpFormulaItem::ScTpFormulaItem( sal_uInt16 nWhichP, const ScFormulaOptions& rOpt ) :
+    SfxPoolItem ( nWhichP ),
+    theOptions  ( rOpt )
+{
+}
+
+ScTpFormulaItem::ScTpFormulaItem( const ScTpFormulaItem& rItem ) :
+    SfxPoolItem ( rItem ),
+    theOptions  ( rItem.theOptions )
+{
+}
+
+ScTpFormulaItem::~ScTpFormulaItem()
+{
+}
+
+String ScTpFormulaItem::GetValueText() const
+{
+    return String::CreateFromAscii( "ScTpFormulaItem" );
+}
+
+int ScTpFormulaItem::operator==( const SfxPoolItem& rItem ) const
+{
+    OSL_ENSURE( SfxPoolItem::operator==( rItem ), "unequal Which or Type" );
+
+    const ScTpFormulaItem& rPItem = (const ScTpFormulaItem&)rItem;
+    return ( theOptions == rPItem.theOptions );
+}
+
+SfxPoolItem* ScTpFormulaItem::Clone( SfxItemPool * ) const
+{
+    return new ScTpFormulaItem( *this );
+}
+
+// -----------------------------------------------------------------------
+
+#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> ScFormulaCfg::GetPropertyNames()
+{
+    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;
+}
+
+ScFormulaCfg::ScFormulaCfg() :
+    ConfigItem( OUString(RTL_CONSTASCII_USTRINGPARAM( CFGPATH_FORMULA )) )
+{
+    sal_Int32 nIntVal = 0;
+
+    Sequence<OUString> aNames = GetPropertyNames();
+    Sequence<Any> aValues = GetProperties(aNames);
+    const Any* pValues = aValues.getConstArray();
+    OSL_ENSURE(aValues.getLength() == aNames.getLength(), "GetProperties failed");
+    if(aValues.getLength() == aNames.getLength())
+    {
+        for(int nProp = 0; nProp < aNames.getLength(); nProp++)
+        {
+            OSL_ENSURE(pValues[nProp].hasValue(), "property value missing");
+            if(pValues[nProp].hasValue())
+            {
+                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;
+                }
+            }
+        }
+    }
+}
+
+void ScFormulaCfg::Commit()
+{
+    Sequence<OUString> aNames = GetPropertyNames();
+    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;
+        }
+    }
+    PutProperties(aNames, aValues);
+}
+
+void ScFormulaCfg::SetOptions( const ScFormulaOptions& rNew )
+{
+    *(ScFormulaOptions*)this = rNew;
+    SetModified();
+}
+
+void ScFormulaCfg::Notify( const ::com::sun::star::uno::Sequence< OUString >& ) {}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index dbddbe0..4dec73a 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -79,6 +79,7 @@
 #include "viewopti.hxx"
 #include "docoptio.hxx"
 #include "appoptio.hxx"
+#include "formulaopt.hxx"
 #include "inputopt.hxx"
 #include "printopt.hxx"
 #include "navicfg.hxx"
@@ -141,6 +142,7 @@ ScModule::ScModule( SfxObjectFactory* pFact ) :
     pViewCfg( NULL ),
     pDocCfg( NULL ),
     pAppCfg( NULL ),
+    pFormulaCfg( NULL ),
     pInputCfg( NULL ),
     pPrintCfg( NULL ),
     pNavipiCfg( NULL ),
@@ -342,6 +344,7 @@ void ScModule::DeleteCfg()
     DELETEZ( pViewCfg ); // Speichern passiert vor Exit() automatisch
     DELETEZ( pDocCfg );
     DELETEZ( pAppCfg );
+    DELETEZ( pFormulaCfg );
     DELETEZ( pInputCfg );
     DELETEZ( pPrintCfg );
     DELETEZ( pNavipiCfg );
@@ -849,6 +852,22 @@ const ScAppOptions& ScModule::GetAppOptions()
     return *pAppCfg;
 }
 
+void ScModule::SetFormulaOptions( const ScFormulaOptions& rOpt )
+{
+    if ( !pFormulaCfg )
+        pFormulaCfg = new ScFormulaCfg;
+
+    pFormulaCfg->SetOptions( rOpt );
+}
+
+const ScFormulaOptions& ScModule::GetFormulaOptions()
+{
+    if ( !pFormulaCfg )
+        pFormulaCfg = new ScFormulaCfg;
+
+    return *pFormulaCfg;
+}
+
 void ScModule::SetInputOptions( const ScInputOptions& rOpt )
 {
     if ( !pInputCfg )
@@ -987,7 +1006,6 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet )
     sal_Bool                    bCalcAll            = false;
     sal_Bool                    bSaveAppOptions     = false;
     sal_Bool                    bSaveInputOptions   = false;
-    sal_Bool                    bUpdateDocFormat    = false;
 
     //--------------------------------------------------------------------------
 
@@ -1031,71 +1049,18 @@ 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))
+    if (rOptSet.HasItem(SID_SCFORMULAOPTIONS, &pItem))
     {
-        sal_uInt16 nVal = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
-        ::formula::FormulaGrammar::Grammar eOld = pAppCfg->GetFormulaSyntax();
-        ::formula::FormulaGrammar::Grammar eNew = ::formula::FormulaGrammar::GRAM_NATIVE;
+        const ScFormulaOptions& rOpt = ((const ScTpFormulaItem*)pItem)->GetFormulaOptions();
+        SetFormulaOptions( rOpt );
 
-        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;
-        default:
-            ;
-        }
-
-        if (eOld != eNew)
+        if ( pDocSh )
         {
-            pAppCfg->SetFormulaSyntax(eNew);
-            bSaveAppOptions = true;
-            bUpdateDocFormat = true;
+            pDocSh->SetFormulaOptions( rOpt );
+            pDocSh->SetDocumentModified();
         }
     }
 
-    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 && pDocSh )
-    {
-        pDocSh->SetFormulaOptions( *pAppCfg );
-        pDocSh->SetDocumentModified();
-    }
-
     //============================================
     // ViewOptions
     //============================================
@@ -1995,11 +1960,7 @@ SfxItemSet*  ScModule::CreateItemSet( sal_uInt16 nId )
                             // 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,
+                            SID_SCFORMULAOPTIONS, SID_SCFORMULAOPTIONS,
                             0 );
 
         const ScAppOptions& rAppOpt = GetAppOptions();
@@ -2071,34 +2032,7 @@ SfxItemSet*  ScModule::CreateItemSet( sal_uInt16 nId )
                                    rAppOpt.GetKeyBindingType() ) );
 
         // TP_FORMULA
-        pRet->Put( SfxBoolItem( SID_SC_OPT_FORMULA_ENGLISH_FUNCNAME,
-                                rAppOpt.GetUseEnglishFuncName() ) );
-
-        sal_uInt16 nVal = 0;
-        switch (rAppOpt.GetFormulaSyntax())
-        {
-            case formula::FormulaGrammar::GRAM_NATIVE:
-                nVal = 0;
-            break;
-            case formula::FormulaGrammar::GRAM_NATIVE_XL_A1:
-                nVal = 1;
-            break;
-            case formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1:
-                nVal = 2;
-            break;
-            default:
-                ;
-        }
-        pRet->Put( SfxUInt16Item( SID_SC_OPT_FORMULA_GRAMMAR, nVal ) );
-        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 );
-
+        pRet->Put( ScTpFormulaItem( SID_SCFORMULAOPTIONS, GetFormulaOptions() ) );
     }
     return pRet;
 }
diff --git a/sc/source/ui/docshell/docsh3.cxx b/sc/source/ui/docshell/docsh3.cxx
index 522e9d7..a07226b 100644
--- a/sc/source/ui/docshell/docsh3.cxx
+++ b/sc/source/ui/docshell/docsh3.cxx
@@ -432,7 +432,7 @@ void ScDocShell::InitOptions(bool bForLoading)      // called from InitNew and L
     ScModule* pScMod = SC_MOD();
 
     ScDocOptions  aDocOpt  = pScMod->GetDocOptions();
-    ScAppOptions  aAppOpt  = pScMod->GetAppOptions();
+    ScFormulaOptions aFormulaOpt = pScMod->GetFormulaOptions();
     ScViewOptions aViewOpt = pScMod->GetViewOptions();
     aDocOpt.SetAutoSpell( bAutoSpell );
 
@@ -449,7 +449,7 @@ void ScDocShell::InitOptions(bool bForLoading)      // called from InitNew and L
 
     aDocument.SetDocOptions( aDocOpt );
     aDocument.SetViewOptions( aViewOpt );
-    SetFormulaOptions( aAppOpt );
+    SetFormulaOptions( aFormulaOpt );
 
     //  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 372415e..f6831dd 100644
--- a/sc/source/ui/docshell/docsh6.cxx
+++ b/sc/source/ui/docshell/docsh6.cxx
@@ -481,13 +481,13 @@ sal_Bool ScDocShell::ReloadTabLinks()
     return sal_True;        //! Fehler erkennen
 }
 
-void ScDocShell::SetFormulaOptions(const ScAppOptions& rAppOpt )
+void ScDocShell::SetFormulaOptions(const ScFormulaOptions& rOpt )
 {
-    aDocument.SetGrammar( rAppOpt.GetFormulaSyntax() );
+    aDocument.SetGrammar( rOpt.GetFormulaSyntax() );
 
     // This needs to be called first since it may re-initialize the entire
     // opcode map.
-    if (rAppOpt.GetUseEnglishFuncName())
+    if (rOpt.GetUseEnglishFuncName())
     {
         // switch native symbols to English.
         ScCompiler aComp(NULL, ScAddress());
@@ -503,7 +503,7 @@ void ScDocShell::SetFormulaOptions(const ScAppOptions& rAppOpt )
 
     // Update the separators.
     ScCompiler::UpdateSeparatorsNative(
-        rAppOpt.GetFormulaSepArg(), rAppOpt.GetFormulaSepArrayCol(), 
rAppOpt.GetFormulaSepArrayRow());
+        rOpt.GetFormulaSepArg(), rOpt.GetFormulaSepArrayCol(), rOpt.GetFormulaSepArrayRow());
 }
 
 void ScDocShell::CheckConfigOptions()
@@ -515,19 +515,19 @@ void ScDocShell::CheckConfigOptions()
     OUString aDecSep = ScGlobal::GetpLocaleData()->getNumDecimalSep();
 
     ScModule* pScMod = SC_MOD();
-    const ScAppOptions& rAppOpt=pScMod->GetAppOptions();
-    OUString aSepArg = rAppOpt.GetFormulaSepArg();
-    OUString aSepArrRow = rAppOpt.GetFormulaSepArrayRow();
-    OUString aSepArrCol = rAppOpt.GetFormulaSepArrayCol();
+    const ScFormulaOptions& rOpt=pScMod->GetFormulaOptions();
+    OUString aSepArg = rOpt.GetFormulaSepArg();
+    OUString aSepArrRow = rOpt.GetFormulaSepArrayRow();
+    OUString aSepArrCol = rOpt.GetFormulaSepArrayCol();
 
     if (aDecSep == aSepArg || aDecSep == aSepArrRow || aDecSep == aSepArrCol)
     {
         // One of arg separators conflicts with the current decimal
         // separator.  Reset them to default.
-        ScAppOptions aNew = rAppOpt;
+        ScFormulaOptions aNew = rOpt;
         aNew.ResetFormulaSeparators();
         SetFormulaOptions(aNew);
-        pScMod->SetAppOptions(aNew);
+        pScMod->SetFormulaOptions(aNew);
 
         // Launch a nice warning dialog to let the users know of this change.
         ScTabViewShell* pViewShell = GetBestViewShell();
diff --git a/sc/source/ui/inc/docsh.hxx b/sc/source/ui/inc/docsh.hxx
index 488c202..56f6c93 100644
--- a/sc/source/ui/inc/docsh.hxx
+++ b/sc/source/ui/inc/docsh.hxx
@@ -40,6 +40,7 @@
 #include "scdll.hxx"
 #include "document.hxx"
 #include "appoptio.hxx"
+#include "formulaopt.hxx"
 #include "shellids.hxx"
 #include "refreshtimer.hxx"
 #include "optutil.hxx"
@@ -321,7 +322,7 @@ public:
     void            UpdateLinks();          // Link-Eintraege aktuallisieren
     sal_Bool            ReloadTabLinks();       // Links ausfuehren (Inhalt aktualisieren)
 
-    void            SetFormulaOptions(const ScAppOptions& rAppOpt );
+    void            SetFormulaOptions(const ScFormulaOptions& rOpt );
     virtual void    CheckConfigOptions();
 
     void            PostEditView( ScEditEngineDefaulter* pEditEngine, const ScAddress& rCursorPos 
);
diff --git a/sc/source/ui/optdlg/tpformula.cxx b/sc/source/ui/optdlg/tpformula.cxx
index ccda938..c029c81 100644
--- a/sc/source/ui/optdlg/tpformula.cxx
+++ b/sc/source/ui/optdlg/tpformula.cxx
@@ -36,13 +36,11 @@
 #include <scmod.hxx>
 #include <svl/eitem.hxx>
 #include <svl/stritem.hxx>
-
 #include "tpformula.hxx"
+#include "formulaopt.hxx"
 #include "optdlg.hrc"
 #include "scresid.hxx"
 #include "formula/grammar.hxx"
-#include "appoptio.hxx"
-#include "global.hxx"
 
 #include <unotools/localedatawrapper.hxx>
 
@@ -87,7 +85,13 @@ ScTpFormulaOptions::ScTpFormulaOptions(Window* pParent, const SfxItemSet& rCoreA
     maEdSepArrayRow.SetGetFocusHdl(aLink);
 
     // Get the decimal separator for current locale.
-    rtl::OUString aSep = SC_MOD()->GetAppOptions().GetLocaleDataWrapper().getNumDecimalSep();
+    ScFormulaOptions aOpt;
+    const SfxPoolItem* pItem = NULL;
+
+    if(SFX_ITEM_SET == rCoreAttrs.GetItemState(SID_SCFORMULAOPTIONS, false , &pItem))
+        aOpt = ((const ScTpFormulaItem*)pItem)->GetFormulaOptions();
+
+    rtl::OUString aSep = aOpt.GetLocaleDataWrapper().getNumDecimalSep();
     mnDecSep = aSep.isEmpty() ? sal_Unicode('.') : aSep[0];
 }
 
@@ -98,7 +102,7 @@ ScTpFormulaOptions::~ScTpFormulaOptions()
 void ScTpFormulaOptions::ResetSeparators()
 {
     rtl::OUString aFuncArg, aArrayCol, aArrayRow;
-    ScAppOptions::GetDefaultFormulaSeparators(aFuncArg, aArrayCol, aArrayRow);
+    ScFormulaOptions::GetDefaultFormulaSeparators(aFuncArg, aArrayCol, aArrayRow);
     maEdSepFuncArg.SetText(aFuncArg);
     maEdSepArrayCol.SetText(aArrayCol);
     maEdSepArrayRow.SetText(aArrayRow);
@@ -208,96 +212,97 @@ SfxTabPage* ScTpFormulaOptions::Create(Window* pParent, const SfxItemSet& 
rCoreS
 
 sal_Bool ScTpFormulaOptions::FillItemSet(SfxItemSet& rCoreSet)
 {
-    bool bRet = false;
-    if (maLbFormulaSyntax.GetSavedValue() != maLbFormulaSyntax.GetSelectEntryPos())
+    sal_Bool bRet = false;
+    ScFormulaOptions aOpt;
+    sal_Bool bEnglishFuncName = maCbEnglishFuncName.IsChecked();
+    sal_Int16 aSyntaxPos      = maLbFormulaSyntax.GetSelectEntryPos();
+    OUString aSep             = maEdSepFuncArg.GetText();
+    OUString aSepArrayCol     = maEdSepArrayCol.GetText();
+    OUString aSepArrayRow     = maEdSepArrayRow.GetText();
+
+    if ( maLbFormulaSyntax.GetSavedValue() != aSyntaxPos
+         || maCbEnglishFuncName.GetSavedValue() != bEnglishFuncName
+         || static_cast<OUString>(maEdSepFuncArg.GetSavedValue()) != aSep
+         || static_cast<OUString>(maEdSepArrayCol.GetSavedValue()) != aSepArrayCol
+         || static_cast<OUString>(maEdSepArrayRow.GetSavedValue()) != aSepArrayRow )
     {
-        rCoreSet.Put(
-            SfxUInt16Item(SID_SC_OPT_FORMULA_GRAMMAR, maLbFormulaSyntax.GetSelectEntryPos()));
+        ::formula::FormulaGrammar::Grammar eGram = ::formula::FormulaGrammar::GRAM_DEFAULT;
+
+        switch (aSyntaxPos)
+        {
+        case 0:
+            eGram = ::formula::FormulaGrammar::GRAM_NATIVE;
+        break;
+        case 1:
+            eGram = ::formula::FormulaGrammar::GRAM_NATIVE_XL_A1;
+        break;
+        case 2:
+            eGram = ::formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1;
+        break;
+        }
+
+        aOpt.SetFormulaSyntax(eGram);
+        aOpt.SetUseEnglishFuncName(bEnglishFuncName);
+        aOpt.SetFormulaSepArg(aSep);
+        aOpt.SetFormulaSepArrayCol(aSepArrayCol);
+        aOpt.SetFormulaSepArrayRow(aSepArrayRow);
+
+        rCoreSet.Put( ScTpFormulaItem( SID_SCFORMULAOPTIONS, aOpt ) );
         bRet = true;
     }
-
-    if (maCbEnglishFuncName.GetSavedValue() != maCbEnglishFuncName.IsChecked())
-    {
-        rCoreSet.Put(
-            SfxBoolItem(SID_SC_OPT_FORMULA_ENGLISH_FUNCNAME, maCbEnglishFuncName.IsChecked()));
-        bRet = true;
-    }
-
-    if (maEdSepFuncArg.GetSavedValue() != maEdSepFuncArg.GetText())
-    {
-        rCoreSet.Put(
-            SfxStringItem(SID_SC_OPT_FORMULA_SEP_ARG, maEdSepFuncArg.GetText()));
-        bRet = true;
-    }
-
-    if (maEdSepArrayCol.GetSavedValue() != maEdSepArrayCol.GetText())
-    {
-        rCoreSet.Put(
-            SfxStringItem(SID_SC_OPT_FORMULA_SEP_ARRAY_COL, maEdSepArrayCol.GetText()));
-        bRet = true;
-    }
-
-    if (maEdSepArrayRow.GetSavedValue() != maEdSepArrayRow.GetText())
-    {
-        rCoreSet.Put(
-            SfxStringItem(SID_SC_OPT_FORMULA_SEP_ARRAY_ROW, maEdSepArrayRow.GetText()));
-        bRet = true;
-    }
-
     return bRet;
 }
 
 void ScTpFormulaOptions::Reset(const SfxItemSet& rCoreSet)
 {
+    ScFormulaOptions aOpt;
     const SfxPoolItem* pItem = NULL;
 
+    if(SFX_ITEM_SET == rCoreSet.GetItemState(SID_SCFORMULAOPTIONS, false , &pItem))
+        aOpt = ((const ScTpFormulaItem*)pItem)->GetFormulaOptions();
+
     // formula grammar.
-    maLbFormulaSyntax.SelectEntryPos(0);
-    if (rCoreSet.HasItem(SID_SC_OPT_FORMULA_GRAMMAR, &pItem))
+    ::formula::FormulaGrammar::Grammar eGram = aOpt.GetFormulaSyntax();
+
+    switch (eGram)
     {
-        sal_uInt16 nVal = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
-        if (nVal <= 2)
-            maLbFormulaSyntax.SelectEntryPos(nVal);
+    case ::formula::FormulaGrammar::GRAM_NATIVE:
+        maLbFormulaSyntax.SelectEntryPos(0);
+        break;
+    case ::formula::FormulaGrammar::GRAM_NATIVE_XL_A1:
+        maLbFormulaSyntax.SelectEntryPos(1);
+        break;
+    case ::formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1:
+        maLbFormulaSyntax.SelectEntryPos(2);
+        break;
+    default:
+        maLbFormulaSyntax.SelectEntryPos(0);
     }
+
     maLbFormulaSyntax.SaveValue();
 
     // english function name.
-    maCbEnglishFuncName.Check(false);
-    if (rCoreSet.HasItem(SID_SC_OPT_FORMULA_ENGLISH_FUNCNAME, &pItem))
-    {
-        bool bVal = static_cast<const SfxBoolItem*>(pItem)->GetValue();
-        maCbEnglishFuncName.Check(bVal);
-    }
+    maCbEnglishFuncName.Check( aOpt.GetUseEnglishFuncName() );
     maCbEnglishFuncName.SaveValue();
 
-    ResetSeparators();
-
-    // argument separator.
-    if (rCoreSet.HasItem(SID_SC_OPT_FORMULA_SEP_ARG, &pItem))
-    {
-        rtl::OUString aVal = static_cast<const SfxStringItem*>(pItem)->GetValue();
-        if (aVal.getLength() == 1)
-            maEdSepFuncArg.SetText(aVal);
-    }
-    maEdSepFuncArg.SaveValue();
-
-    // matrix column separator.
-    if (rCoreSet.HasItem(SID_SC_OPT_FORMULA_SEP_ARRAY_COL, &pItem))
-    {
-        rtl::OUString aVal = static_cast<const SfxStringItem*>(pItem)->GetValue();
-        if (aVal.getLength() == 1)
-            maEdSepArrayCol.SetText(aVal);
-    }
-    maEdSepArrayCol.SaveValue();
+    // Separators
+    OUString aSep = aOpt.GetFormulaSepArg();
+    OUString aSepArrayRow = aOpt.GetFormulaSepArrayRow();
+    OUString aSepArrayCol = aOpt.GetFormulaSepArrayCol();
 
-    // matrix row separator.
-    if (rCoreSet.HasItem(SID_SC_OPT_FORMULA_SEP_ARRAY_ROW, &pItem))
+    if (aSep.getLength() == 1 && aSepArrayRow.getLength() == 1 && aSepArrayCol.getLength() == 1)
     {
-        rtl::OUString aVal = static_cast<const SfxStringItem*>(pItem)->GetValue();
-        if (aVal.getLength() == 1)
-            maEdSepArrayRow.SetText(aVal);
+        // Each separator must be one character long.
+        maEdSepFuncArg.SetText(aSep);
+        maEdSepArrayCol.SetText(aSepArrayCol);
+        maEdSepArrayRow.SetText(aSepArrayRow);
+
+        maEdSepFuncArg.SaveValue();
+        maEdSepArrayCol.SaveValue();
+        maEdSepArrayRow.SaveValue();
     }
-    maEdSepArrayRow.SaveValue();
+    else
+        ResetSeparators();
 }
 
 int ScTpFormulaOptions::DeactivatePage(SfxItemSet* /*pSet*/)
-- 
1.7.3.4


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.