Hi,
This is an old topic again...

On Tue, Jul 12, 2011 at 00:26, Markus Mohrhard
<markus.mohrh...@googlemail.com> wrote:
> Hello Albert,
>
> nice work but I have some comments.
>
> Operator== should have return type bool and not int(I saw that ScDocOptions
> used int too, but I have changed that already).
> But all in all I think we shouldn't introduce operator== there.
> I didn't like the old approach with operator== but after your changes it
> seems even more unnecessary. Let's just use ScAppOptions directly and set
> the keybinding even if it is the same keybinding as the old one. With this
> approach you don't need to compare two ScAppOptions instances and there is
> no need for operator== anymore. And all in all I think we can remove the two
> dynamically created ScAppOption instances with this approach.
>

I have updated the patch according to Markus comments above, removing
the check to see if the keybinding option has been modified. A side
effect of the above is that return type sal_Bool of
ScTpCompatOptions::FillItemSet is not needed anymore (at the moment i
have set it to always return true). In the next iteration I plan to
check what to do with this.

Before I do that it would be nice If someone could have a look at my
new patch. It is good, I plan to do the same thing to the Formula and
Defaults options.

BTW: will the work on simplified C++ configuration access have any
impact on this part of the code?

/Albert
From 8697ca2fe0c79ee4cdbab9eb711ab4917fae131e Mon Sep 17 00:00:00 2001
From: Albert Thuswaldner <albert.thuswald...@gmail.com>
Date: Fri, 3 Feb 2012 11:15:31 +0100
Subject: [PATCH] Moved ScTpCompat from docoptions to appoptions

---
 sc/inc/appoptio.hxx                     |   33 +++++++++++-
 sc/inc/docoptio.hxx                     |    9 ---
 sc/source/core/tool/appoptio.cxx        |   87 ++++++++++++++++++++++---------
 sc/source/core/tool/docoptio.cxx        |   63 ----------------------
 sc/source/ui/app/scmod.cxx              |    4 --
 sc/source/ui/inc/tpcompatibility.hxx    |    5 +-
 sc/source/ui/optdlg/tpcompatibility.cxx |   21 +++-----
 7 files changed, 103 insertions(+), 119 deletions(-)

diff --git a/sc/inc/appoptio.hxx b/sc/inc/appoptio.hxx
index 84fbc86..91cedbc 100644
--- a/sc/inc/appoptio.hxx
+++ b/sc/inc/appoptio.hxx
@@ -33,6 +33,7 @@
 #include <svx/zoomitem.hxx>
 #include <unotools/configitem.hxx>
 #include "scdllapi.h"
+#include "scmod.hxx"
 #include "global.hxx"
 #include "optutil.hxx"
 
@@ -87,9 +88,11 @@ public:
 
     void        SetShowSharedDocumentWarning( sal_Bool bNew )   { mbShowSharedDocumentWarning = bNew; }
     sal_Bool        GetShowSharedDocumentWarning() const        { return mbShowSharedDocumentWarning; }
+    ScOptionsUtil::KeyBindingType GetKeyBindingType() const { return eKeyBindingType; }
+    void        SetKeyBindingType( ScOptionsUtil::KeyBindingType e ) { eKeyBindingType = e; }
 
 
-    const ScAppOptions& operator=   ( const ScAppOptions& rOpt );
+    inline const ScAppOptions&	operator=( const ScAppOptions& rOpt );
 
 private:
     SCTAB   nTabCountInNewSpreadsheet;
@@ -110,8 +113,32 @@ private:
     sal_Int32       nDefaultObjectSizeWidth;
     sal_Int32       nDefaultObjectSizeHeight;
     sal_Bool        mbShowSharedDocumentWarning;
+    ScOptionsUtil::KeyBindingType eKeyBindingType;
 };
 
+inline const ScAppOptions& ScAppOptions::operator=( const ScAppOptions& rCpy )
+{
+    nTabCountInNewSpreadsheet = rCpy.nTabCountInNewSpreadsheet;
+    eMetric			= rCpy.eMetric;
+    eZoomType		= rCpy.eZoomType;
+    bSynchronizeZoom = rCpy.bSynchronizeZoom;
+    nZoom			= rCpy.nZoom;
+    SetLRUFuncList( rCpy.pLRUList, rCpy.nLRUFuncCount );
+    nStatusFunc		= rCpy.nStatusFunc;
+    bAutoComplete	= rCpy.bAutoComplete;
+    bDetectiveAuto	= rCpy.bDetectiveAuto;
+    nTrackContentColor = rCpy.nTrackContentColor;
+    nTrackInsertColor  = rCpy.nTrackInsertColor;
+    nTrackDeleteColor  = rCpy.nTrackDeleteColor;
+    nTrackMoveColor    = rCpy.nTrackMoveColor;
+    eLinkMode		= rCpy.eLinkMode;
+    nDefaultObjectSizeWidth = rCpy.nDefaultObjectSizeWidth;
+    nDefaultObjectSizeHeight = rCpy.nDefaultObjectSizeHeight;
+    mbShowSharedDocumentWarning = rCpy.mbShowSharedDocumentWarning;
+    eKeyBindingType  = rCpy.eKeyBindingType;
+
+    return *this;
+}
 
 //==================================================================
 //  Config Item containing app options
@@ -128,6 +155,7 @@ class ScAppCfg : public ScAppOptions
     ScLinkConfigItem    aContentItem;
     ScLinkConfigItem    aSortListItem;
     ScLinkConfigItem    aMiscItem;
+    ScLinkConfigItem    aCompatItem;
 
     DECL_LINK( LayoutCommitHdl, void* );
     DECL_LINK( InputCommitHdl, void* );
@@ -135,6 +163,7 @@ class ScAppCfg : public ScAppOptions
     DECL_LINK( ContentCommitHdl, void* );
     DECL_LINK( SortListCommitHdl, void* );
     DECL_LINK( MiscCommitHdl, void* );
+    DECL_LINK( CompatCommitHdl, void* );
 
     com::sun::star::uno::Sequence<rtl::OUString> GetLayoutPropertyNames();
     com::sun::star::uno::Sequence<rtl::OUString> GetInputPropertyNames();
@@ -142,6 +171,7 @@ class ScAppCfg : public ScAppOptions
     com::sun::star::uno::Sequence<rtl::OUString> GetContentPropertyNames();
     com::sun::star::uno::Sequence<rtl::OUString> GetSortListPropertyNames();
     com::sun::star::uno::Sequence<rtl::OUString> GetMiscPropertyNames();
+    com::sun::star::uno::Sequence<rtl::OUString> GetCompatPropertyNames();
 
 public:
             ScAppCfg();
@@ -150,7 +180,6 @@ public:
     void    OptionsChanged();   // after direct access to ScAppOptions base class
 };
 
-
 #endif
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/inc/docoptio.hxx b/sc/inc/docoptio.hxx
index a960ec0..de44cf0 100644
--- a/sc/inc/docoptio.hxx
+++ b/sc/inc/docoptio.hxx
@@ -45,7 +45,6 @@ class SC_DLLPUBLIC ScDocOptions
     SCTAB nInitTabCount;            // number of Tabs for new Spreadsheet doc
     ::rtl::OUString aInitTabPrefix;   // The Tab prefix name in new Spreadsheet doc
     sal_uInt16 nPrecStandardFormat; // precision for standard format
-    ScOptionsUtil::KeyBindingType eKeyBindingType;
     sal_uInt16 nDay;                    // Null date:
     sal_uInt16 nMonth;
     sal_uInt16 nYear;
@@ -105,9 +104,6 @@ public:
     sal_uInt16  GetStdPrecision() const { return nPrecStandardFormat; }
     void        SetStdPrecision( sal_uInt16 n ) { nPrecStandardFormat = n; }
 
-    ScOptionsUtil::KeyBindingType GetKeyBindingType() const { return eKeyBindingType; }
-    void        SetKeyBindingType( ScOptionsUtil::KeyBindingType e ) { eKeyBindingType = e; }
-
     sal_Bool    IsCalcAsShown() const       { return bCalcAsShown; }
     void    SetCalcAsShown( sal_Bool bVal ) { bCalcAsShown = bVal; }
 
@@ -145,7 +141,6 @@ inline const ScDocOptions& ScDocOptions::operator=( const ScDocOptions& rCpy )
     aInitTabPrefix      = rCpy.aInitTabPrefix;
     fIterEps            = rCpy.fIterEps;
     nPrecStandardFormat = rCpy.nPrecStandardFormat;
-    eKeyBindingType     = rCpy.eKeyBindingType;
     nDay                = rCpy.nDay;
     nMonth              = rCpy.nMonth;
     nYear               = rCpy.nYear;
@@ -175,7 +170,6 @@ inline bool ScDocOptions::operator==( const ScDocOptions& rOpt ) const
             &&  rOpt.aInitTabPrefix         == aInitTabPrefix
             &&  rOpt.fIterEps               == fIterEps
             &&  rOpt.nPrecStandardFormat    == nPrecStandardFormat
-            &&  rOpt.eKeyBindingType        == eKeyBindingType
             &&  rOpt.nDay                   == nDay
             &&  rOpt.nMonth                 == nMonth
             &&  rOpt.nYear                  == nYear
@@ -231,19 +225,16 @@ class ScDocCfg : public ScDocOptions
     ScLinkConfigItem    aCalcItem;
     ScLinkConfigItem    aFormulaItem;
     ScLinkConfigItem    aLayoutItem;
-    ScLinkConfigItem    aCompatItem;
     ScLinkConfigItem    aDefaultsItem;
 
     DECL_LINK( CalcCommitHdl, void* );
     DECL_LINK( FormulaCommitHdl, void* );
     DECL_LINK( LayoutCommitHdl, void* );
-    DECL_LINK( CompatCommitHdl, 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> GetCompatPropertyNames();
     com::sun::star::uno::Sequence<rtl::OUString> GetDefaultsPropertyNames();
 
 public:
diff --git a/sc/source/core/tool/appoptio.cxx b/sc/source/core/tool/appoptio.cxx
index 66db4f8..a2f9f80 100644
--- a/sc/source/core/tool/appoptio.cxx
+++ b/sc/source/core/tool/appoptio.cxx
@@ -116,30 +116,8 @@ void ScAppOptions::SetDefaults()
     nDefaultObjectSizeHeight = 5000;
 
     mbShowSharedDocumentWarning = true;
-}
-
-//------------------------------------------------------------------------
 
-const ScAppOptions& ScAppOptions::operator=( const ScAppOptions& rCpy )
-{
-    nTabCountInNewSpreadsheet = rCpy.nTabCountInNewSpreadsheet;
-    eMetric         = rCpy.eMetric;
-    eZoomType       = rCpy.eZoomType;
-    bSynchronizeZoom = rCpy.bSynchronizeZoom;
-    nZoom           = rCpy.nZoom;
-    SetLRUFuncList( rCpy.pLRUList, rCpy.nLRUFuncCount );
-    nStatusFunc     = rCpy.nStatusFunc;
-    bAutoComplete   = rCpy.bAutoComplete;
-    bDetectiveAuto  = rCpy.bDetectiveAuto;
-    nTrackContentColor = rCpy.nTrackContentColor;
-    nTrackInsertColor  = rCpy.nTrackInsertColor;
-    nTrackDeleteColor  = rCpy.nTrackDeleteColor;
-    nTrackMoveColor    = rCpy.nTrackMoveColor;
-    eLinkMode       = rCpy.eLinkMode;
-    nDefaultObjectSizeWidth = rCpy.nDefaultObjectSizeWidth;
-    nDefaultObjectSizeHeight = rCpy.nDefaultObjectSizeHeight;
-    mbShowSharedDocumentWarning = rCpy.mbShowSharedDocumentWarning;
-    return *this;
+    eKeyBindingType     = ScOptionsUtil::KEY_DEFAULT;
 }
 
 //------------------------------------------------------------------------
@@ -289,6 +267,11 @@ void lcl_GetSortList( Any& rDest )
 #define SCMISCOPT_SHOWSHAREDDOCWARN 2
 #define SCMISCOPT_COUNT             3
 
+#define CFGPATH_COMPAT      "Office.Calc/Compatibility"
+
+#define SCCOMPATOPT_KEY_BINDING     0
+#define SCCOMPATOPT_COUNT           1
+
 
 Sequence<OUString> ScAppCfg::GetLayoutPropertyNames()
 {
@@ -389,6 +372,19 @@ Sequence<OUString> ScAppCfg::GetMiscPropertyNames()
     return aNames;
 }
 
+Sequence<OUString> ScAppCfg::GetCompatPropertyNames()
+{
+    static const char* aPropNames[] =
+    {
+        "KeyBindings/BaseGroup"         // SCCOMPATOPT_KEY_BINDING
+    };
+    Sequence<OUString> aNames(SCCOMPATOPT_COUNT);
+    OUString* pNames = aNames.getArray();
+    for (int i = 0; i < SCCOMPATOPT_COUNT; ++i)
+        pNames[i] = OUString::createFromAscii(aPropNames[i]);
+
+    return aNames;
+}
 
 ScAppCfg::ScAppCfg() :
     aLayoutItem( OUString(RTL_CONSTASCII_USTRINGPARAM( CFGPATH_LAYOUT )) ),
