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/XFrame.hpp>
25 #include <com/sun/star/frame/XDispatch.hpp>
26 #include <com/sun/star/frame/XStatusbarController.hpp>
27 #include <com/sun/star/frame/XLayoutManager.hpp>
28 #include <com/sun/star/ui/XStatusbarItem.hpp>
29 #include <com/sun/star/uno/XComponentContext.hpp>
30 #include <com/sun/star/util/XURLTransformer.hpp>
31 #include <cppuhelper/weak.hxx>
32 #include <cppuhelper/interfacecontainer.hxx>
33 #include <comphelper/broadcasthelper.hxx>
34 #include <tools/gen.hxx>
35 #include <unordered_map>
40 class SVT_DLLPUBLIC StatusbarController
:
41 public ::com::sun::star::frame::XStatusbarController
,
42 public ::comphelper::OBaseMutex
,
43 public ::cppu::OWeakObject
46 StatusbarController( const com::sun::star::uno::Reference
< com::sun::star::uno::XComponentContext
>& rxContext
,
47 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& xFrame
,
48 const OUString
& aCommandURL
,
50 StatusbarController();
51 virtual ~StatusbarController();
53 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
> getFrameInterface() const;
54 ::com::sun::star::uno::Reference
< ::com::sun::star::util::XURLTransformer
> getURLTransformer() const;
56 ::Rectangle
getControlRect() const;
59 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& aType
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
60 virtual void SAL_CALL
acquire() throw () SAL_OVERRIDE
;
61 virtual void SAL_CALL
release() throw () SAL_OVERRIDE
;
64 virtual void SAL_CALL
initialize( const ::com::sun::star::uno::Sequence
< ::com::sun::star::uno::Any
>& aArguments
) throw (::com::sun::star::uno::Exception
, ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
67 virtual void SAL_CALL
update() throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
70 virtual void SAL_CALL
dispose() throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
71 virtual void SAL_CALL
addEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
72 virtual void SAL_CALL
removeEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& aListener
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
75 virtual void SAL_CALL
disposing( const com::sun::star::lang::EventObject
& Source
) throw ( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
78 virtual void SAL_CALL
statusChanged( const ::com::sun::star::frame::FeatureStateEvent
& Event
) throw ( ::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
80 // XStatusbarController
81 virtual sal_Bool SAL_CALL
mouseButtonDown( const ::com::sun::star::awt::MouseEvent
& aMouseEvent
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
82 virtual sal_Bool SAL_CALL
mouseMove( const ::com::sun::star::awt::MouseEvent
& aMouseEvent
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
83 virtual sal_Bool SAL_CALL
mouseButtonUp( const ::com::sun::star::awt::MouseEvent
& aMouseEvent
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
84 virtual void SAL_CALL
command( const ::com::sun::star::awt::Point
& aPos
,
87 const ::com::sun::star::uno::Any
& aData
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
88 virtual void SAL_CALL
paint( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XGraphics
>& xGraphics
,
89 const ::com::sun::star::awt::Rectangle
& rOutputRectangle
,
90 ::sal_Int32 nStyle
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
91 virtual void SAL_CALL
click( const ::com::sun::star::awt::Point
& aPos
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
92 virtual void SAL_CALL
doubleClick( const ::com::sun::star::awt::Point
& aPos
) throw (::com::sun::star::uno::RuntimeException
, std::exception
) SAL_OVERRIDE
;
97 Listener( const ::com::sun::star::util::URL
& rURL
, const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatch
>& rDispatch
) :
98 aURL( rURL
), xDispatch( rDispatch
) {}
100 ::com::sun::star::util::URL aURL
;
101 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatch
> xDispatch
;
104 typedef std::unordered_map
< OUString
,
105 css::uno::Reference
< css::frame::XDispatch
>,
107 std::equal_to
< OUString
> > 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 ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& aArgs
);
116 void execute( const OUString
& aCommand
, const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& aArgs
);
118 bool m_bInitialized
: 1,
120 unsigned short m_nID
;
121 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
> m_xFrame
;
122 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> m_xParentWindow
;
123 ::com::sun::star::uno::Reference
< ::com::sun::star::uno::XComponentContext
> m_xContext
;
124 OUString m_aCommandURL
;
125 URLToDispatchMap m_aListenerMap
;
126 ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer
; /// container for ALL Listener
127 mutable ::com::sun::star::uno::Reference
< ::com::sun::star::util::XURLTransformer
> m_xURLTransformer
;
128 ::com::sun::star::uno::Reference
< ::com::sun::star::ui::XStatusbarItem
> m_xStatusbarItem
;
133 #endif // INCLUDED_SVTOOLS_STATUSBARCONTROLLER_HXX
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */