eliminated useless back and forth conversion
Why convert back and forth between LanguageTag (formerly comphelper::Locale) if all you need and use is a BCP47 string. Change-Id: I1ec12186284211bcd7d115ee092c195b926e7cd0
This commit is contained in:
@@ -53,7 +53,6 @@
|
||||
#include <unotools/configpaths.hxx>
|
||||
#include <rtl/logfile.hxx>
|
||||
#include <svtools/acceleratorexecute.hxx>
|
||||
#include <i18npool/languagetag.hxx>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
@@ -608,7 +607,7 @@ AcceleratorCache& XMLBasedAcceleratorConfiguration::impl_getCFG(sal_Bool bWriteA
|
||||
}
|
||||
|
||||
//-----------------------------------------------
|
||||
LanguageTag XMLBasedAcceleratorConfiguration::impl_ts_getLocale() const
|
||||
OUString XMLBasedAcceleratorConfiguration::impl_ts_getLocale() const
|
||||
{
|
||||
// SAFE -> ----------------------------------
|
||||
ReadGuard aReadLock(m_aLock);
|
||||
@@ -623,8 +622,8 @@ LanguageTag XMLBasedAcceleratorConfiguration::impl_ts_getLocale() const
|
||||
xProp->getPropertyValue("ooLocale") >>= sISOLocale;
|
||||
|
||||
if (sISOLocale.isEmpty())
|
||||
return LanguageTag( LANGUAGE_ENGLISH_US);
|
||||
return LanguageTag(sISOLocale);
|
||||
return OUString("en-US");
|
||||
return sISOLocale;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@@ -1264,7 +1263,7 @@ void XCUBasedAcceleratorConfiguration::impl_ts_load( sal_Bool bPreferred, const
|
||||
xModules->getByName(m_sModuleCFG) >>= xAccess;
|
||||
}
|
||||
|
||||
const ::rtl::OUString sIsoLang = impl_ts_getLocale().getBcp47();
|
||||
const ::rtl::OUString sIsoLang = impl_ts_getLocale();
|
||||
const ::rtl::OUString sDefaultLocale("en-US");
|
||||
|
||||
css::uno::Reference< css::container::XNameAccess > xKey;
|
||||
@@ -1492,7 +1491,7 @@ void XCUBasedAcceleratorConfiguration::insertKeyToConfiguration( const css::awt:
|
||||
xContainer->getByName(sKey) >>= xKey;
|
||||
|
||||
xKey->getByName(CFG_PROP_COMMAND) >>= xCommand;
|
||||
::rtl::OUString sLocale = impl_ts_getLocale().getBcp47();
|
||||
::rtl::OUString sLocale = impl_ts_getLocale();
|
||||
if ( !xCommand->hasByName(sLocale) )
|
||||
xCommand->insertByName(sLocale, css::uno::makeAny(sCommand));
|
||||
else
|
||||
@@ -1574,7 +1573,7 @@ void XCUBasedAcceleratorConfiguration::reloadChanged( const ::rtl::OUString& sPr
|
||||
|
||||
if (xContainer->hasByName(sKey))
|
||||
{
|
||||
::rtl::OUString sLocale = impl_ts_getLocale().getBcp47();
|
||||
::rtl::OUString sLocale = impl_ts_getLocale();
|
||||
xContainer->getByName(sKey) >>= xKey;
|
||||
xKey->getByName(CFG_PROP_COMMAND) >>= xCommand;
|
||||
xCommand->getByName(sLocale) >>= sCommand;
|
||||
@@ -1646,7 +1645,7 @@ AcceleratorCache& XCUBasedAcceleratorConfiguration::impl_getCFG(sal_Bool bPrefer
|
||||
}
|
||||
|
||||
//-----------------------------------------------
|
||||
LanguageTag XCUBasedAcceleratorConfiguration::impl_ts_getLocale() const
|
||||
OUString XCUBasedAcceleratorConfiguration::impl_ts_getLocale() const
|
||||
{
|
||||
// SAFE -> ----------------------------------
|
||||
ReadGuard aReadLock(m_aLock);
|
||||
@@ -1661,8 +1660,8 @@ LanguageTag XCUBasedAcceleratorConfiguration::impl_ts_getLocale() const
|
||||
xProp->getPropertyValue("ooLocale") >>= sISOLocale;
|
||||
|
||||
if (sISOLocale.isEmpty())
|
||||
return LanguageTag( LANGUAGE_ENGLISH_US);
|
||||
return LanguageTag(sISOLocale);
|
||||
return OUString("en-US");
|
||||
return sISOLocale;
|
||||
}
|
||||
|
||||
} // namespace framework
|
||||
|
@@ -488,7 +488,7 @@ void PresetHandler::connectToResource( PresetHandler::EConfigType
|
||||
{
|
||||
// First try to find the right localized set inside share layer.
|
||||
// Fallbacks are allowed there.
|
||||
LanguageTag aShareLocale( rLanguageTag);
|
||||
OUString aShareLocale( rLanguageTag.getBcp47());
|
||||
::rtl::OUString sLocalizedSharePath(sRelPathShare);
|
||||
sal_Bool bAllowFallbacks = sal_True ;
|
||||
xShare = impl_openLocalizedPathIgnoringErrors(sLocalizedSharePath, eShareMode, sal_True , aShareLocale, bAllowFallbacks);
|
||||
@@ -496,7 +496,7 @@ void PresetHandler::connectToResource( PresetHandler::EConfigType
|
||||
// The try to locate the right sub dir inside user layer ... without using fallbacks!
|
||||
// Normaly the corresponding sub dir should be created matching the specified locale.
|
||||
// Because we allow creation of storages inside user layer by default.
|
||||
LanguageTag aUserLocale( rLanguageTag);
|
||||
OUString aUserLocale( rLanguageTag.getBcp47());
|
||||
::rtl::OUString sLocalizedUserPath(sRelPathUser);
|
||||
bAllowFallbacks = sal_False ;
|
||||
xUser = impl_openLocalizedPathIgnoringErrors(sLocalizedUserPath, eUserMode , sal_False, aUserLocale, bAllowFallbacks);
|
||||
@@ -800,22 +800,21 @@ css::uno::Reference< css::embed::XStorage > PresetHandler::impl_openPathIgnoring
|
||||
//-----------------------------------------------
|
||||
::std::vector< ::rtl::OUString >::const_iterator PresetHandler::impl_findMatchingLocalizedValue(
|
||||
const ::std::vector< ::rtl::OUString >& lLocalizedValues,
|
||||
LanguageTag& rLanguageTag,
|
||||
OUString& rLanguageTag,
|
||||
sal_Bool bAllowFallbacks )
|
||||
{
|
||||
::std::vector< ::rtl::OUString >::const_iterator pFound = lLocalizedValues.end();
|
||||
if (bAllowFallbacks)
|
||||
{
|
||||
pFound = LanguageTag::getFallback(lLocalizedValues, rLanguageTag.getBcp47());
|
||||
pFound = LanguageTag::getFallback(lLocalizedValues, rLanguageTag);
|
||||
}
|
||||
else
|
||||
{
|
||||
OUString aCheck( rLanguageTag.getBcp47());
|
||||
for ( pFound = lLocalizedValues.begin();
|
||||
pFound != lLocalizedValues.end() ;
|
||||
++pFound )
|
||||
{
|
||||
if (*pFound == aCheck)
|
||||
if (*pFound == rLanguageTag)
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -823,7 +822,7 @@ css::uno::Reference< css::embed::XStorage > PresetHandler::impl_openPathIgnoring
|
||||
// if we found a valid locale ... take it over to our in/out parameter rLanguageTag
|
||||
if (pFound != lLocalizedValues.end())
|
||||
{
|
||||
rLanguageTag.reset( *pFound);
|
||||
rLanguageTag = *pFound;
|
||||
}
|
||||
|
||||
return pFound;
|
||||
@@ -834,7 +833,7 @@ css::uno::Reference< css::embed::XStorage > PresetHandler::impl_openLocalizedPat
|
||||
::rtl::OUString& sPath ,
|
||||
sal_Int32 eMode ,
|
||||
sal_Bool bShare ,
|
||||
LanguageTag& rLanguageTag ,
|
||||
OUString& rLanguageTag ,
|
||||
sal_Bool bAllowFallback)
|
||||
{
|
||||
css::uno::Reference< css::embed::XStorage > xPath = impl_openPathIgnoringErrors(sPath, eMode, bShare);
|
||||
@@ -857,7 +856,7 @@ css::uno::Reference< css::embed::XStorage > PresetHandler::impl_openLocalizedPat
|
||||
if (pLocaleFolder != lSubFolders.end())
|
||||
sLocalizedPath += *pLocaleFolder;
|
||||
else
|
||||
sLocalizedPath += rLanguageTag.getBcp47();
|
||||
sLocalizedPath += rLanguageTag;
|
||||
|
||||
css::uno::Reference< css::embed::XStorage > xLocalePath = impl_openPathIgnoringErrors(sLocalizedPath, eMode, bShare);
|
||||
|
||||
|
@@ -48,7 +48,6 @@
|
||||
|
||||
#include <cppuhelper/propshlp.hxx>
|
||||
#include <cppuhelper/weak.hxx>
|
||||
#include <i18npool/languagetag.hxx>
|
||||
#include <salhelper/singletonref.hxx>
|
||||
|
||||
//__________________________________________
|
||||
@@ -210,10 +209,10 @@ class XMLBasedAcceleratorConfiguration : protected ThreadHelpBase
|
||||
@descr We does not cache this value, because we are not listen
|
||||
for changes on the configuration layer ...
|
||||
|
||||
@return LanguageTag
|
||||
The current office locale.
|
||||
@return OUString
|
||||
The current office locale as BCP47 string.
|
||||
*/
|
||||
LanguageTag impl_ts_getLocale() const;
|
||||
OUString impl_ts_getLocale() const;
|
||||
|
||||
//______________________________________
|
||||
// helper
|
||||
@@ -428,10 +427,10 @@ class XCUBasedAcceleratorConfiguration : protected ThreadHelpBase
|
||||
@descr We does not cache this value, because we are not listen
|
||||
for changes on the configuration layer ...
|
||||
|
||||
@return LanguageTag
|
||||
The current office locale.
|
||||
@return OUString
|
||||
The current office locale as BCP47 string.
|
||||
*/
|
||||
LanguageTag impl_ts_getLocale() const;
|
||||
OUString impl_ts_getLocale() const;
|
||||
|
||||
//______________________________________
|
||||
// helper
|
||||
|
@@ -455,7 +455,7 @@ class PresetHandler : private ThreadHelpBase // attention! Must be the first bas
|
||||
As a negative result the special iterator lLocalizedValues.end() will be returned.
|
||||
*/
|
||||
::std::vector< ::rtl::OUString >::const_iterator impl_findMatchingLocalizedValue(const ::std::vector< ::rtl::OUString >& lLocalizedValues,
|
||||
LanguageTag& rLanguageTag ,
|
||||
OUString& rLanguageTag ,
|
||||
sal_Bool bAllowFallbacks );
|
||||
|
||||
//---------------------------------------
|
||||
@@ -489,7 +489,7 @@ class PresetHandler : private ThreadHelpBase // attention! Must be the first bas
|
||||
css::uno::Reference< css::embed::XStorage > impl_openLocalizedPathIgnoringErrors(::rtl::OUString& sPath ,
|
||||
sal_Int32 eMode ,
|
||||
sal_Bool bShare ,
|
||||
LanguageTag& rLanguageTag ,
|
||||
OUString& rLanguageTag ,
|
||||
sal_Bool bAllowFallback);
|
||||
|
||||
//---------------------------------------
|
||||
|
Reference in New Issue
Block a user