summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Meeks <michael.meeks@suse.com>2013-06-25 13:38:22 +0100
committerMichael Meeks <michael.meeks@suse.com>2013-06-25 16:14:20 +0100
commit26a45c1886d9167d8f9ae9aad6234a3702768d8a (patch)
treec919f51de310c859bfb677e8e17651aa32764c62
parentf9704bf73dfba50421132e5379165912a2779906 (diff)
cleanup options dialog, and add an option for formula grouping.
Change-Id: I3cb19fb24028bc07d24b56786b6573dc79911bda
-rw-r--r--officecfg/registry/schema/org/openoffice/Office/Calc.xcs12
-rw-r--r--sc/inc/calcconfig.hxx1
-rw-r--r--sc/source/core/data/documen9.cxx7
-rw-r--r--sc/source/core/tool/calcconfig.cxx8
-rw-r--r--sc/source/core/tool/formulaopt.cxx16
-rw-r--r--sc/source/ui/optdlg/calcoptionsdlg.cxx123
-rw-r--r--sc/source/ui/optdlg/calcoptionsdlg.hrc3
-rw-r--r--sc/source/ui/optdlg/calcoptionsdlg.hxx5
-rw-r--r--sc/source/ui/optdlg/calcoptionsdlg.src12
9 files changed, 131 insertions, 56 deletions
diff --git a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
index 8ee1809fe38c..b3964387a490 100644
--- a/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/Calc.xcs
@@ -1318,6 +1318,18 @@
<info>
<desc>Contains settings that affect formula handling.</desc>
</info>
+ <group oor:name="Calculation">
+ <info>
+ <desc>Contains settings for how to calculate formulae.</desc>
+ </info>
+ <prop oor:name="OpenCL" oor:type="xs:boolean" oor:nillable="false">
+ <!-- UIHints: Tools - Options Spreadsheet Formula -->
+ <info>
+ <desc>Whether to use OpenCL for formula computation, if available.</desc>
+ </info>
+ <value>false</value>
+ </prop>
+ </group>
<group oor:name="Syntax">
<info>
<desc>Contains settings for formula syntax.</desc>
diff --git a/sc/inc/calcconfig.hxx b/sc/inc/calcconfig.hxx
index 96eabcc14858..aace08dad030 100644
--- a/sc/inc/calcconfig.hxx
+++ b/sc/inc/calcconfig.hxx
@@ -28,6 +28,7 @@ struct SC_DLLPUBLIC ScCalcConfig
{
formula::FormulaGrammar::AddressConvention meStringRefAddressSyntax;
bool mbEmptyStringAsZero:1;
+ bool mbOpenCLEnabled:1;
ScCalcConfig();
diff --git a/sc/source/core/data/documen9.cxx b/sc/source/core/data/documen9.cxx
index d0813798ca03..525f12d06029 100644
--- a/sc/source/core/data/documen9.cxx
+++ b/sc/source/core/data/documen9.cxx
@@ -52,6 +52,7 @@
#include "editutil.hxx"
#include "postit.hxx"
#include "charthelper.hxx"
+#include "interpre.hxx"
using namespace ::com::sun::star;
#include <stdio.h>
@@ -689,9 +690,11 @@ void ScDocument::ApplyAsianEditSettings( ScEditEngineDefaulter& rEngine )
void ScDocument::RebuildFormulaGroups()
{
- static const char *pEnableFormulaGroups = getenv("SC_FORMULAGROUP");
+ bool bEnableFormulaGroups;
- if ( !pEnableFormulaGroups )
+ bEnableFormulaGroups = ScInterpreter::GetGlobalConfig().mbOpenCLEnabled;
+
+ if ( !bEnableFormulaGroups )
return;
SCTAB nTab;
diff --git a/sc/source/core/tool/calcconfig.cxx b/sc/source/core/tool/calcconfig.cxx
index c85ddf205e39..ed93f64852fe 100644
--- a/sc/source/core/tool/calcconfig.cxx
+++ b/sc/source/core/tool/calcconfig.cxx
@@ -14,7 +14,10 @@
ScCalcConfig::ScCalcConfig() :
meStringRefAddressSyntax(formula::FormulaGrammar::CONV_UNSPECIFIED),
- mbEmptyStringAsZero(false) {}
+ mbEmptyStringAsZero(false),
+ mbOpenCLEnabled(false)
+{
+}
void ScCalcConfig::reset()
{
@@ -24,7 +27,8 @@ void ScCalcConfig::reset()
bool ScCalcConfig::operator== (const ScCalcConfig& r) const
{
return meStringRefAddressSyntax == r.meStringRefAddressSyntax &&
- mbEmptyStringAsZero == r.mbEmptyStringAsZero;
+ mbEmptyStringAsZero == r.mbEmptyStringAsZero &&
+ mbOpenCLEnabled == r.mbOpenCLEnabled;
}
bool ScCalcConfig::operator!= (const ScCalcConfig& r) const
diff --git a/sc/source/core/tool/formulaopt.cxx b/sc/source/core/tool/formulaopt.cxx
index df9e69a44488..db35f93e49b2 100644
--- a/sc/source/core/tool/formulaopt.cxx
+++ b/sc/source/core/tool/formulaopt.cxx
@@ -204,7 +204,8 @@ SfxPoolItem* ScTpFormulaItem::Clone( SfxItemPool * ) const
#define SCFORMULAOPT_EMPTY_STRING_AS_ZERO 6
#define SCFORMULAOPT_OOXML_RECALC 7
#define SCFORMULAOPT_ODF_RECALC 8
-#define SCFORMULAOPT_COUNT 9
+#define SCFORMULAOPT_OPENCL_ENABLED 9
+#define SCFORMULAOPT_COUNT 10
Sequence<OUString> ScFormulaCfg::GetPropertyNames()
{
@@ -219,6 +220,7 @@ Sequence<OUString> ScFormulaCfg::GetPropertyNames()
"Syntax/EmptyStringAsZero", // SCFORMULAOPT_EMPTY_STRING_AS_ZERO
"Load/OOXMLRecalcMode", // SCFORMULAOPT_OOXML_RECALC
"Load/ODFRecalcMode", // SCFORMULAOPT_ODF_RECALC
+ "Calculation/OpenCL" // SCFORMULAOPT_OPENCL_ENABLED
};
Sequence<OUString> aNames(SCFORMULAOPT_COUNT);
OUString* pNames = aNames.getArray();
@@ -390,6 +392,12 @@ ScFormulaCfg::ScFormulaCfg() :
SetODFRecalcOptions(eOpt);
}
break;
+ case SCFORMULAOPT_OPENCL_ENABLED:
+ {
+ sal_Bool bVal = GetCalcConfig().mbOpenCLEnabled;
+ pValues[nProp] >>= bVal;
+ GetCalcConfig().mbOpenCLEnabled = bVal;
+ }
default:
;
}
@@ -492,6 +500,12 @@ void ScFormulaCfg::Commit()
pValues[nProp] <<= nVal;
}
break;
+ case SCFORMULAOPT_OPENCL_ENABLED:
+ {
+ sal_Bool bVal = GetCalcConfig().mbOpenCLEnabled;
+ pValues[nProp] <<= bVal;
+ }
+ break;
default:
;
}
diff --git a/sc/source/ui/optdlg/calcoptionsdlg.cxx b/sc/source/ui/optdlg/calcoptionsdlg.cxx
index 6aacdff9e2dc..88eb78e6c774 100644
--- a/sc/source/ui/optdlg/calcoptionsdlg.cxx
+++ b/sc/source/ui/optdlg/calcoptionsdlg.cxx
@@ -19,6 +19,12 @@
namespace {
+typedef enum {
+ CALC_OPTION_REF_SYNTAX = 0,
+ CALC_OPTION_EMPTY_AS_ZERO = 1,
+ CALC_OPTION_ENABLE_OPENCL = 2
+} CalcOptionOrder;
+
class OptionString : public SvLBoxString
{
OUString maDesc;
@@ -27,6 +33,8 @@ public:
OptionString(const OUString& rDesc, const OUString& rValue) :
maDesc(rDesc), maValue(rValue) {}
+ void SetValue(const OUString &rValue) { maValue = rValue; }
+
virtual void Paint(const Point& rPos, SvTreeListBox& rDev, const SvViewDataEntry* pView, const SvTreeListEntry* pEntry);
};
@@ -88,6 +96,8 @@ ScCalcOptionsDialog::ScCalcOptionsDialog(Window* pParent, const ScCalcConfig& rC
maUseFormulaSyntax(ScResId(STR_USE_FORMULA_SYNTAX).toString()),
maCaptionEmptyStringAsZero(ScResId(STR_EMPTY_STRING_AS_ZERO_CAPTION).toString()),
maDescEmptyStringAsZero(ScResId(STR_EMPTY_STRING_AS_ZERO_DESC).toString()),
+ maCaptionOpenCLEnabled(ScResId(STR_OPENCL_ENABLED).toString()),
+ maDescOpenCLEnabled(ScResId(STR_OPENCL_ENABLED_DESC).toString()),
maConfig(rConfig)
{
maLbSettings.SetStyle(maLbSettings.GetStyle() | WB_CLIPCHILDREN | WB_FORCE_MAKEVISIBLE);
@@ -115,6 +125,36 @@ const ScCalcConfig& ScCalcOptionsDialog::GetConfig() const
return maConfig;
}
+SvTreeListEntry *ScCalcOptionsDialog::createBoolItem(const OUString &rCaption, bool bValue) const
+{
+ SvTreeListEntry* pEntry = new SvTreeListEntry;
+ pEntry->AddItem(new SvLBoxString(pEntry, 0, OUString()));
+ pEntry->AddItem(new SvLBoxContextBmp(pEntry, 0, Image(), Image(), 0));
+ OptionString* pItem = new OptionString(rCaption, toString(bValue));
+ pEntry->AddItem(pItem);
+ return pEntry;
+}
+
+void ScCalcOptionsDialog::setValueAt(size_t nPos, const OUString &rValue)
+{
+ SvTreeList *pModel = maLbSettings.GetModel();
+ SvTreeListEntry* pEntry = pModel->GetEntry(NULL, nPos);
+ if (!pEntry)
+ {
+ SAL_WARN("sc", "missing entry at " << nPos << " in value view");
+ return;
+ }
+ OptionString* pOpt = dynamic_cast<OptionString *>(pEntry->GetItem(2));
+ if (!pOpt)
+ {
+ SAL_WARN("sc", "missing option string item so can't set " << rValue);
+ return;
+ }
+
+ pOpt->SetValue(rValue);
+ pModel->InvalidateEntry(pEntry);
+}
+
void ScCalcOptionsDialog::FillOptionsList()
{
maLbSettings.SetUpdateMode(false);
@@ -133,16 +173,8 @@ void ScCalcOptionsDialog::FillOptionsList()
pModel->Insert(pEntry);
}
- {
- // Treat empty string as zero.
- SvTreeListEntry* pEntry = new SvTreeListEntry;
- pEntry->AddItem(new SvLBoxString(pEntry, 0, OUString()));
- pEntry->AddItem(new SvLBoxContextBmp(pEntry, 0, Image(), Image(), 0));
- OptionString* pItem = new OptionString(
- maCaptionEmptyStringAsZero, toString(maConfig.mbEmptyStringAsZero));
- pEntry->AddItem(pItem);
- pModel->Insert(pEntry);
- }
+ pModel->Insert(createBoolItem(maCaptionEmptyStringAsZero,maConfig.mbEmptyStringAsZero));
+ pModel->Insert(createBoolItem(maCaptionOpenCLEnabled,maConfig.mbOpenCLEnabled));
maLbSettings.SetUpdateMode(true);
}
@@ -150,9 +182,9 @@ void ScCalcOptionsDialog::FillOptionsList()
void ScCalcOptionsDialog::SelectionChanged()
{
sal_uInt16 nSelectedPos = maLbSettings.GetSelectEntryPos();
- switch (nSelectedPos)
+ switch ((CalcOptionOrder)nSelectedPos)
{
- case 0:
+ case CALC_OPTION_REF_SYNTAX:
{
// Formula syntax for INDIRECT function.
maBtnTrue.Hide();
@@ -182,14 +214,23 @@ void ScCalcOptionsDialog::SelectionChanged()
maFtAnnotation.SetText(maDescStringRefSyntax);
}
break;
- case 1:
+
+ // booleans
+ case CALC_OPTION_EMPTY_AS_ZERO:
+ case CALC_OPTION_ENABLE_OPENCL:
{
// Treat empty string as zero.
maLbOptionEdit.Hide();
maBtnTrue.Show();
maBtnFalse.Show();
- if (maConfig.mbEmptyStringAsZero)
+ bool bValue = false;
+ if ( nSelectedPos == CALC_OPTION_EMPTY_AS_ZERO )
+ bValue = maConfig.mbEmptyStringAsZero;
+ else
+ bValue = maConfig.mbOpenCLEnabled;
+
+ if ( bValue )
{
maBtnTrue.Check(true);
maBtnFalse.Check(false);
@@ -210,59 +251,41 @@ void ScCalcOptionsDialog::SelectionChanged()
void ScCalcOptionsDialog::ListOptionValueChanged()
{
sal_uInt16 nSelected = maLbSettings.GetSelectEntryPos();
- switch (nSelected)
+ switch ((CalcOptionOrder) nSelected)
{
- case 0:
+ case CALC_OPTION_REF_SYNTAX:
{
// Formula syntax for INDIRECT function.
sal_uInt16 nPos = maLbOptionEdit.GetSelectEntryPos();
maConfig.meStringRefAddressSyntax = toAddressConvention(nPos);
- maLbSettings.SetUpdateMode(false);
-
- SvTreeList* pModel = maLbSettings.GetModel();
- SvTreeListEntry* pEntry = pModel->GetEntry(NULL, 0);
- if (!pEntry)
- return;
-
- OptionString* pItem = new OptionString(
- maCaptionStringRefSyntax, toString(maConfig.meStringRefAddressSyntax));
- pEntry->ReplaceItem(pItem, 2);
-
- maLbSettings.SetUpdateMode(true);
+ setValueAt(nSelected, toString(maConfig.meStringRefAddressSyntax));
}
break;
- default:
- ;
+
+ case CALC_OPTION_EMPTY_AS_ZERO:
+ case CALC_OPTION_ENABLE_OPENCL:
+ break;
}
}
void ScCalcOptionsDialog::RadioValueChanged()
{
sal_uInt16 nSelected = maLbSettings.GetSelectEntryPos();
+ bool bValue = maBtnTrue.IsChecked();
switch (nSelected)
{
- case 1:
- {
- // Treat empty string as zero.
- maConfig.mbEmptyStringAsZero = maBtnTrue.IsChecked();
- maLbSettings.SetUpdateMode(false);
-
- SvTreeList* pModel = maLbSettings.GetModel();
- SvTreeListEntry* pEntry = pModel->GetEntry(NULL, 1);
- if (!pEntry)
- return;
-
- OptionString* pItem = new OptionString(
- maCaptionEmptyStringAsZero, toString(maConfig.mbEmptyStringAsZero));
- pEntry->ReplaceItem(pItem, 2);
-
- maLbSettings.SetUpdateMode(true);
- }
- break;
- default:
- ;
+ case CALC_OPTION_REF_SYNTAX:
+ return;
+ case CALC_OPTION_EMPTY_AS_ZERO:
+ maConfig.mbEmptyStringAsZero = bValue;
+ break;
+ case CALC_OPTION_ENABLE_OPENCL:
+ maConfig.mbOpenCLEnabled = bValue;
+ break;
}
+
+ setValueAt(nSelected, toString(bValue));
}
OUString ScCalcOptionsDialog::toString(formula::FormulaGrammar::AddressConvention eConv) const
diff --git a/sc/source/ui/optdlg/calcoptionsdlg.hrc b/sc/source/ui/optdlg/calcoptionsdlg.hrc
index 9276e98b384a..a6f5ee4240a1 100644
--- a/sc/source/ui/optdlg/calcoptionsdlg.hrc
+++ b/sc/source/ui/optdlg/calcoptionsdlg.hrc
@@ -35,5 +35,8 @@
#define STR_EMPTY_STRING_AS_ZERO_CAPTION 27
#define STR_EMPTY_STRING_AS_ZERO_DESC 28
+#define STR_OPENCL_ENABLED 28
+#define STR_OPENCL_ENABLED_DESC 29
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sc/source/ui/optdlg/calcoptionsdlg.hxx b/sc/source/ui/optdlg/calcoptionsdlg.hxx
index b05c73e741e0..ea93fcb97738 100644
--- a/sc/source/ui/optdlg/calcoptionsdlg.hxx
+++ b/sc/source/ui/optdlg/calcoptionsdlg.hxx
@@ -39,6 +39,8 @@ private:
OUString toString(formula::FormulaGrammar::AddressConvention eConv) const;
OUString toString(bool bVal) const;
+ SvTreeListEntry *createBoolItem(const OUString &rCaption, bool bValue) const;
+ void setValueAt(size_t nPos, const OUString &rString);
private:
SvxCheckListBox maLbSettings;
@@ -68,6 +70,9 @@ private:
OUString maCaptionEmptyStringAsZero;
OUString maDescEmptyStringAsZero;
+ OUString maCaptionOpenCLEnabled;
+ OUString maDescOpenCLEnabled;
+
ScCalcConfig maConfig;
};
diff --git a/sc/source/ui/optdlg/calcoptionsdlg.src b/sc/source/ui/optdlg/calcoptionsdlg.src
index 1dd7ca3d9d43..f86a2ac23f23 100644
--- a/sc/source/ui/optdlg/calcoptionsdlg.src
+++ b/sc/source/ui/optdlg/calcoptionsdlg.src
@@ -24,7 +24,7 @@ ModalDialog RID_SCDLG_FORMULA_CALCOPTIONS
{
Border = TRUE ;
Pos = MAP_APPFONT ( 6 , 10 ) ;
- Size = MAP_APPFONT ( 218 , 67 ) ;
+ Size = MAP_APPFONT ( 218 , 70 ) ;
TabStop = TRUE ;
};
@@ -122,6 +122,16 @@ ModalDialog RID_SCDLG_FORMULA_CALCOPTIONS
{
Text [ en-US ] = "False";
};
+
+ String STR_OPENCL_ENABLED
+ {
+ Text [ en-US ] = "Enable OpenCL for some formula computation";
+ };
+
+ String STR_OPENCL_ENABLED_DESC
+ {
+ Text [ en-US ] = "This option enables some sorts of simple formula expressions to be executed using OpenCL if it is available on your system.";
+ };
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */