LibreOffice Module framework (master) 1
windowcommanddispatch.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/awt/XWindow.hpp>
23#include <com/sun/star/frame/XFrame.hpp>
24
26#include <tools/link.hxx>
27#include <mutex>
28
29namespace com::sun::star::uno {
30 class XComponentContext;
31}
32class VclWindowEvent;
33
34namespace framework{
35
48{
49 private:
50 std::mutex m_mutex;
51
53 css::uno::Reference< css::uno::XComponentContext > m_xContext;
54
56 css::uno::WeakReference< css::frame::XFrame > m_xFrame;
57
59 css::uno::WeakReference< css::awt::XWindow > m_xWindow;
60
61 // native interface
62
63 public:
64
77 WindowCommandDispatch(css::uno::Reference< css::uno::XComponentContext > xContext ,
78 const css::uno::Reference< css::frame::XFrame >& xFrame);
79
83
84 // implementation
85
86 private:
87
95
99 void impl_stopListening();
100
103 DECL_LINK( impl_notifyCommand, VclWindowEvent&, void );
104
105}; // class WindowCommandDispatch
106
107} // namespace framework
108
109/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
internal helper to bind e.g.
css::uno::WeakReference< css::frame::XFrame > m_xFrame
knows the frame, where we dispatch our commands as weak reference
~WindowCommandDispatch()
used to free internal resources.
css::uno::WeakReference< css::awt::XWindow > m_xWindow
knows the VCL window (where the hard coded commands occurred) as weak XWindow reference
void impl_startListening()
establish all listener connections we need.
css::uno::Reference< css::uno::XComponentContext > m_xContext
can be used to create own needed services on demand.
DECL_LINK(impl_notifyCommand, VclWindowEvent &, void)
callback from VCL to notify new commands
void impl_stopListening()
drop all listener connections we need.
WindowCommandDispatch(css::uno::Reference< css::uno::XComponentContext > xContext, const css::uno::Reference< css::frame::XFrame > &xFrame)
creates a new instance and initialize it with all necessary parameters.