summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorTor Lillqvist <tml@collabora.com>2014-11-07 12:03:09 +0200
committerTor Lillqvist <tml@collabora.com>2014-11-07 18:44:28 +0200
commit03b4aa438b4a72431044f9fc137804329e5bdf43 (patch)
tree1ca38588c150879622013b17ab738580bf565275 /sc
parentcd56935a177b7d9fd10434afe220fe6c10820f82 (diff)
Some simplification and refactoring, no functional change
Change-Id: Ie7ba158063dc0c588e114278cedb80e414ccc4cb
Diffstat (limited to 'sc')
-rw-r--r--sc/inc/calcconfig.hxx24
-rw-r--r--sc/source/core/tool/calcconfig.cxx15
-rw-r--r--sc/source/core/tool/formulaopt.cxx20
-rw-r--r--sc/source/ui/optdlg/calcoptionsdlg.cxx63
-rw-r--r--sc/source/ui/optdlg/calcoptionsdlg.hxx5
5 files changed, 46 insertions, 81 deletions
diff --git a/sc/inc/calcconfig.hxx b/sc/inc/calcconfig.hxx
index e051e1db2b38..1a4c62c6683b 100644
--- a/sc/inc/calcconfig.hxx
+++ b/sc/inc/calcconfig.hxx
@@ -41,7 +41,7 @@ struct SC_DLLPUBLIC ScCalcConfig
STRING_CONVERSION_LOCALE_DEPENDENT ///< =1+"1.000" may be 2 or 1001 ... =1+"x" gives #VALUE!
};
- struct OpenCLImplementationMatcher
+ struct OpenCLImpl
{
OUString maOS;
OUString maOSVersion;
@@ -49,15 +49,15 @@ struct SC_DLLPUBLIC ScCalcConfig
OUString maDevice;
OUString maDriverVersion;
- OpenCLImplementationMatcher()
+ OpenCLImpl()
{
}
- OpenCLImplementationMatcher(const OUString& rOS,
- const OUString& rOSVersion,
- const OUString& rPlatformVendor,
- const OUString& rDevice,
- const OUString& rDriverVersion)
+ OpenCLImpl(const OUString& rOS,
+ const OUString& rOSVersion,
+ const OUString& rPlatformVendor,
+ const OUString& rDevice,
+ const OUString& rDriverVersion)
: maOS(rOS),
maOSVersion(rOSVersion),
maPlatformVendor(rPlatformVendor),
@@ -66,7 +66,7 @@ struct SC_DLLPUBLIC ScCalcConfig
{
}
- bool operator==(const OpenCLImplementationMatcher& r) const
+ bool operator==(const OpenCLImpl& r) const
{
return maOS == r.maOS &&
maOSVersion == r.maOSVersion &&
@@ -74,11 +74,11 @@ struct SC_DLLPUBLIC ScCalcConfig
maDevice == r.maDevice &&
maDriverVersion == r.maDriverVersion;
}
- bool operator!=(const OpenCLImplementationMatcher& r) const
+ bool operator!=(const OpenCLImpl& r) const
{
return !operator==(r);
}
- bool operator<(const OpenCLImplementationMatcher& r) const
+ bool operator<(const OpenCLImpl& r) const
{
return (maOS < r.maOS ||
(maOS == r.maOS &&
@@ -103,8 +103,8 @@ struct SC_DLLPUBLIC ScCalcConfig
sal_Int32 mnOpenCLMinimumFormulaGroupSize;
std::set<OpCodeEnum> maOpenCLSubsetOpCodes;
- std::set<OpenCLImplementationMatcher> maOpenCLWhiteList;
- std::set<OpenCLImplementationMatcher> maOpenCLBlackList;
+ std::set<OpenCLImpl> maOpenCLWhiteList;
+ std::set<OpenCLImpl> maOpenCLBlackList;
ScCalcConfig();
diff --git a/sc/source/core/tool/calcconfig.cxx b/sc/source/core/tool/calcconfig.cxx
index 8b7e58afd10d..5fd4aecb431e 100644
--- a/sc/source/core/tool/calcconfig.cxx
+++ b/sc/source/core/tool/calcconfig.cxx
@@ -44,8 +44,8 @@ void ScCalcConfig::setOpenCLConfigToDefault()
maOpenCLSubsetOpCodes.insert(ocSum);
maOpenCLSubsetOpCodes.insert(ocAverage);
maOpenCLSubsetOpCodes.insert(ocSumIfs);
- maOpenCLBlackList.insert(OpenCLImplementationMatcher("Windows", "*", "Intel(R) Corporation", "*", "9.17.10.2884"));
- maOpenCLBlackList.insert(OpenCLImplementationMatcher("SuperOS", "*", "Big Corp, Inc.", "Whizz\\Grafix", "4.2/beta;3"));
+ maOpenCLBlackList.insert(OpenCLImpl("Windows", "*", "Intel(R) Corporation", "*", "9.17.10.2884"));
+ maOpenCLBlackList.insert(OpenCLImpl("SuperOS", "*", "Big Corp, Inc.", "Whizz\\Grafix", "4.2/beta;3"));
}
void ScCalcConfig::reset()
@@ -84,7 +84,7 @@ bool ScCalcConfig::operator!= (const ScCalcConfig& r) const
namespace {
-void writeOpenCLImplementationMatcher(std::ostream& rStream, const std::set<ScCalcConfig::OpenCLImplementationMatcher>& rSet)
+std::ostream& operator<<(std::ostream& rStream, const std::set<ScCalcConfig::OpenCLImpl>& rSet)
{
for (auto i = rSet.cbegin(); i != rSet.cend(); ++i)
{
@@ -98,6 +98,7 @@ void writeOpenCLImplementationMatcher(std::ostream& rStream, const std::set<ScCa
"DriverVersion=" << (*i).maDriverVersion <<
"}";
}
+ return rStream;
}
} // anonymous namespace
@@ -114,12 +115,8 @@ std::ostream& operator<<(std::ostream& rStream, const ScCalcConfig& rConfig)
"OpenCLDevice='" << rConfig.maOpenCLDevice << "',"
"OpenCLMinimumFormulaGroupSize=" << rConfig.mnOpenCLMinimumFormulaGroupSize << ","
"OpenCLSubsetOpCodes={" << ScOpCodeSetToSymbolicString(rConfig.maOpenCLSubsetOpCodes) << "},"
- "OpenCLWhiteList={";
- writeOpenCLImplementationMatcher(rStream, rConfig.maOpenCLWhiteList);
- rStream << "},"
- "OpenCLBlackList={";
- writeOpenCLImplementationMatcher(rStream, rConfig.maOpenCLBlackList);
- rStream << "}"
+ "OpenCLWhiteList={" << rConfig.maOpenCLWhiteList << "},"
+ "OpenCLBlackList={" << rConfig.maOpenCLBlackList << "}"
"}";
return rStream;
}
diff --git a/sc/source/core/tool/formulaopt.cxx b/sc/source/core/tool/formulaopt.cxx
index 9661b49dd45a..bcf72821f7cf 100644
--- a/sc/source/core/tool/formulaopt.cxx
+++ b/sc/source/core/tool/formulaopt.cxx
@@ -280,7 +280,7 @@ ScFormulaCfg::ScFormulaCfg() :
namespace {
-css::uno::Sequence<OUString> SetOfOpenCLImplementationMatcherToStringSequence(std::set<ScCalcConfig::OpenCLImplementationMatcher>& rSet)
+css::uno::Sequence<OUString> SetOfOpenCLImplToStringSequence(std::set<ScCalcConfig::OpenCLImpl>& rSet)
{
css::uno::Sequence<OUString> result(rSet.size());
@@ -323,13 +323,13 @@ OUString getToken(const OUString& string, sal_Int32& index)
return result;
}
-std::set<ScCalcConfig::OpenCLImplementationMatcher> StringSequenceToSetOfOpenCLImplementationMatcher(css::uno::Sequence<OUString>& rSequence)
+std::set<ScCalcConfig::OpenCLImpl> StringSequenceToSetOfOpenCLImpl(css::uno::Sequence<OUString>& rSequence)
{
- std::set<ScCalcConfig::OpenCLImplementationMatcher> result;
+ std::set<ScCalcConfig::OpenCLImpl> result;
for (auto i = rSequence.begin(); i != rSequence.end(); ++i)
{
- ScCalcConfig::OpenCLImplementationMatcher m;
+ ScCalcConfig::OpenCLImpl m;
sal_Int32 index(0);
m.maOS = getToken(*i, index);
m.maOSVersion = getToken(*i, index);
@@ -589,16 +589,16 @@ void ScFormulaCfg::UpdateFromProperties( const Sequence<OUString>& aNames )
break;
case SCFORMULAOPT_OPENCL_WHITELIST:
{
- css::uno::Sequence<OUString> sVal = SetOfOpenCLImplementationMatcherToStringSequence(GetCalcConfig().maOpenCLWhiteList);
+ css::uno::Sequence<OUString> sVal = SetOfOpenCLImplToStringSequence(GetCalcConfig().maOpenCLWhiteList);
pValues[nProp] >>= sVal;
- GetCalcConfig().maOpenCLWhiteList = StringSequenceToSetOfOpenCLImplementationMatcher(sVal);
+ GetCalcConfig().maOpenCLWhiteList = StringSequenceToSetOfOpenCLImpl(sVal);
}
break;
case SCFORMULAOPT_OPENCL_BLACKLIST:
{
- css::uno::Sequence<OUString> sVal = SetOfOpenCLImplementationMatcherToStringSequence(GetCalcConfig().maOpenCLBlackList);
+ css::uno::Sequence<OUString> sVal = SetOfOpenCLImplToStringSequence(GetCalcConfig().maOpenCLBlackList);
pValues[nProp] >>= sVal;
- GetCalcConfig().maOpenCLBlackList = StringSequenceToSetOfOpenCLImplementationMatcher(sVal);
+ GetCalcConfig().maOpenCLBlackList = StringSequenceToSetOfOpenCLImpl(sVal);
}
break;
}
@@ -756,13 +756,13 @@ void ScFormulaCfg::Commit()
break;
case SCFORMULAOPT_OPENCL_WHITELIST:
{
- css::uno::Sequence<OUString> sVal = SetOfOpenCLImplementationMatcherToStringSequence(GetCalcConfig().maOpenCLWhiteList);
+ css::uno::Sequence<OUString> sVal = SetOfOpenCLImplToStringSequence(GetCalcConfig().maOpenCLWhiteList);
pValues[nProp] <<= sVal;
}
break;
case SCFORMULAOPT_OPENCL_BLACKLIST:
{
- css::uno::Sequence<OUString> sVal = SetOfOpenCLImplementationMatcherToStringSequence(GetCalcConfig().maOpenCLBlackList);
+ css::uno::Sequence<OUString> sVal = SetOfOpenCLImplToStringSequence(GetCalcConfig().maOpenCLBlackList);
pValues[nProp] <<= sVal;
}
break;
diff --git a/sc/source/ui/optdlg/calcoptionsdlg.cxx b/sc/source/ui/optdlg/calcoptionsdlg.cxx
index 9551f1684093..2768b402e402 100644
--- a/sc/source/ui/optdlg/calcoptionsdlg.cxx
+++ b/sc/source/ui/optdlg/calcoptionsdlg.cxx
@@ -231,27 +231,7 @@ ScCalcOptionsDialog::ScCalcOptionsDialog(vcl::Window* pParent, const ScCalcConfi
ScCalcOptionsDialog::~ScCalcOptionsDialog() {}
-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(), false));
- OptionString* pItem = new OptionString(rCaption, toString(bValue));
- pEntry->AddItem(pItem);
- return pEntry;
-}
-
-SvTreeListEntry *ScCalcOptionsDialog::createIntegerItem(const OUString &rCaption, sal_Int32 nValue) const
-{
- SvTreeListEntry* pEntry = new SvTreeListEntry;
- pEntry->AddItem(new SvLBoxString(pEntry, 0, OUString()));
- pEntry->AddItem(new SvLBoxContextBmp(pEntry, 0, Image(), Image(), false));
- OptionString* pItem = new OptionString(rCaption, toString(nValue));
- pEntry->AddItem(pItem);
- return pEntry;
-}
-
-SvTreeListEntry *ScCalcOptionsDialog::createStringItem(const OUString &rCaption, const OUString& sValue) const
+SvTreeListEntry *ScCalcOptionsDialog::createItem(const OUString &rCaption, const OUString& sValue) const
{
SvTreeListEntry* pEntry = new SvTreeListEntry;
pEntry->AddItem(new SvLBoxString(pEntry, 0, OUString()));
@@ -261,16 +241,6 @@ SvTreeListEntry *ScCalcOptionsDialog::createStringItem(const OUString &rCaption,
return pEntry;
}
-SvTreeListEntry *ScCalcOptionsDialog::createStringListItem(const OUString &rCaption) const
-{
- SvTreeListEntry* pEntry = new SvTreeListEntry;
- pEntry->AddItem(new SvLBoxString(pEntry, 0, OUString()));
- pEntry->AddItem(new SvLBoxContextBmp(pEntry, 0, Image(), Image(), false));
- OptionString* pItem = new OptionString(rCaption, "");
- pEntry->AddItem(pItem);
- return pEntry;
-}
-
void ScCalcOptionsDialog::setValueAt(size_t nPos, const OUString &rValue)
{
SvTreeList *pModel = mpLbSettings->GetModel();
@@ -333,7 +303,7 @@ void ScCalcOptionsDialog::fillOpenCLList()
namespace {
-void fillListBox(ListBox* pListBox, const std::set<ScCalcConfig::OpenCLImplementationMatcher>& rSet)
+void fillListBox(ListBox* pListBox, const std::set<ScCalcConfig::OpenCLImpl>& rSet)
{
pListBox->SetUpdateMode(false);
pListBox->Clear();
@@ -380,7 +350,7 @@ void ScCalcOptionsDialog::FillOptionsList()
addOption( pModel, pItem);
}
- pModel->Insert(createBoolItem(maCaptionEmptyStringAsZero,maConfig.mbEmptyStringAsZero));
+ pModel->Insert(createItem(maCaptionEmptyStringAsZero,toString(maConfig.mbEmptyStringAsZero)));
{
// Syntax for INDIRECT function.
@@ -390,12 +360,12 @@ void ScCalcOptionsDialog::FillOptionsList()
}
#if HAVE_FEATURE_OPENCL
- pModel->Insert(createBoolItem(maCaptionOpenCLEnabled,maConfig.mbOpenCLEnabled));
- pModel->Insert(createBoolItem(maCaptionOpenCLSubsetEnabled,maConfig.mbOpenCLSubsetOnly));
- pModel->Insert(createIntegerItem(maCaptionOpenCLMinimumFormulaSize,maConfig.mnOpenCLMinimumFormulaGroupSize));
- pModel->Insert(createStringItem(maCaptionOpenCLSubsetOpCodes,ScOpCodeSetToSymbolicString(maConfig.maOpenCLSubsetOpCodes)));
- pModel->Insert(createStringListItem(maCaptionOpenCLWhiteList));
- pModel->Insert(createStringListItem(maCaptionOpenCLBlackList));
+ pModel->Insert(createItem(maCaptionOpenCLEnabled,toString(maConfig.mbOpenCLEnabled)));
+ pModel->Insert(createItem(maCaptionOpenCLSubsetEnabled,toString(maConfig.mbOpenCLSubsetOnly)));
+ pModel->Insert(createItem(maCaptionOpenCLMinimumFormulaSize,toString(maConfig.mnOpenCLMinimumFormulaGroupSize)));
+ pModel->Insert(createItem(maCaptionOpenCLSubsetOpCodes,ScOpCodeSetToSymbolicString(maConfig.maOpenCLSubsetOpCodes)));
+ pModel->Insert(createItem(maCaptionOpenCLWhiteList,""));
+ pModel->Insert(createItem(maCaptionOpenCLBlackList,""));
fillOpenCLList();
@@ -871,15 +841,16 @@ IMPL_LINK(ScCalcOptionsDialog, OpenCLWhiteAndBlackListSelHdl, Control*, )
{
// We know this is called for the mpOpenCLWhiteAndBlackListBox
- std::set<ScCalcConfig::OpenCLImplementationMatcher>
- &m(mpLbSettings->GetSelectEntryPos() == CALC_OPTION_OPENCL_WHITELIST ? maConfig.maOpenCLWhiteList : maConfig.maOpenCLBlackList);
+ 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));
- mpOS->SetText(nth(m, n)->maOS);
- mpOSVersion->SetText(nth(m, n)->maOSVersion);
- mpPlatformVendor->SetText(nth(m, n)->maPlatformVendor);
- mpDevice->SetText(nth(m, n)->maDevice);
- mpDriverVersion->SetText(nth(m, n)->maDriverVersion);
+ mpOS->SetText(impl.maOS);
+ mpOSVersion->SetText(impl.maOSVersion);
+ mpPlatformVendor->SetText(impl.maPlatformVendor);
+ mpDevice->SetText(impl.maDevice);
+ mpDriverVersion->SetText(impl.maDriverVersion);
return 0;
}
diff --git a/sc/source/ui/optdlg/calcoptionsdlg.hxx b/sc/source/ui/optdlg/calcoptionsdlg.hxx
index a6ad5cd61835..45d8e5836f7f 100644
--- a/sc/source/ui/optdlg/calcoptionsdlg.hxx
+++ b/sc/source/ui/optdlg/calcoptionsdlg.hxx
@@ -62,10 +62,7 @@ private:
OUString toString(ScCalcConfig::StringConversion eConv) const;
OUString toString(bool bVal) const;
OUString toString(sal_Int32 nVal) const;
- SvTreeListEntry *createBoolItem(const OUString &rCaption, bool bValue) const;
- SvTreeListEntry *createIntegerItem(const OUString &rCaption, sal_Int32 nValue) const;
- SvTreeListEntry *createStringItem(const OUString &rCaption, const OUString& sValue) const;
- SvTreeListEntry *createStringListItem(const OUString &rCaption) const;
+ SvTreeListEntry *createItem(const OUString &rCaption, const OUString& sValue) const;
void setValueAt(size_t nPos, const OUString &rString);
private: