Coverage Report

Created: 2026-10-14 09:33

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/svx/srchdlg.hxx
Line
Count
Source
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
#ifndef INCLUDED_SVX_SRCHDLG_HXX
20
#define INCLUDED_SVX_SRCHDLG_HXX
21
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>
30
#include <vcl/weld/Button.hxx>
31
#include <vcl/weld/CheckButton.hxx>
32
#include <vcl/weld/ComboBox.hxx>
33
#include <vcl/weld/Container.hxx>
34
#include <vcl/weld/Expander.hxx>
35
#include <vcl/weld/Frame.hxx>
36
#include <vcl/weld/Image.hxx>
37
#include <vcl/weld/Label.hxx>
38
#include <vcl/weld/RadioButton.hxx>
39
40
#include <memory>
41
#include <vector>
42
43
class SvxSearchItem;
44
class SfxStyleSheetBasePool;
45
class SvxSearchController;
46
class VclAbstractDialog;
47
struct SearchDlg_Impl;
48
enum class ModifyFlags;
49
enum class TransliterationFlags;
50
51
struct SearchAttrInfo
52
{
53
    SearchAttrInfo()
54
    : nSlot(0)
55
0
    , aItemPtr() {}
56
57
    SearchAttrInfo(sal_uInt16 Slot, const SfxPoolItemHolder& ItemPtr)
58
0
    : nSlot(Slot)
59
0
    , aItemPtr(ItemPtr) {}
60
61
    sal_uInt16          nSlot;
62
    SfxPoolItemHolder   aItemPtr;
63
};
64
65
typedef std::vector<SearchAttrInfo> SrchAttrInfoList;
66
67
class SVX_DLLPUBLIC SearchAttrItemList : private SrchAttrInfoList
68
{
69
public:
70
0
    SearchAttrItemList() {}
71
    SearchAttrItemList( const SearchAttrItemList& rList );
72
    SearchAttrItemList( SearchAttrItemList&& rList ) noexcept;
73
    ~SearchAttrItemList();
74
75
    void            Put( const SfxItemSet& rSet );
76
    SfxItemSet&     Get( SfxItemSet& rSet );
77
    void            Clear();
78
0
    sal_uInt16      Count() const { return SrchAttrInfoList::size(); }
79
    SearchAttrInfo& operator[](sal_uInt16 nPos)
80
0
                        { return SrchAttrInfoList::operator[]( nPos ); }
81
    SearchAttrInfo& GetObject( sal_uInt16 nPos )
82
0
                        { return SrchAttrInfoList::operator[]( nPos ); }
83
84
    // the pointer to the item is not being copied, so don't delete
85
    void Insert( const SearchAttrInfo& rItem )
86
0
        { SrchAttrInfoList::push_back( rItem ); }
87
    // deletes the pointer to the items
88
    void Remove(size_t nPos);
89
};
90
91
enum class SearchLabel
92
{
93
    Empty,
94
    End,
95
    Start,
96
    EndSheet,
97
    NotFound,
98
    StartWrapped,
99
    EndWrapped,
100
    NavElementNotFound,
101
    ReminderStartWrapped,
102
    ReminderEndWrapped
103
};
104
105
class SvxSearchDialog;
106
class SVX_DLLPUBLIC SvxSearchDialogWrapper final : public SfxChildWindow
107
{
108
    std::shared_ptr<SvxSearchDialog> m_dialog;
109
public:
110
    SvxSearchDialogWrapper(vcl::Window* pParent, sal_uInt16 nId, SfxBindings& rBindings,
111
                           const SfxChildWinInfo& rInfo);
112
113
    virtual ~SvxSearchDialogWrapper () override;
114
0
    SvxSearchDialog *getDialog () { return m_dialog.get();}
115
    static void SetSearchLabel(const SearchLabel& rSL);
116
    static void SetSearchLabel(const OUString& sStr);
117
    static OUString GetSearchLabel();
118
    SFX_DECL_CHILDWINDOW_WITHID(SvxSearchDialogWrapper);
119
};
120
121
/**
122
    In this modeless dialog the attributes for a search are configured
123
    and a search is started from it. Several search types
124
    (search, search all, replace, replace all) are possible.
125
126
 */
