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>
29 #include <vcl/transfer.hxx>
30 #include <vcl/weld.hxx>
31 #include <svl/lstner.hxx>
32 #include <svl/eitem.hxx>
34 #include <svl/style.hxx>
36 #include <sfx2/childwin.hxx>
37 #include <sfx2/objsh.hxx>
38 #include <sfx2/styfitem.hxx>
39 #include <sfx2/templdlg.hxx>
41 #include <vcl/idle.hxx>
43 class SfxStyleFamilyItem
;
44 class SfxTemplateItem
;
46 class SfxStyleSheetBase
;
47 class SfxStyleSheetBasePool
;
48 class StyleTreeListBox_Impl
;
49 class SfxTemplateDialog_Impl
;
50 class SfxCommonTemplateDialog_Impl
;
52 namespace com::sun::star::frame
{
53 class XModuleManager2
;
56 enum class StyleFlags
{
57 NONE
=0, UpdateFamilyList
=1, UpdateFamily
=2
60 template<> struct typed_flags
<StyleFlags
> : is_typed_flags
<StyleFlags
, 3> {};
63 class TreeViewDropTarget
;
65 class SfxCommonTemplateDialog_Impl
: public SfxListener
68 class DeletionWatcher
;
69 friend class DeletionWatcher
;
74 DeletionWatcher
* impl_setDeletionWatcher(DeletionWatcher
* pNewWatcher
);
75 OUString
getDefaultStyleName( const SfxStyleFamily eFam
);
78 #define MAX_FAMILIES 6
79 #define COUNT_BOUND_FUNC 14
81 friend class SfxTemplateControllerItem
;
83 SfxBindings
* pBindings
;
84 std::array
<std::unique_ptr
<SfxTemplateControllerItem
>, COUNT_BOUND_FUNC
> pBoundItems
;
86 weld::Container
* mpContainer
;
87 std::unique_ptr
<weld::Builder
> mxMenuBuilder
;
88 std::unique_ptr
<weld::Menu
> mxMenu
;
89 OString sLastItemIdent
;
91 std::unique_ptr
<Idle
> pIdle
;
93 std::unique_ptr
<SfxStyleFamilies
> pStyleFamilies
;
94 std::array
<std::unique_ptr
<SfxTemplateItem
>, MAX_FAMILIES
> pFamilyState
;
95 SfxStyleSheetBasePool
* pStyleSheetPool
;
96 SfxObjectShell
* pCurObjShell
;
97 css::uno::Reference
<css::frame::XModuleManager2
> xModuleManager
;
98 DeletionWatcher
* m_pDeletionWatcher
;
100 std::unique_ptr
<weld::TreeView
> mxFmtLb
;
101 std::unique_ptr
<weld::TreeView
> mxTreeBox
;
102 std::unique_ptr
<weld::CheckButton
> mxPreviewCheckbox
;
103 std::unique_ptr
<weld::ComboBox
> mxFilterLb
;
104 std::unique_ptr
<TreeViewDropTarget
> m_xTreeView1DropTargetHelper
;
105 std::unique_ptr
<TreeViewDropTarget
> m_xTreeView2DropTargetHelper
;
107 sal_uInt16 nActFamily
; // Id in the ToolBox = Position - 1
108 sal_uInt16 nActFilter
; // FilterIdx
109 SfxStyleSearchBits nAppFilter
; // Filter, which has set the application (for automatic)
111 sal_uInt16 m_nModifier
;
115 bool bUpdateFamily
:1;
121 bool bWaterDisabled
:1;
122 bool bNewByExampleDisabled
:1;
123 bool bUpdateByExampleDisabled
:1;
125 bool bAllowReParentDrop
:1;
126 bool bHierarchical
:1;
127 bool m_bWantHierarchical
:1;
128 bool bBindingUpdate
:1;
130 DECL_LINK(FilterSelectHdl
, weld::ComboBox
&, void );
131 DECL_LINK(FmtSelectHdl
, weld::TreeView
&, void);
132 DECL_LINK(TreeListApplyHdl
, weld::TreeView
&, bool);
133 DECL_LINK(MousePressHdl
, const MouseEvent
&, bool);
134 DECL_LINK(TimeOut
, Timer
*, void );
135 DECL_LINK(PreviewHdl
, weld::Button
&, void);
136 DECL_LINK(PopupFlatMenuHdl
, const CommandEvent
&, bool);
137 DECL_LINK(PopupTreeMenuHdl
, const CommandEvent
&, bool);
138 DECL_LINK(KeyInputHdl
, const KeyEvent
&, bool);
139 DECL_LINK(QueryTooltipHdl
, const weld::TreeIter
&, OUString
);
140 DECL_LINK(OnAsyncExecuteDrop
, void *, void);
141 DECL_LINK(DragBeginHdl
, bool&, bool);
142 DECL_LINK(CustomRenderHdl
, weld::TreeView::render_args
, void);
143 DECL_STATIC_LINK(SfxCommonTemplateDialog_Impl
, CustomGetSizeHdl
, weld::TreeView::get_size_args
, Size
);
145 void DropHdl(const OUString
& rStyle
, const OUString
& rParent
);
147 virtual void EnableItem(const OString
& /*rMesId*/, bool /*bCheck*/ = true)
149 virtual void CheckItem(const OString
& /*rMesId*/, bool /*bCheck*/ = true)
151 virtual bool IsCheckedItem(const OString
& /*rMesId*/ )
156 void InvalidateBindings();
157 virtual void InsertFamilyItem(sal_uInt16 nId
, const SfxStyleFamilyItem
& rItem
) = 0;
158 virtual void EnableFamilyItem(sal_uInt16 nId
, bool bEnabled
) = 0;
159 virtual void ClearFamilyList() = 0;
160 virtual void ReplaceUpdateButtonByMenu();
168 bool Execute_Impl(sal_uInt16 nId
, const OUString
& rStr
, const OUString
& rRefStr
,
169 sal_uInt16 nFamily
, SfxStyleSearchBits nMask
= SfxStyleSearchBits::Auto
,
170 sal_uInt16
* pIdx
= nullptr, const sal_uInt16
* pModifier
= nullptr );
172 void UpdateStyles_Impl(StyleFlags nFlags
);
173 const SfxStyleFamilyItem
* GetFamilyItem_Impl() const;
174 bool IsInitialized() const
176 return nActFamily
!= 0xffff;
180 void EnableHierarchical(bool);
182 void FilterSelect( sal_uInt16 nFilterIdx
, bool bForce
);
183 void SetFamilyState( sal_uInt16 nSlotId
, const SfxTemplateItem
* );
184 void SetWaterCanState( const SfxBoolItem
* pItem
);
185 bool IsSafeForWaterCan() const;
187 void SelectStyle(const OUString
& rStyle
, bool bIsCallback
);
188 void UpdateStyleDependents();
189 bool HasSelectedStyle() const;
190 void GetSelectedStyle() const;
193 void UpdateFamily_Impl();
195 // In which FamilyState do I have to look, in order to get the
196 // information of the ith Family in the pStyleFamilies.
197 sal_uInt16
StyleNrToInfoOffset( sal_uInt16 i
);
199 void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) override
;
201 void FamilySelect( sal_uInt16 nId
, bool bPreviewRefresh
= false );
202 void SetFamily(SfxStyleFamily nFamily
);
203 void ActionSelect(const OString
& rId
);
205 sal_Int32
LoadFactoryStyleFilter( SfxObjectShell
const * i_pObjSh
);
206 void SaveFactoryStyleFilter( SfxObjectShell
const * i_pObjSh
, sal_Int32 i_nFilter
);
207 SfxObjectShell
* SaveSelection();
209 void PrepareMenu(const Point
& rPos
);
210 void ShowMenu(const CommandEvent
& rCEvt
);
214 SfxCommonTemplateDialog_Impl(SfxBindings
* pB
, weld::Container
*, weld::Builder
* pBuilder
);
215 virtual ~SfxCommonTemplateDialog_Impl() override
;
217 void MenuSelect(const OString
& rIdent
);
218 DECL_LINK( MenuSelectAsyncHdl
, void*, void );
220 virtual void EnableEdit( bool b
)
224 void EnableDel( bool b
)
228 void EnableNew( bool b
)
232 void EnableHide( bool b
)
236 void EnableShow( bool b
)
241 void EnableTreeDrag(bool b
);
242 void EnableExample_Impl(sal_uInt16 nId
, bool bEnable
);
243 SfxStyleFamily
GetActualFamily() const;
244 OUString
GetSelectedEntry() const;
246 SfxObjectShell
* GetObjectShell() const
251 sal_Int8
AcceptDrop(const AcceptDropEvent
& rEvt
, const DropTargetHelper
& rHelper
);
252 sal_Int8
ExecuteDrop(const ExecuteDropEvent
& rEvt
);
254 void CreateContextMenu();
257 class ToolbarDropTarget
;
258 class DropTargetHelper
;
260 class SfxTemplateDialog_Impl
: public SfxCommonTemplateDialog_Impl
263 friend class SfxTemplateControllerItem
;
264 friend class SfxTemplatePanelControl
;
266 std::unique_ptr
<ToolbarDropTarget
> m_xToolbarDropTargetHelper
;
267 std::unique_ptr
<weld::Toolbar
> m_xActionTbL
;
268 std::unique_ptr
<weld::Toolbar
> m_xActionTbR
;
269 std::unique_ptr
<weld::Menu
> m_xToolMenu
;
270 int m_nActionTbLVisible
;
274 DECL_LINK(ToolBoxLSelect
, const OString
&, void);
275 DECL_LINK(ToolBoxRSelect
, const OString
&, void);
276 DECL_LINK(ToolMenuSelectHdl
, const OString
&, void);
279 virtual void EnableEdit( bool ) override
;
280 virtual void EnableItem(const OString
& rMesId
, bool bCheck
= true) override
;
281 virtual void CheckItem(const OString
& rMesId
, bool bCheck
= true) override
;
282 virtual bool IsCheckedItem(const OString
& rMesId
) override
;
283 virtual void InsertFamilyItem(sal_uInt16 nId
, const SfxStyleFamilyItem
& rItem
) override
;
284 virtual void EnableFamilyItem(sal_uInt16 nId
, bool bEnabled
) override
;
285 virtual void ClearFamilyList() override
;
286 virtual void ReplaceUpdateButtonByMenu() override
;
289 friend class SfxTemplateDialog
;
291 SfxTemplateDialog_Impl( SfxBindings
*, SfxTemplatePanelControl
* pDlgWindow
);
292 virtual ~SfxTemplateDialog_Impl() override
;
294 sal_Int8
AcceptToolbarDrop(const AcceptDropEvent
& rEvt
, const DropTargetHelper
& rHelper
);
299 #endif // INCLUDED_SFX2_SOURCE_INC_TEMPLDGI_HXX
302 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */