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