1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: EventThread.hxx,v $
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 _FRM_EVENT_THREAD_HXX_
32 #define _FRM_EVENT_THREAD_HXX_
34 #include <com/sun/star/lang/XEventListener.hpp>
35 #include <com/sun/star/lang/EventObject.hpp>
36 #include <com/sun/star/lang/XComponent.hpp>
37 #include <com/sun/star/awt/XControl.hpp>
38 #include <vos/thread.hxx>
41 #include <osl/conditn.hxx>
42 #include <cppuhelper/component.hxx>
43 #include <comphelper/stl_types.hxx>
44 #include <comphelper/uno3.hxx>
45 using namespace comphelper
;
47 //.........................................................................
50 //.........................................................................
52 // ***************************************************************************************************
53 // ***************************************************************************************************
55 typedef ::vos::OThread OComponentEventThread_TBASE
;
56 class OComponentEventThread
57 :public OComponentEventThread_TBASE
58 ,public ::com::sun::star::lang::XEventListener
59 ,public ::cppu::OWeakObject
61 DECLARE_STL_VECTOR(::com::sun::star::lang::EventObject
*, ThreadEvents
);
62 DECLARE_STL_VECTOR(::com::sun::star::uno::Reference
< ::com::sun::star::uno::XAdapter
> , ThreadObjects
);
63 DECLARE_STL_VECTOR(sal_Bool
, ThreadBools
);
65 ::osl::Mutex m_aMutex
;
66 ::osl::Condition m_aCond
; // Queue gefuellt?
67 ThreadEvents m_aEvents
; // Event-Queue
68 ThreadObjects m_aControls
; // Control fuer Submit
69 ThreadBools m_aFlags
; // Flags fuer Submit/Reset
71 ::cppu::OComponentHelper
* m_pCompImpl
; // Implementierung des Controls
72 ::com::sun::star::uno::Reference
< ::com::sun::star::lang::XComponent
> m_xComp
; // ::com::sun::star::lang::XComponent des Controls
77 virtual void SAL_CALL
run();
79 virtual void SAL_CALL
kill();
80 virtual void SAL_CALL
onTerminated();
82 // Die folgende Methode wird gerufen um das Event unter Beruecksichtigung
83 // seines Typs zu duplizieren.
84 virtual ::com::sun::star::lang::EventObject
* cloneEvent(const ::com::sun::star::lang::EventObject
* _pEvt
) const = 0;
86 // Ein Event bearbeiten. Der Mutex ist dabei nicht gelockt, pCompImpl
87 // bleibt aber in jedem Fall gueltig. Bei pEvt kann es sich auch um
88 // einen abgeleiteten Typ handeln, naemlich den, den cloneEvent
89 // zurueckgibt. rControl ist nur gesetzt, wenn beim addEvent ein
90 // Control uebergeben wurde. Da das Control nur als WeakRef gehalten
91 // wird kann es auch zwischenzeitlich verschwinden.
92 virtual void processEvent( ::cppu::OComponentHelper
* _pCompImpl
,
93 const ::com::sun::star::lang::EventObject
* _pEvt
,
94 const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControl
>& _rControl
,
100 DECLARE_UNO3_DEFAULTS(OComponentEventThread
, OWeakObject
);
101 virtual ::com::sun::star::uno::Any SAL_CALL
queryInterface(const ::com::sun::star::uno::Type
& _rType
) throw (::com::sun::star::uno::RuntimeException
);
103 OComponentEventThread(::cppu::OComponentHelper
* pCompImpl
);
104 virtual ~OComponentEventThread();
106 void addEvent( const ::com::sun::star::lang::EventObject
* _pEvt
, sal_Bool bFlag
= sal_False
);
107 void addEvent( const ::com::sun::star::lang::EventObject
* _pEvt
, const ::com::sun::star::uno::Reference
< ::com::sun::star::awt::XControl
>& rControl
,
108 sal_Bool bFlag
= sal_False
);
110 // ::com::sun::star::lang::XEventListener
111 virtual void SAL_CALL
disposing(const ::com::sun::star::lang::EventObject
& _rSource
) throw (::com::sun::star::uno::RuntimeException
);
113 /* resolve ambiguity : both OWeakObject and OObject have these memory operators */
114 void * SAL_CALL
operator new( size_t size
) throw() { return OThread::operator new(size
); }
115 void SAL_CALL
operator delete( void * p
) throw() { OThread::operator delete(p
); }
119 void implTerminated( );
121 void impl_clearEventQueue();
124 //.........................................................................
126 //.........................................................................
128 #endif // _FRM_EVENT_THREAD_HXX_