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 .
20 #ifndef INCLUDED_SVTOOLS_STATUSBARCONTROLLER_HXX
21 #define INCLUDED_SVTOOLS_STATUSBARCONTROLLER_HXX
23 #include <svtools/svtdllapi.h>
24 #include <com/sun/star/frame/XStatusbarController.hpp>
25 #include <cppuhelper/weak.hxx>
26 #include <cppuhelper/interfacecontainer.hxx>
27 #include <cppuhelper/basemutex.hxx>
28 #include <tools/gen.hxx>
29 #include <unordered_map>
31 namespace com :: sun :: star :: awt
{ class XWindow
; }
32 namespace com :: sun :: star :: beans
{ struct PropertyValue
; }
33 namespace com :: sun :: star :: frame
{ class XDispatch
; }
34 namespace com :: sun :: star :: frame
{ class XFrame
; }
35 namespace com :: sun :: star :: ui
{ class XStatusbarItem
; }
36 namespace com :: sun :: star :: uno
{ class XComponentContext
; }
37 namespace com :: sun :: star :: util
{ class XURLTransformer
; }
42 class SVT_DLLPUBLIC StatusbarController
:
43 public css::frame::XStatusbarController
,
44 public ::cppu::BaseMutex
,
45 public ::cppu::OWeakObject
48 StatusbarController( const css::uno::Reference
< css::uno::XComponentContext
>& rxContext
,
49 const css::uno::Reference
< css::frame::XFrame
>& xFrame
,
50 const OUString
& aCommandURL
,
52 StatusbarController();
53 virtual ~StatusbarController() override
;
55 css::uno::Reference
< css::frame::XFrame
> getFrameInterface() const;
56 css::uno::Reference
< css::util::XURLTransformer
> getURLTransformer() const;
58 ::tools::Rectangle
getControlRect() const;
61 virtual css::uno::Any SAL_CALL
queryInterface( const css::uno::Type
& aType
) override
;
62 virtual void SAL_CALL
acquire() throw () override
;
63 virtual void SAL_CALL
release() throw () override
;
66 virtual void SAL_CALL
initialize( const css::uno::Sequence
< css::uno::Any
>& aArguments
) override
;
69 virtual void SAL_CALL
update() override
;
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
;
77 virtual void SAL_CALL
disposing( const css::lang::EventObject
& Source
) override
;
80 virtual void SAL_CALL
statusChanged( const css::frame::FeatureStateEvent
& Event
) override
;
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
,
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
;
99 Listener( const css::util::URL
& rURL
, const css::uno::Reference
< css::frame::XDispatch
>& rDispatch
) :
100 aURL( rURL
), xDispatch( rDispatch
) {}
102 css::util::URL
const aURL
;
103 css::uno::Reference
< css::frame::XDispatch
> xDispatch
;
106 typedef std::unordered_map
< OUString
,
107 css::uno::Reference
< css::frame::XDispatch
> > URLToDispatchMap
;
109 // methods to support status forwarder, known by the old sfx2 toolbox controller implementation
110 void addStatusListener( const OUString
& aCommandURL
);
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
);
118 bool m_bInitialized
: 1,
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
;
124 OUString m_aCommandURL
;
125 URLToDispatchMap m_aListenerMap
;
126 ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer
; /// container for ALL Listener
127 mutable css::uno::Reference
< css::util::XURLTransformer
> m_xURLTransformer
;
128 css::uno::Reference
< css::ui::XStatusbarItem
> m_xStatusbarItem
;
133 #endif // INCLUDED_SVTOOLS_STATUSBARCONTROLLER_HXX
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */