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 _SFXMNUMGR_HXX 28 #define _SFXMNUMGR_HXX 29 30 #include <stdarg.h> 31 32 #ifndef _MENU_HXX //autogen //wg. MENU_APPEND !!!! 33 #include <vcl/menu.hxx> 34 #endif 35 #include <tools/wintypes.hxx> 36 #include <tools/link.hxx> 37 #include <com/sun/star/embed/VerbDescriptor.hpp> 38 #include <com/sun/star/uno/Sequence.hxx> 39 40 #include <tools/stream.hxx> 41 #include <tools/resid.hxx> 42 #include <sfx2/sfx.hrc> 43 44 class SfxVirtualMenu; 45 class SfxPoolItem; 46 class SfxBindings; 47 class ResMgr; 48 class Menu; 49 class PopupMenu; 50 class SfxBindings; 51 class ResId; 52 class Point; 53 class SfxObjectShell; 54 class SfxModule; 55 class SfxViewFrame; 56 57 class SfxMenuManager 58 { 59 friend class SfxPopupMenuManager; 60 61 SfxVirtualMenu* pMenu; // das eigentliche Menu 62 SfxVirtualMenu* pOldMenu; // only while reconfiguring 63 sal_Bool bMenuBar; // Popup oder MenuBar 64 SfxBindings* pBindings; 65 ResMgr* pResMgr; 66 sal_uInt32 nType; 67 sal_Bool bAddClipboardFuncs : 1; 68 69 void Construct( SfxVirtualMenu& rMenu ); 70 71 protected: 72 SfxMenuManager( Menu*, SfxBindings& ); 73 SfxMenuManager( const ResId&, SfxBindings& ); 74 ~SfxMenuManager(); 75 sal_uInt16 GetItemPos( sal_uInt16 nId ); 76 sal_uInt32 GetType() { return nType; } 77 public: 78 79 void UseDefault(); 80 81 DECL_LINK( Select, Menu* ); 82 83 SfxVirtualMenu* GetMenu() const 84 { return pMenu; } 85 86 SfxBindings& GetBindings() { return *pBindings; } 87 const SfxBindings& GetBindings() const { return *pBindings; } 88 void SetResMgr(ResMgr* pMgr) {pResMgr = pMgr; } 89 ResMgr* GetResMgr() const { return pResMgr; } 90 void SetPopupMenu( sal_uInt16 nId, PopupMenu *pMenu ); 91 92 //#if 0 // _SOLAR__PRIVATE 93 void Construct_Impl( Menu* pMenu, sal_Bool bWithHelp ); 94 //#endif 95 }; 96 97 //-------------------------------------------------------------------- 98 99 class SAL_DLLPUBLIC_EXPORT SfxPopupMenuManager : public SfxMenuManager 100 { 101 private: 102 DECL_LINK( SelectHdl, void * ); 103 Menu* pSVMenu; 104 105 // when #i107205 gets fixed this one should be superfluous. 106 // But right now we want to avoid the memory leak that would otherwise occur, 107 // if we don't delete the pointer that got created in SfxPopupMenuManager::Popup 108 static PopupMenu * pStaticThesSubMenu; 109 110 // only declared, but not defined: don't allow copying 111 SfxPopupMenuManager( const SfxPopupMenuManager& ); 112 SfxPopupMenuManager& operator=( const SfxPopupMenuManager& ); 113 114 public: 115 SfxPopupMenuManager( const ResId&, SfxBindings& ); 116 SfxPopupMenuManager( PopupMenu*, SfxBindings& ); 117 ~SfxPopupMenuManager(); 118 static void ExecutePopup( const ResId&, SfxViewFrame* pViewFrame, const Point& rPoint, Window* pWindow ); 119 // @deprecated!! 120 // Don't use this method any longer. The whole class will be removed in the future. 121 // Changing code which relies on Popup would need much more effort. 122 // Please contact cd@openoffice.org if you have questions or need help 123 static SfxPopupMenuManager* Popup( const ResId& rResId, SfxViewFrame* pFrame,const Point& rPoint, Window* pWindow ); 124 125 sal_uInt16 Execute( const Point& rPos, Window *pWindow ); 126 sal_uInt16 Execute( const Point& rPoint, Window* pWindow, va_list pArgs, const SfxPoolItem *pArg1 ); 127 sal_uInt16 Execute( const Point& rPoint, Window* pWindow, const SfxPoolItem *pArg1 ... ); 128 129 // @deprecated (start)!! 130 // Don't use these methods any longer. The whole class will be removed in the future. 131 // Changing code which relies on these methods would need much more effort! 132 // Please contact cd@openoffice.org if you have questions or need help 133 void StartInsert(); 134 void EndInsert(); 135 void CheckItem( sal_uInt16, sal_Bool ); 136 void RemoveItem( sal_uInt16 ); 137 void InsertItem( sal_uInt16, const String&, MenuItemBits, const rtl::OString& rHelpId, 138 sal_uInt16 nPos = MENU_APPEND ); 139 void InsertSeparator( sal_uInt16 nPos = MENU_APPEND ); 140 // @deprecated (end) 141 142 void RemoveDisabledEntries(); 143 void AddClipboardFunctions(); 144 Menu* GetSVMenu(); 145 }; 146 147 #endif // #ifndef _SFXMNUMGR_HXX 148 149