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 INCLUDED_EXTENSIONS_SOURCE_BIBLIOGRAPHY_LOADLISTENERADAPTER_HXX
21 #define INCLUDED_EXTENSIONS_SOURCE_BIBLIOGRAPHY_LOADLISTENERADAPTER_HXX
23 #include <osl/mutex.hxx>
24 #include <com/sun/star/lang/XComponent.hpp>
25 #include <cppuhelper/implbase.hxx>
26 #include <com/sun/star/form/XLoadable.hpp>
27 #include <rtl/ref.hxx>
34 class OComponentAdapterBase
;
36 class OComponentListener
38 friend class OComponentAdapterBase
;
41 rtl::Reference
<OComponentAdapterBase
> m_xAdapter
;
42 ::osl::Mutex
& m_rMutex
;
44 explicit OComponentListener( ::osl::Mutex
& _rMutex
)
49 virtual ~OComponentListener();
52 void setAdapter( OComponentAdapterBase
* _pAdapter
);
55 class OComponentAdapterBase
57 friend class OComponentListener
;
60 css::uno::Reference
< css::lang::XComponent
> m_xComponent
;
61 OComponentListener
* m_pListener
;
62 bool m_bListening
: 1;
64 // impl method for dispose - virtual, 'cause you at least need to remove the listener from the broadcaster
65 virtual void disposing() = 0;
68 // attribute access for derivees
69 const css::uno::Reference
< css::lang::XComponent
>&
70 getComponent() const { return m_xComponent
; }
71 OComponentListener
* getListener() { return m_pListener
; }
73 // to be called by derivees which started listening at the component
74 virtual void startComponentListening() = 0;
76 virtual ~OComponentAdapterBase();
79 explicit OComponentAdapterBase(
80 const css::uno::Reference
< css::lang::XComponent
>& _rxComp
84 // can be called from within you ctor, to have you're object fully initialized at the moment of
85 // the call (which would not be the case when calling this ctor)
86 void Init( OComponentListener
* _pListener
);
88 // base for ref-counting, implemented by OComponentAdapter
89 virtual void SAL_CALL
acquire( ) throw () = 0;
90 virtual void SAL_CALL
release( ) throw () = 0;
92 /// dispose the object - stop listening and such
97 /// @throws css::uno::RuntimeException
98 virtual void SAL_CALL
disposing( const css::lang::EventObject
& Source
);
101 class OLoadListener
: public OComponentListener
103 friend class OLoadListenerAdapter
;
106 explicit OLoadListener( ::osl::Mutex
& _rMutex
) : OComponentListener( _rMutex
) { }
108 // XLoadListener equivalents
109 virtual void _loaded( const css::lang::EventObject
& aEvent
) = 0;
110 virtual void _unloading( const css::lang::EventObject
& aEvent
) = 0;
111 virtual void _unloaded( const css::lang::EventObject
& aEvent
) = 0;
112 virtual void _reloading( const css::lang::EventObject
& aEvent
) = 0;
113 virtual void _reloaded( const css::lang::EventObject
& aEvent
) = 0;
116 typedef ::cppu::WeakImplHelper
< css::form::XLoadListener
> OLoadListenerAdapter_Base
;
117 class OLoadListenerAdapter
118 :public OLoadListenerAdapter_Base
119 ,public OComponentAdapterBase
122 OLoadListener
* getLoadListener( ) { return static_cast< OLoadListener
* >( getListener() ); }
125 virtual void disposing() override
;
126 virtual void startComponentListening() override
;
129 explicit OLoadListenerAdapter(
130 const css::uno::Reference
< css::form::XLoadable
>& _rxLoadable
134 virtual void SAL_CALL
acquire( ) throw () override
;
135 virtual void SAL_CALL
release( ) throw () override
;
139 virtual void SAL_CALL
disposing( const css::lang::EventObject
& _rSource
) override
;
142 virtual void SAL_CALL
loaded( const css::lang::EventObject
& aEvent
) override
;
143 virtual void SAL_CALL
unloading( const css::lang::EventObject
& aEvent
) override
;
144 virtual void SAL_CALL
unloaded( const css::lang::EventObject
& aEvent
) override
;
145 virtual void SAL_CALL
reloading( const css::lang::EventObject
& aEvent
) override
;
146 virtual void SAL_CALL
reloaded( const css::lang::EventObject
& aEvent
) override
;
153 #endif // INCLUDED_EXTENSIONS_SOURCE_BIBLIOGRAPHY_LOADLISTENERADAPTER_HXX
155 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */