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

Kohei Yoshida kohei at kemper.freedesktop.org
Mon Feb 6 10:44:29 PST 2012


 sc/inc/appoptio.hxx                     |    8 +++
 sc/inc/docoptio.hxx                     |    9 ----
 sc/inc/sc.hrc                           |    2 
 sc/source/core/tool/appoptio.cxx        |   68 ++++++++++++++++++++++++++++++--
 sc/source/core/tool/docoptio.cxx        |   63 -----------------------------
 sc/source/ui/app/scmod.cxx              |   25 +++++++++--
 sc/source/ui/inc/tpcompatibility.hxx    |    5 --
 sc/source/ui/optdlg/tpcompatibility.cxx |   65 +++++++++++++-----------------
 8 files changed, 125 insertions(+), 120 deletions(-)

New commits:
commit 28ff7a37e66c8746a0b176b4ea25e20c1cd135c5
Author: Albert Thuswaldner <albert.thuswaldner at gmail.com>
Date:   Fri Feb 3 11:15:31 2012 +0100

    Moved ScTpCompat from docoptions to appoptions

diff --git a/sc/inc/appoptio.hxx b/sc/inc/appoptio.hxx
index 84fbc86..fac4061 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,6 +88,8 @@ public:
 
     void        SetShowSharedDocumentWarning( sal_Bool bNew )   { mbShowSharedDocumentWarning = bNew; }
     sal_Bool        GetShowSharedDocumentWarning() const        { return mbShowSharedDocumentWarning; }
+    ScOptionsUtil::KeyBindingType GetKeyBindingType() const { return meKeyBindingType; }
+    void        SetKeyBindingType( ScOptionsUtil::KeyBindingType e ) { meKeyBindingType = e; }
 
 
     const ScAppOptions& operator=   ( const ScAppOptions& rOpt );
@@ -110,6 +113,7 @@ private:
     sal_Int32       nDefaultObjectSizeWidth;
     sal_Int32       nDefaultObjectSizeHeight;
     sal_Bool        mbShowSharedDocumentWarning;
+    ScOptionsUtil::KeyBindingType meKeyBindingType;
 };
 
 
@@ -128,6 +132,7 @@ class ScAppCfg : public ScAppOptions
     ScLinkConfigItem    aContentItem;
     ScLinkConfigItem    aSortListItem;
     ScLinkConfigItem    aMiscItem;
+    ScLinkConfigItem    aCompatItem;
 
     DECL_LINK( LayoutCommitHdl, void* );
     DECL_LINK( InputCommitHdl, void* );
@@ -135,6 +140,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 +148,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 +157,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/inc/sc.hrc b/sc/inc/sc.hrc
index 6ca8544..27cb28b 100644
--- a/sc/inc/sc.hrc
+++ b/sc/inc/sc.hrc
@@ -223,6 +223,8 @@
 // "Zoom / Synchronize sheets" in options dialog
 #define SID_SC_OPT_SYNCZOOM             (SC_VIEW_START + 98)
 
+#define SID_SC_OPT_KEY_BINDING_COMPAT   (SC_VIEW_START + 99)
+
 // NOTE: last valid ID is (SC_VIEW_START + 99)
 
 // messages
diff --git a/sc/source/core/tool/appoptio.cxx b/sc/source/core/tool/appoptio.cxx
index 66db4f8..d53328b 100644
--- a/sc/source/core/tool/appoptio.cxx
+++ b/sc/source/core/tool/appoptio.cxx
@@ -116,9 +116,9 @@ void ScAppOptions::SetDefaults()
     nDefaultObjectSizeHeight = 5000;
 
     mbShowSharedDocumentWarning = true;
-}
 
-//------------------------------------------------------------------------
+    meKeyBindingType     = ScOptionsUtil::KEY_DEFAULT;
+}
 
 const ScAppOptions& ScAppOptions::operator=( const ScAppOptions& rCpy )
 {
@@ -139,6 +139,7 @@ const ScAppOptions& ScAppOptions::operator=( const ScAppOptions& rCpy )
     nDefaultObjectSizeWidth = rCpy.nDefaultObjectSizeWidth;
     nDefaultObjectSizeHeight = rCpy.nDefaultObjectSizeHeight;
     mbShowSharedDocumentWarning = rCpy.mbShowSharedDocumentWarning;
+    meKeyBindingType  = rCpy.meKeyBindingType;
     return *this;
 }
 
@@ -289,6 +290,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 +395,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 +415,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 +594,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 +771,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 +804,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 a9da20e..a011370 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -1015,6 +1015,19 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet )
         bSaveAppOptions = sal_True;
     }
 
+    if ( IS_AVAILABLE(SID_SC_OPT_KEY_BINDING_COMPAT,pItem) )
+    {
+        sal_uInt16 nVal = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
+        ScOptionsUtil::KeyBindingType eOld = pAppCfg->GetKeyBindingType();
+        ScOptionsUtil::KeyBindingType eNew = static_cast<ScOptionsUtil::KeyBindingType>(nVal);
+        if (eOld != eNew)
+        {
+            pAppCfg->SetKeyBindingType(eNew);
+            bSaveAppOptions = true;
+            pDocSh->ResetKeyBindings(eNew);
+        }
+    }
+
     //============================================
     // ViewOptions
     //============================================
@@ -1092,10 +1105,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 &&
@@ -1917,6 +1926,8 @@ SfxItemSet*  ScModule::CreateItemSet( sal_uInt16 nId )
                             //
                             SID_ATTR_METRIC,        SID_ATTR_METRIC,
                             SID_ATTR_DEFTABSTOP,    SID_ATTR_DEFTABSTOP,
+                            // TP_COMPATIBILITY
+                            SID_SC_OPT_KEY_BINDING_COMPAT, SID_SC_OPT_KEY_BINDING_COMPAT,
                             0 );
 
         ScDocShell*     pDocSh = PTR_CAST(ScDocShell,
@@ -1980,6 +1991,12 @@ SfxItemSet*  ScModule::CreateItemSet( sal_uInt16 nId )
         // TP_USERLISTS
         if ( pUL )
             aULItem.SetUserList( *pUL );
+
+        // TP_COMPATIBILITY
+        pRet->Put(
+            SfxUInt16Item(
+                SID_SC_OPT_KEY_BINDING_COMPAT, GetAppOptions().GetKeyBindingType()));
+
         pRet->Put( aULItem );
 
     }
diff --git a/sc/source/ui/inc/tpcompatibility.hxx b/sc/source/ui/inc/tpcompatibility.hxx
index 91f7254..fe57a2a 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
 {
@@ -56,9 +56,6 @@ private:
     FixedLine maFlKeyBindings;
     FixedText maFtKeyBindings;
     ListBox   maLbKeyBindings;
-
-    ::boost::shared_ptr<ScDocOptions> mpOldOptions;
-    ::boost::shared_ptr<ScDocOptions> mpNewOptions;
 };
 
 #endif
diff --git a/sc/source/ui/optdlg/tpcompatibility.cxx b/sc/source/ui/optdlg/tpcompatibility.cxx
index fae9106..3748fb1 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),
@@ -41,11 +42,6 @@ ScTpCompatOptions::ScTpCompatOptions(Window *pParent, const SfxItemSet &rCoreAtt
     maLbKeyBindings(this, ScResId(LB_KEY_BINDINGS))
 {
     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()));
 }
 
 ScTpCompatOptions::~ScTpCompatOptions()
@@ -59,43 +55,40 @@ SfxTabPage* ScTpCompatOptions::Create(Window *pParent, const SfxItemSet &rCoreAt
 
 sal_Bool ScTpCompatOptions::FillItemSet(SfxItemSet &rCoreAttrs)
 {
-    ScOptionsUtil::KeyBindingType eKeyB = ScOptionsUtil::KEY_DEFAULT;
-    switch (maLbKeyBindings.GetSelectEntryPos())
-    {
-        case 0:
-            eKeyB = ScOptionsUtil::KEY_DEFAULT;
-        break;
-        case 1:
-            eKeyB = ScOptionsUtil::KEY_OOO_LEGACY;
-        break;
-        default:
-            ;
-    }
-    mpNewOptions->SetKeyBindingType(eKeyB);
-
-    if (*mpNewOptions != *mpOldOptions)
+    bool bRet = false;
+    if (maLbKeyBindings.GetSavedValue() != maLbKeyBindings.GetSelectEntryPos())
     {
-        rCoreAttrs.Put(ScTpCalcItem(GetWhich(SID_SCDOCOPTIONS), *mpNewOptions));
-        return true;
+        rCoreAttrs.Put(
+            SfxUInt16Item(
+                SID_SC_OPT_KEY_BINDING_COMPAT, maLbKeyBindings.GetSelectEntryPos()));
+        bRet = true;
     }
-    else
-        return false;
+    return bRet;
 }
 
-void ScTpCompatOptions::Reset(const SfxItemSet &/*rCoreAttrs*/)
+void ScTpCompatOptions::Reset(const SfxItemSet &rCoreAttrs)
 {
-    ScOptionsUtil::KeyBindingType eKeyB = mpOldOptions->GetKeyBindingType();
-    switch (eKeyB)
+    const SfxPoolItem* pItem;
+    if (SFX_ITEM_SET == rCoreAttrs.GetItemState(SID_SC_OPT_KEY_BINDING_COMPAT, false, &pItem))
     {
-        case ScOptionsUtil::KEY_DEFAULT:
-            maLbKeyBindings.SelectEntryPos(0);
-        break;
-        case ScOptionsUtil::KEY_OOO_LEGACY:
-            maLbKeyBindings.SelectEntryPos(1);
-        break;
-        default:
-            ;
+        const SfxUInt16Item* p16Item = static_cast<const SfxUInt16Item*>(pItem);
+        ScOptionsUtil::KeyBindingType eKeyB =
+            static_cast<ScOptionsUtil::KeyBindingType>(p16Item->GetValue());
+
+        switch (eKeyB)
+        {
+            case ScOptionsUtil::KEY_DEFAULT:
+                maLbKeyBindings.SelectEntryPos(0);
+            break;
+            case ScOptionsUtil::KEY_OOO_LEGACY:
+                maLbKeyBindings.SelectEntryPos(1);
+            break;
+            default:
+                ;
+        }
     }
+
+    maLbKeyBindings.SaveValue();
 }
 
 int ScTpCompatOptions::DeactivatePage(SfxItemSet* /*pSet*/)


More information about the Libreoffice-commits mailing list