1f8e07b45SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3f8e07b45SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4f8e07b45SAndrew Rist * or more contributor license agreements. See the NOTICE file 5f8e07b45SAndrew Rist * distributed with this work for additional information 6f8e07b45SAndrew Rist * regarding copyright ownership. The ASF licenses this file 7f8e07b45SAndrew Rist * to you under the Apache License, Version 2.0 (the 8f8e07b45SAndrew Rist * "License"); you may not use this file except in compliance 9f8e07b45SAndrew Rist * with the License. You may obtain a copy of the License at 10f8e07b45SAndrew Rist * 11f8e07b45SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12f8e07b45SAndrew Rist * 13f8e07b45SAndrew Rist * Unless required by applicable law or agreed to in writing, 14f8e07b45SAndrew Rist * software distributed under the License is distributed on an 15f8e07b45SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16f8e07b45SAndrew Rist * KIND, either express or implied. See the License for the 17f8e07b45SAndrew Rist * specific language governing permissions and limitations 18f8e07b45SAndrew Rist * under the License. 19f8e07b45SAndrew Rist * 20f8e07b45SAndrew Rist *************************************************************/ 21f8e07b45SAndrew Rist 22f8e07b45SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef __FRAMEWORK_DISPATCH_MENUDISPATCHER_HXX_ 25cdf0e10cSrcweir #define __FRAMEWORK_DISPATCH_MENUDISPATCHER_HXX_ 26cdf0e10cSrcweir 27cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 28cdf0e10cSrcweir // my own includes 29cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 30cdf0e10cSrcweir 31cdf0e10cSrcweir #include <classes/taskcreator.hxx> 32cdf0e10cSrcweir #include <services/frame.hxx> 33cdf0e10cSrcweir #include <macros/generic.hxx> 34cdf0e10cSrcweir #include <macros/xinterface.hxx> 35cdf0e10cSrcweir #include <macros/xtypeprovider.hxx> 36cdf0e10cSrcweir #include <macros/debug.hxx> 37cdf0e10cSrcweir #include <threadhelp/threadhelpbase.hxx> 38cdf0e10cSrcweir #include <classes/menumanager.hxx> 39cdf0e10cSrcweir #include <general.h> 40cdf0e10cSrcweir #include <stdtypes.h> 41cdf0e10cSrcweir 42cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 43cdf0e10cSrcweir // interface includes 44cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 45cdf0e10cSrcweir #include <com/sun/star/lang/XTypeProvider.hpp> 46cdf0e10cSrcweir #include <com/sun/star/frame/XDispatch.hpp> 47cdf0e10cSrcweir #include <com/sun/star/util/URL.hpp> 48cdf0e10cSrcweir #include <com/sun/star/frame/DispatchDescriptor.hpp> 49cdf0e10cSrcweir #include <com/sun/star/beans/PropertyValue.hpp> 50cdf0e10cSrcweir #include <com/sun/star/frame/XStatusListener.hpp> 51cdf0e10cSrcweir #include <com/sun/star/frame/XFrameLoader.hpp> 52cdf0e10cSrcweir #include <com/sun/star/frame/XLoadEventListener.hpp> 53cdf0e10cSrcweir #include <com/sun/star/frame/XDesktop.hpp> 54cdf0e10cSrcweir #include <com/sun/star/frame/FeatureStateEvent.hpp> 55cdf0e10cSrcweir #include <com/sun/star/frame/XFrameActionListener.hpp> 56cdf0e10cSrcweir 57cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 58cdf0e10cSrcweir // other includes 59cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 60cdf0e10cSrcweir #include <cppuhelper/weak.hxx> 61cdf0e10cSrcweir #include <cppuhelper/weakref.hxx> 62cdf0e10cSrcweir #include <cppuhelper/interfacecontainer.h> 63cdf0e10cSrcweir 64cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 65cdf0e10cSrcweir // namespace 66cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 67cdf0e10cSrcweir 68cdf0e10cSrcweir namespace framework{ 69cdf0e10cSrcweir 70cdf0e10cSrcweir 71cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 72cdf0e10cSrcweir // exported const 73cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 74cdf0e10cSrcweir 75cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 76cdf0e10cSrcweir // exported definitions 77cdf0e10cSrcweir //_________________________________________________________________________________________________________________ 78cdf0e10cSrcweir 79cdf0e10cSrcweir /*-************************************************************************************************************//** 80cdf0e10cSrcweir We must save informations about our listener and URL for listening. 81cdf0e10cSrcweir We implement this as a hashtable for strings. 82cdf0e10cSrcweir *//*-*************************************************************************************************************/ 83cdf0e10cSrcweir 84cdf0e10cSrcweir typedef ::cppu::OMultiTypeInterfaceContainerHelperVar< ::rtl::OUString , 855758ad8cSAriel Constenla-Haile rtl::OUStringHash, 86cdf0e10cSrcweir std::equal_to< ::rtl::OUString > > IMPL_ListenerHashContainer; 87cdf0e10cSrcweir 88cdf0e10cSrcweir 89cdf0e10cSrcweir /*-************************************************************************************************************//** 90cdf0e10cSrcweir @short helper for desktop only(!) to create new tasks on demand for dispatches 91cdf0e10cSrcweir @descr Use this class as member only! Never use it as baseclass. 92*b12a77c9Smseidel XInterface will be ambiguous and we hold a weakcss::uno::Reference to our OWNER - not to our SUPERCLASS! 93cdf0e10cSrcweir 94cdf0e10cSrcweir @implements XInterface 95cdf0e10cSrcweir XDispatch 96cdf0e10cSrcweir XLoadEventListener 97cdf0e10cSrcweir XFrameActionListener 98cdf0e10cSrcweir XEventListener 99cdf0e10cSrcweir @base ThreadHelpBase 100cdf0e10cSrcweir OWeakObject 101cdf0e10cSrcweir 102cdf0e10cSrcweir @devstatus ready to use 103cdf0e10cSrcweir *//*-*************************************************************************************************************/ 104cdf0e10cSrcweir class MenuDispatcher : // interfaces 105cdf0e10cSrcweir public css::lang::XTypeProvider , 106cdf0e10cSrcweir public css::frame::XDispatch , 107cdf0e10cSrcweir public css::frame::XFrameActionListener , 108cdf0e10cSrcweir // baseclasses 10907a3d7f1SPedro Giffuni // Order is necessary for right initialization! 110cdf0e10cSrcweir public ThreadHelpBase , 111cdf0e10cSrcweir public cppu::OWeakObject 112cdf0e10cSrcweir { 113cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 114cdf0e10cSrcweir // public methods 115cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 116cdf0e10cSrcweir 117cdf0e10cSrcweir public: 118cdf0e10cSrcweir 119cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 120cdf0e10cSrcweir // constructor / destructor 121cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 122cdf0e10cSrcweir 123cdf0e10cSrcweir /*-****************************************************************************************************//** 124cdf0e10cSrcweir @short standard ctor 12507a3d7f1SPedro Giffuni @descr These initialize a new instance of this class with needed informations for work. 126cdf0e10cSrcweir 127cdf0e10cSrcweir @seealso using at owner 128cdf0e10cSrcweir 129cdf0e10cSrcweir @param "xFactory" , css::uno::Reference to servicemanager for creation of new services 130cdf0e10cSrcweir @param "xOwner" , css::uno::Reference to our owner, the Desktop!!! 131cdf0e10cSrcweir @return - 132cdf0e10cSrcweir 133cdf0e10cSrcweir @onerror - 134cdf0e10cSrcweir *//*-*****************************************************************************************************/ 135cdf0e10cSrcweir 136cdf0e10cSrcweir MenuDispatcher( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory , 137cdf0e10cSrcweir const css::uno::Reference< css::frame::XFrame >& xOwner ); 138cdf0e10cSrcweir 139cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 140cdf0e10cSrcweir // XInterface 141cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 142cdf0e10cSrcweir 143cdf0e10cSrcweir FWK_DECLARE_XINTERFACE 144cdf0e10cSrcweir FWK_DECLARE_XTYPEPROVIDER 145cdf0e10cSrcweir 146cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 147cdf0e10cSrcweir // XDispatch 148cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 149cdf0e10cSrcweir 150cdf0e10cSrcweir /*-****************************************************************************************************//** 151cdf0e10cSrcweir @short dispatch URL with arguments 15207a3d7f1SPedro Giffuni @descr Every dispatch create a new task. If load of URL failed task will deleted automatically! 153cdf0e10cSrcweir 154cdf0e10cSrcweir @seealso - 155cdf0e10cSrcweir 156cdf0e10cSrcweir @param "aURL" , URL to dispatch. 157cdf0e10cSrcweir @param "seqArguments" , list of optional arguments. 158cdf0e10cSrcweir @return - 159cdf0e10cSrcweir 160cdf0e10cSrcweir @onerror - 161cdf0e10cSrcweir *//*-*****************************************************************************************************/ 162cdf0e10cSrcweir 163cdf0e10cSrcweir virtual void SAL_CALL dispatch( const css::util::URL& aURL , 164cdf0e10cSrcweir const css::uno::Sequence< css::beans::PropertyValue >& seqProperties ) throw( css::uno::RuntimeException ); 165cdf0e10cSrcweir 166cdf0e10cSrcweir /*-****************************************************************************************************//** 167cdf0e10cSrcweir @short add listener for state events 168cdf0e10cSrcweir @descr You can add a listener to get information about status of dispatch: OK or Failed. 169cdf0e10cSrcweir 170cdf0e10cSrcweir @seealso method loadFinished() 171cdf0e10cSrcweir @seealso method loadCancelled() 172cdf0e10cSrcweir 173cdf0e10cSrcweir @param "xControl" , css::uno::Reference to a valid listener for state events. 17407a3d7f1SPedro Giffuni @param "aURL" , URL about listener will be informed, if something occurred. 175cdf0e10cSrcweir @return - 176cdf0e10cSrcweir 177cdf0e10cSrcweir @onerror - 178cdf0e10cSrcweir *//*-*****************************************************************************************************/ 179cdf0e10cSrcweir 180cdf0e10cSrcweir virtual void SAL_CALL addStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xControl, 181cdf0e10cSrcweir const css::util::URL& aURL ) throw( css::uno::RuntimeException ); 182cdf0e10cSrcweir 183cdf0e10cSrcweir /*-****************************************************************************************************//** 184cdf0e10cSrcweir @short remove listener for state events 185cdf0e10cSrcweir @descr You can remove a listener if information of dispatch isn't important for you any longer. 186cdf0e10cSrcweir 187cdf0e10cSrcweir @seealso method loadFinished() 188cdf0e10cSrcweir @seealso method loadCancelled() 189cdf0e10cSrcweir 190cdf0e10cSrcweir @param "xControl" , css::uno::Reference to a valid listener. 191cdf0e10cSrcweir @param "aURL" , URL on which listener has registered. 192cdf0e10cSrcweir @return - 193cdf0e10cSrcweir 194cdf0e10cSrcweir @onerror - 195cdf0e10cSrcweir *//*-*****************************************************************************************************/ 196cdf0e10cSrcweir 197cdf0e10cSrcweir virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xControl, 198cdf0e10cSrcweir const css::util::URL& aURL ) throw( css::uno::RuntimeException ); 199cdf0e10cSrcweir 200cdf0e10cSrcweir 201cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 202cdf0e10cSrcweir // XFrameActionListener 203cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 204cdf0e10cSrcweir 205cdf0e10cSrcweir virtual void SAL_CALL frameAction( const css::frame::FrameActionEvent& aEvent ) throw ( css::uno::RuntimeException ); 206cdf0e10cSrcweir 207cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 208cdf0e10cSrcweir // XEventListener 209cdf0e10cSrcweir //--------------------------------------------------------------------------------------------------------- 210cdf0e10cSrcweir 211cdf0e10cSrcweir /*-****************************************************************************************************//** 212cdf0e10cSrcweir @short dispose current instance 213cdf0e10cSrcweir @descr If service helper isn't required any longer call this method to release all used ressources. 214cdf0e10cSrcweir 215cdf0e10cSrcweir @seealso - 216cdf0e10cSrcweir 217cdf0e10cSrcweir @param "aEvent", information about source of this event. 218cdf0e10cSrcweir @return - 219cdf0e10cSrcweir 220cdf0e10cSrcweir @onerror - 221cdf0e10cSrcweir *//*-*****************************************************************************************************/ 222cdf0e10cSrcweir 223cdf0e10cSrcweir void SAL_CALL disposing( const EVENTOBJECT& aEvent ) throw( css::uno::RuntimeException ); 224cdf0e10cSrcweir 225cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 226cdf0e10cSrcweir // protected methods 227cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 228cdf0e10cSrcweir 229cdf0e10cSrcweir protected: 230cdf0e10cSrcweir 231cdf0e10cSrcweir /*-****************************************************************************************************//** 232cdf0e10cSrcweir @short standard destructor 233cdf0e10cSrcweir @descr This method destruct an instance of this class and clear some member. 234cdf0e10cSrcweir This method is protected, because its not allowed to use an instance of this class as a member! 235cdf0e10cSrcweir You MUST use a pointer. 236cdf0e10cSrcweir 237cdf0e10cSrcweir @seealso - 238cdf0e10cSrcweir 239cdf0e10cSrcweir @param - 240cdf0e10cSrcweir @return - 241cdf0e10cSrcweir 242cdf0e10cSrcweir @onerror - 243cdf0e10cSrcweir *//*-*****************************************************************************************************/ 244cdf0e10cSrcweir 245cdf0e10cSrcweir virtual ~MenuDispatcher(); 246cdf0e10cSrcweir 247cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 248cdf0e10cSrcweir // private methods 249cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 250cdf0e10cSrcweir 251cdf0e10cSrcweir private: 252cdf0e10cSrcweir 253cdf0e10cSrcweir DECL_LINK( Close_Impl, void* ); 254cdf0e10cSrcweir 255cdf0e10cSrcweir /*-****************************************************************************************************//** 256cdf0e10cSrcweir @short - 257cdf0e10cSrcweir @descr - 258cdf0e10cSrcweir 259cdf0e10cSrcweir @seealso - 260cdf0e10cSrcweir 261cdf0e10cSrcweir @param - 262cdf0e10cSrcweir @return - 263cdf0e10cSrcweir 264cdf0e10cSrcweir @onerror - 265cdf0e10cSrcweir *//*-*****************************************************************************************************/ 266cdf0e10cSrcweir 267cdf0e10cSrcweir sal_Bool impl_setMenuBar( MenuBar* pMenuBar, sal_Bool bMenuFromResource = sal_False ); 268cdf0e10cSrcweir 269cdf0e10cSrcweir /*-****************************************************************************************************//** 270cdf0e10cSrcweir @short - 271cdf0e10cSrcweir @descr - 272cdf0e10cSrcweir 273cdf0e10cSrcweir @seealso - 274cdf0e10cSrcweir 275cdf0e10cSrcweir @param - 276cdf0e10cSrcweir @return - 277cdf0e10cSrcweir 278cdf0e10cSrcweir @onerror - 279cdf0e10cSrcweir *//*-*****************************************************************************************************/ 280cdf0e10cSrcweir 281cdf0e10cSrcweir void impl_setAccelerators( Menu* pMenu, const Accelerator& aAccel ); 282cdf0e10cSrcweir 283cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 284cdf0e10cSrcweir // debug methods 285cdf0e10cSrcweir // (should be private everyway!) 286cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 287cdf0e10cSrcweir 288cdf0e10cSrcweir /*-****************************************************************************************************//** 289cdf0e10cSrcweir @short debug-method to check incoming parameter of some other mehods of this class 290cdf0e10cSrcweir @descr The following methods are used to check parameters for other methods 291cdf0e10cSrcweir of this class. The return value is used directly for an ASSERT(...). 292cdf0e10cSrcweir 293cdf0e10cSrcweir @seealso ASSERTs in implementation! 294cdf0e10cSrcweir 295cdf0e10cSrcweir @param css::uno::References to checking variables 296cdf0e10cSrcweir @return sal_False on invalid parameter<BR> 297cdf0e10cSrcweir sal_True otherway 298cdf0e10cSrcweir 299cdf0e10cSrcweir @onerror - 300cdf0e10cSrcweir *//*-*****************************************************************************************************/ 301cdf0e10cSrcweir 302cdf0e10cSrcweir #ifdef ENABLE_ASSERTIONS 303cdf0e10cSrcweir 304cdf0e10cSrcweir private: 305cdf0e10cSrcweir 306cdf0e10cSrcweir static sal_Bool impldbg_checkParameter_MenuDispatcher ( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory , 307cdf0e10cSrcweir const css::uno::Reference< css::frame::XFrame >& xOwner ); 308cdf0e10cSrcweir static sal_Bool impldbg_checkParameter_addStatusListener ( const css::uno::Reference< css::frame::XStatusListener >& xControl , 309cdf0e10cSrcweir const css::util::URL& aURL ); 310cdf0e10cSrcweir static sal_Bool impldbg_checkParameter_removeStatusListener ( const css::uno::Reference< css::frame::XStatusListener >& xControl , 311cdf0e10cSrcweir const css::util::URL& aURL ); 312cdf0e10cSrcweir #endif // #ifdef ENABLE_ASSERTIONS 313cdf0e10cSrcweir 314cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 315cdf0e10cSrcweir // variables 316cdf0e10cSrcweir // (should be private everyway!) 317cdf0e10cSrcweir //------------------------------------------------------------------------------------------------------------- 318cdf0e10cSrcweir 319cdf0e10cSrcweir private: 320cdf0e10cSrcweir 321cdf0e10cSrcweir css::uno::WeakReference< css::frame::XFrame > m_xOwnerWeak ; /// css::uno::WeakReference to owner (Don't use a hard css::uno::Reference. Owner can't delete us then!) 322cdf0e10cSrcweir css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory ; /// factory shared with our owner to create new services! 323cdf0e10cSrcweir IMPL_ListenerHashContainer m_aListenerContainer; /// hash table for listener at specified URLs 324cdf0e10cSrcweir sal_Bool m_bAlreadyDisposed ; /// Protection against multiple disposing calls. 325cdf0e10cSrcweir sal_Bool m_bActivateListener ; /// dispatcher is listener for frame activation 326cdf0e10cSrcweir MenuManager* m_pMenuManager ; /// menu manager controlling menu dispatches 327cdf0e10cSrcweir 328cdf0e10cSrcweir }; // class MenuDispatcher 329cdf0e10cSrcweir 330cdf0e10cSrcweir } // namespace framework 331cdf0e10cSrcweir 332cdf0e10cSrcweir #endif // #ifndef __FRAMEWORK_DISPATCH_MENUDISPATCHER_HXX_ 333