1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: toxhlp.cxx,v $
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>
40 #include <tools/string.hxx>
41 #include <tools/debug.hxx>
42 #include <toxwrap.hxx>
44 using namespace ::com::sun::star
;
47 IndexEntrySupplierWrapper::IndexEntrySupplierWrapper()
50 lang::XMultiServiceFactory
> rxMSF
=
51 ::comphelper::getProcessServiceFactory();
54 STAR_REFERENCE( uno::XInterface
) xI
=
55 rxMSF
->createInstance( ::rtl::OUString::createFromAscii(
56 "com.sun.star.i18n.IndexEntrySupplier" ) );
59 UNO_NMSPC::Any x
= xI
->queryInterface( ::getCppuType(
60 (const uno::Reference
< i18n::XExtendedIndexEntrySupplier
>*)0) );
64 catch ( UNO_NMSPC::Exception
&
71 ByteString
aMsg( "IndexEntrySupplierWrapper: Exception caught\n" );
72 aMsg
+= ByteString( String( e
.Message
), RTL_TEXTENCODING_UTF8
);
73 DBG_ERRORFILE( aMsg
.GetBuffer() );
78 IndexEntrySupplierWrapper::~IndexEntrySupplierWrapper()
82 String
IndexEntrySupplierWrapper::GetIndexKey( const String
& rTxt
,
83 const String
& rTxtReading
,
84 const STAR_NMSPC::lang::Locale
& rLocale
) const
88 sRet
= xIES
->getIndexKey( rTxt
, rTxtReading
, rLocale
);
90 catch ( UNO_NMSPC::Exception
&
97 ByteString
aMsg( "getIndexKey: Exception caught\n" );
98 aMsg
+= ByteString( String( e
.Message
), RTL_TEXTENCODING_UTF8
);
99 DBG_ERRORFILE( aMsg
.GetBuffer() );
105 String
IndexEntrySupplierWrapper::GetFollowingText( BOOL bMorePages
) const
109 sRet
= xIES
->getIndexFollowPageWord( bMorePages
, aLcl
);
111 catch ( UNO_NMSPC::Exception
&
118 ByteString
aMsg( "getIndexFollowPageWord: Exception caught\n" );
119 aMsg
+= ByteString( String( e
.Message
), RTL_TEXTENCODING_UTF8
);
120 DBG_ERRORFILE( aMsg
.GetBuffer() );
126 STAR_NMSPC::uno::Sequence
< ::rtl::OUString
>
127 IndexEntrySupplierWrapper::GetAlgorithmList( const STAR_NMSPC::lang::Locale
& rLcl
) const
129 uno::Sequence
< ::rtl::OUString
> sRet
;
132 sRet
= xIES
->getAlgorithmList( rLcl
);
134 catch ( UNO_NMSPC::Exception
&
141 ByteString
aMsg( "getAlgorithmList: Exception caught\n" );
142 aMsg
+= ByteString( String( e
.Message
), RTL_TEXTENCODING_UTF8
);
143 DBG_ERRORFILE( aMsg
.GetBuffer() );
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
;
155 bRet
= xIES
->loadAlgorithm( rLcl
, sSortAlgorithm
, nOptions
);
157 catch ( UNO_NMSPC::Exception
&
164 ByteString
aMsg( "loadAlgorithm: Exception caught\n" );
165 aMsg
+= ByteString( String( e
.Message
), RTL_TEXTENCODING_UTF8
);
166 DBG_ERRORFILE( aMsg
.GetBuffer() );
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
180 nRet
= xIES
->compareIndexEntry( rTxt1
, rTxtReading1
, rLocale1
,
181 rTxt2
, rTxtReading2
, rLocale2
);
183 catch ( UNO_NMSPC::Exception
&
190 ByteString
aMsg( "compareIndexEntry: Exception caught\n" );
191 aMsg
+= ByteString( String( e
.Message
), RTL_TEXTENCODING_UTF8
);
192 DBG_ERRORFILE( aMsg
.GetBuffer() );