summaryrefslogtreecommitdiff
path: root/sc/source/ui
diff options
context:
space:
mode:
authorAlbert Thuswaldner <albert.thuswaldner@gmail.com>2012-04-10 00:09:40 +0200
committerKohei Yoshida <kohei.yoshida@gmail.com>2012-04-10 12:19:15 -0400
commitbf0629e09d176555aaa10f60061b206103cc0295 (patch)
tree68ef7efc0b3c6faf895b46f2debf0c6259539b66 /sc/source/ui
parente6d4795e52643a8e940f79c1ee6510cc14fdfb38 (diff)
Grouping ScFormulaOptions
Diffstat (limited to 'sc/source/ui')
-rw-r--r--sc/source/ui/app/scmod.cxx120
-rw-r--r--sc/source/ui/docshell/docsh3.cxx4
-rw-r--r--sc/source/ui/docshell/docsh6.cxx20
-rw-r--r--sc/source/ui/inc/docsh.hxx3
-rw-r--r--sc/source/ui/optdlg/tpformula.cxx153
5 files changed, 120 insertions, 180 deletions
diff --git a/sc/source/ui/app/scmod.cxx b/sc/source/ui/app/scmod.cxx
index dbddbe023429..4dec73a976c7 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 522e9d78a121..a07226bd288c 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 372415e01a85..f6831dd1ab2d 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 488c202de6cc..56f6c934b667 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 ccda938fa1ac..c029c81b5d55 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*/)