tdf#144672 fix Index entries in Naviator are always grayed out
[LibreOffice.git] / include / sfx2 / templatedlg.hxx
blob10d3107fc3e1e4096e8cd90131502c4d0ef5bff3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
10 #ifndef INCLUDED_SFX2_INC_TEMPLATEDLG_HXX
11 #define INCLUDED_SFX2_INC_TEMPLATEDLG_HXX
13 #include <sal/config.h>
14 #include <sfx2/dllapi.h>
16 #include <set>
17 #include <string_view>
19 #include <vcl/idle.hxx>
20 #include <vcl/timer.hxx>
21 #include <vcl/weld.hxx>
23 #include <sfx2/templatedlglocalview.hxx>
25 class ThumbnailViewItem;
27 namespace com
29 namespace sun::star::frame
31 class XDesktop2;
32 class XModel;
36 class SFX2_DLLPUBLIC SfxTemplateManagerDlg : public weld::GenericDialogController
38 typedef bool (*selection_cmp_fn)(const ThumbnailViewItem*, const ThumbnailViewItem*);
40 public:
41 SfxTemplateManagerDlg(weld::Window* parent);
43 virtual ~SfxTemplateManagerDlg() override;
44 virtual short run() override;
46 void setDocumentModel(const css::uno::Reference<css::frame::XModel>& rModel);
47 void setTemplateViewMode(TemplateViewMode eViewMode);
48 TemplateViewMode getTemplateViewMode() const;
50 protected:
51 void getApplicationSpecificSettings();
53 void readSettings();
55 void writeSettings();
57 void fillFolderComboBox();
59 DECL_DLLPRIVATE_LINK(SelectApplicationHdl, weld::ComboBox&, void);
60 DECL_DLLPRIVATE_LINK(SelectRegionHdl, weld::ComboBox&, void);
62 DECL_DLLPRIVATE_LINK(OkClickHdl, weld::Button&, void);
63 void ImportActionHdl();
64 static void ExtensionsActionHdl();
66 DECL_DLLPRIVATE_LINK(TVItemStateHdl, const ThumbnailViewItem*, void);
68 DECL_DLLPRIVATE_LINK(MenuSelectHdl, const OString&, void);
69 void DefaultTemplateMenuSelectHdl(std::string_view rIdent);
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);
80 void SearchUpdate();
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);
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);
92 void OnTemplateImportCategory(std::u16string_view sCategory);
93 // static void OnTemplateLink ();
94 void OnTemplateOpen();
95 void OnTemplateExport();
97 void OnTemplateState(const ThumbnailViewItem* pItem);
99 void OnCategoryNew();
100 void OnCategoryRename();
101 void OnCategoryDelete();
103 void updateMenuItems();
107 * Move templates stored in the filesystem to another folder.
111 void localMoveTo(sal_uInt16 nMenuId);
113 /// Return filter according to the currently selected application filter.
114 FILTER_APPLICATION getCurrentApplicationFilter() const;
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;
121 Timer m_aUpdateDataTimer;
123 std::unique_ptr<weld::Entry> mxSearchFilter;
124 std::unique_ptr<weld::ComboBox> mxCBApp;
125 std::unique_ptr<weld::ComboBox> mxCBFolder;
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::Menu> mxTemplateDefaultMenu;
132 std::unique_ptr<weld::CustomWeld> mxLocalViewWeld;
133 std::unique_ptr<weld::Toggleable> mxListViewButton;
134 std::unique_ptr<weld::Toggleable> mxThumbnailViewButton;
135 TemplateViewMode mViewMode;
136 bool bMakeSelItemVisible;
139 // class SfxTemplateCategoryDialog -------------------------------------------------------------------
141 class SfxTemplateCategoryDialog final : public weld::GenericDialogController
143 private:
144 OUString msSelectedCategory;
145 bool mbIsNewCategory;
147 std::unique_ptr<weld::TreeView> mxLBCategory;
148 std::unique_ptr<weld::Label> mxSelectLabel;
149 std::unique_ptr<weld::Entry> mxNewCategoryEdit;
150 std::unique_ptr<weld::Label> mxCreateLabel;
151 std::unique_ptr<weld::Button> mxOKButton;
153 public:
154 DECL_LINK(NewCategoryEditHdl, weld::Entry&, void);
155 DECL_LINK(SelectCategoryHdl, weld::TreeView&, void);
157 void SetCategoryLBEntries(std::vector<OUString> names);
159 const OUString& GetSelectedCategory() const { return msSelectedCategory; };
161 bool IsNewCategoryCreated() const { return mbIsNewCategory; }
163 public:
164 explicit SfxTemplateCategoryDialog(weld::Window* pParent);
166 virtual ~SfxTemplateCategoryDialog() override;
169 // class SfxTemplateSelectionDialog -------------------------------------------------------------------
171 class SFX2_DLLPUBLIC SfxTemplateSelectionDlg final : public SfxTemplateManagerDlg
173 public:
174 SfxTemplateSelectionDlg(weld::Window* parent);
176 virtual ~SfxTemplateSelectionDlg() override;
177 virtual short run() override;
179 OUString const& getTemplatePath() const { return msTemplatePath; };
180 bool IsStartWithTemplate() const { return mxCBXHideDlg->get_active(); };
182 private:
183 DECL_DLLPRIVATE_LINK(OpenTemplateHdl, ThumbnailViewItem*, void);
184 DECL_DLLPRIVATE_LINK(OkClickHdl, weld::Button&, void);
185 DECL_DLLPRIVATE_LINK(TimeOut, Timer*, void);
187 OUString msTemplatePath;
188 Idle maIdle;
191 #endif // INCLUDED_SFX2_INC_TEMPLATEDLG_HXX
193 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */