include/docmodel/color/ComplexColor.hxx | 30 ++++++++++++++++++++++++++++++ include/docmodel/color/Transformation.hxx | 20 ++++++++++++++++++++ 2 files changed, 50 insertions(+)
New commits: commit a3d566165c0580ab41334cb3e031465df1f839ad Author: Tomaž Vajngerl <tomaz.vajng...@collabora.co.uk> AuthorDate: Thu May 18 14:48:30 2023 +0900 Commit: Tomaž Vajngerl <qui...@gmail.com> CommitDate: Sat May 20 11:54:28 2023 +0200 docmodel: add hash to ComplexColor and Transformation classes Change-Id: I206235162b057f184fbd413982c06f9bd9fa8a94 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/152013 Tested-by: Tomaž Vajngerl <qui...@gmail.com> Reviewed-by: Tomaž Vajngerl <qui...@gmail.com> 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: */