summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2014-11-07 15:08:07 +0200
committerTor Lillqvist <tml@collabora.com>2014-11-07 18:44:28 +0200
commit0485355e05da36f4023b4c594ecb80b342608f5a (patch)
tree41ec42c8f9379b2ac9d35b14ededaaba6061c1cd /sc
parent03b4aa438b4a72431044f9fc137804329e5bdf43 (diff)
Make it possible to actually edit existing white/black list entries
Still not possible to add new ones or delete existing ones, though. And the UI for this is not finished at all. Work in progress. Also some refactoring. To increase readability, introduce typedefs in ScCalcConfig. Not sure whether nested types inside the class is a good idea or not. Change-Id: I8e1695bb0594e2cd5f8b5ce0ece075842b77762a
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/calcconfig.hxx19
-rw-r--r--sc/source/core/tool/calcconfig.cxx39
-rw-r--r--sc/source/ui/optdlg/calcoptionsdlg.cxx109
-rw-r--r--sc/source/ui/optdlg/calcoptionsdlg.hxx6
4 files changed, 118 insertions, 55 deletions
diff --git a/sc/inc/calcconfig.hxx b/sc/inc/calcconfig.hxx
index 1a4c62c6683b..4b72dc876847 100644
--- a/sc/inc/calcconfig.hxx
+++ b/sc/inc/calcconfig.hxx
@@ -101,10 +101,15 @@ struct SC_DLLPUBLIC ScCalcConfig
bool mbOpenCLAutoSelect:1;
OUString maOpenCLDevice;
sal_Int32 mnOpenCLMinimumFormulaGroupSize;
- std::set<OpCodeEnum> maOpenCLSubsetOpCodes;
- std::set<OpenCLImpl> maOpenCLWhiteList;
- std::set<OpenCLImpl> maOpenCLBlackList;
+ typedef std::set<OpCodeEnum> OpCodeSet;
+
+ OpCodeSet maOpenCLSubsetOpCodes;
+
+ typedef std::set<OpenCLImpl> OpenCLImplSet;
+
+ OpenCLImplSet maOpenCLWhiteList;
+ OpenCLImplSet maOpenCLBlackList;
ScCalcConfig();
@@ -117,11 +122,13 @@ struct SC_DLLPUBLIC ScCalcConfig
bool operator!= (const ScCalcConfig& r) const;
};
+SC_DLLPUBLIC std::ostream& operator<<(std::ostream& rStream, const ScCalcConfig::OpenCLImpl& rImpl);
+SC_DLLPUBLIC std::ostream& operator<<(std::ostream& rStream, const ScCalcConfig::OpenCLImplSet& rSet);
SC_DLLPUBLIC std::ostream& operator<<(std::ostream& rStream, const ScCalcConfig& rConfig);
-SC_DLLPUBLIC OUString ScOpCodeSetToNumberString(const std::set<OpCodeEnum>& rOpCodes);
-SC_DLLPUBLIC OUString ScOpCodeSetToSymbolicString(const std::set<OpCodeEnum>& rOpCodes);
-SC_DLLPUBLIC std::set<OpCodeEnum> ScStringToOpCodeSet(const OUString& rOpCodes);
+SC_DLLPUBLIC OUString ScOpCodeSetToNumberString(const ScCalcConfig::OpCodeSet& rOpCodes);
+SC_DLLPUBLIC OUString ScOpCodeSetToSymbolicString(const ScCalcConfig::OpCodeSet& rOpCodes);
+SC_DLLPUBLIC ScCalcConfig::OpCodeSet ScStringToOpCodeSet(const OUString& rOpCodes);
#endif
diff --git a/sc/source/core/tool/calcconfig.cxx b/sc/source/core/tool/calcconfig.cxx
index 5fd4aecb431e..583c2a3d450a 100644
--- a/sc/source/core/tool/calcconfig.cxx
+++ b/sc/source/core/tool/calcconfig.cxx
@@ -82,27 +82,32 @@ bool ScCalcConfig::operator!= (const ScCalcConfig& r) const
return !operator==(r);
}
-namespace {
+std::ostream& operator<<(std::ostream& rStream, const ScCalcConfig::OpenCLImpl& rImpl)
+{
+ rStream << "{"
+ "OS=" << rImpl.maOS << ","
+ "OSVersion=" << rImpl.maOSVersion << ","
+ "PlatformVendor=" << rImpl.maPlatformVendor << ","
+ "Device=" << rImpl.maDevice << ","
+ "DriverVersion=" << rImpl.maDriverVersion <<
+ "}";
-std::ostream& operator<<(std::ostream& rStream, const std::set<ScCalcConfig::OpenCLImpl>& rSet)
+ return rStream;
+}
+
+std::ostream& operator<<(std::ostream& rStream, const ScCalcConfig::OpenCLImplSet& rSet)
{
+ rStream << "{";
for (auto i = rSet.cbegin(); i != rSet.cend(); ++i)
{
if (i != rSet.cbegin())
rStream << ",";
- rStream << "{"
- "OS=" << (*i).maOS << ","
- "OSVersion=" << (*i).maOSVersion << ","
- "PlatformVendor=" << (*i).maPlatformVendor << ","
- "Device=" << (*i).maDevice << ","
- "DriverVersion=" << (*i).maDriverVersion <<
- "}";
+ rStream << *i;
}
+ rStream << "}";
return rStream;
}
-} // anonymous namespace
-
std::ostream& operator<<(std::ostream& rStream, const ScCalcConfig& rConfig)
{
rStream << "{"
@@ -115,8 +120,8 @@ std::ostream& operator<<(std::ostream& rStream, const ScCalcConfig& rConfig)
"OpenCLDevice='" << rConfig.maOpenCLDevice << "',"
"OpenCLMinimumFormulaGroupSize=" << rConfig.mnOpenCLMinimumFormulaGroupSize << ","
"OpenCLSubsetOpCodes={" << ScOpCodeSetToSymbolicString(rConfig.maOpenCLSubsetOpCodes) << "},"
- "OpenCLWhiteList={" << rConfig.maOpenCLWhiteList << "},"
- "OpenCLBlackList={" << rConfig.maOpenCLBlackList << "}"
+ "OpenCLWhiteList=" << rConfig.maOpenCLWhiteList << ","
+ "OpenCLBlackList=" << rConfig.maOpenCLBlackList <<
"}";
return rStream;
}
@@ -140,7 +145,7 @@ formula::FormulaCompiler::OpCodeMapPtr setup()
} // anonymous namespace
-OUString ScOpCodeSetToNumberString(const std::set<OpCodeEnum>& rOpCodes)
+OUString ScOpCodeSetToNumberString(const ScCalcConfig::OpCodeSet& rOpCodes)
{
OUStringBuffer result;
@@ -154,7 +159,7 @@ OUString ScOpCodeSetToNumberString(const std::set<OpCodeEnum>& rOpCodes)
return result.toString();
}
-OUString ScOpCodeSetToSymbolicString(const std::set<OpCodeEnum>& rOpCodes)
+OUString ScOpCodeSetToSymbolicString(const ScCalcConfig::OpCodeSet& rOpCodes)
{
OUStringBuffer result;
formula::FormulaCompiler::OpCodeMapPtr pOpCodeMap(setup());
@@ -172,9 +177,9 @@ OUString ScOpCodeSetToSymbolicString(const std::set<OpCodeEnum>& rOpCodes)
return result.toString();
}
-std::set<OpCodeEnum> ScStringToOpCodeSet(const OUString& rOpCodes)
+ScCalcConfig::OpCodeSet ScStringToOpCodeSet(const OUString& rOpCodes)
{
- std::set<OpCodeEnum> result;
+ ScCalcConfig::OpCodeSet result;
formula::FormulaCompiler::OpCodeMapPtr pOpCodeMap(setup());
OUString s(rOpCodes + ";");
diff --git a/sc/source/ui/optdlg/calcoptionsdlg.cxx b/sc/source/ui/optdlg/calcoptionsdlg.cxx
index 2768b402e402..8140eef4743d 100644
--- a/sc/source/ui/optdlg/calcoptionsdlg.cxx
+++ b/sc/source/ui/optdlg/calcoptionsdlg.cxx
@@ -162,6 +162,11 @@ ScCalcOptionsDialog::ScCalcOptionsDialog(vcl::Window* pParent, const ScCalcConfi
mpSpinButton->SetModifyHdl(LINK(this, ScCalcOptionsDialog, NumModifiedHdl));
mpEditField->SetModifyHdl(LINK(this, ScCalcOptionsDialog, EditModifiedHdl));
+ mpOS->SetModifyHdl(LINK(this, ScCalcOptionsDialog, EditModifiedHdl));
+ mpOSVersion->SetModifyHdl(LINK(this, ScCalcOptionsDialog, EditModifiedHdl));
+ mpPlatformVendor->SetModifyHdl(LINK(this, ScCalcOptionsDialog, EditModifiedHdl));
+ mpDevice->SetModifyHdl(LINK(this, ScCalcOptionsDialog, EditModifiedHdl));
+ mpDriverVersion->SetModifyHdl(LINK(this, ScCalcOptionsDialog, EditModifiedHdl));
mpOpenCLWhiteAndBlackListBox->set_height_request(4* mpOpenCLWhiteAndBlackListBox->GetTextHeight());
mpOpenCLWhiteAndBlackListBox->SetStyle(mpOpenCLWhiteAndBlackListBox->GetStyle() | WB_CLIPCHILDREN | WB_FORCE_MAKEVISIBLE);
@@ -303,7 +308,7 @@ void ScCalcOptionsDialog::fillOpenCLList()
namespace {
-void fillListBox(ListBox* pListBox, const std::set<ScCalcConfig::OpenCLImpl>& rSet)
+ void fillListBox(ListBox* pListBox, const ScCalcConfig::OpenCLImplSet& rSet)
{
pListBox->SetUpdateMode(false);
pListBox->Clear();
@@ -725,12 +730,76 @@ void ScCalcOptionsDialog::SpinButtonValueChanged()
maConfig.mnOpenCLMinimumFormulaGroupSize = nVal;
}
-void ScCalcOptionsDialog::EditFieldValueChanged()
+ScCalcConfig::OpenCLImplSet& ScCalcOptionsDialog::CurrentWhiteOrBlackList()
{
- // We know that the mpEditField is used for only one thing at the moment,
- // the OpenCL subset list of opcodes
- OUString sVal = mpEditField->GetText();
- maConfig.maOpenCLSubsetOpCodes = ScStringToOpCodeSet(sVal);
+ return (mpLbSettings->GetSelectEntryPos() == CALC_OPTION_OPENCL_WHITELIST ? maConfig.maOpenCLWhiteList : maConfig.maOpenCLBlackList);
+}
+
+const ScCalcConfig::OpenCLImpl& ScCalcOptionsDialog::CurrentWhiteOrBlackListEntry()
+{
+ ScCalcConfig::OpenCLImplSet& rSet(CurrentWhiteOrBlackList());
+
+ auto i = rSet.begin();
+ int n(mpOpenCLWhiteAndBlackListBox->GetSelectEntryPos());
+ while (n && i != rSet.end())
+ {
+ ++i;
+ --n;
+ }
+
+ return *i;
+}
+
+void ScCalcOptionsDialog::EditFieldValueChanged(Control *pCtrl)
+{
+ Edit* pEdit(dynamic_cast<Edit*>(pCtrl));
+
+ assert(pEdit);
+
+ OUString sVal = pEdit->GetText();
+
+ if (pEdit == mpEditField)
+ {
+ // We know that the mpEditField is used for only one thing at the moment,
+ // the OpenCL subset list of opcodes
+ maConfig.maOpenCLSubsetOpCodes = ScStringToOpCodeSet(sVal);
+ }
+ else
+ {
+ // We know that this handler is otherwise currently used only
+ // for the OpenCL white/blacklists
+
+ const ScCalcConfig::OpenCLImpl& impl(CurrentWhiteOrBlackListEntry());
+ ScCalcConfig::OpenCLImpl newImpl(impl);
+
+ if (pEdit == mpOS)
+ {
+ newImpl.maOS = sVal;
+ }
+ else if (pEdit == mpOSVersion)
+ {
+ newImpl.maOSVersion = sVal;
+ }
+ else if (pEdit == mpPlatformVendor)
+ {
+ newImpl.maPlatformVendor = sVal;
+ }
+ else if (pEdit == mpDevice)
+ {
+ newImpl.maDevice = sVal;
+ }
+ else if (pEdit == mpDriverVersion)
+ {
+ newImpl.maDriverVersion = sVal;
+ }
+ else
+ assert(false && "pEdit does not match any of the Edit fields");
+
+ ScCalcConfig::OpenCLImplSet& rSet(CurrentWhiteOrBlackList());
+
+ rSet.erase(impl);
+ rSet.insert(newImpl);
+ }
}
void ScCalcOptionsDialog::WhiteAndBlackListSelectionChanged()
@@ -814,37 +883,17 @@ IMPL_LINK_NOARG(ScCalcOptionsDialog, NumModifiedHdl)
return 0;
}
-IMPL_LINK_NOARG(ScCalcOptionsDialog, EditModifiedHdl)
+IMPL_LINK(ScCalcOptionsDialog, EditModifiedHdl, Control*, pCtrl)
{
- EditFieldValueChanged();
+ EditFieldValueChanged(pCtrl);
return 0;
}
-namespace {
-
-template <class T>
-typename T::iterator nth(T container, int n)
-{
- auto i = container.begin();
- while (n && i != container.end())
- {
- ++i;
- --n;
- }
-
- return i;
-}
-
-} // anonymous namespace
-
IMPL_LINK(ScCalcOptionsDialog, OpenCLWhiteAndBlackListSelHdl, Control*, )
{
- // We know this is called for the mpOpenCLWhiteAndBlackListBox
+ // We know this handler is used for the mpOpenCLWhiteAndBlackListBox
- std::set<ScCalcConfig::OpenCLImpl>
- &implSet(mpLbSettings->GetSelectEntryPos() == CALC_OPTION_OPENCL_WHITELIST ? maConfig.maOpenCLWhiteList : maConfig.maOpenCLBlackList);
- sal_uLong n(mpOpenCLWhiteAndBlackListBox->GetSelectEntryPos());
- const ScCalcConfig::OpenCLImpl& impl(*nth(implSet, n));
+ const ScCalcConfig::OpenCLImpl& impl(CurrentWhiteOrBlackListEntry());
mpOS->SetText(impl.maOS);
mpOSVersion->SetText(impl.maOSVersion);
diff --git a/sc/source/ui/optdlg/calcoptionsdlg.hxx b/sc/source/ui/optdlg/calcoptionsdlg.hxx
index 45d8e5836f7f..d8115c2594b7 100644
--- a/sc/source/ui/optdlg/calcoptionsdlg.hxx
+++ b/sc/source/ui/optdlg/calcoptionsdlg.hxx
@@ -39,7 +39,7 @@ public:
DECL_LINK( BtnAutomaticSelectHdl, void* );
DECL_LINK( DeviceSelHdl, void* );
DECL_LINK( NumModifiedHdl, void * );
- DECL_LINK( EditModifiedHdl, void * );
+ DECL_LINK( EditModifiedHdl, Control * );
DECL_LINK( OpenCLWhiteAndBlackListSelHdl, Control* );
const ScCalcConfig& GetConfig() const { return maConfig;}
@@ -52,7 +52,7 @@ private:
void OpenCLAutomaticSelectionChanged();
void SelectedDeviceChanged();
void SpinButtonValueChanged();
- void EditFieldValueChanged();
+ void EditFieldValueChanged(Control *pCtrl);
void WhiteAndBlackListSelectionChanged();
#if HAVE_FEATURE_OPENCL
void fillOpenCLList();
@@ -64,6 +64,8 @@ private:
OUString toString(sal_Int32 nVal) const;
SvTreeListEntry *createItem(const OUString &rCaption, const OUString& sValue) const;
void setValueAt(size_t nPos, const OUString &rString);
+ std::set<ScCalcConfig::OpenCLImpl>& CurrentWhiteOrBlackList();
+ const ScCalcConfig::OpenCLImpl& CurrentWhiteOrBlackListEntry();
private:
SvxCheckListBox* mpLbSettings;