update dev300-m57
[ooovba.git] / svtools / inc / framestatuslistener.hxx
blob1da27f536364a718a6f4d3240ea751870b76c1ad
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: framestatuslistener.hxx,v $
10 * $Revision: 1.5 $
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_FRAMESTATUSLISTENER_HXX
32 #define _SVTOOLS_FRAMESTATUSLISTENER_HXX
34 #include "svtools/svtdllapi.h"
35 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
36 #include <com/sun/star/util/XURLTransformer.hpp>
37 #include <com/sun/star/frame/XFrame.hpp>
38 #include <com/sun/star/frame/XFrameActionListener.hpp>
39 #include <com/sun/star/frame/XDispatch.hpp>
40 #include <com/sun/star/frame/XStatusListener.hpp>
41 #include <cppuhelper/weak.hxx>
42 #include <cppuhelper/interfacecontainer.hxx>
43 #include <comphelper/broadcasthelper.hxx>
45 #ifndef INCLUDED_HASH_MAP
46 #include <hash_map>
47 #define INCLUDED_HASH_MAP
48 #endif
50 namespace svt
53 class SVT_DLLPUBLIC FrameStatusListener : public ::com::sun::star::frame::XStatusListener,
54 public ::com::sun::star::frame::XFrameActionListener,
55 public ::com::sun::star::lang::XComponent,
56 public ::comphelper::OBaseMutex,
57 public ::cppu::OWeakObject
59 public:
60 FrameStatusListener( const com::sun::star::uno::Reference< com::sun::star::lang::XMultiServiceFactory >& rServiceManager,
61 const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame >& xFrame );
62 virtual ~FrameStatusListener();
64 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > getFrameInterface() const;
65 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > getServiceManager() const;
67 void updateStatus( const rtl::OUString aCommandURL );
69 // methods to support status forwarder, known by the old sfx2 toolbox controller implementation
70 void addStatusListener( const rtl::OUString& aCommandURL );
71 void removeStatusListener( const rtl::OUString& aCommandURL );
72 void bindListener();
73 void unbindListener();
74 sal_Bool isBound() const;
76 // XInterface
77 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException);
78 virtual void SAL_CALL acquire() throw ();
79 virtual void SAL_CALL release() throw ();
81 // XComponent
82 virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException);
83 virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
84 virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
86 // XEventListener
87 virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& Source ) throw ( ::com::sun::star::uno::RuntimeException );
89 // XStatusListener
90 virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException ) = 0;
92 // XFrameActionListener
93 virtual void SAL_CALL frameAction( const com::sun::star::frame::FrameActionEvent& Action ) throw ( ::com::sun::star::uno::RuntimeException );
95 protected:
96 struct Listener
98 Listener( const ::com::sun::star::util::URL& rURL, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >& rDispatch ) :
99 aURL( rURL ), xDispatch( rDispatch ) {}
101 ::com::sun::star::util::URL aURL;
102 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDispatch;
105 typedef ::std::hash_map< ::rtl::OUString,
106 com::sun::star::uno::Reference< com::sun::star::frame::XDispatch >,
107 ::rtl::OUStringHash,
108 ::std::equal_to< ::rtl::OUString > > URLToDispatchMap;
110 sal_Bool m_bInitialized : 1,
111 m_bDisposed : 1;
112 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame;
113 ::com::sun::star::uno::Reference< ::com::sun::star::lang::XMultiServiceFactory > m_xServiceManager;
114 URLToDispatchMap m_aListenerMap;
119 #endif // _SVTOOLS_FRAMESTATUSLISTENER_HXX