1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: templdgi.hxx,v $
10 * $Revision: 1.18.46.1 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
30 #ifndef _SFX_TEMPDLGI_HXX
31 #define _SFX_TEMPDLGI_HXX
33 class SfxTemplateControllerItem
;
35 #ifndef _BUTTON_HXX //autogen
36 #include <vcl/button.hxx>
38 #ifndef _TOOLBOX_HXX //autogen
39 #include <vcl/toolbox.hxx>
41 #ifndef _LSTBOX_HXX //autogen
42 #include <vcl/lstbox.hxx>
44 #include <svtools/lstner.hxx>
45 #include <svtools/svtreebx.hxx>
46 #include <svtools/eitem.hxx>
48 #define _SVSTDARR_USHORTS
49 #include <svtools/svstdarr.hxx> // SvUShorts
51 #include <rsc/rscsfx.hxx>
52 #include <tools/rtti.hxx>
54 #include <sfx2/childwin.hxx>
55 #include <sfx2/templdlg.hxx>
57 class SfxStyleFamilies
;
58 class SfxStyleFamilyItem
;
59 class SfxTemplateItem
;
61 class SfxStyleSheetBasePool
;
63 class StyleTreeListBox_Impl
;
64 class SfxTemplateDialog_Impl
;
65 class SfxCommonTemplateDialog_Impl
;
66 class SfxTemplateDialogWrapper
;
67 class SfxDockingWindow
;
69 namespace com
{ namespace sun
{ namespace star
{ namespace frame
{ class XModuleManager
; } } } }
71 // class DropListBox_Impl ------------------------------------------------
73 class DropListBox_Impl
: public SvTreeListBox
76 DECL_LINK( OnAsyncExecuteDrop
, SvLBoxEntry
* );
77 DECL_LINK( OnAsyncExecuteError
, void* );
80 SfxCommonTemplateDialog_Impl
* pDialog
;
84 DropListBox_Impl( Window
* pParent
, const ResId
& rId
, SfxCommonTemplateDialog_Impl
* pD
) :
85 SvTreeListBox( pParent
, rId
), pDialog( pD
) {}
86 DropListBox_Impl( Window
* pParent
, WinBits nWinBits
, SfxCommonTemplateDialog_Impl
* pD
) :
87 SvTreeListBox( pParent
, nWinBits
), pDialog( pD
) {}
89 virtual void MouseButtonDown( const MouseEvent
& rMEvt
);
90 virtual sal_Int8
AcceptDrop( const AcceptDropEvent
& rEvt
);
91 using SvLBox::ExecuteDrop
;
92 virtual sal_Int8
ExecuteDrop( const ExecuteDropEvent
& rEvt
);
94 USHORT
GetModifier() const { return nModifier
; }
96 virtual long Notify( NotifyEvent
& rNEvt
);
99 // class SfxActionListBox ------------------------------------------------
101 class SfxActionListBox
: public DropListBox_Impl
105 SfxActionListBox( SfxCommonTemplateDialog_Impl
* pParent
, WinBits nWinBits
);
106 SfxActionListBox( SfxCommonTemplateDialog_Impl
* pParent
, const ResId
&rResId
);
108 virtual PopupMenu
* CreateContextMenu( void );
111 // class SfxCommonTemplateDialog_Impl ------------------------------------
117 Deleted() : bDead(false) {}
119 inline bool operator()() { return bDead
; }
122 class SfxCommonTemplateDialog_Impl
: public SfxListener
125 class ISfxTemplateCommon_Impl
: public ISfxTemplateCommon
128 SfxCommonTemplateDialog_Impl
* pDialog
;
130 ISfxTemplateCommon_Impl( SfxCommonTemplateDialog_Impl
* pDialogP
) : pDialog( pDialogP
) {}
131 virtual SfxStyleFamily
GetActualFamily() const { return pDialog
->GetActualFamily(); }
132 virtual String
GetSelectedEntry() const { return pDialog
->GetSelectedEntry(); }
135 ISfxTemplateCommon_Impl aISfxTemplateCommon
;
138 void ClearResource();
141 #define MAX_FAMILIES 5
142 #define COUNT_BOUND_FUNC 13
144 #define UPDATE_FAMILY_LIST 0x0001
145 #define UPDATE_FAMILY 0x0002
147 friend class DropListBox_Impl
;
148 friend class SfxTemplateControllerItem
;
149 friend class SfxTemplateDialogWrapper
;
151 SfxBindings
* pBindings
;
152 SfxTemplateControllerItem
* pBoundItems
[COUNT_BOUND_FUNC
];
158 ResId
* m_pStyleFamiliesId
;
159 SfxStyleFamilies
* pStyleFamilies
;
160 SfxTemplateItem
* pFamilyState
[MAX_FAMILIES
];
161 SfxStyleSheetBasePool
* pStyleSheetPool
;
162 SvTreeListBox
* pTreeBox
;
163 SfxObjectShell
* pCurObjShell
;
164 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XModuleManager
>
168 SfxActionListBox aFmtLb
;
172 USHORT nActFamily
; // Id in der ToolBox = Position - 1
173 USHORT nActFilter
; // FilterIdx
174 USHORT nAppFilter
; // Filter, den die Applikation gesetzt hat (fuer automatisch)
185 bNewByExampleDisabled
:1,
186 bUpdateByExampleDisabled
:1,
191 DECL_LINK( FilterSelectHdl
, ListBox
* );
192 DECL_LINK( FmtSelectHdl
, SvTreeListBox
* );
193 DECL_LINK( ApplyHdl
, Control
* );
194 DECL_LINK( DropHdl
, StyleTreeListBox_Impl
* );
195 DECL_LINK( TimeOut
, Timer
* );
198 virtual void EnableItem( USHORT
/*nMesId*/, BOOL
/*bCheck*/ = TRUE
) {}
199 virtual void CheckItem( USHORT
/*nMesId*/, BOOL
/*bCheck*/ = TRUE
) {}
200 virtual BOOL
IsCheckedItem( USHORT
/*nMesId*/ ) { return TRUE
; }
201 virtual void LoadedFamilies() {}
202 virtual void Update() { UpdateStyles_Impl(UPDATE_FAMILY_LIST
); }
203 virtual void InvalidateBindings();
204 virtual void InsertFamilyItem( USHORT nId
, const SfxStyleFamilyItem
* pIten
) = 0;
205 virtual void EnableFamilyItem( USHORT nId
, BOOL bEnabled
= TRUE
) = 0;
206 virtual void ClearFamilyList() = 0;
207 virtual void ReplaceUpdateButtonByMenu();
209 void NewHdl( void* );
210 void EditHdl( void* );
211 void DeleteHdl( void* );
213 BOOL
Execute_Impl( USHORT nId
, const String
& rStr
, const String
& rRefStr
,
214 USHORT nFamily
, USHORT nMask
= 0,
215 USHORT
* pIdx
= NULL
, const USHORT
* pModifier
= NULL
);
217 void UpdateStyles_Impl(USHORT nFlags
);
218 const SfxStyleFamilyItem
* GetFamilyItem_Impl() const;
219 BOOL
IsInitialized() { return nActFamily
!= 0xffff; }
224 void FilterSelect( USHORT nFilterIdx
, BOOL bForce
= FALSE
);
225 void SetFamilyState( USHORT nSlotId
, const SfxTemplateItem
* );
226 void SetWaterCanState( const SfxBoolItem
* pItem
);
228 void SelectStyle( const String
& rStyle
);
229 BOOL
HasSelectedStyle() const;
232 void UpdateFamily_Impl();
234 // In welchem FamilyState muss ich nachsehen, um die Info der i-ten
235 // Family in der pStyleFamilies zu bekommen.
236 USHORT
StyleNrToInfoOffset( USHORT i
);
237 USHORT
InfoOffsetToStyleNr( USHORT i
);
239 void Notify( SfxBroadcaster
& rBC
, const SfxHint
& rHint
);
241 void FamilySelect( USHORT nId
);
242 void SetFamily( USHORT nId
);
243 void ActionSelect( USHORT nId
);
245 sal_Int32
LoadFactoryStyleFilter( SfxObjectShell
* i_pObjSh
);
246 void SaveFactoryStyleFilter( SfxObjectShell
* i_pObjSh
, sal_Int32 i_nFilter
);
251 SfxCommonTemplateDialog_Impl( SfxBindings
* pB
, SfxDockingWindow
* );
252 SfxCommonTemplateDialog_Impl( SfxBindings
* pB
, ModalDialog
* );
253 ~SfxCommonTemplateDialog_Impl();
255 DECL_LINK( MenuSelectHdl
, Menu
* );
257 virtual void EnableEdit( BOOL b
= TRUE
) { bCanEdit
= b
; }
258 virtual void EnableDel( BOOL b
= TRUE
) { bCanDel
= b
; }
259 virtual void EnableNew( BOOL b
= TRUE
) { bCanNew
= b
; }
261 ISfxTemplateCommon
* GetISfxTemplateCommon() { return &aISfxTemplateCommon
; }
262 Window
* GetWindow() { return pWindow
; }
264 void EnableTreeDrag( BOOL b
= TRUE
);
265 void ExecuteContextMenu_Impl( const Point
& rPos
, Window
* pWin
);
266 void EnableExample_Impl( USHORT nId
, BOOL bEnable
);
267 SfxStyleFamily
GetActualFamily() const;
268 String
GetSelectedEntry() const;
269 SfxObjectShell
* GetObjectShell() const { return pCurObjShell
; }
271 virtual void PrepareDeleteAction(); // disable buttons, change button text, etc. when del is going to happen
273 inline BOOL
CanEdit( void ) const { return bCanEdit
; }
274 inline BOOL
CanDel( void ) const { return bCanDel
; }
275 inline BOOL
CanNew( void ) const { return bCanNew
; }
277 // normaly for derivates from SvTreeListBoxes, but in this case the dialog handles context menus
278 virtual PopupMenu
* CreateContextMenu( void );
280 // Rechnet von den SFX_STYLE_FAMILY Ids auf 1-5 um
281 static USHORT
SfxFamilyIdToNId( SfxStyleFamily nFamily
);
283 void SetAutomaticFilter();
285 /* -----------------10.12.2003 11:42-----------------
287 --------------------------------------------------*/
289 class DropToolBox_Impl
: public ToolBox
, public DropTargetHelper
291 SfxTemplateDialog_Impl
& rParent
;
293 virtual sal_Int8
AcceptDrop( const AcceptDropEvent
& rEvt
);
294 virtual sal_Int8
ExecuteDrop( const ExecuteDropEvent
& rEvt
);
296 DropToolBox_Impl(Window
* pParent
, SfxTemplateDialog_Impl
* pTemplateDialog
);
299 // class SfxTemplateDialog_Impl ------------------------------------------
301 class SfxTemplateDialog_Impl
: public SfxCommonTemplateDialog_Impl
304 friend class SfxTemplateControllerItem
;
305 friend class SfxTemplateDialogWrapper
;
306 friend class DropToolBox_Impl
;
308 SfxTemplateDialog
* m_pFloat
;
310 DropToolBox_Impl m_aActionTbL
;
311 ToolBox m_aActionTbR
;
313 DECL_LINK( ToolBoxLSelect
, ToolBox
* );
314 DECL_LINK( ToolBoxRSelect
, ToolBox
* );
315 DECL_LINK( ToolBoxRClick
, ToolBox
* );
316 DECL_LINK( MenuSelectHdl
, Menu
* );
319 virtual void Command( const CommandEvent
& rMEvt
);
320 virtual void EnableEdit( BOOL
= TRUE
);
321 virtual void EnableItem( USHORT nMesId
, BOOL bCheck
= TRUE
);
322 virtual void CheckItem( USHORT nMesId
, BOOL bCheck
= TRUE
);
323 virtual BOOL
IsCheckedItem( USHORT nMesId
);
324 virtual void LoadedFamilies();
325 virtual void InsertFamilyItem( USHORT nId
, const SfxStyleFamilyItem
* pIten
);
326 virtual void EnableFamilyItem( USHORT nId
, BOOL bEnabled
= TRUE
);
327 virtual void ClearFamilyList();
328 virtual void ReplaceUpdateButtonByMenu();
331 Size
GetMinOutputSizePixel();
333 void updateFamilyImages();
334 void updateNonFamilyImages();
337 friend class SfxTemplateDialog
;
340 SfxTemplateDialog_Impl( Window
* pParent
, SfxBindings
*, SfxTemplateDialog
* pWindow
);
341 ~SfxTemplateDialog_Impl();
344 // class SfxTemplateCatalog_Impl -----------------------------------------
346 class SfxTemplateCatalog_Impl
: public SfxCommonTemplateDialog_Impl
349 friend class SfxTemplateControllerItem
;
350 friend class SfxCommonTemplateDialog_Impl
;
354 CancelButton aCancelBtn
;
356 PushButton aChangeBtn
;
361 SfxTemplateCatalog
* pReal
;
363 SfxModalDefParentHelper aHelper
;
366 virtual void EnableItem( USHORT nMesId
, BOOL bCheck
= TRUE
);
367 virtual void CheckItem( USHORT nMesId
, BOOL bCheck
= TRUE
);
368 virtual BOOL
IsCheckedItem( USHORT nMesId
);
369 virtual void InsertFamilyItem( USHORT nId
, const SfxStyleFamilyItem
* pIten
);
370 virtual void EnableFamilyItem( USHORT nId
, BOOL bEnabled
= TRUE
);
371 virtual void ClearFamilyList();
372 virtual void EnableEdit( BOOL
= TRUE
);
373 virtual void EnableDel( BOOL
= TRUE
);
374 virtual void EnableNew( BOOL
= TRUE
);
376 using SfxCommonTemplateDialog_Impl::NewHdl
;
377 DECL_LINK( FamListSelect
, ListBox
* );
378 DECL_LINK( OkHdl
, Button
* );
379 DECL_LINK( CancelHdl
, Button
* );
380 DECL_LINK( NewHdl
, Button
* );
381 DECL_LINK( ChangeHdl
, Button
* );
382 DECL_LINK( DelHdl
, Button
* );
383 DECL_LINK( OrgHdl
, Button
* );
387 SfxTemplateCatalog_Impl( Window
* pParent
, SfxBindings
*, SfxTemplateCatalog
* pWindow
);
388 ~SfxTemplateCatalog_Impl();
390 friend class SfxTemplateCatalog
;
392 virtual void PrepareDeleteAction();
395 #endif // #ifndef _SFX_TEMPDLGI_HXX