Bump version to 4.1-6
[LibreOffice.git] / sfx2 / source / inc / templdgi.hxx
blobf685a7114f389627b54537c8e20f79555b8b03d7
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 _SFX_TEMPDLGI_HXX
20 #define _SFX_TEMPDLGI_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 SfxTemplateDialogWrapper;
48 class SfxDockingWindow;
50 namespace com { namespace sun { namespace star { namespace frame { class XModuleManager2; } } } }
52 // class DropListBox_Impl ------------------------------------------------
54 class DropListBox_Impl : public SvTreeListBox
56 private:
57 DECL_LINK(OnAsyncExecuteDrop, void *);
59 protected:
60 SfxCommonTemplateDialog_Impl* pDialog;
61 sal_uInt16 nModifier;
63 public:
64 DropListBox_Impl( Window* pParent, const ResId& rId, SfxCommonTemplateDialog_Impl* pD ) :
65 SvTreeListBox( pParent, rId ), pDialog( pD ) {}
66 DropListBox_Impl( Window* pParent, WinBits nWinBits, SfxCommonTemplateDialog_Impl* pD ) :
67 SvTreeListBox( pParent, nWinBits ), pDialog( pD ) {}
69 virtual void MouseButtonDown( const MouseEvent& rMEvt );
70 virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
71 using SvTreeListBox::ExecuteDrop;
72 virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
74 sal_uInt16 GetModifier() const { return nModifier; }
76 virtual long Notify( NotifyEvent& rNEvt );
79 // class SfxActionListBox ------------------------------------------------
81 class SfxActionListBox : public DropListBox_Impl
83 protected:
84 public:
85 SfxActionListBox( SfxCommonTemplateDialog_Impl* pParent, WinBits nWinBits );
87 virtual PopupMenu* CreateContextMenu( void );
90 // class SfxCommonTemplateDialog_Impl ------------------------------------
92 class SfxCommonTemplateDialog_Impl : public SfxListener
94 private:
95 class DeletionWatcher;
96 friend class DeletionWatcher;
98 class ISfxTemplateCommon_Impl : public ISfxTemplateCommon
100 private:
101 SfxCommonTemplateDialog_Impl* pDialog;
102 public:
103 ISfxTemplateCommon_Impl( SfxCommonTemplateDialog_Impl* pDialogP ) : pDialog( pDialogP ) {}
104 virtual ~ISfxTemplateCommon_Impl() {}
105 virtual SfxStyleFamily GetActualFamily() const { return pDialog->GetActualFamily(); }
106 virtual String GetSelectedEntry() const { return pDialog->GetSelectedEntry(); }
109 ISfxTemplateCommon_Impl aISfxTemplateCommon;
111 void ReadResource();
112 void ClearResource();
113 void impl_clear();
114 void impl_setDeletionWatcher(DeletionWatcher* pNewWatcher);
116 protected:
117 #define MAX_FAMILIES 5
118 #define COUNT_BOUND_FUNC 13
120 #define UPDATE_FAMILY_LIST 0x0001
121 #define UPDATE_FAMILY 0x0002
123 friend class DropListBox_Impl;
124 friend class SfxTemplateControllerItem;
125 friend class SfxTemplateDialogWrapper;
127 SfxBindings* pBindings;
128 SfxTemplateControllerItem* pBoundItems[COUNT_BOUND_FUNC];
130 Window* pWindow;
131 SfxModule* pModule;
132 Timer* pTimer;
134 ResId* m_pStyleFamiliesId;
135 SfxStyleFamilies* pStyleFamilies;
136 SfxTemplateItem* pFamilyState[MAX_FAMILIES];
137 SfxStyleSheetBasePool* pStyleSheetPool;
138 SvTreeListBox* pTreeBox;
139 SfxObjectShell* pCurObjShell;
140 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager2 >
141 xModuleManager;
142 DeletionWatcher* m_pDeletionWatcher;
144 SfxActionListBox aFmtLb;
145 ListBox aFilterLb;
146 Size aSize;
148 sal_uInt16 nActFamily; // Id in the ToolBox = Position - 1
149 sal_uInt16 nActFilter; // FilterIdx
150 sal_uInt16 nAppFilter; // Filter, which has set the application (for automatic)
152 sal_Bool bDontUpdate :1,
153 bIsWater :1,
154 bEnabled :1,
155 bUpdate :1,
156 bUpdateFamily :1,
157 bCanEdit :1,
158 bCanDel :1,
159 bCanNew :1,
160 bCanHide :1,
161 bCanShow :1,
162 bWaterDisabled :1,
163 bNewByExampleDisabled :1,
164 bUpdateByExampleDisabled:1,
165 bTreeDrag :1,
166 bHierarchical :1,
167 m_bWantHierarchical :1,
168 bBindingUpdate :1;
170 DECL_LINK( FilterSelectHdl, ListBox * );
171 DECL_LINK( FmtSelectHdl, SvTreeListBox * );
172 DECL_LINK( ApplyHdl, Control * );
173 DECL_LINK( DropHdl, StyleTreeListBox_Impl * );
174 DECL_LINK( TimeOut, Timer * );
177 virtual void EnableItem( sal_uInt16 /*nMesId*/, sal_Bool /*bCheck*/ = sal_True ) {}
178 virtual void CheckItem( sal_uInt16 /*nMesId*/, sal_Bool /*bCheck*/ = sal_True ) {}
179 virtual sal_Bool IsCheckedItem( sal_uInt16 /*nMesId*/ ) { return sal_True; }
180 virtual void LoadedFamilies() {}
181 virtual void Update() { UpdateStyles_Impl(UPDATE_FAMILY_LIST); }
182 virtual void InvalidateBindings();
183 virtual void InsertFamilyItem( sal_uInt16 nId, const SfxStyleFamilyItem* pIten ) = 0;
184 virtual void EnableFamilyItem( sal_uInt16 nId, sal_Bool bEnabled = sal_True ) = 0;
185 virtual void ClearFamilyList() = 0;
186 virtual void ReplaceUpdateButtonByMenu();
188 void NewHdl( void* );
189 void EditHdl( void* );
190 void DeleteHdl( void* );
191 void HideHdl( void* );
192 void ShowHdl( void* );
194 sal_Bool Execute_Impl( sal_uInt16 nId, const String& rStr, const String& rRefStr,
195 sal_uInt16 nFamily, sal_uInt16 nMask = 0,
196 sal_uInt16* pIdx = NULL, const sal_uInt16* pModifier = NULL );
198 void UpdateStyles_Impl(sal_uInt16 nFlags);
199 const SfxStyleFamilyItem* GetFamilyItem_Impl() const;
200 sal_Bool IsInitialized() const { return nActFamily != 0xffff; }
201 void ResetFocus();
202 void EnableDelete();
203 void Initialize();
204 void EnableHierarchical(bool);
206 void FilterSelect( sal_uInt16 nFilterIdx, sal_Bool bForce = sal_False );
207 void SetFamilyState( sal_uInt16 nSlotId, const SfxTemplateItem* );
208 void SetWaterCanState( const SfxBoolItem* pItem );
210 void SelectStyle( const String& rStyle );
211 sal_Bool HasSelectedStyle() const;
212 SfxStyleSheetBase *GetSelectedStyle() const;
213 void FillTreeBox();
214 void Update_Impl();
215 void UpdateFamily_Impl();
217 // In which FamilyState do I have to look , in order to get the
218 // information of the ith Family in the pStyleFamilies.
219 sal_uInt16 StyleNrToInfoOffset( sal_uInt16 i );
221 void Notify( SfxBroadcaster& rBC, const SfxHint& rHint );
223 void FamilySelect( sal_uInt16 nId );
224 void SetFamily( sal_uInt16 nId );
225 void ActionSelect( sal_uInt16 nId );
227 sal_Int32 LoadFactoryStyleFilter( SfxObjectShell* i_pObjSh );
228 void SaveFactoryStyleFilter( SfxObjectShell* i_pObjSh, sal_Int32 i_nFilter );
229 SfxObjectShell * SaveSelection();
231 public:
232 TYPEINFO();
234 SfxCommonTemplateDialog_Impl( SfxBindings* pB, Window*, bool );
235 ~SfxCommonTemplateDialog_Impl();
237 DECL_LINK( MenuSelectHdl, Menu * );
239 virtual void EnableEdit( sal_Bool b = sal_True ) { bCanEdit = b; }
240 virtual void EnableDel( sal_Bool b = sal_True ) { bCanDel = b; }
241 virtual void EnableNew( sal_Bool b = sal_True ) { bCanNew = b; }
242 virtual void EnableHide( sal_Bool b = sal_True ) { bCanHide = b; }
243 virtual void EnableShow( sal_Bool b = sal_True ) { bCanShow = b; }
245 ISfxTemplateCommon* GetISfxTemplateCommon() { return &aISfxTemplateCommon; }
246 Window* GetWindow() { return pWindow; }
248 void EnableTreeDrag( sal_Bool b = sal_True );
249 void ExecuteContextMenu_Impl( const Point& rPos, Window* pWin );
250 void EnableExample_Impl( sal_uInt16 nId, sal_Bool bEnable );
251 SfxStyleFamily GetActualFamily() const;
252 String GetSelectedEntry() const;
253 SfxObjectShell* GetObjectShell() const { return pCurObjShell; }
255 virtual void PrepareDeleteAction(); // disable buttons, change button text, etc. when del is going to happen
257 inline sal_Bool CanEdit( void ) const { return bCanEdit; }
258 inline sal_Bool CanDel( void ) const { return bCanDel; }
259 inline sal_Bool CanNew( void ) const { return bCanNew; }
260 inline sal_Bool CanHide( void ) const { return bCanHide; }
261 inline sal_Bool CanShow( void ) const { return bCanShow; }
263 // normaly for derivates from SvTreeListBoxes, but in this case the dialog handles context menus
264 virtual PopupMenu* CreateContextMenu( void );
266 // converts from SFX_STYLE_FAMILY Ids to 1-5
267 static sal_uInt16 SfxFamilyIdToNId( SfxStyleFamily nFamily );
269 void SetAutomaticFilter();
272 class DropToolBox_Impl : public ToolBox, public DropTargetHelper
274 SfxTemplateDialog_Impl& rParent;
275 protected:
276 virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt );
277 virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt );
278 public:
279 DropToolBox_Impl(Window* pParent, SfxTemplateDialog_Impl* pTemplateDialog);
280 ~DropToolBox_Impl();
282 // class SfxTemplateDialog_Impl ------------------------------------------
284 class SfxTemplateDialog_Impl : public SfxCommonTemplateDialog_Impl
286 private:
287 friend class SfxTemplateControllerItem;
288 friend class SfxTemplateDialogWrapper;
289 friend class DropToolBox_Impl;
290 friend class SfxTemplatePanelControl;
292 Window* m_pFloat;
293 sal_Bool m_bZoomIn;
294 DropToolBox_Impl m_aActionTbL;
295 ToolBox m_aActionTbR;
297 DECL_LINK( ToolBoxLSelect, ToolBox * );
298 DECL_LINK( ToolBoxRSelect, ToolBox * );
299 DECL_LINK( ToolBoxRClick, ToolBox * );
300 DECL_LINK( MenuSelectHdl, Menu* );
302 protected:
303 virtual void Command( const CommandEvent& rMEvt );
304 virtual void EnableEdit( sal_Bool = sal_True );
305 virtual void EnableItem( sal_uInt16 nMesId, sal_Bool bCheck = sal_True );
306 virtual void CheckItem( sal_uInt16 nMesId, sal_Bool bCheck = sal_True );
307 virtual sal_Bool IsCheckedItem( sal_uInt16 nMesId );
308 virtual void LoadedFamilies();
309 virtual void InsertFamilyItem( sal_uInt16 nId, const SfxStyleFamilyItem* pIten );
310 virtual void EnableFamilyItem( sal_uInt16 nId, sal_Bool bEnabled = sal_True );
311 virtual void ClearFamilyList();
312 virtual void ReplaceUpdateButtonByMenu();
314 void Resize();
315 Size GetMinOutputSizePixel();
317 void updateFamilyImages();
318 void updateNonFamilyImages();
320 public:
321 friend class SfxTemplateDialog;
322 TYPEINFO();
324 SfxTemplateDialog_Impl( SfxBindings*, SfxTemplateDialog* pDlgWindow );
325 SfxTemplateDialog_Impl( SfxBindings*, SfxTemplatePanelControl* pDlgWindow );
326 ~SfxTemplateDialog_Impl();
328 void Initialize (void);
331 #endif // #ifndef _SFX_TEMPDLGI_HXX
334 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */