LCOV - code coverage report
Current view: top level - sfx2/source/notify - globalevents.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 178 0.0 %
Date: 2014-04-14 Functions: 0 36 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             : #include <sal/types.h>
      21             : 
      22             : #include <com/sun/star/task/theJobExecutor.hpp>
      23             : #include <com/sun/star/container/XNameReplace.hpp>
      24             : #include <com/sun/star/container/XSet.hpp>
      25             : #include <com/sun/star/document/XEventListener.hpp>
      26             : #include <com/sun/star/document/XEventBroadcaster.hpp>
      27             : #include <com/sun/star/document/XDocumentEventListener.hpp>
      28             : #include <com/sun/star/frame/XGlobalEventBroadcaster.hpp>
      29             : #include <com/sun/star/lang/XServiceInfo.hpp>
      30             : #include <com/sun/star/uno/Type.hxx>
      31             : 
      32             : #include <cppuhelper/implbase1.hxx>
      33             : #include <cppuhelper/implbase3.hxx>
      34             : #include <cppuhelper/interfacecontainer.hxx>
      35             : #include <cppuhelper/supportsservice.hxx>
      36             : #include <rtl/ref.hxx>
      37             : #include <sfx2/app.hxx>
      38             : #include <sfx2/objsh.hxx>
      39             : #include <sfx2/sfxbasemodel.hxx>
      40             : #include <sfx2/evntconf.hxx>
      41             : #include <tools/diagnose_ex.h>
      42             : #include <unotools/eventcfg.hxx>
      43             : #include <eventsupplier.hxx>
      44             : 
      45             : #include <vector>
      46             : 
      47             : using namespace css;
      48             : 
      49             : namespace {
      50             : 
      51           0 : struct ModelCollectionMutexBase
      52             : {
      53             : public:
      54             :     osl::Mutex m_aLock;
      55             : };
      56             : 
      57             : typedef ::std::vector< css::uno::Reference< css::frame::XModel > > TModelList;
      58             : 
      59             : class ModelCollectionEnumeration : public ModelCollectionMutexBase
      60             :                                  , public ::cppu::WeakImplHelper1< css::container::XEnumeration >
      61             : {
      62             : private:
      63             :     TModelList m_lModels;
      64             :     TModelList::iterator m_pEnumerationIt;
      65             : 
      66             : public:
      67             :     ModelCollectionEnumeration();
      68             :     virtual ~ModelCollectionEnumeration();
      69             :     void setModelList(const TModelList& rList);
      70             : 
      71             :     // css.container.XEnumeration
      72             :     virtual sal_Bool SAL_CALL hasMoreElements()
      73             :         throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
      74             : 
      75             :     virtual css::uno::Any SAL_CALL nextElement()
      76             :         throw(css::container::NoSuchElementException,
      77             :               css::lang::WrappedTargetException     ,
      78             :               css::uno::RuntimeException, std::exception            ) SAL_OVERRIDE;
      79             : };
      80             : 
      81             : 
      82             : //TODO: remove support of obsolete document::XEventBroadcaster/Listener
      83             : class SfxGlobalEvents_Impl : public ModelCollectionMutexBase
      84             :                            , public ::cppu::WeakImplHelper3< css::lang::XServiceInfo
      85             :                                                            , css::frame::XGlobalEventBroadcaster
      86             :                                                            , css::document::XEventListener
      87             :                                                             >
      88             : {
      89             :     css::uno::Reference< css::container::XNameReplace > m_xEvents;
      90             :     css::uno::Reference< css::document::XEventListener > m_xJobExecutorListener;
      91             :     ::cppu::OInterfaceContainerHelper m_aLegacyListeners;
      92             :     ::cppu::OInterfaceContainerHelper m_aDocumentListeners;
      93             :     TModelList m_lModels;
      94             :     GlobalEventConfig* pImp;
      95             : 
      96             : public:
      97             :     SfxGlobalEvents_Impl(const css::uno::Reference < css::uno::XComponentContext >& rxContext);
      98             :     virtual ~SfxGlobalEvents_Impl();
      99             : 
     100           0 :     virtual OUString SAL_CALL getImplementationName()
     101             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
     102             :     {
     103           0 :         return OUString("com.sun.star.comp.sfx2.GlobalEventBroadcaster");
     104             :     }
     105             : 
     106           0 :     virtual sal_Bool SAL_CALL supportsService(OUString const & ServiceName)
     107             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
     108             :     {
     109           0 :         return cppu::supportsService(this, ServiceName);
     110             :     }
     111             : 
     112           0 :     virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames()
     113             :         throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE
     114             :     {
     115           0 :         css::uno::Sequence< OUString > aSeq(1);
     116           0 :         aSeq[0] = OUString("com.sun.star.frame.GlobalEventBroadcaster");
     117           0 :         return aSeq;
     118             :     }
     119             : 
     120             :     // css.document.XEventBroadcaster
     121             :     virtual css::uno::Reference< css::container::XNameReplace > SAL_CALL getEvents()
     122             :         throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     123             : 
     124             :     virtual void SAL_CALL addEventListener(const css::uno::Reference< css::document::XEventListener >& xListener)
     125             :         throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     126             : 
     127             :     virtual void SAL_CALL removeEventListener( const css::uno::Reference< css::document::XEventListener >& xListener)
     128             :         throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     129             : 
     130             :     // css.document.XDocumentEventBroadcaster
     131             :     virtual void SAL_CALL addDocumentEventListener( const css::uno::Reference< css::document::XDocumentEventListener >& _Listener ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     132             :     virtual void SAL_CALL removeDocumentEventListener( const css::uno::Reference< css::document::XDocumentEventListener >& _Listener ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     133             :     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, std::exception) SAL_OVERRIDE;
     134             : 
     135             :     // css.document.XEventListener
     136             :     virtual void SAL_CALL notifyEvent(const css::document::EventObject& aEvent)
     137             :         throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     138             : 
     139             :     // css.document.XDocumentEventListener
     140             :     virtual void SAL_CALL documentEventOccured( const css::document::DocumentEvent& Event ) throw (css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     141             : 
     142             :     // css.container.XSet
     143             :     virtual sal_Bool SAL_CALL has(const css::uno::Any& aElement)
     144             :         throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     145             : 
     146             :     virtual void SAL_CALL insert(const css::uno::Any& aElement)
     147             :         throw(css::lang::IllegalArgumentException  ,
     148             :               css::container::ElementExistException,
     149             :               css::uno::RuntimeException, std::exception           ) SAL_OVERRIDE;
     150             : 
     151             :     virtual void SAL_CALL remove(const css::uno::Any& aElement)
     152             :         throw(css::lang::IllegalArgumentException   ,
     153             :               css::container::NoSuchElementException,
     154             :               css::uno::RuntimeException, std::exception            ) SAL_OVERRIDE;
     155             : 
     156             :     // css.container.XEnumerationAccess
     157             :     virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration()
     158             :         throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     159             : 
     160             :     // css.container.XElementAccess
     161             :     virtual css::uno::Type SAL_CALL getElementType()
     162             :         throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     163             : 
     164             :     virtual sal_Bool SAL_CALL hasElements()
     165             :         throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     166             : 
     167             :     // css.lang.XEventListener
     168             :     virtual void SAL_CALL disposing(const css::lang::EventObject& aEvent)
     169             :         throw(css::uno::RuntimeException, std::exception) SAL_OVERRIDE;
     170             : 
     171             : private:
     172             : 
     173             :     // threadsafe
     174             :     void implts_notifyJobExecution(const css::document::EventObject& aEvent);
     175             :     void implts_checkAndExecuteEventBindings(const css::document::DocumentEvent& aEvent);
     176             :     void implts_notifyListener(const css::document::DocumentEvent& aEvent);
     177             : 
     178             :     // not threadsafe
     179             :     TModelList::iterator impl_searchDoc(const css::uno::Reference< css::frame::XModel >& xModel);
     180             : };
     181             : 
     182           0 : ModelCollectionEnumeration::ModelCollectionEnumeration()
     183             :     : ModelCollectionMutexBase(                 )
     184           0 :     , m_pEnumerationIt        (m_lModels.begin())
     185             : {
     186           0 : }
     187             : 
     188           0 : ModelCollectionEnumeration::~ModelCollectionEnumeration()
     189             : {
     190           0 : }
     191             : 
     192           0 : void ModelCollectionEnumeration::setModelList(const TModelList& rList)
     193             : {
     194             :     // SAFE ->
     195           0 :     ::osl::ResettableMutexGuard aLock(m_aLock);
     196           0 :     m_lModels        = rList;
     197           0 :     m_pEnumerationIt = m_lModels.begin();
     198           0 :     aLock.clear();
     199             :     // <- SAFE
     200           0 : }
     201             : 
     202           0 : sal_Bool SAL_CALL ModelCollectionEnumeration::hasMoreElements()
     203             :     throw(uno::RuntimeException, std::exception)
     204             : {
     205             :     // SAFE ->
     206           0 :     ::osl::ResettableMutexGuard aLock(m_aLock);
     207           0 :     return (m_pEnumerationIt != m_lModels.end());
     208             :     // <- SAFE
     209             : }
     210             : 
     211           0 : uno::Any SAL_CALL ModelCollectionEnumeration::nextElement()
     212             :     throw(container::NoSuchElementException,
     213             :           lang::WrappedTargetException     ,
     214             :           uno::RuntimeException, std::exception            )
     215             : {
     216             :     // SAFE ->
     217           0 :     ::osl::ResettableMutexGuard aLock(m_aLock);
     218           0 :     if (m_pEnumerationIt == m_lModels.end())
     219             :         throw container::NoSuchElementException(
     220             :                     OUString("End of model enumeration reached."),
     221           0 :                     static_cast< container::XEnumeration* >(this));
     222           0 :     uno::Reference< frame::XModel > xModel(*m_pEnumerationIt, uno::UNO_QUERY);
     223           0 :     ++m_pEnumerationIt;
     224           0 :     aLock.clear();
     225             :     // <- SAFE
     226             : 
     227           0 :     return uno::makeAny(xModel);
     228             : }
     229             : 
     230             : 
     231           0 : SfxGlobalEvents_Impl::SfxGlobalEvents_Impl( const uno::Reference < uno::XComponentContext >& rxContext)
     232             :     : ModelCollectionMutexBase(       )
     233             :     , m_xJobExecutorListener( task::theJobExecutor::get( rxContext ), uno::UNO_QUERY_THROW )
     234             :     , m_aLegacyListeners      (m_aLock)
     235             :     , m_aDocumentListeners    (m_aLock)
     236           0 :     , pImp                    (0      )
     237             : {
     238           0 :     m_refCount++;
     239           0 :     SFX_APP();
     240           0 :     pImp                   = new GlobalEventConfig();
     241           0 :     m_xEvents              = pImp;
     242           0 :     m_refCount--;
     243           0 : }
     244             : 
     245             : 
     246           0 : SfxGlobalEvents_Impl::~SfxGlobalEvents_Impl()
     247             : {
     248           0 : }
     249             : 
     250             : 
     251           0 : uno::Reference< container::XNameReplace > SAL_CALL SfxGlobalEvents_Impl::getEvents()
     252             :     throw(uno::RuntimeException, std::exception)
     253             : {
     254             :     // SAFE ->
     255           0 :     ::osl::ResettableMutexGuard aLock(m_aLock);
     256           0 :     return m_xEvents;
     257             :     // <- SAFE
     258             : }
     259             : 
     260             : 
     261           0 : void SAL_CALL SfxGlobalEvents_Impl::addEventListener(const uno::Reference< document::XEventListener >& xListener)
     262             :     throw(uno::RuntimeException, std::exception)
     263             : {
     264             :     // container is threadsafe
     265           0 :     m_aLegacyListeners.addInterface(xListener);
     266           0 : }
     267             : 
     268             : 
     269           0 : void SAL_CALL SfxGlobalEvents_Impl::removeEventListener(const uno::Reference< document::XEventListener >& xListener)
     270             :     throw(uno::RuntimeException, std::exception)
     271             : {
     272             :     // container is threadsafe
     273           0 :     m_aLegacyListeners.removeInterface(xListener);
     274           0 : }
     275             : 
     276             : 
     277           0 : void SAL_CALL SfxGlobalEvents_Impl::addDocumentEventListener( const uno::Reference< document::XDocumentEventListener >& _Listener )
     278             :     throw(uno::RuntimeException, std::exception)
     279             : {
     280           0 :     m_aDocumentListeners.addInterface( _Listener );
     281           0 : }
     282             : 
     283             : 
     284           0 : void SAL_CALL SfxGlobalEvents_Impl::removeDocumentEventListener( const uno::Reference< document::XDocumentEventListener >& _Listener )
     285             :     throw(uno::RuntimeException, std::exception)
     286             : {
     287           0 :     m_aDocumentListeners.removeInterface( _Listener );
     288           0 : }
     289             : 
     290             : 
     291           0 : void SAL_CALL SfxGlobalEvents_Impl::notifyDocumentEvent( const OUString& /*_EventName*/,
     292             :         const uno::Reference< frame::XController2 >& /*_ViewController*/, const uno::Any& /*_Supplement*/ )
     293             :         throw (lang::IllegalArgumentException, lang::NoSupportException, uno::RuntimeException, std::exception)
     294             : {
     295             :     // we're a multiplexer only, no chance to generate artifical events here
     296           0 :     throw lang::NoSupportException(OUString(), *this);
     297             : }
     298             : 
     299             : 
     300           0 : void SAL_CALL SfxGlobalEvents_Impl::notifyEvent(const document::EventObject& aEvent)
     301             :     throw(uno::RuntimeException, std::exception)
     302             : {
     303           0 :     document::DocumentEvent aDocEvent(aEvent.Source, aEvent.EventName, NULL, uno::Any());
     304           0 :     implts_notifyJobExecution(aEvent);
     305           0 :     implts_checkAndExecuteEventBindings(aDocEvent);
     306           0 :     implts_notifyListener(aDocEvent);
     307           0 : }
     308             : 
     309             : 
     310           0 : void SAL_CALL SfxGlobalEvents_Impl::documentEventOccured( const document::DocumentEvent& _Event )
     311             :     throw (uno::RuntimeException, std::exception)
     312             : {
     313           0 :     implts_notifyJobExecution(document::EventObject(_Event.Source, _Event.EventName));
     314           0 :     implts_checkAndExecuteEventBindings(_Event);
     315           0 :     implts_notifyListener(_Event);
     316           0 : }
     317             : 
     318             : 
     319           0 : void SAL_CALL SfxGlobalEvents_Impl::disposing(const lang::EventObject& aEvent)
     320             :     throw(uno::RuntimeException, std::exception)
     321             : {
     322           0 :     uno::Reference< frame::XModel > xDoc(aEvent.Source, uno::UNO_QUERY);
     323             : 
     324             :     // SAFE ->
     325           0 :     ::osl::ResettableMutexGuard aLock(m_aLock);
     326           0 :     TModelList::iterator pIt = impl_searchDoc(xDoc);
     327           0 :     if (pIt != m_lModels.end())
     328           0 :         m_lModels.erase(pIt);
     329           0 :     aLock.clear();
     330             :     // <- SAFE
     331           0 : }
     332             : 
     333             : 
     334           0 : sal_Bool SAL_CALL SfxGlobalEvents_Impl::has(const uno::Any& aElement)
     335             :     throw (uno::RuntimeException, std::exception)
     336             : {
     337           0 :     uno::Reference< frame::XModel > xDoc;
     338           0 :     aElement >>= xDoc;
     339             : 
     340           0 :     bool bHas = false;
     341             : 
     342             :     // SAFE ->
     343           0 :     ::osl::ResettableMutexGuard aLock(m_aLock);
     344           0 :     TModelList::iterator pIt = impl_searchDoc(xDoc);
     345           0 :     if (pIt != m_lModels.end())
     346           0 :         bHas = true;
     347           0 :     aLock.clear();
     348             :     // <- SAFE
     349             : 
     350           0 :     return bHas;
     351             : }
     352             : 
     353             : 
     354           0 : void SAL_CALL SfxGlobalEvents_Impl::insert( const uno::Any& aElement )
     355             :     throw (lang::IllegalArgumentException  ,
     356             :            container::ElementExistException,
     357             :            uno::RuntimeException, std::exception           )
     358             : {
     359           0 :     uno::Reference< frame::XModel > xDoc;
     360           0 :     aElement >>= xDoc;
     361           0 :     if (!xDoc.is())
     362             :         throw lang::IllegalArgumentException(
     363             :                 OUString("Cant locate at least the model parameter."),
     364             :                 static_cast< container::XSet* >(this),
     365           0 :                 0);
     366             : 
     367             :     // SAFE ->
     368           0 :     ::osl::ResettableMutexGuard aLock(m_aLock);
     369           0 :     TModelList::iterator pIt = impl_searchDoc(xDoc);
     370           0 :     if (pIt != m_lModels.end())
     371             :         throw container::ElementExistException(
     372             :                 OUString(),
     373           0 :                 static_cast< container::XSet* >(this));
     374           0 :     m_lModels.push_back(xDoc);
     375           0 :     aLock.clear();
     376             :     // <- SAFE
     377             : 
     378           0 :     uno::Reference< document::XDocumentEventBroadcaster > xDocBroadcaster(xDoc, uno::UNO_QUERY );
     379           0 :     if (xDocBroadcaster.is())
     380           0 :         xDocBroadcaster->addDocumentEventListener(this);
     381             :     else
     382             :     {
     383             :         // try the "legacy version" of XDocumentEventBroadcaster, which is XEventBroadcaster
     384           0 :         uno::Reference< document::XEventBroadcaster > xBroadcaster(xDoc, uno::UNO_QUERY);
     385           0 :         if (xBroadcaster.is())
     386           0 :             xBroadcaster->addEventListener(static_cast< document::XEventListener* >(this));
     387           0 :     }
     388           0 : }
     389             : 
     390             : 
     391           0 : void SAL_CALL SfxGlobalEvents_Impl::remove( const uno::Any& aElement )
     392             :     throw (lang::IllegalArgumentException   ,
     393             :            container::NoSuchElementException,
     394             :            uno::RuntimeException, std::exception            )
     395             : {
     396           0 :     uno::Reference< frame::XModel > xDoc;
     397           0 :     aElement >>= xDoc;
     398           0 :     if (!xDoc.is())
     399             :         throw lang::IllegalArgumentException(
     400             :                 OUString("Cant locate at least the model parameter."),
     401             :                 static_cast< container::XSet* >(this),
     402           0 :                 0);
     403             : 
     404             :     // SAFE ->
     405           0 :     ::osl::ResettableMutexGuard aLock(m_aLock);
     406           0 :     TModelList::iterator pIt = impl_searchDoc(xDoc);
     407           0 :     if (pIt == m_lModels.end())
     408             :         throw container::NoSuchElementException(
     409             :                 OUString(),
     410           0 :                 static_cast< container::XSet* >(this));
     411           0 :     m_lModels.erase(pIt);
     412           0 :     aLock.clear();
     413             :     // <- SAFE
     414             : 
     415           0 :     uno::Reference< document::XDocumentEventBroadcaster > xDocBroadcaster(xDoc, uno::UNO_QUERY );
     416           0 :     if (xDocBroadcaster.is())
     417           0 :         xDocBroadcaster->removeDocumentEventListener(this);
     418             :     else
     419             :     {
     420             :         // try the "legacy version" of XDocumentEventBroadcaster, which is XEventBroadcaster
     421           0 :         uno::Reference< document::XEventBroadcaster > xBroadcaster(xDoc, uno::UNO_QUERY);
     422           0 :         if (xBroadcaster.is())
     423           0 :             xBroadcaster->removeEventListener(static_cast< document::XEventListener* >(this));
     424           0 :     }
     425           0 : }
     426             : 
     427             : 
     428           0 : uno::Reference< container::XEnumeration > SAL_CALL SfxGlobalEvents_Impl::createEnumeration()
     429             :     throw (uno::RuntimeException, std::exception)
     430             : {
     431             :     // SAFE ->
     432           0 :     ::osl::ResettableMutexGuard aLock(m_aLock);
     433           0 :     ModelCollectionEnumeration* pEnum = new ModelCollectionEnumeration();
     434           0 :     pEnum->setModelList(m_lModels);
     435             :     uno::Reference< container::XEnumeration > xEnum(
     436           0 :         static_cast< container::XEnumeration* >(pEnum),
     437           0 :         uno::UNO_QUERY);
     438           0 :     aLock.clear();
     439             :     // <- SAFE
     440             : 
     441           0 :     return xEnum;
     442             : }
     443             : 
     444             : 
     445           0 : uno::Type SAL_CALL SfxGlobalEvents_Impl::getElementType()
     446             :     throw (uno::RuntimeException, std::exception)
     447             : {
     448           0 :     return ::getCppuType(static_cast< uno::Reference< frame::XModel >* >(NULL));
     449             : }
     450             : 
     451             : 
     452           0 : sal_Bool SAL_CALL SfxGlobalEvents_Impl::hasElements()
     453             :     throw (uno::RuntimeException, std::exception)
     454             : {
     455             :     // SAFE ->
     456           0 :     ::osl::ResettableMutexGuard aLock(m_aLock);
     457           0 :     return (m_lModels.size()>0);
     458             :     // <- SAFE
     459             : }
     460             : 
     461             : 
     462           0 : void SfxGlobalEvents_Impl::implts_notifyJobExecution(const document::EventObject& aEvent)
     463             : {
     464             :     try
     465             :     {
     466           0 :         m_xJobExecutorListener->notifyEvent(aEvent);
     467             :     }
     468           0 :     catch(const uno::RuntimeException&)
     469           0 :         { throw; }
     470           0 :     catch(const uno::Exception&)
     471             :         {}
     472           0 : }
     473             : 
     474             : 
     475           0 : void SfxGlobalEvents_Impl::implts_checkAndExecuteEventBindings(const document::DocumentEvent& aEvent)
     476             : {
     477             :     try
     478             :     {
     479             :         // SAFE ->
     480           0 :         ::osl::ResettableMutexGuard aLock(m_aLock);
     481           0 :         uno::Reference< container::XNameReplace > xEvents = m_xEvents;
     482           0 :         aLock.clear();
     483             :         // <- SAFE
     484             : 
     485           0 :         uno::Any aAny;
     486           0 :         if ( xEvents.is() && xEvents->hasByName( aEvent.EventName ) )
     487           0 :             aAny = xEvents->getByName(aEvent.EventName);
     488           0 :         SfxEvents_Impl::Execute(aAny, aEvent, 0);
     489             :     }
     490           0 :     catch ( uno::RuntimeException const & )
     491             :     {
     492           0 :         throw;
     493             :     }
     494           0 :     catch ( uno::Exception const & )
     495             :     {
     496             :        DBG_UNHANDLED_EXCEPTION();
     497             :     }
     498           0 : }
     499             : 
     500             : 
     501           0 : void SfxGlobalEvents_Impl::implts_notifyListener(const document::DocumentEvent& aEvent)
     502             : {
     503             :     // containers are threadsafe
     504           0 :     document::EventObject aLegacyEvent(aEvent.Source, aEvent.EventName);
     505           0 :     m_aLegacyListeners.notifyEach( &document::XEventListener::notifyEvent, aLegacyEvent );
     506             : 
     507           0 :     m_aDocumentListeners.notifyEach( &document::XDocumentEventListener::documentEventOccured, aEvent );
     508           0 : }
     509             : 
     510             : 
     511             : // not threadsafe ... must be locked from outside!
     512           0 : TModelList::iterator SfxGlobalEvents_Impl::impl_searchDoc(const uno::Reference< frame::XModel >& xModel)
     513             : {
     514           0 :     if (!xModel.is())
     515           0 :         return m_lModels.end();
     516             : 
     517           0 :     TModelList::iterator pIt;
     518           0 :     for (  pIt  = m_lModels.begin();
     519           0 :            pIt != m_lModels.end()  ;
     520             :          ++pIt                     )
     521             :     {
     522           0 :         uno::Reference< frame::XModel > xContainerDoc(*pIt, uno::UNO_QUERY);
     523           0 :         if (xContainerDoc == xModel)
     524           0 :             break;
     525           0 :     }
     526             : 
     527           0 :     return pIt;
     528             : }
     529             : 
     530           0 : struct Instance {
     531           0 :     explicit Instance(
     532             :         css::uno::Reference<css::uno::XComponentContext> const & context):
     533             :         instance(
     534           0 :             static_cast<cppu::OWeakObject *>(new SfxGlobalEvents_Impl(context)))
     535           0 :     {}
     536             : 
     537             :     rtl::Reference<css::uno::XInterface> instance;
     538             : };
     539             : 
     540             : struct Singleton:
     541             :     public rtl::StaticWithArg<
     542             :         Instance, css::uno::Reference<css::uno::XComponentContext>, Singleton>
     543             : {};
     544             : 
     545             : }
     546             : 
     547             : extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface * SAL_CALL
     548           0 : com_sun_star_comp_sfx2_GlobalEventBroadcaster_get_implementation(
     549             :     css::uno::XComponentContext *context,
     550             :     css::uno::Sequence<css::uno::Any> const &)
     551             : {
     552             :     return cppu::acquire(static_cast<cppu::OWeakObject *>(
     553           0 :                 Singleton::get(context).instance.get()));
     554             : }
     555             : 
     556             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10