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/idle.hxx>
19 #include <vcl/timer.hxx>
20 #include <vcl/weld.hxx>
22 #include <sfx2/templatelocalview.hxx>
24 class TemplateSearchView
;
25 class ThumbnailViewItem
;
28 namespace sun
{ namespace star
{ namespace frame
{
34 class SFX2_DLLPUBLIC SfxTemplateManagerDlg
: public weld::GenericDialogController
36 typedef bool (*selection_cmp_fn
)(const ThumbnailViewItem
*,const ThumbnailViewItem
*);
40 SfxTemplateManagerDlg(weld::Window
*parent
);
42 virtual ~SfxTemplateManagerDlg() override
;
43 virtual short run() override
;
45 void setDocumentModel (const css::uno::Reference
<css::frame::XModel
> &rModel
);
49 void getApplicationSpecificSettings();
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);
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 ();
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;
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
> mxLinkButton
;
134 std::unique_ptr
<weld::CheckButton
> mxCBXHideDlg
;
135 std::unique_ptr
<weld::MenuButton
> mxActionBar
;
136 std::unique_ptr
<TemplateSearchView
> mxSearchView
;
137 std::unique_ptr
<SfxTemplateLocalView
> 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
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
;
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 {
166 return msSelectedCategory
;
169 void SetSelectLabelText(OUString
const & sText
) const {
170 mxSelectLabel
->set_label(sText
);
173 bool IsNewCategoryCreated() const {
174 return mbIsNewCategory
;
179 explicit SfxTemplateCategoryDialog(weld::Window
* pParent
);
181 virtual ~SfxTemplateCategoryDialog() override
;
185 // class SfxTemplateSelectionDialog -------------------------------------------------------------------
187 class SFX2_DLLPUBLIC SfxTemplateSelectionDlg final
: public SfxTemplateManagerDlg
190 SfxTemplateSelectionDlg(weld::Window
*parent
);
192 virtual ~SfxTemplateSelectionDlg() override
;
193 virtual short run() override
;
195 OUString
const & getTemplatePath() const { return msTemplatePath
; };
196 bool IsStartWithTemplate() const { return mxCBXHideDlg
->get_active(); };
199 DECL_LINK(OpenTemplateHdl
, ThumbnailViewItem
*, void);
200 DECL_LINK(OkClickHdl
, weld::Button
&, void);
201 DECL_LINK(TimeOut
, Timer
*, void);
203 OUString msTemplatePath
;
207 #endif // INCLUDED_SFX2_INC_TEMPLATEDLG_HXX
209 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */