[Libreoffice-commits] .: sc/inc sc/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Mon Feb 27 11:38:49 PST 2012
sc/inc/appoptio.hxx | 1
sc/source/core/tool/appoptio.cxx | 22 ++++--
sc/source/ui/app/scmod.cxx | 24 +++++-
sc/source/ui/inc/tpformula.hxx | 2
sc/source/ui/optdlg/tpformula.cxx | 133 ++++++++++++++++++++------------------
5 files changed, 105 insertions(+), 77 deletions(-)
New commits:
commit 7eb1c1e31dac3b8377307192cae9cdde0ebe18bb
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Mon Feb 27 14:37:20 2012 -0500
Fixed up several issues with the new formula options handler.
diff --git a/sc/inc/appoptio.hxx b/sc/inc/appoptio.hxx
index 65b3676..7c69f88 100644
--- a/sc/inc/appoptio.hxx
+++ b/sc/inc/appoptio.hxx
@@ -108,6 +108,7 @@ public:
void ResetFormulaSeparators();
+ static void GetDefaultFormulaSeparators(rtl::OUString& rSepArg, rtl::OUString& rSepArrayCol, rtl::OUString& rSepArrayRow);
static const LocaleDataWrapper& GetLocaleDataWrapper();
const ScAppOptions& operator= ( const ScAppOptions& rOpt );
diff --git a/sc/source/core/tool/appoptio.cxx b/sc/source/core/tool/appoptio.cxx
index 3df026e..a931572 100644
--- a/sc/source/core/tool/appoptio.cxx
+++ b/sc/source/core/tool/appoptio.cxx
@@ -130,10 +130,16 @@ void ScAppOptions::SetDefaults()
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.
- aFormulaSepArg = OUString(RTL_CONSTASCII_USTRINGPARAM(";"));
- aFormulaSepArrayCol = OUString(RTL_CONSTASCII_USTRINGPARAM(";"));
- aFormulaSepArrayRow = OUString(RTL_CONSTASCII_USTRINGPARAM("|"));
+ 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;
@@ -166,18 +172,18 @@ void ScAppOptions::ResetFormulaSeparators()
// by default, the parameter separator equals the locale-specific
// list separator.
- aFormulaSepArg = OUString(cListSep);
+ 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.
- aFormulaSepArg = OUString(RTL_CONSTASCII_USTRINGPARAM(";"));
+ rSepArg = OUString(RTL_CONSTASCII_USTRINGPARAM(";"));
- aFormulaSepArrayCol = OUString(RTL_CONSTASCII_USTRINGPARAM(","));
+ rSepArrayCol = OUString(RTL_CONSTASCII_USTRINGPARAM(","));
if (cDecSep == sal_Unicode(','))
- aFormulaSepArrayCol = OUString(RTL_CONSTASCII_USTRINGPARAM("."));
- aFormulaSepArrayRow = OUString(RTL_CONSTASCII_USTRINGPARAM(";"));
+ rSepArrayCol = OUString(RTL_CONSTASCII_USTRINGPARAM("."));
+ rSepArrayRow = OUString(RTL_CONSTASCII_USTRINGPARAM(";"));
}
const LocaleDataWrapper& ScAppOptions::GetLocaleDataWrapper()
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index f496211..3752b7c 100644
--- a/sc/source/ui/app/scmod.cxx
+++ b/sc/source/ui/app/scmod.cxx
@@ -1043,7 +1043,7 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet )
{
sal_uInt16 nVal = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
::formula::FormulaGrammar::Grammar eOld = pAppCfg->GetFormulaSyntax();
- ::formula::FormulaGrammar::Grammar eNew;
+ ::formula::FormulaGrammar::Grammar eNew = ::formula::FormulaGrammar::GRAM_NATIVE;
switch (nVal)
{
@@ -1056,6 +1056,8 @@ void ScModule::ModifyOptions( const SfxItemSet& rOptSet )
case 2:
eNew = ::formula::FormulaGrammar::GRAM_NATIVE_XL_R1C1;
break;
+ default:
+ ;
}
if (eOld != eNew)
@@ -2071,8 +2073,23 @@ SfxItemSet* ScModule::CreateItemSet( sal_uInt16 nId )
// TP_FORMULA
pRet->Put( SfxBoolItem( SID_SC_OPT_FORMULA_ENGLISH_FUNCNAME,
rAppOpt.GetUseEnglishFuncName() ) );
- pRet->Put( SfxUInt16Item( SID_SC_OPT_FORMULA_GRAMMAR,
- rAppOpt.GetFormulaSyntax() ) );
+
+ 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,
@@ -2080,7 +2097,6 @@ SfxItemSet* ScModule::CreateItemSet( sal_uInt16 nId )
pRet->Put( SfxStringItem( SID_SC_OPT_FORMULA_SEP_ARRAY_ROW,
rAppOpt.GetFormulaSepArrayRow() ) );
-//
pRet->Put( aULItem );
}
diff --git a/sc/source/ui/inc/tpformula.hxx b/sc/source/ui/inc/tpformula.hxx
index 83abbb9..033f61d 100644
--- a/sc/source/ui/inc/tpformula.hxx
+++ b/sc/source/ui/inc/tpformula.hxx
@@ -84,8 +84,6 @@ private:
Edit maEdSepArrayRow;
PushButton maBtnSepReset;
- ::boost::shared_ptr<ScAppOptions> mpOptions;
-
/** Stores old separator value of currently focused separator edit box.
This value is used to revert undesired value change. */
::rtl::OUString maOldSepValue;
diff --git a/sc/source/ui/optdlg/tpformula.cxx b/sc/source/ui/optdlg/tpformula.cxx
index 241cac0..ccda938 100644
--- a/sc/source/ui/optdlg/tpformula.cxx
+++ b/sc/source/ui/optdlg/tpformula.cxx
@@ -73,8 +73,6 @@ ScTpFormulaOptions::ScTpFormulaOptions(Window* pParent, const SfxItemSet& rCoreA
{
FreeResource();
- mpOptions.reset( new ScAppOptions( SC_MOD()->GetAppOptions() ) );
-
Link aLink = LINK( this, ScTpFormulaOptions, ButtonHdl );
maBtnSepReset.SetClickHdl(aLink);
@@ -89,8 +87,8 @@ ScTpFormulaOptions::ScTpFormulaOptions(Window* pParent, const SfxItemSet& rCoreA
maEdSepArrayRow.SetGetFocusHdl(aLink);
// Get the decimal separator for current locale.
- String aSep = mpOptions->GetLocaleDataWrapper().getNumDecimalSep();
- mnDecSep = aSep.Len() ? aSep.GetChar(0) : sal_Unicode('.');
+ rtl::OUString aSep = SC_MOD()->GetAppOptions().GetLocaleDataWrapper().getNumDecimalSep();
+ mnDecSep = aSep.isEmpty() ? sal_Unicode('.') : aSep[0];
}
ScTpFormulaOptions::~ScTpFormulaOptions()
@@ -99,10 +97,11 @@ ScTpFormulaOptions::~ScTpFormulaOptions()
void ScTpFormulaOptions::ResetSeparators()
{
- ScAppOptions rAppOpt=SC_MOD()->GetAppOptions();
- maEdSepFuncArg.SetText(rAppOpt.GetFormulaSepArg());
- maEdSepArrayCol.SetText(rAppOpt.GetFormulaSepArrayCol());
- maEdSepArrayRow.SetText(rAppOpt.GetFormulaSepArrayRow());
+ rtl::OUString aFuncArg, aArrayCol, aArrayRow;
+ ScAppOptions::GetDefaultFormulaSeparators(aFuncArg, aArrayCol, aArrayRow);
+ maEdSepFuncArg.SetText(aFuncArg);
+ maEdSepArrayCol.SetText(aArrayCol);
+ maEdSepArrayRow.SetText(aArrayRow);
}
void ScTpFormulaOptions::OnFocusSeparatorInput(Edit* pEdit)
@@ -209,88 +208,96 @@ SfxTabPage* ScTpFormulaOptions::Create(Window* pParent, const SfxItemSet& rCoreS
sal_Bool ScTpFormulaOptions::FillItemSet(SfxItemSet& rCoreSet)
{
- sal_Bool bRet = false;
- sal_Bool bEnglishFuncName = maCbEnglishFuncName.IsChecked();
- ::formula::FormulaGrammar::Grammar eGram = ::formula::FormulaGrammar::GRAM_DEFAULT;
- OUString aSep = maEdSepFuncArg.GetText();
- OUString aSepArrayCol = maEdSepArrayCol.GetText();
- OUString aSepArrayRow = maEdSepArrayRow.GetText();
-
- switch (maLbFormulaSyntax.GetSelectEntryPos())
+ bool bRet = false;
+ if (maLbFormulaSyntax.GetSavedValue() != maLbFormulaSyntax.GetSelectEntryPos())
{
- 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;
- }
-
- if ( bEnglishFuncName != mpOptions->GetUseEnglishFuncName() )
- {
- rCoreSet.Put( SfxBoolItem( SID_SC_OPT_FORMULA_ENGLISH_FUNCNAME, bEnglishFuncName ) );
+ rCoreSet.Put(
+ SfxUInt16Item(SID_SC_OPT_FORMULA_GRAMMAR, maLbFormulaSyntax.GetSelectEntryPos()));
bRet = true;
}
- if ( eGram != mpOptions->GetFormulaSyntax() )
+
+ if (maCbEnglishFuncName.GetSavedValue() != maCbEnglishFuncName.IsChecked())
{
- rCoreSet.Put( SfxUInt16Item( SID_SC_OPT_FORMULA_GRAMMAR, eGram ) );
+ rCoreSet.Put(
+ SfxBoolItem(SID_SC_OPT_FORMULA_ENGLISH_FUNCNAME, maCbEnglishFuncName.IsChecked()));
bRet = true;
}
- if ( aSep != mpOptions->GetFormulaSepArg() )
+
+ if (maEdSepFuncArg.GetSavedValue() != maEdSepFuncArg.GetText())
{
- rCoreSet.Put( SfxStringItem( SID_SC_OPT_FORMULA_SEP_ARG, aSep ) );
+ rCoreSet.Put(
+ SfxStringItem(SID_SC_OPT_FORMULA_SEP_ARG, maEdSepFuncArg.GetText()));
bRet = true;
}
- if ( aSepArrayCol != mpOptions->GetFormulaSepArrayCol() )
+
+ if (maEdSepArrayCol.GetSavedValue() != maEdSepArrayCol.GetText())
{
- rCoreSet.Put( SfxStringItem( SID_SC_OPT_FORMULA_SEP_ARRAY_ROW, aSepArrayCol ) );
+ rCoreSet.Put(
+ SfxStringItem(SID_SC_OPT_FORMULA_SEP_ARRAY_COL, maEdSepArrayCol.GetText()));
bRet = true;
}
- if ( aSepArrayRow != mpOptions->GetFormulaSepArrayRow() )
+
+ if (maEdSepArrayRow.GetSavedValue() != maEdSepArrayRow.GetText())
{
- rCoreSet.Put( SfxStringItem( SID_SC_OPT_FORMULA_SEP_ARRAY_COL, aSepArrayRow ) );
+ rCoreSet.Put(
+ SfxStringItem(SID_SC_OPT_FORMULA_SEP_ARRAY_ROW, maEdSepArrayRow.GetText()));
bRet = true;
}
return bRet;
}
-void ScTpFormulaOptions::Reset(const SfxItemSet& /*rCoreSet*/)
+void ScTpFormulaOptions::Reset(const SfxItemSet& rCoreSet)
{
- ::formula::FormulaGrammar::Grammar eGram = mpOptions->GetFormulaSyntax();
- switch (eGram)
+ const SfxPoolItem* pItem = NULL;
+
+ // formula grammar.
+ maLbFormulaSyntax.SelectEntryPos(0);
+ if (rCoreSet.HasItem(SID_SC_OPT_FORMULA_GRAMMAR, &pItem))
{
- 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);
+ sal_uInt16 nVal = static_cast<const SfxUInt16Item*>(pItem)->GetValue();
+ if (nVal <= 2)
+ maLbFormulaSyntax.SelectEntryPos(nVal);
}
+ maLbFormulaSyntax.SaveValue();
- maCbEnglishFuncName.Check(mpOptions->GetUseEnglishFuncName());
+ // 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.SaveValue();
- OUString aSep = mpOptions->GetFormulaSepArg();
- OUString aSepArrayRow = mpOptions->GetFormulaSepArrayRow();
- OUString aSepArrayCol = mpOptions->GetFormulaSepArrayCol();
+ ResetSeparators();
- if (aSep.getLength() == 1 && aSepArrayRow.getLength() == 1 && aSepArrayCol.getLength() == 1)
+ // argument separator.
+ if (rCoreSet.HasItem(SID_SC_OPT_FORMULA_SEP_ARG, &pItem))
{
- // Each separator must be one character long.
- maEdSepFuncArg.SetText(aSep);
- maEdSepArrayCol.SetText(aSepArrayCol);
- maEdSepArrayRow.SetText(aSepArrayRow);
+ rtl::OUString aVal = static_cast<const SfxStringItem*>(pItem)->GetValue();
+ if (aVal.getLength() == 1)
+ maEdSepFuncArg.SetText(aVal);
}
- else
- ResetSeparators();
+ 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();
+
+ // matrix row separator.
+ if (rCoreSet.HasItem(SID_SC_OPT_FORMULA_SEP_ARRAY_ROW, &pItem))
+ {
+ rtl::OUString aVal = static_cast<const SfxStringItem*>(pItem)->GetValue();
+ if (aVal.getLength() == 1)
+ maEdSepArrayRow.SetText(aVal);
+ }
+ maEdSepArrayRow.SaveValue();
}
int ScTpFormulaOptions::DeactivatePage(SfxItemSet* /*pSet*/)
More information about the Libreoffice-commits
mailing list