Coverage Report

Created: 2025-12-08 09:28

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