summaryrefslogtreecommitdiff
path: root/include/i18nlangtag
diff options
context:
space:
mode:
authorMichael Stahl <mstahl@redhat.com>2017-06-06 23:04:49 +0200
committerMichael Stahl <mstahl@redhat.com>2017-06-07 12:59:23 +0200
commit93a41b20538f18344eb1b8c23b1eae134212b141 (patch)
treefebaeaa7772bd1dd098365de0944a7300ba25f26 /include/i18nlangtag
parent26e7cb5ef4fa0df985214ef98622255cfdfbdd01 (diff)
tdf#108349: fix LanguageType conversions from UNO "short"
The bugdoc uses LANGUAGE_USER_LATIN_VATICAN LanguageType(0x8076). The UNO API uses signed "short" for these in various interfaces, and so the LanguageType constructor complains about out-of-(short)-range values. Avoid this by deleting the problematic constructor, so that the places that currently call it with API parameters can be changed to first cast the parameter to unsigned. (Yes, we need to write "template<>" twice in a row. Don't ask me why, i just work here. sberg says we also need to omit the explict <short>.) Change-Id: I2443a89bc8d579504fc707ded3d145f9a625597a Reviewed-on: https://gerrit.libreoffice.org/38473 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'include/i18nlangtag')
-rw-r--r--include/i18nlangtag/lang.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/include/i18nlangtag/lang.h b/include/i18nlangtag/lang.h
index 07cb601e9d78..cc87c8283b1b 100644
--- a/include/i18nlangtag/lang.h
+++ b/include/i18nlangtag/lang.h
@@ -95,6 +95,15 @@ struct LanguageTypeTag {};
typedef o3tl::strong_int<sal_uInt16, LanguageTypeTag> LanguageType;
inline std::ostream& operator<<(std::ostream& os, LanguageType const & lt) { os << sal_uInt16(lt); return os; }
constexpr LanguageType primary(LanguageType lt) { return LanguageType(sal_uInt16(lt) & 0x03ff); }
+
+namespace o3tl
+{
+ // delete "sal_Int16" constructor via specialization: values > 0x7FFF are
+ // actually used, and unfortunately passed around in the API as signed
+ // "short", so use this to find all places where casts must be inserted
+ template<> template<> constexpr strong_int<unsigned short,LanguageTypeTag>::strong_int(short, std::enable_if<std::is_integral<short>::value, int>::type) = delete;
+}
+
#endif
#define LANGUAGE_MASK_PRIMARY 0x03ff