Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 :
21 : #include "unotools/intlwrapper.hxx"
22 : #include <com/sun/star/i18n/CollatorOptions.hpp>
23 : #include <i18npool/mslangid.hxx>
24 : #include <comphelper/processfactory.hxx>
25 :
26 0 : IntlWrapper::IntlWrapper(
27 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rxContext,
28 : const LanguageTag& rLanguageTag )
29 : :
30 : maLanguageTag( rLanguageTag ),
31 : m_xContext( rxContext ),
32 : pLocaleData( NULL ),
33 : pCollator( NULL ),
34 0 : pCaseCollator( NULL )
35 : {
36 0 : }
37 :
38 0 : IntlWrapper::IntlWrapper(
39 : const LanguageTag& rLanguageTag )
40 : :
41 : maLanguageTag( rLanguageTag ),
42 : m_xContext( comphelper::getProcessComponentContext() ),
43 : pLocaleData( NULL ),
44 : pCollator( NULL ),
45 0 : pCaseCollator( NULL )
46 : {
47 0 : }
48 :
49 0 : IntlWrapper::~IntlWrapper()
50 : {
51 0 : delete pLocaleData;
52 0 : delete pCollator;
53 0 : delete pCaseCollator;
54 0 : }
55 :
56 :
57 0 : void IntlWrapper::ImplNewLocaleData() const
58 : {
59 0 : ((IntlWrapper*)this)->pLocaleData = new LocaleDataWrapper( m_xContext, maLanguageTag );
60 0 : }
61 :
62 :
63 0 : void IntlWrapper::ImplNewCollator( sal_Bool bCaseSensitive ) const
64 : {
65 0 : CollatorWrapper* p = new CollatorWrapper( m_xContext );
66 0 : if ( bCaseSensitive )
67 : {
68 0 : p->loadDefaultCollator( maLanguageTag.getLocale(), 0 );
69 0 : ((IntlWrapper*)this)->pCaseCollator = p;
70 : }
71 : else
72 : {
73 0 : p->loadDefaultCollator( maLanguageTag.getLocale(),
74 0 : ::com::sun::star::i18n::CollatorOptions::CollatorOptions_IGNORE_CASE );
75 0 : ((IntlWrapper*)this)->pCollator = p;
76 : }
77 0 : }
78 :
79 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|