bump product version to 5.0.4.1
[LibreOffice.git] / sfx2 / source / inc / templdgi.hxx
blob76e41684954c2c40175b430d0d1c3267ea64659f
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 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;
40 class SfxBindings;
41 class SfxStyleSheetBase;
42 class SfxStyleSheetBasePool;
43 class SvTreeListBox ;
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;
51 }}}}
53 class DropListBox_Impl : public SvTreeListBox
55 private:
56 DECL_LINK(OnAsyncExecuteDrop, void *);
58 protected:
59 SfxCommonTemplateDialog_Impl* pDialog;
60 sal_uInt16 nModifier;
62 public:
63 DropListBox_Impl(vcl::Window* pParent, const ResId& rId, SfxCommonTemplateDialog_Impl* pD)
64 : SvTreeListBox(pParent, rId)
65 , pDialog(pD)
66 , nModifier(0)
68 SetHighlightRange();
71 DropListBox_Impl(vcl::Window* pParent, WinBits nWinBits, SfxCommonTemplateDialog_Impl* pD)
72 : SvTreeListBox(pParent, nWinBits)
73 , pDialog(pD)
74 , nModifier(0)
76 SetHighlightRange();
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
86 return nModifier;
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
98 private:
99 SvTreeListEntry* pCurEntry;
100 Link<> aDoubleClickLink;
101 Link<> aDropLink;
102 OUString aParent;
103 OUString aStyle;
105 protected:
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;
114 public:
115 StyleTreeListBox_Impl( SfxCommonTemplateDialog_Impl* pParent, WinBits nWinStyle = 0);
117 void Recalc();
119 void SetDoubleClickHdl(const Link<> &rLink)
121 aDoubleClickLink = rLink;
123 void SetDropHdl(const Link<> &rLink)
125 aDropLink = rLink;
128 using SvTreeListBox::GetParent;
130 const OUString& GetParent() const
132 return aParent;
134 const OUString& GetStyle() const
136 return aStyle;
138 void MakeExpanded_Impl(ExpandedEntries_t& rEntries) const;
140 virtual PopupMenu* CreateContextMenu() SAL_OVERRIDE;
143 class SfxActionListBox : public DropListBox_Impl
145 protected:
146 public:
147 SfxActionListBox( SfxCommonTemplateDialog_Impl* pParent, WinBits nWinBits );
149 virtual PopupMenu* CreateContextMenu() SAL_OVERRIDE;
150 void Recalc();
153 class SfxCommonTemplateDialog_Impl : public SfxListener
155 private:
156 class DeletionWatcher;
157 friend class DeletionWatcher;
159 bool mbIgnoreSelect;
161 void ReadResource();
162 void ClearResource();
163 void impl_clear();
164 DeletionWatcher* impl_setDeletionWatcher(DeletionWatcher* pNewWatcher);
166 protected:
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;
180 SfxModule* pModule;
181 Idle* pIdle;
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;
194 Size aSize;
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)
200 bool bDontUpdate :1;
201 bool bIsWater :1;
202 bool bEnabled :1;
203 bool bUpdate :1;
204 bool bUpdateFamily :1;
205 bool bCanEdit :1;
206 bool bCanDel :1;
207 bool bCanNew :1;
208 bool bCanHide :1;
209 bool bCanShow :1;
210 bool bWaterDisabled :1;
211 bool bNewByExampleDisabled :1;
212 bool bUpdateByExampleDisabled :1;
213 bool bTreeDrag :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*/ )
230 return true;
232 virtual void LoadedFamilies()
234 void Update()
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;
261 void ResetFocus();
262 void EnableDelete();
263 void Initialize();
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;
273 void FillTreeBox();
274 void Update_Impl();
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();
291 public:
292 TYPEINFO_OVERRIDE();
294 SfxCommonTemplateDialog_Impl( SfxBindings* pB, vcl::Window*, bool );
295 virtual ~SfxCommonTemplateDialog_Impl();
297 DECL_LINK( MenuSelectHdl, Menu * );
299 virtual void EnableEdit( bool b = true )
301 bCanEdit = b;
303 void EnableDel( bool b = true )
305 bCanDel = b;
307 void EnableNew( bool b = true )
309 bCanNew = b;
311 void EnableHide( bool b = true )
313 bCanHide = b;
315 void EnableShow( bool b = true )
317 bCanShow = b;
320 vcl::Window* GetWindow()
322 return pWindow;
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
332 return pCurObjShell;
335 inline bool CanEdit() const
337 return bCanEdit;
339 inline bool CanDel() const
341 return bCanDel;
343 inline bool CanNew() const
345 return bCanNew;
348 inline bool CanHide() const
350 return bCanHide;
353 inline bool CanShow() const
355 return bCanShow;
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;
365 protected:
366 virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ) SAL_OVERRIDE;
367 virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ) SAL_OVERRIDE;
368 public:
369 DropToolBox_Impl(vcl::Window* pParent, SfxTemplateDialog_Impl* pTemplateDialog);
372 class SfxTemplateDialog_Impl : public SfxCommonTemplateDialog_Impl
374 private:
375 friend class SfxTemplateControllerItem;
376 friend class DropToolBox_Impl;
377 friend class SfxTemplatePanelControl;
379 VclPtr<vcl::Window> m_pFloat;
380 bool m_bZoomIn;
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* );
389 protected:
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;
400 void Resize();
401 Size GetMinOutputSizePixel();
403 void updateFamilyImages();
404 void updateNonFamilyImages();
406 public:
407 friend class SfxTemplateDialog;
408 TYPEINFO_OVERRIDE();
410 SfxTemplateDialog_Impl( SfxBindings*, SfxTemplatePanelControl* pDlgWindow );
411 virtual ~SfxTemplateDialog_Impl();
413 void Initialize();
416 #endif // INCLUDED_SFX2_SOURCE_INC_TEMPLDGI_HXX
419 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */