Bump version to 21.06.18.1
[LibreOffice.git] / include / svtools / statusbarcontroller.hxx
blobe784dad4dc99cd6e180ea79d9a98b4fa7aa33e20
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 <svtools/svtdllapi.h>
23 #include <com/sun/star/frame/XStatusbarController.hpp>
24 #include <cppuhelper/weak.hxx>
25 #include <cppuhelper/interfacecontainer.hxx>
26 #include <cppuhelper/basemutex.hxx>
27 #include <tools/gen.hxx>
28 #include <unordered_map>
30 namespace com :: sun :: star :: awt { class XWindow; }
31 namespace com :: sun :: star :: beans { struct PropertyValue; }
32 namespace com :: sun :: star :: frame { class XDispatch; }
33 namespace com :: sun :: star :: frame { class XFrame; }
34 namespace com :: sun :: star :: ui { class XStatusbarItem; }
35 namespace com :: sun :: star :: uno { class XComponentContext; }
36 namespace com :: sun :: star :: util { class XURLTransformer; }
38 namespace svt
41 class SVT_DLLPUBLIC StatusbarController :
42 public css::frame::XStatusbarController,
43 public ::cppu::BaseMutex,
44 public ::cppu::OWeakObject
46 public:
47 StatusbarController( const css::uno::Reference< css::uno::XComponentContext >& rxContext,
48 const css::uno::Reference< css::frame::XFrame >& xFrame,
49 const OUString& aCommandURL,
50 unsigned short nID );
51 StatusbarController();
52 virtual ~StatusbarController() override;
54 css::uno::Reference< css::frame::XFrame > getFrameInterface() const;
55 css::uno::Reference< css::util::XURLTransformer > getURLTransformer() const;
57 ::tools::Rectangle getControlRect() const;
59 // XInterface
60 virtual css::uno::Any SAL_CALL queryInterface( const css::uno::Type& aType ) override;
61 virtual void SAL_CALL acquire() throw () override;
62 virtual void SAL_CALL release() throw () override;
64 // XInitialization
65 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
67 // XUpdatable
68 virtual void SAL_CALL update() override;
70 // XComponent
71 virtual void SAL_CALL dispose() override;
72 virtual void SAL_CALL addEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener ) override;
73 virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::lang::XEventListener >& aListener ) override;
75 // XEventListener
76 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
78 // XStatusListener
79 virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) override;
81 // XStatusbarController
82 virtual sal_Bool SAL_CALL mouseButtonDown( const css::awt::MouseEvent& aMouseEvent ) override;
83 virtual sal_Bool SAL_CALL mouseMove( const css::awt::MouseEvent& aMouseEvent ) override;
84 virtual sal_Bool SAL_CALL mouseButtonUp( const css::awt::MouseEvent& aMouseEvent ) override;
85 virtual void SAL_CALL command( const css::awt::Point& aPos,
86 ::sal_Int32 nCommand,
87 sal_Bool bMouseEvent,
88 const css::uno::Any& aData ) override;
89 virtual void SAL_CALL paint( const css::uno::Reference< css::awt::XGraphics >& xGraphics,
90 const css::awt::Rectangle& rOutputRectangle,
91 ::sal_Int32 nStyle ) override;
92 virtual void SAL_CALL click( const css::awt::Point& aPos ) override;
93 virtual void SAL_CALL doubleClick( const css::awt::Point& aPos ) override;
95 protected:
96 struct Listener
98 Listener( const css::util::URL& rURL, const css::uno::Reference< css::frame::XDispatch >& rDispatch ) :
99 aURL( rURL ), xDispatch( rDispatch ) {}
101 css::util::URL aURL;
102 css::uno::Reference< css::frame::XDispatch > xDispatch;
105 typedef std::unordered_map< OUString,
106 css::uno::Reference< css::frame::XDispatch > > URLToDispatchMap;
108 // methods to support status forwarder, known by the old sfx2 toolbox controller implementation
109 void addStatusListener( const OUString& aCommandURL );
110 void bindListener();
112 // execute methods
113 // execute bound status bar controller command/execute various commands
114 void execute( const css::uno::Sequence< css::beans::PropertyValue >& aArgs );
115 void execute( const OUString& aCommand, const css::uno::Sequence< css::beans::PropertyValue >& aArgs );
117 bool m_bInitialized : 1,
118 m_bDisposed : 1;
119 unsigned short m_nID;
120 css::uno::Reference< css::frame::XFrame > m_xFrame;
121 css::uno::Reference< css::awt::XWindow > m_xParentWindow;
122 css::uno::Reference< css::uno::XComponentContext > m_xContext;
123 OUString m_aCommandURL;
124 URLToDispatchMap m_aListenerMap;
125 ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener
126 mutable css::uno::Reference< css::util::XURLTransformer > m_xURLTransformer;
127 css::uno::Reference< css::ui::XStatusbarItem > m_xStatusbarItem;
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */