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