1 /************************************************************************* 2 * 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * Copyright 2000, 2010 Oracle and/or its affiliates. 6 * 7 * OpenOffice.org - a multi-platform office productivity suite 8 * 9 * This file is part of OpenOffice.org. 10 * 11 * OpenOffice.org is free software: you can redistribute it and/or modify 12 * it under the terms of the GNU Lesser General Public License version 3 13 * only, as published by the Free Software Foundation. 14 * 15 * OpenOffice.org is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU Lesser General Public License version 3 for more details 19 * (a copy is included in the LICENSE file that accompanied this code). 20 * 21 * You should have received a copy of the GNU Lesser General Public License 22 * version 3 along with OpenOffice.org. If not, see 23 * <http://www.openoffice.org/license.html> 24 * for a copy of the LGPLv3 License. 25 * 26 ************************************************************************/ 27 #ifndef _SFX_TEMPDLGI_HXX 28 #define _SFX_TEMPDLGI_HXX 29 30 class SfxTemplateControllerItem; 31 32 #ifndef _BUTTON_HXX //autogen 33 #include <vcl/button.hxx> 34 #endif 35 #ifndef _TOOLBOX_HXX //autogen 36 #include <vcl/toolbox.hxx> 37 #endif 38 #ifndef _LSTBOX_HXX //autogen 39 #include <vcl/lstbox.hxx> 40 #endif 41 #include <svl/lstner.hxx> 42 #include <svtools/svtreebx.hxx> 43 #include <svl/eitem.hxx> 44 45 #define _SVSTDARR_USHORTS 46 #include <svl/svstdarr.hxx> // SvUShorts 47 48 #include <rsc/rscsfx.hxx> 49 #include <tools/rtti.hxx> 50 51 #include <sfx2/childwin.hxx> 52 #include <sfx2/templdlg.hxx> 53 54 class SfxStyleFamilies; 55 class SfxStyleFamilyItem; 56 class SfxTemplateItem; 57 class SfxBindings; 58 class SfxStyleSheetBasePool; 59 class SvTreeListBox ; 60 class StyleTreeListBox_Impl; 61 class SfxTemplateDialog_Impl; 62 class SfxCommonTemplateDialog_Impl; 63 class SfxTemplateDialogWrapper; 64 class SfxDockingWindow; 65 66 namespace com { namespace sun { namespace star { namespace frame { class XModuleManager; } } } } 67 68 // class DropListBox_Impl ------------------------------------------------ 69 70 class DropListBox_Impl : public SvTreeListBox 71 { 72 private: 73 DECL_LINK( OnAsyncExecuteDrop, SvLBoxEntry* ); 74 DECL_LINK( OnAsyncExecuteError, void* ); 75 76 protected: 77 SfxCommonTemplateDialog_Impl* pDialog; 78 sal_uInt16 nModifier; 79 80 public: 81 DropListBox_Impl( Window* pParent, const ResId& rId, SfxCommonTemplateDialog_Impl* pD ) : 82 SvTreeListBox( pParent, rId ), pDialog( pD ) {} 83 DropListBox_Impl( Window* pParent, WinBits nWinBits, SfxCommonTemplateDialog_Impl* pD ) : 84 SvTreeListBox( pParent, nWinBits ), pDialog( pD ) {} 85 86 virtual void MouseButtonDown( const MouseEvent& rMEvt ); 87 virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ); 88 using SvLBox::ExecuteDrop; 89 virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ); 90 91 sal_uInt16 GetModifier() const { return nModifier; } 92 93 virtual long Notify( NotifyEvent& rNEvt ); 94 }; 95 96 // class SfxActionListBox ------------------------------------------------ 97 98 class SfxActionListBox : public DropListBox_Impl 99 { 100 protected: 101 public: 102 SfxActionListBox( SfxCommonTemplateDialog_Impl* pParent, WinBits nWinBits ); 103 SfxActionListBox( SfxCommonTemplateDialog_Impl* pParent, const ResId &rResId ); 104 105 virtual PopupMenu* CreateContextMenu( void ); 106 }; 107 108 // class SfxCommonTemplateDialog_Impl ------------------------------------ 109 110 struct Deleted 111 { 112 bool bDead; 113 114 Deleted() : bDead(false) {} 115 116 inline bool operator()() { return bDead; } 117 }; 118 119 class SfxCommonTemplateDialog_Impl : public SfxListener 120 { 121 private: 122 class ISfxTemplateCommon_Impl : public ISfxTemplateCommon 123 { 124 private: 125 SfxCommonTemplateDialog_Impl* pDialog; 126 public: 127 ISfxTemplateCommon_Impl( SfxCommonTemplateDialog_Impl* pDialogP ) : pDialog( pDialogP ) {} 128 virtual SfxStyleFamily GetActualFamily() const { return pDialog->GetActualFamily(); } 129 virtual String GetSelectedEntry() const { return pDialog->GetSelectedEntry(); } 130 }; 131 132 ISfxTemplateCommon_Impl aISfxTemplateCommon; 133 134 void ReadResource(); 135 void ClearResource(); 136 137 protected: 138 #define MAX_FAMILIES 5 139 #define COUNT_BOUND_FUNC 13 140 141 #define UPDATE_FAMILY_LIST 0x0001 142 #define UPDATE_FAMILY 0x0002 143 144 friend class DropListBox_Impl; 145 friend class SfxTemplateControllerItem; 146 friend class SfxTemplateDialogWrapper; 147 148 SfxBindings* pBindings; 149 SfxTemplateControllerItem* pBoundItems[COUNT_BOUND_FUNC]; 150 151 Window* pWindow; 152 SfxModule* pModule; 153 Timer* pTimer; 154 155 ResId* m_pStyleFamiliesId; 156 SfxStyleFamilies* pStyleFamilies; 157 SfxTemplateItem* pFamilyState[MAX_FAMILIES]; 158 SfxStyleSheetBasePool* pStyleSheetPool; 159 SvTreeListBox* pTreeBox; 160 SfxObjectShell* pCurObjShell; 161 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModuleManager > 162 xModuleManager; 163 Deleted* pbDeleted; 164 165 SfxActionListBox aFmtLb; 166 ListBox aFilterLb; 167 Size aSize; 168 169 sal_uInt16 nActFamily; // Id in der ToolBox = Position - 1 170 sal_uInt16 nActFilter; // FilterIdx 171 sal_uInt16 nAppFilter; // Filter, den die Applikation gesetzt hat (fuer automatisch) 172 173 sal_Bool bDontUpdate :1, 174 bIsWater :1, 175 bEnabled :1, 176 bUpdate :1, 177 bUpdateFamily :1, 178 bCanEdit :1, 179 bCanDel :1, 180 bCanNew :1, 181 bWaterDisabled :1, 182 bNewByExampleDisabled :1, 183 bUpdateByExampleDisabled:1, 184 bTreeDrag :1, 185 bHierarchical :1, 186 bBindingUpdate :1; 187 188 DECL_LINK( FilterSelectHdl, ListBox * ); 189 DECL_LINK( FmtSelectHdl, SvTreeListBox * ); 190 DECL_LINK( ApplyHdl, Control * ); 191 DECL_LINK( DropHdl, StyleTreeListBox_Impl * ); 192 DECL_LINK( TimeOut, Timer * ); 193 194 195 virtual void EnableItem( sal_uInt16 /*nMesId*/, sal_Bool /*bCheck*/ = sal_True ) {} 196 virtual void CheckItem( sal_uInt16 /*nMesId*/, sal_Bool /*bCheck*/ = sal_True ) {} 197 virtual sal_Bool IsCheckedItem( sal_uInt16 /*nMesId*/ ) { return sal_True; } 198 virtual void LoadedFamilies() {} 199 virtual void Update() { UpdateStyles_Impl(UPDATE_FAMILY_LIST); } 200 virtual void InvalidateBindings(); 201 virtual void InsertFamilyItem( sal_uInt16 nId, const SfxStyleFamilyItem* pIten ) = 0; 202 virtual void EnableFamilyItem( sal_uInt16 nId, sal_Bool bEnabled = sal_True ) = 0; 203 virtual void ClearFamilyList() = 0; 204 virtual void ReplaceUpdateButtonByMenu(); 205 206 void NewHdl( void* ); 207 void EditHdl( void* ); 208 void DeleteHdl( void* ); 209 210 sal_Bool Execute_Impl( sal_uInt16 nId, const String& rStr, const String& rRefStr, 211 sal_uInt16 nFamily, sal_uInt16 nMask = 0, 212 sal_uInt16* pIdx = NULL, const sal_uInt16* pModifier = NULL ); 213 214 void UpdateStyles_Impl(sal_uInt16 nFlags); 215 const SfxStyleFamilyItem* GetFamilyItem_Impl() const; 216 sal_Bool IsInitialized() { return nActFamily != 0xffff; } 217 void ResetFocus(); 218 void EnableDelete(); 219 void Initialize(); 220 221 void FilterSelect( sal_uInt16 nFilterIdx, sal_Bool bForce = sal_False ); 222 void SetFamilyState( sal_uInt16 nSlotId, const SfxTemplateItem* ); 223 void SetWaterCanState( const SfxBoolItem* pItem ); 224 225 void SelectStyle( const String& rStyle ); 226 sal_Bool HasSelectedStyle() const; 227 void FillTreeBox(); 228 void Update_Impl(); 229 void UpdateFamily_Impl(); 230 231 // In welchem FamilyState muss ich nachsehen, um die Info der i-ten 232 // Family in der pStyleFamilies zu bekommen. 233 sal_uInt16 StyleNrToInfoOffset( sal_uInt16 i ); 234 sal_uInt16 InfoOffsetToStyleNr( sal_uInt16 i ); 235 236 void Notify( SfxBroadcaster& rBC, const SfxHint& rHint ); 237 238 void FamilySelect( sal_uInt16 nId ); 239 void SetFamily( sal_uInt16 nId ); 240 void ActionSelect( sal_uInt16 nId ); 241 242 sal_Int32 LoadFactoryStyleFilter( SfxObjectShell* i_pObjSh ); 243 void SaveFactoryStyleFilter( SfxObjectShell* i_pObjSh, sal_Int32 i_nFilter ); 244 245 public: 246 TYPEINFO(); 247 248 SfxCommonTemplateDialog_Impl( SfxBindings* pB, SfxDockingWindow* ); 249 SfxCommonTemplateDialog_Impl( SfxBindings* pB, ModalDialog* ); 250 ~SfxCommonTemplateDialog_Impl(); 251 252 DECL_LINK( MenuSelectHdl, Menu * ); 253 254 virtual void EnableEdit( sal_Bool b = sal_True ) { bCanEdit = b; } 255 virtual void EnableDel( sal_Bool b = sal_True ) { bCanDel = b; } 256 virtual void EnableNew( sal_Bool b = sal_True ) { bCanNew = b; } 257 258 ISfxTemplateCommon* GetISfxTemplateCommon() { return &aISfxTemplateCommon; } 259 Window* GetWindow() { return pWindow; } 260 261 void EnableTreeDrag( sal_Bool b = sal_True ); 262 void ExecuteContextMenu_Impl( const Point& rPos, Window* pWin ); 263 void EnableExample_Impl( sal_uInt16 nId, sal_Bool bEnable ); 264 SfxStyleFamily GetActualFamily() const; 265 String GetSelectedEntry() const; 266 SfxObjectShell* GetObjectShell() const { return pCurObjShell; } 267 268 virtual void PrepareDeleteAction(); // disable buttons, change button text, etc. when del is going to happen 269 270 inline sal_Bool CanEdit( void ) const { return bCanEdit; } 271 inline sal_Bool CanDel( void ) const { return bCanDel; } 272 inline sal_Bool CanNew( void ) const { return bCanNew; } 273 274 // normaly for derivates from SvTreeListBoxes, but in this case the dialog handles context menus 275 virtual PopupMenu* CreateContextMenu( void ); 276 277 // Rechnet von den SFX_STYLE_FAMILY Ids auf 1-5 um 278 static sal_uInt16 SfxFamilyIdToNId( SfxStyleFamily nFamily ); 279 280 void SetAutomaticFilter(); 281 }; 282 /* -----------------10.12.2003 11:42----------------- 283 284 --------------------------------------------------*/ 285 286 class DropToolBox_Impl : public ToolBox, public DropTargetHelper 287 { 288 SfxTemplateDialog_Impl& rParent; 289 protected: 290 virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ); 291 virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ); 292 public: 293 DropToolBox_Impl(Window* pParent, SfxTemplateDialog_Impl* pTemplateDialog); 294 ~DropToolBox_Impl(); 295 }; 296 // class SfxTemplateDialog_Impl ------------------------------------------ 297 298 class SfxTemplateDialog_Impl : public SfxCommonTemplateDialog_Impl 299 { 300 private: 301 friend class SfxTemplateControllerItem; 302 friend class SfxTemplateDialogWrapper; 303 friend class DropToolBox_Impl; 304 305 SfxTemplateDialog* m_pFloat; 306 sal_Bool m_bZoomIn; 307 DropToolBox_Impl m_aActionTbL; 308 ToolBox m_aActionTbR; 309 310 DECL_LINK( ToolBoxLSelect, ToolBox * ); 311 DECL_LINK( ToolBoxRSelect, ToolBox * ); 312 DECL_LINK( ToolBoxRClick, ToolBox * ); 313 DECL_LINK( MenuSelectHdl, Menu* ); 314 315 protected: 316 virtual void Command( const CommandEvent& rMEvt ); 317 virtual void EnableEdit( sal_Bool = sal_True ); 318 virtual void EnableItem( sal_uInt16 nMesId, sal_Bool bCheck = sal_True ); 319 virtual void CheckItem( sal_uInt16 nMesId, sal_Bool bCheck = sal_True ); 320 virtual sal_Bool IsCheckedItem( sal_uInt16 nMesId ); 321 virtual void LoadedFamilies(); 322 virtual void InsertFamilyItem( sal_uInt16 nId, const SfxStyleFamilyItem* pIten ); 323 virtual void EnableFamilyItem( sal_uInt16 nId, sal_Bool bEnabled = sal_True ); 324 virtual void ClearFamilyList(); 325 virtual void ReplaceUpdateButtonByMenu(); 326 327 void Resize(); 328 Size GetMinOutputSizePixel(); 329 330 void updateFamilyImages(); 331 void updateNonFamilyImages(); 332 333 public: 334 friend class SfxTemplateDialog; 335 TYPEINFO(); 336 337 SfxTemplateDialog_Impl( Window* pParent, SfxBindings*, SfxTemplateDialog* pWindow ); 338 ~SfxTemplateDialog_Impl(); 339 }; 340 341 // class SfxTemplateCatalog_Impl ----------------------------------------- 342 343 class SfxTemplateCatalog_Impl : public SfxCommonTemplateDialog_Impl 344 { 345 private: 346 friend class SfxTemplateControllerItem; 347 friend class SfxCommonTemplateDialog_Impl; 348 349 ListBox aFamList; 350 OKButton aOkBtn; 351 CancelButton aCancelBtn; 352 PushButton aNewBtn; 353 PushButton aChangeBtn; 354 PushButton aDelBtn; 355 PushButton aOrgBtn; 356 HelpButton aHelpBtn; 357 358 SfxTemplateCatalog* pReal; 359 SvUShorts aFamIds; 360 SfxModalDefParentHelper aHelper; 361 362 protected: 363 virtual void EnableItem( sal_uInt16 nMesId, sal_Bool bCheck = sal_True ); 364 virtual void CheckItem( sal_uInt16 nMesId, sal_Bool bCheck = sal_True ); 365 virtual sal_Bool IsCheckedItem( sal_uInt16 nMesId ); 366 virtual void InsertFamilyItem( sal_uInt16 nId, const SfxStyleFamilyItem* pIten ); 367 virtual void EnableFamilyItem( sal_uInt16 nId, sal_Bool bEnabled = sal_True ); 368 virtual void ClearFamilyList(); 369 virtual void EnableEdit( sal_Bool = sal_True ); 370 virtual void EnableDel( sal_Bool = sal_True ); 371 virtual void EnableNew( sal_Bool = sal_True ); 372 373 using SfxCommonTemplateDialog_Impl::NewHdl; 374 DECL_LINK( FamListSelect, ListBox * ); 375 DECL_LINK( OkHdl, Button * ); 376 DECL_LINK( CancelHdl, Button * ); 377 DECL_LINK( NewHdl, Button * ); 378 DECL_LINK( ChangeHdl, Button * ); 379 DECL_LINK( DelHdl, Button * ); 380 DECL_LINK( OrgHdl, Button * ); 381 382 public: 383 TYPEINFO(); 384 SfxTemplateCatalog_Impl( Window* pParent, SfxBindings*, SfxTemplateCatalog* pWindow ); 385 ~SfxTemplateCatalog_Impl(); 386 387 friend class SfxTemplateCatalog; 388 389 virtual void PrepareDeleteAction(); 390 }; 391 392 #endif // #ifndef _SFX_TEMPDLGI_HXX 393 394 395