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 3e37953868cc..e5d4a1f42b3f 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 d26993cabb5f..cd893ef654ab 100644
--- a/linguistic/source/spelldsp.cxx
+++ b/linguistic/source/spelldsp.cxx
@@ -756,7 +756,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))));
}
@@ -766,7 +766,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);
}
@@ -776,7 +776,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 fabae0651e6e..f71618f56044 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -5531,8 +5531,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 );
@@ -5579,8 +5579,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;