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 INCLUDED_CUI_SOURCE_INC_CUIFMSEARCH_HXX
21 #define INCLUDED_CUI_SOURCE_INC_CUIFMSEARCH_HXX
23 #include <com/sun/star/sdbc/XResultSet.hpp>
25 #include <svx/fmsearch.hxx>
26 #include <vcl/weld.hxx>
27 #include <tools/link.hxx>
28 #include <rtl/ustring.hxx>
31 class FmSearchConfigItem
;
34 struct FmSearchProgress
;
38 /// Dialog for searching in Forms/Tables
39 class FmSearchDialog final
: public weld::GenericDialogController
41 friend class FmSearchEngine
;
46 Link
<FmFoundRecordInformation
&,void> m_lnkFoundHandler
; ///< Handler for "found"
47 Link
<FmFoundRecordInformation
&,void> m_lnkCanceledNotFoundHdl
; ///< Handler for Positioning the Cursors
49 Link
<FmSearchContext
&,sal_uInt32
> m_lnkContextSupplier
; ///< for search in contexts
51 /// memorize the currently selected field for every context
52 std::vector
<OUString
> m_arrContextFields
;
54 std::unique_ptr
<FmSearchEngine
> m_pSearchEngine
;
57 std::unique_ptr
<::svxform::FmSearchConfigItem
> m_pConfig
;
60 std::unique_ptr
<weld::RadioButton
> m_prbSearchForText
;
61 std::unique_ptr
<weld::RadioButton
> m_prbSearchForNull
;
62 std::unique_ptr
<weld::RadioButton
> m_prbSearchForNotNull
;
63 std::unique_ptr
<weld::ComboBox
> m_pcmbSearchText
;
64 std::unique_ptr
<weld::Label
> m_pftForm
;
65 std::unique_ptr
<weld::ComboBox
> m_plbForm
;
66 std::unique_ptr
<weld::RadioButton
> m_prbAllFields
;
67 std::unique_ptr
<weld::RadioButton
> m_prbSingleField
;
68 std::unique_ptr
<weld::ComboBox
> m_plbField
;
69 std::unique_ptr
<weld::Label
> m_pftPosition
;
70 std::unique_ptr
<weld::ComboBox
> m_plbPosition
;
71 std::unique_ptr
<weld::CheckButton
> m_pcbUseFormat
;
72 std::unique_ptr
<weld::CheckButton
> m_pcbCase
;
73 std::unique_ptr
<weld::CheckButton
> m_pcbBackwards
;
74 std::unique_ptr
<weld::CheckButton
> m_pcbStartOver
;
75 std::unique_ptr
<weld::CheckButton
> m_pcbWildCard
;
76 std::unique_ptr
<weld::CheckButton
> m_pcbRegular
;
77 std::unique_ptr
<weld::CheckButton
> m_pcbApprox
;
78 std::unique_ptr
<weld::Button
> m_ppbApproxSettings
;
79 std::unique_ptr
<weld::CheckButton
> m_pHalfFullFormsCJK
;
80 std::unique_ptr
<weld::CheckButton
> m_pSoundsLikeCJK
;
81 std::unique_ptr
<weld::Button
> m_pSoundsLikeCJKSettings
;
82 std::unique_ptr
<weld::Label
> m_pftRecord
;
83 std::unique_ptr
<weld::Label
> m_pftHint
;
84 std::unique_ptr
<weld::Button
> m_pbSearchAgain
;
85 std::unique_ptr
<weld::Button
> m_pbClose
;
88 /** This can search in different sets of fields. There is a number of contexts; their names are in strContexts (separated
89 by ';'), the user can choose one of them.
90 When the user chooses a context, lnkContextSupplier is called, it gets a pointer on a FmSearchContext-structure,
91 that has to be filled.
92 The following counts for the search :
93 a) in case of formatted search the iterator itself is used (like in the first constructor)
94 b) in case of formatted search NOT the FormatKey at the fields of the iterator is used, but the respective TextComponent
95 is asked (that's why the original iterator is used; by its move the controls behind the TextComponent-interface are
97 c) in case of not-formatted search a clone of the iterator is used (because the TextComponent-interfaces don't need to
99 (of course needed : the string number i in strUsedFields of a context must correspond with the interface number i in the
100 arrFields of the context)
102 FmSearchDialog(weld::Window
* pParent
, const OUString
& strInitialText
, const std::vector
< OUString
>& _rContexts
, sal_Int16 nInitialContext
,
103 const Link
<FmSearchContext
&,sal_uInt32
>& lnkContextSupplier
);
105 virtual short run() override
;
107 virtual ~FmSearchDialog() override
;
109 /** The found-handler gets in the 'found'-case a pointer on a FmFoundRecordInformation-structure
110 (which is only valid in the handler; so if one needs to memorize the data, don't copy the pointer but
112 This handler MUST be set.
113 Furthermore, it should be considered, that during the handler the search-dialog is still modal.
115 void SetFoundHandler(const Link
<FmFoundRecordInformation
&,void>& lnk
) { m_lnkFoundHandler
= lnk
; }
117 If the search has been cancelled or has been finished without success, the current data set is always displayed in the
118 search dialog. This handler exists to make this synchronous with the possible display of the caller (it does not
119 necessarily need to be set).
120 The pointer that is passed to the handler points to a FmFoundRecordInformation-structure, for which aPosition and
121 possibly (in a search with contexts) nContext are valid.
123 void SetCanceledNotFoundHdl(const Link
<FmFoundRecordInformation
&,void>& lnk
) { m_lnkCanceledNotFoundHdl
= lnk
; }
125 inline void SetActiveField(const OUString
& strField
);
128 void Init(const OUString
& strVisibleFields
, const OUString
& strInitialText
);
129 // only to be used out of the constructors
131 void OnFound(const css::uno::Any
& aCursorPos
, sal_Int16 nFieldPos
);
133 void EnableSearchUI(bool bEnable
);
135 void EnableSearchForDependees(bool bEnable
);
137 void InitContext(sal_Int16 nContext
);
140 void SaveParams() const;
142 // Handler for the Controls
143 DECL_LINK( OnClickedFieldRadios
, weld::Button
&, void );
144 DECL_LINK( OnClickedSearchAgain
, weld::Button
&, void );
145 DECL_LINK( OnClickedSpecialSettings
, weld::Button
&, void );
147 DECL_LINK( OnSearchTextModified
, weld::ComboBox
&, void );
149 DECL_LINK( OnPositionSelected
, weld::ComboBox
&, void );
150 DECL_LINK( OnFieldSelected
, weld::ComboBox
&, void );
152 DECL_LINK( OnFocusGrabbed
, weld::Widget
&, void );
153 DECL_LINK( OnCheckBoxToggled
, weld::ToggleButton
&, void );
155 DECL_LINK( OnContextSelection
, weld::ComboBox
&, void );
157 DECL_LINK( OnSearchProgress
, const FmSearchProgress
*, void );
159 void initCommon( const css::uno::Reference
< css::sdbc::XResultSet
>& _rxCursor
);
162 inline void FmSearchDialog::SetActiveField(const OUString
& strField
)
164 int nInitialField
= m_plbField
->find_text(strField
);
165 if (nInitialField
== -1)
167 m_plbField
->set_active(nInitialField
);
168 OnFieldSelected(*m_plbField
);
171 #endif // INCLUDED_CUI_SOURCE_INC_CUIFMSEARCH_HXX
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */