1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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()
36 CollatorWrapper::compareString (const OUString
& s1
, const OUString
& s2
) const
40 if (mxInternationalCollator
.is())
41 return mxInternationalCollator
->compareString (s1
, s2
);
43 catch (const uno::RuntimeException
&)
45 SAL_WARN( "unotools.i18n","CollatorWrapper: compareString failed");
51 uno::Sequence
< OUString
>
52 CollatorWrapper::listCollatorAlgorithms (const lang::Locale
& rLocale
) const
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
> ();
68 CollatorWrapper::loadDefaultCollator (const lang::Locale
& rLocale
, sal_Int32 nOptions
)
72 if (mxInternationalCollator
.is())
73 return mxInternationalCollator
->loadDefaultCollator (rLocale
, nOptions
);
75 catch (const uno::RuntimeException
&)
77 SAL_WARN( "unotools.i18n","CollatorWrapper: loadDefaultCollator failed");
84 CollatorWrapper::loadCollatorAlgorithm (const OUString
& rAlgorithm
,
85 const lang::Locale
& rLocale
, sal_Int32 nOptions
)
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");
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */