bump product version to 4.2.0.1
[LibreOffice.git] / include / svtools / framestatuslistener.hxx
blob8dd804414765ac852f463e5fcc6ea054f4b86610
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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_FRAMESTATUSLISTENER_HXX
21 #define INCLUDED_SVTOOLS_FRAMESTATUSLISTENER_HXX
23 #include <svtools/svtdllapi.h>
24 #include <com/sun/star/uno/XComponentContext.hpp>
25 #include <com/sun/star/util/XURLTransformer.hpp>
26 #include <com/sun/star/frame/XFrame.hpp>
27 #include <com/sun/star/frame/XFrameActionListener.hpp>
28 #include <com/sun/star/frame/XDispatch.hpp>
29 #include <com/sun/star/frame/XStatusListener.hpp>
30 #include <cppuhelper/weak.hxx>
31 #include <cppuhelper/interfacecontainer.hxx>
32 #include <comphelper/broadcasthelper.hxx>
34 #include <boost/unordered_map.hpp>
36 namespace svt
39 class SVT_DLLPUBLIC FrameStatusListener : public ::com::sun::star::frame::XStatusListener,
40 public ::com::sun::star::frame::XFrameActionListener,
41 public ::com::sun::star::lang::XComponent,
42 public ::comphelper::OBaseMutex,
43 public ::cppu::OWeakObject
45 public:
46 FrameStatusListener( 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 virtual ~FrameStatusListener();
50 // methods to support status forwarder, known by the old sfx2 toolbox controller implementation
51 void addStatusListener( const OUString& aCommandURL );
52 void bindListener();
53 void unbindListener();
54 sal_Bool isBound() const;
56 // XInterface
57 virtual ::com::sun::star::uno::Any SAL_CALL queryInterface( const ::com::sun::star::uno::Type& aType ) throw (::com::sun::star::uno::RuntimeException);
58 virtual void SAL_CALL acquire() throw ();
59 virtual void SAL_CALL release() throw ();
61 // XComponent
62 virtual void SAL_CALL dispose() throw (::com::sun::star::uno::RuntimeException);
63 virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
64 virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
66 // XEventListener
67 virtual void SAL_CALL disposing( const com::sun::star::lang::EventObject& Source ) throw ( ::com::sun::star::uno::RuntimeException );
69 // XStatusListener
70 virtual void SAL_CALL statusChanged( const ::com::sun::star::frame::FeatureStateEvent& Event ) throw ( ::com::sun::star::uno::RuntimeException ) = 0;
72 // XFrameActionListener
73 virtual void SAL_CALL frameAction( const com::sun::star::frame::FrameActionEvent& Action ) throw ( ::com::sun::star::uno::RuntimeException );
75 protected:
76 struct Listener
78 Listener( const ::com::sun::star::util::URL& rURL, const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch >& rDispatch ) :
79 aURL( rURL ), xDispatch( rDispatch ) {}
81 ::com::sun::star::util::URL aURL;
82 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatch > xDispatch;
85 typedef ::boost::unordered_map< OUString,
86 com::sun::star::uno::Reference< com::sun::star::frame::XDispatch >,
87 OUStringHash,
88 ::std::equal_to< OUString > > URLToDispatchMap;
90 sal_Bool m_bInitialized : 1,
91 m_bDisposed : 1;
92 ::com::sun::star::uno::Reference< ::com::sun::star::frame::XFrame > m_xFrame;
93 ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
94 URLToDispatchMap m_aListenerMap;
99 #endif // INCLUDED_SVTOOLS_FRAMESTATUSLISTENER_HXX
101 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */