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/collatorwrapper.hxx>
21 : #include <tools/debug.hxx>
22 : #include <com/sun/star/i18n/Collator.hpp>
23 :
24 : using namespace ::com::sun::star;
25 :
26 0 : CollatorWrapper::CollatorWrapper ( const uno::Reference< uno::XComponentContext > &rxContext )
27 : {
28 0 : mxInternationalCollator = i18n::Collator::create( rxContext );
29 0 : }
30 :
31 0 : CollatorWrapper::~CollatorWrapper()
32 : {
33 0 : }
34 :
35 : sal_Int32
36 0 : CollatorWrapper::compareString (const OUString& s1, const OUString& s2) const
37 : {
38 : try
39 : {
40 0 : if (mxInternationalCollator.is())
41 0 : return mxInternationalCollator->compareString (s1, s2);
42 : }
43 0 : catch (const uno::RuntimeException&)
44 : {
45 : SAL_WARN( "unotools.i18n","CollatorWrapper: compareString failed");
46 : }
47 :
48 0 : return 0;
49 : }
50 :
51 : uno::Sequence< OUString >
52 0 : CollatorWrapper::listCollatorAlgorithms (const lang::Locale& rLocale) const
53 : {
54 : try
55 : {
56 0 : if (mxInternationalCollator.is())
57 0 : return mxInternationalCollator->listCollatorAlgorithms (rLocale);
58 : }
59 0 : catch (const uno::RuntimeException&)
60 : {
61 : SAL_WARN( "unotools.i18n","CollatorWrapper: listCollatorAlgorithms failed");
62 : }
63 :
64 0 : return uno::Sequence< OUString > ();
65 : }
66 :
67 : sal_Int32
68 0 : CollatorWrapper::loadDefaultCollator (const lang::Locale& rLocale, sal_Int32 nOptions)
69 : {
70 : try
71 : {
72 0 : if (mxInternationalCollator.is())
73 0 : return mxInternationalCollator->loadDefaultCollator (rLocale, nOptions);
74 : }
75 0 : catch (const uno::RuntimeException&)
76 : {
77 : SAL_WARN( "unotools.i18n","CollatorWrapper: loadDefaultCollator failed");
78 : }
79 :
80 0 : return 0;
81 : }
82 :
83 : sal_Int32
84 0 : CollatorWrapper::loadCollatorAlgorithm (const OUString& rAlgorithm,
85 : const lang::Locale& rLocale, sal_Int32 nOptions)
86 : {
87 : try
88 : {
89 0 : if (mxInternationalCollator.is())
90 0 : return mxInternationalCollator->loadCollatorAlgorithm (
91 0 : rAlgorithm, rLocale, nOptions);
92 : }
93 0 : catch (const uno::RuntimeException&)
94 : {
95 : SAL_WARN( "unotools.i18n","CollatorWrapper: loadCollatorAlgorithm failed");
96 : }
97 :
98 0 : return 0;
99 :
100 : }
101 :
102 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|