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 24 #ifndef __FRAMEWORK_DISPATCH_POPUPMENUDISPATCHER_HXX_ 25 #define __FRAMEWORK_DISPATCH_POPUPMENUDISPATCHER_HXX_ 26 27 //_________________________________________________________________________________________________________________ 28 // my own includes 29 //_________________________________________________________________________________________________________________ 30 31 #include <services/frame.hxx> 32 /* 33 #include <macros/generic.hxx> 34 */ 35 #include <macros/xinterface.hxx> 36 #include <macros/xtypeprovider.hxx> 37 #include <macros/xserviceinfo.hxx> 38 /* 39 #include <macros/debug.hxx> 40 */ 41 #include <threadhelp/threadhelpbase.hxx> 42 #include <general.h> 43 #include <stdtypes.h> 44 45 //_________________________________________________________________________________________________________________ 46 // interface includes 47 //_________________________________________________________________________________________________________________ 48 #include <com/sun/star/lang/XTypeProvider.hpp> 49 #include <com/sun/star/frame/XDispatch.hpp> 50 #include <com/sun/star/frame/XDispatchProvider.hpp> 51 #include <com/sun/star/util/URL.hpp> 52 #include <com/sun/star/frame/DispatchDescriptor.hpp> 53 #include <com/sun/star/beans/PropertyValue.hpp> 54 #include <com/sun/star/frame/XStatusListener.hpp> 55 #include <com/sun/star/frame/XFrameLoader.hpp> 56 #include <com/sun/star/frame/XLoadEventListener.hpp> 57 #include <com/sun/star/frame/XDesktop.hpp> 58 #include <com/sun/star/frame/FeatureStateEvent.hpp> 59 #include <com/sun/star/frame/XFrameActionListener.hpp> 60 #include <com/sun/star/lang/XInitialization.hpp> 61 #include <com/sun/star/container/XNameAccess.hpp> 62 #ifndef _COM_SUN_STAR_URI_XURLREFERENCEFACTORY_HPP_ 63 #include <com/sun/star/uri/XUriReferenceFactory.hpp> 64 #endif 65 #ifndef _COM_SUN_STAR_URI_XURLREFERENCE_HPP_ 66 #include <com/sun/star/uri/XUriReference.hpp> 67 #endif 68 69 //_________________________________________________________________________________________________________________ 70 // other includes 71 //_________________________________________________________________________________________________________________ 72 #include <cppuhelper/weak.hxx> 73 #include <cppuhelper/weakref.hxx> 74 #include <cppuhelper/interfacecontainer.h> 75 76 //_________________________________________________________________________________________________________________ 77 // namespace 78 //_________________________________________________________________________________________________________________ 79 80 namespace framework{ 81 82 83 //_________________________________________________________________________________________________________________ 84 // exported const 85 //_________________________________________________________________________________________________________________ 86 87 //_________________________________________________________________________________________________________________ 88 // exported definitions 89 //_________________________________________________________________________________________________________________ 90 91 /*-************************************************************************************************************//** 92 We must save informations about our listener and URL for listening. 93 We implement this as a hashtable for strings. 94 *//*-*************************************************************************************************************/ 95 96 typedef ::cppu::OMultiTypeInterfaceContainerHelperVar< ::rtl::OUString , 97 rtl::OUStringHash, 98 std::equal_to< ::rtl::OUString > > IMPL_ListenerHashContainer; 99 100 101 /*-************************************************************************************************************//** 102 @short helper for desktop only(!) to create new tasks on demand for dispatches 103 @descr Use this class as member only! Never use it as baseclass. 104 XInterface will be ambiguous and we hold a weakcss::uno::Reference to our OWNER - not to our SUPERCLASS! 105 106 @implements XInterface 107 XDispatch 108 XLoadEventListener 109 XFrameActionListener 110 XEventListener 111 @base ThreadHelpBase 112 OWeakObject 113 114 @devstatus ready to use 115 *//*-*************************************************************************************************************/ 116 class PopupMenuDispatcher : // interfaces 117 public css::lang::XTypeProvider , 118 public css::lang::XServiceInfo , 119 public css::frame::XDispatchProvider , 120 public css::frame::XDispatch , 121 public css::frame::XFrameActionListener , 122 public css::lang::XInitialization , 123 // baseclasses 124 // Order is necessary for right initialization! 125 public ThreadHelpBase , 126 public cppu::OWeakObject 127 { 128 //------------------------------------------------------------------------------------------------------------- 129 // public methods 130 //------------------------------------------------------------------------------------------------------------- 131 public: 132 133 // constructor / destructor 134 PopupMenuDispatcher( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory ); 135 136 // XInterface, XTypeProvider, XServiceInfo 137 FWK_DECLARE_XINTERFACE 138 FWK_DECLARE_XTYPEPROVIDER 139 DECLARE_XSERVICEINFO 140 141 // XInitialization 142 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& lArguments ); 143 // XDispatchProvider 144 virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL queryDispatch( 145 const ::com::sun::star::util::URL& aURL , 146 const ::rtl::OUString& sTarget , 147 sal_Int32 nFlags ); 148 149 virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL queryDispatches( 150 const css::uno::Sequence< css::frame::DispatchDescriptor >& lDescriptor ); 151 152 // XDispatch 153 virtual void SAL_CALL dispatch( const css::util::URL& aURL, 154 const css::uno::Sequence< css::beans::PropertyValue >& seqProperties ); 155 156 virtual void SAL_CALL addStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xControl, 157 const css::util::URL& aURL ); 158 159 virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xControl, 160 const css::util::URL& aURL ); 161 162 163 // XFrameActionListener 164 virtual void SAL_CALL frameAction( const css::frame::FrameActionEvent& aEvent ); 165 166 // XEventListener 167 void SAL_CALL disposing( const css::lang::EventObject& aEvent ); 168 169 // protected methods 170 protected: 171 virtual ~PopupMenuDispatcher(); 172 173 void impl_RetrievePopupControllerQuery(); 174 void impl_CreateUriRefFactory(); 175 176 // private methods 177 178 // variables 179 private: 180 css::uno::WeakReference< css::frame::XFrame > m_xWeakFrame ; /// css::uno::WeakReference to frame (Don't use a hard css::uno::Reference. Owner can't delete us then!) 181 css::uno::Reference< css::container::XNameAccess > m_xPopupCtrlQuery ; /// reference to query for popup controller 182 css::uno::Reference< css::uri::XUriReferenceFactory > m_xUriRefFactory ; /// reference to the uri reference factory 183 css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory ; /// factory shared with our owner to create new services! 184 IMPL_ListenerHashContainer m_aListenerContainer; /// hash table for listener at specified URLs 185 sal_Bool m_bAlreadyDisposed ; /// Protection against multiple disposing calls. 186 sal_Bool m_bActivateListener ; /// dispatcher is listener for frame activation 187 188 }; // class PopupMenuDispatcher 189 190 } // namespace framework 191 192 #endif // #ifndef __FRAMEWORK_DISPATCH_POPUPMENUDISPATCHER_HXX_ 193