Kaydet (Commit) eb5d2323 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:constantparam in i18nlangtag

Change-Id: I148a47a9b63b78651ec18cd947f45b8f4dbb9345
Reviewed-on: https://gerrit.libreoffice.org/44094Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 33a3de2f
......@@ -144,26 +144,20 @@ LanguageType MsLangId::resolveSystemLanguageByScriptType( LanguageType nLang, sa
// static
css::lang::Locale MsLangId::Conversion::convertLanguageToLocale(
LanguageType nLang, bool bResolveSystem )
LanguageType nLang )
{
css::lang::Locale aLocale;
if (!bResolveSystem && simplifySystemLanguages( nLang) == LANGUAGE_SYSTEM)
; // nothing => empty locale
else
// Still resolve LANGUAGE_DONTKNOW if resolving is not requested,
// but not LANGUAGE_SYSTEM or others.
LanguageType nOrigLang = nLang;
nLang = MsLangId::getRealLanguage(nLang);
convertLanguageToLocaleImpl( nLang, aLocale, true );
if (aLocale.Language.isEmpty() && simplifySystemLanguages(nOrigLang) == LANGUAGE_SYSTEM)
{
// Still resolve LANGUAGE_DONTKNOW if resolving is not requested,
// but not LANGUAGE_SYSTEM or others.
LanguageType nOrigLang = nLang;
if (bResolveSystem || nLang == LANGUAGE_DONTKNOW)
nLang = MsLangId::getRealLanguage( nLang);
convertLanguageToLocaleImpl( nLang, aLocale, true);
if (bResolveSystem && aLocale.Language.isEmpty() && simplifySystemLanguages( nOrigLang) == LANGUAGE_SYSTEM)
{
// None found but resolve requested, last resort is "en-US".
aLocale.Language = "en";
aLocale.Country = "US";
aLocale.Variant.clear();
}
// None found but resolve requested, last resort is "en-US".
aLocale.Language = "en";
aLocale.Country = "US";
aLocale.Variant.clear();
}
return aLocale;
}
......@@ -187,7 +181,7 @@ css::lang::Locale MsLangId::getFallbackLocale(
{
// empty language => LANGUAGE_SYSTEM
if (rLocale.Language.isEmpty())
return Conversion::lookupFallbackLocale( Conversion::convertLanguageToLocale( LANGUAGE_SYSTEM, true));
return Conversion::lookupFallbackLocale( Conversion::convertLanguageToLocale( LANGUAGE_SYSTEM ));
else
return Conversion::lookupFallbackLocale( rLocale);
}
......
......@@ -961,7 +961,7 @@ LanguageTag::ImplPtr LanguageTag::registerImpl() const
// May have involved canonicalize(), so compare with
// pImpl->maBcp47 instead of maBcp47!
aBcp47 = LanguageTagImpl::convertToBcp47(
MsLangId::Conversion::convertLanguageToLocale( pImpl->mnLangID, true));
MsLangId::Conversion::convertLanguageToLocale( pImpl->mnLangID ));
bInsert = (aBcp47 == pImpl->maBcp47);
}
}
......@@ -1344,7 +1344,7 @@ void LanguageTagImpl::convertLocaleToBcp47()
// locale via LanguageTag::convertToBcp47(LanguageType) and
// LanguageTag::convertToLocale(LanguageType) would instantiate another
// LanguageTag.
maLocale = MsLangId::Conversion::convertLanguageToLocale( LANGUAGE_SYSTEM, true);
maLocale = MsLangId::Conversion::convertLanguageToLocale( LANGUAGE_SYSTEM );
}
if (maLocale.Language.isEmpty())
{
......@@ -1488,7 +1488,7 @@ void LanguageTagImpl::convertLangToLocale()
mbInitializedLangID = true;
}
// Resolve system here! The original is remembered as mbSystemLocale.
maLocale = MsLangId::Conversion::convertLanguageToLocale( mnLangID, true);
maLocale = MsLangId::Conversion::convertLanguageToLocale( mnLangID );
mbInitializedLocale = true;
}
......
......@@ -267,15 +267,9 @@ public:
const Bcp47CountryEntry * pEntry );
/** Convert a LanguageType to a Locale.
@param bResolveSystem
If bResolveSystem==true, a LANGUAGE_SYSTEM is resolved.
If bResolveSystem==false, a LANGUAGE_SYSTEM results in an
empty Locale.
*/
/** Convert a LanguageType to a Locale. */
I18NLANGTAG_DLLPRIVATE static css::lang::Locale convertLanguageToLocale(
LanguageType nLang, bool bResolveSystem );
LanguageType nLang );
/** Used by convertLanguageToLocale(LanguageType,bool) and
getLocale(IsoLanguageCountryEntry*) and
......
......@@ -41,8 +41,7 @@ namespace linguistic
std::vector< OUString >
MergeProposalSeqs(
std::vector< OUString > &rAlt1,
std::vector< OUString > &rAlt2,
bool bAllowDuplicates );
std::vector< OUString > &rAlt2 );
void SeqRemoveNegEntries(
std::vector< OUString > &rSeq,
......
......@@ -48,7 +48,7 @@ namespace jfw
{
OString getElement(OString const & docPath,
xmlChar const * pathExpression, bool bThrowIfEmpty)
xmlChar const * pathExpression)
{
//Prepare the xml document and context
OSL_ASSERT(!docPath.isEmpty());
......@@ -70,10 +70,9 @@ OString getElement(OString const & docPath,
OString sValue;
if (xmlXPathNodeSetIsEmpty(pathObj->nodesetval))
{
if (bThrowIfEmpty)
throw FrameworkException(
JFW_E_ERROR,
"[Java framework] Error in function getElement (elements.cxx)");
throw FrameworkException(
JFW_E_ERROR,
"[Java framework] Error in function getElement (elements.cxx)");
}
else
{
......@@ -85,7 +84,7 @@ OString getElement(OString const & docPath,
OString getElementUpdated()
{
return getElement(jfw::getVendorSettingsPath(),
reinterpret_cast<xmlChar const *>("/jf:javaSelection/jf:updated/text()"), true);
reinterpret_cast<xmlChar const *>("/jf:javaSelection/jf:updated/text()"));
}
void createSettingsStructure(xmlDoc * document, bool * bNeedsSave)
......
......@@ -125,7 +125,7 @@ void SeqRemoveNegEntries( std::vector< OUString > &rSeq,
{
std::vector< OUString > aNew;
// merge sequence without duplicates and empty strings in new empty sequence
aNew = MergeProposalSeqs( aNew, rSeq, false );
aNew = MergeProposalSeqs( aNew, rSeq );
rSeq = aNew;
}
}
......@@ -133,38 +133,30 @@ void SeqRemoveNegEntries( std::vector< OUString > &rSeq,
std::vector< OUString > MergeProposalSeqs(
std::vector< OUString > &rAlt1,
std::vector< OUString > &rAlt2,
bool bAllowDuplicates )
std::vector< OUString > &rAlt2 )
{
std::vector< OUString > aMerged;
if (rAlt1.empty() && bAllowDuplicates)
aMerged = rAlt2;
else if (rAlt2.empty() && bAllowDuplicates)
aMerged = rAlt1;
else
{
size_t nAltCount1 = rAlt1.size();
size_t nAltCount2 = rAlt2.size();
size_t nAltCount1 = rAlt1.size();
size_t nAltCount2 = rAlt2.size();
sal_Int32 nCountNew = std::min<sal_Int32>( nAltCount1 + nAltCount2, (sal_Int32) MAX_PROPOSALS );
aMerged.resize( nCountNew );
sal_Int32 nCountNew = std::min<sal_Int32>( nAltCount1 + nAltCount2, (sal_Int32) MAX_PROPOSALS );
aMerged.resize( nCountNew );
sal_Int32 nIndex = 0;
sal_Int32 i = 0;
for (int j = 0; j < 2; j++)
sal_Int32 nIndex = 0;
sal_Int32 i = 0;
for (int j = 0; j < 2; j++)
{
sal_Int32 nCount = j == 0 ? nAltCount1 : nAltCount2;
std::vector< OUString >& rAlt = j == 0 ? rAlt1 : rAlt2;
for (i = 0; i < nCount && nIndex < MAX_PROPOSALS; i++)
{
sal_Int32 nCount = j == 0 ? nAltCount1 : nAltCount2;
std::vector< OUString >& rAlt = j == 0 ? rAlt1 : rAlt2;
for (i = 0; i < nCount && nIndex < MAX_PROPOSALS; i++)
{
if (!rAlt[i].isEmpty() &&
(bAllowDuplicates || !SeqHasEntry(aMerged, rAlt[i] )))
aMerged[ nIndex++ ] = rAlt[ i ];
}
if (!rAlt[i].isEmpty() &&
!SeqHasEntry(aMerged, rAlt[i] ))
aMerged[ nIndex++ ] = rAlt[ i ];
}
aMerged.resize( nIndex );
}
aMerged.resize( nIndex );
return aMerged;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment