merged tag ooo/OOO330_m14
[LibreOffice.git] / i18npool / source / search / textsearch.hxx
blob383b78e769b0b6903080dbc9a8294103c876fe2b
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2000, 2010 Oracle and/or its affiliates.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * This file is part of OpenOffice.org.
11 * OpenOffice.org is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License version 3
13 * only, as published by the Free Software Foundation.
15 * OpenOffice.org is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU Lesser General Public License version 3 for more details
19 * (a copy is included in the LICENSE file that accompanied this code).
21 * You should have received a copy of the GNU Lesser General Public License
22 * version 3 along with OpenOffice.org. If not, see
23 * <http://www.openoffice.org/license.html>
24 * for a copy of the LGPLv3 License.
26 ************************************************************************/
28 #ifndef INCLUDED_I18NPOOL_TEXTSEARCH_HXX
29 #define INCLUDED_I18NPOOL_TEXTSEARCH_HXX
32 #include <com/sun/star/util/XTextSearch.hpp>
33 #include <com/sun/star/i18n/XBreakIterator.hpp>
34 #include <cppuhelper/implbase2.hxx> // helper for implementations
35 #include <com/sun/star/i18n/XExtendedTransliteration.hpp>
36 #include <com/sun/star/i18n/XCharacterClassification.hpp>
37 #include <com/sun/star/lang/XServiceInfo.hpp>
39 #include <map>
41 class Regexpr;
42 class WLevDistance;
43 typedef ::std::map< sal_Unicode, sal_Int32 > TextSearchJumpTable;
45 // ----------------------------------------------------
46 // class SearchClass
47 // ----------------------------------------------------
48 class TextSearch: public cppu::WeakImplHelper2
50 ::com::sun::star::util::XTextSearch,
51 ::com::sun::star::lang::XServiceInfo
54 ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory > xMSF;
56 ::com::sun::star::util::SearchOptions aSrchPara;
57 ::rtl::OUString sSrchStr;
58 ::rtl::OUString sSrchStr2;
60 mutable com::sun::star::uno::Reference<
61 com::sun::star::i18n::XCharacterClassification > xCharClass;
63 com::sun::star::uno::Reference<
64 com::sun::star::i18n::XExtendedTransliteration > xTranslit;
65 com::sun::star::uno::Reference<
66 com::sun::star::i18n::XExtendedTransliteration > xTranslit2;
68 // define a function pointer for the different search nethods
69 typedef ::com::sun::star::util::SearchResult
70 (SAL_CALL TextSearch:: *FnSrch)( const ::rtl::OUString& searchStr,
71 sal_Int32 startPos, sal_Int32 endPos );
73 FnSrch fnForward;
74 FnSrch fnBackward;
76 // Members and methods for the normal (Boyer-Moore) search
77 TextSearchJumpTable* pJumpTable;
78 TextSearchJumpTable* pJumpTable2;
79 bool bIsForwardTab;
80 bool bUsePrimarySrchStr;
81 void MakeForwardTab();
82 void MakeForwardTab2();
83 void MakeBackwardTab();
84 void MakeBackwardTab2();
85 sal_Int32 GetDiff( const sal_Unicode ) const;
86 ::com::sun::star::util::SearchResult SAL_CALL
87 NSrchFrwrd( const ::rtl::OUString& searchStr,
88 sal_Int32 startPos, sal_Int32 endPos )
89 throw(::com::sun::star::uno::RuntimeException);
90 ::com::sun::star::util::SearchResult SAL_CALL
91 NSrchBkwrd( const ::rtl::OUString& searchStr,
92 sal_Int32 startPos, sal_Int32 endPos )
93 throw(::com::sun::star::uno::RuntimeException);
95 // Members and methods for the regular expression search
96 Regexpr* pRegExp;
97 ::com::sun::star::util::SearchResult SAL_CALL
98 RESrchFrwrd( const ::rtl::OUString& searchStr,
99 sal_Int32 startPos, sal_Int32 endPos )
100 throw(::com::sun::star::uno::RuntimeException);
101 ::com::sun::star::util::SearchResult SAL_CALL
102 RESrchBkwrd( const ::rtl::OUString& searchStr,
103 sal_Int32 startPos, sal_Int32 endPos )
104 throw(::com::sun::star::uno::RuntimeException);
106 // Members and methods for the "Weight Levenshtein-Distance" search
107 int nLimit;
108 WLevDistance* pWLD;
109 com::sun::star::uno::Reference < com::sun::star::i18n::XBreakIterator > xBreak;
110 ::com::sun::star::util::SearchResult SAL_CALL
111 ApproxSrchFrwrd( const ::rtl::OUString& searchStr,
112 sal_Int32 startPos, sal_Int32 endPos )
113 throw(::com::sun::star::uno::RuntimeException);
114 ::com::sun::star::util::SearchResult SAL_CALL
115 ApproxSrchBkwrd( const ::rtl::OUString& searchStr,
116 sal_Int32 startPos, sal_Int32 endPos )
117 throw(::com::sun::star::uno::RuntimeException);
119 bool IsDelimiter( const ::rtl::OUString& rStr, sal_Int32 nPos ) const;
121 sal_Bool checkCTLStart, checkCTLEnd;
122 sal_Bool SAL_CALL isCellStart(const ::rtl::OUString& searchStr, sal_Int32 nPos)
123 throw(::com::sun::star::uno::RuntimeException);
125 public:
126 TextSearch(
127 const ::com::sun::star::uno::Reference < ::com::sun::star::lang::XMultiServiceFactory >& rxMSF );
129 virtual ~TextSearch();
131 // Methods
132 virtual void SAL_CALL
133 setOptions( const ::com::sun::star::util::SearchOptions& options )
134 throw(::com::sun::star::uno::RuntimeException);
135 virtual ::com::sun::star::util::SearchResult SAL_CALL
136 searchForward( const ::rtl::OUString& searchStr,
137 sal_Int32 startPos, sal_Int32 endPos )
138 throw(::com::sun::star::uno::RuntimeException);
139 virtual ::com::sun::star::util::SearchResult SAL_CALL
140 searchBackward( const ::rtl::OUString& searchStr,
141 sal_Int32 startPos, sal_Int32 endPos )
142 throw(::com::sun::star::uno::RuntimeException);
144 //XServiceInfo
145 virtual rtl::OUString SAL_CALL getImplementationName(void)
146 throw( ::com::sun::star::uno::RuntimeException );
147 virtual sal_Bool SAL_CALL supportsService(const rtl::OUString& ServiceName)
148 throw( ::com::sun::star::uno::RuntimeException );
149 virtual ::com::sun::star::uno::Sequence< rtl::OUString > SAL_CALL getSupportedServiceNames(void)
150 throw( ::com::sun::star::uno::RuntimeException );
154 #endif