Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*************************************************************************
3 : : *
4 : : * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 : : *
6 : : * Copyright 2000, 2010 Oracle and/or its affiliates.
7 : : *
8 : : * OpenOffice.org - a multi-platform office productivity suite
9 : : *
10 : : * This file is part of OpenOffice.org.
11 : : *
12 : : * OpenOffice.org is free software: you can redistribute it and/or modify
13 : : * it under the terms of the GNU Lesser General Public License version 3
14 : : * only, as published by the Free Software Foundation.
15 : : *
16 : : * OpenOffice.org is distributed in the hope that it will be useful,
17 : : * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 : : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 : : * GNU Lesser General Public License version 3 for more details
20 : : * (a copy is included in the LICENSE file that accompanied this code).
21 : : *
22 : : * You should have received a copy of the GNU Lesser General Public License
23 : : * version 3 along with OpenOffice.org. If not, see
24 : : * <http://www.openoffice.org/license.html>
25 : : * for a copy of the LGPLv3 License.
26 : : *
27 : : ************************************************************************/
28 : :
29 : : #ifndef _CUI_FMSEARCH_HXX
30 : : #define _CUI_FMSEARCH_HXX
31 : :
32 : : #include <com/sun/star/sdbc/XResultSet.hpp>
33 : :
34 : : #include <svx/fmsearch.hxx>
35 : : #include <vcl/dialog.hxx>
36 : : #include <vcl/button.hxx>
37 : : #include <vcl/fixed.hxx>
38 : : #include <vcl/edit.hxx>
39 : : #include <vcl/combobox.hxx>
40 : : #include <vcl/lstbox.hxx>
41 : : #include <tools/link.hxx>
42 : : #include <comphelper/uno3.hxx>
43 : : #include <comphelper/stl_types.hxx>
44 : : #include <tools/string.hxx>
45 : :
46 : : namespace svxform {
47 : : class FmSearchConfigItem;
48 : : }
49 : :
50 : : struct FmSearchProgress;
51 : :
52 : : class FmSearchEngine;
53 : :
54 : : /// Dialog for searching in Forms/Tables
55 : : class FmSearchDialog : public ModalDialog
56 : : {
57 : : friend class FmSearchEngine;
58 : :
59 : : // my all Controls
60 : : FixedLine m_flSearchFor;
61 : : RadioButton m_rbSearchForText;
62 : : RadioButton m_rbSearchForNull;
63 : : RadioButton m_rbSearchForNotNull;
64 : : ComboBox m_cmbSearchText;
65 : : FixedLine m_flWhere;
66 : : FixedText m_ftForm;
67 : : ListBox m_lbForm;
68 : : RadioButton m_rbAllFields;
69 : : RadioButton m_rbSingleField;
70 : : ListBox m_lbField;
71 : : FixedLine m_flOptions;
72 : : FixedText m_ftPosition;
73 : : ListBox m_lbPosition;
74 : : CheckBox m_cbUseFormat;
75 : : CheckBox m_cbCase;
76 : : CheckBox m_cbBackwards;
77 : : CheckBox m_cbStartOver;
78 : : CheckBox m_cbWildCard;
79 : : CheckBox m_cbRegular;
80 : : CheckBox m_cbApprox;
81 : : PushButton m_pbApproxSettings;
82 : : CheckBox m_aHalfFullFormsCJK;
83 : : CheckBox m_aSoundsLikeCJK;
84 : : PushButton m_aSoundsLikeCJKSettings;
85 : : FixedLine m_flState;
86 : : FixedText m_ftRecordLabel;
87 : : FixedText m_ftRecord;
88 : : FixedText m_ftHint;
89 : : PushButton m_pbSearchAgain;
90 : : CancelButton m_pbClose;
91 : : HelpButton m_pbHelp;
92 : : String m_sSearch;
93 : : String m_sCancel;
94 : :
95 : : Window* m_pPreSearchFocus;
96 : :
97 : : Link m_lnkFoundHandler; ///< Handler for "found"
98 : : Link m_lnkCanceledNotFoundHdl; ///< Handler for Positioning the Cursors
99 : :
100 : : Link m_lnkContextSupplier; ///< for search in contexts
101 : :
102 : : /// memorize the currently selected field for every context
103 : : ::std::vector<String> m_arrContextFields;
104 : :
105 : : FmSearchEngine* m_pSearchEngine;
106 : :
107 : : Timer m_aDelayedPaint;
108 : : // see EnableSearchUI
109 : :
110 : : ::svxform::FmSearchConfigItem* m_pConfig;
111 : : public:
112 : : /** This can search in different sets of fields. There is a number of contexts; their names are in strContexts (seperated
113 : : by ';'), the user can choose one of them.
114 : : When the user chooses a context, lnkContextSupplier is called, it gets a pointer on an FmSearchContext-structure,
115 : : that has to be filled.
116 : : The following counts for the search :
117 : : a) in case of formatted search the iterator itself is used (like in the first constructor)
118 : : b) in case of formatted search NOT the FormatKey at the fields of the iterator is used, but the respective TextComponent
119 : : is asked (that's why the original iterator is used; by its move the controls behind the TextComponent-interface are
120 : : updated hopefully)
121 : : c) in case of not-formatted search a clone of the iterator is used (because the TextComponent-interfaces don't need to
122 : : be asked)
123 : : (of course needed : the string number i in strUsedFields of a context must correspond with the interface number i in the
124 : : arrFields of the context)
125 : : */
126 : : FmSearchDialog(Window* pParent, const String& strInitialText, const ::std::vector< String >& _rContexts, sal_Int16 nInitialContext,
127 : : const Link& lnkContextSupplier);
128 : :
129 : : virtual ~FmSearchDialog();
130 : :
131 : : /** The found-handler gets in the 'found'-case a pointer on a FmFoundRecordInformation-structure
132 : : (which is only valid in the handler; so if one needs to memorize the data, don't copy the pointer but
133 : : the structure).
134 : : This handler MUST be set.
135 : : Furthermore, it should be considered, that during the handler the search-dialog is still modal.
136 : : */
137 : 0 : void SetFoundHandler(const Link& lnk) { m_lnkFoundHandler = lnk; }
138 : : /**
139 : : If the search has been cancelled or has been finished without success, the current data set is always displayed in the
140 : : search dialog. This handler exists to make this synchronous with the possible display of the caller (it does not
141 : : necessarily need to be set).
142 : : The pointer that is passed to the handler points to a FmFoundRecordInformation-structure, for which aPosition and
143 : : possibly (in a search with contexts) nContext are valid.
144 : : */
145 : 0 : void SetCanceledNotFoundHdl(const Link& lnk) { m_lnkCanceledNotFoundHdl = lnk; }
146 : :
147 : : inline void SetActiveField(const String& strField);
148 : :
149 : : protected:
150 : : virtual sal_Bool Close();
151 : :
152 : : void Init(const String& strVisibleFields, const String& strInitialText);
153 : : // only to be used out of the constructors
154 : :
155 : : void OnFound(const ::com::sun::star::uno::Any& aCursorPos, sal_Int16 nFieldPos);
156 : : /** When searching in an own thread I naturally want to disable the UI for starting the search and for setting search
157 : : parameters. If bEnable == sal_False, for all affected controls painting is turned off and shortly after turned on
158 : : again using m_aDelayedPaint. If there is a demand with bEnable == sal_True inbetween, the timer is stopped and
159 : : painting is turned on immediately. As a consequence for this intricateness there is no flickering when turning
160 : : off and on quickly.
161 : : */
162 : : void EnableSearchUI(sal_Bool bEnable);
163 : :
164 : : void EnableSearchForDependees(sal_Bool bEnable);
165 : :
166 : : void EnableControlPaint(sal_Bool bEnable);
167 : :
168 : : void InitContext(sal_Int16 nContext);
169 : :
170 : : void LoadParams();
171 : : void SaveParams() const;
172 : :
173 : : private:
174 : : // Handler for the Controls
175 : : DECL_LINK( OnClickedFieldRadios, Button* );
176 : : DECL_LINK(OnClickedSearchAgain, void *);
177 : : DECL_LINK( OnClickedSpecialSettings, Button* );
178 : :
179 : : DECL_LINK(OnSearchTextModified, void *);
180 : :
181 : : DECL_LINK( OnPositionSelected, ListBox* );
182 : : DECL_LINK( OnFieldSelected, ListBox* );
183 : :
184 : : DECL_LINK( OnCheckBoxToggled, CheckBox* );
185 : :
186 : : DECL_LINK( OnContextSelection, ListBox* );
187 : :
188 : : DECL_LINK( OnSearchProgress, FmSearchProgress* );
189 : :
190 : : DECL_LINK( OnDelayedPaint, void* ); ///< see EnableSearchUI
191 : :
192 : : void implMoveControls(Control** _ppControls, sal_Int32 _nControls, sal_Int32 _nUp, Control* _pToResize);
193 : :
194 : : void initCommon( const ::com::sun::star::uno::Reference< ::com::sun::star::sdbc::XResultSet >& _rxCursor );
195 : : };
196 : :
197 : 0 : inline void FmSearchDialog::SetActiveField(const String& strField)
198 : : {
199 : 0 : sal_uInt16 nInitialField = m_lbField.GetEntryPos(strField);
200 [ # # ]: 0 : if (nInitialField == COMBOBOX_ENTRY_NOTFOUND)
201 : 0 : nInitialField = 0;
202 : 0 : m_lbField.SelectEntryPos(nInitialField);
203 [ # # ]: 0 : LINK(this, FmSearchDialog, OnFieldSelected).Call(&m_lbField);
204 : 0 : }
205 : :
206 : : #endif // _CUI_FMSEARCH_HXX
207 : :
208 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|