update credits
[LibreOffice.git] / unotools / source / i18n / collatorwrapper.cxx
blob3a9cf3fd278f44784e84a14c980373fd6c5242c2
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <unotools/collatorwrapper.hxx>
21 #include <tools/debug.hxx>
22 #include <com/sun/star/i18n/Collator.hpp>
24 using namespace ::com::sun::star;
26 CollatorWrapper::CollatorWrapper ( const uno::Reference< uno::XComponentContext > &rxContext )
28 mxInternationalCollator = i18n::Collator::create( rxContext );
31 CollatorWrapper::~CollatorWrapper()
35 sal_Int32
36 CollatorWrapper::compareString (const OUString& s1, const OUString& s2) const
38 try
40 if (mxInternationalCollator.is())
41 return mxInternationalCollator->compareString (s1, s2);
43 catch (const uno::RuntimeException&)
45 SAL_WARN( "unotools.i18n","CollatorWrapper: compareString failed");
48 return 0;
51 uno::Sequence< OUString >
52 CollatorWrapper::listCollatorAlgorithms (const lang::Locale& rLocale) const
54 try
56 if (mxInternationalCollator.is())
57 return mxInternationalCollator->listCollatorAlgorithms (rLocale);
59 catch (const uno::RuntimeException&)
61 SAL_WARN( "unotools.i18n","CollatorWrapper: listCollatorAlgorithms failed");
64 return uno::Sequence< OUString > ();
67 sal_Int32
68 CollatorWrapper::loadDefaultCollator (const lang::Locale& rLocale, sal_Int32 nOptions)
70 try
72 if (mxInternationalCollator.is())
73 return mxInternationalCollator->loadDefaultCollator (rLocale, nOptions);
75 catch (const uno::RuntimeException&)
77 SAL_WARN( "unotools.i18n","CollatorWrapper: loadDefaultCollator failed");
80 return 0;
83 sal_Int32
84 CollatorWrapper::loadCollatorAlgorithm (const OUString& rAlgorithm,
85 const lang::Locale& rLocale, sal_Int32 nOptions)
87 try
89 if (mxInternationalCollator.is())
90 return mxInternationalCollator->loadCollatorAlgorithm (
91 rAlgorithm, rLocale, nOptions);
93 catch (const uno::RuntimeException&)
95 SAL_WARN( "unotools.i18n","CollatorWrapper: loadCollatorAlgorithm failed");
98 return 0;
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */