Coverage Report

Created: 2026-02-14 09:37

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/sfx2/source/inc/templdgi.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_SFX2_SOURCE_INC_TEMPLDGI_HXX
20
#define INCLUDED_SFX2_SOURCE_INC_TEMPLDGI_HXX
21
22
#include <sal/config.h>
23
24
#include <memory>
25
26
#include <vcl/transfer.hxx>
27
#include <vcl/weld/Builder.hxx>
28
#include <vcl/weld/ComboBox.hxx>
29
#include <vcl/weld/Toolbar.hxx>
30
#include <vcl/weld/weld.hxx>
31
#include <svl/eitem.hxx>
32
33
#include <svl/style.hxx>
34
35
#include <sfx2/objsh.hxx>
36
#include <sfx2/styfitem.hxx>
37
#include <sfx2/templdlg.hxx>
38
39
#include "StyleList.hxx"
40
41
class SfxStyleFamilyItem;
42
class SfxTemplateItem;
43
class SfxBindings;
44
namespace com::sun::star::frame {
45
    class XModuleManager2;
46
}
47
48
class SfxCommonTemplateDialog_Impl
49
{
50
private:
51
    class DeletionWatcher;
52
    friend class DeletionWatcher;
53
54
    DeletionWatcher* impl_setDeletionWatcher(DeletionWatcher* pNewWatcher);
55
56
protected:
57
0
#define MAX_FAMILIES            6
58
0
#define COUNT_BOUND_FUNC        14
59
60
    friend class SfxTemplateControllerItem;
61
62
    SfxBindings* pBindings;
63
64
    css::uno::Reference<css::frame::XModuleManager2> xModuleManager;
65
    DeletionWatcher* m_pDeletionWatcher;
66
67
    StyleList m_aStyleList;
68
    std::unique_ptr<weld::CheckButton> mxPreviewCheckbox;
69
    std::unique_ptr<weld::CheckButton> mxSpotlightCheckbox;
70
    std::unique_ptr<weld::ComboBox> mxFilterLb;
71
72
    sal_uInt16 nActFamily; // Id in the ToolBox = Position - 1
73
    sal_uInt16 nActFilter; // FilterIdx
74
75
    bool bIsWater :1;
76
    bool bUpdate :1;
77
    bool bWaterDisabled :1;
78
    bool bNewByExampleDisabled :1;
79
    bool bUpdateByExampleDisabled :1;
80
    bool m_bWantHierarchical :1;
81
82
    Link<void*, size_t> m_aStyleListReadResource;
83
    Link<void*, void> m_aStyleListClear;
84
    Link<void*, void> m_aStyleListCleanup;
85
    Link<const ExecuteDropEvent&, sal_Int8> m_aStyleListExecuteDrop;
86
    Link<void*, void> m_aStyleListNewMenu;
87
    Link<void*, bool> m_aStyleListWaterCan;
88
    Link<void*, bool> m_aStyleListHasSelectedStyle;
89
    Link<void*, void> m_aStyleListUpdateStyleDependents;
90
    Link<bool, void> m_aStyleListEnableTreeDrag;
91
    Link<void*, void> m_aStyleListEnableDelete;
92
    Link<const SfxBoolItem*, void> m_aStyleListSetWaterCanState;
93
    Link<sal_uInt16, void> m_aStyleListSetFamily;
94
95
    DECL_LINK(FilterSelectHdl, weld::ComboBox&, void );
96
    DECL_LINK(PreviewHdl, weld::Toggleable&, void);
97
    DECL_LINK(SpotlightHdl, weld::Toggleable&, void);
98
99
    virtual void InsertFamilyItem(sal_uInt16 nId, const SfxStyleFamilyItem& rItem) = 0;
100
    virtual void EnableFamilyItem(sal_uInt16 nId, bool bEnabled) = 0;
101
    virtual void ClearFamilyList() = 0;
102
    virtual void ReplaceUpdateButtonByMenu();
103
104
    void Initialize();
105
    void EnableHierarchical(bool, StyleList& rStyleList);
106
107
    void FilterSelect( sal_uInt16 nFilterIdx );
108
    void SetFamilyState( sal_uInt16 nSlotId, const SfxTemplateItem* );
109
    void SetWaterCanState( const SfxBoolItem* pItem );
110
    bool IsSafeForWaterCan() const;
111
112
    void SetFamily(SfxStyleFamily nFamily);
113
    void ActionSelect(const OUString& rId, StyleList& rStyleList);
114
115
    void SaveFactoryStyleFilter(SfxObjectShell const* i_pObjSh, sal_Int32 i_nFilter);
116
117
    DECL_LINK(ReadResource_Hdl, StyleList&, void);
118
    DECL_LINK(ClearResource_Hdl, void*, void);
119
    DECL_LINK(SaveSelection_Hdl, StyleList&, SfxObjectShell*);
120
    DECL_LINK(LoadFactoryStyleFilter_Hdl, SfxObjectShell const*, sal_Int32);
121
    DECL_LINK(UpdateStyles_Hdl, StyleFlags, void);
122
    DECL_LINK(UpdateFamily_Hdl, StyleList&, void);
123
    DECL_LINK(UpdateStyleDependents_Hdl, void*, void);
124
125
public:
126
    // Used in StyleList::NewMenuExecuteAction, StyleList::UpdateStyleDependents, StyleList::NewHdl,  EditHdl...
127
    // It comes into action whenever an existing style is selected for use, or a new style is created etc..
128
    bool Execute_Impl(sal_uInt16 nId, const OUString& rStr, const OUString& rRefStr,
129
                      sal_uInt16 nFamily, StyleList& rStyleList, SfxStyleSearchBits nMask = SfxStyleSearchBits::Auto,
130
                      sal_uInt16* pIdx = nullptr, const sal_uInt16* pModifier = nullptr);
131
132
    // This function handles drop of content into the treeview to create a new style
133
    sal_Int8 ExecuteDrop(const ExecuteDropEvent& rEvt);
134
    // This function is used when a newstyle is created
135
    DECL_LINK(OnAsyncExecuteDrop, void*, void);
136
137
    // Used in StyleList::UpdateStyles, StyleList::Update
138
    // Whenever a new family(Eg. Character, List etc.) is selected it comes into action
139
    void FamilySelect(sal_uInt16 nId, StyleList& rStyleList, bool bRefresh = false);
140
141
    // Constructor
142
    SfxCommonTemplateDialog_Impl(SfxBindings* pB, weld::Container*, weld::Builder* pBuilder);
143
144
    // Destructor
145
    virtual ~SfxCommonTemplateDialog_Impl();
146
147
    // Used in StyleList::SelectStyle, StyleList::Notify, IMPL_LINK(PopupFlatMenuHdl)
148
    // These functions are used when a style is edited, deleted, created etc..
149
    virtual void EnableEdit(bool b, StyleList* rStyleList);
150
    void EnableDel(bool b, const StyleList* rStyleList);
151
    void EnableNew(bool b, const StyleList* rStyleList);
152
    void EnableHide(bool b, const StyleList* rStyleList);
153
    void EnableShow(bool b, const StyleList* rStyleList);
154
155
    // Used in TreeDrag
156
    void EnableTreeDrag(bool b);
157
    // It comes into action when a style is created or updated or newmenu is created
158
    void EnableExample_Impl(sal_uInt16 nId, bool bEnable);
159
160
    // This comes into action when a family is selected or a style is applied for use
161
0
    virtual void CheckItem(const OUString& /*rMesId*/, bool /*bCheck*/ = true) {}
162
    // This is used for watercan or when newmenu or watercan is enabled or updated
163
0
    virtual void EnableItem(const OUString& /*rMesId*/, bool /*bCheck*/ = true) {}
164
    // This is used for watercan
165
0
    virtual bool IsCheckedItem(const OUString& /*rMesId*/) { return true; }
166
167
    // This is used when a style is selected
168
    void SelectStyle(const OUString& rStyle, bool bIsCallback, StyleList& rStyleList);
169
170
    //When a new document is created, it comes into action
171
    void IsUpdate(StyleList&);
172
173
    // This function return the value of bUpdate in Stylelist
174
    // This value is used in StyleList's Notify
175
0
    bool GetNotifyUpdate() const { return bUpdate; }
176
    // This function sets the value of bUpdate in Dialog
177
    // This function is used in StyleList's Notify to update the value of bUpdate when required
178
0
    void SetNotifyupdate(bool b) { bUpdate = b; }
179
180
0
    void connect_stylelist_read_resource(const Link<void*, size_t>& rLink) { m_aStyleListReadResource = rLink; }
181
0
    void connect_stylelist_clear(const Link<void*, void>& rLink) { m_aStyleListClear = rLink; }
182
0
    void connect_stylelist_cleanup(const Link<void*, void>& rLink) { m_aStyleListCleanup = rLink; }
183
    void connect_stylelist_execute_drop(const Link<const ExecuteDropEvent&, sal_Int8>& rLink);
184
0
    void connect_stylelist_execute_new_menu(const Link<void*, void>& rLink) { m_aStyleListNewMenu = rLink; }
185
0
    void connect_stylelist_for_watercan(const Link<void*, bool>& rLink) { m_aStyleListWaterCan = rLink; }
186
    void connect_stylelist_has_selected_style(const Link<void*, bool>& rLink);
187
    void connect_stylelist_update_style_dependents(const Link<void*, void>& rLink);
188
    void connect_stylelist_enable_tree_drag(const Link<bool, void> rLink);
189
    void connect_stylelist_enable_delete(const Link<void*, void> rLink);
190
    void connect_stylelist_set_water_can_state(const Link<const SfxBoolItem*, void> rLink);
191
0
    void connect_set_family(const Link<sal_uInt16, void> rLink) { m_aStyleListSetFamily = rLink; }
192
};
193
194
class ToolbarDropTarget;
195
class DropTargetHelper;
196
197
class SfxTemplateDialog_Impl final : public SfxCommonTemplateDialog_Impl
198
{
199
private:
200
    friend class SfxTemplateControllerItem;
201
    friend class SfxTemplatePanelControl;
202
203
    std::unique_ptr<ToolbarDropTarget> m_xToolbarDropTargetHelper;
204
    std::unique_ptr<weld::Toolbar> m_xActionTbL;
205
    std::unique_ptr<weld::Toolbar> m_xActionTbR;
206
    std::unique_ptr<weld::Menu> m_xToolMenu;
207
    int m_nActionTbLVisible;
208
209
    void FillToolMenu();
210
211
    DECL_LINK(ToolBoxLSelect, const OUString&, void);
212
    DECL_LINK(ToolBoxRSelect, const OUString&, void);
213
    DECL_LINK(ToolMenuSelectHdl, const OUString&, void);
214
215
    virtual void EnableEdit( bool, StyleList* rStyleList) override;
216
    virtual void EnableItem(const OUString& rMesId, bool bCheck = true) override;
217
    virtual void CheckItem(const OUString& rMesId, bool bCheck = true) override;
218
    virtual bool IsCheckedItem(const OUString& rMesId) override;
219
    virtual void InsertFamilyItem(sal_uInt16 nId, const SfxStyleFamilyItem& rItem) override;
220
    virtual void EnableFamilyItem(sal_uInt16 nId, bool bEnabled) override;
221
    virtual void ClearFamilyList() override;
222
    virtual void ReplaceUpdateButtonByMenu() override;
223
224
public:
225
    friend class SfxTemplateDialog;
226
227
    SfxTemplateDialog_Impl( SfxBindings*, SfxTemplatePanelControl* pDlgWindow );
228
    virtual ~SfxTemplateDialog_Impl() override;
229
230
    sal_Int8 AcceptToolbarDrop(const AcceptDropEvent& rEvt, const DropTargetHelper& rHelper);
231
232
    void Initialize();
233
};
234
235
#endif // INCLUDED_SFX2_SOURCE_INC_TEMPLDGI_HXX
236
237
238
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */