1 /************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance 9 * with the License. You may obtain a copy of the License at 10 * 11 * http://www.apache.org/licenses/LICENSE-2.0 12 * 13 * Unless required by applicable law or agreed to in writing, 14 * software distributed under the License is distributed on an 15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 * KIND, either express or implied. See the License for the 17 * specific language governing permissions and limitations 18 * under the License. 19 * 20 *************************************************************/ 21 22 23 #ifndef _SFXMNUMGR_HXX 24 #define _SFXMNUMGR_HXX 25 26 #include <stdarg.h> 27 28 #ifndef _MENU_HXX //autogen //wg. MENU_APPEND !!!! 29 #include <vcl/menu.hxx> 30 #endif 31 #include <tools/wintypes.hxx> 32 #include <tools/link.hxx> 33 #include <com/sun/star/embed/VerbDescriptor.hpp> 34 #include <com/sun/star/uno/Sequence.hxx> 35 36 #include <tools/stream.hxx> 37 #include <tools/resid.hxx> 38 #include <sfx2/sfx.hrc> 39 40 class SfxVirtualMenu; 41 class SfxPoolItem; 42 class SfxBindings; 43 class ResMgr; 44 class Menu; 45 class PopupMenu; 46 class SfxBindings; 47 class ResId; 48 class Point; 49 class SfxObjectShell; 50 class SfxModule; 51 class SfxViewFrame; 52 53 class SfxMenuManager 54 { 55 friend class SfxPopupMenuManager; 56 57 SfxVirtualMenu* pMenu; // das eigentliche Menu 58 SfxVirtualMenu* pOldMenu; // only while reconfiguring 59 sal_Bool bMenuBar; // Popup oder MenuBar 60 SfxBindings* pBindings; 61 ResMgr* pResMgr; 62 sal_uInt32 nType; 63 sal_Bool bAddClipboardFuncs : 1; 64 65 void Construct( SfxVirtualMenu& rMenu ); 66 67 protected: 68 SfxMenuManager( Menu*, SfxBindings& ); 69 SfxMenuManager( const ResId&, SfxBindings& ); 70 ~SfxMenuManager(); 71 sal_uInt16 GetItemPos( sal_uInt16 nId ); GetType()72 sal_uInt32 GetType() { return nType; } 73 public: 74 75 void UseDefault(); 76 77 DECL_LINK( Select, Menu* ); 78 GetMenu() const79 SfxVirtualMenu* GetMenu() const 80 { return pMenu; } 81 GetBindings()82 SfxBindings& GetBindings() { return *pBindings; } GetBindings() const83 const SfxBindings& GetBindings() const { return *pBindings; } SetResMgr(ResMgr * pMgr)84 void SetResMgr(ResMgr* pMgr) {pResMgr = pMgr; } GetResMgr() const85 ResMgr* GetResMgr() const { return pResMgr; } 86 void SetPopupMenu( sal_uInt16 nId, PopupMenu *pMenu ); 87 88 //#if 0 // _SOLAR__PRIVATE 89 void Construct_Impl( Menu* pMenu, sal_Bool bWithHelp ); 90 //#endif 91 }; 92 93 //-------------------------------------------------------------------- 94 95 class SAL_DLLPUBLIC_EXPORT SfxPopupMenuManager : public SfxMenuManager 96 { 97 private: 98 DECL_LINK( SelectHdl, void * ); 99 Menu* pSVMenu; 100 101 // when #i107205 gets fixed this one should be superfluous. 102 // But right now we want to avoid the memory leak that would otherwise occur, 103 // if we don't delete the pointer that got created in SfxPopupMenuManager::Popup 104 static PopupMenu * pStaticThesSubMenu; 105 106 // only declared, but not defined: don't allow copying 107 SfxPopupMenuManager( const SfxPopupMenuManager& ); 108 SfxPopupMenuManager& operator=( const SfxPopupMenuManager& ); 109 110 public: 111 SfxPopupMenuManager( const ResId&, SfxBindings& ); 112 SfxPopupMenuManager( PopupMenu*, SfxBindings& ); 113 ~SfxPopupMenuManager(); 114 static void ExecutePopup( const ResId&, SfxViewFrame* pViewFrame, const Point& rPoint, Window* pWindow ); 115 // @deprecated!! 116 // Don't use this method any longer. The whole class will be removed in the future. 117 // Changing code which relies on Popup would need much more effort. 118 // Please contact cd@openoffice.org if you have questions or need help 119 static SfxPopupMenuManager* Popup( const ResId& rResId, SfxViewFrame* pFrame,const Point& rPoint, Window* pWindow ); 120 121 sal_uInt16 Execute( const Point& rPos, Window *pWindow ); 122 sal_uInt16 Execute( const Point& rPoint, Window* pWindow, va_list pArgs, const SfxPoolItem *pArg1 ); 123 sal_uInt16 Execute( const Point& rPoint, Window* pWindow, const SfxPoolItem *pArg1 ... ); 124 125 // @deprecated (start)!! 126 // Don't use these methods any longer. The whole class will be removed in the future. 127 // Changing code which relies on these methods would need much more effort! 128 // Please contact cd@openoffice.org if you have questions or need help 129 void StartInsert(); 130 void EndInsert(); 131 void CheckItem( sal_uInt16, sal_Bool ); 132 void RemoveItem( sal_uInt16 ); 133 void InsertItem( sal_uInt16, const String&, MenuItemBits, const rtl::OString& rHelpId, 134 sal_uInt16 nPos = MENU_APPEND ); 135 void InsertSeparator( sal_uInt16 nPos = MENU_APPEND ); 136 // @deprecated (end) 137 138 void RemoveDisabledEntries(); 139 void AddClipboardFunctions(); 140 Menu* GetSVMenu(); 141 }; 142 143 #endif // #ifndef _SFXMNUMGR_HXX 144 145