1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef _CUI_FMSEARCH_HXX
21 #define _CUI_FMSEARCH_HXX
23 #include <com/sun/star/sdbc/XResultSet.hpp>
25 #include <svx/fmsearch.hxx>
26 #include <vcl/dialog.hxx>
27 #include <vcl/button.hxx>
28 #include <vcl/fixed.hxx>
29 #include <vcl/edit.hxx>
30 #include <vcl/combobox.hxx>
31 #include <vcl/lstbox.hxx>
32 #include <tools/link.hxx>
33 #include <comphelper/uno3.hxx>
34 #include <comphelper/stl_types.hxx>
35 #include <tools/string.hxx>
38 class FmSearchConfigItem
;
41 struct FmSearchProgress
;
45 /// Dialog for searching in Forms/Tables
46 class FmSearchDialog
: public ModalDialog
48 friend class FmSearchEngine
;
51 FixedLine m_flSearchFor
;
52 RadioButton m_rbSearchForText
;
53 RadioButton m_rbSearchForNull
;
54 RadioButton m_rbSearchForNotNull
;
55 ComboBox m_cmbSearchText
;
59 RadioButton m_rbAllFields
;
60 RadioButton m_rbSingleField
;
62 FixedLine m_flOptions
;
63 FixedText m_ftPosition
;
65 CheckBox m_cbUseFormat
;
67 CheckBox m_cbBackwards
;
68 CheckBox m_cbStartOver
;
69 CheckBox m_cbWildCard
;
72 PushButton m_pbApproxSettings
;
73 CheckBox m_aHalfFullFormsCJK
;
74 CheckBox m_aSoundsLikeCJK
;
75 PushButton m_aSoundsLikeCJKSettings
;
77 FixedText m_ftRecordLabel
;
80 PushButton m_pbSearchAgain
;
81 CancelButton m_pbClose
;
86 Window
* m_pPreSearchFocus
;
88 Link m_lnkFoundHandler
; ///< Handler for "found"
89 Link m_lnkCanceledNotFoundHdl
; ///< Handler for Positioning the Cursors
91 Link m_lnkContextSupplier
; ///< for search in contexts
93 /// memorize the currently selected field for every context
94 ::std::vector
<String
> m_arrContextFields
;
96 FmSearchEngine
* m_pSearchEngine
;
98 Timer m_aDelayedPaint
;
101 ::svxform::FmSearchConfigItem
* m_pConfig
;
103 /** This can search in different sets of fields. There is a number of contexts; their names are in strContexts (seperated
104 by ';'), the user can choose one of them.
105 When the user chooses a context, lnkContextSupplier is called, it gets a pointer on an FmSearchContext-structure,
106 that has to be filled.
107 The following counts for the search :
108 a) in case of formatted search the iterator itself is used (like in the first constructor)
109 b) in case of formatted search NOT the FormatKey at the fields of the iterator is used, but the respective TextComponent
110 is asked (that's why the original iterator is used; by its move the controls behind the TextComponent-interface are
112 c) in case of not-formatted search a clone of the iterator is used (because the TextComponent-interfaces don't need to
114 (of course needed : the string number i in strUsedFields of a context must correspond with the interface number i in the
115 arrFields of the context)
117 FmSearchDialog(Window
* pParent
, const OUString
& strInitialText
, const ::std::vector
< String
>& _rContexts
, sal_Int16 nInitialContext
,
118 const Link
& lnkContextSupplier
);
120 virtual ~FmSearchDialog();
122 /** The found-handler gets in the 'found'-case a pointer on a FmFoundRecordInformation-structure
123 (which is only valid in the handler; so if one needs to memorize the data, don't copy the pointer but
125 This handler MUST be set.
126 Furthermore, it should be considered, that during the handler the search-dialog is still modal.
128 void SetFoundHandler(const Link
& lnk
) { m_lnkFoundHandler
= lnk
; }
130 If the search has been cancelled or has been finished without success, the current data set is always displayed in the
131 search dialog. This handler exists to make this synchronous with the possible display of the caller (it does not
132 necessarily need to be set).
133 The pointer that is passed to the handler points to a FmFoundRecordInformation-structure, for which aPosition and
134 possibly (in a search with contexts) nContext are valid.
136 void SetCanceledNotFoundHdl(const Link
& lnk
) { m_lnkCanceledNotFoundHdl
= lnk
; }
138 inline void SetActiveField(const String
& strField
);
141 virtual sal_Bool
Close();
143 void Init(const OUString
& strVisibleFields
, const OUString
& strInitialText
);
144 // only to be used out of the constructors
146 void OnFound(const ::com::sun::star::uno::Any
& aCursorPos
, sal_Int16 nFieldPos
);
147 /** When searching in an own thread I naturally want to disable the UI for starting the search and for setting search
148 parameters. If bEnable == sal_False, for all affected controls painting is turned off and shortly after turned on
149 again using m_aDelayedPaint. If there is a demand with bEnable == sal_True inbetween, the timer is stopped and
150 painting is turned on immediately. As a consequence for this intricateness there is no flickering when turning
153 void EnableSearchUI(sal_Bool bEnable
);
155 void EnableSearchForDependees(sal_Bool bEnable
);
157 void EnableControlPaint(sal_Bool bEnable
);
159 void InitContext(sal_Int16 nContext
);
162 void SaveParams() const;
165 // Handler for the Controls
166 DECL_LINK( OnClickedFieldRadios
, Button
* );
167 DECL_LINK(OnClickedSearchAgain
, void *);
168 DECL_LINK( OnClickedSpecialSettings
, Button
* );
170 DECL_LINK(OnSearchTextModified
, void *);
172 DECL_LINK( OnPositionSelected
, ListBox
* );
173 DECL_LINK( OnFieldSelected
, ListBox
* );
175 DECL_LINK( OnCheckBoxToggled
, CheckBox
* );
177 DECL_LINK( OnContextSelection
, ListBox
* );
179 DECL_LINK( OnSearchProgress
, FmSearchProgress
* );
181 DECL_LINK( OnDelayedPaint
, void* ); ///< see EnableSearchUI
183 void implMoveControls(Control
** _ppControls
, sal_Int32 _nControls
, sal_Int32 _nUp
, Control
* _pToResize
);
185 void initCommon( const ::com::sun::star::uno::Reference
< ::com::sun::star::sdbc::XResultSet
>& _rxCursor
);
188 inline void FmSearchDialog::SetActiveField(const String
& strField
)
190 sal_uInt16 nInitialField
= m_lbField
.GetEntryPos(strField
);
191 if (nInitialField
== COMBOBOX_ENTRY_NOTFOUND
)
193 m_lbField
.SelectEntryPos(nInitialField
);
194 LINK(this, FmSearchDialog
, OnFieldSelected
).Call(&m_lbField
);
197 #endif // _CUI_FMSEARCH_HXX
199 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */