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_SERVICES_DISPATCHHELPER_HXX
21 #define INCLUDED_FRAMEWORK_INC_SERVICES_DISPATCHHELPER_HXX
23 #include <config_options.h>
24 #include <com/sun/star/frame/XDispatchHelper.hpp>
25 #include <com/sun/star/frame/XDispatchResultListener.hpp>
26 #include <com/sun/star/lang/XServiceInfo.hpp>
27 #include <com/sun/star/uno/Any.hxx>
29 #include <cppuhelper/implbase.hxx>
30 #include <framework/fwkdllapi.h>
31 #include <condition_variable>
34 namespace com::sun::star::lang
36 class XMultiServiceFactory
;
38 namespace com::sun::star::lang
40 class XSingleServiceFactory
;
42 namespace com::sun::star::uno
44 class XComponentContext
;
50 @short implements an easy way for dispatches
51 @descr Dispatches are split into different parts:
53 - searching for a dispatch object
54 - dispatching of the URL
55 All these steps are done inside one method call here.
57 class UNLESS_MERGELIBS(FWK_DLLPUBLIC
) DispatchHelper final
58 : public ::cppu::WeakImplHelper
<css::lang::XServiceInfo
, css::frame::XDispatchHelper
,
59 css::frame::XDispatchResultListener
>
63 /** global uno service manager.
64 Can be used to create own needed services. */
65 css::uno::Reference
<css::uno::XComponentContext
> m_xContext
;
67 /** used to wait for asynchronous listener callbacks. */
68 std::condition_variable m_aBlock
;
71 css::uno::Any m_aResult
;
73 css::uno::Reference
<css::uno::XInterface
> m_xBroadcaster
;
80 DispatchHelper(css::uno::Reference
<css::uno::XComponentContext
> xContext
);
81 virtual ~DispatchHelper() override
;
84 virtual OUString SAL_CALL
getImplementationName() override
;
85 virtual sal_Bool SAL_CALL
supportsService(const OUString
& sServiceName
) override
;
86 virtual css::uno::Sequence
<OUString
> SAL_CALL
getSupportedServiceNames() override
;
89 virtual css::uno::Any SAL_CALL
90 executeDispatch(const css::uno::Reference
<css::frame::XDispatchProvider
>& xDispatchProvider
,
91 const OUString
& sURL
, const OUString
& sTargetFrameName
, sal_Int32 nSearchFlags
,
92 const css::uno::Sequence
<css::beans::PropertyValue
>& lArguments
) override
;
94 // not a public XDispatchHelper-method, need in sfx2/source/control/statcach.cxx for extensions
95 /// @throws css::uno::RuntimeException
97 executeDispatch(const css::uno::Reference
<css::frame::XDispatch
>& xDispatch
,
98 const css::util::URL
& aURL
, bool SyncronFlag
,
99 const css::uno::Sequence
<css::beans::PropertyValue
>& lArguments
);
101 // XDispatchResultListener
102 virtual void SAL_CALL
dispatchFinished(const css::frame::DispatchResultEvent
& aResult
) override
;
105 virtual void SAL_CALL
disposing(const css::lang::EventObject
& aEvent
) override
;
111 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */