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/.
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 class SfxTemplateControllerItem
;
24 #include <sal/config.h>
30 #include <vcl/transfer.hxx>
31 #include <vcl/weld.hxx>
32 #include <svl/lstner.hxx>
33 #include <svl/eitem.hxx>
35 #include <svl/style.hxx>
37 #include <sfx2/childwin.hxx>
38 #include <sfx2/objsh.hxx>
39 #include <sfx2/styfitem.hxx>
40 #include <sfx2/templdlg.hxx>
42 #include <vcl/idle.hxx>
44 class SfxStyleFamilyItem
;
45 class SfxTemplateItem
;
47 class SfxStyleSheetBase
;
48 class SfxStyleSheetBasePool
;
49 class StyleTreeListBox_Impl
;
50 class SfxTemplateDialog_Impl
;
51 class SfxCommonTemplateDialog_Impl
;
53 namespace com::sun::star::frame
{
54 class XModuleManager2
;
57 enum class StyleFlags
{
58 NONE
=0, UpdateFamilyList
=1, UpdateFamily
=2
61 template<> struct typed_flags
<StyleFlags
> : is_typed_flags
<StyleFlags
, 3> {};
64 class TreeViewDropTarget
;
66 class SfxCommonTemplateDialog_Impl
: public SfxListener
69 class DeletionWatcher
;
70 friend class DeletionWatcher
;
75 DeletionWatcher
* impl_setDeletionWatcher(DeletionWatcher
* pNewWatcher
);
76 OUString
getDefaultStyleName( const SfxStyleFamily eFam
);
79 #define MAX_FAMILIES 6
80 #define COUNT_BOUND_FUNC 14
82 friend class SfxTemplateControllerItem
;
84 SfxBindings
* pBindings
;
85 std::array
<std::unique_ptr
<SfxTemplateControllerItem
>, COUNT_BOUND_FUNC
> pBoundItems
;
87 weld::Container
* mpContainer
;
88 std::unique_ptr
<weld::Builder
> mxMenuBuilder
;
89 std::unique_ptr
<weld::Menu
> mxMenu
;
90 OString sLastItemIdent
;
92 std::unique_ptr
<Idle
> pIdle
;
94 std::optional
<SfxStyleFamilies
> mxStyleFamilies
;
95 std::array
<std::unique_ptr
<SfxTemplateItem
>, MAX_FAMILIES
> pFamilyState
;
96 SfxStyleSheetBasePool
* pStyleSheetPool
;
97 SfxObjectShell
* pCurObjShell
;
98 css::uno::Reference
<css::frame::XModuleManager2
> xModuleManager
;
99 DeletionWatcher
* m_pDeletionWatcher
;
101 std::unique_ptr
<weld::TreeView
> mxFmtLb
;
102 std::unique_ptr
<weld::TreeView
> mxTreeBox
;
103 std::unique_ptr
<weld::CheckButton
> mxPreviewCheckbox
;
104 std::unique_ptr
<weld::ComboBox
> mxFilterLb
;
105 std::unique_ptr
<TreeViewDropTarget
> m_xTreeView1DropTargetHelper
;
106 std::unique_ptr
<TreeViewDropTarget
> m_xTreeView2DropTargetHelper
;
108 sal_uInt16 nActFamily
; // Id in the ToolBox = Position - 1
109 sal_uInt16 nActFilter
; // FilterIdx
110 SfxStyleSearchBits nAppFilter
; // Filter, which has set the application (for automatic)
112 sal_uInt16 m_nModifier
;
116 bool bUpdateFamily
:1;
122 bool bWaterDisabled
:1;
123 bool bNewByExampleDisabled
:1;
124 bool bUpdateByExampleDisabled
:1;
126 bool bAllowReParentDrop
:1;
127 bool bHierarchical
:1;
128 bool m_bWantHierarchical
:1;
129 bool bBindingUpdate
:1;
131 DECL_LINK(FilterSelectHdl
, weld::ComboBox
&, void );
132 DECL_LINK(FmtSelectHdl
, weld::TreeView
&, void);
133 DECL_LINK(TreeListApplyHdl
, weld::TreeView
&, bool);
134 DECL_LINK(MousePressHdl
, const MouseEvent
&, bool);
135 DECL_LINK(TimeOut
, Timer
*, void );
136 DECL_LINK(PreviewHdl
, weld::Toggleable
&, void);
137 DECL_LINK(PopupFlatMenuHdl
, const CommandEvent
&, bool);
138 DECL_LINK(PopupTreeMenuHdl
, const CommandEvent
&, bool);
139 DECL_LINK(KeyInputHdl
, const KeyEvent
&, bool);
140 DECL_LINK(QueryTooltipHdl
, const weld::TreeIter
&, OUString
);
141 DECL_LINK(OnAsyncExecuteDrop
, void *, void);
142 DECL_LINK(DragBeginHdl
, bool&, bool);
143 DECL_LINK(CustomRenderHdl
, weld::TreeView::render_args
, void);
144 DECL_STATIC_LINK(SfxCommonTemplateDialog_Impl
, CustomGetSizeHdl
, weld::TreeView::get_size_args
, Size
);
146 void DropHdl(const OUString
& rStyle
, const OUString
& rParent
);
148 virtual void EnableItem(const OString
& /*rMesId*/, bool /*bCheck*/ = true)
150 virtual void CheckItem(const OString
& /*rMesId*/, bool /*bCheck*/ = true)
152 virtual bool IsCheckedItem(const OString
& /*rMesId*/ )
157 void InvalidateBindings();
158 virtual void InsertFamilyItem(sal_uInt16 nId
, const SfxStyleFamilyItem
& rItem
) = 0;
159 virtual void EnableFamilyItem(sal_uInt16 nId
, bool bEnabled
) = 0;
160 virtual void ClearFamilyList() = 0;
161 virtual void ReplaceUpdateButtonByMenu();
169 bool Execute_Impl(sal_uInt16 nId
, const OUString
& rStr
, const OUString
& rRefStr
,
170 sal_uInt16 nFamily
, SfxStyleSearchBits nMask
= SfxStyleSearchBits::Auto
,
171 sal_uInt16
* pIdx
= nullptr, const sal_uInt16
* pModifier
= nullptr );
173 void UpdateStyles_Impl(StyleFlags nFlags
);
174 const SfxStyleFamilyItem
* GetFamilyItem_Impl() const;
175 bool IsInitialized() const
177 return nActFamily
!= 0xffff;
181 void EnableHierarchical(bool);
183 void FilterSelect( sal_uInt16 nFilterIdx
, bool bForce
);
184 void SetFamilyState( sal_uInt16 nSlotId
, const SfxTemplateItem
* );
185 void SetWaterCanState( const SfxBoolItem
* pItem
);
186 bool IsSafeForWaterCan() const;
188 void SelectStyle(const OUString
& rStyle
, bool bIsCallback
);
189 void UpdateStyleDependents();
190 bool HasSelectedStyle() const;
191 void GetSelectedStyle() const;
194 void UpdateFamily_Impl();
196 // In which FamilyState do I have to look, in order to get the
197 // information of the ith Family in the pStyleFamilies.
198 sal_uInt16
StyleNrToInfoOffset( sal_uInt16 i
);
200 void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
202 void FamilySelect( sal_uInt16 nId
, bool bPreviewRefresh
= false );
203 void SetFamily(SfxStyleFamily nFamily
);
204 void ActionSelect(const OString
& rId
);
206 sal_Int32
LoadFactoryStyleFilter( SfxObjectShell
const * i_pObjSh
);
207 void SaveFactoryStyleFilter( SfxObjectShell
const * i_pObjSh
, sal_Int32 i_nFilter
);
208 SfxObjectShell
* SaveSelection();
210 void PrepareMenu(const Point
& rPos
);
211 void ShowMenu(const CommandEvent
& rCEvt
);
215 SfxCommonTemplateDialog_Impl(SfxBindings
* pB
, weld::Container
*, weld::Builder
* pBuilder
);
216 virtual ~SfxCommonTemplateDialog_Impl() override
;
218 void MenuSelect(const OString
& rIdent
);
219 DECL_LINK( MenuSelectAsyncHdl
, void*, void );
221 virtual void EnableEdit( bool b
)
225 void EnableDel( bool b
)
229 void EnableNew( bool b
)
233 void EnableHide( bool b
)
237 void EnableShow( bool b
)
242 void EnableTreeDrag(bool b
);
243 void EnableExample_Impl(sal_uInt16 nId
, bool bEnable
);
244 SfxStyleFamily
GetActualFamily() const;
245 OUString
GetSelectedEntry() const;
247 SfxObjectShell
* GetObjectShell() const
252 sal_Int8
AcceptDrop(const AcceptDropEvent
& rEvt
, const DropTargetHelper
& rHelper
);
253 sal_Int8
ExecuteDrop(const ExecuteDropEvent
& rEvt
);
255 void CreateContextMenu();
258 class ToolbarDropTarget
;
259 class DropTargetHelper
;
261 class SfxTemplateDialog_Impl
: public SfxCommonTemplateDialog_Impl
264 friend class SfxTemplateControllerItem
;
265 friend class SfxTemplatePanelControl
;
267 std::unique_ptr
<ToolbarDropTarget
> m_xToolbarDropTargetHelper
;
268 std::unique_ptr
<weld::Toolbar
> m_xActionTbL
;
269 std::unique_ptr
<weld::Toolbar
> m_xActionTbR
;
270 std::unique_ptr
<weld::Menu
> m_xToolMenu
;
271 int m_nActionTbLVisible
;
275 DECL_LINK(ToolBoxLSelect
, const OString
&, void);
276 DECL_LINK(ToolBoxRSelect
, const OString
&, void);
277 DECL_LINK(ToolMenuSelectHdl
, const OString
&, void);
280 virtual void EnableEdit( bool ) override
;
281 virtual void EnableItem(const OString
& rMesId
, bool bCheck
= true) override
;
282 virtual void CheckItem(const OString
& rMesId
, bool bCheck
= true) override
;
283 virtual bool IsCheckedItem(const OString
& rMesId
) override
;
284 virtual void InsertFamilyItem(sal_uInt16 nId
, const SfxStyleFamilyItem
& rItem
) override
;
285 virtual void EnableFamilyItem(sal_uInt16 nId
, bool bEnabled
) override
;
286 virtual void ClearFamilyList() override
;
287 virtual void ReplaceUpdateButtonByMenu() override
;
290 friend class SfxTemplateDialog
;
292 SfxTemplateDialog_Impl( SfxBindings
*, SfxTemplatePanelControl
* pDlgWindow
);
293 virtual ~SfxTemplateDialog_Impl() override
;
295 sal_Int8
AcceptToolbarDrop(const AcceptDropEvent
& rEvt
, const DropTargetHelper
& rHelper
);
300 #endif // INCLUDED_SFX2_SOURCE_INC_TEMPLDGI_HXX
303 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */