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 <unotools/configpaths.hxx>
|
||||||
#include <rtl/logfile.hxx>
|
#include <rtl/logfile.hxx>
|
||||||
#include <svtools/acceleratorexecute.hxx>
|
#include <svtools/acceleratorexecute.hxx>
|
||||||
#include <i18npool/languagetag.hxx>
|
|
||||||
#include <stdio.h>
|
#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 -> ----------------------------------
|
// SAFE -> ----------------------------------
|
||||||
ReadGuard aReadLock(m_aLock);
|
ReadGuard aReadLock(m_aLock);
|
||||||
@@ -623,8 +622,8 @@ LanguageTag XMLBasedAcceleratorConfiguration::impl_ts_getLocale() const
|
|||||||
xProp->getPropertyValue("ooLocale") >>= sISOLocale;
|
xProp->getPropertyValue("ooLocale") >>= sISOLocale;
|
||||||
|
|
||||||
if (sISOLocale.isEmpty())
|
if (sISOLocale.isEmpty())
|
||||||
return LanguageTag( LANGUAGE_ENGLISH_US);
|
return OUString("en-US");
|
||||||
return LanguageTag(sISOLocale);
|
return sISOLocale;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@@ -1264,7 +1263,7 @@ void XCUBasedAcceleratorConfiguration::impl_ts_load( sal_Bool bPreferred, const
|
|||||||
xModules->getByName(m_sModuleCFG) >>= xAccess;
|
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");
|
const ::rtl::OUString sDefaultLocale("en-US");
|
||||||
|
|
||||||
css::uno::Reference< css::container::XNameAccess > xKey;
|
css::uno::Reference< css::container::XNameAccess > xKey;
|
||||||
@@ -1492,7 +1491,7 @@ void XCUBasedAcceleratorConfiguration::insertKeyToConfiguration( const css::awt:
|
|||||||
xContainer->getByName(sKey) >>= xKey;
|
xContainer->getByName(sKey) >>= xKey;
|
||||||
|
|
||||||
xKey->getByName(CFG_PROP_COMMAND) >>= xCommand;
|
xKey->getByName(CFG_PROP_COMMAND) >>= xCommand;
|
||||||
::rtl::OUString sLocale = impl_ts_getLocale().getBcp47();
|
::rtl::OUString sLocale = impl_ts_getLocale();
|
||||||
if ( !xCommand->hasByName(sLocale) )
|
if ( !xCommand->hasByName(sLocale) )
|
||||||
xCommand->insertByName(sLocale, css::uno::makeAny(sCommand));
|
xCommand->insertByName(sLocale, css::uno::makeAny(sCommand));
|
||||||
else
|
else
|
||||||
@@ -1574,7 +1573,7 @@ void XCUBasedAcceleratorConfiguration::reloadChanged( const ::rtl::OUString& sPr
|
|||||||
|
|
||||||
if (xContainer->hasByName(sKey))
|
if (xContainer->hasByName(sKey))
|
||||||
{
|
{
|
||||||
::rtl::OUString sLocale = impl_ts_getLocale().getBcp47();
|
::rtl::OUString sLocale = impl_ts_getLocale();
|
||||||
xContainer->getByName(sKey) >>= xKey;
|
xContainer->getByName(sKey) >>= xKey;
|
||||||
xKey->getByName(CFG_PROP_COMMAND) >>= xCommand;
|
xKey->getByName(CFG_PROP_COMMAND) >>= xCommand;
|
||||||
xCommand->getByName(sLocale) >>= sCommand;
|
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 -> ----------------------------------
|
// SAFE -> ----------------------------------
|
||||||
ReadGuard aReadLock(m_aLock);
|
ReadGuard aReadLock(m_aLock);
|
||||||
@@ -1661,8 +1660,8 @@ LanguageTag XCUBasedAcceleratorConfiguration::impl_ts_getLocale() const
|
|||||||
xProp->getPropertyValue("ooLocale") >>= sISOLocale;
|
xProp->getPropertyValue("ooLocale") >>= sISOLocale;
|
||||||
|
|
||||||
if (sISOLocale.isEmpty())
|
if (sISOLocale.isEmpty())
|
||||||
return LanguageTag( LANGUAGE_ENGLISH_US);
|
return OUString("en-US");
|
||||||
return LanguageTag(sISOLocale);
|
return sISOLocale;
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace framework
|
} // namespace framework
|
||||||
|
@@ -488,7 +488,7 @@ void PresetHandler::connectToResource( PresetHandler::EConfigType
|
|||||||
{
|
{
|
||||||
// First try to find the right localized set inside share layer.
|
// First try to find the right localized set inside share layer.
|
||||||
// Fallbacks are allowed there.
|
// Fallbacks are allowed there.
|
||||||
LanguageTag aShareLocale( rLanguageTag);
|
OUString aShareLocale( rLanguageTag.getBcp47());
|
||||||
::rtl::OUString sLocalizedSharePath(sRelPathShare);
|
::rtl::OUString sLocalizedSharePath(sRelPathShare);
|
||||||
sal_Bool bAllowFallbacks = sal_True ;
|
sal_Bool bAllowFallbacks = sal_True ;
|
||||||
xShare = impl_openLocalizedPathIgnoringErrors(sLocalizedSharePath, eShareMode, sal_True , aShareLocale, bAllowFallbacks);
|
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!
|
// 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.
|
// Normaly the corresponding sub dir should be created matching the specified locale.
|
||||||
// Because we allow creation of storages inside user layer by default.
|
// Because we allow creation of storages inside user layer by default.
|
||||||
LanguageTag aUserLocale( rLanguageTag);
|
OUString aUserLocale( rLanguageTag.getBcp47());
|
||||||
::rtl::OUString sLocalizedUserPath(sRelPathUser);
|
::rtl::OUString sLocalizedUserPath(sRelPathUser);
|
||||||
bAllowFallbacks = sal_False ;
|
bAllowFallbacks = sal_False ;
|
||||||
xUser = impl_openLocalizedPathIgnoringErrors(sLocalizedUserPath, eUserMode , sal_False, aUserLocale, bAllowFallbacks);
|
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(
|
::std::vector< ::rtl::OUString >::const_iterator PresetHandler::impl_findMatchingLocalizedValue(
|
||||||
const ::std::vector< ::rtl::OUString >& lLocalizedValues,
|
const ::std::vector< ::rtl::OUString >& lLocalizedValues,
|
||||||
LanguageTag& rLanguageTag,
|
OUString& rLanguageTag,
|
||||||
sal_Bool bAllowFallbacks )
|
sal_Bool bAllowFallbacks )
|
||||||
{
|
{
|
||||||
::std::vector< ::rtl::OUString >::const_iterator pFound = lLocalizedValues.end();
|
::std::vector< ::rtl::OUString >::const_iterator pFound = lLocalizedValues.end();
|
||||||
if (bAllowFallbacks)
|
if (bAllowFallbacks)
|
||||||
{
|
{
|
||||||
pFound = LanguageTag::getFallback(lLocalizedValues, rLanguageTag.getBcp47());
|
pFound = LanguageTag::getFallback(lLocalizedValues, rLanguageTag);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
OUString aCheck( rLanguageTag.getBcp47());
|
|
||||||
for ( pFound = lLocalizedValues.begin();
|
for ( pFound = lLocalizedValues.begin();
|
||||||
pFound != lLocalizedValues.end() ;
|
pFound != lLocalizedValues.end() ;
|
||||||
++pFound )
|
++pFound )
|
||||||
{
|
{
|
||||||
if (*pFound == aCheck)
|
if (*pFound == rLanguageTag)
|
||||||
break;
|
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 we found a valid locale ... take it over to our in/out parameter rLanguageTag
|
||||||
if (pFound != lLocalizedValues.end())
|
if (pFound != lLocalizedValues.end())
|
||||||
{
|
{
|
||||||
rLanguageTag.reset( *pFound);
|
rLanguageTag = *pFound;
|
||||||
}
|
}
|
||||||
|
|
||||||
return pFound;
|
return pFound;
|
||||||
@@ -834,7 +833,7 @@ css::uno::Reference< css::embed::XStorage > PresetHandler::impl_openLocalizedPat
|
|||||||
::rtl::OUString& sPath ,
|
::rtl::OUString& sPath ,
|
||||||
sal_Int32 eMode ,
|
sal_Int32 eMode ,
|
||||||
sal_Bool bShare ,
|
sal_Bool bShare ,
|
||||||
LanguageTag& rLanguageTag ,
|
OUString& rLanguageTag ,
|
||||||
sal_Bool bAllowFallback)
|
sal_Bool bAllowFallback)
|
||||||
{
|
{
|
||||||
css::uno::Reference< css::embed::XStorage > xPath = impl_openPathIgnoringErrors(sPath, eMode, bShare);
|
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())
|
if (pLocaleFolder != lSubFolders.end())
|
||||||
sLocalizedPath += *pLocaleFolder;
|
sLocalizedPath += *pLocaleFolder;
|
||||||
else
|
else
|
||||||
sLocalizedPath += rLanguageTag.getBcp47();
|
sLocalizedPath += rLanguageTag;
|
||||||
|
|
||||||
css::uno::Reference< css::embed::XStorage > xLocalePath = impl_openPathIgnoringErrors(sLocalizedPath, eMode, bShare);
|
css::uno::Reference< css::embed::XStorage > xLocalePath = impl_openPathIgnoringErrors(sLocalizedPath, eMode, bShare);
|
||||||
|
|
||||||
|
@@ -48,7 +48,6 @@
|
|||||||
|
|
||||||
#include <cppuhelper/propshlp.hxx>
|
#include <cppuhelper/propshlp.hxx>
|
||||||
#include <cppuhelper/weak.hxx>
|
#include <cppuhelper/weak.hxx>
|
||||||
#include <i18npool/languagetag.hxx>
|
|
||||||
#include <salhelper/singletonref.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
|
@descr We does not cache this value, because we are not listen
|
||||||
for changes on the configuration layer ...
|
for changes on the configuration layer ...
|
||||||
|
|
||||||
@return LanguageTag
|
@return OUString
|
||||||
The current office locale.
|
The current office locale as BCP47 string.
|
||||||
*/
|
*/
|
||||||
LanguageTag impl_ts_getLocale() const;
|
OUString impl_ts_getLocale() const;
|
||||||
|
|
||||||
//______________________________________
|
//______________________________________
|
||||||
// helper
|
// helper
|
||||||
@@ -428,10 +427,10 @@ class XCUBasedAcceleratorConfiguration : protected ThreadHelpBase
|
|||||||
@descr We does not cache this value, because we are not listen
|
@descr We does not cache this value, because we are not listen
|
||||||
for changes on the configuration layer ...
|
for changes on the configuration layer ...
|
||||||
|
|
||||||
@return LanguageTag
|
@return OUString
|
||||||
The current office locale.
|
The current office locale as BCP47 string.
|
||||||
*/
|
*/
|
||||||
LanguageTag impl_ts_getLocale() const;
|
OUString impl_ts_getLocale() const;
|
||||||
|
|
||||||
//______________________________________
|
//______________________________________
|
||||||
// helper
|
// 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.
|
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,
|
::std::vector< ::rtl::OUString >::const_iterator impl_findMatchingLocalizedValue(const ::std::vector< ::rtl::OUString >& lLocalizedValues,
|
||||||
LanguageTag& rLanguageTag ,
|
OUString& rLanguageTag ,
|
||||||
sal_Bool bAllowFallbacks );
|
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 ,
|
css::uno::Reference< css::embed::XStorage > impl_openLocalizedPathIgnoringErrors(::rtl::OUString& sPath ,
|
||||||
sal_Int32 eMode ,
|
sal_Int32 eMode ,
|
||||||
sal_Bool bShare ,
|
sal_Bool bShare ,
|
||||||
LanguageTag& rLanguageTag ,
|
OUString& rLanguageTag ,
|
||||||
sal_Bool bAllowFallback);
|
sal_Bool bAllowFallback);
|
||||||
|
|
||||||
//---------------------------------------
|
//---------------------------------------
|
||||||
|
Reference in New Issue
Block a user