diff options
author | Eike Rathke <er@openoffice.org> | 2001-01-16 14:41:30 +0000 |
---|---|---|
committer | Eike Rathke <er@openoffice.org> | 2001-01-16 14:41:30 +0000 |
commit | d682b08a98f3c7292cbcb5bfd358bb1b895ec62c (patch) | |
tree | b6ac5626bfc9cb4270594ca79b703ac2a2df69f1 /unotools | |
parent | 1e982605500b3ff542b1ef557791611496b83463 (diff) |
add: getInstalledLocaleNames
Diffstat (limited to 'unotools')
-rw-r--r-- | unotools/inc/unotools/localedatawrapper.hxx | 10 | ||||
-rw-r--r-- | unotools/source/i18n/localedatawrapper.cxx | 45 |
2 files changed, 51 insertions, 4 deletions
diff --git a/unotools/inc/unotools/localedatawrapper.hxx b/unotools/inc/unotools/localedatawrapper.hxx index b846e5b1545d..bedbba2252a9 100644 --- a/unotools/inc/unotools/localedatawrapper.hxx +++ b/unotools/inc/unotools/localedatawrapper.hxx @@ -2,9 +2,9 @@ * * $RCSfile: localedatawrapper.hxx,v $ * - * $Revision: 1.7 $ + * $Revision: 1.8 $ * - * last change: $Author: er $ $Date: 2000-11-18 18:53:10 $ + * last change: $Author: er $ $Date: 2001-01-16 15:40:54 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -88,6 +88,8 @@ namespace com { namespace sun { namespace star { class LocaleDataWrapper { + static ::com::sun::star::uno::Sequence< ::com::sun::star::lang::Locale > xInstalledLocales; + ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xSMgr; ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XLocaleData > xLD; ::com::sun::star::lang::Locale aLocale; @@ -164,6 +166,10 @@ public: ::com::sun::star::uno::Sequence< ::rtl::OUString > getTransliterations() const; ::com::sun::star::i18n::ForbiddenCharacters getForbiddenCharacters() const; ::com::sun::star::uno::Sequence< ::rtl::OUString > getReservedWord() const; + ::com::sun::star::uno::Sequence< ::com::sun::star::lang::Locale > getAllInstalledLocaleNames() const; + + /// same as the wrapper implementation but static + static ::com::sun::star::uno::Sequence< ::com::sun::star::lang::Locale > getInstalledLocaleNames(); /// maps the LocaleData string to the International enum diff --git a/unotools/source/i18n/localedatawrapper.cxx b/unotools/source/i18n/localedatawrapper.cxx index a98637248473..f36ac66ff350 100644 --- a/unotools/source/i18n/localedatawrapper.cxx +++ b/unotools/source/i18n/localedatawrapper.cxx @@ -2,9 +2,9 @@ * * $RCSfile: localedatawrapper.cxx,v $ * - * $Revision: 1.8 $ + * $Revision: 1.9 $ * - * last change: $Author: er $ $Date: 2000-11-18 18:56:34 $ + * last change: $Author: er $ $Date: 2001-01-16 15:41:30 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -73,6 +73,10 @@ #include <comphelper/componentfactory.hxx> #endif +#ifndef _UNOTOOLS_PROCESSFACTORY_HXX_ +#include <unotools/processfactory.hxx> +#endif + #ifndef _COM_SUN_STAR_UNO_XINTERFACE_HPP_ #include <com/sun/star/uno/XInterface.hpp> #endif @@ -103,6 +107,9 @@ using namespace ::com::sun::star; using namespace ::com::sun::star::i18n; using namespace ::com::sun::star::uno; +uno::Sequence< lang::Locale > LocaleDataWrapper::xInstalledLocales = + uno::Sequence< lang::Locale >(0); + LocaleDataWrapper::LocaleDataWrapper( const Reference< lang::XMultiServiceFactory > & xSF, @@ -367,8 +374,42 @@ void LocaleDataWrapper::invalidateData() } +::com::sun::star::uno::Sequence< ::com::sun::star::lang::Locale > LocaleDataWrapper::getAllInstalledLocaleNames() const +{ + if ( xInstalledLocales.getLength() ) + return xInstalledLocales; + + try + { + if ( xLD.is() ) + xInstalledLocales = xLD->getAllInstalledLocaleNames(); + } + catch ( Exception& e ) + { +#ifndef PRODUCT + ByteString aMsg( "getAllInstalledLocaleNames: Exception caught\n" ); + aMsg += ByteString( String( e.Message ), RTL_TEXTENCODING_UTF8 ); + DBG_ERRORFILE( aMsg.GetBuffer() ); +#endif + } + return xInstalledLocales; +} + + // --- Impl and helpers ---------------------------------------------------- +// static +::com::sun::star::uno::Sequence< ::com::sun::star::lang::Locale > LocaleDataWrapper::getInstalledLocaleNames() +{ + if ( !xInstalledLocales.getLength() ) + { + LocaleDataWrapper aLDW( ::utl::getProcessServiceFactory(), lang::Locale() ); + aLDW.getAllInstalledLocaleNames(); + } + return xInstalledLocales; +} + + const String& LocaleDataWrapper::getOneLocaleItem( sal_Int16 nItem ) const { if ( nItem >= LocaleItem::COUNT ) |