LibreOffice Module framework (master) 1
closedispatcher.hxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#pragma once
21
22#include <com/sun/star/frame/XFrame.hpp>
23#include <com/sun/star/frame/XStatusListener.hpp>
24#include <com/sun/star/frame/XNotifyingDispatch.hpp>
25#include <com/sun/star/frame/XDispatchInformationProvider.hpp>
26#include <com/sun/star/util/URL.hpp>
27#include <com/sun/star/frame/XDispatchResultListener.hpp>
28#include <com/sun/star/uno/XComponentContext.hpp>
29
30#include <memory>
33#include <vcl/evntpost.hxx>
34#include <vcl/vclptr.hxx>
35
36class SystemWindow;
37
38namespace framework{
39
50class CloseDispatcher final : public ::cppu::WeakImplHelper<
51 css::frame::XNotifyingDispatch, // => XDispatch
52 css::frame::XDispatchInformationProvider >
53{
54
55 // types
56
57 private:
58
63 {
67 };
68
69 // member
70
71 private:
72
76 css::uno::Reference< css::uno::XComponentContext > m_xContext;
77
80 css::uno::WeakReference< css::frame::XFrame > m_xCloseFrame;
81
85 std::unique_ptr<vcl::EventPoster> m_aAsyncCallback;
86
90
92 css::uno::Reference< css::uno::XInterface > m_xSelfHold;
93
95 css::uno::Reference< css::frame::XDispatchResultListener > m_xResultListener;
96
98
99 // native interface
100
101 public:
102
118 CloseDispatcher(css::uno::Reference< css::uno::XComponentContext > xContext ,
119 const css::uno::Reference< css::frame::XFrame >& xFrame ,
120 std::u16string_view sTarget);
121
123 virtual ~CloseDispatcher() override;
124
125 // uno interface
126
127 public:
128
129 // XNotifyingDispatch
130 virtual void SAL_CALL dispatchWithNotification( const css::util::URL& aURL ,
131 const css::uno::Sequence< css::beans::PropertyValue >& lArguments,
132 const css::uno::Reference< css::frame::XDispatchResultListener >& xListener ) override;
133
134 // XDispatch
135 virtual void SAL_CALL dispatch ( const css::util::URL& aURL ,
136 const css::uno::Sequence< css::beans::PropertyValue >& lArguments) override;
137 virtual void SAL_CALL addStatusListener ( const css::uno::Reference< css::frame::XStatusListener >& xListener ,
138 const css::util::URL& aURL ) override;
139 virtual void SAL_CALL removeStatusListener( const css::uno::Reference< css::frame::XStatusListener >& xListener ,
140 const css::util::URL& aURL ) override;
141
142 // XDispatchInformationProvider
143 virtual css::uno::Sequence< sal_Int16 > SAL_CALL getSupportedCommandGroups ( ) override;
144 virtual css::uno::Sequence< css::frame::DispatchInformation > SAL_CALL getConfigurableDispatchInformation( sal_Int16 nCommandGroup ) override;
145
146 // internal helper
147
148 private:
149
156 DECL_LINK( impl_asyncCallback, LinkParamNone*, void );
157
175 bool implts_prepareFrameForClosing(const css::uno::Reference< css::frame::XFrame >& xFrame,
176 bool bCloseAllOtherViewsToo,
177 bool& bControllerSuspended );
178
193 bool implts_closeFrame();
194
202
215
231 void implts_notifyResultListener(const css::uno::Reference< css::frame::XDispatchResultListener >& xListener,
232 sal_Int16 nState ,
233 const css::uno::Any& aResult );
234
254 static css::uno::Reference< css::frame::XFrame > static_impl_searchRightTargetFrame(const css::uno::Reference< css::frame::XFrame >& xFrame ,
255 std::u16string_view sTarget);
256
257}; // class CloseDispatcher
258
259} // namespace framework
260
261/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
helper to dispatch the URLs ".uno:CloseDoc"/".uno:CloseWin"/".uno:CloseFrame" to close a frame/docume...
virtual css::uno::Sequence< sal_Int16 > SAL_CALL getSupportedCommandGroups() override
virtual ~CloseDispatcher() override
does nothing real.
virtual void SAL_CALL addStatusListener(const css::uno::Reference< css::frame::XStatusListener > &xListener, const css::util::URL &aURL) override
bool implts_prepareFrameForClosing(const css::uno::Reference< css::frame::XFrame > &xFrame, bool bCloseAllOtherViewsToo, bool &bControllerSuspended)
prepare m_xCloseFrame so it should be closeable without problems.
virtual void SAL_CALL removeStatusListener(const css::uno::Reference< css::frame::XStatusListener > &xListener, const css::util::URL &aURL) override
bool implts_terminateApplication()
calls XDesktop->terminate().
std::unique_ptr< vcl::EventPoster > m_aAsyncCallback
used for asynchronous callbacks within the main thread.
css::uno::Reference< css::uno::XComponentContext > m_xContext
reference to a uno service manager, which can be used to create own needed uno resources.
css::uno::Reference< css::uno::XInterface > m_xSelfHold
for asynchronous operations we must hold us self alive!
void implts_notifyResultListener(const css::uno::Reference< css::frame::XDispatchResultListener > &xListener, sal_Int16 nState, const css::uno::Any &aResult)
notify a DispatchResultListener.
virtual css::uno::Sequence< css::frame::DispatchInformation > SAL_CALL getConfigurableDispatchInformation(sal_Int16 nCommandGroup) override
virtual void SAL_CALL dispatchWithNotification(const css::util::URL &aURL, const css::uno::Sequence< css::beans::PropertyValue > &lArguments, const css::uno::Reference< css::frame::XDispatchResultListener > &xListener) override
DECL_LINK(impl_asyncCallback, LinkParamNone *, void)
a callback for asynchronous started operations.
static css::uno::Reference< css::frame::XFrame > static_impl_searchRightTargetFrame(const css::uno::Reference< css::frame::XFrame > &xFrame, std::u16string_view sTarget)
try to find the right target frame where this close request must be really done.
EOperation m_eOperation
used inside asynchronous callback to decide, which operation must be executed.
bool implts_closeFrame()
close the member m_xCloseFrame.
css::uno::WeakReference< css::frame::XFrame > m_xCloseFrame
reference to the target frame, which should be closed by this dispatch.
virtual void SAL_CALL dispatch(const css::util::URL &aURL, const css::uno::Sequence< css::beans::PropertyValue > &lArguments) override
VclPtr< SystemWindow > m_pSysWindow
EOperation
describe, which request must be done here.
css::uno::Reference< css::frame::XDispatchResultListener > m_xResultListener
holded alive for internally asynchronous operations!
CloseDispatcher(css::uno::Reference< css::uno::XComponentContext > xContext, const css::uno::Reference< css::frame::XFrame > &xFrame, std::u16string_view sTarget)
connect a new CloseDispatcher instance to its frame.
bool implts_establishBackingMode()
set the special BackingComponent (now StartModule) as new component of our m_xCloseFrame.