Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
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/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
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 .
18 : */
19 :
20 : #ifndef _SFXSTATUSLISTENER_HXX
21 : #define _SFXSTATUSLISTENER_HXX
22 :
23 : #include "sal/config.h"
24 : #include "sfx2/dllapi.h"
25 : #include <svl/poolitem.hxx>
26 : #include <cppuhelper/weak.hxx>
27 : #include <osl/conditn.hxx>
28 : #include <com/sun/star/frame/FeatureStateEvent.hpp>
29 : #include <com/sun/star/frame/XDispatchProvider.hpp>
30 : #include <com/sun/star/lang/XComponent.hpp>
31 : #include <com/sun/star/frame/XStatusListener.hpp>
32 :
33 : #include <sfx2/sfxuno.hxx>
34 :
35 : // Interface for implementations which needs to get notifications about state changes
36 0 : class SfxStatusListenerInterface
37 : {
38 : public:
39 : virtual void StateChanged( sal_uInt16 nSlotId, SfxItemState eState, const SfxPoolItem* pState ) = 0;
40 :
41 : protected:
42 0 : ~SfxStatusListenerInterface() {}
43 : };
44 :
45 : class SFX2_DLLPUBLIC SfxStatusListener :
46 : public ::com::sun::star::frame::XStatusListener ,
47 : public ::com::sun::star::lang::XTypeProvider ,
48 : public ::com::sun::star::lang::XComponent ,
49 : public ::cppu::OWeakObject
50 : {
51 : public:
52 : SFX_DECL_XINTERFACE_XTYPEPROVIDER
53 :
54 : SfxStatusListener( const ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider >& rDispatchProvider, sal_uInt16 nSlotId, const OUString& aCommand );
55 : virtual ~SfxStatusListener();
56 :
57 : // old methods from SfxControllerItem
58 7746 : sal_uInt16 GetId() const { return m_nSlotID; }
59 : void UnBind();
60 : void ReBind();
61 :
62 : virtual void StateChanged( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState );
63 :
64 : // XComponent
65 : virtual void SAL_CALL dispose() throw( ::com::sun::star::uno::RuntimeException );
66 : virtual void SAL_CALL addEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& xListener ) throw (::com::sun::star::uno::RuntimeException);
67 : virtual void SAL_CALL removeEventListener( const ::com::sun::star::uno::Reference< ::com::sun::star::lang::XEventListener >& aListener ) throw (::com::sun::star::uno::RuntimeException);
68 :
69 : // XEventListener
70 : virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& Source) throw( ::com::sun::star::uno::RuntimeException );
71 :
72 : // XStatusListener
73 : virtual void SAL_CALL statusChanged(const ::com::sun::star::frame::FeatureStateEvent& Event) throw( ::com::sun::star::uno::RuntimeException );
74 :
75 : private:
76 : SfxStatusListener( const SfxStatusListener& );
77 : SfxStatusListener();
78 : SfxStatusListener& operator=( const SfxStatusListener& );
79 :
80 : sal_uInt16 m_nSlotID;
81 : ::com::sun::star::util::URL m_aCommand;
82 : ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDispatchProvider > m_xDispatchProvider;
83 : ::com::sun::star::uno::Reference< com::sun::star::frame::XDispatch > m_xDispatch;
84 : };
85 :
86 : #endif // _SFXSTATUSLISTENER_HXX
87 :
88 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|