1*b5088357SAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
3*b5088357SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
4*b5088357SAndrew Rist * or more contributor license agreements. See the NOTICE file
5*b5088357SAndrew Rist * distributed with this work for additional information
6*b5088357SAndrew Rist * regarding copyright ownership. The ASF licenses this file
7*b5088357SAndrew Rist * to you under the Apache License, Version 2.0 (the
8*b5088357SAndrew Rist * "License"); you may not use this file except in compliance
9*b5088357SAndrew Rist * with the License. You may obtain a copy of the License at
10*b5088357SAndrew Rist *
11*b5088357SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12*b5088357SAndrew Rist *
13*b5088357SAndrew Rist * Unless required by applicable law or agreed to in writing,
14*b5088357SAndrew Rist * software distributed under the License is distributed on an
15*b5088357SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*b5088357SAndrew Rist * KIND, either express or implied. See the License for the
17*b5088357SAndrew Rist * specific language governing permissions and limitations
18*b5088357SAndrew Rist * under the License.
19*b5088357SAndrew Rist *
20*b5088357SAndrew Rist *************************************************************/
21*b5088357SAndrew Rist
22*b5088357SAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_unotools.hxx"
26cdf0e10cSrcweir
27cdf0e10cSrcweir #include "unotools/intlwrapper.hxx"
28cdf0e10cSrcweir #include <com/sun/star/i18n/CollatorOptions.hpp>
29cdf0e10cSrcweir #include <i18npool/mslangid.hxx>
30cdf0e10cSrcweir
IntlWrapper(const::com::sun::star::uno::Reference<::com::sun::star::lang::XMultiServiceFactory> & xSF,const::com::sun::star::lang::Locale & rLocale)31cdf0e10cSrcweir IntlWrapper::IntlWrapper(
32cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & xSF,
33cdf0e10cSrcweir const ::com::sun::star::lang::Locale& rLocale )
34cdf0e10cSrcweir :
35cdf0e10cSrcweir aLocale( rLocale ),
36cdf0e10cSrcweir xSMgr( xSF ),
37cdf0e10cSrcweir pCharClass( NULL ),
38cdf0e10cSrcweir pLocaleData( NULL ),
39cdf0e10cSrcweir pCalendar( NULL ),
40cdf0e10cSrcweir pCollator( NULL ),
41cdf0e10cSrcweir pCaseCollator( NULL )
42cdf0e10cSrcweir {
43cdf0e10cSrcweir eLanguage = MsLangId::convertLocaleToLanguage( aLocale );
44cdf0e10cSrcweir }
45cdf0e10cSrcweir
46cdf0e10cSrcweir
IntlWrapper(const::com::sun::star::uno::Reference<::com::sun::star::lang::XMultiServiceFactory> & xSF,LanguageType eLang)47cdf0e10cSrcweir IntlWrapper::IntlWrapper(
48cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > & xSF,
49cdf0e10cSrcweir LanguageType eLang )
50cdf0e10cSrcweir :
51cdf0e10cSrcweir xSMgr( xSF ),
52cdf0e10cSrcweir pCharClass( NULL ),
53cdf0e10cSrcweir pLocaleData( NULL ),
54cdf0e10cSrcweir pCalendar( NULL ),
55cdf0e10cSrcweir pCollator( NULL ),
56cdf0e10cSrcweir pCaseCollator( NULL ),
57cdf0e10cSrcweir eLanguage( eLang )
58cdf0e10cSrcweir {
59cdf0e10cSrcweir MsLangId::convertLanguageToLocale( eLanguage, aLocale );
60cdf0e10cSrcweir }
61cdf0e10cSrcweir
62cdf0e10cSrcweir
~IntlWrapper()63cdf0e10cSrcweir IntlWrapper::~IntlWrapper()
64cdf0e10cSrcweir {
65cdf0e10cSrcweir delete pCharClass;
66cdf0e10cSrcweir delete pLocaleData;
67cdf0e10cSrcweir delete pCalendar;
68cdf0e10cSrcweir delete pCollator;
69cdf0e10cSrcweir delete pCaseCollator;
70cdf0e10cSrcweir }
71cdf0e10cSrcweir
72cdf0e10cSrcweir
ImplNewCharClass() const73cdf0e10cSrcweir void IntlWrapper::ImplNewCharClass() const
74cdf0e10cSrcweir {
75cdf0e10cSrcweir ((IntlWrapper*)this)->pCharClass = new CharClass( xSMgr, aLocale );
76cdf0e10cSrcweir }
77cdf0e10cSrcweir
78cdf0e10cSrcweir
ImplNewLocaleData() const79cdf0e10cSrcweir void IntlWrapper::ImplNewLocaleData() const
80cdf0e10cSrcweir {
81cdf0e10cSrcweir ((IntlWrapper*)this)->pLocaleData = new LocaleDataWrapper( xSMgr, aLocale );
82cdf0e10cSrcweir }
83cdf0e10cSrcweir
84cdf0e10cSrcweir
ImplNewCalendar() const85cdf0e10cSrcweir void IntlWrapper::ImplNewCalendar() const
86cdf0e10cSrcweir {
87cdf0e10cSrcweir CalendarWrapper* p = new CalendarWrapper( xSMgr );
88cdf0e10cSrcweir p->loadDefaultCalendar( aLocale );
89cdf0e10cSrcweir ((IntlWrapper*)this)->pCalendar = p;
90cdf0e10cSrcweir }
91cdf0e10cSrcweir
92cdf0e10cSrcweir
ImplNewCollator(sal_Bool bCaseSensitive) const93cdf0e10cSrcweir void IntlWrapper::ImplNewCollator( sal_Bool bCaseSensitive ) const
94cdf0e10cSrcweir {
95cdf0e10cSrcweir CollatorWrapper* p = new CollatorWrapper( xSMgr );
96cdf0e10cSrcweir if ( bCaseSensitive )
97cdf0e10cSrcweir {
98cdf0e10cSrcweir p->loadDefaultCollator( aLocale, 0 );
99cdf0e10cSrcweir ((IntlWrapper*)this)->pCaseCollator = p;
100cdf0e10cSrcweir }
101cdf0e10cSrcweir else
102cdf0e10cSrcweir {
103cdf0e10cSrcweir p->loadDefaultCollator( aLocale, ::com::sun::star::i18n::CollatorOptions::CollatorOptions_IGNORE_CASE );
104cdf0e10cSrcweir ((IntlWrapper*)this)->pCollator = p;
105cdf0e10cSrcweir }
106cdf0e10cSrcweir }
107