Kaydet (Commit) 26a45c18 authored tarafından Michael Meeks's avatar Michael Meeks

cleanup options dialog, and add an option for formula grouping.

Change-Id: I3cb19fb24028bc07d24b56786b6573dc79911bda
üst f9704bf7
......@@ -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>
......
......@@ -28,6 +28,7 @@ struct SC_DLLPUBLIC ScCalcConfig
{
formula::FormulaGrammar::AddressConvention meStringRefAddressSyntax;
bool mbEmptyStringAsZero:1;
bool mbOpenCLEnabled:1;
ScCalcConfig();
......
......@@ -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;
......
......@@ -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
......
......@@ -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:
;
}
......
......@@ -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
......
......@@ -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: */
......@@ -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;
};
......
......@@ -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: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment