diff options
Diffstat (limited to 'sc/source')
-rw-r--r-- | sc/source/core/tool/docoptio.cxx | 71 | ||||
-rw-r--r-- | sc/source/ui/inc/tpcompatibility.hxx | 6 | ||||
-rw-r--r-- | sc/source/ui/optdlg/tpcompatibility.cxx | 40 |
3 files changed, 115 insertions, 2 deletions
diff --git a/sc/source/core/tool/docoptio.cxx b/sc/source/core/tool/docoptio.cxx index 23e193c556ad..5c50cc02025e 100644 --- a/sc/source/core/tool/docoptio.cxx +++ b/sc/source/core/tool/docoptio.cxx @@ -91,6 +91,7 @@ ScDocOptions::ScDocOptions( const ScDocOptions& rCpy ) : fIterEps( rCpy.fIterEps ), nIterCount( rCpy.nIterCount ), nPrecStandardFormat( rCpy.nPrecStandardFormat ), + eKeyBindingType( rCpy.eKeyBindingType ), nDay( rCpy.nDay ), nMonth( rCpy.nMonth ), nYear( rCpy.nYear ), @@ -126,6 +127,7 @@ void ScDocOptions::ResetDocOptions() nIterCount = 100; fIterEps = 1.0E-3; nPrecStandardFormat = SvNumberFormatter::UNLIMITED_PRECISION; + eKeyBindingType = KEY_DEFAULT; nDay = 30; nMonth = 12; nYear = 1899; @@ -283,6 +285,9 @@ SfxPoolItem* __EXPORT 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 Sequence<OUString> ScDocCfg::GetCalcPropertyNames() { @@ -345,10 +350,25 @@ 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; +} + ScDocCfg::ScDocCfg() : aCalcItem( OUString::createFromAscii( CFGPATH_CALC ) ), aFormulaItem(OUString::createFromAscii(CFGPATH_FORMULA)), - aLayoutItem( OUString::createFromAscii( CFGPATH_DOCLAYOUT ) ) + aLayoutItem(OUString::createFromAscii(CFGPATH_DOCLAYOUT)), + aCompatItem(OUString::createFromAscii(CFGPATH_COMPAT)) { sal_Int32 nIntVal = 0; double fDoubleVal = 0; @@ -513,6 +533,33 @@ 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: + { + fprintf(stdout, "ScDocCfg::ScDocCfg: SCCOMPATOPT_KEY_BINDING\n"); + nIntVal = 0; + if (pValues[nProp] >>= nIntVal) + fprintf(stdout, "ScDocCfg::ScDocCfg: key binding = %ld\n", nIntVal); + else + fprintf(stdout, "ScDocCfg::ScDocCfg: key binding failed to load\n"); + + SetKeyBindingType(static_cast<ScDocOptions::KeyBindingType>(nIntVal)); + } + break; + } + } + } + aCompatItem.SetCommitLink( LINK(this, ScDocCfg, CompatCommitHdl) ); } IMPL_LINK( ScDocCfg, CalcCommitHdl, void *, EMPTYARG ) @@ -637,6 +684,27 @@ 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: + { + fprintf(stdout, "IMPL_LINK: pushing key binding type (%d)\n", GetKeyBindingType()); + pValues[nProp] <<= static_cast<sal_Int32>(GetKeyBindingType()); + } + break; + } + } + aCompatItem.PutProperties(aNames, aValues); + return 0; +} void ScDocCfg::SetOptions( const ScDocOptions& rNew ) { @@ -645,6 +713,7 @@ void ScDocCfg::SetOptions( const ScDocOptions& rNew ) aCalcItem.SetModified(); aFormulaItem.SetModified(); aLayoutItem.SetModified(); + aCompatItem.SetModified(); } diff --git a/sc/source/ui/inc/tpcompatibility.hxx b/sc/source/ui/inc/tpcompatibility.hxx index 75942c7cdd46..423ac2e4d22d 100644 --- a/sc/source/ui/inc/tpcompatibility.hxx +++ b/sc/source/ui/inc/tpcompatibility.hxx @@ -32,6 +32,10 @@ #include <vcl/fixed.hxx> #include <vcl/lstbox.hxx> +#include <boost/shared_ptr.hpp> + +class ScDocOptions; + class ScTpCompatOptions : public SfxTabPage { public: @@ -50,6 +54,8 @@ private: 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 7820dc4ad53d..c9853f3c7c4e 100644 --- a/sc/source/ui/optdlg/tpcompatibility.cxx +++ b/sc/source/ui/optdlg/tpcompatibility.cxx @@ -33,6 +33,7 @@ #include "tpcompatibility.hxx" #include "optdlg.hrc" #include "scresid.hxx" +#include "docoptio.hxx" ScTpCompatOptions::ScTpCompatOptions(Window *pParent, const SfxItemSet &rCoreAttrs) : SfxTabPage(pParent, ScResId(RID_SCPAGE_COMPATIBILITY), rCoreAttrs), @@ -41,6 +42,11 @@ 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() @@ -54,11 +60,43 @@ SfxTabPage* ScTpCompatOptions::Create(Window *pParent, const SfxItemSet &rCoreAt BOOL ScTpCompatOptions::FillItemSet(SfxItemSet &rCoreAttrs) { - return false; + ScDocOptions::KeyBindingType eKeyB = ScDocOptions::KEY_DEFAULT; + switch (maLbKeyBindings.GetSelectEntryPos()) + { + case 0: + eKeyB = ScDocOptions::KEY_DEFAULT; + break; + case 1: + eKeyB = ScDocOptions::KEY_OOO_LEGACY; + break; + default: + ; + } + mpNewOptions->SetKeyBindingType(eKeyB); + + if (*mpNewOptions != *mpOldOptions) + { + rCoreAttrs.Put(ScTpCalcItem(GetWhich(SID_SCDOCOPTIONS), *mpNewOptions)); + return true; + } + else + return false; } void ScTpCompatOptions::Reset(const SfxItemSet &rCoreAttrs) { + ScDocOptions::KeyBindingType eKeyB = mpOldOptions->GetKeyBindingType(); + switch (eKeyB) + { + case ScDocOptions::KEY_DEFAULT: + maLbKeyBindings.SelectEntryPos(0); + break; + case ScDocOptions::KEY_OOO_LEGACY: + maLbKeyBindings.SelectEntryPos(1); + break; + default: + ; + } } int ScTpCompatOptions::DeactivatePage(SfxItemSet* /*pSet*/) |