Version 7.6.3.2-android, tag libreoffice-7.6.3.2-android
[LibreOffice.git] / include / sfx2 / templatedlg.hxx
blob5aea4ec82a6f9ac35f3a029a65c2e5e5664ae8c2
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 OUString&, void);
69 void DefaultTemplateMenuSelectHdl(std::u16string_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::CustomWeld> mxLocalViewWeld;
132 std::unique_ptr<weld::Toggleable> mxListViewButton;
133 std::unique_ptr<weld::Toggleable> mxThumbnailViewButton;
134 TemplateViewMode mViewMode;
135 bool bMakeSelItemVisible;
138 // class SfxTemplateCategoryDialog -------------------------------------------------------------------
140 class SfxTemplateCategoryDialog final : public weld::GenericDialogController
142 private:
143 OUString msSelectedCategory;
144 bool mbIsNewCategory;
146 std::unique_ptr<weld::TreeView> mxLBCategory;
147 std::unique_ptr<weld::Entry> mxNewCategoryEdit;
148 std::unique_ptr<weld::Button> mxOKButton;
150 public:
151 DECL_LINK(NewCategoryEditHdl, weld::Entry&, void);
152 DECL_LINK(SelectCategoryHdl, weld::TreeView&, void);
154 void SetCategoryLBEntries(std::vector<OUString> names);
156 const OUString& GetSelectedCategory() const { return msSelectedCategory; };
158 bool IsNewCategoryCreated() const { return mbIsNewCategory; }
160 public:
161 explicit SfxTemplateCategoryDialog(weld::Window* pParent);
163 virtual ~SfxTemplateCategoryDialog() override;
166 // class SfxTemplateSelectionDialog -------------------------------------------------------------------
168 class SFX2_DLLPUBLIC SfxTemplateSelectionDlg final : public SfxTemplateManagerDlg
170 public:
171 SfxTemplateSelectionDlg(weld::Window* parent);
173 virtual ~SfxTemplateSelectionDlg() override;
174 virtual short run() override;
176 OUString const& getTemplatePath() const { return msTemplatePath; };
177 bool IsStartWithTemplate() const { return mxCBXHideDlg->get_active(); };
179 private:
180 DECL_DLLPRIVATE_LINK(OpenTemplateHdl, ThumbnailViewItem*, void);
181 DECL_DLLPRIVATE_LINK(OkClickHdl, weld::Button&, void);
182 DECL_DLLPRIVATE_LINK(TimeOut, Timer*, void);
184 OUString msTemplatePath;
185 Idle maIdle;
188 #endif // INCLUDED_SFX2_INC_TEMPLATEDLG_HXX
190 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */