summaryrefslogtreecommitdiff
path: root/include/tools
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2021-01-20 11:29:18 +0100
committerStephan Bergmann <sbergman@redhat.com>2021-01-21 07:58:02 +0100
commitaf34108d90bbbce90cf00c4b23961787599c7fa5 (patch)
treede3130c4d4fd8e5f163d084f87f750188297235b /include/tools
parente64784c4e8775d0c831ad71c70e73854a4b9aaa4 (diff)
Use C++20 consteval for the Color(sal_uInt32) ctor
...to make it more obvious that, since 63a68064bb33f180b8a231f7524d99405d910226 "make the Color constructors explicitly specify transparency", it should only be called when the argument is known at compile-time to have no transparency/alpha channel. (This revealed a GCC bug causing bogus > xmloff/source/chart/ColorPropertySet.cxx: In constructor ‘xmloff::chart::ColorPropertySet::ColorPropertySet(Color)’: > xmloff/source/chart/ColorPropertySet.cxx:81:9: error: ‘this’ is not a constant expression > 81 | m_nDefaultColor( 0x0099ccff ) // blue 8 > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ so in configure.ac suppress HAVE_CPP_CONSTEVAL when the compiler is found broken.) Change-Id: I68df7bd5fbd9b2dcf2243b5a4bde4064d3d665fd Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109697 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'include/tools')
-rw-r--r--include/tools/color.hxx10
1 files changed, 8 insertions, 2 deletions
diff --git a/include/tools/color.hxx b/include/tools/color.hxx
index 209ed34169a8..cd472fd472ee 100644
--- a/include/tools/color.hxx
+++ b/include/tools/color.hxx
@@ -22,6 +22,7 @@
#include <sal/types.h>
#include <tools/toolsdllapi.h>
#include <com/sun/star/uno/Any.hxx>
+#include <config_global.h>
#include <basegfx/color/bcolor.hxx>
#include <osl/endian.h>
@@ -72,7 +73,12 @@ public:
: mValue(0) // black
{}
- constexpr Color(const sal_uInt32 nColor)
+#if HAVE_CPP_CONSTEVAL
+ consteval
+#else
+ constexpr
+#endif
+ Color(const sal_uInt32 nColor)
: mValue(nColor)
{
assert(nColor <= 0xffffff && "don't pass transparency to this constructor, use the Color(ColorTransparencyTag,...) or Color(ColorAlphaTag,...) constructor to make it explicit");
@@ -211,7 +217,7 @@ public:
*/
Color GetRGBColor() const
{
- return mValue & 0x00FFFFFF;
+ return {R, G, B};
}
/* Comparison and operators */