@@ -396,7 +392,8 @@ ScAppCfg::ScAppCfg() :
     aRevisionItem( OUString(RTL_CONSTASCII_USTRINGPARAM( CFGPATH_REVISION )) ),
     aContentItem( OUString(RTL_CONSTASCII_USTRINGPARAM( CFGPATH_CONTENT )) ),
     aSortListItem( OUString(RTL_CONSTASCII_USTRINGPARAM( CFGPATH_SORTLIST )) ),
-    aMiscItem( OUString(RTL_CONSTASCII_USTRINGPARAM( CFGPATH_MISC )) )
+    aMiscItem( OUString(RTL_CONSTASCII_USTRINGPARAM( CFGPATH_MISC )) ),
+    aCompatItem( OUString(RTL_CONSTASCII_USTRINGPARAM(CFGPATH_COMPAT )) )
 {
     sal_Int32 nIntVal = 0;
 
@@ -574,6 +571,28 @@ ScAppCfg::ScAppCfg() :
         }
     }
     aMiscItem.SetCommitLink( LINK( this, ScAppCfg, MiscCommitHdl ) );
+
+    aNames = GetCompatPropertyNames();
+    aValues = aCompatItem.GetProperties(aNames);
+    aCompatItem.EnableNotification(aNames);
+    pValues = aValues.getConstArray();
+    if (aValues.getLength() == aNames.getLength())
+    {
+        for (int nProp = 0; nProp < aNames.getLength(); ++nProp)
+        {
+            switch (nProp)
+            {
+                case SCCOMPATOPT_KEY_BINDING:
+                {
+                    nIntVal = 0; // 0 = 'Default'
+                    pValues[nProp] >>= nIntVal;
+                    SetKeyBindingType(static_cast<ScOptionsUtil::KeyBindingType>(nIntVal));
+                }
+                break;
+            }
+        }
+    }
+    aCompatItem.SetCommitLink( LINK(this, ScAppCfg, CompatCommitHdl) );
 }
 
 IMPL_LINK( ScAppCfg, LayoutCommitHdl, void *, EMPTYARG )
@@ -729,6 +748,25 @@ IMPL_LINK( ScAppCfg, MiscCommitHdl, void *, EMPTYARG )
     return 0;
 }
 
+IMPL_LINK( ScAppCfg, CompatCommitHdl, void *, EMPTYARG )
+{
+    Sequence<OUString> aNames = GetCompatPropertyNames();
+    Sequence<Any> aValues(aNames.getLength());
+    Any* pValues = aValues.getArray();
+
+    for (int nProp = 0; nProp < aNames.getLength(); ++nProp)
+    {
+        switch(nProp)
+        {
+            case SCCOMPATOPT_KEY_BINDING:
+                pValues[nProp] <<= static_cast<sal_Int32>(GetKeyBindingType());
+            break;
+        }
+    }
+    aCompatItem.PutProperties(aNames, aValues);
+    return 0;
+}
+
 void ScAppCfg::SetOptions( const ScAppOptions& rNew )
 {
     *(ScAppOptions*)this = rNew;
@@ -743,6 +781,7 @@ void ScAppCfg::OptionsChanged()
     aContentItem.SetModified();
     aSortListItem.SetModified();
     aMiscItem.SetModified();
+    aCompatItem.SetModified();
 }
 
 
diff --git a/sc/source/core/tool/docoptio.cxx b/sc/source/core/tool/docoptio.cxx
index 56b8871..b8fd587 100644
--- a/sc/source/core/tool/docoptio.cxx
+++ b/sc/source/core/tool/docoptio.cxx
@@ -91,7 +91,6 @@ ScDocOptions::ScDocOptions( const ScDocOptions& rCpy )
             nInitTabCount( rCpy.nInitTabCount ),
             aInitTabPrefix( rCpy.aInitTabPrefix ),
             nPrecStandardFormat( rCpy.nPrecStandardFormat ),
-            eKeyBindingType( rCpy.eKeyBindingType ),
             nDay( rCpy.nDay ),
             nMonth( rCpy.nMonth ),
             nYear( rCpy.nYear ),
@@ -129,7 +128,6 @@ void ScDocOptions::ResetDocOptions()
     aInitTabPrefix      = ScGlobal::GetRscString(STR_TABLE_DEF); // Default Prefix "Sheet"
     fIterEps            = 1.0E-3;
     nPrecStandardFormat = SvNumberFormatter::UNLIMITED_PRECISION;
-    eKeyBindingType     = ScOptionsUtil::KEY_DEFAULT;
     nDay                = 30;
     nMonth              = 12;
     nYear               = 1899;
@@ -287,10 +285,6 @@ SfxPoolItem* ScTpCalcItem::Clone( SfxItemPool * ) const
 #define SCDOCLAYOUTOPT_TABSTOP      0
 #define SCDOCLAYOUTOPT_COUNT        1
 
-#define CFGPATH_COMPAT      "Office.Calc/Compatibility"
-#define SCCOMPATOPT_KEY_BINDING     0
-#define SCCOMPATOPT_COUNT           1
-
 #define CFGPATH_DEFAULTS    "Office.Calc/Defaults"
 #define SCDEFAULTSOPT_TAB_COUNT     0
 #define SCDEFAULTSOPT_TAB_PREFIX    1
@@ -358,20 +352,6 @@ Sequence<OUString> ScDocCfg::GetLayoutPropertyNames()
     return aNames;
 }
 
-Sequence<OUString> ScDocCfg::GetCompatPropertyNames()
-{
-    static const char* aPropNames[] =
-    {
-        "KeyBindings/BaseGroup"             // SCCOMPATOPT_KEY_BINDING
-    };
-    Sequence<OUString> aNames(SCCOMPATOPT_COUNT);
-    OUString* pNames = aNames.getArray();
-    for (int i = 0; i < SCCOMPATOPT_COUNT; ++i)
-        pNames[i] = OUString::createFromAscii(aPropNames[i]);
-
-    return aNames;
-}
-
 Sequence<OUString> ScDocCfg::GetDefaultsPropertyNames()
 {
     static const char* aPropNames[] =
@@ -392,7 +372,6 @@ ScDocCfg::ScDocCfg() :
     aCalcItem( OUString(RTL_CONSTASCII_USTRINGPARAM( CFGPATH_CALC )) ),
     aFormulaItem(OUString(RTL_CONSTASCII_USTRINGPARAM(CFGPATH_FORMULA))),
     aLayoutItem(OUString(RTL_CONSTASCII_USTRINGPARAM(CFGPATH_DOCLAYOUT))),
-    aCompatItem(OUString(RTL_CONSTASCII_USTRINGPARAM(CFGPATH_COMPAT))),
     aDefaultsItem(OUString(RTL_CONSTASCII_USTRINGPARAM(CFGPATH_DEFAULTS)))
 {
     sal_Int32 nIntVal = 0;
@@ -562,28 +541,6 @@ ScDocCfg::ScDocCfg() :
     }
     aLayoutItem.SetCommitLink( LINK( this, ScDocCfg, LayoutCommitHdl ) );
 
-    aNames = GetCompatPropertyNames();
-    aValues = aCompatItem.GetProperties(aNames);
-    aCompatItem.EnableNotification(aNames);
-    pValues = aValues.getConstArray();
-    if (aValues.getLength() == aNames.getLength())
-    {
-        for (int nProp = 0; nProp < aNames.getLength(); ++nProp)
-        {
-            switch (nProp)
-            {
-                case SCCOMPATOPT_KEY_BINDING:
-                {
-                    nIntVal = 0; // 0 = 'Default'
-                    pValues[nProp] >>= nIntVal;
-                    SetKeyBindingType(static_cast<ScOptionsUtil::KeyBindingType>(nIntVal));
-                }
-                break;
-            }
-        }
-    }
-    aCompatItem.SetCommitLink( LINK(this, ScDocCfg, CompatCommitHdl) );
-
     aNames = GetDefaultsPropertyNames();
     aValues = aDefaultsItem.GetProperties(aNames);
     aDefaultsItem.EnableNotification(aNames);
@@ -734,25 +691,6 @@ IMPL_LINK( ScDocCfg, LayoutCommitHdl, void *, EMPTYARG )
     return 0;
 }
 
-IMPL_LINK( ScDocCfg, CompatCommitHdl, void *, EMPTYARG )
-{
-    Sequence<OUString> aNames = GetCompatPropertyNames();
-    Sequence<Any> aValues(aNames.getLength());
-    Any* pValues = aValues.getArray();
-
-    for (int nProp = 0; nProp < aNames.getLength(); ++nProp)
-    {
-        switch(nProp)
-        {
-            case SCCOMPATOPT_KEY_BINDING:
-                pValues[nProp] <<= static_cast<sal_Int32>(GetKeyBindingType());
-            break;
-        }
-    }
-    aCompatItem.PutProperties(aNames, aValues);
-    return 0;
-}
-
 IMPL_LINK( ScDocCfg, DefaultsCommitHdl, void *, EMPTYARG )
 {
     Sequence<OUString> aNames = GetDefaultsPropertyNames();
@@ -782,7 +720,6 @@ void ScDocCfg::SetOptions( const ScDocOptions& rNew )
     aCalcItem.SetModified();
     aFormulaItem.SetModified();
     aLayoutItem.SetModified();
-    aCompatItem.SetModified();
     aDefaultsItem.SetModified();
 }
 
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index 47ef6b9..a2f2207 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -1092,10 +1092,6 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet )
         if ( pDoc )
         {
             const ScDocOptions& rOldOpt = pDoc->GetDocOptions();
-            ScOptionsUtil::KeyBindingType eKeyOld = rOldOpt.GetKeyBindingType();
-            ScOptionsUtil::KeyBindingType eKeyNew = rNewOpt.GetKeyBindingType();
-            if (eKeyOld != eKeyNew)
-                pDocSh->ResetKeyBindings(eKeyNew);
 
             bRepaint = ( bRepaint || ( rOldOpt != rNewOpt )   );
             bCalcAll =   bRepaint &&
diff --git a/sc/source/ui/inc/tpcompatibility.hxx b/sc/source/ui/inc/tpcompatibility.hxx
index 91f7254..911d56e 100644
--- a/sc/source/ui/inc/tpcompatibility.hxx
+++ b/sc/source/ui/inc/tpcompatibility.hxx
@@ -35,7 +35,7 @@
 
 #include <boost/shared_ptr.hpp>
 
-class ScDocOptions;
+class ScAppOptions;
 
 class ScTpCompatOptions : public SfxTabPage
 {
@@ -57,8 +57,7 @@ private:
     FixedText maFtKeyBindings;
     ListBox   maLbKeyBindings;
 
-    ::boost::shared_ptr<ScDocOptions> mpOldOptions;
-    ::boost::shared_ptr<ScDocOptions> mpNewOptions;
+    ::boost::shared_ptr<ScAppOptions> mpOptions;
 };
 
 #endif
diff --git a/sc/source/ui/optdlg/tpcompatibility.cxx b/sc/source/ui/optdlg/tpcompatibility.cxx
index fae9106..b0a44be 100644
--- a/sc/source/ui/optdlg/tpcompatibility.cxx
+++ b/sc/source/ui/optdlg/tpcompatibility.cxx
@@ -29,10 +29,11 @@
 
 #undef SC_DLLIMPLEMENTATION
 
+#include <scmod.hxx>
 #include "tpcompatibility.hxx"
 #include "optdlg.hrc"
 #include "scresid.hxx"
-#include "docoptio.hxx"
+#include "appoptio.hxx"
 
 ScTpCompatOptions::ScTpCompatOptions(Window *pParent, const SfxItemSet &rCoreAttrs) :
     SfxTabPage(pParent, ScResId(RID_SCPAGE_COMPATIBILITY), rCoreAttrs),
@@ -42,10 +43,7 @@ ScTpCompatOptions::ScTpCompatOptions(Window *pParent, const SfxItemSet &rCoreAtt
 {
     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()));
+    mpOptions.reset( new ScAppOptions( SC_MOD()->GetAppOptions() ) );
 }
 
 ScTpCompatOptions::~ScTpCompatOptions()
@@ -71,20 +69,15 @@ sal_Bool ScTpCompatOptions::FillItemSet(SfxItemSet &rCoreAttrs)
         default:
             ;
     }
-    mpNewOptions->SetKeyBindingType(eKeyB);
+    mpOptions->SetKeyBindingType(eKeyB);
+    SC_MOD()->SetAppOptions(*mpOptions);
 
-    if (*mpNewOptions != *mpOldOptions)
-    {
-        rCoreAttrs.Put(ScTpCalcItem(GetWhich(SID_SCDOCOPTIONS), *mpNewOptions));
-        return true;
-    }
-    else
-        return false;
+    return true;
 }
 
 void ScTpCompatOptions::Reset(const SfxItemSet &/*rCoreAttrs*/)
 {
-    ScOptionsUtil::KeyBindingType eKeyB = mpOldOptions->GetKeyBindingType();
+    ScOptionsUtil::KeyBindingType eKeyB = mpOptions->GetKeyBindingType();
     switch (eKeyB)
     {
         case ScOptionsUtil::KEY_DEFAULT:
-- 
1.7.3.4

_______________________________________________
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice

Reply via email to