cid#1607171 Data race condition
[LibreOffice.git] / framework / inc / dispatch / popupmenudispatcher.hxx
blob0d22beb8647709900e4b2beb8fcfaad85dd1fc11
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
22 #include <com/sun/star/frame/XDispatch.hpp>
23 #include <com/sun/star/frame/XDispatchProvider.hpp>
24 #include <com/sun/star/util/URL.hpp>
25 #include <com/sun/star/frame/DispatchDescriptor.hpp>
26 #include <com/sun/star/beans/PropertyValue.hpp>
27 #include <com/sun/star/frame/XStatusListener.hpp>
28 #include <com/sun/star/frame/XFrameActionListener.hpp>
29 #include <com/sun/star/lang/XInitialization.hpp>
30 #include <com/sun/star/container/XNameAccess.hpp>
31 #include <com/sun/star/uri/XUriReferenceFactory.hpp>
32 #include <com/sun/star/lang/XServiceInfo.hpp>
33 #include <com/sun/star/uno/XComponentContext.hpp>
35 #include <cppuhelper/implbase.hxx>
36 #include <cppuhelper/weakref.hxx>
38 namespace framework{
40 /*-************************************************************************************************************
41 @short helper for desktop only(!) to create new tasks on demand for dispatches
42 @descr Use this class as member only! Never use it as baseclass.
43 XInterface will be ambiguous and we hold a weakcss::uno::Reference to our OWNER - not to our SUPERCLASS!
45 @implements XInterface
46 XDispatch
47 XLoadEventListener
48 XFrameActionListener
49 XEventListener
50 @base OWeakObject
52 @devstatus ready to use
53 *//*-*************************************************************************************************************/
54 class PopupMenuDispatcher final : public ::cppu::WeakImplHelper<
55 css::lang::XServiceInfo,
56 css::frame::XDispatchProvider,
57 css::frame::XDispatch,
58 css::frame::XFrameActionListener,
59 css::lang::XInitialization >
62 // public methods
64 public:
66 // constructor / destructor
67 PopupMenuDispatcher( css::uno::Reference< css::uno::XComponentContext > xContext );
69 /* interface XServiceInfo */
70 virtual OUString SAL_CALL getImplementationName() override;
71 virtual sal_Bool SAL_CALL supportsService( const OUString& sServiceName ) override;
72 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
74 // XInitialization
75 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& lArguments ) override;
76 // XDispatchProvider
77 virtual css::uno::Reference< css::frame::XDispatch > SAL_CALL queryDispatch(
78 const css::util::URL& aURL ,
79 const OUString& sTarget ,
80 sal_Int32 nFlags ) override;
82 virtual css::uno::Sequence< css::uno::Reference< css::frame::XDispatch > > SAL_CALL queryDispatches(
83 const css::uno::Sequence< css::frame::DispatchDescriptor >& lDescriptor ) override;
85 // XDispatch
86 virtual void SAL_CALL dispatch( const css::util::URL& aURL,
87 const css::uno::Sequence< css::beans::PropertyValue >& seqProperties ) override;
89 virtual void SAL_CALL addStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xControl,
90 const css::util::URL& aURL ) override;
92 virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xControl,
93 const css::util::URL& aURL ) override;
95 // XFrameActionListener
96 virtual void SAL_CALL frameAction( const css::frame::FrameActionEvent& aEvent ) override;
98 // XEventListener
99 void SAL_CALL disposing( const css::lang::EventObject& aEvent ) override;
101 private:
102 virtual ~PopupMenuDispatcher() override;
104 void impl_RetrievePopupControllerQuery();
106 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!)
107 css::uno::Reference< css::container::XNameAccess > m_xPopupCtrlQuery; /// reference to query for popup controller
108 css::uno::Reference< css::uri::XUriReferenceFactory > m_xUriRefFactory; /// reference to the uri reference factory
109 css::uno::Reference< css::uno::XComponentContext > m_xContext; /// factory shared with our owner to create new services!
110 bool m_bAlreadyDisposed; /// Protection against multiple disposing calls.
111 bool m_bActivateListener; /// dispatcher is listener for frame activation
113 }; // class PopupMenuDispatcher
115 } // namespace framework
117 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */