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 .
19 #ifndef INCLUDED_SVX_SRCHDLG_HXX
20 #define INCLUDED_SVX_SRCHDLG_HXX
22 #include <sfx2/childwin.hxx>
23 #include <sfx2/basedlgs.hxx>
24 #include <svl/poolitem.hxx>
25 #include <svl/srchdefs.hxx>
26 #include <svl/srchitem.hxx>
27 #include <svl/itemset.hxx>
28 #include <svx/svxdllapi.h>
29 #include <vcl/timer.hxx>
34 class SfxStyleSheetBasePool
;
35 class SvxJSearchOptionsPage
;
36 class SvxSearchController
;
37 class VclAbstractDialog
;
38 struct SearchDlg_Impl
;
39 enum class ModifyFlags
;
40 enum class TransliterationFlags
;
48 SearchAttrInfo(sal_uInt16 Slot
, const SfxPoolItemHolder
& ItemPtr
)
50 , aItemPtr(ItemPtr
) {}
53 SfxPoolItemHolder aItemPtr
;
56 typedef std::vector
<SearchAttrInfo
> SrchAttrInfoList
;
58 class SVX_DLLPUBLIC SearchAttrItemList
: private SrchAttrInfoList
61 SearchAttrItemList() {}
62 SearchAttrItemList( const SearchAttrItemList
& rList
);
63 SearchAttrItemList( SearchAttrItemList
&& rList
) noexcept
;
64 ~SearchAttrItemList();
66 void Put( const SfxItemSet
& rSet
);
67 SfxItemSet
& Get( SfxItemSet
& rSet
);
69 sal_uInt16
Count() const { return SrchAttrInfoList::size(); }
70 SearchAttrInfo
& operator[](sal_uInt16 nPos
)
71 { return SrchAttrInfoList::operator[]( nPos
); }
72 SearchAttrInfo
& GetObject( sal_uInt16 nPos
)
73 { return SrchAttrInfoList::operator[]( nPos
); }
75 // the pointer to the item is not being copied, so don't delete
76 void Insert( const SearchAttrInfo
& rItem
)
77 { SrchAttrInfoList::push_back( rItem
); }
78 // deletes the pointer to the items
79 void Remove(size_t nPos
);
82 enum class SearchLabel
96 class SvxSearchDialog
;
97 class SVX_DLLPUBLIC SvxSearchDialogWrapper final
: public SfxChildWindow
99 std::shared_ptr
<SvxSearchDialog
> dialog
;
101 SvxSearchDialogWrapper( vcl::Window
*pParent
, sal_uInt16 nId
,
102 SfxBindings
* pBindings
, SfxChildWinInfo
const * pInfo
);
104 virtual ~SvxSearchDialogWrapper () override
;
105 SvxSearchDialog
*getDialog () { return dialog
.get();}
106 static void SetSearchLabel(const SearchLabel
& rSL
);
107 static void SetSearchLabel(const OUString
& sStr
);
108 static OUString
GetSearchLabel();
109 SFX_DECL_CHILDWINDOW_WITHID(SvxSearchDialogWrapper
);
113 In this modeless dialog the attributes for a search are configured
114 and a search is started from it. Several search types
115 (search, search all, replace, replace all) are possible.
119 class SVX_DLLPUBLIC SvxSearchDialog final
: public SfxModelessDialogController
121 friend class SvxSearchController
;
122 friend class SvxSearchDialogWrapper
;
123 friend class SvxJSearchOptionsDialog
;
126 SvxSearchDialog(weld::Window
* pParent
, SfxChildWindow
* pChildWin
, SfxBindings
& rBind
);
127 virtual ~SvxSearchDialog() override
;
129 virtual void ChildWinDispose() override
;
130 virtual void Close() override
;
133 virtual void Activate() override
;
135 const SearchAttrItemList
* GetSearchItemList() const
136 { return pSearchList
.get(); }
137 const SearchAttrItemList
* GetReplaceItemList() const
138 { return pReplaceList
.get(); }
140 TransliterationFlags
GetTransliterationFlags() const;
142 void SetSaveToModule(bool b
);
144 void SetSearchLabel(const OUString
& rStr
);
146 // bring this window back to the foreground
150 SfxBindings
& rBindings
;
151 Timer m_aPresentIdle
;
155 bool bReplaceBackwards
;
156 SearchOptionFlags nOptions
;
159 ModifyFlags nModifyFlag
;
162 OUString aLayoutWriterStr
;
163 OUString aLayoutCalcStr
;
165 sal_uInt16 nRememberSize
;
167 std::vector
<OUString
> aSearchStrings
;
168 std::vector
<OUString
> aReplaceStrings
;
170 std::unique_ptr
<SearchDlg_Impl
> pImpl
;
171 std::unique_ptr
<SearchAttrItemList
> pSearchList
;
172 std::unique_ptr
<SearchAttrItemList
> pReplaceList
;
173 std::unique_ptr
<SvxSearchItem
> pSearchItem
;
175 std::unique_ptr
<SvxSearchController
> pSearchController
;
176 std::unique_ptr
<SvxSearchController
> pOptionsController
;
177 std::unique_ptr
<SvxSearchController
> pFamilyController
;
179 mutable TransliterationFlags
180 nTransliterationFlags
;
182 bool m_executingSubDialog
= false;
184 std::unique_ptr
<weld::Frame
> m_xSearchFrame
;
185 std::unique_ptr
<weld::ComboBox
> m_xSearchLB
;
186 std::unique_ptr
<weld::ComboBox
> m_xSearchTmplLB
;
187 std::unique_ptr
<weld::Label
> m_xSearchAttrText
;
188 std::unique_ptr
<weld::Label
> m_xSearchLabel
;
189 std::unique_ptr
<weld::Image
> m_xSearchIcon
;
190 std::unique_ptr
<weld::Container
> m_xSearchBox
;
192 std::unique_ptr
<weld::Frame
> m_xReplaceFrame
;
193 std::unique_ptr
<weld::ComboBox
> m_xReplaceLB
;
194 std::unique_ptr
<weld::ComboBox
> m_xReplaceTmplLB
;
195 std::unique_ptr
<weld::Label
> m_xReplaceAttrText
;
197 std::unique_ptr
<weld::Button
> m_xSearchBtn
;
198 std::unique_ptr
<weld::Button
> m_xBackSearchBtn
;
199 std::unique_ptr
<weld::Button
> m_xSearchAllBtn
;
200 std::unique_ptr
<weld::Button
> m_xReplaceBtn
;
201 std::unique_ptr
<weld::Button
> m_xReplaceAllBtn
;
203 std::unique_ptr
<weld::Frame
> m_xComponentFrame
;
204 std::unique_ptr
<weld::Button
> m_xSearchComponent1PB
;
205 std::unique_ptr
<weld::Button
> m_xSearchComponent2PB
;
207 std::unique_ptr
<weld::CheckButton
> m_xMatchCaseCB
;
208 std::unique_ptr
<weld::CheckButton
> m_xSearchFormattedCB
;
209 std::unique_ptr
<weld::CheckButton
> m_xWordBtn
;
211 std::unique_ptr
<weld::Button
> m_xCloseBtn
;
212 std::unique_ptr
<weld::Button
> m_xHelpBtn
;
213 std::unique_ptr
<weld::CheckButton
> m_xIncludeDiacritics
;
214 std::unique_ptr
<weld::CheckButton
> m_xIncludeKashida
;
215 std::unique_ptr
<weld::Expander
> m_xOtherOptionsExpander
;
216 std::unique_ptr
<weld::CheckButton
> m_xSelectionBtn
;
217 std::unique_ptr
<weld::CheckButton
> m_xRegExpBtn
;
218 std::unique_ptr
<weld::CheckButton
> m_xWildcardBtn
;
219 std::unique_ptr
<weld::CheckButton
> m_xSimilarityBox
;
220 std::unique_ptr
<weld::Button
> m_xSimilarityBtn
;
221 std::unique_ptr
<weld::CheckButton
> m_xLayoutBtn
;
222 std::unique_ptr
<weld::CheckButton
> m_xNotesBtn
;
223 std::unique_ptr
<weld::CheckButton
> m_xJapMatchFullHalfWidthCB
;
224 std::unique_ptr
<weld::CheckButton
> m_xJapOptionsCB
;
225 std::unique_ptr
<weld::CheckButton
> m_xReplaceBackwardsCB
;
226 std::unique_ptr
<weld::Button
> m_xJapOptionsBtn
;
228 std::unique_ptr
<weld::Button
> m_xAttributeBtn
;
229 std::unique_ptr
<weld::Button
> m_xFormatBtn
;
230 std::unique_ptr
<weld::Button
> m_xNoFormatBtn
;
232 std::unique_ptr
<weld::Widget
> m_xCalcGrid
;
233 std::unique_ptr
<weld::Label
> m_xCalcSearchInFT
;
234 std::unique_ptr
<weld::ComboBox
> m_xCalcSearchInLB
;
235 std::unique_ptr
<weld::Label
> m_xCalcSearchDirFT
;
236 std::unique_ptr
<weld::RadioButton
> m_xRowsBtn
;
237 std::unique_ptr
<weld::RadioButton
> m_xColumnsBtn
;
238 std::unique_ptr
<weld::CheckButton
> m_xAllSheetsCB
;
239 std::unique_ptr
<weld::Label
> m_xCalcStrFT
;
241 DECL_DLLPRIVATE_LINK( ModifyHdl_Impl
, weld::ComboBox
&, void );
242 DECL_DLLPRIVATE_LINK( FlagHdl_Impl
, weld::Toggleable
&, void );
243 DECL_DLLPRIVATE_LINK( CommandHdl_Impl
, weld::Button
&, void );
244 DECL_DLLPRIVATE_LINK(TemplateHdl_Impl
, weld::Toggleable
&, void);
245 DECL_DLLPRIVATE_LINK( FocusHdl_Impl
, weld::Widget
&, void );
246 DECL_DLLPRIVATE_LINK( LBSelectHdl_Impl
, weld::ComboBox
&, void );
247 DECL_DLLPRIVATE_LINK(LoseFocusHdl_Impl
, weld::Widget
&, void);
248 DECL_DLLPRIVATE_LINK(FormatHdl_Impl
, weld::Button
&, void);
249 DECL_DLLPRIVATE_LINK(NoFormatHdl_Impl
, weld::Button
&, void);
250 DECL_DLLPRIVATE_LINK(AttributeHdl_Impl
, weld::Button
&, void);
251 DECL_DLLPRIVATE_LINK( TimeoutHdl_Impl
, Timer
*, void );
252 SVX_DLLPRIVATE
void ClickHdl_Impl(const weld::Widget
* pCtrl
);
254 SVX_DLLPRIVATE
void Construct_Impl();
255 SVX_DLLPRIVATE
void InitControls_Impl();
256 SVX_DLLPRIVATE
void ShowOptionalControls_Impl();
257 SVX_DLLPRIVATE
void Init_Impl( bool bHasItemSet
);
258 SVX_DLLPRIVATE
void InitAttrList_Impl( const SfxItemSet
* pSSet
,
259 const SfxItemSet
* pRSet
);
260 SVX_DLLPRIVATE
void Remember_Impl( const OUString
&rStr
, bool bSearch
);
261 SVX_DLLPRIVATE
void PaintAttrText_Impl();
262 SVX_DLLPRIVATE OUString
& BuildAttrText_Impl( OUString
& rStr
, bool bSrchFlag
) const;
264 SVX_DLLPRIVATE
void TemplatesChanged_Impl( SfxStyleSheetBasePool
& rPool
);
265 SVX_DLLPRIVATE
void EnableControls_Impl( const SearchOptionFlags nFlags
);
266 SVX_DLLPRIVATE
void EnableControl_Impl(const weld::Widget
& rCtrl
);
267 SVX_DLLPRIVATE
void SetItem_Impl( const SvxSearchItem
* pItem
);
269 SVX_DLLPRIVATE
void SetModifyFlag_Impl(const weld::Widget
* pCtrl
);
270 SVX_DLLPRIVATE
void SaveToModule_Impl();
272 SVX_DLLPRIVATE
void ApplyTransliterationFlags_Impl( TransliterationFlags nSettings
);
273 SVX_DLLPRIVATE
bool IsOtherOptionsExpanded() const;
275 SVX_DLLPRIVATE
short executeSubDialog(VclAbstractDialog
* dialog
);
277 DECL_DLLPRIVATE_LINK(PresentTimeoutHdl_Impl
, Timer
*, void);
282 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */