LCOV - code coverage report
Current view: top level - embeddedobj/source/general - dummyobject.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 176 276 63.8 %
Date: 2015-06-13 12:38:46 Functions: 26 40 65.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 <com/sun/star/embed/EmbedStates.hpp>
      21             : #include <com/sun/star/embed/EmbedVerbs.hpp>
      22             : #include <com/sun/star/embed/EmbedUpdateModes.hpp>
      23             : #include <com/sun/star/embed/XEmbeddedClient.hpp>
      24             : #include <com/sun/star/embed/XInplaceClient.hpp>
      25             : #include <com/sun/star/embed/XWindowSupplier.hpp>
      26             : #include <com/sun/star/embed/StateChangeInProgressException.hpp>
      27             : #include <com/sun/star/embed/Aspects.hpp>
      28             : #include <com/sun/star/embed/EmbedMapUnits.hpp>
      29             : #include <com/sun/star/embed/EntryInitModes.hpp>
      30             : #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
      31             : #include <com/sun/star/lang/DisposedException.hpp>
      32             : 
      33             : #include <cppuhelper/interfacecontainer.h>
      34             : 
      35             : #include <dummyobject.hxx>
      36             : 
      37             : 
      38             : using namespace ::com::sun::star;
      39             : 
      40             : 
      41        1532 : void ODummyEmbeddedObject::CheckInit_WrongState()
      42             : {
      43        1532 :     if ( m_bDisposed )
      44           0 :         throw lang::DisposedException();
      45             : 
      46        1532 :     if ( m_nObjectState == -1 )
      47             :         throw embed::WrongStateException( "The object has no persistence!",
      48           0 :                                         static_cast< ::cppu::OWeakObject* >(this) );
      49        1532 : }
      50             : 
      51         284 : void ODummyEmbeddedObject::CheckInit_Runtime()
      52             : {
      53         284 :     if ( m_bDisposed )
      54           0 :         throw lang::DisposedException();
      55             : 
      56         284 :     if ( m_nObjectState == -1 )
      57             :         throw uno::RuntimeException( "The object has no persistence!",
      58           0 :                                      static_cast< ::cppu::OWeakObject* >(this) );
      59         284 : }
      60          48 : void ODummyEmbeddedObject::PostEvent_Impl( const OUString& aEventName )
      61             : {
      62          48 :     if ( m_pInterfaceContainer )
      63             :     {
      64             :         ::cppu::OInterfaceContainerHelper* pIC = m_pInterfaceContainer->getContainer(
      65          48 :                                             cppu::UnoType<document::XEventListener>::get());
      66          48 :         if( pIC )
      67             :         {
      68          48 :             document::EventObject aEvent;
      69          48 :             aEvent.EventName = aEventName;
      70          48 :             aEvent.Source = uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >( this ) );
      71             :             // For now all the events are sent as object events
      72             :             // aEvent.Source = ( xSource.is() ? xSource
      73             :             //                     : uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >( this ) ) );
      74          96 :             ::cppu::OInterfaceIteratorHelper aIt( *pIC );
      75         138 :             while( aIt.hasMoreElements() )
      76             :             {
      77             :                 try
      78             :                 {
      79          42 :                     static_cast<document::XEventListener *>(aIt.next())->notifyEvent( aEvent );
      80             :                 }
      81           0 :                 catch( const uno::RuntimeException& )
      82             :                 {
      83           0 :                     aIt.remove();
      84             :                 }
      85             : 
      86             :                 // the listener could dispose the object.
      87          42 :                 if ( m_bDisposed )
      88          48 :                     return;
      89          48 :             }
      90             :         }
      91             :     }
      92             : }
      93             : 
      94             : 
      95         170 : ODummyEmbeddedObject::~ODummyEmbeddedObject()
      96             : {
      97         170 : }
      98             : 
      99             : 
     100          56 : void SAL_CALL ODummyEmbeddedObject::changeState( sal_Int32 nNewState )
     101             :         throw ( embed::UnreachableStateException,
     102             :                 embed::WrongStateException,
     103             :                 uno::Exception,
     104             :                 uno::RuntimeException, std::exception )
     105             : {
     106          56 :     ::osl::MutexGuard aGuard( m_aMutex );
     107          56 :     CheckInit_WrongState();
     108             : 
     109          56 :     if ( nNewState == embed::EmbedStates::LOADED )
     110          84 :         return;
     111             : 
     112          14 :     throw embed::UnreachableStateException();
     113             : }
     114             : 
     115             : 
     116           0 : uno::Sequence< sal_Int32 > SAL_CALL ODummyEmbeddedObject::getReachableStates()
     117             :         throw ( embed::WrongStateException,
     118             :                 uno::RuntimeException, std::exception )
     119             : {
     120           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     121           0 :     CheckInit_WrongState();
     122             : 
     123           0 :     uno::Sequence< sal_Int32 > aResult( 1 );
     124           0 :     aResult[0] = embed::EmbedStates::LOADED;
     125             : 
     126           0 :     return aResult;
     127             : }
     128             : 
     129             : 
     130        1163 : sal_Int32 SAL_CALL ODummyEmbeddedObject::getCurrentState()
     131             :         throw ( embed::WrongStateException,
     132             :                 uno::RuntimeException, std::exception )
     133             : {
     134        1163 :     ::osl::MutexGuard aGuard( m_aMutex );
     135        1163 :     CheckInit_WrongState();
     136             : 
     137        1163 :     return m_nObjectState;
     138             : }
     139             : 
     140             : 
     141           0 : void SAL_CALL ODummyEmbeddedObject::doVerb( sal_Int32 )
     142             :         throw ( lang::IllegalArgumentException,
     143             :                 embed::WrongStateException,
     144             :                 embed::UnreachableStateException,
     145             :                 uno::Exception,
     146             :                 uno::RuntimeException, std::exception )
     147             : {
     148           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     149           0 :     CheckInit_WrongState();
     150             : 
     151             :     // no supported verbs
     152           0 : }
     153             : 
     154             : 
     155           0 : uno::Sequence< embed::VerbDescriptor > SAL_CALL ODummyEmbeddedObject::getSupportedVerbs()
     156             :         throw ( embed::WrongStateException,
     157             :                 uno::RuntimeException, std::exception )
     158             : {
     159           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     160           0 :     CheckInit_WrongState();
     161             : 
     162           0 :     return uno::Sequence< embed::VerbDescriptor >();
     163             : }
     164             : 
     165             : 
     166           6 : void SAL_CALL ODummyEmbeddedObject::setClientSite(
     167             :                 const uno::Reference< embed::XEmbeddedClient >& xClient )
     168             :         throw ( embed::WrongStateException,
     169             :                 uno::RuntimeException, std::exception )
     170             : {
     171           6 :     ::osl::MutexGuard aGuard( m_aMutex );
     172           6 :     CheckInit_WrongState();
     173             : 
     174           6 :     m_xClientSite = xClient;
     175           6 : }
     176             : 
     177             : 
     178           0 : uno::Reference< embed::XEmbeddedClient > SAL_CALL ODummyEmbeddedObject::getClientSite()
     179             :         throw ( embed::WrongStateException,
     180             :                 uno::RuntimeException, std::exception )
     181             : {
     182           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     183           0 :     CheckInit_WrongState();
     184             : 
     185           0 :     return m_xClientSite;
     186             : }
     187             : 
     188             : 
     189           0 : void SAL_CALL ODummyEmbeddedObject::update()
     190             :         throw ( embed::WrongStateException,
     191             :                 uno::Exception,
     192             :                 uno::RuntimeException, std::exception )
     193             : {
     194           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     195           0 :     CheckInit_WrongState();
     196           0 : }
     197             : 
     198             : 
     199           0 : void SAL_CALL ODummyEmbeddedObject::setUpdateMode( sal_Int32 )
     200             :         throw ( embed::WrongStateException,
     201             :                 uno::RuntimeException, std::exception )
     202             : {
     203           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     204           0 :     CheckInit_WrongState();
     205           0 : }
     206             : 
     207             : 
     208         143 : sal_Int64 SAL_CALL ODummyEmbeddedObject::getStatus( sal_Int64 )
     209             :         throw ( embed::WrongStateException,
     210             :                 uno::RuntimeException, std::exception )
     211             : {
     212         143 :     ::osl::MutexGuard aGuard( m_aMutex );
     213         143 :     CheckInit_WrongState();
     214             : 
     215         143 :     return 0;
     216             : }
     217             : 
     218             : 
     219           0 : void SAL_CALL ODummyEmbeddedObject::setContainerName( const OUString& )
     220             :         throw ( uno::RuntimeException, std::exception )
     221             : {
     222           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     223           0 :     CheckInit_Runtime();
     224           0 : }
     225             : 
     226             : 
     227           8 : void SAL_CALL ODummyEmbeddedObject::setVisualAreaSize( sal_Int64 nAspect, const awt::Size& aSize )
     228             :         throw ( lang::IllegalArgumentException,
     229             :                 embed::WrongStateException,
     230             :                 uno::Exception,
     231             :                 uno::RuntimeException, std::exception )
     232             : {
     233           8 :     ::osl::MutexGuard aGuard( m_aMutex );
     234           8 :     CheckInit_WrongState();
     235             : 
     236             :     OSL_ENSURE( nAspect != embed::Aspects::MSOLE_ICON, "For iconified objects no graphical replacement is required!\n" );
     237           8 :     if ( nAspect == embed::Aspects::MSOLE_ICON )
     238             :         // no representation can be retrieved
     239             :         throw embed::WrongStateException( "Illegal call!",
     240           0 :                                     static_cast< ::cppu::OWeakObject* >(this) );
     241             : 
     242           8 :     m_nCachedAspect = nAspect;
     243           8 :     m_aCachedSize = aSize;
     244           8 :     m_bHasCachedSize = true;
     245           8 : }
     246             : 
     247             : 
     248          26 : awt::Size SAL_CALL ODummyEmbeddedObject::getVisualAreaSize( sal_Int64 nAspect )
     249             :         throw ( lang::IllegalArgumentException,
     250             :                 embed::WrongStateException,
     251             :                 uno::Exception,
     252             :                 uno::RuntimeException, std::exception )
     253             : {
     254          26 :     ::osl::MutexGuard aGuard( m_aMutex );
     255          26 :     CheckInit_WrongState();
     256             : 
     257             :     OSL_ENSURE( nAspect != embed::Aspects::MSOLE_ICON, "For iconified objects no graphical replacement is required!\n" );
     258          26 :     if ( nAspect == embed::Aspects::MSOLE_ICON )
     259             :         // no representation can be retrieved
     260             :         throw embed::WrongStateException( "Illegal call!",
     261           0 :                                     static_cast< ::cppu::OWeakObject* >(this) );
     262             : 
     263          26 :     if ( !m_bHasCachedSize || m_nCachedAspect != nAspect )
     264             :         throw embed::NoVisualAreaSizeException(
     265             :                 "No size available!",
     266          20 :                 static_cast< ::cppu::OWeakObject* >(this) );
     267             : 
     268          26 :     return m_aCachedSize;
     269             : }
     270             : 
     271             : 
     272          29 : sal_Int32 SAL_CALL ODummyEmbeddedObject::getMapUnit( sal_Int64 nAspect )
     273             :         throw ( uno::Exception,
     274             :                 uno::RuntimeException, std::exception)
     275             : {
     276          29 :     ::osl::MutexGuard aGuard( m_aMutex );
     277          29 :     CheckInit_Runtime();
     278             : 
     279             :     OSL_ENSURE( nAspect != embed::Aspects::MSOLE_ICON, "For iconified objects no graphical replacement is required!\n" );
     280          29 :     if ( nAspect == embed::Aspects::MSOLE_ICON )
     281             :         // no representation can be retrieved
     282             :         throw embed::WrongStateException( "Illegal call!",
     283           0 :                                     static_cast< ::cppu::OWeakObject* >(this) );
     284             : 
     285          29 :     return embed::EmbedMapUnits::ONE_100TH_MM;
     286             : }
     287             : 
     288             : 
     289           0 : embed::VisualRepresentation SAL_CALL ODummyEmbeddedObject::getPreferredVisualRepresentation( sal_Int64 )
     290             :         throw ( lang::IllegalArgumentException,
     291             :                 embed::WrongStateException,
     292             :                 uno::Exception,
     293             :                 uno::RuntimeException, std::exception )
     294             : {
     295           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     296           0 :     CheckInit_WrongState();
     297             : 
     298             :     // no representation can be retrieved
     299             :     throw embed::WrongStateException( "Illegal call!",
     300           0 :                                 static_cast< ::cppu::OWeakObject* >(this) );
     301             : }
     302             : 
     303             : 
     304          85 : void SAL_CALL ODummyEmbeddedObject::setPersistentEntry(
     305             :                     const uno::Reference< embed::XStorage >& xStorage,
     306             :                     const OUString& sEntName,
     307             :                     sal_Int32 nEntryConnectionMode,
     308             :                     const uno::Sequence< beans::PropertyValue >& /* lArguments */,
     309             :                     const uno::Sequence< beans::PropertyValue >& /* lObjArgs */ )
     310             :         throw ( lang::IllegalArgumentException,
     311             :                 embed::WrongStateException,
     312             :                 io::IOException,
     313             :                 uno::Exception,
     314             :                 uno::RuntimeException, std::exception )
     315             : {
     316          85 :     ::osl::MutexGuard aGuard( m_aMutex );
     317          85 :     if ( m_bDisposed )
     318           0 :         throw lang::DisposedException(); // TODO
     319             : 
     320          85 :     if ( !xStorage.is() )
     321             :         throw lang::IllegalArgumentException( "No parent storage is provided!",
     322             :                                             static_cast< ::cppu::OWeakObject* >(this),
     323           0 :                                             1 );
     324             : 
     325          85 :     if ( sEntName.isEmpty() )
     326             :         throw lang::IllegalArgumentException( "Empty element name is provided!",
     327             :                                             static_cast< ::cppu::OWeakObject* >(this),
     328           0 :                                             2 );
     329             : 
     330          85 :     if ( ( m_nObjectState != -1 || nEntryConnectionMode == embed::EntryInitModes::NO_INIT )
     331           0 :       && ( m_nObjectState == -1 || nEntryConnectionMode != embed::EntryInitModes::NO_INIT ) )
     332             :     {
     333             :         throw embed::WrongStateException(
     334             :                     "Can't change persistent representation of activated object!",
     335           0 :                     static_cast< ::cppu::OWeakObject* >(this) );
     336             :     }
     337             : 
     338          85 :     if ( m_bWaitSaveCompleted )
     339             :     {
     340           0 :         if ( nEntryConnectionMode == embed::EntryInitModes::NO_INIT )
     341           0 :             saveCompleted( ( m_xParentStorage != xStorage || !m_aEntryName.equals( sEntName ) ) );
     342             :         else
     343             :             throw embed::WrongStateException(
     344             :                         "The object waits for saveCompleted() call!",
     345           0 :                         static_cast< ::cppu::OWeakObject* >(this) );
     346             :     }
     347             : 
     348          85 :     if ( nEntryConnectionMode == embed::EntryInitModes::DEFAULT_INIT
     349           0 :       || nEntryConnectionMode == embed::EntryInitModes::NO_INIT )
     350             :     {
     351         170 :         if ( xStorage->hasByName( sEntName ) )
     352             : 
     353             :         {
     354          85 :             m_xParentStorage = xStorage;
     355          85 :             m_aEntryName = sEntName;
     356          85 :             m_nObjectState = embed::EmbedStates::LOADED;
     357             :         }
     358             :         else
     359             :             throw lang::IllegalArgumentException( "Wrong entry is provided!",
     360             :                                 static_cast< ::cppu::OWeakObject* >(this),
     361           0 :                                 2 );
     362             : 
     363             :     }
     364             :     else
     365             :         throw lang::IllegalArgumentException( "Wrong connection mode is provided!",
     366             :                                 static_cast< ::cppu::OWeakObject* >(this),
     367           0 :                                 3 );
     368          85 : }
     369             : 
     370             : 
     371          18 : void SAL_CALL ODummyEmbeddedObject::storeToEntry( const uno::Reference< embed::XStorage >& xStorage,
     372             :                             const OUString& sEntName,
     373             :                             const uno::Sequence< beans::PropertyValue >& /* lArguments */,
     374             :                             const uno::Sequence< beans::PropertyValue >& /* lObjArgs */ )
     375             :         throw ( lang::IllegalArgumentException,
     376             :                 embed::WrongStateException,
     377             :                 io::IOException,
     378             :                 uno::Exception,
     379             :                 uno::RuntimeException, std::exception )
     380             : {
     381          18 :     ::osl::MutexGuard aGuard( m_aMutex );
     382          18 :     CheckInit_WrongState();
     383             : 
     384          18 :     if ( m_bWaitSaveCompleted )
     385             :         throw embed::WrongStateException(
     386             :                     "The object waits for saveCompleted() call!",
     387           0 :                     static_cast< ::cppu::OWeakObject* >(this) );
     388             : 
     389          18 :     m_xParentStorage->copyElementTo( m_aEntryName, xStorage, sEntName );
     390          18 : }
     391             : 
     392             : 
     393          27 : void SAL_CALL ODummyEmbeddedObject::storeAsEntry( const uno::Reference< embed::XStorage >& xStorage,
     394             :                             const OUString& sEntName,
     395             :                             const uno::Sequence< beans::PropertyValue >& /* lArguments */,
     396             :                             const uno::Sequence< beans::PropertyValue >& /* lObjArgs */ )
     397             :         throw ( lang::IllegalArgumentException,
     398             :                 embed::WrongStateException,
     399             :                 io::IOException,
     400             :                 uno::Exception,
     401             :                 uno::RuntimeException, std::exception )
     402             : {
     403          27 :     ::osl::MutexGuard aGuard( m_aMutex );
     404          27 :     CheckInit_WrongState();
     405             : 
     406          27 :     if ( m_bWaitSaveCompleted )
     407             :         throw embed::WrongStateException(
     408             :                     "The object waits for saveCompleted() call!",
     409           0 :                     static_cast< ::cppu::OWeakObject* >(this) );
     410             : 
     411          27 :     PostEvent_Impl( OUString( "OnSaveAs" ) );
     412             : 
     413          27 :     m_xParentStorage->copyElementTo( m_aEntryName, xStorage, sEntName );
     414             : 
     415          27 :     m_bWaitSaveCompleted = true;
     416          27 :     m_xNewParentStorage = xStorage;
     417          27 :     m_aNewEntryName = sEntName;
     418          27 : }
     419             : 
     420             : 
     421          43 : void SAL_CALL ODummyEmbeddedObject::saveCompleted( sal_Bool bUseNew )
     422             :         throw ( embed::WrongStateException,
     423             :                 uno::Exception,
     424             :                 uno::RuntimeException, std::exception )
     425             : {
     426          43 :     ::osl::MutexGuard aGuard( m_aMutex );
     427          43 :     CheckInit_WrongState();
     428             : 
     429             :     // it is allowed to call saveCompleted( false ) for nonstored objects
     430          43 :     if ( !m_bWaitSaveCompleted && !bUseNew )
     431          59 :         return;
     432             : 
     433             :     OSL_ENSURE( m_bWaitSaveCompleted, "Unexpected saveCompleted() call!\n" );
     434          27 :     if ( !m_bWaitSaveCompleted )
     435           0 :         throw io::IOException(); // TODO: illegal call
     436             : 
     437             :     OSL_ENSURE( m_xNewParentStorage.is() , "Internal object information is broken!\n" );
     438          27 :     if ( !m_xNewParentStorage.is() )
     439           0 :         throw uno::RuntimeException(); // TODO: broken internal information
     440             : 
     441          27 :     if ( bUseNew )
     442             :     {
     443          21 :         m_xParentStorage = m_xNewParentStorage;
     444          21 :         m_aEntryName = m_aNewEntryName;
     445             : 
     446          21 :         PostEvent_Impl( OUString( "OnSaveAsDone" ) );
     447             :     }
     448             : 
     449          27 :     m_xNewParentStorage = uno::Reference< embed::XStorage >();
     450          27 :     m_aNewEntryName.clear();
     451          27 :     m_bWaitSaveCompleted = false;
     452             : }
     453             : 
     454             : 
     455           0 : sal_Bool SAL_CALL ODummyEmbeddedObject::hasEntry()
     456             :         throw ( embed::WrongStateException,
     457             :                 uno::RuntimeException, std::exception )
     458             : {
     459           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     460           0 :     CheckInit_WrongState();
     461             : 
     462           0 :     if ( m_bWaitSaveCompleted )
     463             :         throw embed::WrongStateException(
     464             :                     "The object waits for saveCompleted() call!",
     465           0 :                     static_cast< ::cppu::OWeakObject* >(this) );
     466             : 
     467           0 :     if ( !m_aEntryName.isEmpty() )
     468           0 :         return sal_True;
     469             : 
     470           0 :     return sal_False;
     471             : }
     472             : 
     473             : 
     474          42 : OUString SAL_CALL ODummyEmbeddedObject::getEntryName()
     475             :         throw ( embed::WrongStateException,
     476             :                 uno::RuntimeException, std::exception )
     477             : {
     478          42 :     ::osl::MutexGuard aGuard( m_aMutex );
     479          42 :     CheckInit_WrongState();
     480             : 
     481          42 :     if ( m_bWaitSaveCompleted )
     482             :         throw embed::WrongStateException(
     483             :                     "The object waits for saveCompleted() call!",
     484           0 :                     static_cast< ::cppu::OWeakObject* >(this) );
     485             : 
     486          42 :     return m_aEntryName;
     487             : }
     488             : 
     489             : 
     490           0 : void SAL_CALL ODummyEmbeddedObject::storeOwn()
     491             :         throw ( embed::WrongStateException,
     492             :                 io::IOException,
     493             :                 uno::Exception,
     494             :                 uno::RuntimeException, std::exception )
     495             : {
     496           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     497           0 :     CheckInit_WrongState();
     498             : 
     499           0 :     if ( m_bWaitSaveCompleted )
     500             :         throw embed::WrongStateException(
     501             :                     "The object waits for saveCompleted() call!",
     502           0 :                     static_cast< ::cppu::OWeakObject* >(this) );
     503             : 
     504             :     // the object can not be activated or changed
     505           0 :     return;
     506             : }
     507             : 
     508             : 
     509           0 : sal_Bool SAL_CALL ODummyEmbeddedObject::isReadonly()
     510             :         throw ( embed::WrongStateException,
     511             :                 uno::RuntimeException, std::exception )
     512             : {
     513           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     514           0 :     CheckInit_WrongState();
     515             : 
     516           0 :     if ( m_bWaitSaveCompleted )
     517             :         throw embed::WrongStateException(
     518             :                     "The object waits for saveCompleted() call!",
     519           0 :                     static_cast< ::cppu::OWeakObject* >(this) );
     520             : 
     521             :     // this object can not be changed
     522           0 :     return sal_True;
     523             : }
     524             : 
     525             : 
     526           0 : void SAL_CALL ODummyEmbeddedObject::reload(
     527             :                 const uno::Sequence< beans::PropertyValue >& /* lArguments */,
     528             :                 const uno::Sequence< beans::PropertyValue >& /* lObjArgs */ )
     529             :         throw ( lang::IllegalArgumentException,
     530             :                 embed::WrongStateException,
     531             :                 io::IOException,
     532             :                 uno::Exception,
     533             :                 uno::RuntimeException, std::exception )
     534             : {
     535           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     536           0 :     CheckInit_WrongState();
     537             : 
     538           0 :     if ( m_bWaitSaveCompleted )
     539             :         throw embed::WrongStateException(
     540             :                     "The object waits for saveCompleted() call!",
     541           0 :                     static_cast< ::cppu::OWeakObject* >(this) );
     542             : 
     543             :     // nothing to reload
     544           0 : }
     545             : 
     546             : 
     547         198 : uno::Sequence< sal_Int8 > SAL_CALL ODummyEmbeddedObject::getClassID()
     548             :         throw ( uno::RuntimeException, std::exception )
     549             : {
     550         198 :     ::osl::MutexGuard aGuard( m_aMutex );
     551         198 :     CheckInit_Runtime();
     552             : 
     553             :     // currently the class ID is empty
     554             :     // TODO/LATER: should a special class ID be used in this case?
     555         198 :     return uno::Sequence< sal_Int8 >();
     556             : }
     557             : 
     558             : 
     559           0 : OUString SAL_CALL ODummyEmbeddedObject::getClassName()
     560             :         throw ( uno::RuntimeException, std::exception )
     561             : {
     562           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     563           0 :     if ( m_bDisposed )
     564           0 :         throw lang::DisposedException(); // TODO
     565             : 
     566           0 :     return OUString();
     567             : }
     568             : 
     569             : 
     570           0 : void SAL_CALL ODummyEmbeddedObject::setClassInfo(
     571             :                 const uno::Sequence< sal_Int8 >& /*aClassID*/, const OUString& /*aClassName*/ )
     572             :         throw ( lang::NoSupportException,
     573             :                 uno::RuntimeException, std::exception )
     574             : {
     575           0 :     throw lang::NoSupportException();
     576             : }
     577             : 
     578             : 
     579          57 : uno::Reference< util::XCloseable > SAL_CALL ODummyEmbeddedObject::getComponent()
     580             :         throw ( uno::RuntimeException, std::exception )
     581             : {
     582          57 :     ::osl::MutexGuard aGuard( m_aMutex );
     583          57 :     CheckInit_Runtime();
     584             : 
     585          57 :     return uno::Reference< util::XCloseable >();
     586             : }
     587             : 
     588             : 
     589         169 : void SAL_CALL ODummyEmbeddedObject::addStateChangeListener( const uno::Reference< embed::XStateChangeListener >& xListener )
     590             :     throw ( uno::RuntimeException, std::exception )
     591             : {
     592         169 :     ::osl::MutexGuard aGuard( m_aMutex );
     593         169 :     if ( m_bDisposed )
     594         169 :         return;
     595             : 
     596         169 :     if ( !m_pInterfaceContainer )
     597          80 :         m_pInterfaceContainer = new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex );
     598             : 
     599         169 :     m_pInterfaceContainer->addInterface( cppu::UnoType<embed::XStateChangeListener>::get(),
     600         338 :                                                         xListener );
     601             : }
     602             : 
     603             : 
     604         169 : void SAL_CALL ODummyEmbeddedObject::removeStateChangeListener(
     605             :                     const uno::Reference< embed::XStateChangeListener >& xListener )
     606             :     throw (uno::RuntimeException, std::exception)
     607             : {
     608         169 :     ::osl::MutexGuard aGuard( m_aMutex );
     609         169 :     if ( m_pInterfaceContainer )
     610         169 :         m_pInterfaceContainer->removeInterface( cppu::UnoType<embed::XStateChangeListener>::get(),
     611         338 :                                                 xListener );
     612         169 : }
     613             : 
     614             : 
     615          73 : void SAL_CALL ODummyEmbeddedObject::close( sal_Bool bDeliverOwnership )
     616             :     throw ( util::CloseVetoException,
     617             :             uno::RuntimeException, std::exception )
     618             : {
     619          73 :     ::osl::MutexGuard aGuard( m_aMutex );
     620          73 :     if ( m_bDisposed )
     621           0 :         throw lang::DisposedException(); // TODO
     622             : 
     623         146 :     uno::Reference< uno::XInterface > xSelfHold( static_cast< ::cppu::OWeakObject* >( this ) );
     624         146 :     lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >( this ) );
     625             : 
     626          73 :     if ( m_pInterfaceContainer )
     627             :     {
     628             :         ::cppu::OInterfaceContainerHelper* pContainer =
     629          68 :             m_pInterfaceContainer->getContainer( cppu::UnoType<util::XCloseListener>::get());
     630          68 :         if ( pContainer != NULL )
     631             :         {
     632          68 :             ::cppu::OInterfaceIteratorHelper pIterator(*pContainer);
     633         136 :             while (pIterator.hasMoreElements())
     634             :             {
     635             :                 try
     636             :                 {
     637           6 :                     static_cast<util::XCloseListener*>(pIterator.next())->queryClosing( aSource, bDeliverOwnership );
     638             :                 }
     639           0 :                 catch( const uno::RuntimeException& )
     640             :                 {
     641           0 :                     pIterator.remove();
     642             :                 }
     643          68 :             }
     644             :         }
     645             : 
     646             :         pContainer = m_pInterfaceContainer->getContainer(
     647          62 :                                     cppu::UnoType<util::XCloseListener>::get());
     648          62 :         if ( pContainer != NULL )
     649             :         {
     650          62 :             ::cppu::OInterfaceIteratorHelper pCloseIterator(*pContainer);
     651         124 :             while (pCloseIterator.hasMoreElements())
     652             :             {
     653             :                 try
     654             :                 {
     655           0 :                     static_cast<util::XCloseListener*>(pCloseIterator.next())->notifyClosing( aSource );
     656             :                 }
     657           0 :                 catch( const uno::RuntimeException& )
     658             :                 {
     659           0 :                     pCloseIterator.remove();
     660             :                 }
     661          62 :             }
     662             :         }
     663             : 
     664          62 :         m_pInterfaceContainer->disposeAndClear( aSource );
     665             :     }
     666             : 
     667         140 :     m_bDisposed = true; // the object is disposed now for outside
     668          67 : }
     669             : 
     670             : 
     671          89 : void SAL_CALL ODummyEmbeddedObject::addCloseListener( const uno::Reference< util::XCloseListener >& xListener )
     672             :     throw ( uno::RuntimeException, std::exception )
     673             : {
     674          89 :     ::osl::MutexGuard aGuard( m_aMutex );
     675          89 :     if ( m_bDisposed )
     676          89 :         return;
     677             : 
     678          89 :     if ( !m_pInterfaceContainer )
     679           0 :         m_pInterfaceContainer = new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex );
     680             : 
     681          89 :     m_pInterfaceContainer->addInterface( cppu::UnoType<util::XCloseListener>::get(), xListener );
     682             : }
     683             : 
     684             : 
     685          89 : void SAL_CALL ODummyEmbeddedObject::removeCloseListener( const uno::Reference< util::XCloseListener >& xListener )
     686             :     throw (uno::RuntimeException, std::exception)
     687             : {
     688          89 :     ::osl::MutexGuard aGuard( m_aMutex );
     689          89 :     if ( m_pInterfaceContainer )
     690          89 :         m_pInterfaceContainer->removeInterface( cppu::UnoType<util::XCloseListener>::get(),
     691         178 :                                                 xListener );
     692          89 : }
     693             : 
     694             : 
     695          95 : void SAL_CALL ODummyEmbeddedObject::addEventListener( const uno::Reference< document::XEventListener >& xListener )
     696             :         throw ( uno::RuntimeException, std::exception )
     697             : {
     698          95 :     ::osl::MutexGuard aGuard( m_aMutex );
     699          95 :     if ( m_bDisposed )
     700          95 :         return;
     701             : 
     702          95 :     if ( !m_pInterfaceContainer )
     703           0 :         m_pInterfaceContainer = new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex );
     704             : 
     705          95 :     m_pInterfaceContainer->addInterface( cppu::UnoType<document::XEventListener>::get(), xListener );
     706             : }
     707             : 
     708             : 
     709          95 : void SAL_CALL ODummyEmbeddedObject::removeEventListener( const uno::Reference< document::XEventListener >& xListener )
     710             :         throw ( uno::RuntimeException, std::exception )
     711             : {
     712          95 :     ::osl::MutexGuard aGuard( m_aMutex );
     713          95 :     if ( m_pInterfaceContainer )
     714          95 :         m_pInterfaceContainer->removeInterface( cppu::UnoType<document::XEventListener>::get(),
     715         190 :                                                 xListener );
     716          95 : }
     717             : 
     718             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11