101aa44aaSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 301aa44aaSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 401aa44aaSAndrew Rist * or more contributor license agreements. See the NOTICE file 501aa44aaSAndrew Rist * distributed with this work for additional information 601aa44aaSAndrew Rist * regarding copyright ownership. The ASF licenses this file 701aa44aaSAndrew Rist * to you under the Apache License, Version 2.0 (the 801aa44aaSAndrew Rist * "License"); you may not use this file except in compliance 901aa44aaSAndrew Rist * with the License. You may obtain a copy of the License at 1001aa44aaSAndrew Rist * 1101aa44aaSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 1201aa44aaSAndrew Rist * 1301aa44aaSAndrew Rist * Unless required by applicable law or agreed to in writing, 1401aa44aaSAndrew Rist * software distributed under the License is distributed on an 1501aa44aaSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 1601aa44aaSAndrew Rist * KIND, either express or implied. See the License for the 1701aa44aaSAndrew Rist * specific language governing permissions and limitations 1801aa44aaSAndrew Rist * under the License. 1901aa44aaSAndrew Rist * 2001aa44aaSAndrew Rist *************************************************************/ 2101aa44aaSAndrew Rist 2201aa44aaSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef __SVTOOLS_POPUPMENUCONTROLLERBASE_HXX_ 25cdf0e10cSrcweir #define __SVTOOLS_POPUPMENUCONTROLLERBASE_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "svtools/svtdllapi.h" 28cdf0e10cSrcweir 29cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 30cdf0e10cSrcweir // interface includes 31cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 32cdf0e10cSrcweir #include <com/sun/star/lang/XServiceInfo.hpp> 33cdf0e10cSrcweir #include <com/sun/star/lang/XTypeProvider.hpp> 34cdf0e10cSrcweir #include <com/sun/star/lang/XInitialization.hpp> 35cdf0e10cSrcweir #include <com/sun/star/lang/XMultiServiceFactory.hpp> 36cdf0e10cSrcweir #include <com/sun/star/frame/XFrame.hpp> 37cdf0e10cSrcweir #include <com/sun/star/frame/XDispatchProvider.hpp> 38cdf0e10cSrcweir #include <com/sun/star/frame/XDispatch.hpp> 39cdf0e10cSrcweir #include <com/sun/star/frame/XStatusListener.hpp> 40cdf0e10cSrcweir #include <com/sun/star/frame/XPopupMenuController.hpp> 41cdf0e10cSrcweir #include <com/sun/star/uri/XUriReferenceFactory.hpp> 42cdf0e10cSrcweir #include <com/sun/star/uri/XUriReference.hpp> 43cdf0e10cSrcweir #include <com/sun/star/util/XURLTransformer.hpp> 44cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 45cdf0e10cSrcweir // includes of other projects 46cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 47cdf0e10cSrcweir #include <toolkit/awt/vclxmenu.hxx> 48cdf0e10cSrcweir #include <cppuhelper/compbase7.hxx> 49cdf0e10cSrcweir #include <comphelper/broadcasthelper.hxx> 50cdf0e10cSrcweir #include <cppuhelper/weak.hxx> 51cdf0e10cSrcweir #include <rtl/ustring.hxx> 52cdf0e10cSrcweir 53cdf0e10cSrcweir namespace svt 54cdf0e10cSrcweir { 55cdf0e10cSrcweir struct PopupMenuControllerBaseDispatchInfo; 56cdf0e10cSrcweir 57cdf0e10cSrcweir typedef ::cppu::WeakComponentImplHelper7< 58cdf0e10cSrcweir com::sun::star::lang::XServiceInfo , 59cdf0e10cSrcweir com::sun::star::frame::XPopupMenuController , 60cdf0e10cSrcweir com::sun::star::lang::XInitialization , 61cdf0e10cSrcweir com::sun::star::frame::XStatusListener , 62cdf0e10cSrcweir com::sun::star::awt::XMenuListener , 63cdf0e10cSrcweir com::sun::star::frame::XDispatchProvider , 64cdf0e10cSrcweir com::sun::star::frame::XDispatch > PopupMenuControllerBaseType; 65cdf0e10cSrcweir 66*437a6594Smseidel class SVT_DLLPUBLIC PopupMenuControllerBase : protected ::comphelper::OBaseMutex, // Struct for right initialization of mutex member! Must be first of baseclasses. 67cdf0e10cSrcweir public PopupMenuControllerBaseType 68cdf0e10cSrcweir { 69cdf0e10cSrcweir public: 70cdf0e10cSrcweir PopupMenuControllerBase( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory >& xServiceManager ); 71cdf0e10cSrcweir virtual ~PopupMenuControllerBase(); 72cdf0e10cSrcweir 73cdf0e10cSrcweir // XServiceInfo 74cdf0e10cSrcweir virtual ::rtl::OUString SAL_CALL getImplementationName( ) throw (::com::sun::star::uno::RuntimeException) = 0; 75cdf0e10cSrcweir virtual sal_Bool SAL_CALL supportsService( const ::rtl::OUString& ServiceName ) throw (::com::sun::star::uno::RuntimeException); 76cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames( ) throw (::com::sun::star::uno::RuntimeException) = 0; 77cdf0e10cSrcweir 78cdf0e10cSrcweir // XPopupMenuController 79cdf0e10cSrcweir virtual void SAL_CALL setPopupMenu( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu >& PopupMenu ) throw (::com::sun::star::uno::RuntimeException); 80cdf0e10cSrcweir virtual void SAL_CALL updatePopupMenu() throw (::com::sun::star::uno::RuntimeException); 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 ) = 0; 87cdf0e10cSrcweir 88cdf0e10cSrcweir // XMenuListener 89d026be40SAriel Constenla-Haile virtual void SAL_CALL itemHighlighted( const ::com::sun::star::awt::MenuEvent& rEvent ) throw (::com::sun::star::uno::RuntimeException); 90d026be40SAriel Constenla-Haile virtual void SAL_CALL itemSelected( const ::com::sun::star::awt::MenuEvent& rEvent ) throw (::com::sun::star::uno::RuntimeException); 91d026be40SAriel Constenla-Haile virtual void SAL_CALL itemActivated( const ::com::sun::star::awt::MenuEvent& rEvent ) throw (::com::sun::star::uno::RuntimeException); 92d026be40SAriel Constenla-Haile virtual void SAL_CALL itemDeactivated( const ::com::sun::star::awt::MenuEvent& rEvent ) throw (::com::sun::star::uno::RuntimeException); 93cdf0e10cSrcweir 94cdf0e10cSrcweir // XDispatchProvider 95cdf0e10cSrcweir virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL queryDispatch( const ::com::sun::star::util::URL& aURL, const ::rtl::OUString& sTarget, sal_Int32 nFlags ) throw( ::com::sun::star::uno::RuntimeException ); 96cdf0e10cSrcweir virtual ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > > SAL_CALL queryDispatches( const ::com::sun::star::uno::Sequence< ::com::sun::star::frame::DispatchDescriptor >& lDescriptor ) throw( ::com::sun::star::uno::RuntimeException ); 97cdf0e10cSrcweir 98cdf0e10cSrcweir // XDispatch 99cdf0e10cSrcweir virtual void SAL_CALL dispatch( const ::com::sun::star::util::URL& aURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& seqProperties ) throw( ::com::sun::star::uno::RuntimeException ); 100cdf0e10cSrcweir virtual void SAL_CALL addStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& xControl, const ::com::sun::star::util::URL& aURL ) throw( ::com::sun::star::uno::RuntimeException ); 101cdf0e10cSrcweir virtual void SAL_CALL removeStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XStatusListener >& xControl, const ::com::sun::star::util::URL& aURL ) throw( ::com::sun::star::uno::RuntimeException ); 102cdf0e10cSrcweir 103cdf0e10cSrcweir // XEventListener 104cdf0e10cSrcweir virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& Source ) throw ( ::com::sun::star::uno::RuntimeException ); 105cdf0e10cSrcweir 106cdf0e10cSrcweir void dispatchCommand( const ::rtl::OUString& sCommandURL, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& rArgs ); 107cdf0e10cSrcweir 108cdf0e10cSrcweir protected: 109cdf0e10cSrcweir void throwIfDisposed() throw ( ::com::sun::star::uno::RuntimeException ); 110cdf0e10cSrcweir 111cdf0e10cSrcweir /** helper method to cause statusChanged is called once for the given command url */ 112cdf0e10cSrcweir void SAL_CALL updateCommand( const rtl::OUString& rCommandURL ); 113cdf0e10cSrcweir 114cdf0e10cSrcweir /** this function is called upon disposing the component 115cdf0e10cSrcweir */ 116cdf0e10cSrcweir virtual void SAL_CALL disposing(); 117cdf0e10cSrcweir 118cdf0e10cSrcweir virtual void resetPopupMenu( com::sun::star::uno::Reference< com::sun::star::awt::XPopupMenu >& rPopupMenu ); 119cdf0e10cSrcweir virtual void impl_setPopupMenu(); 120cdf0e10cSrcweir virtual void impl_select(const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >& _xDispatch,const ::com::sun::star::util::URL& aURL); 121cdf0e10cSrcweir ::rtl::OUString determineBaseURL( const ::rtl::OUString& aURL ); 122cdf0e10cSrcweir 123cdf0e10cSrcweir DECL_STATIC_LINK( PopupMenuControllerBase, ExecuteHdl_Impl, PopupMenuControllerBaseDispatchInfo* ); 124cdf0e10cSrcweir 125cdf0e10cSrcweir 126cdf0e10cSrcweir bool m_bInitialized; 127cdf0e10cSrcweir rtl::OUString m_aCommandURL; 128cdf0e10cSrcweir rtl::OUString m_aBaseURL; 129cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > m_xDispatch; 130cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame; 131cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager; 132cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > m_xURLTransformer; 133cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XPopupMenu > m_xPopupMenu; 134cdf0e10cSrcweir }; 135cdf0e10cSrcweir } 136cdf0e10cSrcweir 137cdf0e10cSrcweir #endif // __SVTOOLS_POPUPMENUCONTROLLERBASE_HXX_ 138