LCOV - code coverage report
Current view: top level - embeddedobj/source/general - dummyobject.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 110 268 41.0 %
Date: 2012-08-25 Functions: 17 39 43.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 102 580 17.6 %

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

Generated by: LCOV version 1.10