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 : #include "unotools/intlwrapper.hxx"
21 : #include <com/sun/star/i18n/CollatorOptions.hpp>
22 : #include <i18nlangtag/mslangid.hxx>
23 : #include <comphelper/processfactory.hxx>
24 :
25 0 : IntlWrapper::IntlWrapper(
26 : const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & rxContext,
27 : const LanguageTag& rLanguageTag )
28 : :
29 : maLanguageTag( rLanguageTag ),
30 : m_xContext( rxContext ),
31 : pLocaleData( NULL ),
32 : pCollator( NULL ),
33 0 : pCaseCollator( NULL )
34 : {
35 0 : }
36 :
37 0 : IntlWrapper::IntlWrapper(
38 : const LanguageTag& rLanguageTag )
39 : :
40 : maLanguageTag( rLanguageTag ),
41 : m_xContext( comphelper::getProcessComponentContext() ),
42 : pLocaleData( NULL ),
43 : pCollator( NULL ),
44 0 : pCaseCollator( NULL )
45 : {
46 0 : }
47 :
48 0 : IntlWrapper::~IntlWrapper()
49 : {
50 0 : delete pLocaleData;
51 0 : delete pCollator;
52 0 : delete pCaseCollator;
53 0 : }
54 :
55 0 : void IntlWrapper::ImplNewLocaleData() const
56 : {
57 0 : ((IntlWrapper*)this)->pLocaleData = new LocaleDataWrapper( m_xContext, maLanguageTag );
58 0 : }
59 :
60 0 : void IntlWrapper::ImplNewCollator( bool bCaseSensitive ) const
61 : {
62 0 : CollatorWrapper* p = new CollatorWrapper( m_xContext );
63 0 : if ( bCaseSensitive )
64 : {
65 0 : p->loadDefaultCollator( maLanguageTag.getLocale(), 0 );
66 0 : ((IntlWrapper*)this)->pCaseCollator = p;
67 : }
68 : else
69 : {
70 0 : p->loadDefaultCollator( maLanguageTag.getLocale(),
71 0 : ::com::sun::star::i18n::CollatorOptions::CollatorOptions_IGNORE_CASE );
72 0 : ((IntlWrapper*)this)->pCollator = p;
73 : }
74 0 : }
75 :
76 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|