LibreOffice Module cui (master)  1
cuifmsearch.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #ifndef INCLUDED_CUI_SOURCE_INC_CUIFMSEARCH_HXX
21 #define INCLUDED_CUI_SOURCE_INC_CUIFMSEARCH_HXX
22 
23 #include <com/sun/star/sdbc/XResultSet.hpp>
24 
25 #include <svx/fmsearch.hxx>
26 #include <vcl/weld.hxx>
27 #include <tools/link.hxx>
28 #include <rtl/ustring.hxx>
29 
30 namespace svxform {
31  class FmSearchConfigItem;
32 }
33 
34 struct FmSearchProgress;
35 
36 class FmSearchEngine;
37 
40 {
41  friend class FmSearchEngine;
42 
43  OUString m_sSearch;
44  OUString m_sCancel;
45 
48 
50 
52  std::vector<OUString> m_arrContextFields;
53 
54  std::unique_ptr<FmSearchEngine> m_pSearchEngine;
55 
56  // see EnableSearchUI
57  std::unique_ptr<::svxform::FmSearchConfigItem> m_pConfig;
58 
59  // my all Controls
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;
86 
87 public:
102  FmSearchDialog(weld::Window* pParent, const OUString& strInitialText, const std::vector< OUString >& _rContexts, sal_Int16 nInitialContext,
103  const Link<FmSearchContext&,sal_uInt32>& lnkContextSupplier);
104 
105  virtual short run() override;
106 
107  virtual ~FmSearchDialog() override;
108 
115  void SetFoundHandler(const Link<FmFoundRecordInformation&,void>& lnk) { m_lnkFoundHandler = lnk; }
123  void SetCanceledNotFoundHdl(const Link<FmFoundRecordInformation&,void>& lnk) { m_lnkCanceledNotFoundHdl = lnk; }
124 
125  inline void SetActiveField(const OUString& strField);
126 
127 private:
128  void Init(const OUString& strVisibleFields, const OUString& strInitialText);
129  // only to be used out of the constructors
130 
131  void OnFound(const css::uno::Any& aCursorPos, sal_Int16 nFieldPos);
132 
133  void EnableSearchUI(bool bEnable);
134 
135  void EnableSearchForDependees(bool bEnable);
136 
137  void InitContext(sal_Int16 nContext);
138 
139  void LoadParams();
140  void SaveParams() const;
141 
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 );
146 
147  DECL_LINK( OnSearchTextModified, weld::ComboBox&, void );
148 
149  DECL_LINK( OnPositionSelected, weld::ComboBox&, void );
150  DECL_LINK( OnFieldSelected, weld::ComboBox&, void );
151 
152  DECL_LINK( OnFocusGrabbed, weld::Widget&, void );
153  DECL_LINK( OnCheckBoxToggled, weld::ToggleButton&, void );
154 
155  DECL_LINK( OnContextSelection, weld::ComboBox&, void );
156 
157  DECL_LINK( OnSearchProgress, const FmSearchProgress*, void );
158 
159  void initCommon( const css::uno::Reference< css::sdbc::XResultSet >& _rxCursor );
160 };
161 
162 inline void FmSearchDialog::SetActiveField(const OUString& strField)
163 {
164  int nInitialField = m_plbField->find_text(strField);
165  if (nInitialField == -1)
166  nInitialField = 0;
167  m_plbField->set_active(nInitialField);
168  OnFieldSelected(*m_plbField);
169 }
170 
171 #endif // INCLUDED_CUI_SOURCE_INC_CUIFMSEARCH_HXX
172 
173 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
std::unique_ptr< weld::ComboBox > m_plbPosition
Definition: cuifmsearch.hxx:70
std::unique_ptr< weld::Button > m_pSoundsLikeCJKSettings
Definition: cuifmsearch.hxx:81
void SaveParams() const
DECL_LINK(OnClickedFieldRadios, weld::Button &, void)
std::unique_ptr< weld::RadioButton > m_prbSingleField
Definition: cuifmsearch.hxx:67
std::unique_ptr< weld::ComboBox > m_plbForm
Definition: cuifmsearch.hxx:65
std::unique_ptr< weld::CheckButton > m_pcbCase
Definition: cuifmsearch.hxx:72
std::unique_ptr< weld::Button > m_pbClose
Definition: cuifmsearch.hxx:85
std::unique_ptr< weld::CheckButton > m_pcbStartOver
Definition: cuifmsearch.hxx:74
std::unique_ptr< weld::ComboBox > m_pcmbSearchText
Definition: cuifmsearch.hxx:63
std::unique_ptr< weld::CheckButton > m_pcbBackwards
Definition: cuifmsearch.hxx:73
void EnableSearchUI(bool bEnable)
std::unique_ptr< weld::Label > m_pftPosition
Definition: cuifmsearch.hxx:69
std::unique_ptr< weld::Label > m_pftRecord
Definition: cuifmsearch.hxx:82
Link< FmFoundRecordInformation &, void > m_lnkCanceledNotFoundHdl
Handler for Positioning the Cursors.
Definition: cuifmsearch.hxx:47
std::unique_ptr< weld::Label > m_pftForm
Definition: cuifmsearch.hxx:64
void SetActiveField(const OUString &strField)
void SetCanceledNotFoundHdl(const Link< FmFoundRecordInformation &, void > &lnk)
If the search has been cancelled or has been finished without success, the current data set is always...
std::unique_ptr< weld::RadioButton > m_prbSearchForNull
Definition: cuifmsearch.hxx:61
OUString m_sCancel
Definition: cuifmsearch.hxx:44
std::unique_ptr< weld::CheckButton > m_pcbRegular
Definition: cuifmsearch.hxx:76
std::unique_ptr< weld::CheckButton > m_pSoundsLikeCJK
Definition: cuifmsearch.hxx:80
std::unique_ptr< weld::ComboBox > m_plbField
Definition: cuifmsearch.hxx:68
std::unique_ptr< weld::Button > m_ppbApproxSettings
Definition: cuifmsearch.hxx:78
std::unique_ptr< weld::CheckButton > m_pHalfFullFormsCJK
Definition: cuifmsearch.hxx:79
std::vector< OUString > m_arrContextFields
memorize the currently selected field for every context
Definition: cuifmsearch.hxx:52
std::unique_ptr< weld::CheckButton > m_pcbWildCard
Definition: cuifmsearch.hxx:75
FmSearchDialog(weld::Window *pParent, const OUString &strInitialText, const std::vector< OUString > &_rContexts, sal_Int16 nInitialContext, const Link< FmSearchContext &, sal_uInt32 > &lnkContextSupplier)
This can search in different sets of fields.
Definition: cuifmsearch.cxx:71
std::unique_ptr< weld::RadioButton > m_prbSearchForText
Definition: cuifmsearch.hxx:60
void EnableSearchForDependees(bool bEnable)
std::unique_ptr< FmSearchEngine > m_pSearchEngine
Definition: cuifmsearch.hxx:54
Dialog for searching in Forms/Tables.
Definition: cuifmsearch.hxx:39
std::unique_ptr< weld::Button > m_pbSearchAgain
Definition: cuifmsearch.hxx:84
std::unique_ptr< weld::CheckButton > m_pcbApprox
Definition: cuifmsearch.hxx:77
std::unique_ptr< weld::RadioButton > m_prbAllFields
Definition: cuifmsearch.hxx:66
void initCommon(const css::uno::Reference< css::sdbc::XResultSet > &_rxCursor)
Definition: cuifmsearch.cxx:43
Link< FmSearchContext &, sal_uInt32 > m_lnkContextSupplier
for search in contexts
Definition: cuifmsearch.hxx:49
std::unique_ptr< weld::CheckButton > m_pcbUseFormat
Definition: cuifmsearch.hxx:71
void InitContext(sal_Int16 nContext)
std::unique_ptr< weld::Label > m_pftHint
Definition: cuifmsearch.hxx:83
std::unique_ptr< weld::RadioButton > m_prbSearchForNotNull
Definition: cuifmsearch.hxx:62
std::unique_ptr<::svxform::FmSearchConfigItem > m_pConfig
Definition: cuifmsearch.hxx:57
OUString m_sSearch
Definition: cuifmsearch.hxx:43
virtual ~FmSearchDialog() override
void SetFoundHandler(const Link< FmFoundRecordInformation &, void > &lnk)
The found-handler gets in the 'found'-case a pointer on a FmFoundRecordInformation-structure (which i...
void Init(const OUString &strVisibleFields, const OUString &strInitialText)
Link< FmFoundRecordInformation &, void > m_lnkFoundHandler
Handler for "found".
Definition: cuifmsearch.hxx:46
void OnFound(const css::uno::Any &aCursorPos, sal_Int16 nFieldPos)
virtual short run() override