1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #ifndef INCLUDED_FRAMEWORK_INC_DISPATCH_POPUPMENUDISPATCHER_HXX
21 #define INCLUDED_FRAMEWORK_INC_DISPATCH_POPUPMENUDISPATCHER_HXX
23 #include <macros/xinterface.hxx>
24 #include <macros/xtypeprovider.hxx>
25 #include <macros/xserviceinfo.hxx>
29 #include <com/sun/star/lang/XTypeProvider.hpp>
30 #include <com/sun/star/frame/XDispatch.hpp>
31 #include <com/sun/star/frame/XDispatchProvider.hpp>
32 #include <com/sun/star/util/URL.hpp>
33 #include <com/sun/star/frame/DispatchDescriptor.hpp>
34 #include <com/sun/star/beans/PropertyValue.hpp>
35 #include <com/sun/star/frame/XStatusListener.hpp>
36 #include <com/sun/star/frame/XFrameLoader.hpp>
37 #include <com/sun/star/frame/XLoadEventListener.hpp>
38 #include <com/sun/star/frame/XDesktop.hpp>
39 #include <com/sun/star/frame/FeatureStateEvent.hpp>
40 #include <com/sun/star/frame/XFrameActionListener.hpp>
41 #include <com/sun/star/lang/XInitialization.hpp>
42 #include <com/sun/star/container/XNameAccess.hpp>
43 #include <com/sun/star/uri/XUriReferenceFactory.hpp>
44 #include <com/sun/star/uri/XUriReference.hpp>
46 #include <cppuhelper/implbase5.hxx>
47 #include <cppuhelper/weakref.hxx>
48 #include <cppuhelper/interfacecontainer.h>
52 typedef cppu::OMultiTypeInterfaceContainerHelperVar
<OUString
>
53 IMPL_ListenerHashContainer
;
55 /*-************************************************************************************************************
56 @short helper for desktop only(!) to create new tasks on demand for dispatches
57 @descr Use this class as member only! Never use it as baseclass.
58 XInterface will be ambigous and we hold a weakcss::uno::Reference to our OWNER - not to our SUPERCLASS!
60 @implements XInterface
67 @devstatus ready to use
68 *//*-*************************************************************************************************************/
69 class PopupMenuDispatcher
: public ::cppu::WeakImplHelper5
<
70 css::lang::XServiceInfo
,
71 css::frame::XDispatchProvider
,
72 css::frame::XDispatch
,
73 css::frame::XFrameActionListener
,
74 css::lang::XInitialization
>
81 // constructor / destructor
82 PopupMenuDispatcher( const css::uno::Reference
< css::uno::XComponentContext
>& xContext
);
84 // XInterface, XTypeProvider, XServiceInfo
88 virtual void SAL_CALL
initialize( const css::uno::Sequence
< css::uno::Any
>& lArguments
) throw( css::uno::Exception
,
89 css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
91 virtual ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatch
> SAL_CALL
queryDispatch(
92 const ::com::sun::star::util::URL
& aURL
,
93 const OUString
& sTarget
,
95 throw( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
97 virtual css::uno::Sequence
< css::uno::Reference
< css::frame::XDispatch
> > SAL_CALL
queryDispatches(
98 const css::uno::Sequence
< css::frame::DispatchDescriptor
>& lDescriptor
)
99 throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
102 virtual void SAL_CALL
dispatch( const css::util::URL
& aURL
,
103 const css::uno::Sequence
< css::beans::PropertyValue
>& seqProperties
) throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
105 virtual void SAL_CALL
addStatusListener( const css::uno::Reference
< css::frame::XStatusListener
>& xControl
,
106 const css::util::URL
& aURL
) throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
108 virtual void SAL_CALL
removeStatusListener( const css::uno::Reference
< css::frame::XStatusListener
>& xControl
,
109 const css::util::URL
& aURL
) throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
111 // XFrameActionListener
112 virtual void SAL_CALL
frameAction( const css::frame::FrameActionEvent
& aEvent
) throw ( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
115 void SAL_CALL
disposing( const css::lang::EventObject
& aEvent
) throw( css::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
119 virtual ~PopupMenuDispatcher();
121 void impl_RetrievePopupControllerQuery();
122 void impl_CreateUriRefFactory();
127 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!)
128 css::uno::Reference
< css::container::XNameAccess
> m_xPopupCtrlQuery
; /// reference to query for popup controller
129 css::uno::Reference
< css::uri::XUriReferenceFactory
> m_xUriRefFactory
; /// reference to the uri reference factory
130 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
; /// factory shared with our owner to create new services!
132 IMPL_ListenerHashContainer m_aListenerContainer
; /// hash table for listener at specified URLs
133 bool m_bAlreadyDisposed
; /// Protection against multiple disposing calls.
134 bool m_bActivateListener
; /// dispatcher is listener for frame activation
136 }; // class PopupMenuDispatcher
138 } // namespace framework
140 #endif // INCLUDED_FRAMEWORK_INC_DISPATCH_POPUPMENUDISPATCHER_HXX
142 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */