diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/o3tl/typed_flags_set.hxx | 73 | ||||
-rw-r--r-- | include/svx/dlgutil.hxx | 4 |
2 files changed, 55 insertions, 22 deletions
diff --git a/include/o3tl/typed_flags_set.hxx b/include/o3tl/typed_flags_set.hxx index 4755c09fb536..9b8cb817ee02 100644 --- a/include/o3tl/typed_flags_set.hxx +++ b/include/o3tl/typed_flags_set.hxx @@ -25,18 +25,21 @@ #include <cassert> #include <type_traits> +#include <config_global.h> +#include <sal/types.h> + namespace o3tl { namespace detail { -template<typename T> inline +template<typename T> inline SAL_CONSTEXPR typename std::enable_if<std::is_signed<T>::value, bool>::type isNonNegative( T value) { return value >= 0; } -template<typename T> inline +template<typename T> inline SAL_CONSTEXPR typename std::enable_if<std::is_unsigned<T>::value, bool>::type isNonNegative(T) { return true; @@ -70,19 +73,23 @@ struct is_typed_flags { public: typedef is_typed_flags Unwrapped; - explicit Wrap(typename std::underlying_type<E>::type value): + explicit SAL_CONSTEXPR Wrap( + typename std::underlying_type<E>::type value): value_(value) { +#if !HAVE_CXX11_CONSTEXPR || HAVE_CXX14_CONSTEXPR assert(detail::isNonNegative(value)); assert((value & ~M) == 0); +#endif } - operator E() { return static_cast<E>(value_); } + SAL_CONSTEXPR operator E() const { return static_cast<E>(value_); } - explicit operator typename std::underlying_type<E>::type() + explicit SAL_CONSTEXPR operator typename std::underlying_type<E>::type() + const { return value_; } - explicit operator bool() { return value_ != 0; } + explicit SAL_CONSTEXPR operator bool() const { return value_ != 0; } private: typename std::underlying_type<E>::type value_; @@ -94,17 +101,19 @@ struct is_typed_flags { } template<typename E> -inline typename o3tl::typed_flags<E>::Wrap operator ~(E rhs) { +inline SAL_CONSTEXPR typename o3tl::typed_flags<E>::Wrap operator ~(E rhs) { +#if !HAVE_CXX11_CONSTEXPR || HAVE_CXX14_CONSTEXPR assert( o3tl::detail::isNonNegative( static_cast<typename std::underlying_type<E>::type>(rhs))); +#endif return static_cast<typename o3tl::typed_flags<E>::Wrap>( o3tl::typed_flags<E>::mask & ~static_cast<typename std::underlying_type<E>::type>(rhs)); } template<typename E> -inline typename o3tl::typed_flags<E>::Wrap operator ~( +inline SAL_CONSTEXPR typename o3tl::typed_flags<E>::Wrap operator ~( typename o3tl::typed_flags<E>::Wrap rhs) { return static_cast<typename o3tl::typed_flags<E>::Wrap>( @@ -113,44 +122,53 @@ inline typename o3tl::typed_flags<E>::Wrap operator ~( } template<typename E> -inline typename o3tl::typed_flags<E>::Wrap operator ^(E lhs, E rhs) { +inline SAL_CONSTEXPR typename o3tl::typed_flags<E>::Wrap operator ^( + E lhs, E rhs) +{ +#if !HAVE_CXX11_CONSTEXPR || HAVE_CXX14_CONSTEXPR assert( o3tl::detail::isNonNegative( static_cast<typename std::underlying_type<E>::type>(lhs))); assert( o3tl::detail::isNonNegative( static_cast<typename std::underlying_type<E>::type>(rhs))); +#endif return static_cast<typename o3tl::typed_flags<E>::Wrap>( static_cast<typename std::underlying_type<E>::type>(lhs) ^ static_cast<typename std::underlying_type<E>::type>(rhs)); } template<typename E> -inline typename o3tl::typed_flags<E>::Wrap operator ^( +inline SAL_CONSTEXPR typename o3tl::typed_flags<E>::Wrap operator ^( E lhs, typename o3tl::typed_flags<E>::Wrap rhs) { +#if !HAVE_CXX11_CONSTEXPR || HAVE_CXX14_CONSTEXPR assert( o3tl::detail::isNonNegative( static_cast<typename std::underlying_type<E>::type>(lhs))); +#endif return static_cast<typename o3tl::typed_flags<E>::Wrap>( static_cast<typename std::underlying_type<E>::type>(lhs) ^ static_cast<typename std::underlying_type<E>::type>(rhs)); } template<typename E> -inline typename o3tl::typed_flags<E>::Wrap operator ^( +inline SAL_CONSTEXPR typename o3tl::typed_flags<E>::Wrap operator ^( typename o3tl::typed_flags<E>::Wrap lhs, E rhs) { +#if !HAVE_CXX11_CONSTEXPR || HAVE_CXX14_CONSTEXPR assert( o3tl::detail::isNonNegative( static_cast<typename std::underlying_type<E>::type>(rhs))); +#endif return static_cast<typename o3tl::typed_flags<E>::Wrap>( static_cast<typename std::underlying_type<E>::type>(lhs) ^ static_cast<typename std::underlying_type<E>::type>(rhs)); } template<typename W> -inline typename o3tl::typed_flags<typename W::Unwrapped::Self>::Wrap operator ^( +inline SAL_CONSTEXPR +typename o3tl::typed_flags<typename W::Unwrapped::Self>::Wrap operator ^( W lhs, W rhs) { return static_cast<W>( @@ -163,44 +181,53 @@ inline typename o3tl::typed_flags<typename W::Unwrapped::Self>::Wrap operator ^( } template<typename E> -inline typename o3tl::typed_flags<E>::Wrap operator &(E lhs, E rhs) { +inline SAL_CONSTEXPR typename o3tl::typed_flags<E>::Wrap operator &( + E lhs, E rhs) +{ +#if !HAVE_CXX11_CONSTEXPR || HAVE_CXX14_CONSTEXPR assert( o3tl::detail::isNonNegative( static_cast<typename std::underlying_type<E>::type>(lhs))); assert( o3tl::detail::isNonNegative( static_cast<typename std::underlying_type<E>::type>(rhs))); +#endif return static_cast<typename o3tl::typed_flags<E>::Wrap>( static_cast<typename std::underlying_type<E>::type>(lhs) & static_cast<typename std::underlying_type<E>::type>(rhs)); } template<typename E> -inline typename o3tl::typed_flags<E>::Wrap operator &( +inline SAL_CONSTEXPR typename o3tl::typed_flags<E>::Wrap operator &( E lhs, typename o3tl::typed_flags<E>::Wrap rhs) { +#if !HAVE_CXX11_CONSTEXPR || HAVE_CXX14_CONSTEXPR assert( o3tl::detail::isNonNegative( static_cast<typename std::underlying_type<E>::type>(lhs))); +#endif return static_cast<typename o3tl::typed_flags<E>::Wrap>( static_cast<typename std::underlying_type<E>::type>(lhs) & static_cast<typename std::underlying_type<E>::type>(rhs)); } template<typename E> -inline typename o3tl::typed_flags<E>::Wrap operator &( +inline SAL_CONSTEXPR typename o3tl::typed_flags<E>::Wrap operator &( typename o3tl::typed_flags<E>::Wrap lhs, E rhs) { +#if !HAVE_CXX11_CONSTEXPR || HAVE_CXX14_CONSTEXPR assert( o3tl::detail::isNonNegative( static_cast<typename std::underlying_type<E>::type>(rhs))); +#endif return static_cast<typename o3tl::typed_flags<E>::Wrap>( static_cast<typename std::underlying_type<E>::type>(lhs) & static_cast<typename std::underlying_type<E>::type>(rhs)); } template<typename W> -inline typename o3tl::typed_flags<typename W::Unwrapped::Self>::Wrap operator &( +inline SAL_CONSTEXPR +typename o3tl::typed_flags<typename W::Unwrapped::Self>::Wrap operator &( W lhs, W rhs) { return static_cast<W>( @@ -213,44 +240,50 @@ inline typename o3tl::typed_flags<typename W::Unwrapped::Self>::Wrap operator &( } template<typename E> -inline typename o3tl::typed_flags<E>::Wrap operator |(E lhs, E rhs) { +inline SAL_CONSTEXPR typename o3tl::typed_flags<E>::Wrap operator |(E lhs, E rhs) { +#if !HAVE_CXX11_CONSTEXPR || HAVE_CXX14_CONSTEXPR assert( o3tl::detail::isNonNegative( static_cast<typename std::underlying_type<E>::type>(lhs))); assert( o3tl::detail::isNonNegative( static_cast<typename std::underlying_type<E>::type>(rhs))); +#endif return static_cast<typename o3tl::typed_flags<E>::Wrap>( static_cast<typename std::underlying_type<E>::type>(lhs) | static_cast<typename std::underlying_type<E>::type>(rhs)); } template<typename E> -inline typename o3tl::typed_flags<E>::Wrap operator |( +inline SAL_CONSTEXPR typename o3tl::typed_flags<E>::Wrap operator |( E lhs, typename o3tl::typed_flags<E>::Wrap rhs) { +#if !HAVE_CXX11_CONSTEXPR || HAVE_CXX14_CONSTEXPR assert( o3tl::detail::isNonNegative( static_cast<typename std::underlying_type<E>::type>(lhs))); +#endif return static_cast<typename o3tl::typed_flags<E>::Wrap>( static_cast<typename std::underlying_type<E>::type>(lhs) | static_cast<typename std::underlying_type<E>::type>(rhs)); } template<typename E> -inline typename o3tl::typed_flags<E>::Wrap operator |( +inline SAL_CONSTEXPR typename o3tl::typed_flags<E>::Wrap operator |( typename o3tl::typed_flags<E>::Wrap lhs, E rhs) { +#if !HAVE_CXX11_CONSTEXPR || HAVE_CXX14_CONSTEXPR assert( o3tl::detail::isNonNegative( static_cast<typename std::underlying_type<E>::type>(rhs))); +#endif return static_cast<typename o3tl::typed_flags<E>::Wrap>( static_cast<typename std::underlying_type<E>::type>(lhs) | static_cast<typename std::underlying_type<E>::type>(rhs)); } template<typename W> -inline typename o3tl::typed_flags<typename W::Unwrapped::Self>::Wrap operator |( +inline SAL_CONSTEXPR typename o3tl::typed_flags<typename W::Unwrapped::Self>::Wrap operator |( W lhs, W rhs) { return static_cast<W>( diff --git a/include/svx/dlgutil.hxx b/include/svx/dlgutil.hxx index c60fd93ca35f..284d3554cdbb 100644 --- a/include/svx/dlgutil.hxx +++ b/include/svx/dlgutil.hxx @@ -33,8 +33,8 @@ SVX_DLLPUBLIC FieldUnit GetModuleFieldUnit( const SfxItemSet& ); SVX_DLLPUBLIC FieldUnit GetModuleFieldUnit(); SVX_DLLPUBLIC bool GetApplyCharUnit( const SfxItemSet& ); -#define OUTPUT_DRAWMODE_COLOR DrawModeFlags::Default -#define OUTPUT_DRAWMODE_CONTRAST (DrawModeFlags::SettingsLine | DrawModeFlags::SettingsFill | DrawModeFlags::SettingsText | DrawModeFlags::SettingsGradient) +SAL_CONSTEXPR DrawModeFlags const OUTPUT_DRAWMODE_COLOR = DrawModeFlags::Default; +SAL_CONSTEXPR DrawModeFlags const OUTPUT_DRAWMODE_CONTRAST = DrawModeFlags::SettingsLine | DrawModeFlags::SettingsFill | DrawModeFlags::SettingsText | DrawModeFlags::SettingsGradient; #endif |