1*f8e07b45SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*f8e07b45SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*f8e07b45SAndrew Rist * or more contributor license agreements. See the NOTICE file 5*f8e07b45SAndrew Rist * distributed with this work for additional information 6*f8e07b45SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*f8e07b45SAndrew Rist * to you under the Apache License, Version 2.0 (the 8*f8e07b45SAndrew Rist * "License"); you may not use this file except in compliance 9*f8e07b45SAndrew Rist * with the License. You may obtain a copy of the License at 10*f8e07b45SAndrew Rist * 11*f8e07b45SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*f8e07b45SAndrew Rist * 13*f8e07b45SAndrew Rist * Unless required by applicable law or agreed to in writing, 14*f8e07b45SAndrew Rist * software distributed under the License is distributed on an 15*f8e07b45SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*f8e07b45SAndrew Rist * KIND, either express or implied. See the License for the 17*f8e07b45SAndrew Rist * specific language governing permissions and limitations 18*f8e07b45SAndrew Rist * under the License. 19*f8e07b45SAndrew Rist * 20*f8e07b45SAndrew Rist *************************************************************/ 21*f8e07b45SAndrew Rist 22*f8e07b45SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef __FRAMEWORK_UIELEMENT_NEWMENUCONTROLLER_HXX_ 25cdf0e10cSrcweir #define __FRAMEWORK_UIELEMENT_NEWMENUCONTROLLER_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 28cdf0e10cSrcweir // my own includes 29cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <macros/xserviceinfo.hxx> 32cdf0e10cSrcweir #include <stdtypes.h> 33cdf0e10cSrcweir 34cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 35cdf0e10cSrcweir // interface includes 36cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 37cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 38cdf0e10cSrcweir #include <com/sun/star/lang/XTypeProvider.hpp> 39cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp> 40cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 41cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp> 42cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProvider.hpp> 43cdf0e10cSrcweir #include <com/sun/star/frame/XDispatch.hpp> 44cdf0e10cSrcweir #include <com/sun/star/frame/XStatusListener.hpp> 45cdf0e10cSrcweir #include <com/sun/star/frame/XPopupMenuController.hpp> 46cdf0e10cSrcweir #include <com/sun/star/beans/XPropertySet.hpp> 47cdf0e10cSrcweir #include <com/sun/star/ui/XAcceleratorConfiguration.hpp> 48cdf0e10cSrcweir 49cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 50cdf0e10cSrcweir // includes of other projects 51cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 52cdf0e10cSrcweir #include <svtools/popupmenucontrollerbase.hxx> 53cdf0e10cSrcweir #include <toolkit/awt/vclxmenu.hxx> 54cdf0e10cSrcweir #include <cppuhelper/weak.hxx> 55cdf0e10cSrcweir #include <rtl/ustring.hxx> 56cdf0e10cSrcweir #include <vcl/accel.hxx> 57cdf0e10cSrcweir #ifndef _VCL_MENU_HXX_ 58cdf0e10cSrcweir #include <vcl/menu.hxx> 59cdf0e10cSrcweir #endif 60cdf0e10cSrcweir #include <hash_map> 61cdf0e10cSrcweir 62cdf0e10cSrcweir namespace framework 63cdf0e10cSrcweir { 64cdf0e10cSrcweir struct NewDocument 65cdf0e10cSrcweir { 66cdf0e10cSrcweir ::com::sun::star::util::URL aTargetURL; 67cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aArgSeq; 68cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDispatch; 69cdf0e10cSrcweir }; 70cdf0e10cSrcweir 71cdf0e10cSrcweir class NewMenuController : public svt::PopupMenuControllerBase 72cdf0e10cSrcweir { 73cdf0e10cSrcweir using svt::PopupMenuControllerBase::disposing; 74cdf0e10cSrcweir 75cdf0e10cSrcweir public: 76cdf0e10cSrcweir NewMenuController( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ); 77cdf0e10cSrcweir virtual ~NewMenuController(); 78cdf0e10cSrcweir 79cdf0e10cSrcweir // XServiceInfo 80cdf0e10cSrcweir DECLARE_XSERVICEINFO 81cdf0e10cSrcweir 82cdf0e10cSrcweir // XInitialization 83cdf0e10cSrcweir virtual void SAL_CALL initialize( const ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any >& aArguments ) throw (::com::sun::star::uno::Exception, ::com::sun::star::uno::RuntimeException); 84cdf0e10cSrcweir 85cdf0e10cSrcweir // XStatusListener 86cdf0e10cSrcweir virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException ); 87cdf0e10cSrcweir 88cdf0e10cSrcweir // XMenuListener 89cdf0e10cSrcweir virtual void SAL_CALL select( const ::com::sun::star::awt::MenuEvent& rEvent ) throw (::com::sun::star::uno::RuntimeException); 90cdf0e10cSrcweir virtual void SAL_CALL activate( const ::com::sun::star::awt::MenuEvent& rEvent ) throw (::com::sun::star::uno::RuntimeException); 91cdf0e10cSrcweir 92cdf0e10cSrcweir // XEventListener 93cdf0e10cSrcweir virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& Source ) throw ( ::com::sun::star::uno::RuntimeException ); 94cdf0e10cSrcweir 95cdf0e10cSrcweir DECL_STATIC_LINK( NewMenuController, ExecuteHdl_Impl, NewDocument* ); 96cdf0e10cSrcweir 97cdf0e10cSrcweir private: 98cdf0e10cSrcweir virtual void impl_setPopupMenu(); 99cdf0e10cSrcweir struct AddInfo 100cdf0e10cSrcweir { 101cdf0e10cSrcweir rtl::OUString aTargetFrame; 102cdf0e10cSrcweir rtl::OUString aImageId; 103cdf0e10cSrcweir }; 104cdf0e10cSrcweir 105cdf0e10cSrcweir typedef ::std::hash_map< int, AddInfo > AddInfoForId; 106cdf0e10cSrcweir 107cdf0e10cSrcweir void fillPopupMenu( com::sun::star::uno::Reference< com::sun::star::awt::XPopupMenu >& rPopupMenu ); 108cdf0e10cSrcweir void retrieveShortcutsFromConfiguration( const ::com::sun::star::uno::Reference< ::com::sun::star::ui::XAcceleratorConfiguration >& rAccelCfg, 109cdf0e10cSrcweir const ::com::sun::star::uno::Sequence< rtl::OUString >& rCommands, 110cdf0e10cSrcweir std::vector< KeyCode >& aMenuShortCuts ); 111cdf0e10cSrcweir void setAccelerators( PopupMenu* pPopupMenu ); 112cdf0e10cSrcweir void determineAndSetNewDocAccel( PopupMenu* pPopupMenu, const KeyCode& rKeyCode ); 113cdf0e10cSrcweir void setMenuImages( PopupMenu* pPopupMenu, sal_Bool bSetImages, sal_Bool bHiContrast ); 114cdf0e10cSrcweir 115cdf0e10cSrcweir private: 116cdf0e10cSrcweir // members 117cdf0e10cSrcweir sal_Bool m_bShowImages : 1, 118cdf0e10cSrcweir m_bHiContrast : 1, 119cdf0e10cSrcweir m_bNewMenu : 1, 120cdf0e10cSrcweir m_bModuleIdentified : 1, 121cdf0e10cSrcweir m_bAcceleratorCfg : 1; 122cdf0e10cSrcweir AddInfoForId m_aAddInfoForItem; 123cdf0e10cSrcweir rtl::OUString m_aTargetFrame; 124cdf0e10cSrcweir rtl::OUString m_aModuleIdentifier; 125cdf0e10cSrcweir rtl::OUString m_aEmptyDocURL; 126cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::ui::XAcceleratorConfiguration > m_xDocAcceleratorManager; 127cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::ui::XAcceleratorConfiguration > m_xModuleAcceleratorManager; 128cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::ui::XAcceleratorConfiguration > m_xGlobalAcceleratorManager; 129cdf0e10cSrcweir }; 130cdf0e10cSrcweir } 131cdf0e10cSrcweir 132cdf0e10cSrcweir #endif // __FRAMEWORK_UIELEMENT_NEWMENUCONTROLLER_HXX_ 133