sd: keep a non-owning pointer to the OverridingShell
[LibreOffice.git] / sfx2 / source / inc / templdgi.hxx
blob59c21f659bd6650bce979297680f17263a7fbb05
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/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
19 #ifndef INCLUDED_SFX2_SOURCE_INC_TEMPLDGI_HXX
20 #define INCLUDED_SFX2_SOURCE_INC_TEMPLDGI_HXX
22 #include <sal/config.h>
24 #include <memory>
26 #include <vcl/transfer.hxx>
27 #include <vcl/weld.hxx>
28 #include <svl/eitem.hxx>
30 #include <svl/style.hxx>
32 #include <sfx2/objsh.hxx>
33 #include <sfx2/styfitem.hxx>
34 #include <sfx2/templdlg.hxx>
36 #include "StyleList.hxx"
38 class SfxTemplateControllerItem;
39 class SfxStyleFamilyItem;
40 class SfxTemplateItem;
41 class SfxBindings;
42 class SfxStyleSheetBase;
43 class SfxStyleSheetBasePool;
44 class StyleTreeListBox_Impl;
45 class SfxTemplateDialog_Impl;
46 class SfxCommonTemplateDialog_Impl;
47 namespace com::sun::star::frame {
48 class XModuleManager2;
51 class SfxCommonTemplateDialog_Impl
53 private:
54 class DeletionWatcher;
55 friend class DeletionWatcher;
57 DeletionWatcher* impl_setDeletionWatcher(DeletionWatcher* pNewWatcher);
59 protected:
60 #define MAX_FAMILIES 6
61 #define COUNT_BOUND_FUNC 14
63 friend class SfxTemplateControllerItem;
65 SfxBindings* pBindings;
67 css::uno::Reference<css::frame::XModuleManager2> xModuleManager;
68 DeletionWatcher* m_pDeletionWatcher;
70 StyleList m_aStyleList;
71 std::unique_ptr<weld::CheckButton> mxPreviewCheckbox;
72 std::unique_ptr<weld::CheckButton> mxHighlightCheckbox;
73 std::unique_ptr<weld::ComboBox> mxFilterLb;
75 sal_uInt16 nActFamily; // Id in the ToolBox = Position - 1
76 sal_uInt16 nActFilter; // FilterIdx
78 bool bIsWater :1;
79 bool bUpdate :1;
80 bool bWaterDisabled :1;
81 bool bNewByExampleDisabled :1;
82 bool bUpdateByExampleDisabled :1;
83 bool m_bWantHierarchical :1;
85 Link<void*, size_t> m_aStyleListReadResource;
86 Link<void*, void> m_aStyleListClear;
87 Link<void*, void> m_aStyleListCleanup;
88 Link<const ExecuteDropEvent&, sal_Int8> m_aStyleListExecuteDrop;
89 Link<void*, void> m_aStyleListNewMenu;
90 Link<void*, bool> m_aStyleListWaterCan;
91 Link<void*, bool> m_aStyleListHasSelectedStyle;
92 Link<void*, void> m_aStyleListUpdateFamily;
93 Link<void*, void> m_aStyleListUpdateStyleDependents;
94 Link<bool, void> m_aStyleListEnableTreeDrag;
95 Link<void*, void> m_aStyleListEnableDelete;
96 Link<const SfxBoolItem*, void> m_aStyleListSetWaterCanState;
97 Link<sal_uInt16, void> m_aStyleListSetFamily;
99 DECL_LINK(FilterSelectHdl, weld::ComboBox&, void );
100 DECL_LINK(PreviewHdl, weld::Toggleable&, void);
101 DECL_LINK(HighlightHdl, weld::Toggleable&, void);
103 virtual void InsertFamilyItem(sal_uInt16 nId, const SfxStyleFamilyItem& rItem) = 0;
104 virtual void EnableFamilyItem(sal_uInt16 nId, bool bEnabled) = 0;
105 virtual void ClearFamilyList() = 0;
106 virtual void ReplaceUpdateButtonByMenu();
108 void Initialize();
109 void EnableHierarchical(bool, StyleList& rStyleList);
111 void FilterSelect( sal_uInt16 nFilterIdx );
112 void SetFamilyState( sal_uInt16 nSlotId, const SfxTemplateItem* );
113 void SetWaterCanState( const SfxBoolItem* pItem );
114 bool IsSafeForWaterCan() const;
116 void SetFamily(SfxStyleFamily nFamily);
117 void ActionSelect(const OUString& rId, StyleList& rStyleList);
119 void SaveFactoryStyleFilter(SfxObjectShell const* i_pObjSh, sal_Int32 i_nFilter);
121 DECL_LINK(ReadResource_Hdl, StyleList&, void);
122 DECL_LINK(ClearResource_Hdl, void*, void);
123 DECL_LINK(SaveSelection_Hdl, StyleList&, SfxObjectShell*);
124 DECL_LINK(LoadFactoryStyleFilter_Hdl, SfxObjectShell const*, sal_Int32);
125 DECL_LINK(UpdateStyles_Hdl, StyleFlags, void);
126 DECL_LINK(UpdateFamily_Hdl, StyleList&, void);
127 DECL_LINK(UpdateStyleDependents_Hdl, void*, void);
129 public:
130 // Used in StyleList::NewMenuExecuteAction, StyleList::UpdateStyleDependents, StyleList::NewHdl, EditHdl...
131 // It comes into action whenever an existing style is selected for use, or a new style is created etc..
132 bool Execute_Impl(sal_uInt16 nId, const OUString& rStr, const OUString& rRefStr,
133 sal_uInt16 nFamily, StyleList& rStyleList, SfxStyleSearchBits nMask = SfxStyleSearchBits::Auto,
134 sal_uInt16* pIdx = nullptr, const sal_uInt16* pModifier = nullptr);
136 // This function handles drop of content into the treeview to create a new style
137 sal_Int8 ExecuteDrop(const ExecuteDropEvent& rEvt);
138 // This function is used when a newstyle is created
139 DECL_LINK(OnAsyncExecuteDrop, void*, void);
141 // Used in StyleList::UpdateStyles, StyleList::Update
142 // Whenever a new family(Eg. Character, List etc.) is selected it comes into action
143 void FamilySelect(sal_uInt16 nId, StyleList& rStyleList, bool bRefresh = false);
145 // Constructor
146 SfxCommonTemplateDialog_Impl(SfxBindings* pB, weld::Container*, weld::Builder* pBuilder);
148 // Destructor
149 virtual ~SfxCommonTemplateDialog_Impl();
151 // Used in StyleList::SelectStyle, StyleList::Notify, IMPL_LINK(PopupFlatMenuHdl)
152 // These functions are used when a style is edited, deleted, created etc..
153 virtual void EnableEdit(bool b, StyleList* rStyleList);
154 void EnableDel(bool b, const StyleList* rStyleList);
155 void EnableNew(bool b, const StyleList* rStyleList);
156 void EnableHide(bool b, const StyleList* rStyleList);
157 void EnableShow(bool b, const StyleList* rStyleList);
159 // Used in TreeDrag
160 void EnableTreeDrag(bool b);
161 // It comes into action when a style is created or updated or newmenu is created
162 void EnableExample_Impl(sal_uInt16 nId, bool bEnable);
164 // This comes into action when a family is selected or a style is applied for use
165 virtual void CheckItem(const OUString& /*rMesId*/, bool /*bCheck*/ = true) {}
166 // This is used for watercan or when newmenu or watercan is enabled or updated
167 virtual void EnableItem(const OUString& /*rMesId*/, bool /*bCheck*/ = true) {}
168 // This is used for watercan
169 virtual bool IsCheckedItem(const OUString& /*rMesId*/) { return true; }
171 // This is used when a style is selected
172 void SelectStyle(const OUString& rStyle, bool bIsCallback, StyleList& rStyleList);
174 //When a new document is created, it comes into action
175 void IsUpdate(StyleList&);
177 // This function return the value of bUpdate in Stylelist
178 // This value is used in StyleList's Notify
179 bool GetNotifyUpdate() const { return bUpdate; }
180 // This function sets the value of bUpdate in Dialog
181 // This function is used in StyleList's Notify to update the value of bUpdate when required
182 void SetNotifyupdate(bool b) { bUpdate = b; }
184 void connect_stylelist_read_resource(const Link<void*, size_t>& rLink) { m_aStyleListReadResource = rLink; }
185 void connect_stylelist_clear(const Link<void*, void>& rLink) { m_aStyleListClear = rLink; }
186 void connect_stylelist_cleanup(const Link<void*, void>& rLink) { m_aStyleListCleanup = rLink; }
187 void connect_stylelist_execute_drop(const Link<const ExecuteDropEvent&, sal_Int8>& rLink);
188 void connect_stylelist_execute_new_menu(const Link<void*, void>& rLink) { m_aStyleListNewMenu = rLink; }
189 void connect_stylelist_for_watercan(const Link<void*, bool>& rLink) { m_aStyleListWaterCan = rLink; }
190 void connect_stylelist_has_selected_style(const Link<void*, bool>& rLink);
191 void connect_stylelist_update_style_dependents(const Link<void*, void>& rLink);
192 void connect_stylelist_enable_tree_drag(const Link<bool, void> rLink);
193 void connect_stylelist_enable_delete(const Link<void*, void> rLink);
194 void connect_stylelist_set_water_can_state(const Link<const SfxBoolItem*, void> rLink);
195 void connect_set_family(const Link<sal_uInt16, void> rLink) { m_aStyleListSetFamily = rLink; }
198 class ToolbarDropTarget;
199 class DropTargetHelper;
201 class SfxTemplateDialog_Impl final : public SfxCommonTemplateDialog_Impl
203 private:
204 friend class SfxTemplateControllerItem;
205 friend class SfxTemplatePanelControl;
207 std::unique_ptr<ToolbarDropTarget> m_xToolbarDropTargetHelper;
208 std::unique_ptr<weld::Toolbar> m_xActionTbL;
209 std::unique_ptr<weld::Toolbar> m_xActionTbR;
210 std::unique_ptr<weld::Menu> m_xToolMenu;
211 int m_nActionTbLVisible;
213 void FillToolMenu();
215 DECL_LINK(ToolBoxLSelect, const OUString&, void);
216 DECL_LINK(ToolBoxRSelect, const OUString&, void);
217 DECL_LINK(ToolMenuSelectHdl, const OUString&, void);
219 virtual void EnableEdit( bool, StyleList* rStyleList) override;
220 virtual void EnableItem(const OUString& rMesId, bool bCheck = true) override;
221 virtual void CheckItem(const OUString& rMesId, bool bCheck = true) override;
222 virtual bool IsCheckedItem(const OUString& rMesId) override;
223 virtual void InsertFamilyItem(sal_uInt16 nId, const SfxStyleFamilyItem& rItem) override;
224 virtual void EnableFamilyItem(sal_uInt16 nId, bool bEnabled) override;
225 virtual void ClearFamilyList() override;
226 virtual void ReplaceUpdateButtonByMenu() override;
228 public:
229 friend class SfxTemplateDialog;
231 SfxTemplateDialog_Impl( SfxBindings*, SfxTemplatePanelControl* pDlgWindow );
232 virtual ~SfxTemplateDialog_Impl() override;
234 sal_Int8 AcceptToolbarDrop(const AcceptDropEvent& rEvt, const DropTargetHelper& rHelper);
236 void Initialize();
239 #endif // INCLUDED_SFX2_SOURCE_INC_TEMPLDGI_HXX
242 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */