Coverage Report

Created: 2026-05-16 09:25

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/include/svtools/statusbarcontroller.hxx
Line
Count
Source
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 <svtools/svtdllapi.h>
23
#include <com/sun/star/frame/XStatusbarController.hpp>
24
#include <cppuhelper/weak.hxx>
25
#include <comphelper/interfacecontainer4.hxx>
26
#include <unordered_map>
27
#include <utility>
28
29
namespace com :: sun :: star :: awt { class XWindow; }
30
namespace com :: sun :: star :: beans { struct PropertyValue; }
31
namespace com :: sun :: star :: frame { class XDispatch; }
32
namespace com :: sun :: star :: frame { class XFrame; }
33
namespace com :: sun :: star :: ui { class XStatusbarItem; }
34
namespace com :: sun :: star :: uno { class XComponentContext; }
35
namespace com :: sun :: star :: util { class XURLTransformer; }
36
namespace tools { class Rectangle; }
37
38
namespace svt
39
{
40
41
class SVT_DLLPUBLIC StatusbarController :
42
                            public css::frame::XStatusbarController,
43
                            public ::cppu::OWeakObject
44
{
45
    public:
46
        StatusbarController( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
47
                             const css::uno::Reference< css::frame::XFrame >& xFrame,
48
                             OUString aCommandURL,
49
                             unsigned short       nID );
50
        StatusbarController();
51
        virtual ~StatusbarController() override;
52
53
        css::uno::Reference< css::frame::XFrame > getFrameInterface() const;
54
        css::uno::Reference< css::util::XURLTransformer > getURLTransformer() const;
55
56
        ::tools::Rectangle getControlRect() const;
57
58
        // XInterface
59
        virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
60
        virtual void SAL_CALL acquire() noexcept override;
61
        virtual void SAL_CALL release() noexcept override;
62
63
        // XInitialization
64
        virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
65
66
        // XUpdatable
67
        virtual void SAL_CALL update() override;
68
69
        // XComponent
70
        virtual void SAL_CALL dispose() override;
71
        virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
72
        virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override;
73
74
        // XEventListener
75
        virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
76
77
        // XStatusListener
78
        virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) override;
79
80
        // XStatusbarController
81
        virtual sal_Bool SAL_CALL mouseButtonDown( const css::awt::MouseEvent& aMouseEvent ) override;
82
        virtual sal_Bool SAL_CALL mouseMove( const css::awt::MouseEvent& aMouseEvent ) override;
83
        virtual sal_Bool SAL_CALL mouseButtonUp( const css::awt::MouseEvent& aMouseEvent ) override;
84
        virtual void SAL_CALL command( const css::awt::Point& aPos,
85
                                       ::sal_Int32 nCommand,
86
                                       sal_Bool bMouseEvent,
87
                                       const css::uno::Any& aData ) override;
88
        virtual void SAL_CALL paint( const css::uno::Reference< css::awt::XGraphics >& xGraphics,
89
                                     const css::awt::Rectangle& rOutputRectangle,
90
                                     ::sal_Int32 nStyle ) override;
91
        virtual void SAL_CALL click( const css::awt::Point& aPos ) override;
92
        virtual void SAL_CALL doubleClick( const css::awt::Point& aPos ) override;
93
94
    protected:
95
        struct Listener
96
        {
97
            Listener( css::util::URL _aURL, css::uno::Reference< css::frame::XDispatch > _xDispatch ) :
98
0
                aURL(std::move( _aURL )), xDispatch(std::move( _xDispatch )) {}
99
100
            css::util::URL                               aURL;
101
            css::uno::Reference< css::frame::XDispatch > xDispatch;
102
        };
103
104
        typedef std::unordered_map< OUString,
105
                                    css::uno::Reference< css::frame::XDispatch > > URLToDispatchMap;
106
107
        // methods to support status forwarder, known by the old sfx2 toolbox controller implementation
108
        void addStatusListener( const OUString& aCommandURL );
109
        void bindListener();
110
111
        // execute methods
112
        // execute bound status bar controller command/execute various commands
113
        void execute( const css::uno::Sequence< css::beans::PropertyValue >& aArgs );
114
        void execute( const OUString& aCommand, const css::uno::Sequence< css::beans::PropertyValue >& aArgs );
115
116
        bool                                                      m_bInitialized : 1,
117
                                                                  m_bDisposed : 1;
118
        unsigned short                                            m_nID;
119
        css::uno::Reference< css::frame::XFrame >                 m_xFrame;
120
        css::uno::Reference< css::awt::XWindow >                  m_xParentWindow;
121
        css::uno::Reference< css::uno::XComponentContext >        m_xContext;
122
        OUString                                                  m_aCommandURL;
123
        URLToDispatchMap                                          m_aListenerMap;
124
        comphelper::OInterfaceContainerHelper4<css::lang::XEventListener> m_aEventListeners;
125
        mutable css::uno::Reference< css::util::XURLTransformer > m_xURLTransformer;
126
        css::uno::Reference< css::ui::XStatusbarItem >            m_xStatusbarItem;
127
        std::mutex m_aMutex; // for m_aEventListeners
128
};
129
130
}
131
132
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */