update dev300-m57
[ooovba.git] / svtools / inc / statusbarcontroller.hxx
blob41376d38e397176bd579635e1210d142c050045f
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: statusbarcontroller.hxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _SVTOOLS_STATUSBARCONTROLLER_HXX
32 #define _SVTOOLS_STATUSBARCONTROLLER_HXX
34 #include "svtools/svtdllapi.h"
35 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
36 #include <com/sun/star/lang/XInitialization.hpp>
37 #include <com/sun/star/util/XUpdatable.hpp>
38 #include <com/sun/star/frame/XFrame.hpp>
39 #include <com/sun/star/frame/XDispatch.hpp>
40 #include <com/sun/star/frame/XStatusListener.hpp>
41 #include <com/sun/star/frame/XStatusbarController.hpp>
42 #include <com/sun/star/util/XURLTransformer.hpp>
43 #include <com/sun/star/frame/XLayoutManager.hpp>
44 #include <cppuhelper/weak.hxx>
45 #include <cppuhelper/interfacecontainer.hxx>
46 #include <comphelper/broadcasthelper.hxx>
48 #ifndef INCLUDED_HASH_MAP
49 #include <hash_map>
50 #define INCLUDED_HASH_MAP
51 #endif
53 #include <tools/gen.hxx>
55 namespace svt
58 class SVT_DLLPUBLIC StatusbarController : public ::com::sun::star::frame::XStatusListener,
59 public ::com::sun::star::frame::XStatusbarController,
60 public ::com::sun::star::lang::XInitialization,
61 public ::com::sun::star::util::XUpdatable,
62 public ::com::sun::star::lang::XComponent,
63 public ::comphelper::OBaseMutex,
64 public ::cppu::OWeakObject
66 public:
67 StatusbarController( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServiceManager,
68 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame,
69 const rtl::OUString& aCommandURL,
70 unsigned short nID );
71 StatusbarController();
72 virtual ~StatusbarController();
74 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > getFrameInterface() const;
75 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getServiceManager() const;
76 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager > getLayoutManager() const;
77 ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > getURLTransformer() const;
79 void updateStatus( const rtl::OUString aCommandURL );
80 void updateStatus();
82 ::Rectangle getControlRect() const;
84 // XInterface
85 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException);
86 virtual void SAL_CALL acquire() throw ();
87 virtual void SAL_CALL release() throw ();
89 // XInitialization
90 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);
92 // XUpdatable
93 virtual void SAL_CALL update() throw (::com::sun::star::uno::RuntimeException);
95 // XComponent
96 virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException);
97 virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
98 virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
100 // XEventListener
101 virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& Source ) throw ( ::com::sun::star::uno::RuntimeException );
103 // XStatusListener
104 virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException );
106 // XStatusbarController
107 virtual ::sal_Bool SAL_CALL mouseButtonDown( const ::com::sun::star::awt::MouseEvent& aMouseEvent ) throw (::com::sun::star::uno::RuntimeException);
108 virtual ::sal_Bool SAL_CALL mouseMove( const ::com::sun::star::awt::MouseEvent& aMouseEvent ) throw (::com::sun::star::uno::RuntimeException);
109 virtual ::sal_Bool SAL_CALL mouseButtonUp( const ::com::sun::star::awt::MouseEvent& aMouseEvent ) throw (::com::sun::star::uno::RuntimeException);
110 virtual void SAL_CALL command( const ::com::sun::star::awt::Point& aPos,
111 ::sal_Int32 nCommand,
112 ::sal_Bool bMouseEvent,
113 const ::com::sun::star::uno::Any& aData ) throw (::com::sun::star::uno::RuntimeException);
114 virtual void SAL_CALL paint( const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XGraphics >& xGraphics,
115 const ::com::sun::star::awt::Rectangle& rOutputRectangle,
116 ::sal_Int32 nItemId, ::sal_Int32 nStyle ) throw (::com::sun::star::uno::RuntimeException);
117 virtual void SAL_CALL click() throw (::com::sun::star::uno::RuntimeException);
118 virtual void SAL_CALL doubleClick() throw (::com::sun::star::uno::RuntimeException);
120 protected:
121 struct Listener
123 Listener( const ::com::sun::star::util::URL& rURL, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >& rDispatch ) :
124 aURL( rURL ), xDispatch( rDispatch ) {}
126 ::com::sun::star::util::URL aURL;
127 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDispatch;
130 typedef ::std::hash_map< ::rtl::OUString,
131 com::sun::star::uno::Reference< com::sun::star::frame::XDispatch >,
132 ::rtl::OUStringHash,
133 ::std::equal_to< ::rtl::OUString > > URLToDispatchMap;
135 // methods to support status forwarder, known by the old sfx2 toolbox controller implementation
136 void addStatusListener( const rtl::OUString& aCommandURL );
137 void removeStatusListener( const rtl::OUString& aCommandURL );
138 void bindListener();
139 void unbindListener();
140 sal_Bool isBound() const;
142 // execute methods
143 // execute bound status bar controller command/execute various commands
144 void execute( const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs );
145 void execute( const rtl::OUString& aCommand, const ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue >& aArgs );
147 sal_Bool m_bInitialized : 1,
148 m_bDisposed : 1;
149 unsigned short m_nID;
150 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame;
151 ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xParentWindow;
152 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager;
153 rtl::OUString m_aCommandURL;
154 URLToDispatchMap m_aListenerMap;
155 ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer; /// container for ALL Listener
156 mutable ::com::sun::star::uno::Reference< ::com::sun::star::util::XURLTransformer > m_xURLTransformer;
161 #endif // _SVTOOLS_TOOLBOXCONTROLLER_HXX