summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2012-05-29 23:25:06 -0400
committerKohei Yoshida <kohei.yoshida@gmail.com>2012-05-30 11:37:20 -0400
commitb52fc9ad0469f5a16496b2eb5a6b77e3028814ee (patch)
treec29783df3d78595a80e9f0ac3a42e6df66833124 /sc
parentbebc0e4286edefc20e31b554bccb867274e82a5c (diff)
Create a common struct for interpreter config options.
And use it both in the core interpreter and the configuration UI. Change-Id: Ia2a16fcb53025840d906864b564255cd3c53e8e9
Diffstat (limited to 'sc')
-rw-r--r--sc/Library_sc.mk1
-rw-r--r--sc/inc/calcconfig.hxx50
-rw-r--r--sc/source/core/inc/interpre.hxx13
-rw-r--r--sc/source/core/tool/calcconfig.cxx44
-rw-r--r--sc/source/core/tool/interpr1.cxx2
-rw-r--r--sc/source/core/tool/interpr4.cxx7
-rw-r--r--sc/source/ui/docshell/docsh6.cxx3
-rw-r--r--sc/source/ui/inc/tpformula.hxx5
-rw-r--r--sc/source/ui/optdlg/tpformula.cxx13
9 files changed, 118 insertions, 20 deletions
diff --git a/sc/Library_sc.mk b/sc/Library_sc.mk
index 20a5eafd72e1..72d9da3c945b 100644
--- a/sc/Library_sc.mk
+++ b/sc/Library_sc.mk
@@ -158,6 +158,7 @@ $(eval $(call gb_Library_add_exception_objects,sc,\
sc/source/core/tool/adiasync \
sc/source/core/tool/appoptio \
sc/source/core/tool/autoform \
+ sc/source/core/tool/calcconfig \
sc/source/core/tool/callform \
sc/source/core/tool/cellform \
sc/source/core/tool/cellkeytranslator \
diff --git a/sc/inc/calcconfig.hxx b/sc/inc/calcconfig.hxx
new file mode 100644
index 000000000000..4af6222778dd
--- /dev/null
+++ b/sc/inc/calcconfig.hxx
@@ -0,0 +1,50 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2012 Kohei Yoshida <kohei.yoshida@suse.com>
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#ifndef __SC_CALCCONFIG_HXX__
+#define __SC_CALCCONFIG_HXX__
+
+#include "scdllapi.h"
+#include "formula/grammar.hxx"
+
+/**
+ * Configuration options for formula interpreter.
+ */
+struct SC_DLLPUBLIC ScCalcConfig
+{
+ formula::FormulaGrammar::AddressConvention meIndirectRefSyntax;
+
+ ScCalcConfig();
+
+ bool operator== (const ScCalcConfig& r) const;
+ bool operator!= (const ScCalcConfig& r) const;
+};
+
+#endif
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/inc/interpre.hxx b/sc/source/core/inc/interpre.hxx
index 1833a6556373..c92ad0c95a0e 100644
--- a/sc/source/core/inc/interpre.hxx
+++ b/sc/source/core/inc/interpre.hxx
@@ -37,6 +37,7 @@
#include "document.hxx"
#include "scmatrix.hxx"
#include "externalrefmgr.hxx"
+#include "calcconfig.hxx"
#include <math.h>
#include <map>
@@ -98,14 +99,8 @@ public:
DECL_FIXEDMEMPOOL_NEWDEL( ScInterpreter )
- struct Config
- {
- formula::FormulaGrammar::AddressConvention meIndirectRefSyntax;
- Config();
- };
-
- static void SetGlobalConfig(const Config& rConfig);
- static const Config& GetGlobalConfig();
+ static void SetGlobalConfig(const ScCalcConfig& rConfig);
+ static const ScCalcConfig& GetGlobalConfig();
static void GlobalExit(); // aus ScGlobal::Clear() gerufen
@@ -130,7 +125,7 @@ public:
VolatileType GetVolatileType() const;
private:
- static Config maGlobalConfig;
+ static ScCalcConfig maGlobalConfig;
static ScTokenStack* pGlobalStack;
static bool bGlobalStackInUse;
diff --git a/sc/source/core/tool/calcconfig.cxx b/sc/source/core/tool/calcconfig.cxx
new file mode 100644
index 000000000000..e4efbca260df
--- /dev/null
+++ b/sc/source/core/tool/calcconfig.cxx
@@ -0,0 +1,44 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * Version: MPL 1.1 / GPLv3+ / LGPLv3+
+ *
+ * The contents of this file are subject to the Mozilla Public License Version
+ * 1.1 (the "License"); you may not use this file except in compliance with
+ * the License or as specified alternatively below. You may obtain a copy of
+ * the License at http://www.mozilla.org/MPL/
+ *
+ * Software distributed under the License is distributed on an "AS IS" basis,
+ * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+ * for the specific language governing rights and limitations under the
+ * License.
+ *
+ * Major Contributor(s):
+ * Copyright (C) 2012 Kohei Yoshida <kohei.yoshida@suse.com>
+ *
+ * All Rights Reserved.
+ *
+ * For minor contributions see the git repository.
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
+ * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
+ * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
+ * instead of those above.
+ */
+
+#include "calcconfig.hxx"
+
+ScCalcConfig::ScCalcConfig() :
+ meIndirectRefSyntax(formula::FormulaGrammar::CONV_UNSPECIFIED) {}
+
+bool ScCalcConfig::operator== (const ScCalcConfig& r) const
+{
+ return meIndirectRefSyntax == r.meIndirectRefSyntax;
+}
+
+bool ScCalcConfig::operator!= (const ScCalcConfig& r) const
+{
+ return !operator==(r);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/core/tool/interpr1.cxx b/sc/source/core/tool/interpr1.cxx
index a145dd6551a2..c689df990a90 100644
--- a/sc/source/core/tool/interpr1.cxx
+++ b/sc/source/core/tool/interpr1.cxx
@@ -82,7 +82,7 @@ static const sal_uInt64 n2power48 = SAL_CONST_UINT64( 281474976710656); // 2^48
IMPL_FIXEDMEMPOOL_NEWDEL( ScTokenStack )
IMPL_FIXEDMEMPOOL_NEWDEL( ScInterpreter )
-ScInterpreter::Config ScInterpreter::maGlobalConfig;
+ScCalcConfig ScInterpreter::maGlobalConfig;
ScTokenStack* ScInterpreter::pGlobalStack = NULL;
bool ScInterpreter::bGlobalStackInUse = false;
diff --git a/sc/source/core/tool/interpr4.cxx b/sc/source/core/tool/interpr4.cxx
index fe75f618e65c..4a1020120d70 100644
--- a/sc/source/core/tool/interpr4.cxx
+++ b/sc/source/core/tool/interpr4.cxx
@@ -3692,15 +3692,12 @@ ScInterpreter::~ScInterpreter()
delete pTokenMatrixMap;
}
-ScInterpreter::Config::Config() :
- meIndirectRefSyntax(formula::FormulaGrammar::CONV_UNSPECIFIED) {}
-
-void ScInterpreter::SetGlobalConfig(const Config& rConfig)
+void ScInterpreter::SetGlobalConfig(const ScCalcConfig& rConfig)
{
maGlobalConfig = rConfig;
}
-const ScInterpreter::Config& ScInterpreter::GetGlobalConfig()
+const ScCalcConfig& ScInterpreter::GetGlobalConfig()
{
return maGlobalConfig;
}
diff --git a/sc/source/ui/docshell/docsh6.cxx b/sc/source/ui/docshell/docsh6.cxx
index 5ca7d45ded11..1cdaf4ac182c 100644
--- a/sc/source/ui/docshell/docsh6.cxx
+++ b/sc/source/ui/docshell/docsh6.cxx
@@ -51,6 +51,7 @@
#include "scmod.hxx"
#include "compiler.hxx"
#include "interpre.hxx"
+#include "calcconfig.hxx"
#include "formula/FormulaCompiler.hxx"
#include "comphelper/processfactory.hxx"
@@ -507,7 +508,7 @@ void ScDocShell::SetFormulaOptions(const ScFormulaOptions& rOpt )
rOpt.GetFormulaSepArg(), rOpt.GetFormulaSepArrayCol(), rOpt.GetFormulaSepArrayRow());
// Global interpreter settings.
- ScInterpreter::Config aConfig;
+ ScCalcConfig aConfig;
aConfig.meIndirectRefSyntax = rOpt.GetIndirectFuncSyntax();
ScInterpreter::SetGlobalConfig(aConfig);
}
diff --git a/sc/source/ui/inc/tpformula.hxx b/sc/source/ui/inc/tpformula.hxx
index bf908255b9ed..ea9ea6ad55e5 100644
--- a/sc/source/ui/inc/tpformula.hxx
+++ b/sc/source/ui/inc/tpformula.hxx
@@ -35,6 +35,8 @@
#include <vcl/edit.hxx>
#include <vcl/button.hxx>
+#include "calcconfig.hxx"
+
class ScTpFormulaOptions : public SfxTabPage
{
public:
@@ -86,6 +88,9 @@ private:
This value is used to revert undesired value change. */
::rtl::OUString maOldSepValue;
+ ScCalcConfig maSavedConfig;
+ ScCalcConfig maCurrentConfig;
+
sal_Unicode mnDecSep;
};
diff --git a/sc/source/ui/optdlg/tpformula.cxx b/sc/source/ui/optdlg/tpformula.cxx
index 814e3281c8c5..eb882158fe94 100644
--- a/sc/source/ui/optdlg/tpformula.cxx
+++ b/sc/source/ui/optdlg/tpformula.cxx
@@ -246,7 +246,7 @@ SfxTabPage* ScTpFormulaOptions::Create(Window* pParent, const SfxItemSet& rCoreS
sal_Bool ScTpFormulaOptions::FillItemSet(SfxItemSet& rCoreSet)
{
- sal_Bool bRet = false;
+ bool bRet = false;
ScFormulaOptions aOpt;
sal_Bool bEnglishFuncName = maCbEnglishFuncName.IsChecked();
sal_Int16 aSyntaxPos = maLbFormulaSyntax.GetSelectEntryPos();
@@ -258,7 +258,8 @@ sal_Bool ScTpFormulaOptions::FillItemSet(SfxItemSet& rCoreSet)
|| maCbEnglishFuncName.GetSavedValue() != bEnglishFuncName
|| static_cast<OUString>(maEdSepFuncArg.GetSavedValue()) != aSep
|| static_cast<OUString>(maEdSepArrayCol.GetSavedValue()) != aSepArrayCol
- || static_cast<OUString>(maEdSepArrayRow.GetSavedValue()) != aSepArrayRow )
+ || static_cast<OUString>(maEdSepArrayRow.GetSavedValue()) != aSepArrayRow
+ || maSavedConfig != maCurrentConfig )
{
::formula::FormulaGrammar::Grammar eGram = ::formula::FormulaGrammar::GRAM_DEFAULT;
@@ -280,6 +281,7 @@ sal_Bool ScTpFormulaOptions::FillItemSet(SfxItemSet& rCoreSet)
aOpt.SetFormulaSepArg(aSep);
aOpt.SetFormulaSepArrayCol(aSepArrayCol);
aOpt.SetFormulaSepArrayRow(aSepArrayRow);
+ aOpt.SetIndirectFuncSyntax(maCurrentConfig.meIndirectRefSyntax);
rCoreSet.Put( ScTpFormulaItem( SID_SCFORMULAOPTIONS, aOpt ) );
bRet = true;
@@ -340,9 +342,12 @@ void ScTpFormulaOptions::Reset(const SfxItemSet& rCoreSet)
// detailed calc settings.
ScFormulaOptions aDefaults;
- formula::FormulaGrammar::AddressConvention eConv = aOpt.GetIndirectFuncSyntax();
- bool bDefault = aDefaults.GetIndirectFuncSyntax() == eConv;
+
+ maSavedConfig.meIndirectRefSyntax = aOpt.GetIndirectFuncSyntax();
+ bool bDefault = aDefaults.GetIndirectFuncSyntax() == maSavedConfig.meIndirectRefSyntax;
UpdateCustomCalcRadioButtons(bDefault);
+
+ maCurrentConfig = maSavedConfig;
}
int ScTpFormulaOptions::DeactivatePage(SfxItemSet* /*pSet*/)