LibreOffice Module unotools (master) 1
collatorwrapper.cxx
Go to the documentation of this file.
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>
24#include <com/sun/star/i18n/Collator.hpp>
25
26using namespace ::com::sun::star;
27
28CollatorWrapper::CollatorWrapper ( const uno::Reference< uno::XComponentContext > &rxContext )
29{
30 mxInternationalCollator = i18n::Collator::create( rxContext );
31}
32
33sal_Int32
34CollatorWrapper::compareString (const OUString& s1, const OUString& s2) const
35{
36 try
37 {
39 return mxInternationalCollator->compareString (s1, s2);
40 }
41 catch (const uno::RuntimeException&)
42 {
43 SAL_WARN( "unotools.i18n","CollatorWrapper: compareString failed");
44 }
45
46 return 0;
47}
48
49uno::Sequence< OUString >
50CollatorWrapper::listCollatorAlgorithms (const lang::Locale& rLocale) const
51{
52 try
53 {
55 return mxInternationalCollator->listCollatorAlgorithms (rLocale);
56 }
57 catch (const uno::RuntimeException&)
58 {
59 SAL_WARN( "unotools.i18n","CollatorWrapper: listCollatorAlgorithms failed");
60 }
61
62 return uno::Sequence< OUString > ();
63}
64
65sal_Int32
66CollatorWrapper::loadDefaultCollator (const lang::Locale& rLocale, sal_Int32 nOptions)
67{
68 try
69 {
71 return mxInternationalCollator->loadDefaultCollator (rLocale, nOptions);
72 }
73 catch (const uno::RuntimeException&)
74 {
75 SAL_WARN( "unotools.i18n","CollatorWrapper: loadDefaultCollator failed");
76 }
77
78 return 0;
79}
80
81void
82CollatorWrapper::loadCollatorAlgorithm (const OUString& rAlgorithm,
83 const lang::Locale& rLocale, sal_Int32 nOptions)
84{
85 try
86 {
88 mxInternationalCollator->loadCollatorAlgorithm (
89 rAlgorithm, rLocale, nOptions);
90 }
91 catch (const uno::RuntimeException&)
92 {
93 SAL_WARN( "unotools.i18n","CollatorWrapper: loadCollatorAlgorithm failed");
94 }
95}
96
97/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int32 loadDefaultCollator(const css::lang::Locale &rLocale, sal_Int32 nOption)
CollatorWrapper(const css::uno::Reference< css::uno::XComponentContext > &rxContext)
sal_Int32 compareString(const OUString &s1, const OUString &s2) const
css::uno::Reference< css::i18n::XCollator > mxInternationalCollator
void loadCollatorAlgorithm(const OUString &rAlgorithm, const css::lang::Locale &rLocale, sal_Int32 nOption)
css::uno::Sequence< OUString > listCollatorAlgorithms(const css::lang::Locale &rLocale) const
#define SAL_WARN(area, stream)