LibreOffice Module svtools (master) 1
framestatuslistener.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/XFrameActionListener.hpp>
23#include <com/sun/star/frame/XStatusListener.hpp>
24#include <cppuhelper/weak.hxx>
25
26#include <unordered_map>
27#include <utility>
28
29namespace com :: sun :: star :: frame { class XDispatch; }
30namespace com :: sun :: star :: frame { class XFrame; }
31namespace com :: sun :: star :: uno { class XComponentContext; }
32
33namespace svt
34{
35
36class FrameStatusListener : public css::frame::XStatusListener,
37 public css::frame::XFrameActionListener,
38 public css::lang::XComponent,
40{
41 public:
42 FrameStatusListener( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
43 const css::uno::Reference< css::frame::XFrame >& xFrame );
44 virtual ~FrameStatusListener() override;
45
46 // methods to support status forwarder, known by the old sfx2 toolbox controller implementation
47 void addStatusListener( const OUString& aCommandURL );
48 void bindListener();
49
50 // XInterface
51 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
52 virtual void SAL_CALL acquire() noexcept override;
53 virtual void SAL_CALL release() noexcept override;
54
55 // XComponent
56 virtual void SAL_CALL dispose() override;
57 virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
58 virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override;
59
60 // XEventListener
61 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
62
63 // XStatusListener
64 virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) override = 0;
65
66 // XFrameActionListener
67 virtual void SAL_CALL frameAction( const css::frame::FrameActionEvent& Action ) override;
68
69 private:
70 struct Listener
71 {
72 Listener( css::util::URL _aURL, css::uno::Reference< css::frame::XDispatch > _xDispatch ) :
73 aURL(std::move( _aURL )), xDispatch(std::move( _xDispatch )) {}
74
75 css::util::URL aURL;
76 css::uno::Reference< css::frame::XDispatch > xDispatch;
77 };
78
79 typedef std::unordered_map< OUString,
80 css::uno::Reference< css::frame::XDispatch > > URLToDispatchMap;
81
82 bool m_bDisposed : 1;
83 css::uno::Reference< css::frame::XFrame > m_xFrame;
84 css::uno::Reference< css::uno::XComponentContext > m_xContext;
86};
87
88}
89
90/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual void SAL_CALL acquire() noexcept override
virtual void SAL_CALL addEventListener(const css::uno::Reference< css::lang::XEventListener > &xListener) override
void addStatusListener(const OUString &aCommandURL)
virtual void SAL_CALL dispose() override
virtual ~FrameStatusListener() override
virtual void SAL_CALL statusChanged(const css::frame::FeatureStateEvent &Event) override=0
std::unordered_map< OUString, css::uno::Reference< css::frame::XDispatch > > URLToDispatchMap
virtual void SAL_CALL release() noexcept override
css::uno::Reference< css::uno::XComponentContext > m_xContext
css::uno::Reference< css::frame::XFrame > m_xFrame
virtual void SAL_CALL disposing(const css::lang::EventObject &Source) override
virtual void SAL_CALL removeEventListener(const css::uno::Reference< css::lang::XEventListener > &aListener) override
virtual void SAL_CALL frameAction(const css::frame::FrameActionEvent &Action) override
virtual css::uno::Any SAL_CALL queryInterface(const css::uno::Type &aType) override
FrameStatusListener(const css::uno::Reference< css::uno::XComponentContext > &rxContext, const css::uno::Reference< css::frame::XFrame > &xFrame)
Listener(css::util::URL _aURL, css::uno::Reference< css::frame::XDispatch > _xDispatch)
css::uno::Reference< css::frame::XDispatch > xDispatch
Reference< XFrame > xFrame