summaryrefslogtreecommitdiff
path: root/vcl/inc
diff options
context:
space:
mode:
authorTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2019-01-25 23:10:57 +0100
committerTomaž Vajngerl <tomaz.vajngerl@collabora.co.uk>2019-08-29 20:10:47 +0900
commitdc8059d9ca1d7fc0ea241df73c16bb2a2bf2cce5 (patch)
tree77e5480c3613511a62b3553752f88d3db8a1715a /vcl/inc
parentb1fe787403bfb4bce2e18f2c7bd357be0b6a9406 (diff)
Refactor so we have only one definition map and ControlTypeAndPart
Until now we had multiple maps, each for a specific ControlType (maPushButtonDefinitions for example) which had multiple parts identified by the string. To simplify matters, this changes that we have just one map for a specific ControlType and ControlPart which are identified by ControlTypeAndPart structure. Change-Id: I90a2e5c8f83d697d26049054eacab250e2768c03 Reviewed-on: https://gerrit.libreoffice.org/68690 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl <quikee@gmail.com> (cherry picked from commit 9671ac2dac00c21ae840cb29c2671b22ab95a7b2)
Diffstat (limited to 'vcl/inc')
-rw-r--r--vcl/inc/widgetdraw/WidgetDefinition.hxx48
-rw-r--r--vcl/inc/widgetdraw/WidgetDefinitionReader.hxx5
2 files changed, 43 insertions, 10 deletions
diff --git a/vcl/inc/widgetdraw/WidgetDefinition.hxx b/vcl/inc/widgetdraw/WidgetDefinition.hxx
index 423ab1d970c3..486d61802654 100644
--- a/vcl/inc/widgetdraw/WidgetDefinition.hxx
+++ b/vcl/inc/widgetdraw/WidgetDefinition.hxx
@@ -17,6 +17,9 @@
#include <tools/color.hxx>
#include <unordered_map>
#include <vector>
+#include <cstddef>
+#include <functional>
+#include <boost/functional/hash.hpp>
#include <vcl/salnativewidgets.hxx>
namespace vcl
@@ -83,6 +86,42 @@ public:
}
};
+struct VCL_DLLPUBLIC ControlTypeAndPart
+{
+ ControlType const meType;
+ ControlPart const mePart;
+
+ ControlTypeAndPart(ControlType eType, ControlPart ePart)
+ : meType(eType)
+ , mePart(ePart)
+ {
+ }
+
+ bool operator==(ControlTypeAndPart const& aOther) const
+ {
+ return meType == aOther.meType && mePart == aOther.mePart;
+ }
+};
+
+} // end vcl namespace
+
+namespace std
+{
+template <> struct VCL_DLLPUBLIC hash<vcl::ControlTypeAndPart>
+{
+ std::size_t operator()(vcl::ControlTypeAndPart const& rControlTypeAndPart) const noexcept
+ {
+ std::size_t seed = 0;
+ boost::hash_combine(seed, rControlTypeAndPart.meType);
+ boost::hash_combine(seed, rControlTypeAndPart.mePart);
+ return seed;
+ }
+};
+
+} // end std namespace
+
+namespace vcl
+{
class VCL_DLLPUBLIC WidgetDefinitionState
{
public:
@@ -171,13 +210,8 @@ public:
Color maToolTextColor;
Color maFontColor;
- std::unordered_map<OString, std::shared_ptr<WidgetDefinitionPart>> maPushButtonDefinitions;
- std::unordered_map<OString, std::shared_ptr<WidgetDefinitionPart>> maRadioButtonDefinitions;
- std::unordered_map<OString, std::shared_ptr<WidgetDefinitionPart>> maEditboxDefinitions;
-
- std::shared_ptr<WidgetDefinitionPart> getPushButtonDefinition(ControlPart ePart);
- std::shared_ptr<WidgetDefinitionPart> getRadioButtonDefinition(ControlPart ePart);
- std::shared_ptr<WidgetDefinitionPart> getEditboxDefinition(ControlPart ePart);
+ std::unordered_map<ControlTypeAndPart, std::shared_ptr<WidgetDefinitionPart>> maDefinitions;
+ std::shared_ptr<WidgetDefinitionPart> getDefinition(ControlType eType, ControlPart ePart);
};
} // end vcl namespace
diff --git a/vcl/inc/widgetdraw/WidgetDefinitionReader.hxx b/vcl/inc/widgetdraw/WidgetDefinitionReader.hxx
index 1cb577c08c4d..53da5e1a3bed 100644
--- a/vcl/inc/widgetdraw/WidgetDefinitionReader.hxx
+++ b/vcl/inc/widgetdraw/WidgetDefinitionReader.hxx
@@ -24,9 +24,8 @@ class VCL_DLLPUBLIC WidgetDefinitionReader
private:
OUString m_rFilePath;
- static void
- readDefinition(tools::XmlWalker& rWalker,
- std::unordered_map<OString, std::shared_ptr<WidgetDefinitionPart>>& rDefinition);
+ static void readDefinition(tools::XmlWalker& rWalker, WidgetDefinition& rWidgetDefinition,
+ ControlType eType);
static void readPart(tools::XmlWalker& rWalker, std::shared_ptr<WidgetDefinitionPart> rpPart);