diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-01-28 15:17:04 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2022-01-29 18:59:53 +0100 |
commit | c3d5c9a08df77f9c0d0fd2493cf299dbad1a9dff (patch) | |
tree | f448517b6031741ab182685f3cf8ee332deac2f4 /include/svl | |
parent | 58c849a94234f18eac020be66117aa2378487e2f (diff) |
used TypedWhichId in the constructor of various svx *Item classes
to act as an extra check that we have the association of Item and
TypedWhichId annotations correct.
(*) requires that I add an upcasting constructor to TypedWhichId
(*) Make the field dialog stuff in writer use a new item id
FN_FIELD_DIALOG_DOC_PROPS instead of abusing the
existing SID_DOCINFO
Change-Id: Ica4aea930c80124609a063768c9af5a189df1c27
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129098
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include/svl')
-rw-r--r-- | include/svl/typedwhich.hxx | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/include/svl/typedwhich.hxx b/include/svl/typedwhich.hxx index d3f2bedec671..cb9efabd59fc 100644 --- a/include/svl/typedwhich.hxx +++ b/include/svl/typedwhich.hxx @@ -11,6 +11,7 @@ #include <sal/config.h> #include <sal/types.h> +#include <type_traits> /** * A very thin wrapper around the sal_uInt16 WhichId whose purpose is mostly to carry type information, @@ -23,10 +24,20 @@ public: : mnWhich(nWhich) { } + + /** Up-casting conversion constructor + */ + template <class derived_type> + constexpr TypedWhichId(TypedWhichId<derived_type> other, + std::enable_if_t<std::is_base_of_v<T, derived_type>, int> = 0) + : mnWhich(sal_uInt16(other)) + { + } + constexpr operator sal_uInt16() const { return mnWhich; } private: - sal_uInt16 const mnWhich; + sal_uInt16 mnWhich; }; template <class T> constexpr bool operator==(sal_uInt16 lhs, TypedWhichId<T> const& rhs) |