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 28 #ifndef __FRAMEWORK_CLASSES_MENUMANAGER_HXX_ 29 #define __FRAMEWORK_CLASSES_MENUMANAGER_HXX_ 30 31 /** Attention: stl headers must(!) be included at first. Otherwhise it can make trouble 32 with solaris headers ... 33 */ 34 #include <vector> 35 36 //_________________________________________________________________________________________________________________ 37 // interface includes 38 //_________________________________________________________________________________________________________________ 39 #include <com/sun/star/frame/XFrame.hpp> 40 #include <com/sun/star/frame/XDispatch.hpp> 41 #include <com/sun/star/frame/FeatureStateEvent.hpp> 42 #include <com/sun/star/beans/PropertyValue.hpp> 43 #include <com/sun/star/util/XURLTransformer.hpp> 44 45 //_________________________________________________________________________________________________________________ 46 // other includes 47 //_________________________________________________________________________________________________________________ 48 #include <rtl/ustring.hxx> 49 #include <vcl/menu.hxx> 50 #include <vcl/accel.hxx> 51 #include <cppuhelper/implbase1.hxx> 52 #include <threadhelp/threadhelpbase.hxx> 53 #include <macros/debug.hxx> 54 55 // #110897# 56 #include <com/sun/star/lang/XMultiServiceFactory.hpp> 57 58 #define REFERENCE ::com::sun::star::uno::Reference 59 #define XFRAME ::com::sun::star::frame::XFrame 60 #define XDISPATCH ::com::sun::star::frame::XDispatch 61 #define XDISPATCHPROVIDER ::com::sun::star::frame::XDispatchProvider 62 #define XSTATUSLISTENER ::com::sun::star::frame::XStatusListener 63 #define XEVENTLISTENER ::com::sun::star::lang::XEventListener 64 #define FEATURSTATEEVENT ::com::sun::star::frame::FeatureStateEvent 65 #define RUNTIMEEXCEPTION ::com::sun::star::uno::RuntimeException 66 #define EVENTOBJECT ::com::sun::star::lang::EventObject 67 68 namespace framework 69 { 70 71 class BmkMenu; 72 class AddonMenu; 73 class AddonPopupMenu; 74 class MenuManager : public ThreadHelpBase , 75 public ::cppu::WeakImplHelper1< ::com::sun::star::frame::XStatusListener > 76 { 77 public: 78 // #110897# 79 MenuManager( 80 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory, 81 REFERENCE< XFRAME >& rFrame, 82 Menu* pMenu, 83 sal_Bool bDelete, 84 sal_Bool bDeleteChildren ); 85 #if 0 86 MenuManager( 87 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory, 88 REFERENCE< XFRAME >& rFrame, 89 AddonMenu* pAddonMenu, 90 sal_Bool bDelete, 91 sal_Bool bDeleteChildren ); 92 #endif 93 94 virtual ~MenuManager(); 95 96 // XStatusListener 97 virtual void SAL_CALL statusChanged( const FEATURSTATEEVENT& Event ) throw ( RUNTIMEEXCEPTION ); 98 99 // XEventListener 100 virtual void SAL_CALL disposing( const EVENTOBJECT& Source ) throw ( RUNTIMEEXCEPTION ); 101 102 DECL_LINK( Select, Menu * ); 103 104 Menu* GetMenu() const { return m_pVCLMenu; } 105 106 void RemoveListener(); 107 108 // #110897# 109 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& getServiceFactory(); 110 111 static void UpdateSpecialWindowMenu( Menu* pMenu ,const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceFactory,IMutex& _rMutex); 112 static void FillMenuImages(::com::sun::star::uno::Reference< com::sun::star::frame::XFrame >& xFrame,Menu* _pMenu,sal_Bool bIsHiContrast,sal_Bool bShowMenuImages); 113 114 protected: 115 DECL_LINK( Highlight, Menu * ); 116 DECL_LINK( Activate, Menu * ); 117 DECL_LINK( Deactivate, Menu * ); 118 119 private: 120 void UpdateSpecialFileMenu( Menu* pMenu ); 121 void UpdateSpecialWindowMenu( Menu* pMenu ); 122 void ClearMenuDispatch(const EVENTOBJECT& Source = EVENTOBJECT(),bool _bRemoveOnly = true); 123 void SetHdl(); 124 void AddMenu(PopupMenu* _pPopupMenu,const ::rtl::OUString& _sItemCommand,sal_uInt16 _nItemId,sal_Bool _bDelete,sal_Bool _bDeleteChildren); 125 sal_uInt16 FillItemCommand(::rtl::OUString& _rItemCommand,Menu* _pMenu,sal_uInt16 _nIndex) const; 126 127 128 struct MenuItemHandler 129 { 130 MenuItemHandler( sal_uInt16 aItemId, MenuManager* pManager, REFERENCE< XDISPATCH >& rDispatch ) : 131 nItemId( aItemId ), pSubMenuManager( pManager ), xMenuItemDispatch( rDispatch ) {} 132 133 sal_uInt16 nItemId; 134 ::rtl::OUString aTargetFrame; 135 ::rtl::OUString aMenuItemURL; 136 ::rtl::OUString aFilter; 137 ::rtl::OUString aPassword; 138 ::rtl::OUString aTitle; 139 MenuManager* pSubMenuManager; 140 REFERENCE< XDISPATCH > xMenuItemDispatch; 141 }; 142 143 void CreatePicklistArguments( 144 ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgsList, 145 const MenuItemHandler* ); 146 147 MenuItemHandler* GetMenuItemHandler( sal_uInt16 nItemId ); 148 149 sal_Bool m_bInitialized; 150 sal_Bool m_bDeleteMenu; 151 sal_Bool m_bDeleteChildren; 152 sal_Bool m_bActive; 153 sal_Bool m_bIsBookmarkMenu; 154 sal_Bool m_bWasHiContrast; 155 sal_Bool m_bShowMenuImages; 156 ::rtl::OUString m_aMenuItemCommand; 157 Menu* m_pVCLMenu; 158 REFERENCE< XFRAME > m_xFrame; 159 ::std::vector< MenuItemHandler* > m_aMenuItemHandlerVector; 160 161 // #110897# 162 const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& mxServiceFactory; 163 ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > m_xURLTransformer; 164 }; 165 166 } // namespace 167 168 #endif 169