LCOV - code coverage report
Current view: top level - forms/source/component - EventThread.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 0 3 0.0 %
Date: 2014-11-03 Functions: 0 4 0.0 %
Legend: Lines: hit not hit

          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 INCLUDED_FORMS_SOURCE_COMPONENT_EVENTTHREAD_HXX
      21             : #define INCLUDED_FORMS_SOURCE_COMPONENT_EVENTTHREAD_HXX
      22             : 
      23             : #include <sal/config.h>
      24             : 
      25             : #include <vector>
      26             : 
      27             : #include <com/sun/star/lang/XEventListener.hpp>
      28             : #include <com/sun/star/lang/EventObject.hpp>
      29             : #include <com/sun/star/lang/XComponent.hpp>
      30             : #include <com/sun/star/awt/XControl.hpp>
      31             : #include <osl/thread.hxx>
      32             : 
      33             : 
      34             : #include <osl/conditn.hxx>
      35             : #include <cppuhelper/component.hxx>
      36             : #include <comphelper/uno3.hxx>
      37             : using namespace comphelper;
      38             : 
      39             : 
      40             : namespace frm
      41             : {
      42             : 
      43             : 
      44             : typedef ::osl::Thread   OComponentEventThread_TBASE;
      45             : class OComponentEventThread
      46             :             :public OComponentEventThread_TBASE
      47             :             ,public ::com::sun::star::lang::XEventListener
      48             :             ,public ::cppu::OWeakObject
      49             : {
      50             :     typedef std::vector<css::lang::EventObject*> ThreadEvents;
      51             :     typedef std::vector< ::com::sun::star::uno::Reference< ::com::sun::star::uno::XAdapter> > ThreadObjects;
      52             :     typedef std::vector<sal_Bool> ThreadBools;
      53             : 
      54             :     ::osl::Mutex                    m_aMutex;
      55             :     ::osl::Condition                m_aCond;            // Queue filled?
      56             :     ThreadEvents                    m_aEvents;          // EventQueue
      57             :     ThreadObjects                   m_aControls;        // Control for Submit
      58             :     ThreadBools                     m_aFlags;           // Flags for Submit/Reset
      59             : 
      60             :     ::cppu::OComponentHelper*                   m_pCompImpl;    // Implementation of the Control
      61             :     ::com::sun::star::uno::Reference< ::com::sun::star::lang::XComponent>   m_xComp; // ::com::sun::star::lang::XComponent of the Control
      62             : 
      63             : protected:
      64             : 
      65             :     // XThread
      66             :     virtual void SAL_CALL run() SAL_OVERRIDE;
      67             : 
      68             :     virtual void SAL_CALL kill();
      69             :     virtual void SAL_CALL onTerminated() SAL_OVERRIDE;
      70             : 
      71             :     // The following method is called to duplicate the Event while respecting it's type.
      72             :     virtual ::com::sun::star::lang::EventObject* cloneEvent(const ::com::sun::star::lang::EventObject* _pEvt) const = 0;
      73             : 
      74             :     // Edit an Event:
      75             :     // The mutex is not locked, but pCompImpl stays valid in any case.
      76             :     // pEvt can be a derrived type, namely the one that cloneEvent returns.
      77             :     // rControl is only set, if a Control has been passed in addEvent.
      78             :     // Because the Control is only held as a WeakRef, it can disappear in the meantime.
      79             :     virtual void processEvent( ::cppu::OComponentHelper* _pCompImpl,
      80             :                                const ::com::sun::star::lang::EventObject* _pEvt,
      81             :                                const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& _rControl,
      82             :                                bool _bFlag) = 0;
      83             : 
      84             : public:
      85             : 
      86             :     // UNO Anbindung
      87           0 :     DECLARE_UNO3_DEFAULTS(OComponentEventThread, OWeakObject)
      88             :     virtual ::com::sun::star::uno::Any SAL_CALL queryInterface(const ::com::sun::star::uno::Type& _rType) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      89             : 
      90             :     OComponentEventThread(::cppu::OComponentHelper* pCompImpl);
      91             :     virtual ~OComponentEventThread();
      92             : 
      93             :     void addEvent( const ::com::sun::star::lang::EventObject* _pEvt, bool bFlag = false );
      94             :     void addEvent( const ::com::sun::star::lang::EventObject* _pEvt, const ::com::sun::star::uno::Reference< ::com::sun::star::awt::XControl>& rControl,
      95             :                    bool bFlag = false );
      96             : 
      97             :     // ::com::sun::star::lang::XEventListener
      98             :     virtual void SAL_CALL disposing(const ::com::sun::star::lang::EventObject& _rSource ) throw (::com::sun::star::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      99             : 
     100             :     // Resolve ambiguity: both OWeakObject and OObject have these memory operators
     101           0 :     void * SAL_CALL operator new( size_t size ) throw() { return osl::Thread::operator new(size); }
     102           0 :     void SAL_CALL operator delete( void * p ) throw() { osl::Thread::operator delete(p); }
     103             : 
     104             : private:
     105             :     void    implStarted( );
     106             :     void    implTerminated( );
     107             : 
     108             :     void    impl_clearEventQueue();
     109             : };
     110             : 
     111             : 
     112             : }   // namespace frm
     113             : 
     114             : 
     115             : #endif // INCLUDED_FORMS_SOURCE_COMPONENT_EVENTTHREAD_HXX
     116             : 
     117             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10