xref: /aoo41x/main/sw/source/core/tox/toxhlp.cxx (revision efeef26f)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sw.hxx"
26 
27 
28 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
29 #include <comphelper/processfactory.hxx>
30 #ifndef _COM_SUN_STAR_I18N_XINDEXENTRYSUPPLIER_HPP_
31 #include <com/sun/star/i18n/XExtendedIndexEntrySupplier.hpp>
32 #endif
33 #include <tools/string.hxx>
34 #include <tools/debug.hxx>
35 #include <toxwrap.hxx>
36 
37 using namespace ::com::sun::star;
38 
39 
IndexEntrySupplierWrapper()40 IndexEntrySupplierWrapper::IndexEntrySupplierWrapper()
41 {
42     uno::Reference<
43             lang::XMultiServiceFactory > rxMSF =
44                                     ::comphelper::getProcessServiceFactory();
45 
46 	try {
47 		STAR_REFERENCE( uno::XInterface ) xI =
48 			rxMSF->createInstance( ::rtl::OUString::createFromAscii(
49                                 "com.sun.star.i18n.IndexEntrySupplier" ) );
50 		if( xI.is() )
51 		{
52 			UNO_NMSPC::Any x = xI->queryInterface( ::getCppuType(
53                     (const uno::Reference< i18n::XExtendedIndexEntrySupplier>*)0) );
54 			x >>= xIES;
55 		}
56 	}
57 	catch ( UNO_NMSPC::Exception&
58 #ifdef DBG_UTIL
59         e
60 #endif
61         )
62 	{
63 #ifdef DBG_UTIL
64 		ByteString aMsg( "IndexEntrySupplierWrapper: Exception caught\n" );
65 		aMsg += ByteString( String( e.Message ), RTL_TEXTENCODING_UTF8 );
66 		DBG_ERRORFILE( aMsg.GetBuffer() );
67 #endif
68 	}
69 }
70 
~IndexEntrySupplierWrapper()71 IndexEntrySupplierWrapper::~IndexEntrySupplierWrapper()
72 {
73 }
74 
GetIndexKey(const String & rTxt,const String & rTxtReading,const STAR_NMSPC::lang::Locale & rLocale) const75 String IndexEntrySupplierWrapper::GetIndexKey( const String& rTxt,
76                                                const String& rTxtReading,
77                                                const STAR_NMSPC::lang::Locale& rLocale ) const
78 {
79 	String sRet;
80 	try	{
81         sRet = xIES->getIndexKey( rTxt, rTxtReading, rLocale );
82 	}
83 	catch ( UNO_NMSPC::Exception&
84 #ifdef DBG_UTIL
85         e
86 #endif
87         )
88 	{
89 #ifdef DBG_UTIL
90         ByteString aMsg( "getIndexKey: Exception caught\n" );
91 		aMsg += ByteString( String( e.Message ), RTL_TEXTENCODING_UTF8 );
92 		DBG_ERRORFILE( aMsg.GetBuffer() );
93 #endif
94 	}
95 	return sRet;
96 }
97 
GetFollowingText(sal_Bool bMorePages) const98 String IndexEntrySupplierWrapper::GetFollowingText( sal_Bool bMorePages ) const
99 {
100 	String sRet;
101 	try	{
102 		sRet = xIES->getIndexFollowPageWord( bMorePages, aLcl );
103 	}
104 	catch ( UNO_NMSPC::Exception&
105 #ifdef DBG_UTIL
106         e
107 #endif
108         )
109 	{
110 #ifdef DBG_UTIL
111         ByteString aMsg( "getIndexFollowPageWord: Exception caught\n" );
112 		aMsg += ByteString( String( e.Message ), RTL_TEXTENCODING_UTF8 );
113 		DBG_ERRORFILE( aMsg.GetBuffer() );
114 #endif
115 	}
116 	return sRet;
117 }
118 
119 STAR_NMSPC::uno::Sequence< ::rtl::OUString >
GetAlgorithmList(const STAR_NMSPC::lang::Locale & rLcl) const120 IndexEntrySupplierWrapper::GetAlgorithmList( const STAR_NMSPC::lang::Locale& rLcl ) const
121 {
122     uno::Sequence< ::rtl::OUString > sRet;
123 
124 	try	{
125         sRet = xIES->getAlgorithmList( rLcl );
126 	}
127 	catch ( UNO_NMSPC::Exception&
128 #ifdef DBG_UTIL
129         e
130 #endif
131         )
132 	{
133 #ifdef DBG_UTIL
134         ByteString aMsg( "getAlgorithmList: Exception caught\n" );
135 		aMsg += ByteString( String( e.Message ), RTL_TEXTENCODING_UTF8 );
136 		DBG_ERRORFILE( aMsg.GetBuffer() );
137 #endif
138 	}
139 	return sRet;
140 }
141 
LoadAlgorithm(const STAR_NMSPC::lang::Locale & rLcl,const String & sSortAlgorithm,long nOptions) const142 sal_Bool IndexEntrySupplierWrapper::LoadAlgorithm(
143         const STAR_NMSPC::lang::Locale& rLcl,
144         const String& sSortAlgorithm, long nOptions ) const
145 {
146     sal_Bool bRet = sal_False;
147 	try	{
148         bRet = xIES->loadAlgorithm( rLcl, sSortAlgorithm, nOptions );
149 	}
150 	catch ( UNO_NMSPC::Exception&
151 #ifdef DBG_UTIL
152         e
153 #endif
154         )
155 	{
156 #ifdef DBG_UTIL
157         ByteString aMsg( "loadAlgorithm: Exception caught\n" );
158 		aMsg += ByteString( String( e.Message ), RTL_TEXTENCODING_UTF8 );
159 		DBG_ERRORFILE( aMsg.GetBuffer() );
160 #endif
161 	}
162     return bRet;
163 }
164 
CompareIndexEntry(const String & rTxt1,const String & rTxtReading1,const STAR_NMSPC::lang::Locale & rLocale1,const String & rTxt2,const String & rTxtReading2,const STAR_NMSPC::lang::Locale & rLocale2) const165 sal_Int16 IndexEntrySupplierWrapper::CompareIndexEntry(
166             const String& rTxt1, const String& rTxtReading1,
167             const STAR_NMSPC::lang::Locale& rLocale1,
168             const String& rTxt2, const String& rTxtReading2,
169             const STAR_NMSPC::lang::Locale& rLocale2 ) const
170 {
171     sal_Int16 nRet = 0;
172 	try	{
173         nRet = xIES->compareIndexEntry( rTxt1, rTxtReading1, rLocale1,
174                                         rTxt2, rTxtReading2, rLocale2 );
175 	}
176 	catch ( UNO_NMSPC::Exception&
177 #ifdef DBG_UTIL
178         e
179 #endif
180         )
181 	{
182 #ifdef DBG_UTIL
183         ByteString aMsg( "compareIndexEntry: Exception caught\n" );
184 		aMsg += ByteString( String( e.Message ), RTL_TEXTENCODING_UTF8 );
185 		DBG_ERRORFILE( aMsg.GetBuffer() );
186 #endif
187 	}
188     return nRet;
189 }
190