diff options
author | Eike Rathke <erack@redhat.com> | 2011-11-18 21:26:39 +0100 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2011-11-19 16:15:21 +0100 |
commit | 29e4c61d9dbcb75a608e090e0703ed996cfa060a (patch) | |
tree | 072543589ded25e2ce7edda1368adbd74acbd296 /unotools | |
parent | implement possessive genitive case month names locale data API (diff) | |
download | core-29e4c61d9dbcb75a608e090e0703ed996cfa060a.tar.gz core-29e4c61d9dbcb75a608e090e0703ed996cfa060a.zip |
use new possessive genitive case month names locale data API
Diffstat (limited to 'unotools')
-rw-r--r-- | unotools/inc/unotools/calendarwrapper.hxx | 15 | ||||
-rw-r--r-- | unotools/inc/unotools/localedatawrapper.hxx | 11 | ||||
-rw-r--r-- | unotools/source/i18n/calendarwrapper.cxx | 69 | ||||
-rw-r--r-- | unotools/source/i18n/localedatawrapper.cxx | 54 |
4 files changed, 91 insertions, 58 deletions
diff --git a/unotools/inc/unotools/calendarwrapper.hxx b/unotools/inc/unotools/calendarwrapper.hxx index 7d0ffd32acf7..e2785399e3cb 100644 --- a/unotools/inc/unotools/calendarwrapper.hxx +++ b/unotools/inc/unotools/calendarwrapper.hxx @@ -33,7 +33,7 @@ #include <tools/string.hxx> #include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/uno/Sequence.hxx> -#include <com/sun/star/i18n/Calendar.hpp> +#include <com/sun/star/i18n/Calendar2.hpp> #include <com/sun/star/lang/Locale.hpp> #include "unotools/unotoolsdllapi.h" @@ -45,7 +45,7 @@ namespace com { namespace sun { namespace star { namespace com { namespace sun { namespace star { namespace i18n { - class XExtendedCalendar; + class XCalendar3; } }}} @@ -53,7 +53,7 @@ namespace com { namespace sun { namespace star { class UNOTOOLS_DLLPUBLIC CalendarWrapper { ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xSMgr; - ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XExtendedCalendar > xC; + ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XCalendar3 > xC; DateTime aEpochStart; // 1Jan1970 @@ -68,7 +68,6 @@ public: void loadDefaultCalendar( const ::com::sun::star::lang::Locale& rLocale ); void loadCalendar( const ::rtl::OUString& rUniqueID, const ::com::sun::star::lang::Locale& rLocale ); - ::com::sun::star::i18n::Calendar getLoadedCalendar() const; ::com::sun::star::uno::Sequence< ::rtl::OUString > getAllCalendars( const ::com::sun::star::lang::Locale& rLocale ) const; ::rtl::OUString getUniqueID() const; /// set UTC date/time @@ -80,6 +79,7 @@ public: /// convenience method to get local date/time double getLocalDateTime() const; + // wrapper implementations of XCalendar void setValue( sal_Int16 nFieldIndex, sal_Int16 nValue ); @@ -102,11 +102,18 @@ public: fields DST_OFFSET and DST_OFFSET_SECOND_MILLIS into account. */ sal_Int32 getDSTOffsetInMillis() const; + // wrapper implementations of XExtendedCalendar String getDisplayString( sal_Int32 nCalendarDisplayCode, sal_Int16 nNativeNumberMode ) const; + // wrapper implementations of XCalendar3 + + ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem > getGenitiveMonths() const; + ::com::sun::star::i18n::Calendar2 getLoadedCalendar() const; + + // convenience methods /// get epoch start (should be 01Jan1970) diff --git a/unotools/inc/unotools/localedatawrapper.hxx b/unotools/inc/unotools/localedatawrapper.hxx index 8ff4e46da058..8564bfacfac4 100644 --- a/unotools/inc/unotools/localedatawrapper.hxx +++ b/unotools/inc/unotools/localedatawrapper.hxx @@ -30,7 +30,7 @@ #define _UNOTOOLS_LOCALEDATAWRAPPER_HXX #include <tools/string.hxx> -#include <com/sun/star/i18n/XLocaleData2.hpp> +#include <com/sun/star/i18n/XLocaleData3.hpp> #include <com/sun/star/i18n/LocaleItem.hpp> #include <com/sun/star/i18n/reservedWords.hpp> #include <unotools/readwritemutexguard.hxx> @@ -67,9 +67,9 @@ class UNOTOOLS_DLLPUBLIC LocaleDataWrapper static sal_uInt8 nLocaleDataChecking; // 0:=dontknow, 1:=yes, 2:=no ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > xSMgr; - ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XLocaleData2 > xLD; + ::com::sun::star::uno::Reference< ::com::sun::star::i18n::XLocaleData3 > xLD; ::com::sun::star::lang::Locale aLocale; - ::boost::shared_ptr< ::com::sun::star::i18n::Calendar > xDefaultCalendar; + ::boost::shared_ptr< ::com::sun::star::i18n::Calendar2 > xDefaultCalendar; ::com::sun::star::i18n::LocaleDataItem aLocaleDataItem; ::com::sun::star::uno::Sequence< ::rtl::OUString > aReservedWordSeq; ::com::sun::star::uno::Sequence< sal_Int32 > aGrouping; @@ -153,7 +153,8 @@ public: ::com::sun::star::i18n::LanguageCountryInfo getLanguageCountryInfo() const; ::com::sun::star::i18n::LocaleDataItem getLocaleItem() const; - ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::Calendar > getAllCalendars() const; + /// NOTE: this wraps XLocaleData3::getAllCalendars2() in fact. + ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::Calendar2 > getAllCalendars() const; /// NOTE: this wraps XLocaleData2::getAllCurrencies2() in fact. ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::Currency2 > getAllCurrencies() const; ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::FormatElement > getAllFormats() const; @@ -179,7 +180,7 @@ public: MeasurementSystem mapMeasurementStringToEnum( const String& rMS ) const; /// Convenience method to obtain the default calendar. - const ::boost::shared_ptr< ::com::sun::star::i18n::Calendar > getDefaultCalendar() const; + const ::boost::shared_ptr< ::com::sun::star::i18n::Calendar2 > getDefaultCalendar() const; /// Convenience method to obtain the day names of the default calendar. const ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem > getDefaultCalendarDays() const; diff --git a/unotools/source/i18n/calendarwrapper.cxx b/unotools/source/i18n/calendarwrapper.cxx index 67e6e24e053b..5b7f4155eb58 100644 --- a/unotools/source/i18n/calendarwrapper.cxx +++ b/unotools/source/i18n/calendarwrapper.cxx @@ -34,7 +34,7 @@ #include <tools/debug.hxx> #include <instance.hxx> #include <com/sun/star/i18n/CalendarFieldIndex.hpp> -#include <com/sun/star/i18n/XExtendedCalendar.hpp> +#include <com/sun/star/i18n/XCalendar3.hpp> #define CALENDAR_LIBRARYNAME "i18n" #define CALENDAR_SERVICENAME "com.sun.star.i18n.LocaleCalendar" @@ -54,7 +54,7 @@ CalendarWrapper::CalendarWrapper( xSMgr( xSF ), aEpochStart( Date( 1, 1, 1970 ) ) { - xC = Reference< XExtendedCalendar >( intl_createInstance( xSMgr, CALENDAR_SERVICENAME, "CalendarWrapper" ), uno::UNO_QUERY ); + xC = Reference< XCalendar3 >( intl_createInstance( xSMgr, CALENDAR_SERVICENAME, "CalendarWrapper" ), uno::UNO_QUERY ); } CalendarWrapper::~CalendarWrapper() @@ -107,27 +107,6 @@ void CalendarWrapper::loadCalendar( const ::rtl::OUString& rUniqueID, const ::co } -::com::sun::star::i18n::Calendar CalendarWrapper::getLoadedCalendar() const -{ - try - { - if ( xC.is() ) - return xC->getLoadedCalendar(); - } - catch ( Exception& e ) - { -#ifdef DBG_UTIL - ByteString aMsg( "getLoadedCalendar: Exception caught\n" ); - aMsg += ByteString( String( e.Message ), RTL_TEXTENCODING_UTF8 ); - DBG_ERRORFILE( aMsg.GetBuffer() ); -#else - (void)e; -#endif - } - return ::com::sun::star::i18n::Calendar(); -} - - ::com::sun::star::uno::Sequence< ::rtl::OUString > CalendarWrapper::getAllCalendars( const ::com::sun::star::lang::Locale& rLocale ) const { try @@ -609,4 +588,48 @@ String CalendarWrapper::getDisplayString( sal_Int32 nCalendarDisplayCode, sal_In return String(); } + +// --- XCalendar3 ------------------------------------------------------------ + +::com::sun::star::i18n::Calendar2 CalendarWrapper::getLoadedCalendar() const +{ + try + { + if ( xC.is() ) + return xC->getLoadedCalendar2(); + } + catch ( Exception& e ) + { +#ifdef DBG_UTIL + ByteString aMsg( "getLoadedCalendar2: Exception caught\n" ); + aMsg += ByteString( String( e.Message ), RTL_TEXTENCODING_UTF8 ); + DBG_ERRORFILE( aMsg.GetBuffer() ); +#else + (void)e; +#endif + } + return ::com::sun::star::i18n::Calendar2(); +} + + +::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem > CalendarWrapper::getGenitiveMonths() const +{ + try + { + if ( xC.is() ) + return xC->getGenitiveMonths(); + } + catch ( Exception& e ) + { +#ifdef DBG_UTIL + ByteString aMsg( "getGenitiveMonths: Exception caught\n" ); + aMsg += ByteString( String( e.Message ), RTL_TEXTENCODING_UTF8 ); + DBG_ERRORFILE( aMsg.GetBuffer() ); +#else + (void)e; +#endif + } + return ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::CalendarItem > (0); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/unotools/source/i18n/localedatawrapper.cxx b/unotools/source/i18n/localedatawrapper.cxx index 6bb166fdc7a4..81960aafff24 100644 --- a/unotools/source/i18n/localedatawrapper.cxx +++ b/unotools/source/i18n/localedatawrapper.cxx @@ -84,7 +84,7 @@ LocaleDataWrapper::LocaleDataWrapper( bReservedWordValid( sal_False ) { setLocale( rLocale ); - xLD = Reference< XLocaleData2 > ( + xLD = Reference< XLocaleData3 > ( intl_createInstance( xSMgr, "com.sun.star.i18n.LocaleData", "LocaleDataWrapper" ), uno::UNO_QUERY ); } @@ -182,27 +182,6 @@ void LocaleDataWrapper::invalidateData() } -::com::sun::star::uno::Sequence< ::com::sun::star::i18n::Calendar > LocaleDataWrapper::getAllCalendars() const -{ - try - { - if ( xLD.is() ) - return xLD->getAllCalendars( getLocale() ); - } - catch ( Exception& e ) - { -#ifdef DBG_UTIL - ByteString aMsg( "getAllCalendars: Exception caught\n" ); - aMsg += ByteString( String( e.Message ), RTL_TEXTENCODING_UTF8 ); - DBG_ERRORFILE( aMsg.GetBuffer() ); -#else - (void)e; -#endif - } - return ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::Calendar >(0); -} - - ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::Currency2 > LocaleDataWrapper::getAllCurrencies() const { try @@ -603,12 +582,12 @@ void LocaleDataWrapper::getDefaultCalendarImpl() { if (!xDefaultCalendar) { - Sequence< Calendar > xCals = getAllCalendars(); + Sequence< Calendar2 > xCals = getAllCalendars(); sal_Int32 nCount = xCals.getLength(); sal_Int32 nDef = 0; if (nCount > 1) { - const Calendar* pArr = xCals.getArray(); + const Calendar2* pArr = xCals.getArray(); for (sal_Int32 i=0; i<nCount; ++i) { if (pArr[i].Default) @@ -618,12 +597,12 @@ void LocaleDataWrapper::getDefaultCalendarImpl() } } } - xDefaultCalendar.reset( new Calendar( xCals[nDef])); + xDefaultCalendar.reset( new Calendar2( xCals[nDef])); } } -const ::boost::shared_ptr< ::com::sun::star::i18n::Calendar > LocaleDataWrapper::getDefaultCalendar() const +const ::boost::shared_ptr< ::com::sun::star::i18n::Calendar2 > LocaleDataWrapper::getDefaultCalendar() const { ::utl::ReadWriteGuard aGuard( aMutex ); if (!xDefaultCalendar) @@ -1950,4 +1929,27 @@ void LocaleDataWrapper::evaluateLocaleDataChecking() } } + +// --- XLocaleData3 ---------------------------------------------------------- + +::com::sun::star::uno::Sequence< ::com::sun::star::i18n::Calendar2 > LocaleDataWrapper::getAllCalendars() const +{ + try + { + if ( xLD.is() ) + return xLD->getAllCalendars2( getLocale() ); + } + catch ( Exception& e ) + { +#ifdef DBG_UTIL + ByteString aMsg( "getAllCalendars: Exception caught\n" ); + aMsg += ByteString( String( e.Message ), RTL_TEXTENCODING_UTF8 ); + DBG_ERRORFILE( aMsg.GetBuffer() ); +#else + (void)e; +#endif + } + return ::com::sun::star::uno::Sequence< ::com::sun::star::i18n::Calendar2 >(0); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |