diff options
Diffstat (limited to 'include/oox/helper/helper.hxx')
-rw-r--r-- | include/oox/helper/helper.hxx | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/include/oox/helper/helper.hxx b/include/oox/helper/helper.hxx index 5a83c3780bc8..168116b9db84 100644 --- a/include/oox/helper/helper.hxx +++ b/include/oox/helper/helper.hxx @@ -25,6 +25,7 @@ #include <cstring> #include <limits> +#include <o3tl/safeint.hxx> #include <osl/endian.h> #include <rtl/math.hxx> #include <rtl/textenc.h> @@ -36,10 +37,24 @@ namespace oox { // Helper macros ============================================================== +namespace detail { + +//TODO: Temporary helper for STATIC_ARRAY_SELECT; ultimately, the latter should be replaced by a +// proper function (template): +template<typename T> constexpr std::make_unsigned_t<T> make_unsigned(T value) { + if constexpr (std::is_signed_v<T>) { + return o3tl::make_unsigned(value); + } else { + return value; + } +} + +} + /** Expands to the 'index'-th element of a STATIC data array, or to 'def', if 'index' is out of the array limits. */ #define STATIC_ARRAY_SELECT( array, index, def ) \ - ((static_cast<size_t>(index) < SAL_N_ELEMENTS(array)) ? ((array)[static_cast<size_t>(index)]) : (def)) + ((detail::make_unsigned(index) < SAL_N_ELEMENTS(array)) ? ((array)[static_cast<size_t>(index)]) : (def)) // Common constants =========================================================== |