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 .
22 #include <com/sun/star/frame/XFrameActionListener.hpp>
23 #include <com/sun/star/frame/XStatusListener.hpp>
24 #include <cppuhelper/weak.hxx>
26 #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
; }
36 class FrameStatusListener
: public css::frame::XStatusListener
,
37 public css::frame::XFrameActionListener
,
38 public css::lang::XComponent
,
39 public ::cppu::OWeakObject
42 FrameStatusListener( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
,
43 const css::uno::Reference
< css::frame::XFrame
>& xFrame
);
44 virtual ~FrameStatusListener() override
;
46 // methods to support status forwarder, known by the old sfx2 toolbox controller implementation
47 void addStatusListener( const OUString
& aCommandURL
);
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
;
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
;
61 virtual void SAL_CALL
disposing( const css::lang::EventObject
& Source
) override
;
64 virtual void SAL_CALL
statusChanged( const css::frame::FeatureStateEvent
& Event
) override
= 0;
66 // XFrameActionListener
67 virtual void SAL_CALL
frameAction( const css::frame::FrameActionEvent
& Action
) override
;
72 Listener( css::util::URL _aURL
, css::uno::Reference
< css::frame::XDispatch
> _xDispatch
) :
73 aURL(std::move( _aURL
)), xDispatch(std::move( _xDispatch
)) {}
76 css::uno::Reference
< css::frame::XDispatch
> xDispatch
;
79 typedef std::unordered_map
< OUString
,
80 css::uno::Reference
< css::frame::XDispatch
> > URLToDispatchMap
;
83 css::uno::Reference
< css::frame::XFrame
> m_xFrame
;
84 css::uno::Reference
< css::uno::XComponentContext
> m_xContext
;
85 URLToDispatchMap m_aListenerMap
;
90 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */