Update ooo320-m1
[ooovba.git] / framework / inc / dispatch / popupmenudispatcher.hxx
blob5b705e7b07212f7414561c60eb212457b2c78ddb
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: popupmenudispatcher.hxx,v $
10 * $Revision: 1.3 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef __FRAMEWORK_DISPATCH_POPUPMENUDISPATCHER_HXX_
32 #define __FRAMEWORK_DISPATCH_POPUPMENUDISPATCHER_HXX_
34 //_________________________________________________________________________________________________________________
35 // my own includes
36 //_________________________________________________________________________________________________________________
38 #include <services/frame.hxx>
40 #include <macros/generic.hxx>
42 #include <macros/xinterface.hxx>
43 #include <macros/xtypeprovider.hxx>
44 #include <macros/xserviceinfo.hxx>
46 #include <macros/debug.hxx>
48 #include <threadhelp/threadhelpbase.hxx>
49 #include <general.h>
50 #include <stdtypes.h>
52 //_________________________________________________________________________________________________________________
53 // interface includes
54 //_________________________________________________________________________________________________________________
55 #include <com/sun/star/lang/XTypeProvider.hpp>
56 #include <com/sun/star/frame/XDispatch.hpp>
57 #include <com/sun/star/frame/XDispatchProvider.hpp>
58 #include <com/sun/star/util/URL.hpp>
59 #include <com/sun/star/frame/DispatchDescriptor.hpp>
60 #include <com/sun/star/beans/PropertyValue.hpp>
61 #include <com/sun/star/frame/XStatusListener.hpp>
62 #include <com/sun/star/frame/XFrameLoader.hpp>
63 #include <com/sun/star/frame/XLoadEventListener.hpp>
64 #include <com/sun/star/frame/XDesktop.hpp>
65 #include <com/sun/star/frame/FeatureStateEvent.hpp>
66 #include <com/sun/star/frame/XFrameActionListener.hpp>
67 #include <com/sun/star/lang/XInitialization.hpp>
68 #include <com/sun/star/container/XNameAccess.hpp>
69 #ifndef _COM_SUN_STAR_URI_XURLREFERENCEFACTORY_HPP_
70 #include <com/sun/star/uri/XUriReferenceFactory.hpp>
71 #endif
72 #ifndef _COM_SUN_STAR_URI_XURLREFERENCE_HPP_
73 #include <com/sun/star/uri/XUriReference.hpp>
74 #endif
76 //_________________________________________________________________________________________________________________
77 // other includes
78 //_________________________________________________________________________________________________________________
79 #include <cppuhelper/weak.hxx>
80 #include <cppuhelper/weakref.hxx>
81 #include <cppuhelper/interfacecontainer.h>
83 //_________________________________________________________________________________________________________________
84 // namespace
85 //_________________________________________________________________________________________________________________
87 namespace framework{
90 //_________________________________________________________________________________________________________________
91 // exported const
92 //_________________________________________________________________________________________________________________
94 //_________________________________________________________________________________________________________________
95 // exported definitions
96 //_________________________________________________________________________________________________________________
98 /*-************************************************************************************************************//**
99 We must save informations about our listener and URL for listening.
100 We implement this as a hashtable for strings.
101 *//*-*************************************************************************************************************/
103 typedef ::cppu::OMultiTypeInterfaceContainerHelperVar< ::rtl::OUString ,
104 OUStringHashCode ,
105 std::equal_to< ::rtl::OUString > > IMPL_ListenerHashContainer;
108 /*-************************************************************************************************************//**
109 @short helper for desktop only(!) to create new tasks on demand for dispatches
110 @descr Use this class as member only! Never use it as baseclass.
111 XInterface will be ambigous and we hold a weakcss::uno::Reference to ouer OWNER - not to our SUPERCLASS!
113 @implements XInterface
114 XDispatch
115 XLoadEventListener
116 XFrameActionListener
117 XEventListener
118 @base ThreadHelpBase
119 OWeakObject
121 @devstatus ready to use
122 *//*-*************************************************************************************************************/
123 class PopupMenuDispatcher : // interfaces
124 public css::lang::XTypeProvider ,
125 public css::lang::XServiceInfo ,
126 public css::frame::XDispatchProvider ,
127 public css::frame::XDispatch ,
128 public css::frame::XFrameActionListener ,
129 public css::lang::XInitialization ,
130 // baseclasses
131 // Order is neccessary for right initialization!
132 public ThreadHelpBase ,
133 public cppu::OWeakObject
135 //-------------------------------------------------------------------------------------------------------------
136 // public methods
137 //-------------------------------------------------------------------------------------------------------------
138 public:
140 // constructor / destructor
141 PopupMenuDispatcher( const css::uno::Reference< css::lang::XMultiServiceFactory >& xFactory );
143 // XInterface, XTypeProvider, XServiceInfo
144 FWK_DECLARE_XINTERFACE
145 FWK_DECLARE_XTYPEPROVIDER
146 DECLARE_XSERVICEINFO
148 // XInitialization
149 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& lArguments ) throw( css::uno::Exception ,
150 css::uno::RuntimeException);
151 // XDispatchProvider
152 virtual ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > SAL_CALL queryDispatch(
153 const ::com::sun::star::util::URL& aURL ,
154 const ::rtl::OUString& sTarget ,
155 sal_Int32 nFlags )
156 throw( ::com::sun::star::uno::RuntimeException );
158 virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL queryDispatches(
159 const css::uno::Sequence< css::frame::DispatchDescriptor >& lDescriptor )
160 throw( css::uno::RuntimeException );
162 // XDispatch
163 virtual void SAL_CALL dispatch( const css::util::URL& aURL,
164 const css::uno::Sequence< css::beans::PropertyValue >& seqProperties ) throw( css::uno::RuntimeException );
166 virtual void SAL_CALL addStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xControl,
167 const css::util::URL& aURL ) throw( css::uno::RuntimeException );
169 virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xControl,
170 const css::util::URL& aURL ) throw( css::uno::RuntimeException );
173 // XFrameActionListener
174 virtual void SAL_CALL frameAction( const css::frame::FrameActionEvent& aEvent ) throw ( css::uno::RuntimeException );
176 // XEventListener
177 void SAL_CALL disposing( const css::lang::EventObject& aEvent ) throw( css::uno::RuntimeException );
179 // protected methods
180 protected:
181 virtual ~PopupMenuDispatcher();
183 void impl_RetrievePopupControllerQuery();
184 void impl_CreateUriRefFactory();
186 // private methods
188 // variables
189 private:
190 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!)
191 css::uno::Reference< css::container::XNameAccess > m_xPopupCtrlQuery ; /// reference to query for popup controller
192 css::uno::Reference< css::uri::XUriReferenceFactory > m_xUriRefFactory ; /// reference to the uri reference factory
193 css::uno::Reference< css::lang::XMultiServiceFactory > m_xFactory ; /// factory shared with our owner to create new services!
194 IMPL_ListenerHashContainer m_aListenerContainer; /// hash table for listener at specified URLs
195 sal_Bool m_bAlreadyDisposed ; /// Protection against multiple disposing calls.
196 sal_Bool m_bActivateListener ; /// dispatcher is listener for frame activation
198 }; // class PopupMenuDispatcher
200 } // namespace framework
202 #endif // #ifndef __FRAMEWORK_DISPATCH_POPUPMENUDISPATCHER_HXX_