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 <vcl/button.hxx>
25 #include <vcl/toolbox.hxx>
26 #include <vcl/lstbox.hxx>
27 #include <svl/lstner.hxx>
28 #include <svtools/treelistbox.hxx>
29 #include <svl/eitem.hxx>
31 #include <rsc/rscsfx.hxx>
32 #include <tools/rtti.hxx>
34 #include <sfx2/childwin.hxx>
35 #include <sfx2/templdlg.hxx>
37 class SfxStyleFamilies
;
38 class SfxStyleFamilyItem
;
39 class SfxTemplateItem
;
41 class SfxStyleSheetBase
;
42 class SfxStyleSheetBasePool
;
44 class StyleTreeListBox_Impl
;
45 class SfxTemplateDialog_Impl
;
46 class SfxCommonTemplateDialog_Impl
;
47 class SfxDockingWindow
;
49 namespace com
{ namespace sun
{ namespace star
{ namespace frame
{
50 class XModuleManager2
;
53 class DropListBox_Impl
: public SvTreeListBox
56 DECL_LINK(OnAsyncExecuteDrop
, void *);
59 SfxCommonTemplateDialog_Impl
* pDialog
;
63 DropListBox_Impl(vcl::Window
* pParent
, const ResId
& rId
, SfxCommonTemplateDialog_Impl
* pD
)
64 : SvTreeListBox(pParent
, rId
)
71 DropListBox_Impl(vcl::Window
* pParent
, WinBits nWinBits
, SfxCommonTemplateDialog_Impl
* pD
)
72 : SvTreeListBox(pParent
, nWinBits
)
79 virtual void MouseButtonDown(const MouseEvent
& rMEvt
) SAL_OVERRIDE
;
80 virtual sal_Int8
AcceptDrop(const AcceptDropEvent
& rEvt
) SAL_OVERRIDE
;
81 using SvTreeListBox::ExecuteDrop
;
82 virtual sal_Int8
ExecuteDrop(const ExecuteDropEvent
& rEvt
) SAL_OVERRIDE
;
84 sal_uInt16
GetModifier() const
89 virtual bool Notify( NotifyEvent
& rNEvt
) SAL_OVERRIDE
;
92 typedef std::vector
<OUString
> ExpandedEntries_t
;
94 /** TreeListBox class for displaying the hierarchical view of the templates
96 class StyleTreeListBox_Impl
: public DropListBox_Impl
99 SvTreeListEntry
* pCurEntry
;
100 Link
<> aDoubleClickLink
;
106 virtual void Command(const CommandEvent
& rMEvt
) SAL_OVERRIDE
;
107 virtual bool Notify(NotifyEvent
& rNEvt
) SAL_OVERRIDE
;
108 virtual bool DoubleClickHdl() SAL_OVERRIDE
;
109 virtual bool ExpandingHdl() SAL_OVERRIDE
;
110 virtual void ExpandedHdl() SAL_OVERRIDE
;
111 virtual TriState
NotifyMoving(
112 SvTreeListEntry
* pTarget
, SvTreeListEntry
* pEntry
,
113 SvTreeListEntry
*& rpNewParent
, sal_uIntPtr
& rNewChildPos
) SAL_OVERRIDE
;
115 StyleTreeListBox_Impl( SfxCommonTemplateDialog_Impl
* pParent
, WinBits nWinStyle
= 0);
119 void SetDoubleClickHdl(const Link
<> &rLink
)
121 aDoubleClickLink
= rLink
;
123 void SetDropHdl(const Link
<> &rLink
)
128 using SvTreeListBox::GetParent
;
130 const OUString
& GetParent() const
134 const OUString
& GetStyle() const
138 void MakeExpanded_Impl(ExpandedEntries_t
& rEntries
) const;
140 virtual PopupMenu
* CreateContextMenu() SAL_OVERRIDE
;
143 class SfxActionListBox
: public DropListBox_Impl
147 SfxActionListBox( SfxCommonTemplateDialog_Impl
* pParent
, WinBits nWinBits
);
149 virtual PopupMenu
* CreateContextMenu() SAL_OVERRIDE
;
153 class SfxCommonTemplateDialog_Impl
: public SfxListener
156 class DeletionWatcher
;
157 friend class DeletionWatcher
;
162 void ClearResource();
164 DeletionWatcher
* impl_setDeletionWatcher(DeletionWatcher
* pNewWatcher
);
167 #define MAX_FAMILIES 5
168 #define COUNT_BOUND_FUNC 13
170 #define UPDATE_FAMILY_LIST 0x0001
171 #define UPDATE_FAMILY 0x0002
173 friend class DropListBox_Impl
;
174 friend class SfxTemplateControllerItem
;
176 SfxBindings
* pBindings
;
177 SfxTemplateControllerItem
* pBoundItems
[COUNT_BOUND_FUNC
];
179 VclPtr
<vcl::Window
> pWindow
;
183 ResId
* m_pStyleFamiliesId
;
184 SfxStyleFamilies
* pStyleFamilies
;
185 SfxTemplateItem
* pFamilyState
[MAX_FAMILIES
];
186 SfxStyleSheetBasePool
* pStyleSheetPool
;
187 VclPtr
<StyleTreeListBox_Impl
> pTreeBox
;
188 SfxObjectShell
* pCurObjShell
;
189 css::uno::Reference
<css::frame::XModuleManager2
> xModuleManager
;
190 DeletionWatcher
* m_pDeletionWatcher
;
192 VclPtr
<SfxActionListBox
> aFmtLb
;
193 VclPtr
<ListBox
> aFilterLb
;
196 sal_uInt16 nActFamily
; // Id in the ToolBox = Position - 1
197 sal_uInt16 nActFilter
; // FilterIdx
198 sal_uInt16 nAppFilter
; // Filter, which has set the application (for automatic)
204 bool bUpdateFamily
:1;
210 bool bWaterDisabled
:1;
211 bool bNewByExampleDisabled
:1;
212 bool bUpdateByExampleDisabled
:1;
214 bool bHierarchical
:1;
215 bool m_bWantHierarchical
:1;
216 bool bBindingUpdate
:1;
218 DECL_LINK( FilterSelectHdl
, ListBox
* );
219 DECL_LINK( FmtSelectHdl
, SvTreeListBox
* );
220 DECL_LINK( ApplyHdl
, Control
* );
221 DECL_LINK( DropHdl
, StyleTreeListBox_Impl
* );
222 DECL_LINK_TYPED( TimeOut
, Idle
*, void );
224 virtual void EnableItem(sal_uInt16
/*nMesId*/, bool /*bCheck*/ = true)
226 virtual void CheckItem(sal_uInt16
/*nMesId*/, bool /*bCheck*/ = true)
228 virtual bool IsCheckedItem(sal_uInt16
/*nMesId*/ )
232 virtual void LoadedFamilies()
236 UpdateStyles_Impl(UPDATE_FAMILY_LIST
);
239 void InvalidateBindings();
240 virtual void InsertFamilyItem( sal_uInt16 nId
, const SfxStyleFamilyItem
* pItem
) = 0;
241 virtual void EnableFamilyItem( sal_uInt16 nId
, bool bEnabled
= true ) = 0;
242 virtual void ClearFamilyList() = 0;
243 virtual void ReplaceUpdateButtonByMenu();
245 void NewHdl( void* );
246 void EditHdl( void* );
247 void DeleteHdl( void* );
248 void HideHdl( void* );
249 void ShowHdl( void* );
251 bool Execute_Impl(sal_uInt16 nId
, const OUString
& rStr
, const OUString
& rRefStr
,
252 sal_uInt16 nFamily
, sal_uInt16 nMask
= 0,
253 sal_uInt16
* pIdx
= NULL
, const sal_uInt16
* pModifier
= NULL
);
255 void UpdateStyles_Impl(sal_uInt16 nFlags
);
256 const SfxStyleFamilyItem
* GetFamilyItem_Impl() const;
257 bool IsInitialized() const
259 return nActFamily
!= 0xffff;
264 void EnableHierarchical(bool);
266 void FilterSelect( sal_uInt16 nFilterIdx
, bool bForce
= false );
267 void SetFamilyState( sal_uInt16 nSlotId
, const SfxTemplateItem
* );
268 void SetWaterCanState( const SfxBoolItem
* pItem
);
270 void SelectStyle( const OUString
& rStyle
);
271 bool HasSelectedStyle() const;
272 SfxStyleSheetBase
* GetSelectedStyle() const;
275 void UpdateFamily_Impl();
277 // In which FamilyState do I have to look , in order to get the
278 // information of the ith Family in the pStyleFamilies.
279 sal_uInt16
StyleNrToInfoOffset( sal_uInt16 i
);
281 void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
) SAL_OVERRIDE
;
283 void FamilySelect( sal_uInt16 nId
);
284 void SetFamily( sal_uInt16 nId
);
285 void ActionSelect( sal_uInt16 nId
);
287 sal_Int32
LoadFactoryStyleFilter( SfxObjectShell
* i_pObjSh
);
288 void SaveFactoryStyleFilter( SfxObjectShell
* i_pObjSh
, sal_Int32 i_nFilter
);
289 SfxObjectShell
* SaveSelection();
294 SfxCommonTemplateDialog_Impl( SfxBindings
* pB
, vcl::Window
*, bool );
295 virtual ~SfxCommonTemplateDialog_Impl();
297 DECL_LINK( MenuSelectHdl
, Menu
* );
299 virtual void EnableEdit( bool b
= true )
303 void EnableDel( bool b
= true )
307 void EnableNew( bool b
= true )
311 void EnableHide( bool b
= true )
315 void EnableShow( bool b
= true )
320 vcl::Window
* GetWindow()
325 void EnableTreeDrag(bool b
= true);
326 void EnableExample_Impl(sal_uInt16 nId
, bool bEnable
);
327 SfxStyleFamily
GetActualFamily() const;
328 OUString
GetSelectedEntry() const;
330 SfxObjectShell
* GetObjectShell() const
335 inline bool CanEdit() const
339 inline bool CanDel() const
343 inline bool CanNew() const
348 inline bool CanHide() const
353 inline bool CanShow() const
358 // normally for derivates from SvTreeListBoxes, but in this case the dialog handles context menus
359 PopupMenu
* CreateContextMenu();
362 class DropToolBox_Impl
: public ToolBox
, public DropTargetHelper
364 SfxTemplateDialog_Impl
& rParent
;
366 virtual sal_Int8
AcceptDrop( const AcceptDropEvent
& rEvt
) SAL_OVERRIDE
;
367 virtual sal_Int8
ExecuteDrop( const ExecuteDropEvent
& rEvt
) SAL_OVERRIDE
;
369 DropToolBox_Impl(vcl::Window
* pParent
, SfxTemplateDialog_Impl
* pTemplateDialog
);
372 class SfxTemplateDialog_Impl
: public SfxCommonTemplateDialog_Impl
375 friend class SfxTemplateControllerItem
;
376 friend class DropToolBox_Impl
;
377 friend class SfxTemplatePanelControl
;
379 VclPtr
<vcl::Window
> m_pFloat
;
381 VclPtr
<DropToolBox_Impl
> m_aActionTbL
;
382 VclPtr
<ToolBox
> m_aActionTbR
;
384 DECL_LINK_TYPED( ToolBoxLSelect
, ToolBox
*, void );
385 DECL_LINK_TYPED( ToolBoxRSelect
, ToolBox
*, void );
386 DECL_LINK_TYPED( ToolBoxRClick
, ToolBox
*, void );
387 DECL_LINK( MenuSelectHdl
, Menu
* );
390 virtual void EnableEdit( bool = true ) SAL_OVERRIDE
;
391 virtual void EnableItem( sal_uInt16 nMesId
, bool bCheck
= true ) SAL_OVERRIDE
;
392 virtual void CheckItem( sal_uInt16 nMesId
, bool bCheck
= true ) SAL_OVERRIDE
;
393 virtual bool IsCheckedItem( sal_uInt16 nMesId
) SAL_OVERRIDE
;
394 virtual void LoadedFamilies() SAL_OVERRIDE
;
395 virtual void InsertFamilyItem( sal_uInt16 nId
, const SfxStyleFamilyItem
* pIten
) SAL_OVERRIDE
;
396 virtual void EnableFamilyItem( sal_uInt16 nId
, bool bEnabled
= true ) SAL_OVERRIDE
;
397 virtual void ClearFamilyList() SAL_OVERRIDE
;
398 virtual void ReplaceUpdateButtonByMenu() SAL_OVERRIDE
;
401 Size
GetMinOutputSizePixel();
403 void updateFamilyImages();
404 void updateNonFamilyImages();
407 friend class SfxTemplateDialog
;
410 SfxTemplateDialog_Impl( SfxBindings
*, SfxTemplatePanelControl
* pDlgWindow
);
411 virtual ~SfxTemplateDialog_Impl();
416 #endif // INCLUDED_SFX2_SOURCE_INC_TEMPLDGI_HXX
419 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */