Bump version to 21.06.18.1
[LibreOffice.git] / include / svtools / framestatuslistener.hxx
blob77cc12f9e1005fdcbcd36b32dee71652d335cd9b
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/XFrameActionListener.hpp>
23 #include <com/sun/star/frame/XStatusListener.hpp>
24 #include <cppuhelper/weak.hxx>
25 #include <cppuhelper/basemutex.hxx>
27 #include <unordered_map>
29 namespace com :: sun :: star :: frame { class XDispatch; }
30 namespace com :: sun :: star :: frame { class XFrame; }
31 namespace com :: sun :: star :: uno { class XComponentContext; }
33 namespace svt
36 class FrameStatusListener : public css::frame::XStatusListener,
37 public css::frame::XFrameActionListener,
38 public css::lang::XComponent,
39 public ::cppu::BaseMutex,
40 public ::cppu::OWeakObject
42 public:
43 FrameStatusListener( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
44 const css::uno::Reference< css::frame::XFrame >& xFrame );
45 virtual ~FrameStatusListener() override;
47 // methods to support status forwarder, known by the old sfx2 toolbox controller implementation
48 void addStatusListener( const OUString& aCommandURL );
49 void bindListener();
51 // XInterface
52 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
53 virtual void SAL_CALL acquire() throw () override;
54 virtual void SAL_CALL release() throw () override;
56 // XComponent
57 virtual void SAL_CALL dispose() override;
58 virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
59 virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override;
61 // XEventListener
62 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
64 // XStatusListener
65 virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) override = 0;
67 // XFrameActionListener
68 virtual void SAL_CALL frameAction( const css::frame::FrameActionEvent& Action ) override;
70 protected:
71 struct Listener
73 Listener( const css::util::URL& rURL, const css::uno::Reference< css::frame::XDispatch >& rDispatch ) :
74 aURL( rURL ), xDispatch( rDispatch ) {}
76 css::util::URL aURL;
77 css::uno::Reference< css::frame::XDispatch > xDispatch;
80 typedef std::unordered_map< OUString,
81 css::uno::Reference< css::frame::XDispatch > > URLToDispatchMap;
83 bool m_bDisposed : 1;
84 css::uno::Reference< css::frame::XFrame > m_xFrame;
85 css::uno::Reference< css::uno::XComponentContext > m_xContext;
86 URLToDispatchMap m_aListenerMap;
91 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */