/src/libreoffice/unotools/source/i18n/collatorwrapper.cxx
Line | Count | Source |
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 | | CollatorWrapper::CollatorWrapper ( const uno::Reference< uno::XComponentContext > &rxContext ) |
29 | 3 | { |
30 | 3 | mxInternationalCollator = i18n::Collator::create( rxContext ); |
31 | 3 | } |
32 | | |
33 | | sal_Int32 |
34 | | CollatorWrapper::compareString (const OUString& s1, const OUString& s2) const |
35 | 36.4k | { |
36 | 36.4k | try |
37 | 36.4k | { |
38 | 36.4k | if (mxInternationalCollator.is()) |
39 | 36.4k | return mxInternationalCollator->compareString (s1, s2); |
40 | 36.4k | } |
41 | 36.4k | catch (const uno::RuntimeException&) |
42 | 36.4k | { |
43 | 0 | SAL_WARN( "unotools.i18n","CollatorWrapper: compareString failed"); |
44 | 0 | } |
45 | | |
46 | 0 | return 0; |
47 | 36.4k | } |
48 | | |
49 | | uno::Sequence< OUString > |
50 | | CollatorWrapper::listCollatorAlgorithms (const lang::Locale& rLocale) const |
51 | 0 | { |
52 | 0 | try |
53 | 0 | { |
54 | 0 | if (mxInternationalCollator.is()) |
55 | 0 | return mxInternationalCollator->listCollatorAlgorithms (rLocale); |
56 | 0 | } |
57 | 0 | catch (const uno::RuntimeException&) |
58 | 0 | { |
59 | 0 | SAL_WARN( "unotools.i18n","CollatorWrapper: listCollatorAlgorithms failed"); |
60 | 0 | } |
61 | | |
62 | 0 | return uno::Sequence< OUString > (); |
63 | 0 | } |
64 | | |
65 | | sal_Int32 |
66 | | CollatorWrapper::loadDefaultCollator (const lang::Locale& rLocale, sal_Int32 nOptions) |
67 | 3 | { |
68 | 3 | try |
69 | 3 | { |
70 | 3 | if (mxInternationalCollator.is()) |
71 | 3 | return mxInternationalCollator->loadDefaultCollator (rLocale, nOptions); |
72 | 3 | } |
73 | 3 | catch (const uno::RuntimeException&) |
74 | 3 | { |
75 | 0 | SAL_WARN( "unotools.i18n","CollatorWrapper: loadDefaultCollator failed"); |
76 | 0 | } |
77 | | |
78 | 0 | return 0; |
79 | 3 | } |
80 | | |
81 | | void |
82 | | CollatorWrapper::loadCollatorAlgorithm (const OUString& rAlgorithm, |
83 | | const lang::Locale& rLocale, sal_Int32 nOptions) |
84 | 0 | { |
85 | 0 | try |
86 | 0 | { |
87 | 0 | if (mxInternationalCollator.is()) |
88 | 0 | mxInternationalCollator->loadCollatorAlgorithm ( |
89 | 0 | rAlgorithm, rLocale, nOptions); |
90 | 0 | } |
91 | 0 | catch (const uno::RuntimeException&) |
92 | 0 | { |
93 | 0 | SAL_WARN( "unotools.i18n","CollatorWrapper: loadCollatorAlgorithm failed"); |
94 | 0 | } |
95 | 0 | } |
96 | | |
97 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |