diff options
author | Tomaž Vajngerl <tomaz.vajngerl@collabora.co.uk> | 2023-05-18 14:48:30 +0900 |
---|---|---|
committer | Tomaž Vajngerl <quikee@gmail.com> | 2023-05-20 11:54:28 +0200 |
commit | a3d566165c0580ab41334cb3e031465df1f839ad (patch) | |
tree | 92b8144aabae4de8b68ba14c9d2a937be69a05f4 /include | |
parent | c53a8284cf1740af7035b952fbc040a785117319 (diff) |
docmodel: add hash to ComplexColor and Transformation classes
Change-Id: I206235162b057f184fbd413982c06f9bd9fa8a94
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152013
Tested-by: Tomaž Vajngerl <quikee@gmail.com>
Reviewed-by: Tomaž Vajngerl <quikee@gmail.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/docmodel/color/ComplexColor.hxx | 30 | ||||
-rw-r--r-- | include/docmodel/color/Transformation.hxx | 20 |
2 files changed, 50 insertions, 0 deletions
diff --git a/include/docmodel/color/ComplexColor.hxx b/include/docmodel/color/ComplexColor.hxx index 471c6b30e4d1..d43318cdbe65 100644 --- a/include/docmodel/color/ComplexColor.hxx +++ b/include/docmodel/color/ComplexColor.hxx @@ -14,6 +14,7 @@ #include <tools/color.hxx> #include <docmodel/theme/ThemeColor.hxx> #include <com/sun/star/graphic/XGraphic.hpp> +#include <o3tl/hash_combine.hxx> namespace model { @@ -89,6 +90,8 @@ public: ThemeColorType meSchemeType = ThemeColorType::Unknown; std::vector<Transformation> maTransformations; + ::Color maFinalColor; + public: ColorType getType() const { return meType; } @@ -210,8 +213,35 @@ public: } return aColor; } + + void setFinalColor(Color const& rColor) { maFinalColor = rColor; } + + Color const& getFinalColor() const { return maFinalColor; } + + std::size_t getHash() const + { + std::size_t seed = 0; + o3tl::hash_combine(seed, meType); + o3tl::hash_combine(seed, mnComponent1); + o3tl::hash_combine(seed, mnComponent2); + o3tl::hash_combine(seed, mnComponent3); + o3tl::hash_combine(seed, meSystemColorType); + o3tl::hash_combine(seed, sal_uInt32(maLastColor)); + for (auto const& rTransform : maTransformations) + o3tl::hash_combine(seed, rTransform); + o3tl::hash_combine(seed, sal_uInt32(maFinalColor)); + return seed; + } }; } // end of namespace svx +namespace std +{ +template <> struct hash<model::ComplexColor> +{ + std::size_t operator()(model::ComplexColor const& rColor) const { return rColor.getHash(); } +}; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/docmodel/color/Transformation.hxx b/include/docmodel/color/Transformation.hxx index 26f618dee289..7a05d88aa9e9 100644 --- a/include/docmodel/color/Transformation.hxx +++ b/include/docmodel/color/Transformation.hxx @@ -12,6 +12,7 @@ #include <docmodel/dllapi.h> #include <vector> +#include <o3tl/hash_combine.hxx> namespace model { @@ -65,8 +66,27 @@ struct DOCMODEL_DLLPUBLIC Transformation { return meType == rTransformation.meType && mnValue == rTransformation.mnValue; } + + std::size_t getHash() const + { + std::size_t seed = 0; + o3tl::hash_combine(seed, meType); + o3tl::hash_combine(seed, mnValue); + return seed; + } }; } // end of namespace model +namespace std +{ +template <> struct hash<model::Transformation> +{ + std::size_t operator()(model::Transformation const& rTransformation) const + { + return rTransformation.getHash(); + } +}; +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |