Coverage Report

Created: 2025-12-08 09:28

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/sfx2/templatedlg.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
10
#ifndef INCLUDED_SFX2_INC_TEMPLATEDLG_HXX
11
#define INCLUDED_SFX2_INC_TEMPLATEDLG_HXX
12
13
#include <sal/config.h>
14
#include <sfx2/dllapi.h>
15
16
#include <set>
17
#include <string_view>
18
19
#include <vcl/idle.hxx>
20
#include <vcl/timer.hxx>
21
#include <vcl/weld.hxx>
22
23
#include <sfx2/templatedlglocalview.hxx>
24
25
class ThumbnailViewItem;
26
27
namespace com
28
{
29
namespace sun::star::frame
30
{
31
class XDesktop2;
32
class XModel;
33
}
34
}
35
36
class SFX2_DLLPUBLIC SfxTemplateManagerDlg : public weld::GenericDialogController
37
{
38
    typedef bool (*selection_cmp_fn)(const ThumbnailViewItem*, const ThumbnailViewItem*);
39
40
public:
41
    SfxTemplateManagerDlg(weld::Window* parent);
42
43
    virtual ~SfxTemplateManagerDlg() override;
44
    virtual short run() override;
45
46
    SAL_DLLPRIVATE void setDocumentModel(const css::uno::Reference<css::frame::XModel>& rModel);
47
    SAL_DLLPRIVATE void setTemplateViewMode(TemplateViewMode eViewMode);
48
    SAL_DLLPRIVATE TemplateViewMode getTemplateViewMode() const;
49
50
protected:
51
    SAL_DLLPRIVATE void getApplicationSpecificSettings();
52
53
    SAL_DLLPRIVATE void readSettings();
54
55
    SAL_DLLPRIVATE void writeSettings();
56
57
    SAL_DLLPRIVATE void fillFolderComboBox();
58
59
    DECL_DLLPRIVATE_LINK(SelectApplicationHdl, weld::ComboBox&, void);
60
    DECL_DLLPRIVATE_LINK(SelectRegionHdl, weld::ComboBox&, void);
61
62
    DECL_DLLPRIVATE_LINK(OkClickHdl, weld::Button&, void);
63
    SAL_DLLPRIVATE void ImportActionHdl();
64
    SAL_DLLPRIVATE void ExtensionsActionHdl();
65
66
    DECL_DLLPRIVATE_LINK(TVItemStateHdl, const ThumbnailViewItem*, void);
67
68
    DECL_DLLPRIVATE_LINK(MenuSelectHdl, const OUString&, void);
69
    SAL_DLLPRIVATE void DefaultTemplateMenuSelectHdl(std::u16string_view rIdent);
70
71
    DECL_DLLPRIVATE_LINK(OpenRegionHdl, void*, void);
72
    DECL_DLLPRIVATE_LINK(CreateContextMenuHdl, ThumbnailViewItem*, void);
73
    DECL_DLLPRIVATE_LINK(OpenTemplateHdl, ThumbnailViewItem*, void);
74
    DECL_DLLPRIVATE_LINK(EditTemplateHdl, ThumbnailViewItem*, void);
75
    DECL_DLLPRIVATE_LINK(DeleteTemplateHdl, void*, void);
76
    DECL_DLLPRIVATE_LINK(DefaultTemplateHdl, ThumbnailViewItem*, void);
77
    DECL_DLLPRIVATE_LINK(MoveTemplateHdl, void*, void);
78
    DECL_DLLPRIVATE_LINK(ExportTemplateHdl, void*, void);
79
80
    SAL_DLLPRIVATE void SearchUpdate();
81
82
    DECL_DLLPRIVATE_LINK(SearchUpdateHdl, weld::Entry&, void);
83
    DECL_DLLPRIVATE_LINK(GetFocusHdl, weld::Widget&, void);
84
    DECL_DLLPRIVATE_LINK(LoseFocusHdl, weld::Widget&, void);
85
    DECL_DLLPRIVATE_LINK(ImplUpdateDataHdl, Timer*, void);
86
    DECL_DLLPRIVATE_LINK(KeyInputHdl, const KeyEvent&, bool);
87
88
    DECL_DLLPRIVATE_LINK(ListViewHdl, weld::Toggleable&, void);
89
    DECL_DLLPRIVATE_LINK(ThumbnailViewHdl, weld::Toggleable&, void);
90
    DECL_DLLPRIVATE_LINK(FocusRectLocalHdl, weld::Widget&, tools::Rectangle);
91
92
    SAL_DLLPRIVATE void OnTemplateImportCategory(std::u16string_view sCategory);
93
    //    static void OnTemplateLink ();
94
    SAL_DLLPRIVATE void OnTemplateOpen();
95
    SAL_DLLPRIVATE void OnTemplateExport();
96
97
    SAL_DLLPRIVATE void OnTemplateState(const ThumbnailViewItem* pItem);
98
99
    SAL_DLLPRIVATE void OnCategoryNew();
100
    SAL_DLLPRIVATE void OnCategoryRename();
101
    SAL_DLLPRIVATE void OnCategoryDelete();
102
103
    SAL_DLLPRIVATE void updateMenuItems();
104
105
    /**
106
     *
107
     * Move templates stored in the filesystem to another folder.
108
     *
109
     **/
110
111
    SAL_DLLPRIVATE void localMoveTo(sal_uInt16 nMenuId);
112
113
    /// Return filter according to the currently selected application filter.
114
    SAL_DLLPRIVATE FILTER_APPLICATION getCurrentApplicationFilter() const;
115
116
protected:
117
    std::set<const ThumbnailViewItem*, selection_cmp_fn> maSelTemplates;
118
    css::uno::Reference<css::frame::XModel> m_xModel;
119
    css::uno::Reference<css::frame::XDesktop2> mxDesktop;
120
121
    Timer m_aUpdateDataTimer;
122
123
    std::unique_ptr<weld::Entry> mxSearchFilter;
124
    std::unique_ptr<weld::ComboBox> mxCBApp;
125
    std::unique_ptr<weld::ComboBox> mxCBFolder;
126
127
    std::unique_ptr<weld::Button> mxOKButton;
128
    std::unique_ptr<weld::CheckButton> mxCBXHideDlg;
129
    std::unique_ptr<weld::MenuButton> mxActionBar;
130
    std::unique_ptr<TemplateDlgLocalView> mxLocalView;
131
    std::unique_ptr<weld::CustomWeld> mxLocalViewWeld;
132
    std::unique_ptr<weld::Toggleable> mxListViewButton;
133
    std::unique_ptr<weld::Toggleable> mxThumbnailViewButton;
134
    TemplateViewMode mViewMode;
135
    bool bMakeSelItemVisible;
136
};
137
138
//  class SfxTemplateCategoryDialog -------------------------------------------------------------------
139
140
class SfxTemplateCategoryDialog final : public weld::GenericDialogController
141
{
142
private:
143
    OUString msSelectedCategory;
144
    bool mbIsNewCategory;
145
146
    std::unique_ptr<weld::TreeView> mxLBCategory;
147
    std::unique_ptr<weld::Entry> mxNewCategoryEdit;
148
    std::unique_ptr<weld::Button> mxOKButton;
149
150
public:
151
    DECL_LINK(NewCategoryEditHdl, weld::Entry&, void);
152
    DECL_LINK(SelectCategoryHdl, weld::TreeView&, void);
153
154
    void SetCategoryLBEntries(std::vector<OUString> names);
155
156
0
    const OUString& GetSelectedCategory() const { return msSelectedCategory; };
157
158
0
    bool IsNewCategoryCreated() const { return mbIsNewCategory; }
159
160
public:
161
    explicit SfxTemplateCategoryDialog(weld::Window* pParent);
162
163
    virtual ~SfxTemplateCategoryDialog() override;
164
};
165
166
//  class SfxTemplateSelectionDialog -------------------------------------------------------------------
167
168
class SFX2_DLLPUBLIC SfxTemplateSelectionDlg final : public SfxTemplateManagerDlg
169
{
170
public:
171
    SfxTemplateSelectionDlg(weld::Window* parent);
172
173
    virtual ~SfxTemplateSelectionDlg() override;
174
    virtual short run() override;
175
176
0
    OUString const& getTemplatePath() const { return msTemplatePath; };
177
0
    bool IsStartWithTemplate() const { return mxCBXHideDlg->get_active(); };
178
179
private:
180
    DECL_DLLPRIVATE_LINK(OpenTemplateHdl, ThumbnailViewItem*, void);
181
    DECL_DLLPRIVATE_LINK(OkClickHdl, weld::Button&, void);
182
    DECL_DLLPRIVATE_LINK(TimeOut, Timer*, void);
183
184
    OUString msTemplatePath;
185
    Idle maIdle;
186
};
187
188
#endif // INCLUDED_SFX2_INC_TEMPLATEDLG_HXX
189
190
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */