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: textsearch.hxx,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 #ifndef INCLUDED_I18NPOOL_TEXTSEARCH_HXX
32 #define INCLUDED_I18NPOOL_TEXTSEARCH_HXX
35 #include <com/sun/star/util/XTextSearch.hpp>
36 #include <com/sun/star/i18n/XBreakIterator.hpp>
37 #include <cppuhelper/implbase2.hxx> // helper for implementations
38 #include <com/sun/star/i18n/XExtendedTransliteration.hpp>
39 #include <com/sun/star/i18n/XCharacterClassification.hpp>
40 #include <com/sun/star/lang/XServiceInfo.hpp>
46 typedef ::std::map
< sal_Unicode
, sal_Int32
> TextSearchJumpTable
;
48 // ----------------------------------------------------
50 // ----------------------------------------------------
51 class TextSearch
: public cppu::WeakImplHelper2
53 ::com::sun::star::util::XTextSearch
,
54 ::com::sun::star::lang::XServiceInfo
57 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> xMSF
;
59 ::com::sun::star::util::SearchOptions aSrchPara
;
60 ::rtl::OUString sSrchStr
;
61 ::rtl::OUString sSrchStr2
;
63 mutable com::sun::star::uno::Reference
<
64 com::sun::star::i18n::XCharacterClassification
> xCharClass
;
66 com::sun::star::uno::Reference
<
67 com::sun::star::i18n::XExtendedTransliteration
> xTranslit
;
68 com::sun::star::uno::Reference
<
69 com::sun::star::i18n::XExtendedTransliteration
> xTranslit2
;
71 // define a function pointer for the different search nethods
72 typedef ::com::sun::star::util::SearchResult
73 (SAL_CALL
TextSearch:: *FnSrch
)( const ::rtl::OUString
& searchStr
,
74 sal_Int32 startPos
, sal_Int32 endPos
);
79 // Members and methods for the normal (Boyer-Moore) search
80 TextSearchJumpTable
* pJumpTable
;
81 TextSearchJumpTable
* pJumpTable2
;
83 bool bUsePrimarySrchStr
;
84 void MakeForwardTab();
85 void MakeForwardTab2();
86 void MakeBackwardTab();
87 void MakeBackwardTab2();
88 sal_Int32
GetDiff( const sal_Unicode
) const;
89 ::com::sun::star::util::SearchResult SAL_CALL
90 NSrchFrwrd( const ::rtl::OUString
& searchStr
,
91 sal_Int32 startPos
, sal_Int32 endPos
)
92 throw(::com::sun::star::uno::RuntimeException
);
93 ::com::sun::star::util::SearchResult SAL_CALL
94 NSrchBkwrd( const ::rtl::OUString
& searchStr
,
95 sal_Int32 startPos
, sal_Int32 endPos
)
96 throw(::com::sun::star::uno::RuntimeException
);
98 // Members and methods for the regular expression search
100 ::com::sun::star::util::SearchResult SAL_CALL
101 RESrchFrwrd( const ::rtl::OUString
& searchStr
,
102 sal_Int32 startPos
, sal_Int32 endPos
)
103 throw(::com::sun::star::uno::RuntimeException
);
104 ::com::sun::star::util::SearchResult SAL_CALL
105 RESrchBkwrd( const ::rtl::OUString
& searchStr
,
106 sal_Int32 startPos
, sal_Int32 endPos
)
107 throw(::com::sun::star::uno::RuntimeException
);
109 // Members and methods for the "Weight Levenshtein-Distance" search
112 com::sun::star::uno::Reference
< com::sun::star::i18n::XBreakIterator
> xBreak
;
113 ::com::sun::star::util::SearchResult SAL_CALL
114 ApproxSrchFrwrd( const ::rtl::OUString
& searchStr
,
115 sal_Int32 startPos
, sal_Int32 endPos
)
116 throw(::com::sun::star::uno::RuntimeException
);
117 ::com::sun::star::util::SearchResult SAL_CALL
118 ApproxSrchBkwrd( const ::rtl::OUString
& searchStr
,
119 sal_Int32 startPos
, sal_Int32 endPos
)
120 throw(::com::sun::star::uno::RuntimeException
);
122 bool IsDelimiter( const ::rtl::OUString
& rStr
, sal_Int32 nPos
) const;
124 sal_Bool checkCTLStart
, checkCTLEnd
;
125 sal_Bool SAL_CALL
isCellStart(const ::rtl::OUString
& searchStr
, sal_Int32 nPos
)
126 throw(::com::sun::star::uno::RuntimeException
);
130 const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
>& rxMSF
);
132 virtual ~TextSearch();
135 virtual void SAL_CALL
136 setOptions( const ::com::sun::star::util::SearchOptions
& options
)
137 throw(::com::sun::star::uno::RuntimeException
);
138 virtual ::com::sun::star::util::SearchResult SAL_CALL
139 searchForward( const ::rtl::OUString
& searchStr
,
140 sal_Int32 startPos
, sal_Int32 endPos
)
141 throw(::com::sun::star::uno::RuntimeException
);
142 virtual ::com::sun::star::util::SearchResult SAL_CALL
143 searchBackward( const ::rtl::OUString
& searchStr
,
144 sal_Int32 startPos
, sal_Int32 endPos
)
145 throw(::com::sun::star::uno::RuntimeException
);
148 virtual rtl::OUString SAL_CALL
getImplementationName(void)
149 throw( ::com::sun::star::uno::RuntimeException
);
150 virtual sal_Bool SAL_CALL
supportsService(const rtl::OUString
& ServiceName
)
151 throw( ::com::sun::star::uno::RuntimeException
);
152 virtual ::com::sun::star::uno::Sequence
< rtl::OUString
> SAL_CALL
getSupportedServiceNames(void)
153 throw( ::com::sun::star::uno::RuntimeException
);