tdf#90341 Clean up excessive const_cast'ing
These changes improve const-correctness and reduce the need for const_cast usage. Change-Id: I1275edfbc0ca5d49a5e8339d1ed11148f6decd1e Reviewed-on: https://gerrit.libreoffice.org/c/core/+/174701 Tested-by: Jenkins Reviewed-by: Eike Rathke <erack@redhat.com>
This commit is contained in:
committed by
Eike Rathke
parent
44ace0cbca
commit
ad6f39b19c
@@ -317,12 +317,12 @@ private:
|
|||||||
bool isIsoODF() const;
|
bool isIsoODF() const;
|
||||||
bool isValidBcp47() const;
|
bool isValidBcp47() const;
|
||||||
|
|
||||||
void convertLocaleToBcp47();
|
void convertLocaleToBcp47() const;
|
||||||
bool convertLocaleToLang( bool bAllowOnTheFlyID );
|
bool convertLocaleToLang( bool bAllowOnTheFlyID );
|
||||||
void convertBcp47ToLocale();
|
void convertBcp47ToLocale();
|
||||||
void convertBcp47ToLang();
|
void convertBcp47ToLang();
|
||||||
void convertLangToLocale();
|
void convertLangToLocale() const;
|
||||||
void convertLangToBcp47();
|
void convertLangToBcp47() const;
|
||||||
|
|
||||||
/** @return whether BCP 47 language tag string was changed. */
|
/** @return whether BCP 47 language tag string was changed. */
|
||||||
bool canonicalize();
|
bool canonicalize();
|
||||||
@@ -1029,6 +1029,7 @@ LanguageTagImpl const * LanguageTag::getImpl() const
|
|||||||
return mpImpl.get();
|
return mpImpl.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
LanguageTagImpl * LanguageTag::getImpl()
|
LanguageTagImpl * LanguageTag::getImpl()
|
||||||
{
|
{
|
||||||
if (!mpImpl)
|
if (!mpImpl)
|
||||||
@@ -1039,6 +1040,7 @@ LanguageTagImpl * LanguageTag::getImpl()
|
|||||||
return mpImpl.get();
|
return mpImpl.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LanguageTag::resetVars()
|
void LanguageTag::resetVars()
|
||||||
{
|
{
|
||||||
mpImpl.reset();
|
mpImpl.reset();
|
||||||
@@ -1303,9 +1305,9 @@ bool LanguageTagImpl::synCanonicalize()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LanguageTag::syncFromImpl()
|
void LanguageTag::syncFromImpl() const
|
||||||
{
|
{
|
||||||
LanguageTagImpl* pImpl = getImpl();
|
const LanguageTagImpl* pImpl = getImpl();
|
||||||
bool bRegister = ((mbInitializedBcp47 && maBcp47 != pImpl->maBcp47) ||
|
bool bRegister = ((mbInitializedBcp47 && maBcp47 != pImpl->maBcp47) ||
|
||||||
(mbInitializedLangID && mnLangID != pImpl->mnLangID));
|
(mbInitializedLangID && mnLangID != pImpl->mnLangID));
|
||||||
SAL_INFO_IF( bRegister, "i18nlangtag",
|
SAL_INFO_IF( bRegister, "i18nlangtag",
|
||||||
@@ -1352,7 +1354,7 @@ bool LanguageTag::synCanonicalize()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LanguageTagImpl::convertLocaleToBcp47()
|
void LanguageTagImpl::convertLocaleToBcp47() const
|
||||||
{
|
{
|
||||||
if (mbSystemLocale && !mbInitializedLocale)
|
if (mbSystemLocale && !mbInitializedLocale)
|
||||||
convertLangToLocale();
|
convertLangToLocale();
|
||||||
@@ -1499,7 +1501,7 @@ void LanguageTag::convertBcp47ToLang()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LanguageTagImpl::convertLangToLocale()
|
void LanguageTagImpl::convertLangToLocale() const
|
||||||
{
|
{
|
||||||
if (mbSystemLocale && !mbInitializedLangID)
|
if (mbSystemLocale && !mbInitializedLangID)
|
||||||
{
|
{
|
||||||
@@ -1512,14 +1514,14 @@ void LanguageTagImpl::convertLangToLocale()
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LanguageTag::convertLangToLocale()
|
void LanguageTag::convertLangToLocale() const
|
||||||
{
|
{
|
||||||
getImpl()->convertLangToLocale();
|
getImpl()->convertLangToLocale();
|
||||||
syncFromImpl();
|
syncFromImpl();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void LanguageTagImpl::convertLangToBcp47()
|
void LanguageTagImpl::convertLangToBcp47() const
|
||||||
{
|
{
|
||||||
if (!mbInitializedLocale)
|
if (!mbInitializedLocale)
|
||||||
convertLangToLocale();
|
convertLangToLocale();
|
||||||
@@ -1573,9 +1575,9 @@ const OUString & LanguageTagImpl::getBcp47() const
|
|||||||
if (!mbInitializedBcp47)
|
if (!mbInitializedBcp47)
|
||||||
{
|
{
|
||||||
if (mbInitializedLocale)
|
if (mbInitializedLocale)
|
||||||
const_cast<LanguageTagImpl*>(this)->convertLocaleToBcp47();
|
convertLocaleToBcp47();
|
||||||
else
|
else
|
||||||
const_cast<LanguageTagImpl*>(this)->convertLangToBcp47();
|
convertLangToBcp47();
|
||||||
}
|
}
|
||||||
return maBcp47;
|
return maBcp47;
|
||||||
}
|
}
|
||||||
@@ -1592,7 +1594,7 @@ const OUString & LanguageTag::getBcp47( bool bResolveSystem ) const
|
|||||||
if (!mbInitializedBcp47)
|
if (!mbInitializedBcp47)
|
||||||
{
|
{
|
||||||
getImpl()->getBcp47();
|
getImpl()->getBcp47();
|
||||||
const_cast<LanguageTag*>(this)->syncFromImpl();
|
syncFromImpl();
|
||||||
}
|
}
|
||||||
return maBcp47;
|
return maBcp47;
|
||||||
}
|
}
|
||||||
@@ -1733,7 +1735,7 @@ const css::lang::Locale & LanguageTag::getLocale( bool bResolveSystem ) const
|
|||||||
if (mbInitializedBcp47)
|
if (mbInitializedBcp47)
|
||||||
const_cast<LanguageTag*>(this)->convertBcp47ToLocale();
|
const_cast<LanguageTag*>(this)->convertBcp47ToLocale();
|
||||||
else
|
else
|
||||||
const_cast<LanguageTag*>(this)->convertLangToLocale();
|
convertLangToLocale();
|
||||||
}
|
}
|
||||||
return maLocale;
|
return maLocale;
|
||||||
}
|
}
|
||||||
@@ -1864,7 +1866,7 @@ OUString LanguageTag::getLanguage() const
|
|||||||
if (pImpl->mbCachedLanguage)
|
if (pImpl->mbCachedLanguage)
|
||||||
return pImpl->maCachedLanguage;
|
return pImpl->maCachedLanguage;
|
||||||
OUString aRet( pImpl->getLanguage());
|
OUString aRet( pImpl->getLanguage());
|
||||||
const_cast<LanguageTag*>(this)->syncFromImpl();
|
syncFromImpl();
|
||||||
return aRet;
|
return aRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1886,7 +1888,7 @@ OUString LanguageTag::getScript() const
|
|||||||
if (pImpl->mbCachedScript)
|
if (pImpl->mbCachedScript)
|
||||||
return pImpl->maCachedScript;
|
return pImpl->maCachedScript;
|
||||||
OUString aRet( pImpl->getScript());
|
OUString aRet( pImpl->getScript());
|
||||||
const_cast<LanguageTag*>(this)->syncFromImpl();
|
syncFromImpl();
|
||||||
return aRet;
|
return aRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1922,7 +1924,7 @@ OUString LanguageTag::getCountry() const
|
|||||||
if (pImpl->mbCachedCountry)
|
if (pImpl->mbCachedCountry)
|
||||||
return pImpl->maCachedCountry;
|
return pImpl->maCachedCountry;
|
||||||
OUString aRet( pImpl->getCountry());
|
OUString aRet( pImpl->getCountry());
|
||||||
const_cast<LanguageTag*>(this)->syncFromImpl();
|
syncFromImpl();
|
||||||
return aRet;
|
return aRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1950,7 +1952,7 @@ OUString LanguageTag::getVariants() const
|
|||||||
if (pImpl->mbCachedVariants)
|
if (pImpl->mbCachedVariants)
|
||||||
return pImpl->maCachedVariants;
|
return pImpl->maCachedVariants;
|
||||||
OUString aRet( pImpl->getVariants());
|
OUString aRet( pImpl->getVariants());
|
||||||
const_cast<LanguageTag*>(this)->syncFromImpl();
|
syncFromImpl();
|
||||||
return aRet;
|
return aRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2011,7 +2013,7 @@ bool LanguageTagImpl::hasScript() const
|
|||||||
bool LanguageTag::hasScript() const
|
bool LanguageTag::hasScript() const
|
||||||
{
|
{
|
||||||
bool bRet = getImpl()->hasScript();
|
bool bRet = getImpl()->hasScript();
|
||||||
const_cast<LanguageTag*>(this)->syncFromImpl();
|
syncFromImpl();
|
||||||
return bRet;
|
return bRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2076,7 +2078,7 @@ bool LanguageTagImpl::isIsoLocale() const
|
|||||||
bool LanguageTag::isIsoLocale() const
|
bool LanguageTag::isIsoLocale() const
|
||||||
{
|
{
|
||||||
bool bRet = getImpl()->isIsoLocale();
|
bool bRet = getImpl()->isIsoLocale();
|
||||||
const_cast<LanguageTag*>(this)->syncFromImpl();
|
syncFromImpl();
|
||||||
return bRet;
|
return bRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2111,7 +2113,7 @@ bool LanguageTagImpl::isIsoODF() const
|
|||||||
bool LanguageTag::isIsoODF() const
|
bool LanguageTag::isIsoODF() const
|
||||||
{
|
{
|
||||||
bool bRet = getImpl()->isIsoODF();
|
bool bRet = getImpl()->isIsoODF();
|
||||||
const_cast<LanguageTag*>(this)->syncFromImpl();
|
syncFromImpl();
|
||||||
return bRet;
|
return bRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2131,7 +2133,7 @@ bool LanguageTagImpl::isValidBcp47() const
|
|||||||
bool LanguageTag::isValidBcp47() const
|
bool LanguageTag::isValidBcp47() const
|
||||||
{
|
{
|
||||||
bool bRet = getImpl()->isValidBcp47();
|
bool bRet = getImpl()->isValidBcp47();
|
||||||
const_cast<LanguageTag*>(this)->syncFromImpl();
|
syncFromImpl();
|
||||||
return bRet;
|
return bRet;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -569,16 +569,16 @@ private:
|
|||||||
bool mbIsFallback : 1;
|
bool mbIsFallback : 1;
|
||||||
|
|
||||||
LanguageTagImpl* getImpl();
|
LanguageTagImpl* getImpl();
|
||||||
LanguageTagImpl const* getImpl() const;
|
LanguageTagImpl const * getImpl() const;
|
||||||
ImplPtr registerImpl() const;
|
ImplPtr registerImpl() const;
|
||||||
void syncFromImpl();
|
void syncFromImpl() const;
|
||||||
void syncVarsFromRawImpl() const;
|
void syncVarsFromRawImpl() const;
|
||||||
void syncVarsFromImpl() const;
|
void syncVarsFromImpl() const;
|
||||||
|
|
||||||
void convertLocaleToLang();
|
void convertLocaleToLang();
|
||||||
void convertBcp47ToLocale();
|
void convertBcp47ToLocale();
|
||||||
void convertBcp47ToLang();
|
void convertBcp47ToLang();
|
||||||
void convertLangToLocale();
|
void convertLangToLocale() const;
|
||||||
|
|
||||||
void convertFromRtlLocale();
|
void convertFromRtlLocale();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user