LCOV - code coverage report
Current view: top level - embeddedobj/source/general - dummyobject.cxx (source / functions) Hit Total Coverage
Test: commit e02a6cb2c3e2b23b203b422e4e0680877f232636 Lines: 0 276 0.0 %
Date: 2014-04-14 Functions: 0 40 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 <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           0 : void ODummyEmbeddedObject::CheckInit_WrongState()
      42             : {
      43           0 :     if ( m_bDisposed )
      44           0 :         throw lang::DisposedException();
      45             : 
      46           0 :     if ( m_nObjectState == -1 )
      47             :         throw embed::WrongStateException( OUString( "The object has no persistence!\n" ),
      48           0 :                                         uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
      49           0 : }
      50             : 
      51           0 : void ODummyEmbeddedObject::CheckInit_Runtime()
      52             : {
      53           0 :     if ( m_bDisposed )
      54           0 :         throw lang::DisposedException();
      55             : 
      56           0 :     if ( m_nObjectState == -1 )
      57             :         throw uno::RuntimeException( OUString( "The object has no persistence!\n" ),
      58           0 :                                         uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
      59           0 : }
      60           0 : void ODummyEmbeddedObject::PostEvent_Impl( const OUString& aEventName )
      61             : {
      62           0 :     if ( m_pInterfaceContainer )
      63             :     {
      64             :         ::cppu::OInterfaceContainerHelper* pIC = m_pInterfaceContainer->getContainer(
      65           0 :                                             ::getCppuType((const uno::Reference< document::XEventListener >*)0) );
      66           0 :         if( pIC )
      67             :         {
      68           0 :             document::EventObject aEvent;
      69           0 :             aEvent.EventName = aEventName;
      70           0 :             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           0 :             ::cppu::OInterfaceIteratorHelper aIt( *pIC );
      75           0 :             while( aIt.hasMoreElements() )
      76             :             {
      77             :                 try
      78             :                 {
      79           0 :                     ((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           0 :                 if ( m_bDisposed )
      88           0 :                     return;
      89           0 :             }
      90             :         }
      91             :     }
      92             : }
      93             : 
      94             : 
      95           0 : ODummyEmbeddedObject::~ODummyEmbeddedObject()
      96             : {
      97           0 : }
      98             : 
      99             : 
     100           0 : 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           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     107           0 :     CheckInit_WrongState();
     108             : 
     109           0 :     if ( nNewState == embed::EmbedStates::LOADED )
     110           0 :         return;
     111             : 
     112           0 :     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           0 : sal_Int32 SAL_CALL ODummyEmbeddedObject::getCurrentState()
     131             :         throw ( embed::WrongStateException,
     132             :                 uno::RuntimeException, std::exception )
     133             : {
     134           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     135           0 :     CheckInit_WrongState();
     136             : 
     137           0 :     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           0 : void SAL_CALL ODummyEmbeddedObject::setClientSite(
     167             :                 const uno::Reference< embed::XEmbeddedClient >& xClient )
     168             :         throw ( embed::WrongStateException,
     169             :                 uno::RuntimeException, std::exception )
     170             : {
     171           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     172           0 :     CheckInit_WrongState();
     173             : 
     174           0 :     m_xClientSite = xClient;
     175           0 : }
     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           0 : sal_Int64 SAL_CALL ODummyEmbeddedObject::getStatus( sal_Int64 )
     209             :         throw ( embed::WrongStateException,
     210             :                 uno::RuntimeException, std::exception )
     211             : {
     212           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     213           0 :     CheckInit_WrongState();
     214             : 
     215           0 :     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           0 : 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           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     234           0 :     CheckInit_WrongState();
     235             : 
     236             :     OSL_ENSURE( nAspect != embed::Aspects::MSOLE_ICON, "For iconified objects no graphical replacement is required!\n" );
     237           0 :     if ( nAspect == embed::Aspects::MSOLE_ICON )
     238             :         // no representation can be retrieved
     239             :         throw embed::WrongStateException( OUString( "Illegal call!\n" ),
     240           0 :                                     uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
     241             : 
     242           0 :     m_nCachedAspect = nAspect;
     243           0 :     m_aCachedSize = aSize;
     244           0 :     m_bHasCachedSize = sal_True;
     245           0 : }
     246             : 
     247             : 
     248           0 : 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           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     255           0 :     CheckInit_WrongState();
     256             : 
     257             :     OSL_ENSURE( nAspect != embed::Aspects::MSOLE_ICON, "For iconified objects no graphical replacement is required!\n" );
     258           0 :     if ( nAspect == embed::Aspects::MSOLE_ICON )
     259             :         // no representation can be retrieved
     260             :         throw embed::WrongStateException( OUString( "Illegal call!\n" ),
     261           0 :                                     uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
     262             : 
     263           0 :     if ( !m_bHasCachedSize || m_nCachedAspect != nAspect )
     264             :         throw embed::NoVisualAreaSizeException(
     265             :                 OUString( "No size available!\n" ),
     266           0 :                 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
     267             : 
     268           0 :     return m_aCachedSize;
     269             : }
     270             : 
     271             : 
     272           0 : sal_Int32 SAL_CALL ODummyEmbeddedObject::getMapUnit( sal_Int64 nAspect )
     273             :         throw ( uno::Exception,
     274             :                 uno::RuntimeException, std::exception)
     275             : {
     276           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     277           0 :     CheckInit_Runtime();
     278             : 
     279             :     OSL_ENSURE( nAspect != embed::Aspects::MSOLE_ICON, "For iconified objects no graphical replacement is required!\n" );
     280           0 :     if ( nAspect == embed::Aspects::MSOLE_ICON )
     281             :         // no representation can be retrieved
     282             :         throw embed::WrongStateException( OUString( "Illegal call!\n" ),
     283           0 :                                     uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
     284             : 
     285           0 :     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( OUString( "Illegal call!\n" ),
     300           0 :                                 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
     301             : }
     302             : 
     303             : 
     304           0 : 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           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     317           0 :     if ( m_bDisposed )
     318           0 :         throw lang::DisposedException(); // TODO
     319             : 
     320           0 :     if ( !xStorage.is() )
     321             :         throw lang::IllegalArgumentException( OUString( "No parent storage is provided!\n" ),
     322             :                                             uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
     323           0 :                                             1 );
     324             : 
     325           0 :     if ( sEntName.isEmpty() )
     326             :         throw lang::IllegalArgumentException( OUString( "Empty element name is provided!\n" ),
     327             :                                             uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
     328           0 :                                             2 );
     329             : 
     330           0 :     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             :                     OUString( "Can't change persistent representation of activated object!\n" ),
     335           0 :                     uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
     336             :     }
     337             : 
     338           0 :     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             :                         OUString( "The object waits for saveCompleted() call!\n" ),
     345           0 :                         uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
     346             :     }
     347             : 
     348           0 :     if ( nEntryConnectionMode == embed::EntryInitModes::DEFAULT_INIT
     349           0 :       || nEntryConnectionMode == embed::EntryInitModes::NO_INIT )
     350             :     {
     351           0 :         if ( xStorage->hasByName( sEntName ) )
     352             : 
     353             :         {
     354           0 :             m_xParentStorage = xStorage;
     355           0 :             m_aEntryName = sEntName;
     356           0 :             m_nObjectState = embed::EmbedStates::LOADED;
     357             :         }
     358             :         else
     359             :             throw lang::IllegalArgumentException( OUString( "Wrong entry is provided!\n" ),
     360             :                                 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
     361           0 :                                 2 );
     362             : 
     363             :     }
     364             :     else
     365             :         throw lang::IllegalArgumentException( OUString( "Wrong connection mode is provided!\n" ),
     366             :                                 uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ),
     367           0 :                                 3 );
     368           0 : }
     369             : 
     370             : 
     371           0 : 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           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     382           0 :     CheckInit_WrongState();
     383             : 
     384           0 :     if ( m_bWaitSaveCompleted )
     385             :         throw embed::WrongStateException(
     386             :                     OUString( "The object waits for saveCompleted() call!\n" ),
     387           0 :                     uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
     388             : 
     389           0 :     m_xParentStorage->copyElementTo( m_aEntryName, xStorage, sEntName );
     390           0 : }
     391             : 
     392             : 
     393           0 : 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           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     404           0 :     CheckInit_WrongState();
     405             : 
     406           0 :     if ( m_bWaitSaveCompleted )
     407             :         throw embed::WrongStateException(
     408             :                     OUString( "The object waits for saveCompleted() call!\n" ),
     409           0 :                     uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
     410             : 
     411           0 :     PostEvent_Impl( OUString( "OnSaveAs" ) );
     412             : 
     413           0 :     m_xParentStorage->copyElementTo( m_aEntryName, xStorage, sEntName );
     414             : 
     415           0 :     m_bWaitSaveCompleted = sal_True;
     416           0 :     m_xNewParentStorage = xStorage;
     417           0 :     m_aNewEntryName = sEntName;
     418           0 : }
     419             : 
     420             : 
     421           0 : void SAL_CALL ODummyEmbeddedObject::saveCompleted( sal_Bool bUseNew )
     422             :         throw ( embed::WrongStateException,
     423             :                 uno::Exception,
     424             :                 uno::RuntimeException, std::exception )
     425             : {
     426           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     427           0 :     CheckInit_WrongState();
     428             : 
     429             :     // it is allowed to call saveCompleted( false ) for nonstored objects
     430           0 :     if ( !m_bWaitSaveCompleted && !bUseNew )
     431           0 :         return;
     432             : 
     433             :     OSL_ENSURE( m_bWaitSaveCompleted, "Unexpected saveCompleted() call!\n" );
     434           0 :     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           0 :     if ( !m_xNewParentStorage.is() )
     439           0 :         throw uno::RuntimeException(); // TODO: broken internal information
     440             : 
     441           0 :     if ( bUseNew )
     442             :     {
     443           0 :         m_xParentStorage = m_xNewParentStorage;
     444           0 :         m_aEntryName = m_aNewEntryName;
     445             : 
     446           0 :         PostEvent_Impl( OUString( "OnSaveAsDone" ) );
     447             :     }
     448             : 
     449           0 :     m_xNewParentStorage = uno::Reference< embed::XStorage >();
     450           0 :     m_aNewEntryName = OUString();
     451           0 :     m_bWaitSaveCompleted = sal_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             :                     OUString( "The object waits for saveCompleted() call!\n" ),
     465           0 :                     uno::Reference< uno::XInterface >( 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           0 : OUString SAL_CALL ODummyEmbeddedObject::getEntryName()
     475             :         throw ( embed::WrongStateException,
     476             :                 uno::RuntimeException, std::exception )
     477             : {
     478           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     479           0 :     CheckInit_WrongState();
     480             : 
     481           0 :     if ( m_bWaitSaveCompleted )
     482             :         throw embed::WrongStateException(
     483             :                     OUString( "The object waits for saveCompleted() call!\n" ),
     484           0 :                     uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
     485             : 
     486           0 :     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             :                     OUString( "The object waits for saveCompleted() call!\n" ),
     502           0 :                     uno::Reference< uno::XInterface >( 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             :                     OUString( "The object waits for saveCompleted() call!\n" ),
     519           0 :                     uno::Reference< uno::XInterface >( 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             :                     OUString( "The object waits for saveCompleted() call!\n" ),
     541           0 :                     uno::Reference< uno::XInterface >( static_cast< ::cppu::OWeakObject* >(this) ) );
     542             : 
     543             :     // nothing to reload
     544           0 : }
     545             : 
     546             : 
     547           0 : uno::Sequence< sal_Int8 > SAL_CALL ODummyEmbeddedObject::getClassID()
     548             :         throw ( uno::RuntimeException, std::exception )
     549             : {
     550           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     551           0 :     CheckInit_Runtime();
     552             : 
     553             :     // currently the class ID is empty
     554             :     // TODO/LATER: should a special class ID be used in this case?
     555           0 :     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           0 : uno::Reference< util::XCloseable > SAL_CALL ODummyEmbeddedObject::getComponent()
     580             :         throw ( uno::RuntimeException, std::exception )
     581             : {
     582           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     583           0 :     CheckInit_Runtime();
     584             : 
     585           0 :     return uno::Reference< util::XCloseable >();
     586             : }
     587             : 
     588             : 
     589           0 : void SAL_CALL ODummyEmbeddedObject::addStateChangeListener( const uno::Reference< embed::XStateChangeListener >& xListener )
     590             :     throw ( uno::RuntimeException, std::exception )
     591             : {
     592           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     593           0 :     if ( m_bDisposed )
     594           0 :         return;
     595             : 
     596           0 :     if ( !m_pInterfaceContainer )
     597           0 :         m_pInterfaceContainer = new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex );
     598             : 
     599           0 :     m_pInterfaceContainer->addInterface( ::getCppuType( (const uno::Reference< embed::XStateChangeListener >*)0 ),
     600           0 :                                                         xListener );
     601             : }
     602             : 
     603             : 
     604           0 : void SAL_CALL ODummyEmbeddedObject::removeStateChangeListener(
     605             :                     const uno::Reference< embed::XStateChangeListener >& xListener )
     606             :     throw (uno::RuntimeException, std::exception)
     607             : {
     608           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     609           0 :     if ( m_pInterfaceContainer )
     610           0 :         m_pInterfaceContainer->removeInterface( ::getCppuType( (const uno::Reference< embed::XStateChangeListener >*)0 ),
     611           0 :                                                 xListener );
     612           0 : }
     613             : 
     614             : 
     615           0 : void SAL_CALL ODummyEmbeddedObject::close( sal_Bool bDeliverOwnership )
     616             :     throw ( util::CloseVetoException,
     617             :             uno::RuntimeException, std::exception )
     618             : {
     619           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     620           0 :     if ( m_bDisposed )
     621           0 :         throw lang::DisposedException(); // TODO
     622             : 
     623           0 :     uno::Reference< uno::XInterface > xSelfHold( static_cast< ::cppu::OWeakObject* >( this ) );
     624           0 :     lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >( this ) );
     625             : 
     626           0 :     if ( m_pInterfaceContainer )
     627             :     {
     628             :         ::cppu::OInterfaceContainerHelper* pContainer =
     629           0 :             m_pInterfaceContainer->getContainer( ::getCppuType( ( const uno::Reference< util::XCloseListener >*) NULL ) );
     630           0 :         if ( pContainer != NULL )
     631             :         {
     632           0 :             ::cppu::OInterfaceIteratorHelper pIterator(*pContainer);
     633           0 :             while (pIterator.hasMoreElements())
     634             :             {
     635             :                 try
     636             :                 {
     637           0 :                     ((util::XCloseListener*)pIterator.next())->queryClosing( aSource, bDeliverOwnership );
     638             :                 }
     639           0 :                 catch( const uno::RuntimeException& )
     640             :                 {
     641           0 :                     pIterator.remove();
     642             :                 }
     643           0 :             }
     644             :         }
     645             : 
     646             :         pContainer = m_pInterfaceContainer->getContainer(
     647           0 :                                     ::getCppuType( ( const uno::Reference< util::XCloseListener >*) NULL ) );
     648           0 :         if ( pContainer != NULL )
     649             :         {
     650           0 :             ::cppu::OInterfaceIteratorHelper pCloseIterator(*pContainer);
     651           0 :             while (pCloseIterator.hasMoreElements())
     652             :             {
     653             :                 try
     654             :                 {
     655           0 :                     ((util::XCloseListener*)pCloseIterator.next())->notifyClosing( aSource );
     656             :                 }
     657           0 :                 catch( const uno::RuntimeException& )
     658             :                 {
     659           0 :                     pCloseIterator.remove();
     660             :                 }
     661           0 :             }
     662             :         }
     663             : 
     664           0 :         m_pInterfaceContainer->disposeAndClear( aSource );
     665             :     }
     666             : 
     667           0 :     m_bDisposed = sal_True; // the object is disposed now for outside
     668           0 : }
     669             : 
     670             : 
     671           0 : void SAL_CALL ODummyEmbeddedObject::addCloseListener( const uno::Reference< util::XCloseListener >& xListener )
     672             :     throw ( uno::RuntimeException, std::exception )
     673             : {
     674           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     675           0 :     if ( m_bDisposed )
     676           0 :         return;
     677             : 
     678           0 :     if ( !m_pInterfaceContainer )
     679           0 :         m_pInterfaceContainer = new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex );
     680             : 
     681           0 :     m_pInterfaceContainer->addInterface( ::getCppuType( (const uno::Reference< util::XCloseListener >*)0 ), xListener );
     682             : }
     683             : 
     684             : 
     685           0 : void SAL_CALL ODummyEmbeddedObject::removeCloseListener( const uno::Reference< util::XCloseListener >& xListener )
     686             :     throw (uno::RuntimeException, std::exception)
     687             : {
     688           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     689           0 :     if ( m_pInterfaceContainer )
     690           0 :         m_pInterfaceContainer->removeInterface( ::getCppuType( (const uno::Reference< util::XCloseListener >*)0 ),
     691           0 :                                                 xListener );
     692           0 : }
     693             : 
     694             : 
     695           0 : void SAL_CALL ODummyEmbeddedObject::addEventListener( const uno::Reference< document::XEventListener >& xListener )
     696             :         throw ( uno::RuntimeException, std::exception )
     697             : {
     698           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     699           0 :     if ( m_bDisposed )
     700           0 :         return;
     701             : 
     702           0 :     if ( !m_pInterfaceContainer )
     703           0 :         m_pInterfaceContainer = new ::cppu::OMultiTypeInterfaceContainerHelper( m_aMutex );
     704             : 
     705           0 :     m_pInterfaceContainer->addInterface( ::getCppuType( (const uno::Reference< document::XEventListener >*)0 ), xListener );
     706             : }
     707             : 
     708             : 
     709           0 : void SAL_CALL ODummyEmbeddedObject::removeEventListener( const uno::Reference< document::XEventListener >& xListener )
     710             :         throw ( uno::RuntimeException, std::exception )
     711             : {
     712           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     713           0 :     if ( m_pInterfaceContainer )
     714           0 :         m_pInterfaceContainer->removeInterface( ::getCppuType( (const uno::Reference< document::XEventListener >*)0 ),
     715           0 :                                                 xListener );
     716           0 : }
     717             : 
     718             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10