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