1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
10 #ifndef INCLUDED_SFX2_INC_TEMPLATEDLG_HXX
11 #define INCLUDED_SFX2_INC_TEMPLATEDLG_HXX
13 #include <sal/config.h>
14 #include <sfx2/dllapi.h>
18 #include <vcl/dialog.hxx>
19 #include <vcl/button.hxx>
20 #include <com/sun/star/frame/XDesktop2.hpp>
22 #include <sfx2/templateabstractview.hxx>
26 class TemplateAbstractView
;
27 class TemplateLocalView
;
28 class TemplateRemoteView
;
29 class TemplateRepository
;
30 class TemplateSearchView
;
32 class ThumbnailViewItem
;
36 namespace sun
{ namespace star
{ namespace frame
{
37 class XComponentLoader
;
42 class SFX2_DLLPUBLIC SfxTemplateManagerDlg
: public ModalDialog
44 typedef bool (*selection_cmp_fn
)(const ThumbnailViewItem
*,const ThumbnailViewItem
*);
48 SfxTemplateManagerDlg(vcl::Window
*parent
= nullptr);
50 virtual ~SfxTemplateManagerDlg();
51 virtual void dispose() override
;
52 virtual short Execute() override
;
54 void setDocumentModel (const css::uno::Reference
<css::frame::XModel
> &rModel
);
58 void getApplicationSpecificSettings();
62 void writeSettings ();
64 void fillFolderComboBox();
66 DECL_LINK_TYPED(TBXDropdownHdl
, ToolBox
*, void);
68 DECL_LINK_TYPED(SelectApplicationHdl
, ListBox
&, void);
69 DECL_LINK_TYPED(SelectRegionHdl
, ListBox
&, void);
71 DECL_LINK_TYPED(OkClickHdl
, Button
*, void);
72 DECL_LINK_TYPED(MoveClickHdl
, Button
*, void);
73 DECL_LINK_TYPED(ExportClickHdl
, Button
*, void);
74 DECL_LINK_TYPED(ImportClickHdl
, Button
*, void);
75 DECL_STATIC_LINK_TYPED(SfxTemplateManagerDlg
, LinkClickHdl
, Button
*, void);
77 DECL_LINK_TYPED(TVItemStateHdl
, const ThumbnailViewItem
*, void);
79 DECL_LINK_TYPED(MenuSelectHdl
, Menu
*, bool);
80 DECL_LINK_TYPED(RepositoryMenuSelectHdl
, Menu
*, bool);
81 DECL_LINK_TYPED(DefaultTemplateMenuSelectHdl
, Menu
*, bool);
83 DECL_LINK_TYPED(OpenRegionHdl
, void*, void);
84 DECL_LINK_TYPED(CreateContextMenuHdl
, ThumbnailViewItem
*, void);
85 DECL_LINK_TYPED(OpenTemplateHdl
, ThumbnailViewItem
*, void);
86 DECL_LINK_TYPED(EditTemplateHdl
, ThumbnailViewItem
*, void);
87 DECL_LINK_TYPED(DeleteTemplateHdl
, ThumbnailViewItem
*, void);
88 DECL_LINK_TYPED(DefaultTemplateHdl
, ThumbnailViewItem
*, void);
90 DECL_LINK_TYPED(SearchUpdateHdl
, Edit
&, void);
91 DECL_LINK_TYPED(GetFocusHdl
, Control
&, void);
93 void OnTemplateImportCategory(const OUString
& sCategory
);
94 static void OnTemplateLink ();
95 void OnTemplateOpen ();
96 void OnTemplateExport ();
98 void OnTemplateState (const ThumbnailViewItem
*pItem
);
100 void OnCategoryNew ();
101 void OnCategoryRename();
102 void OnCategoryDelete();
104 void OnRegionState (const ThumbnailViewItem
*pItem
);
106 void OnRepositoryDelete ();
108 void createRepositoryMenu ();
110 void createDefaultTemplateMenu ();
112 // Exchange view between local/online view.
113 void switchMainView (bool bDisplayLocal
);
117 * Move templates stored in the filesystem to another folder.
121 void localMoveTo (sal_uInt16 nMenuId
);
123 void remoteMoveTo (const sal_uInt16 nMenuId
);
127 * Move search result templates stored in the filesystem to another folder.
131 void localSearchMoveTo (sal_uInt16 nMenuId
);
133 // Remote repositories handling methods
134 void loadRepositories ();
136 const std::vector
<TemplateRepository
*>& getRepositories () const { return maRepositories
; }
138 bool insertRepository (const OUString
&rName
, const OUString
&rURL
);
140 bool deleteRepository (const sal_uInt16 nRepositoryId
);
142 void syncRepositories () const;
144 /// Return filter according to the currently selected application filter.
145 FILTER_APPLICATION
getCurrentApplicationFilter();
149 VclPtr
<Edit
> mpSearchFilter
;
150 VclPtr
<ListBox
> mpCBApp
;
151 VclPtr
<ListBox
> mpCBFolder
;
153 VclPtr
<PushButton
> mpOKButton
;
154 VclPtr
<PushButton
> mpMoveButton
;
155 VclPtr
<PushButton
> mpExportButton
;
156 VclPtr
<PushButton
> mpImportButton
;
157 VclPtr
<PushButton
> mpLinkButton
;
158 VclPtr
<ToolBox
> mpActionBar
;
159 VclPtr
<TemplateSearchView
> mpSearchView
;
160 VclPtr
<TemplateAbstractView
> mpCurView
;
161 VclPtr
<TemplateLocalView
> mpLocalView
;
162 VclPtr
<TemplateRemoteView
> mpRemoteView
;
163 PopupMenu
*mpActionMenu
;
164 PopupMenu
*mpRepositoryMenu
;
165 PopupMenu
*mpTemplateDefaultMenu
;
167 std::set
<const ThumbnailViewItem
*,selection_cmp_fn
> maSelTemplates
;
169 css::uno::Reference
< css::frame::XModel
> m_xModel
;
170 css::uno::Reference
< css::frame::XDesktop2
> mxDesktop
;
172 bool mbIsSynced
; ///< Tells whether maRepositories is synchronized with the user config
173 std::vector
<TemplateRepository
*> maRepositories
; ///< Stores the remote repositories for templates
176 // class SfxTemplateCategoryDialog -------------------------------------------------------------------
178 class SFX2_DLLPUBLIC SfxTemplateCategoryDialog
: public ModalDialog
181 VclPtr
<ListBox
> mpLBCategory
;
182 VclPtr
<FixedText
> mpSelectLabel
;
183 VclPtr
<Edit
> mpNewCategoryEdit
;
184 VclPtr
<FixedText
> mpCreateLabel
;
185 VclPtr
<PushButton
> mpOKButton
;
187 OUString msSelectedCategory
;
188 bool mbIsNewCategory
;
191 DECL_LINK_TYPED(NewCategoryEditHdl
, Edit
&, void);
192 DECL_LINK_TYPED(SelectCategoryHdl
, ListBox
&, void);
194 void SetCategoryLBEntries(std::vector
<OUString
> names
);
196 void HideNewCategoryOption();
198 inline const OUString
& GetSelectedCategory() const {
199 return msSelectedCategory
;
202 inline void SetSelectLabelText(OUString sText
) const {
203 mpSelectLabel
->SetText(sText
);
206 inline bool IsNewCategoryCreated() const {
207 return mbIsNewCategory
;
212 explicit SfxTemplateCategoryDialog(vcl::Window
*parent
= nullptr);
214 virtual ~SfxTemplateCategoryDialog();
215 virtual void dispose() override
;
218 #endif // INCLUDED_SFX2_INC_TEMPLATEDLG_HXX
220 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */