summaryrefslogtreecommitdiff
path: root/sc/source/ui
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/source/ui
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/source/ui')
-rw-r--r--sc/source/ui/optdlg/calcoptionsdlg.cxx109
-rw-r--r--sc/source/ui/optdlg/calcoptionsdlg.hxx6
2 files changed, 83 insertions, 32 deletions
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;