summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2013-03-28 00:13:14 +0100
committerEike Rathke <erack@redhat.com>2013-03-28 01:39:07 +0100
commit68fac46e71e954d559eeb8591383f304f3038ad6 (patch)
treea47b46cb315ffaffa07eac3706d471ca6950c1b5 /framework
parent66a63c1608cfd5e755fb141b636e4a84c118179a (diff)
use LanguageTag instead of comphelper::Locale
Change-Id: I2c6d07bbdef62fa17e9c90ca87be6e742268c54f
Diffstat (limited to 'framework')
-rw-r--r--framework/source/accelerators/acceleratorconfiguration.cxx19
-rw-r--r--framework/source/accelerators/documentacceleratorconfiguration.cxx5
-rw-r--r--framework/source/accelerators/globalacceleratorconfiguration.cxx7
-rw-r--r--framework/source/accelerators/moduleacceleratorconfiguration.cxx5
-rw-r--r--framework/source/accelerators/presethandler.cxx49
-rw-r--r--framework/source/inc/accelerators/acceleratorconfiguration.hxx10
-rw-r--r--framework/source/inc/accelerators/presethandler.hxx20
7 files changed, 62 insertions, 53 deletions
diff --git a/framework/source/accelerators/acceleratorconfiguration.cxx b/framework/source/accelerators/acceleratorconfiguration.cxx
index 5df1ab22ff33..c7a5f4ee83af 100644
--- a/framework/source/accelerators/acceleratorconfiguration.cxx
+++ b/framework/source/accelerators/acceleratorconfiguration.cxx
@@ -53,6 +53,7 @@
#include <unotools/configpaths.hxx>
#include <rtl/logfile.hxx>
#include <svtools/acceleratorexecute.hxx>
+#include <i18npool/languagetag.hxx>
#include <stdio.h>
@@ -607,7 +608,7 @@ AcceleratorCache& XMLBasedAcceleratorConfiguration::impl_getCFG(sal_Bool bWriteA
}
//-----------------------------------------------
-::comphelper::Locale XMLBasedAcceleratorConfiguration::impl_ts_getLocale() const
+LanguageTag XMLBasedAcceleratorConfiguration::impl_ts_getLocale() const
{
// SAFE -> ----------------------------------
ReadGuard aReadLock(m_aLock);
@@ -622,8 +623,8 @@ AcceleratorCache& XMLBasedAcceleratorConfiguration::impl_getCFG(sal_Bool bWriteA
xProp->getPropertyValue("ooLocale") >>= sISOLocale;
if (sISOLocale.isEmpty())
- return ::comphelper::Locale::EN_US();
- return ::comphelper::Locale(sISOLocale);
+ return LanguageTag( LANGUAGE_ENGLISH_US);
+ return LanguageTag(sISOLocale);
}
/*******************************************************************************
@@ -1263,7 +1264,7 @@ void XCUBasedAcceleratorConfiguration::impl_ts_load( sal_Bool bPreferred, const
xModules->getByName(m_sModuleCFG) >>= xAccess;
}
- const ::rtl::OUString sIsoLang = impl_ts_getLocale().toISO();
+ const ::rtl::OUString sIsoLang = impl_ts_getLocale().getBcp47();
const ::rtl::OUString sDefaultLocale("en-US");
css::uno::Reference< css::container::XNameAccess > xKey;
@@ -1491,7 +1492,7 @@ void XCUBasedAcceleratorConfiguration::insertKeyToConfiguration( const css::awt:
xContainer->getByName(sKey) >>= xKey;
xKey->getByName(CFG_PROP_COMMAND) >>= xCommand;
- ::rtl::OUString sLocale = impl_ts_getLocale().toISO();
+ ::rtl::OUString sLocale = impl_ts_getLocale().getBcp47();
if ( !xCommand->hasByName(sLocale) )
xCommand->insertByName(sLocale, css::uno::makeAny(sCommand));
else
@@ -1573,7 +1574,7 @@ void XCUBasedAcceleratorConfiguration::reloadChanged( const ::rtl::OUString& sPr
if (xContainer->hasByName(sKey))
{
- ::rtl::OUString sLocale = impl_ts_getLocale().toISO();
+ ::rtl::OUString sLocale = impl_ts_getLocale().getBcp47();
xContainer->getByName(sKey) >>= xKey;
xKey->getByName(CFG_PROP_COMMAND) >>= xCommand;
xCommand->getByName(sLocale) >>= sCommand;
@@ -1645,7 +1646,7 @@ AcceleratorCache& XCUBasedAcceleratorConfiguration::impl_getCFG(sal_Bool bPrefer
}
//-----------------------------------------------
-::comphelper::Locale XCUBasedAcceleratorConfiguration::impl_ts_getLocale() const
+LanguageTag XCUBasedAcceleratorConfiguration::impl_ts_getLocale() const
{
// SAFE -> ----------------------------------
ReadGuard aReadLock(m_aLock);
@@ -1660,8 +1661,8 @@ AcceleratorCache& XCUBasedAcceleratorConfiguration::impl_getCFG(sal_Bool bPrefer
xProp->getPropertyValue("ooLocale") >>= sISOLocale;
if (sISOLocale.isEmpty())
- return ::comphelper::Locale::EN_US();
- return ::comphelper::Locale(sISOLocale);
+ return LanguageTag( LANGUAGE_ENGLISH_US);
+ return LanguageTag(sISOLocale);
}
} // namespace framework
diff --git a/framework/source/accelerators/documentacceleratorconfiguration.cxx b/framework/source/accelerators/documentacceleratorconfiguration.cxx
index 9df177203447..9ef571f4086f 100644
--- a/framework/source/accelerators/documentacceleratorconfiguration.cxx
+++ b/framework/source/accelerators/documentacceleratorconfiguration.cxx
@@ -44,6 +44,7 @@
#include <com/sun/star/xml/sax/XParser.hpp>
#include <comphelper/sequenceashashmap.hxx>
+#include <i18npool/languagetag.hxx>
namespace framework
@@ -156,7 +157,7 @@ void DocumentAcceleratorConfiguration::impl_ts_fillCache()
// get current office locale ... but dont cache it.
// Otherwise we must be listener on the configuration layer
// which seems to superflous for this small implementation .-)
- ::comphelper::Locale aLocale = impl_ts_getLocale();
+ LanguageTag aLanguageTag( impl_ts_getLocale());
// May be the current document does not contain any
// accelerator config? Handle it gracefully :-)
@@ -171,7 +172,7 @@ void DocumentAcceleratorConfiguration::impl_ts_fillCache()
PresetHandler::RESOURCETYPE_ACCELERATOR(),
::rtl::OUString(),
xDocumentRoot,
- aLocale);
+ aLanguageTag);
DocumentAcceleratorConfiguration::reload();
m_aPresetHandler.addStorageListener(this);
diff --git a/framework/source/accelerators/globalacceleratorconfiguration.cxx b/framework/source/accelerators/globalacceleratorconfiguration.cxx
index fdc1505c92c3..83890281725b 100644
--- a/framework/source/accelerators/globalacceleratorconfiguration.cxx
+++ b/framework/source/accelerators/globalacceleratorconfiguration.cxx
@@ -33,7 +33,7 @@
#include <com/sun/star/util/XChangesNotifier.hpp>
#include <vcl/svapp.hxx>
-#include <comphelper/locale.hxx>
+#include <i18npool/languagetag.hxx>
#include <comphelper/configurationhelper.hxx>
@@ -87,10 +87,13 @@ void SAL_CALL GlobalAcceleratorConfiguration::initialize(const css::uno::Sequenc
//-----------------------------------------------
void GlobalAcceleratorConfiguration::impl_ts_fillCache()
{
+#if 0
// get current office locale ... but dont cache it.
// Otherwise we must be listener on the configuration layer
// which seems to superflous for this small implementation .-)
- ::comphelper::Locale aLocale = ::comphelper::Locale(m_sLocale);
+ // XXX: what is this good for? it was a comphelper::Locale but unused
+ LanguageTag aLanguageTag(m_sLocale);
+#endif
// May be there exists no accelerator config? Handle it gracefully :-)
try
diff --git a/framework/source/accelerators/moduleacceleratorconfiguration.cxx b/framework/source/accelerators/moduleacceleratorconfiguration.cxx
index 39c9b18e6340..2a675cc36568 100644
--- a/framework/source/accelerators/moduleacceleratorconfiguration.cxx
+++ b/framework/source/accelerators/moduleacceleratorconfiguration.cxx
@@ -118,10 +118,13 @@ void ModuleAcceleratorConfiguration::impl_ts_fillCache()
aReadLock.unlock();
// <- SAFE ----------------------------------
+#if 0
// get current office locale ... but dont cache it.
// Otherwise we must be listener on the configuration layer
// which seems to superflous for this small implementation .-)
- ::comphelper::Locale aLocale = ::comphelper::Locale(m_sLocale);
+ // XXX: what is this good for? it was a comphelper::Locale but unused
+ LanguageTag aLanguageTag(m_sLocale);
+#endif
// May be the current app module does not have any
// accelerator config? Handle it gracefully :-)
diff --git a/framework/source/accelerators/presethandler.cxx b/framework/source/accelerators/presethandler.cxx
index a6be0dd83478..d65e2fabf7cc 100644
--- a/framework/source/accelerators/presethandler.cxx
+++ b/framework/source/accelerators/presethandler.cxx
@@ -38,6 +38,7 @@
#include <vcl/svapp.hxx>
#include <cppuhelper/exc_hlp.hxx>
#include <rtl/ustrbuf.hxx>
+#include <i18npool/languagetag.hxx>
#define SUBSTORAGE_GLOBAL DECLARE_ASCII("global" )
@@ -103,13 +104,14 @@ PresetHandler::PresetHandler(const css::uno::Reference< css::lang::XMultiService
, m_xSMGR (xSMGR )
, m_aSharedStorages ( )
, m_lDocumentStorages()
- , m_aLocale (::comphelper::Locale::X_NOTRANSLATE())
+ , m_aLanguageTag (LANGUAGE_USER_PRIV_NOTRANSLATE)
{
}
//-----------------------------------------------
PresetHandler::PresetHandler(const PresetHandler& rCopy)
: ThreadHelpBase (&Application::GetSolarMutex() )
+ , m_aLanguageTag( rCopy.m_aLanguageTag)
{
m_xSMGR = rCopy.m_xSMGR;
m_eConfigType = rCopy.m_eConfigType;
@@ -121,7 +123,6 @@ PresetHandler::PresetHandler(const PresetHandler& rCopy)
m_xWorkingStorageUser = rCopy.m_xWorkingStorageUser;
m_lPresets = rCopy.m_lPresets;
m_lTargets = rCopy.m_lTargets;
- m_aLocale = rCopy.m_aLocale;
m_lDocumentStorages = rCopy.m_lDocumentStorages;
m_sRelPathShare = rCopy.m_sRelPathShare;
m_sRelPathNoLang = rCopy.m_sRelPathNoLang;
@@ -371,7 +372,7 @@ void PresetHandler::connectToResource( PresetHandler::EConfigType
const ::rtl::OUString& sResource ,
const ::rtl::OUString& sModule ,
const css::uno::Reference< css::embed::XStorage >& xDocumentRoot,
- const ::comphelper::Locale& aLocale )
+ const LanguageTag& rLanguageTag )
{
// TODO free all current open storages!
@@ -381,7 +382,7 @@ void PresetHandler::connectToResource( PresetHandler::EConfigType
m_eConfigType = eConfigType ;
m_sResourceType = sResource ;
m_sModule = sModule ;
- m_aLocale = aLocale ;
+ m_aLanguageTag = rLanguageTag ;
aWriteLock.unlock();
// <- SAFE ----------------------------------
@@ -481,13 +482,13 @@ void PresetHandler::connectToResource( PresetHandler::EConfigType
sRelPathNoLang = sRelPathShare;
if (
- (aLocale != ::comphelper::Locale::X_NOTRANSLATE()) && // localized level?
+ (rLanguageTag != LanguageTag(LANGUAGE_USER_PRIV_NOTRANSLATE)) && // localized level?
(eConfigType != E_DOCUMENT ) // no localization in document mode!
)
{
// First try to find the right localized set inside share layer.
// Fallbacks are allowed there.
- ::comphelper::Locale aShareLocale = aLocale ;
+ LanguageTag aShareLocale( rLanguageTag);
::rtl::OUString sLocalizedSharePath(sRelPathShare);
sal_Bool bAllowFallbacks = sal_True ;
xShare = impl_openLocalizedPathIgnoringErrors(sLocalizedSharePath, eShareMode, sal_True , aShareLocale, bAllowFallbacks);
@@ -495,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.
- ::comphelper::Locale aUserLocale = aLocale ;
+ LanguageTag aUserLocale( rLanguageTag);
::rtl::OUString sLocalizedUserPath(sRelPathUser);
bAllowFallbacks = sal_False ;
xUser = impl_openLocalizedPathIgnoringErrors(sLocalizedUserPath, eUserMode , sal_False, aUserLocale, bAllowFallbacks);
@@ -797,48 +798,48 @@ css::uno::Reference< css::embed::XStorage > PresetHandler::impl_openPathIgnoring
}
//-----------------------------------------------
-::std::vector< ::rtl::OUString >::const_iterator PresetHandler::impl_findMatchingLocalizedValue(const ::std::vector< ::rtl::OUString >& lLocalizedValues,
- ::comphelper::Locale& aLocale ,
- sal_Bool bAllowFallbacks )
+::std::vector< ::rtl::OUString >::const_iterator PresetHandler::impl_findMatchingLocalizedValue(
+ const ::std::vector< ::rtl::OUString >& lLocalizedValues,
+ LanguageTag& rLanguageTag,
+ sal_Bool bAllowFallbacks )
{
::std::vector< ::rtl::OUString >::const_iterator pFound = lLocalizedValues.end();
if (bAllowFallbacks)
{
- pFound = ::comphelper::Locale::getFallback(lLocalizedValues, aLocale.toISO());
+ pFound = LanguageTag::getFallback(lLocalizedValues, rLanguageTag.getBcp47());
}
else
{
+ OUString aCheck( rLanguageTag.getBcp47());
for ( pFound = lLocalizedValues.begin();
pFound != lLocalizedValues.end() ;
++pFound )
{
- const ::rtl::OUString& sCheckISO = *pFound;
- ::comphelper::Locale aCheckLocale(sCheckISO);
- if (aCheckLocale.equals(aLocale))
+ if (*pFound == aCheck)
break;
}
}
- // if we found a valid locale ... take it over to our in/out parameter aLocale
+ // if we found a valid locale ... take it over to our in/out parameter rLanguageTag
if (pFound != lLocalizedValues.end())
{
- const ::rtl::OUString& sISOLocale = *pFound;
- aLocale.fromISO(sISOLocale);
+ rLanguageTag.reset( *pFound);
}
return pFound;
}
//-----------------------------------------------
-css::uno::Reference< css::embed::XStorage > PresetHandler::impl_openLocalizedPathIgnoringErrors(::rtl::OUString& sPath ,
- sal_Int32 eMode ,
- sal_Bool bShare ,
- ::comphelper::Locale& aLocale ,
- sal_Bool bAllowFallback)
+css::uno::Reference< css::embed::XStorage > PresetHandler::impl_openLocalizedPathIgnoringErrors(
+ ::rtl::OUString& sPath ,
+ sal_Int32 eMode ,
+ sal_Bool bShare ,
+ LanguageTag& rLanguageTag ,
+ sal_Bool bAllowFallback)
{
css::uno::Reference< css::embed::XStorage > xPath = impl_openPathIgnoringErrors(sPath, eMode, bShare);
::std::vector< ::rtl::OUString > lSubFolders = impl_getSubFolderNames(xPath);
- ::std::vector< ::rtl::OUString >::const_iterator pLocaleFolder = impl_findMatchingLocalizedValue(lSubFolders, aLocale, bAllowFallback);
+ ::std::vector< ::rtl::OUString >::const_iterator pLocaleFolder = impl_findMatchingLocalizedValue(lSubFolders, rLanguageTag, bAllowFallback);
// no fallback ... creation not allowed => no storage
if (
@@ -856,7 +857,7 @@ css::uno::Reference< css::embed::XStorage > PresetHandler::impl_openLocalizedPat
if (pLocaleFolder != lSubFolders.end())
sLocalizedPath += *pLocaleFolder;
else
- sLocalizedPath += aLocale.toISO();
+ sLocalizedPath += rLanguageTag.getBcp47();
css::uno::Reference< css::embed::XStorage > xLocalePath = impl_openPathIgnoringErrors(sLocalizedPath, eMode, bShare);
diff --git a/framework/source/inc/accelerators/acceleratorconfiguration.hxx b/framework/source/inc/accelerators/acceleratorconfiguration.hxx
index 99ba6a0a651b..38889fa93ffa 100644
--- a/framework/source/inc/accelerators/acceleratorconfiguration.hxx
+++ b/framework/source/inc/accelerators/acceleratorconfiguration.hxx
@@ -48,7 +48,7 @@
#include <cppuhelper/propshlp.hxx>
#include <cppuhelper/weak.hxx>
-#include <comphelper/locale.hxx>
+#include <i18npool/languagetag.hxx>
#include <salhelper/singletonref.hxx>
//__________________________________________
@@ -210,10 +210,10 @@ class XMLBasedAcceleratorConfiguration : protected ThreadHelpBase
@descr We does not cache this value, because we are not listen
for changes on the configuration layer ...
- @return ::comphelper::Locale
+ @return LanguageTag
The current office locale.
*/
- ::comphelper::Locale impl_ts_getLocale() const;
+ LanguageTag impl_ts_getLocale() const;
//______________________________________
// helper
@@ -428,10 +428,10 @@ class XCUBasedAcceleratorConfiguration : protected ThreadHelpBase
@descr We does not cache this value, because we are not listen
for changes on the configuration layer ...
- @return ::comphelper::Locale
+ @return LanguageTag
The current office locale.
*/
- ::comphelper::Locale impl_ts_getLocale() const;
+ LanguageTag impl_ts_getLocale() const;
//______________________________________
// helper
diff --git a/framework/source/inc/accelerators/presethandler.hxx b/framework/source/inc/accelerators/presethandler.hxx
index 922f12a4c945..c1069f320aa8 100644
--- a/framework/source/inc/accelerators/presethandler.hxx
+++ b/framework/source/inc/accelerators/presethandler.hxx
@@ -31,7 +31,7 @@
#include <comphelper/processfactory.hxx>
#include <salhelper/singletonref.hxx>
-#include <comphelper/locale.hxx>
+#include <i18npool/languagetag.hxx>
namespace framework
{
@@ -203,9 +203,9 @@ class PresetHandler : private ThreadHelpBase // attention! Must be the first bas
/** @short its the current office locale and will be used
to handle localized presets.
- @descr Default is "x-notranslate" which disable any
+ @descr Default is "x-no-translate" which disable any
localized handling inside this class! */
- ::comphelper::Locale m_aLocale;
+ LanguageTag m_aLanguageTag;
//---------------------------------------
/** @short knows the relative path from the root. */
@@ -306,7 +306,7 @@ class PresetHandler : private ThreadHelpBase // attention! Must be the first bas
configuration files. Note: Thats not the real root of the document ...
its only a sub storage. But we interpret it as our root storage.
- @param aLocale
+ @param rLanguageTag
in case this configuration supports localized entries,
the current locale must be set.
@@ -325,7 +325,7 @@ class PresetHandler : private ThreadHelpBase // attention! Must be the first bas
const ::rtl::OUString& sResourceType ,
const ::rtl::OUString& sModule ,
const css::uno::Reference< css::embed::XStorage >& xDocumentRoot ,
- const ::comphelper::Locale& aLocale = ::comphelper::Locale(::comphelper::Locale::X_NOTRANSLATE()));
+ const LanguageTag& rLanguageTag = LanguageTag(LANGUAGE_USER_PRIV_NOTRANSLATE));
//---------------------------------------
/** @short try to copy the specified preset from the share
@@ -442,9 +442,9 @@ class PresetHandler : private ThreadHelpBase // attention! Must be the first bas
b) search with using fallbacks
@param lLocalizedValues
- list of ISO locale codes
+ list of BCP47 language tags / locale codes
- @param aLocale
+ @param rLanguageTag
[IN ] the current office locale, which should be searched inside lLocalizedValues.
[OUT] in case fallbacks was allowed, it contains afterwards the fallback locale.
@@ -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,
- ::comphelper::Locale& aLocale ,
+ LanguageTag& rLanguageTag ,
sal_Bool bAllowFallbacks );
//---------------------------------------
@@ -477,7 +477,7 @@ class PresetHandler : private ThreadHelpBase // attention! Must be the first bas
@param bShare
force using of the share layer instead of the user layer.
- @param aLocale
+ @param rLanguageTag
[IN ] contains the start locale for searching localized sub dirs.
[OUT] contains the locale of a found localized sub dir
@@ -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 ,
- ::comphelper::Locale& aLocale ,
+ LanguageTag& rLanguageTag ,
sal_Bool bAllowFallback);
//---------------------------------------