127
128
class SVX_DLLPUBLIC SvxSearchDialog final : public SfxModelessDialogController
129
{
130
friend class SvxSearchController;
131
friend class SvxSearchDialogWrapper;
132
friend class SvxJSearchOptionsDialog;
133
134
public:
135
    SvxSearchDialog(weld::Window* pParent, SfxChildWindow* pChildWin, SfxBindings& rBind );
136
    virtual ~SvxSearchDialog() override;
137
138
    virtual void    ChildWinDispose() override;
139
    virtual void    Close() override;
140
141
    // Window
142
    virtual void    Activate() override;
143
144
0
    const SearchAttrItemList* GetSearchItemList() const { return m_pSearchList.get(); }
145
0
    const SearchAttrItemList* GetReplaceItemList() const { return m_pReplaceList.get(); }
146
147
    TransliterationFlags        GetTransliterationFlags() const;
148
149
    void            SetSaveToModule(bool b);
150
151
    void SetSearchLabel(const OUString& rStr);
152
153
    // bring this window back to the foreground
154
    void Present();
155
156
    void SetSearchLBEntryTextAndGrabFocus(const OUString& rStr);
157
158
private:
159
    SfxBindings& m_rBindings;
160
    Timer           m_aPresentIdle;
161
    bool m_bWriter;
162
    bool m_bSearch;
163
    bool m_bFormat;
164
    SearchOptionFlags m_nOptions;
165
    bool m_bSet;
166
    bool m_bConstruct;
167
    ModifyFlags m_nModifyFlag;
168
    OUString m_sStylesStr;
169
    OUString m_sLayoutStr;
170
    OUString m_sLayoutWriterStr;
171
    OUString m_sLayoutCalcStr;
172
    OUString m_sCalcStr;
173
    sal_uInt16 m_nRememberSize;
174
175
    std::vector<OUString> m_aSearchStrings;
176
    std::vector<OUString> m_aReplaceStrings;
177
178
    std::unique_ptr<SearchDlg_Impl> m_pImpl;
179
    std::unique_ptr<SearchAttrItemList> m_pSearchList;
180
    std::unique_ptr<SearchAttrItemList> m_pReplaceList;
181
    std::unique_ptr<SvxSearchItem> m_pSearchItem;
182
183
    std::unique_ptr<SvxSearchController> m_pSearchController;
184
    std::unique_ptr<SvxSearchController> m_pOptionsController;
185
    std::unique_ptr<SvxSearchController> m_pFamilyController;
186
187
    mutable TransliterationFlags m_nTransliterationFlags;
188
189
    bool m_executingSubDialog = false;
190
191
    std::unique_ptr<weld::Frame> m_xSearchFrame;
192
    std::unique_ptr<weld::ComboBox> m_xSearchLB;
193
    std::unique_ptr<weld::ComboBox> m_xSearchTmplLB;
194
    std::unique_ptr<weld::Label> m_xSearchAttrText;
195
    std::unique_ptr<weld::Label> m_xSearchLabel;
196
    std::unique_ptr<weld::Image> m_xSearchIcon;
197
    std::unique_ptr<weld::Container> m_xSearchBox;
198
199
    std::unique_ptr<weld::Frame> m_xReplaceFrame;
200
    std::unique_ptr<weld::ComboBox> m_xReplaceLB;
201
    std::unique_ptr<weld::ComboBox> m_xReplaceTmplLB;
202
    std::unique_ptr<weld::Label> m_xReplaceAttrText;
203
204
    std::unique_ptr<weld::Button> m_xSearchBtn;
205
    std::unique_ptr<weld::Button> m_xBackSearchBtn;
206
    std::unique_ptr<weld::Button> m_xSearchAllBtn;
207
    std::unique_ptr<weld::Button> m_xReplaceBtn;
208
    std::unique_ptr<weld::Button> m_xReplaceAllBtn;
209
210
    std::unique_ptr<weld::Frame> m_xComponentFrame;
211
    std::unique_ptr<weld::Button> m_xSearchComponent1PB;
212
    std::unique_ptr<weld::Button> m_xSearchComponent2PB;
213
214
    std::unique_ptr<weld::CheckButton> m_xMatchCaseCB;
215
    std::unique_ptr<weld::CheckButton> m_xSearchFormattedCB;
216
    std::unique_ptr<weld::CheckButton> m_xWordBtn;
217
218
    std::unique_ptr<weld::Button> m_xCloseBtn;
219
    std::unique_ptr<weld::Button> m_xHelpBtn;
220
    std::unique_ptr<weld::CheckButton> m_xIncludeDiacritics;
221
    std::unique_ptr<weld::CheckButton> m_xIncludeKashida;
222
    std::unique_ptr<weld::Expander> m_xOtherOptionsExpander;
223
    std::unique_ptr<weld::CheckButton> m_xSelectionBtn;
224
    std::unique_ptr<weld::CheckButton> m_xRegExpBtn;
225
    std::unique_ptr<weld::CheckButton> m_xWildcardBtn;
226
    std::unique_ptr<weld::CheckButton> m_xSimilarityBox;
227
    std::unique_ptr<weld::Button> m_xSimilarityBtn;
228
    std::unique_ptr<weld::CheckButton> m_xLayoutBtn;
229
    std::unique_ptr<weld::CheckButton> m_xNotesBtn;
230
    std::unique_ptr<weld::CheckButton> m_xJapMatchFullHalfWidthCB;
231
    std::unique_ptr<weld::CheckButton> m_xJapOptionsCB;
232
    std::unique_ptr<weld::CheckButton> m_xReplaceBackwardsCB;
233
    std::unique_ptr<weld::Button> m_xJapOptionsBtn;
234
235
    std::unique_ptr<weld::Button> m_xAttributeBtn;
236
    std::unique_ptr<weld::Button> m_xFormatBtn;
237
    std::unique_ptr<weld::Button> m_xNoFormatBtn;
238
239
    std::unique_ptr<weld::Widget> m_xCalcGrid;
240
    std::unique_ptr<weld::Label> m_xCalcSearchInFT;
241
    std::unique_ptr<weld::ComboBox> m_xCalcSearchInLB;
242
    std::unique_ptr<weld::Label> m_xCalcSearchDirFT;
243
    std::unique_ptr<weld::RadioButton> m_xRowsBtn;
244
    std::unique_ptr<weld::RadioButton> m_xColumnsBtn;
245
    std::unique_ptr<weld::CheckButton> m_xAllSheetsCB;
246
    std::unique_ptr<weld::Label> m_xCalcStrFT;
247
248
    DECL_DLLPRIVATE_LINK( ModifyHdl_Impl, weld::ComboBox&, void );
249
    DECL_DLLPRIVATE_LINK( FlagHdl_Impl, weld::Toggleable&, void );
250
    DECL_DLLPRIVATE_LINK( CommandHdl_Impl, weld::Button&, void );
251
    DECL_DLLPRIVATE_LINK(TemplateHdl_Impl, weld::Toggleable&, void);
252
    DECL_DLLPRIVATE_LINK( FocusHdl_Impl, weld::Widget&, void );
253
    DECL_DLLPRIVATE_LINK( LBSelectHdl_Impl, weld::ComboBox&, void );
254
    DECL_DLLPRIVATE_LINK(LoseFocusHdl_Impl, weld::Widget&, void);
255
    DECL_DLLPRIVATE_LINK(FormatHdl_Impl, weld::Button&, void);
256
    DECL_DLLPRIVATE_LINK(NoFormatHdl_Impl, weld::Button&, void);
257
    DECL_DLLPRIVATE_LINK(AttributeHdl_Impl, weld::Button&, void);
258
    DECL_DLLPRIVATE_LINK( TimeoutHdl_Impl, Timer*, void );
259
    SVX_DLLPRIVATE void ClickHdl_Impl(const weld::Widget* pCtrl);
260
261
    SVX_DLLPRIVATE void Construct_Impl();
262
    SVX_DLLPRIVATE void InitControls_Impl();
263
    SVX_DLLPRIVATE void ShowOptionalControls_Impl();
264
    SVX_DLLPRIVATE void Init_Impl( bool bHasItemSet );
265
    SVX_DLLPRIVATE void InitAttrList_Impl( const SfxItemSet* pSSet,
266
                                       const SfxItemSet* pRSet );
267
    SVX_DLLPRIVATE void Remember_Impl(bool bSearch);
268
    SVX_DLLPRIVATE void PaintAttrText_Impl();
269
    SVX_DLLPRIVATE OUString& BuildAttrText_Impl( OUString& rStr, bool bSrchFlag ) const;
270
271
    SVX_DLLPRIVATE void TemplatesChanged_Impl( SfxStyleSheetBasePool& rPool );
272
    SVX_DLLPRIVATE void EnableControls_Impl( const SearchOptionFlags nFlags );
273
    SVX_DLLPRIVATE void EnableControl_Impl(const weld::Widget& rCtrl);
274
    SVX_DLLPRIVATE void SetItem_Impl( const SvxSearchItem* pItem );
275
276
    SVX_DLLPRIVATE void SetModifyFlag_Impl(const weld::Widget* pCtrl);
277
    SVX_DLLPRIVATE void SaveToModule_Impl();
278
279
    SVX_DLLPRIVATE void ApplyTransliterationFlags_Impl( TransliterationFlags nSettings );
280
    SVX_DLLPRIVATE bool IsOtherOptionsExpanded() const;
281
282
    SVX_DLLPRIVATE short executeSubDialog(VclAbstractDialog * dialog);
283
    SVX_DLLPRIVATE void executeSubDialog(VclPtr<VclAbstractDialog> dialog,
284
                                         const std::function<void(sal_Int32)>& func);
285
286
    DECL_DLLPRIVATE_LINK(PresentTimeoutHdl_Impl, Timer*, void);
287
};
288
289
#endif
290
291
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */