LibreOffice Module extensions (master) 1
loadlisteneradapter.hxx
Go to the documentation of this file.
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#pragma once
21
22#include <osl/mutex.hxx>
23#include <com/sun/star/lang/XComponent.hpp>
25#include <com/sun/star/form/XLoadable.hpp>
26#include <rtl/ref.hxx>
27
28
29namespace bib
30{
31
32
33 class OComponentAdapterBase;
34
36 {
38
39 private:
41 ::osl::Mutex& m_rMutex;
42 protected:
43 explicit OComponentListener( ::osl::Mutex& _rMutex )
44 :m_rMutex( _rMutex )
45 {
46 }
47
48 virtual ~OComponentListener();
49
50 protected:
51 void setAdapter( OComponentAdapterBase* _pAdapter );
52 };
53
55 {
56 friend class OComponentListener;
57
58 private:
59 css::uno::Reference< css::lang::XComponent > m_xComponent;
61 bool m_bListening : 1;
62
63 // impl method for dispose - virtual, 'cause you at least need to remove the listener from the broadcaster
64 virtual void disposing() = 0;
65
66 protected:
67 // attribute access for derivees
68 const css::uno::Reference< css::lang::XComponent >&
69 getComponent() const { return m_xComponent; }
71
72 // to be called by derivees which started listening at the component
73 virtual void startComponentListening() = 0;
74
75 virtual ~OComponentAdapterBase();
76
77 public:
78 explicit OComponentAdapterBase(
79 const css::uno::Reference< css::lang::XComponent >& _rxComp
80 );
81
82 // late construction
83 // can be called from within you ctor, to have you're object fully initialized at the moment of
84 // the call (which would not be the case when calling this ctor)
85 void Init( OComponentListener* _pListener );
86
87 // base for ref-counting, implemented by OComponentAdapter
88 virtual void SAL_CALL acquire( ) noexcept = 0;
89 virtual void SAL_CALL release( ) noexcept = 0;
90
92 void dispose();
93
94 protected:
95 // XEventListener
97 virtual void SAL_CALL disposing( const css::lang::EventObject& Source );
98 };
99
101 {
103
104 protected:
105 explicit OLoadListener( ::osl::Mutex& _rMutex ) : OComponentListener( _rMutex ) { }
106
107 // XLoadListener equivalents
108 virtual void _loaded( const css::lang::EventObject& aEvent ) = 0;
109 virtual void _unloading( const css::lang::EventObject& aEvent ) = 0;
110 virtual void _reloading( const css::lang::EventObject& aEvent ) = 0;
111 virtual void _reloaded( const css::lang::EventObject& aEvent ) = 0;
112 };
113
114 typedef ::cppu::WeakImplHelper< css::form::XLoadListener > OLoadListenerAdapter_Base;
118 {
119 protected:
120 OLoadListener* getLoadListener( ) { return static_cast< OLoadListener* >( getListener() ); }
121
122 protected:
123 virtual void disposing() override;
124 virtual void startComponentListening() override;
125
126 public:
127 explicit OLoadListenerAdapter(
128 const css::uno::Reference< css::form::XLoadable >& _rxLoadable
129 );
130
131
132 virtual void SAL_CALL acquire( ) noexcept override;
133 virtual void SAL_CALL release( ) noexcept override;
134
135 protected:
136 // XEventListener
137 virtual void SAL_CALL disposing( const css::lang::EventObject& _rSource ) override;
138
139 // XLoadListener
140 virtual void SAL_CALL loaded( const css::lang::EventObject& aEvent ) override;
141 virtual void SAL_CALL unloading( const css::lang::EventObject& aEvent ) override;
142 virtual void SAL_CALL unloaded( const css::lang::EventObject& aEvent ) override;
143 virtual void SAL_CALL reloading( const css::lang::EventObject& aEvent ) override;
144 virtual void SAL_CALL reloaded( const css::lang::EventObject& aEvent ) override;
145 };
146
147
148} // namespace bib
149
150
151/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void Init(OComponentListener *_pListener)
virtual void SAL_CALL release() noexcept=0
virtual void startComponentListening()=0
void dispose()
dispose the object - stop listening and such
virtual void SAL_CALL acquire() noexcept=0
virtual void disposing()=0
OComponentAdapterBase(const css::uno::Reference< css::lang::XComponent > &_rxComp)
const css::uno::Reference< css::lang::XComponent > & getComponent() const
OComponentListener * m_pListener
css::uno::Reference< css::lang::XComponent > m_xComponent
OComponentListener * getListener()
void setAdapter(OComponentAdapterBase *_pAdapter)
OComponentListener(::osl::Mutex &_rMutex)
rtl::Reference< OComponentAdapterBase > m_xAdapter
OLoadListener(::osl::Mutex &_rMutex)
virtual void _reloaded(const css::lang::EventObject &aEvent)=0
virtual void _reloading(const css::lang::EventObject &aEvent)=0
virtual void _unloading(const css::lang::EventObject &aEvent)=0
virtual void _loaded(const css::lang::EventObject &aEvent)=0
Definition: bibbeam.cxx:40
::cppu::WeakImplHelper< css::form::XLoadListener > OLoadListenerAdapter_Base