summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/i18nlangtag/lang.h9
-rw-r--r--linguistic/source/spelldsp.cxx6
-rw-r--r--sw/source/filter/ww8/ww8scan.cxx8
-rw-r--r--unotools/source/config/lingucfg.cxx2
4 files changed, 17 insertions, 8 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
diff --git a/linguistic/source/spelldsp.cxx b/linguistic/source/spelldsp.cxx
index 404b350a05d7..5958d5980c60 100644
--- a/linguistic/source/spelldsp.cxx
+++ b/linguistic/source/spelldsp.cxx
@@ -757,7 +757,7 @@ sal_Bool SAL_CALL SpellCheckerDispatcher::hasLanguage(
sal_Int16 nLanguage )
{
MutexGuard aGuard( GetLinguMutex() );
- return hasLocale( LanguageTag::convertToLocale( LanguageType(nLanguage)) );
+ return hasLocale( LanguageTag::convertToLocale(LanguageType(static_cast<sal_uInt16>(nLanguage))));
}
@@ -767,7 +767,7 @@ sal_Bool SAL_CALL SpellCheckerDispatcher::isValid(
const uno::Sequence< beans::PropertyValue >& rProperties )
{
MutexGuard aGuard( GetLinguMutex() );
- return isValid( rWord, LanguageTag::convertToLocale( LanguageType(nLanguage) ), rProperties);
+ return isValid( rWord, LanguageTag::convertToLocale(LanguageType(static_cast<sal_uInt16>(nLanguage))), rProperties);
}
@@ -777,7 +777,7 @@ uno::Reference< linguistic2::XSpellAlternatives > SAL_CALL SpellCheckerDispatche
const uno::Sequence< beans::PropertyValue >& rProperties )
{
MutexGuard aGuard( GetLinguMutex() );
- return spell( rWord, LanguageTag::convertToLocale( LanguageType(nLanguage) ), rProperties);
+ return spell(rWord, LanguageTag::convertToLocale(LanguageType(static_cast<sal_uInt16>(nLanguage))), rProperties);
}
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index 2f28c36a2f22..c3154ffb064e 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -5530,8 +5530,8 @@ WW8Fib::WW8Fib(SvStream& rSt, sal_uInt8 nWantedVersion, sal_uInt32 nOffset)
sal_Int16 cpnBtePap_Ver67=0;
// read FIB
- sal_Int16 nTmpLid = 0;
- rSt.ReadInt16( nTmpLid );
+ sal_uInt16 nTmpLid = 0;
+ rSt.ReadUInt16(nTmpLid);
m_lid = LanguageType(nTmpLid);
rSt.ReadInt16( m_pnNext );
rSt.ReadUChar( aBits1 );
@@ -5578,8 +5578,8 @@ WW8Fib::WW8Fib(SvStream& rSt, sal_uInt8 nWantedVersion, sal_uInt32 nOffset)
&& (bVer67 || WW8ReadINT16( rSt, pnLvcFirst_W6 )) // 8
&& (bVer67 || WW8ReadINT16( rSt, cpnBteLvc_W6 )) // 9
*/
- sal_Int16 nTmpFE = 0;
- rSt.ReadInt16( nTmpFE );
+ sal_uInt16 nTmpFE = 0;
+ rSt.ReadUInt16(nTmpFE);
m_lidFE = LanguageType(nTmpFE);
rSt.ReadUInt16( m_clw );
}
diff --git a/unotools/source/config/lingucfg.cxx b/unotools/source/config/lingucfg.cxx
index 9dfc019b19ac..d11b9c62fd6f 100644
--- a/unotools/source/config/lingucfg.cxx
+++ b/unotools/source/config/lingucfg.cxx
@@ -524,7 +524,7 @@ bool SvtLinguConfigItem::SetProperty( sal_Int32 nPropertyHandle, const uno::Any
{
if (nNew != (sal_uInt16)*plVal)
{
- *plVal = LanguageType(nNew);
+ *plVal = LanguageType(static_cast<sal_uInt16>(nNew));
bMod = true;
}
bSucc = true;