LCOV - code coverage report
Current view: top level - usr/local/src/libreoffice/sfx2/source/inc - eventsupplier.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 1 1 100.0 %
Date: 2013-07-09 Functions: 2 2 100.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 _SFX_EVENTSUPPLIER_HXX_
      21             : #define _SFX_EVENTSUPPLIER_HXX_
      22             : 
      23             : #include <com/sun/star/lang/XTypeProvider.hpp>
      24             : #include <com/sun/star/container/XNameReplace.hpp>
      25             : #include <com/sun/star/container/XSet.hpp>
      26             : #include <com/sun/star/document/XEventListener.hpp>
      27             : #include <com/sun/star/document/XEventBroadcaster.hpp>
      28             : #include <com/sun/star/document/XDocumentEventListener.hpp>
      29             : #include <com/sun/star/document/XEventsSupplier.hpp>
      30             : #include <com/sun/star/frame/XGlobalEventBroadcaster.hpp>
      31             : #include <com/sun/star/lang/XServiceInfo.hpp>
      32             : #include <com/sun/star/task/XJobExecutor.hpp>
      33             : #include <com/sun/star/uno/Reference.hxx>
      34             : #include <com/sun/star/uno/Type.hxx>
      35             : #include <sal/types.h>
      36             : #include <osl/mutex.hxx>
      37             : #include <cppuhelper/implbase1.hxx>
      38             : #include <cppuhelper/implbase2.hxx>
      39             : #include <cppuhelper/implbase3.hxx>
      40             : #include <comphelper/sequenceashashmap.hxx>
      41             : #include <comphelper/sequenceasvector.hxx>
      42             : #include <sfx2/sfxuno.hxx>
      43             : 
      44             : #include <cppuhelper/interfacecontainer.hxx>
      45             : #include <svl/lstner.hxx>
      46             : #include <unotools/eventcfg.hxx>
      47             : 
      48             : namespace comphelper
      49             : {
      50             :     class NamedValueCollection;
      51             : }
      52             : 
      53             : class SfxObjectShell;
      54             : class SvxMacro;
      55             : 
      56             : //--------------------------------------------------------------------------------------------------------
      57             : 
      58             : class SfxEvents_Impl : public ::cppu::WeakImplHelper2< css::container::XNameReplace, css::document::XEventListener  >
      59             : {
      60             :     css::uno::Sequence< OUString >     maEventNames;
      61             :     css::uno::Sequence< css::uno::Any >                 maEventData;
      62             :     css::uno::Reference< css::document::XEventBroadcaster >  mxBroadcaster;
      63             :     ::osl::Mutex                    maMutex;
      64             :     SfxObjectShell                 *mpObjShell;
      65             : 
      66             : public:
      67             :                                 SfxEvents_Impl( SfxObjectShell* pShell,
      68             :                                                 css::uno::Reference< css::document::XEventBroadcaster > xBroadcaster );
      69             :                                ~SfxEvents_Impl();
      70             : 
      71             :     //  --- XNameReplace ---
      72             :     virtual void SAL_CALL       replaceByName( const OUString & aName, const css::uno::Any & aElement )
      73             :                                     throw( css::lang::IllegalArgumentException, css::container::NoSuchElementException,
      74             :                                            css::lang::WrappedTargetException, css::uno::RuntimeException );
      75             : 
      76             :     //  --- XNameAccess ( parent of XNameReplace ) ---
      77             :     virtual css::uno::Any SAL_CALL        getByName( const OUString& aName )
      78             :                                     throw( css::container::NoSuchElementException, css::lang::WrappedTargetException,
      79             :                                            css::uno::RuntimeException );
      80             :     virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() throw ( css::uno::RuntimeException );
      81             :     virtual sal_Bool SAL_CALL   hasByName( const OUString& aName ) throw ( css::uno::RuntimeException );
      82             : 
      83             :     //  --- XElementAccess ( parent of XNameAccess ) ---
      84             :     virtual css::uno::Type SAL_CALL    getElementType() throw ( css::uno::RuntimeException );
      85             :     virtual sal_Bool SAL_CALL   hasElements() throw ( css::uno::RuntimeException );
      86             : 
      87             :     // --- ::document::XEventListener ---
      88             :     virtual void SAL_CALL       notifyEvent( const css::document::EventObject& aEvent )
      89             :                                     throw( css::uno::RuntimeException );
      90             : 
      91             :     // --- ::lang::XEventListener ---
      92             :     virtual void SAL_CALL       disposing( const css::lang::EventObject& Source )
      93             :                                     throw( css::uno::RuntimeException );
      94             : 
      95             :     static SvxMacro*            ConvertToMacro( const css::uno::Any& rElement, SfxObjectShell* pDoc, sal_Bool bNormalizeMacro );
      96             :     static void                 NormalizeMacro( const css::uno::Any& rIn, css::uno::Any& rOut, SfxObjectShell* pDoc );
      97             :     static void                 NormalizeMacro(
      98             :                                     const ::comphelper::NamedValueCollection& i_eventDescriptor,
      99             :                                     ::comphelper::NamedValueCollection& o_normalizedDescriptor,
     100             :                                     SfxObjectShell* i_document );
     101             : };
     102             : 
     103             : //=============================================================================
     104         271 : struct ModelCollectionMutexBase
     105             : {
     106             :     public:
     107             :         ::osl::Mutex m_aLock;
     108             : };
     109             : 
     110             : //=============================================================================
     111             : typedef ::std::vector< css::uno::Reference< css::frame::XModel > > TModelList;
     112             : 
     113             : //=============================================================================
     114             : class ModelCollectionEnumeration : public ModelCollectionMutexBase
     115             :                                  , public ::cppu::WeakImplHelper1< css::container::XEnumeration >
     116             : {
     117             : 
     118             :     //-------------------------------------------------------------------------
     119             :     // member
     120             :     //-------------------------------------------------------------------------
     121             :     private:
     122             :         TModelList m_lModels;
     123             :         TModelList::iterator m_pEnumerationIt;
     124             : 
     125             :     //-------------------------------------------------------------------------
     126             :     // native interface
     127             :     //-------------------------------------------------------------------------
     128             :     public:
     129             :         ModelCollectionEnumeration();
     130             :         virtual ~ModelCollectionEnumeration();
     131             :         void setModelList(const TModelList& rList);
     132             : 
     133             :     //-------------------------------------------------------------------------
     134             :     // uno interface
     135             :     //-------------------------------------------------------------------------
     136             :     public:
     137             : 
     138             :         // css.container.XEnumeration
     139             :         virtual sal_Bool SAL_CALL hasMoreElements()
     140             :             throw(css::uno::RuntimeException);
     141             : 
     142             :         virtual css::uno::Any SAL_CALL nextElement()
     143             :             throw(css::container::NoSuchElementException,
     144             :                   css::lang::WrappedTargetException     ,
     145             :                   css::uno::RuntimeException            );
     146             : };
     147             : 
     148             : //=============================================================================
     149             : //TODO: remove support of obsolete document::XEventBroadcaster/Listener
     150             : class SfxGlobalEvents_Impl : public ModelCollectionMutexBase
     151             :                            , public ::cppu::WeakImplHelper3< css::lang::XServiceInfo
     152             :                                                            , css::frame::XGlobalEventBroadcaster
     153             :                                                            , css::document::XEventListener
     154             :                                                             >
     155             : {
     156             :     css::uno::Reference< css::container::XNameReplace > m_xEvents;
     157             :     css::uno::Reference< css::document::XEventListener > m_xJobExecutorListener;
     158             :     ::cppu::OInterfaceContainerHelper m_aLegacyListeners;
     159             :     ::cppu::OInterfaceContainerHelper m_aDocumentListeners;
     160             :     TModelList m_lModels;
     161             :     GlobalEventConfig* pImp;
     162             : 
     163             : public:
     164             :     SfxGlobalEvents_Impl(const css::uno::Reference < css::uno::XComponentContext >& rxContext);
     165             :     virtual ~SfxGlobalEvents_Impl();
     166             : 
     167             :     SFX_DECL_XSERVICEINFO
     168             : 
     169             :     // css.document.XEventBroadcaster
     170             :     virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents()
     171             :         throw(css::uno::RuntimeException);
     172             : 
     173             :     virtual void SAL_CALL addEventListener(const css::uno::Reference< css::document::XEventListener >& xListener)
     174             :         throw(css::uno::RuntimeException);
     175             : 
     176             :     virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::document::XEventListener >& xListener)
     177             :         throw(css::uno::RuntimeException);
     178             : 
     179             :     // css.document.XDocumentEventBroadcaster
     180             :     virtual void SAL_CALL addDocumentEventListener( const css::uno::Reference< css::document::XDocumentEventListener >& _Listener ) throw (css::uno::RuntimeException);
     181             :     virtual void SAL_CALL removeDocumentEventListener( const css::uno::Reference< css::document::XDocumentEventListener >& _Listener ) throw (css::uno::RuntimeException);
     182             :     virtual void SAL_CALL notifyDocumentEvent( const OUString& _EventName, const css::uno::Reference< css::frame::XController2 >& _ViewController, const css::uno::Any& _Supplement ) throw (css::lang::IllegalArgumentException, css::lang::NoSupportException, css::uno::RuntimeException);
     183             : 
     184             :     // css.document.XEventListener
     185             :     virtual void SAL_CALL notifyEvent(const css::document::EventObject& aEvent)
     186             :         throw(css::uno::RuntimeException);
     187             : 
     188             :     // css.document.XDocumentEventListener
     189             :     virtual void SAL_CALL documentEventOccured( const css::document::DocumentEvent& Event ) throw (css::uno::RuntimeException);
     190             : 
     191             :     // css.container.XSet
     192             :     virtual sal_Bool SAL_CALL has(const css::uno::Any& aElement)
     193             :         throw(css::uno::RuntimeException);
     194             : 
     195             :     virtual void SAL_CALL insert(const css::uno::Any& aElement)
     196             :         throw(css::lang::IllegalArgumentException  ,
     197             :               css::container::ElementExistException,
     198             :               css::uno::RuntimeException           );
     199             : 
     200             :     virtual void SAL_CALL remove(const css::uno::Any& aElement)
     201             :         throw(css::lang::IllegalArgumentException   ,
     202             :               css::container::NoSuchElementException,
     203             :               css::uno::RuntimeException            );
     204             : 
     205             :     // css.container.XEnumerationAccess
     206             :     virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration()
     207             :         throw(css::uno::RuntimeException);
     208             : 
     209             :     // css.container.XElementAccess
     210             :     virtual css::uno::Type SAL_CALL getElementType()
     211             :         throw(css::uno::RuntimeException);
     212             : 
     213             :     virtual sal_Bool SAL_CALL hasElements()
     214             :         throw(css::uno::RuntimeException);
     215             : 
     216             :     // css.lang.XEventListener
     217             :     virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent)
     218             :         throw(css::uno::RuntimeException);
     219             : 
     220             : private:
     221             : 
     222             :     // threadsafe
     223             :     void implts_notifyJobExecution(const css::document::EventObject& aEvent);
     224             :     void implts_checkAndExecuteEventBindings(const css::document::DocumentEvent& aEvent);
     225             :     void implts_notifyListener(const css::document::DocumentEvent& aEvent);
     226             : 
     227             :     // not threadsafe
     228             :     TModelList::iterator impl_searchDoc(const css::uno::Reference< css::frame::XModel >& xModel);
     229             : };
     230             : 
     231             : #endif
     232             : 
     233             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10