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/XExtendedIndexEntrySupplier.hpp>
23 : #include <rtl/strbuf.hxx>
24 : #include <tools/string.hxx>
25 : #include <toxwrap.hxx>
26 :
27 : using namespace ::com::sun::star;
28 :
29 :
30 0 : IndexEntrySupplierWrapper::IndexEntrySupplierWrapper()
31 : {
32 : uno::Reference<
33 : lang::XMultiServiceFactory > rxMSF =
34 0 : ::comphelper::getProcessServiceFactory();
35 :
36 : try {
37 : ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface > xI =
38 0 : rxMSF->createInstance( ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM(
39 0 : "com.sun.star.i18n.IndexEntrySupplier")) );
40 0 : if( xI.is() )
41 : {
42 0 : ::com::sun::star::uno::Any x = xI->queryInterface( ::getCppuType(
43 0 : (const uno::Reference< i18n::XExtendedIndexEntrySupplier>*)0) );
44 0 : x >>= xIES;
45 0 : }
46 : }
47 0 : catch (const ::com::sun::star::uno::Exception&
48 : #if OSL_DEBUG_LEVEL > 0
49 : e
50 : #endif
51 : )
52 : {
53 : #if OSL_DEBUG_LEVEL > 0
54 : rtl::OStringBuffer aMsg(RTL_CONSTASCII_STRINGPARAM("IndexEntrySupplierWrapper: Caught exception\n"));
55 : aMsg.append(rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8));
56 : OSL_FAIL( aMsg.getStr() );
57 : #endif
58 0 : }
59 0 : }
60 :
61 0 : IndexEntrySupplierWrapper::~IndexEntrySupplierWrapper()
62 : {
63 0 : }
64 :
65 0 : String IndexEntrySupplierWrapper::GetIndexKey( const String& rTxt,
66 : const String& rTxtReading,
67 : const ::com::sun::star::lang::Locale& rLocale ) const
68 : {
69 0 : String sRet;
70 : try {
71 0 : sRet = xIES->getIndexKey( rTxt, rTxtReading, rLocale );
72 : }
73 0 : catch (const ::com::sun::star::uno::Exception&
74 : #if OSL_DEBUG_LEVEL > 0
75 : e
76 : #endif
77 : )
78 : {
79 : #if OSL_DEBUG_LEVEL > 0
80 : rtl::OStringBuffer aMsg(RTL_CONSTASCII_STRINGPARAM("getIndexKey: Caught exception\n"));
81 : aMsg.append(rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8));
82 : OSL_FAIL( aMsg.getStr() );
83 : #endif
84 : }
85 0 : return sRet;
86 : }
87 :
88 0 : String IndexEntrySupplierWrapper::GetFollowingText( sal_Bool bMorePages ) const
89 : {
90 0 : String sRet;
91 : try {
92 0 : sRet = xIES->getIndexFollowPageWord( bMorePages, aLcl );
93 : }
94 0 : catch (const ::com::sun::star::uno::Exception&
95 : #if OSL_DEBUG_LEVEL > 0
96 : e
97 : #endif
98 : )
99 : {
100 : #if OSL_DEBUG_LEVEL > 0
101 : rtl::OStringBuffer aMsg(RTL_CONSTASCII_STRINGPARAM("getIndexFollowPageWord: Caught exception\n"));
102 : aMsg.append(rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8));
103 : OSL_FAIL( aMsg.getStr() );
104 : #endif
105 : }
106 0 : return sRet;
107 : }
108 :
109 : ::com::sun::star::uno::Sequence< ::rtl::OUString >
110 0 : IndexEntrySupplierWrapper::GetAlgorithmList( const ::com::sun::star::lang::Locale& rLcl ) const
111 : {
112 0 : uno::Sequence< ::rtl::OUString > sRet;
113 :
114 : try {
115 0 : sRet = xIES->getAlgorithmList( rLcl );
116 : }
117 0 : catch (const ::com::sun::star::uno::Exception&
118 : #if OSL_DEBUG_LEVEL > 0
119 : e
120 : #endif
121 : )
122 : {
123 : #if OSL_DEBUG_LEVEL > 0
124 : rtl::OStringBuffer aMsg(RTL_CONSTASCII_STRINGPARAM("getAlgorithmList: Caught exception\n"));
125 : aMsg.append(rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8));
126 : OSL_FAIL( aMsg.getStr() );
127 : #endif
128 : }
129 0 : return sRet;
130 : }
131 :
132 0 : sal_Bool IndexEntrySupplierWrapper::LoadAlgorithm(
133 : const ::com::sun::star::lang::Locale& rLcl,
134 : const String& sSortAlgorithm, long nOptions ) const
135 : {
136 0 : sal_Bool bRet = sal_False;
137 : try {
138 0 : bRet = xIES->loadAlgorithm( rLcl, sSortAlgorithm, nOptions );
139 : }
140 0 : catch (const ::com::sun::star::uno::Exception&
141 : #if OSL_DEBUG_LEVEL > 0
142 : e
143 : #endif
144 : )
145 : {
146 : #if OSL_DEBUG_LEVEL > 0
147 : rtl::OStringBuffer aMsg(RTL_CONSTASCII_STRINGPARAM("loadAlgorithm: Caught exception\n"));
148 : aMsg.append(rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8));
149 : OSL_FAIL( aMsg.getStr() );
150 : #endif
151 : }
152 0 : return bRet;
153 : }
154 :
155 0 : sal_Int16 IndexEntrySupplierWrapper::CompareIndexEntry(
156 : const String& rTxt1, const String& rTxtReading1,
157 : const ::com::sun::star::lang::Locale& rLocale1,
158 : const String& rTxt2, const String& rTxtReading2,
159 : const ::com::sun::star::lang::Locale& rLocale2 ) const
160 : {
161 0 : sal_Int16 nRet = 0;
162 : try {
163 0 : nRet = xIES->compareIndexEntry( rTxt1, rTxtReading1, rLocale1,
164 0 : rTxt2, rTxtReading2, rLocale2 );
165 : }
166 0 : catch (const ::com::sun::star::uno::Exception&
167 : #if OSL_DEBUG_LEVEL > 0
168 : e
169 : #endif
170 : )
171 : {
172 : #if OSL_DEBUG_LEVEL > 0
173 : rtl::OStringBuffer aMsg(RTL_CONSTASCII_STRINGPARAM("compareIndexEntry: Caught exception\n"));
174 : aMsg.append(rtl::OUStringToOString(e.Message, RTL_TEXTENCODING_UTF8));
175 : OSL_FAIL( aMsg.getStr() );
176 : #endif
177 : }
178 0 : return nRet;
179 : }
180 :
181 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|