workaround segfault in compiler on macos-clang-intel
[LibreOffice.git] / include / svtools / statusbarcontroller.hxx
blobd18cfde1b31ca373bd70dc6c776cb09fa409d31f
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 <comphelper/interfacecontainer4.hxx>
26 #include <tools/gen.hxx>
27 #include <unordered_map>
28 #include <utility>
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::OWeakObject
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;
53 css::uno::Reference< css::frame::XFrame > getFrameInterface() const;
54 css::uno::Reference< css::util::XURLTransformer > getURLTransformer() const;
56 ::tools::Rectangle getControlRect() const;
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;
63 // XInitialization
64 virtual void SAL_CALL initialize( const css::uno::Sequence< css::uno::Any >& aArguments ) override;
66 // XUpdatable
67 virtual void SAL_CALL update() override;
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;
74 // XEventListener
75 virtual void SAL_CALL disposing( const css::lang::EventObject& Source ) override;
77 // XStatusListener
78 virtual void SAL_CALL statusChanged( const css::frame::FeatureStateEvent& Event ) override;
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;
94 protected:
95 struct Listener
97 Listener( css::util::URL _aURL, css::uno::Reference< css::frame::XDispatch > _xDispatch ) :
98 aURL(std::move( _aURL )), xDispatch(std::move( _xDispatch )) {}
100 css::util::URL aURL;
101 css::uno::Reference< css::frame::XDispatch > xDispatch;
104 typedef std::unordered_map< OUString,
105 css::uno::Reference< css::frame::XDispatch > > URLToDispatchMap;
107 // methods to support status forwarder, known by the old sfx2 toolbox controller implementation
108 void addStatusListener( const OUString& aCommandURL );
109 void bindListener();
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 );
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
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */