Bump version to 21.06.18.1
[LibreOffice.git] / include / sfx2 / templatedlg.hxx
blob76d7d98eced5228d55e289061947042128aedc01
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>
18 #include <vcl/idle.hxx>
19 #include <vcl/timer.hxx>
20 #include <vcl/weld.hxx>
22 #include <sfx2/templatelocalview.hxx>
24 class TemplateSearchView;
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);
48 protected:
49 void getApplicationSpecificSettings();
51 void readSettings();
53 void writeSettings();
55 void fillFolderComboBox();
57 DECL_LINK(SelectApplicationHdl, weld::ComboBox&, void);
58 DECL_LINK(SelectRegionHdl, weld::ComboBox&, void);
60 DECL_LINK(OkClickHdl, weld::Button&, void);
61 DECL_LINK(MoveClickHdl, weld::Button&, void);
62 DECL_LINK(ExportClickHdl, weld::Button&, void);
63 DECL_LINK(ImportClickHdl, weld::Button&, void);
64 DECL_STATIC_LINK(SfxTemplateManagerDlg, LinkClickHdl, weld::Button&, void);
66 DECL_LINK(TVItemStateHdl, const ThumbnailViewItem*, void);
68 DECL_LINK(MenuSelectHdl, const OString&, void);
69 void DefaultTemplateMenuSelectHdl(const OString& rIdent);
71 DECL_LINK(OpenRegionHdl, void*, void);
72 DECL_LINK(CreateContextMenuHdl, ThumbnailViewItem*, void);
73 DECL_LINK(OpenTemplateHdl, ThumbnailViewItem*, void);
74 DECL_LINK(EditTemplateHdl, ThumbnailViewItem*, void);
75 DECL_LINK(DeleteTemplateHdl, ThumbnailViewItem*, void);
76 DECL_LINK(DefaultTemplateHdl, ThumbnailViewItem*, void);
78 void SearchUpdate();
80 DECL_LINK(SearchUpdateHdl, weld::Entry&, void);
81 DECL_LINK(GetFocusHdl, weld::Widget&, void);
82 DECL_LINK(LoseFocusHdl, weld::Widget&, void);
83 DECL_LINK(ImplUpdateDataHdl, Timer*, void);
84 DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
86 void OnTemplateImportCategory(const OUString& sCategory);
87 // static void OnTemplateLink ();
88 void OnTemplateOpen();
89 void OnTemplateExport();
91 void OnTemplateState(const ThumbnailViewItem* pItem);
93 void OnCategoryNew();
94 void OnCategoryRename();
95 void OnCategoryDelete();
97 void createDefaultTemplateMenu();
99 /**
101 * Move templates stored in the filesystem to another folder.
105 void localMoveTo(sal_uInt16 nMenuId);
109 * Move search result templates stored in the filesystem to another folder.
113 void localSearchMoveTo(sal_uInt16 nMenuId);
115 /// Return filter according to the currently selected application filter.
116 FILTER_APPLICATION getCurrentApplicationFilter() const;
118 protected:
119 std::set<const ThumbnailViewItem*, selection_cmp_fn> maSelTemplates;
120 css::uno::Reference<css::frame::XModel> m_xModel;
121 css::uno::Reference<css::frame::XDesktop2> mxDesktop;
123 Timer m_aUpdateDataTimer;
125 std::unique_ptr<weld::Entry> mxSearchFilter;
126 std::unique_ptr<weld::ComboBox> mxCBApp;
127 std::unique_ptr<weld::ComboBox> mxCBFolder;
129 std::unique_ptr<weld::Button> mxOKButton;
130 std::unique_ptr<weld::Button> mxMoveButton;
131 std::unique_ptr<weld::Button> mxExportButton;
132 std::unique_ptr<weld::Button> mxImportButton;
133 std::unique_ptr<weld::Button> mxMoreTemplatesButton;
134 std::unique_ptr<weld::CheckButton> mxCBXHideDlg;
135 std::unique_ptr<weld::MenuButton> mxActionBar;
136 std::unique_ptr<TemplateSearchView> mxSearchView;
137 std::unique_ptr<TemplateLocalView> mxLocalView;
138 std::unique_ptr<weld::Menu> mxTemplateDefaultMenu;
139 std::unique_ptr<weld::CustomWeld> mxSearchViewWeld;
140 std::unique_ptr<weld::CustomWeld> mxLocalViewWeld;
143 // class SfxTemplateCategoryDialog -------------------------------------------------------------------
145 class SfxTemplateCategoryDialog final : public weld::GenericDialogController
147 private:
148 OUString msSelectedCategory;
149 bool mbIsNewCategory;
151 std::unique_ptr<weld::TreeView> mxLBCategory;
152 std::unique_ptr<weld::Label> mxSelectLabel;
153 std::unique_ptr<weld::Entry> mxNewCategoryEdit;
154 std::unique_ptr<weld::Label> mxCreateLabel;
155 std::unique_ptr<weld::Button> mxOKButton;
157 public:
158 DECL_LINK(NewCategoryEditHdl, weld::Entry&, void);
159 DECL_LINK(SelectCategoryHdl, weld::TreeView&, void);
161 void SetCategoryLBEntries(std::vector<OUString> names);
163 void HideNewCategoryOption();
165 const OUString& GetSelectedCategory() const { return msSelectedCategory; };
167 void SetSelectLabelText(OUString const& sText) const { mxSelectLabel->set_label(sText); };
169 bool IsNewCategoryCreated() const { return mbIsNewCategory; }
171 public:
172 explicit SfxTemplateCategoryDialog(weld::Window* pParent);
174 virtual ~SfxTemplateCategoryDialog() override;
177 // class SfxTemplateSelectionDialog -------------------------------------------------------------------
179 class SFX2_DLLPUBLIC SfxTemplateSelectionDlg final : public SfxTemplateManagerDlg
181 public:
182 SfxTemplateSelectionDlg(weld::Window* parent);
184 virtual ~SfxTemplateSelectionDlg() override;
185 virtual short run() override;
187 OUString const& getTemplatePath() const { return msTemplatePath; };
188 bool IsStartWithTemplate() const { return mxCBXHideDlg->get_active(); };
190 private:
191 DECL_LINK(OpenTemplateHdl, ThumbnailViewItem*, void);
192 DECL_LINK(OkClickHdl, weld::Button&, void);
193 DECL_LINK(TimeOut, Timer*, void);
195 OUString msTemplatePath;
196 Idle maIdle;
199 #endif // INCLUDED_SFX2_INC_TEMPLATEDLG_HXX
201 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */