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 _SVTOOLS_STATUSBARCONTROLLER_HXX
21 #define _SVTOOLS_STATUSBARCONTROLLER_HXX
23 #include "svtools/svtdllapi.h"
24 #include <com/sun/star/ui/XStatusbarItem.hpp>
25 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
26 #include <com/sun/star/frame/XFrame.hpp>
27 #include <com/sun/star/frame/XDispatch.hpp>
28 #include <com/sun/star/frame/XStatusbarController.hpp>
29 #include <com/sun/star/util/XURLTransformer.hpp>
30 #include <com/sun/star/frame/XLayoutManager.hpp>
31 #include <cppuhelper/weak.hxx>
32 #include <cppuhelper/interfacecontainer.hxx>
33 #include <comphelper/broadcasthelper.hxx>
35 #include <boost/unordered_map.hpp>
37 #include <tools/gen.hxx>
42 class SVT_DLLPUBLIC StatusbarController
:
43 public ::com::sun::star::frame::XStatusbarController
,
44 public ::com::sun::star::lang::XComponent
,
45 public ::comphelper::OBaseMutex
,
46 public ::cppu::OWeakObject
49 StatusbarController( const com::sun::star::uno::Reference
< com::sun::star::lang::XMultiServiceFactory
>& rServiceManager
,
50 const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
>& xFrame
,
51 const OUString
& aCommandURL
,
53 StatusbarController();
54 virtual ~StatusbarController();
56 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
> getFrameInterface() const;
57 ::com::sun::star::uno::Reference
< ::com::sun::star::util::XURLTransformer
> getURLTransformer() const;
59 ::Rectangle
getControlRect() const;
62 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface( const ::com::sun::star::uno::Type
& aType
) throw (::com::sun::star::uno::RuntimeException
);
63 virtual void SAL_CALL
acquire() throw ();
64 virtual void SAL_CALL
release() throw ();
67 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
);
70 virtual void SAL_CALL
update() throw (::com::sun::star::uno::RuntimeException
);
73 virtual void SAL_CALL
dispose() throw (::com::sun::star::uno::RuntimeException
);
74 virtual void SAL_CALL
addEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& xListener
) throw (::com::sun::star::uno::RuntimeException
);
75 virtual void SAL_CALL
removeEventListener( const ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XEventListener
>& aListener
) throw (::com::sun::star::uno::RuntimeException
);
78 virtual void SAL_CALL
disposing( const com::sun::star::lang::EventObject
& Source
) throw ( ::com::sun::star::uno::RuntimeException
);
81 virtual void SAL_CALL
statusChanged( const ::com::sun::star::frame::FeatureStateEvent
& Event
) throw ( ::com::sun::star::uno::RuntimeException
);
83 // XStatusbarController
84 virtual ::sal_Bool SAL_CALL
mouseButtonDown( const ::com::sun::star::awt::MouseEvent
& aMouseEvent
) throw (::com::sun::star::uno::RuntimeException
);
85 virtual ::sal_Bool SAL_CALL
mouseMove( const ::com::sun::star::awt::MouseEvent
& aMouseEvent
) throw (::com::sun::star::uno::RuntimeException
);
86 virtual ::sal_Bool SAL_CALL
mouseButtonUp( const ::com::sun::star::awt::MouseEvent
& aMouseEvent
) throw (::com::sun::star::uno::RuntimeException
);
87 virtual void SAL_CALL
command( const ::com::sun::star::awt::Point
& aPos
,
89 ::sal_Bool bMouseEvent
,
90 const ::com::sun::star::uno::Any
& aData
) throw (::com::sun::star::uno::RuntimeException
);
91 virtual void SAL_CALL
paint( const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XGraphics
>& xGraphics
,
92 const ::com::sun::star::awt::Rectangle
& rOutputRectangle
,
93 ::sal_Int32 nStyle
) throw (::com::sun::star::uno::RuntimeException
);
94 virtual void SAL_CALL
click( const ::com::sun::star::awt::Point
& aPos
) throw (::com::sun::star::uno::RuntimeException
);
95 virtual void SAL_CALL
doubleClick( const ::com::sun::star::awt::Point
& aPos
) throw (::com::sun::star::uno::RuntimeException
);
100 Listener( const ::com::sun::star::util::URL
& rURL
, const ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatch
>& rDispatch
) :
101 aURL( rURL
), xDispatch( rDispatch
) {}
103 ::com::sun::star::util::URL aURL
;
104 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XDispatch
> xDispatch
;
107 typedef ::boost::unordered_map
< OUString
,
108 com::sun::star::uno::Reference
< com::sun::star::frame::XDispatch
>,
110 ::std::equal_to
< OUString
> > URLToDispatchMap
;
112 // methods to support status forwarder, known by the old sfx2 toolbox controller implementation
113 void addStatusListener( const OUString
& aCommandURL
);
117 // execute bound status bar controller command/execute various commands
118 void execute( const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& aArgs
);
119 void execute( const OUString
& aCommand
, const ::com::sun::star::uno::Sequence
< ::com::sun::star::beans::PropertyValue
>& aArgs
);
121 sal_Bool m_bInitialized
: 1,
123 unsigned short m_nID
;
124 ::com::sun::star::uno::Reference
< ::com::sun::star::frame::XFrame
> m_xFrame
;
125 ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XWindow
> m_xParentWindow
;
126 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XMultiServiceFactory
> m_xServiceManager
;
127 OUString m_aCommandURL
;
128 URLToDispatchMap m_aListenerMap
;
129 ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer
; /// container for ALL Listener
130 mutable ::com::sun::star::uno::Reference
< ::com::sun::star::util::XURLTransformer
> m_xURLTransformer
;
131 ::com::sun::star::uno::Reference
< ::com::sun::star::ui::XStatusbarItem
> m_xStatusbarItem
;
136 #endif // _SVTOOLS_TOOLBOXCONTROLLER_HXX
138 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */