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