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 <com/sun/star/lang/XMultiServiceFactory.hpp>
21 : #include <comphelper/processfactory.hxx>
22 : #include <com/sun/star/i18n/IndexEntrySupplier.hpp>
23 : #include <toxwrap.hxx>
24 : #include <sal/log.hxx>
25 :
26 : using namespace ::com::sun::star;
27 :
28 7 : IndexEntrySupplierWrapper::IndexEntrySupplierWrapper()
29 : {
30 7 : uno::Reference< uno::XComponentContext > xContext = ::comphelper::getProcessComponentContext();
31 :
32 : try {
33 7 : xIES = i18n::IndexEntrySupplier::create(xContext);
34 : }
35 0 : catch (const uno::Exception& e)
36 : {
37 : SAL_WARN( "sw.core", "IndexEntrySupplierWrapper: Caught exception: " << e.Message );
38 7 : }
39 7 : }
40 :
41 7 : IndexEntrySupplierWrapper::~IndexEntrySupplierWrapper()
42 : {
43 7 : }
44 :
45 1 : OUString IndexEntrySupplierWrapper::GetIndexKey( const OUString& rText,
46 : const OUString& rTextReading,
47 : const ::com::sun::star::lang::Locale& rLocale ) const
48 : {
49 1 : OUString sRet;
50 : try {
51 1 : sRet = xIES->getIndexKey( rText, rTextReading, rLocale );
52 : }
53 1 : catch (const uno::Exception& e)
54 : {
55 : SAL_WARN( "sw.core", "getIndexKey: Caught exception: " << e.Message );
56 : }
57 1 : return sRet;
58 : }
59 :
60 0 : OUString IndexEntrySupplierWrapper::GetFollowingText( bool bMorePages ) const
61 : {
62 0 : OUString sRet;
63 : try {
64 0 : sRet = xIES->getIndexFollowPageWord( bMorePages, aLcl );
65 : }
66 0 : catch (const uno::Exception& e)
67 : {
68 : SAL_WARN( "sw.core", "getIndexFollowPageWord: Caught exception: " << e.Message );
69 : }
70 0 : return sRet;
71 : }
72 :
73 : ::com::sun::star::uno::Sequence< OUString >
74 5 : IndexEntrySupplierWrapper::GetAlgorithmList( const ::com::sun::star::lang::Locale& rLcl ) const
75 : {
76 5 : uno::Sequence< OUString > sRet;
77 :
78 : try {
79 5 : sRet = xIES->getAlgorithmList( rLcl );
80 : }
81 0 : catch (const uno::Exception& e)
82 : {
83 : SAL_WARN( "sw.core", "getAlgorithmList: Caught exception: " << e.Message );
84 : }
85 5 : return sRet;
86 : }
87 :
88 7 : bool IndexEntrySupplierWrapper::LoadAlgorithm(
89 : const ::com::sun::star::lang::Locale& rLcl,
90 : const OUString& sSortAlgorithm, long nOptions ) const
91 : {
92 7 : bool bRet = false;
93 : try {
94 7 : bRet = xIES->loadAlgorithm( rLcl, sSortAlgorithm, nOptions );
95 : }
96 0 : catch (const uno::Exception& e)
97 : {
98 : SAL_WARN( "sw.core", "loadAlgorithm: Caught exception: " << e.Message );
99 : }
100 7 : return bRet;
101 : }
102 :
103 0 : sal_Int16 IndexEntrySupplierWrapper::CompareIndexEntry(
104 : const OUString& rText1, const OUString& rTextReading1,
105 : const ::com::sun::star::lang::Locale& rLocale1,
106 : const OUString& rText2, const OUString& rTextReading2,
107 : const ::com::sun::star::lang::Locale& rLocale2 ) const
108 : {
109 0 : sal_Int16 nRet = 0;
110 : try {
111 0 : nRet = xIES->compareIndexEntry( rText1, rTextReading1, rLocale1,
112 0 : rText2, rTextReading2, rLocale2 );
113 : }
114 0 : catch (const uno::Exception& e)
115 : {
116 : SAL_WARN( "sw.core", "compareIndexEntry: Caught exception: " << e.Message );
117 : }
118 0 : return nRet;
119 : }
120 :
121 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|