merge the formfield patch from ooo-build
[ooovba.git] / sw / source / core / tox / toxhlp.cxx
blobeab3d53c7bef4259137731a653ff562c3dc33140
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: toxhlp.cxx,v $
10 * $Revision: 1.11 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sw.hxx"
35 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
36 #include <comphelper/processfactory.hxx>
37 #ifndef _COM_SUN_STAR_I18N_XINDEXENTRYSUPPLIER_HPP_
38 #include <com/sun/star/i18n/XExtendedIndexEntrySupplier.hpp>
39 #endif
40 #include <tools/string.hxx>
41 #include <tools/debug.hxx>
42 #include <toxwrap.hxx>
44 using namespace ::com::sun::star;
47 IndexEntrySupplierWrapper::IndexEntrySupplierWrapper()
49 uno::Reference<
50 lang::XMultiServiceFactory > rxMSF =
51 ::comphelper::getProcessServiceFactory();
53 try {
54 STAR_REFERENCE( uno::XInterface ) xI =
55 rxMSF->createInstance( ::rtl::OUString::createFromAscii(
56 "com.sun.star.i18n.IndexEntrySupplier" ) );
57 if( xI.is() )
59 UNO_NMSPC::Any x = xI->queryInterface( ::getCppuType(
60 (const uno::Reference< i18n::XExtendedIndexEntrySupplier>*)0) );
61 x >>= xIES;
64 catch ( UNO_NMSPC::Exception&
65 #ifndef PRODUCT
67 #endif
70 #ifndef PRODUCT
71 ByteString aMsg( "IndexEntrySupplierWrapper: Exception caught\n" );
72 aMsg += ByteString( String( e.Message ), RTL_TEXTENCODING_UTF8 );
73 DBG_ERRORFILE( aMsg.GetBuffer() );
74 #endif
78 IndexEntrySupplierWrapper::~IndexEntrySupplierWrapper()
82 String IndexEntrySupplierWrapper::GetIndexKey( const String& rTxt,
83 const String& rTxtReading,
84 const STAR_NMSPC::lang::Locale& rLocale ) const
86 String sRet;
87 try {
88 sRet = xIES->getIndexKey( rTxt, rTxtReading, rLocale );
90 catch ( UNO_NMSPC::Exception&
91 #ifndef PRODUCT
93 #endif
96 #ifndef PRODUCT
97 ByteString aMsg( "getIndexKey: Exception caught\n" );
98 aMsg += ByteString( String( e.Message ), RTL_TEXTENCODING_UTF8 );
99 DBG_ERRORFILE( aMsg.GetBuffer() );
100 #endif
102 return sRet;
105 String IndexEntrySupplierWrapper::GetFollowingText( BOOL bMorePages ) const
107 String sRet;
108 try {
109 sRet = xIES->getIndexFollowPageWord( bMorePages, aLcl );
111 catch ( UNO_NMSPC::Exception&
112 #ifndef PRODUCT
114 #endif
117 #ifndef PRODUCT
118 ByteString aMsg( "getIndexFollowPageWord: Exception caught\n" );
119 aMsg += ByteString( String( e.Message ), RTL_TEXTENCODING_UTF8 );
120 DBG_ERRORFILE( aMsg.GetBuffer() );
121 #endif
123 return sRet;
126 STAR_NMSPC::uno::Sequence< ::rtl::OUString >
127 IndexEntrySupplierWrapper::GetAlgorithmList( const STAR_NMSPC::lang::Locale& rLcl ) const
129 uno::Sequence< ::rtl::OUString > sRet;
131 try {
132 sRet = xIES->getAlgorithmList( rLcl );
134 catch ( UNO_NMSPC::Exception&
135 #ifndef PRODUCT
137 #endif
140 #ifndef PRODUCT
141 ByteString aMsg( "getAlgorithmList: Exception caught\n" );
142 aMsg += ByteString( String( e.Message ), RTL_TEXTENCODING_UTF8 );
143 DBG_ERRORFILE( aMsg.GetBuffer() );
144 #endif
146 return sRet;
149 sal_Bool IndexEntrySupplierWrapper::LoadAlgorithm(
150 const STAR_NMSPC::lang::Locale& rLcl,
151 const String& sSortAlgorithm, long nOptions ) const
153 sal_Bool bRet = sal_False;
154 try {
155 bRet = xIES->loadAlgorithm( rLcl, sSortAlgorithm, nOptions );
157 catch ( UNO_NMSPC::Exception&
158 #ifndef PRODUCT
160 #endif
163 #ifndef PRODUCT
164 ByteString aMsg( "loadAlgorithm: Exception caught\n" );
165 aMsg += ByteString( String( e.Message ), RTL_TEXTENCODING_UTF8 );
166 DBG_ERRORFILE( aMsg.GetBuffer() );
167 #endif
169 return bRet;
172 sal_Int16 IndexEntrySupplierWrapper::CompareIndexEntry(
173 const String& rTxt1, const String& rTxtReading1,
174 const STAR_NMSPC::lang::Locale& rLocale1,
175 const String& rTxt2, const String& rTxtReading2,
176 const STAR_NMSPC::lang::Locale& rLocale2 ) const
178 sal_Int16 nRet = 0;
179 try {
180 nRet = xIES->compareIndexEntry( rTxt1, rTxtReading1, rLocale1,
181 rTxt2, rTxtReading2, rLocale2 );
183 catch ( UNO_NMSPC::Exception&
184 #ifndef PRODUCT
186 #endif
189 #ifndef PRODUCT
190 ByteString aMsg( "compareIndexEntry: Exception caught\n" );
191 aMsg += ByteString( String( e.Message ), RTL_TEXTENCODING_UTF8 );
192 DBG_ERRORFILE( aMsg.GetBuffer() );
193 #endif
195 return nRet;