LCOV - code coverage report
Current view: top level - embeddedobj/source/commonembedding - embedobj.cxx (source / functions) Hit Total Coverage
Test: commit c8344322a7af75b84dd3ca8f78b05543a976dfd5 Lines: 203 285 71.2 %
Date: 2015-06-13 12:38:46 Functions: 15 20 75.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             : 
      29             : #include <com/sun/star/awt/XWindowPeer.hpp>
      30             : #include <com/sun/star/util/XCloseBroadcaster.hpp>
      31             : #include <com/sun/star/util/XCloseable.hpp>
      32             : #include <com/sun/star/util/XModifiable.hpp>
      33             : #include <com/sun/star/frame/XFrame.hpp>
      34             : #include <com/sun/star/frame/XComponentLoader.hpp>
      35             : #include <com/sun/star/frame/XDispatchProviderInterception.hpp>
      36             : #include <com/sun/star/frame/ModuleManager.hpp>
      37             : #include <com/sun/star/lang/DisposedException.hpp>
      38             : 
      39             : #include <com/sun/star/embed/EmbedMisc.hpp>
      40             : #include <comphelper/processfactory.hxx>
      41             : 
      42             : #include <vcl/svapp.hxx>
      43             : 
      44             : #include <targetstatecontrol.hxx>
      45             : 
      46             : #include "commonembobj.hxx"
      47             : #include "intercept.hxx"
      48             : #include "embedobj.hxx"
      49             : 
      50             : using namespace ::com::sun::star;
      51             : 
      52           3 : awt::Rectangle GetRectangleInterception( const awt::Rectangle& aRect1, const awt::Rectangle& aRect2 )
      53             : {
      54           3 :     awt::Rectangle aResult;
      55             : 
      56             :     OSL_ENSURE( aRect1.Width >= 0 && aRect2.Width >= 0 && aRect1.Height >= 0 && aRect2.Height >= 0,
      57             :                 "Offset must not be less then zero!" );
      58             : 
      59           3 :     aResult.X = aRect1.X > aRect2.X ? aRect1.X : aRect2.X;
      60           3 :     aResult.Y = aRect1.Y > aRect2.Y ? aRect1.Y : aRect2.Y;
      61             : 
      62           3 :     sal_Int32 nRight1 = aRect1.X + aRect1.Width;
      63           3 :     sal_Int32 nBottom1 = aRect1.Y + aRect1.Height;
      64           3 :     sal_Int32 nRight2 = aRect2.X + aRect2.Width;
      65           3 :     sal_Int32 nBottom2 = aRect2.Y + aRect2.Height;
      66           3 :     aResult.Width = ( nRight1 < nRight2 ? nRight1 : nRight2 ) - aResult.X;
      67           3 :     aResult.Height = ( nBottom1 < nBottom2 ? nBottom1 : nBottom2 ) - aResult.Y;
      68             : 
      69           3 :     return aResult;
      70             : }
      71             : 
      72             : 
      73           1 : sal_Int32 OCommonEmbeddedObject::ConvertVerbToState_Impl( sal_Int32 nVerb )
      74             : {
      75           2 :     for ( sal_Int32 nInd = 0; nInd < m_aVerbTable.getLength(); nInd++ )
      76           2 :         if ( m_aVerbTable[nInd][0] == nVerb )
      77           2 :             return m_aVerbTable[nInd][1];
      78             : 
      79           0 :     throw lang::IllegalArgumentException(); // TODO: unexpected verb provided
      80             : }
      81             : 
      82             : 
      83           1 : void OCommonEmbeddedObject::Deactivate()
      84             : {
      85           1 :     uno::Reference< util::XModifiable > xModif( m_pDocHolder->GetComponent(), uno::UNO_QUERY );
      86             : 
      87             :     // no need to lock for the initialization
      88           2 :     uno::Reference< embed::XEmbeddedClient > xClientSite = m_xClientSite;
      89           1 :     if ( !xClientSite.is() )
      90           0 :         throw embed::WrongStateException(); //TODO: client site is not set!
      91             : 
      92             :     // store document if it is modified
      93           1 :     if ( xModif.is() && xModif->isModified() )
      94             :     {
      95             :         try {
      96           1 :             xClientSite->saveObject();
      97             :         }
      98           0 :         catch( const embed::ObjectSaveVetoException& )
      99             :         {
     100             :         }
     101           0 :         catch( const uno::Exception& e )
     102             :         {
     103             :             throw embed::StorageWrappedTargetException(
     104             :                 "The client could not store the object!",
     105             :                 static_cast< ::cppu::OWeakObject* >( this ),
     106           0 :                 uno::makeAny( e ) );
     107             :         }
     108             :     }
     109             : 
     110           1 :     m_pDocHolder->CloseFrame();
     111             : 
     112           2 :     xClientSite->visibilityChanged( sal_False );
     113           1 : }
     114             : 
     115             : 
     116        1346 : void OCommonEmbeddedObject::StateChangeNotification_Impl( bool bBeforeChange, sal_Int32 nOldState, sal_Int32 nNewState ,::osl::ResettableMutexGuard& rGuard )
     117             : {
     118        1346 :     if ( m_pInterfaceContainer )
     119             :     {
     120             :         ::cppu::OInterfaceContainerHelper* pContainer = m_pInterfaceContainer->getContainer(
     121        1344 :                             cppu::UnoType<embed::XStateChangeListener>::get());
     122        1344 :         if ( pContainer != NULL )
     123             :         {
     124        1344 :             lang::EventObject aSource( static_cast< ::cppu::OWeakObject* >( this ) );
     125        2688 :             ::cppu::OInterfaceIteratorHelper pIterator(*pContainer);
     126             : 
     127             :             // should be locked after the method is finished successfully
     128        1344 :             rGuard.clear();
     129             : 
     130        3757 :             while (pIterator.hasMoreElements())
     131             :             {
     132             :                 try
     133             :                 {
     134        1069 :                     if ( bBeforeChange )
     135         541 :                         static_cast<embed::XStateChangeListener*>(pIterator.next())->changingState( aSource, nOldState, nNewState );
     136             :                     else
     137         528 :                         static_cast<embed::XStateChangeListener*>(pIterator.next())->stateChanged( aSource, nOldState, nNewState );
     138             :                 }
     139           0 :                 catch( const uno::Exception& )
     140             :                 {
     141             :                     // even if the listener complains ignore it for now
     142             :                    }
     143             : 
     144        1069 :                 if ( m_bDisposed )
     145        1346 :                     return;
     146             :             }
     147             : 
     148        2688 :             rGuard.reset();
     149             :         }
     150             :     }
     151             : }
     152             : 
     153             : 
     154         682 : void OCommonEmbeddedObject::SwitchStateTo_Impl( sal_Int32 nNextState )
     155             : {
     156             :     // TODO: may be needs interaction handler to detect wherether the object state
     157             :     //         can be changed even after errors
     158             : 
     159         682 :     if ( m_nObjectState == embed::EmbedStates::LOADED )
     160             :     {
     161          99 :         if ( nNextState == embed::EmbedStates::RUNNING )
     162             :         {
     163             :             // after the object reaches the running state the cloned size is not necessary any more
     164          99 :             m_bHasClonedSize = false;
     165             : 
     166          99 :             if ( m_bIsLink )
     167             :             {
     168           0 :                 m_pDocHolder->SetComponent( LoadLink_Impl(), m_bReadOnly );
     169             :             }
     170             :             else
     171             :             {
     172          99 :                 uno::Reference < embed::XEmbedPersist > xPersist( static_cast < embed::XClassifiedObject* > (this), uno::UNO_QUERY );
     173          99 :                 if ( xPersist.is() )
     174             :                 {
     175             :                     // in case embedded object is in loaded state the contents must
     176             :                     // be stored in the related storage and the storage
     177             :                     // must be created already
     178          87 :                     if ( !m_xObjectStorage.is() )
     179           0 :                         throw io::IOException(); //TODO: access denied
     180             : 
     181          87 :                     m_pDocHolder->SetComponent( LoadDocumentFromStorage_Impl(), m_bReadOnly );
     182             :                 }
     183             :                 else
     184             :                 {
     185             :                     // objects without persistence will be initialized internally
     186          12 :                     uno::Sequence < uno::Any > aArgs(1);
     187          12 :                     aArgs[0] <<= uno::Reference < embed::XEmbeddedObject >( this );
     188             :                     uno::Reference< util::XCloseable > xDocument(
     189          24 :                             m_xContext->getServiceManager()->createInstanceWithArgumentsAndContext( GetDocumentServiceName(), aArgs, m_xContext),
     190          24 :                             uno::UNO_QUERY );
     191             : 
     192          24 :                     uno::Reference < container::XChild > xChild( xDocument, uno::UNO_QUERY );
     193          12 :                     if ( xChild.is() )
     194           0 :                         xChild->setParent( m_xParent );
     195             : 
     196          24 :                     m_pDocHolder->SetComponent( xDocument, m_bReadOnly );
     197          99 :                 }
     198             :             }
     199             : 
     200          96 :             if ( !m_pDocHolder->GetComponent().is() )
     201          11 :                 throw embed::UnreachableStateException(); //TODO: can't open document
     202             : 
     203          85 :             m_nObjectState = nNextState;
     204             :         }
     205             :         else
     206             :         {
     207             :             SAL_WARN( "embeddedobj.common", "Unacceptable state switch!" );
     208           0 :             throw uno::RuntimeException(); // TODO
     209             :         }
     210             :     }
     211         583 :     else if ( m_nObjectState == embed::EmbedStates::RUNNING )
     212             :     {
     213         580 :         if ( nNextState == embed::EmbedStates::LOADED )
     214             :         {
     215         579 :             m_nClonedMapUnit = m_pDocHolder->GetMapUnit( embed::Aspects::MSOLE_CONTENT );
     216         579 :             m_bHasClonedSize = m_pDocHolder->GetExtent( embed::Aspects::MSOLE_CONTENT, &m_aClonedSize );
     217             : 
     218             :             // actually frame should not exist at this point
     219         579 :             m_pDocHolder->CloseDocument( false, false );
     220             : 
     221         579 :             m_nObjectState = nNextState;
     222             :         }
     223             :         else
     224             :         {
     225           1 :             if ( nNextState == embed::EmbedStates::INPLACE_ACTIVE )
     226             :             {
     227           1 :                 if ( !m_xClientSite.is() )
     228           0 :                     throw embed::WrongStateException( "client site not set, yet", *this );
     229             : 
     230           1 :                 uno::Reference< embed::XInplaceClient > xInplaceClient( m_xClientSite, uno::UNO_QUERY );
     231           1 :                 if ( xInplaceClient.is() && xInplaceClient->canInplaceActivate() )
     232             :                 {
     233           1 :                     xInplaceClient->activatingInplace();
     234             : 
     235           1 :                     uno::Reference< embed::XWindowSupplier > xClientWindowSupplier( xInplaceClient, uno::UNO_QUERY );
     236           1 :                     if ( !xClientWindowSupplier.is() )
     237           0 :                         throw uno::RuntimeException(); // TODO: the inplace client implementation must support XWinSupp
     238             : 
     239           1 :                     m_xClientWindow = xClientWindowSupplier->getWindow();
     240           1 :                     m_aOwnRectangle = xInplaceClient->getPlacement();
     241           1 :                     m_aClipRectangle = xInplaceClient->getClipRectangle();
     242           1 :                     awt::Rectangle aRectangleToShow = GetRectangleInterception( m_aOwnRectangle, m_aClipRectangle );
     243             : 
     244             :                     // create own window based on the client window
     245             :                     // place and resize the window according to the rectangles
     246           2 :                     uno::Reference< awt::XWindowPeer > xClientWindowPeer( m_xClientWindow, uno::UNO_QUERY );
     247           1 :                     if ( !xClientWindowPeer.is() )
     248           0 :                         throw uno::RuntimeException(); // TODO: the container window must support the interface
     249             : 
     250             :                     // dispatch provider may not be provided
     251           2 :                     uno::Reference< frame::XDispatchProvider > xContainerDP = xInplaceClient->getInplaceDispatchProvider();
     252           1 :                     bool bOk = m_pDocHolder->ShowInplace( xClientWindowPeer, aRectangleToShow, xContainerDP );
     253           1 :                     m_nObjectState = nNextState;
     254           1 :                     if ( !bOk )
     255             :                     {
     256           0 :                         SwitchStateTo_Impl( embed::EmbedStates::RUNNING );
     257           0 :                         throw embed::WrongStateException(); //TODO: can't activate inplace
     258           1 :                     }
     259             :                 }
     260             :                 else
     261           0 :                     throw embed::WrongStateException(); //TODO: can't activate inplace
     262             :             }
     263           0 :             else if ( nNextState == embed::EmbedStates::ACTIVE )
     264             :             {
     265           0 :                 if ( !m_xClientSite.is() )
     266           0 :                     throw embed::WrongStateException(); //TODO: client site is not set!
     267             : 
     268             :                 // create frame and load document in the frame
     269           0 :                 m_pDocHolder->Show();
     270             : 
     271           0 :                 m_xClientSite->visibilityChanged( sal_True );
     272           0 :                 m_nObjectState = nNextState;
     273             :             }
     274             :             else
     275             :             {
     276             :                 SAL_WARN( "embeddedobj.common", "Unacceptable state switch!" );
     277           0 :                 throw uno::RuntimeException(); // TODO
     278             :             }
     279             :         }
     280             :     }
     281           3 :     else if ( m_nObjectState == embed::EmbedStates::INPLACE_ACTIVE )
     282             :     {
     283           2 :         if ( nNextState == embed::EmbedStates::RUNNING )
     284             :         {
     285           1 :             uno::Reference< embed::XInplaceClient > xInplaceClient( m_xClientSite, uno::UNO_QUERY );
     286           1 :             if ( !xInplaceClient.is() )
     287           0 :                 throw uno::RuntimeException();
     288             : 
     289           1 :             m_xClientSite->visibilityChanged( sal_True );
     290             : 
     291           1 :             xInplaceClient->deactivatedInplace();
     292           1 :             Deactivate();
     293           1 :             m_nObjectState = nNextState;
     294             :         }
     295           1 :         else if ( nNextState == embed::EmbedStates::UI_ACTIVE )
     296             :         {
     297           1 :             if ( !(m_nMiscStatus & embed::EmbedMisc::MS_EMBED_NOUIACTIVATE) )
     298             :             {
     299           1 :                 uno::Reference< embed::XInplaceClient > xInplaceClient( m_xClientSite, uno::UNO_QUERY_THROW );
     300             :                 // TODO:
     301             :                 uno::Reference< ::com::sun::star::frame::XLayoutManager > xContainerLM =
     302           2 :                             xInplaceClient->getLayoutManager();
     303           1 :                 if ( xContainerLM.is() )
     304             :                 {
     305             :                     // dispatch provider may not be provided
     306           1 :                     uno::Reference< frame::XDispatchProvider > xContainerDP = xInplaceClient->getInplaceDispatchProvider();
     307             : 
     308             :                     // get the container module name
     309           2 :                     OUString aModuleName;
     310             :                     try
     311             :                     {
     312           1 :                         uno::Reference< embed::XComponentSupplier > xCompSupl( m_xClientSite, uno::UNO_QUERY_THROW );
     313           2 :                         uno::Reference< uno::XInterface > xContDoc( xCompSupl->getComponent(), uno::UNO_QUERY_THROW );
     314             : 
     315           2 :                         uno::Reference< frame::XModuleManager2 > xManager( frame::ModuleManager::create( m_xContext ) );
     316             : 
     317           2 :                         aModuleName = xManager->identify( xContDoc );
     318             :                     }
     319           0 :                     catch( const uno::Exception& )
     320             :                     {}
     321             : 
     322             :                     // if currently another object is UIactive it will be deactivated; usually this will activate the LM of
     323             :                     // the container. Locking the LM will prevent flicker.
     324           1 :                     xContainerLM->lock();
     325           1 :                     xInplaceClient->activatingUI();
     326           1 :                     bool bOk = m_pDocHolder->ShowUI( xContainerLM, xContainerDP, aModuleName );
     327           1 :                     xContainerLM->unlock();
     328             : 
     329           1 :                     if ( bOk )
     330             :                     {
     331           1 :                         m_nObjectState = nNextState;
     332           1 :                         m_pDocHolder->ResizeHatchWindow();
     333             :                     }
     334             :                     else
     335             :                     {
     336           0 :                         xInplaceClient->deactivatedUI();
     337           0 :                         throw embed::WrongStateException(); //TODO: can't activate UI
     338           1 :                     }
     339             :                 }
     340             :                 else
     341           1 :                     throw embed::WrongStateException(); //TODO: can't activate UI
     342             :             }
     343             :         }
     344             :         else
     345             :         {
     346             :             SAL_WARN( "embeddedobj.common", "Unacceptable state switch!" );
     347           0 :             throw uno::RuntimeException(); // TODO
     348             :         }
     349             :     }
     350           1 :     else if ( m_nObjectState == embed::EmbedStates::ACTIVE )
     351             :     {
     352           0 :         if ( nNextState == embed::EmbedStates::RUNNING )
     353             :         {
     354           0 :             Deactivate();
     355           0 :             m_nObjectState = nNextState;
     356             :         }
     357             :         else
     358             :         {
     359             :             SAL_WARN( "embeddedobj.common", "Unacceptable state switch!" );
     360           0 :             throw uno::RuntimeException(); // TODO
     361             :         }
     362             :     }
     363           1 :     else if ( m_nObjectState == embed::EmbedStates::UI_ACTIVE )
     364             :     {
     365           1 :         if ( nNextState == embed::EmbedStates::INPLACE_ACTIVE )
     366             :         {
     367           1 :             uno::Reference< embed::XInplaceClient > xInplaceClient( m_xClientSite, uno::UNO_QUERY_THROW );
     368             :             uno::Reference< ::com::sun::star::frame::XLayoutManager > xContainerLM =
     369           2 :                         xInplaceClient->getLayoutManager();
     370             : 
     371           1 :             bool bOk = false;
     372           1 :             if ( xContainerLM.is() )
     373           1 :                    bOk = m_pDocHolder->HideUI( xContainerLM );
     374             : 
     375           1 :             if ( bOk )
     376             :             {
     377           1 :                 m_nObjectState = nNextState;
     378           1 :                 m_pDocHolder->ResizeHatchWindow();
     379           1 :                    xInplaceClient->deactivatedUI();
     380             :             }
     381             :             else
     382           1 :                 throw embed::WrongStateException(); //TODO: can't activate UI
     383             :         }
     384             :     }
     385             :     else
     386             :         throw embed::WrongStateException( "The object is in unacceptable state!",
     387           0 :                                           static_cast< ::cppu::OWeakObject* >(this) );
     388         668 : }
     389             : 
     390             : 
     391         680 : uno::Sequence< sal_Int32 > OCommonEmbeddedObject::GetIntermediateStatesSequence_Impl( sal_Int32 nNewState )
     392             : {
     393         680 :     sal_Int32 nCurInd = 0;
     394        1263 :     for ( nCurInd = 0; nCurInd < m_aAcceptedStates.getLength(); nCurInd++ )
     395        1263 :         if ( m_aAcceptedStates[nCurInd] == m_nObjectState )
     396         680 :             break;
     397             : 
     398         680 :     if ( nCurInd == m_aAcceptedStates.getLength() )
     399             :         throw embed::WrongStateException( "The object is in unacceptable state!",
     400           0 :                                           static_cast< ::cppu::OWeakObject* >(this) );
     401             : 
     402         680 :     sal_Int32 nDestInd = 0;
     403         783 :     for ( nDestInd = 0; nDestInd < m_aAcceptedStates.getLength(); nDestInd++ )
     404         783 :         if ( m_aAcceptedStates[nDestInd] == nNewState )
     405         680 :             break;
     406             : 
     407         680 :     if ( nDestInd == m_aAcceptedStates.getLength() )
     408             :         throw embed::UnreachableStateException(
     409             :             "The state either not reachable, or the object allows the state only as an intermediate one!",
     410             :             static_cast< ::cppu::OWeakObject* >(this),
     411             :             m_nObjectState,
     412           0 :             nNewState );
     413             : 
     414         680 :     return m_pIntermediateStatesSeqs[nCurInd][nDestInd];
     415             : }
     416             : 
     417             : 
     418         836 : void SAL_CALL OCommonEmbeddedObject::changeState( sal_Int32 nNewState )
     419             :         throw ( embed::UnreachableStateException,
     420             :                 embed::WrongStateException,
     421             :                 uno::Exception,
     422             :                 uno::RuntimeException, std::exception )
     423             : {
     424             :     {
     425         836 :         ::osl::ResettableMutexGuard aGuard( m_aMutex );
     426         836 :         if ( m_bDisposed )
     427           1 :             throw lang::DisposedException(); // TODO
     428             : 
     429         835 :         if ( m_nObjectState == -1 )
     430             :             throw embed::WrongStateException( "The object has no persistence!",
     431           0 :                                               static_cast< ::cppu::OWeakObject* >(this) );
     432             : 
     433         835 :         sal_Int32 nOldState = m_nObjectState;
     434             : 
     435         835 :         if ( m_nTargetState != -1 )
     436             :         {
     437             :             // means that the object is currently trying to reach the target state
     438             :             throw embed::StateChangeInProgressException( OUString(),
     439             :                                                         uno::Reference< uno::XInterface >(),
     440           0 :                                                         m_nTargetState );
     441             :         }
     442             :         else
     443             :         {
     444         835 :             TargetStateControl_Impl aControl( m_nTargetState, nNewState );
     445             : 
     446             :             // in case the object is already in requested state
     447         835 :             if ( m_nObjectState == nNewState )
     448             :             {
     449             :                 // if active object is activated again, bring it's window to top
     450         155 :                 if ( m_nObjectState == embed::EmbedStates::ACTIVE )
     451           0 :                     m_pDocHolder->Show();
     452             : 
     453         976 :                 return;
     454             :             }
     455             : 
     456             :             // retrieve sequence of states that should be passed to reach desired state
     457        1360 :             uno::Sequence< sal_Int32 > aIntermediateStates = GetIntermediateStatesSequence_Impl( nNewState );
     458             : 
     459             :             // notify listeners that the object is going to change the state
     460         680 :             StateChangeNotification_Impl( true, nOldState, nNewState,aGuard );
     461             : 
     462             :             try {
     463         682 :                 for ( sal_Int32 nInd = 0; nInd < aIntermediateStates.getLength(); nInd++ )
     464           2 :                     SwitchStateTo_Impl( aIntermediateStates[nInd] );
     465             : 
     466         680 :                 SwitchStateTo_Impl( nNewState );
     467             :             }
     468          14 :             catch( const uno::Exception& )
     469             :             {
     470          14 :                 if ( nOldState != m_nObjectState )
     471             :                     // notify listeners that the object has changed the state
     472           0 :                     StateChangeNotification_Impl( false, nOldState, m_nObjectState, aGuard );
     473             : 
     474          14 :                 throw;
     475         680 :             }
     476             :         }
     477             : 
     478             :         // notify listeners that the object has changed the state
     479         666 :         StateChangeNotification_Impl( false, nOldState, nNewState, aGuard );
     480             : 
     481             :         // let the object window be shown
     482         666 :         if ( nNewState == embed::EmbedStates::UI_ACTIVE || nNewState == embed::EmbedStates::INPLACE_ACTIVE )
     483           1 :             PostEvent_Impl( OUString( "OnVisAreaChanged" ) );
     484             :     }
     485             : }
     486             : 
     487             : 
     488           0 : uno::Sequence< sal_Int32 > SAL_CALL OCommonEmbeddedObject::getReachableStates()
     489             :         throw ( embed::WrongStateException,
     490             :                 uno::RuntimeException, std::exception )
     491             : {
     492           0 :     if ( m_bDisposed )
     493           0 :         throw lang::DisposedException(); // TODO
     494             : 
     495           0 :     if ( m_nObjectState == -1 )
     496             :         throw embed::WrongStateException( "The object has no persistence!",
     497           0 :                                            static_cast< ::cppu::OWeakObject* >(this) );
     498             : 
     499           0 :     return m_aAcceptedStates;
     500             : }
     501             : 
     502             : 
     503       13262 : sal_Int32 SAL_CALL OCommonEmbeddedObject::getCurrentState()
     504             :         throw ( embed::WrongStateException,
     505             :                 uno::RuntimeException, std::exception )
     506             : {
     507       13262 :     if ( m_bDisposed )
     508           0 :         throw lang::DisposedException(); // TODO
     509             : 
     510       13262 :     if ( m_nObjectState == -1 )
     511             :         throw embed::WrongStateException( "The object has no persistence!",
     512           0 :                                           static_cast< ::cppu::OWeakObject* >(this) );
     513             : 
     514       13262 :     return m_nObjectState;
     515             : }
     516             : 
     517             : 
     518           1 : void SAL_CALL OCommonEmbeddedObject::doVerb( sal_Int32 nVerbID )
     519             :         throw ( lang::IllegalArgumentException,
     520             :                 embed::WrongStateException,
     521             :                 embed::UnreachableStateException,
     522             :                 uno::Exception,
     523             :                 uno::RuntimeException, std::exception )
     524             : {
     525           1 :     SolarMutexGuard aSolarGuard;
     526             :         //TODO: a gross hack to avoid deadlocks when this is called from the
     527             :         // outside and OCommonEmbeddedObject::changeState, with m_aMutex locked,
     528             :         // calls into framework code that tries to lock the solar mutex, while
     529             :         // another thread (through Window::ImplCallPaint, say) calls
     530             :         // OCommonEmbeddedObject::getComponent with the solar mutex locked and
     531             :         // then tries to lock m_aMutex (see fdo#56818); the alternative would be
     532             :         // to get locking done right in this class, but that looks like a
     533             :         // daunting task
     534             : 
     535           2 :     ::osl::ResettableMutexGuard aGuard( m_aMutex );
     536           1 :     if ( m_bDisposed )
     537           0 :         throw lang::DisposedException(); // TODO
     538             : 
     539           1 :     if ( m_nObjectState == -1 )
     540             :         throw embed::WrongStateException( "The object has no persistence!",
     541           0 :                                           static_cast< ::cppu::OWeakObject* >(this) );
     542             : 
     543             :     // for internal documents this call is just a duplicate of changeState
     544           1 :     sal_Int32 nNewState = -1;
     545             :     try
     546             :     {
     547           1 :         nNewState = ConvertVerbToState_Impl( nVerbID );
     548             :     }
     549           0 :     catch( const uno::Exception& )
     550             :     {}
     551             : 
     552           1 :     if ( nNewState == -1 )
     553             :     {
     554             :         // TODO/LATER: Save Copy as... verb ( -8 ) is implemented by container
     555             :         // TODO/LATER: check if the verb is a supported one and if it is produce related operation
     556             :     }
     557             :     else
     558             :     {
     559           1 :         aGuard.clear();
     560           1 :         changeState( nNewState );
     561           1 :     }
     562           1 : }
     563             : 
     564             : 
     565           0 : uno::Sequence< embed::VerbDescriptor > SAL_CALL OCommonEmbeddedObject::getSupportedVerbs()
     566             :         throw ( embed::WrongStateException,
     567             :                 uno::RuntimeException, std::exception )
     568             : {
     569           0 :     if ( m_bDisposed )
     570           0 :         throw lang::DisposedException(); // TODO
     571             : 
     572           0 :     if ( m_nObjectState == -1 )
     573             :         throw embed::WrongStateException( "The object has no persistence!",
     574           0 :                                           static_cast< ::cppu::OWeakObject* >(this) );
     575             : 
     576           0 :     return m_aObjectVerbs;
     577             : }
     578             : 
     579             : 
     580         460 : void SAL_CALL OCommonEmbeddedObject::setClientSite(
     581             :                 const uno::Reference< embed::XEmbeddedClient >& xClient )
     582             :         throw ( embed::WrongStateException,
     583             :                 uno::RuntimeException, std::exception )
     584             : {
     585         460 :     ::osl::MutexGuard aGuard( m_aMutex );
     586         460 :     if ( m_bDisposed )
     587           1 :         throw lang::DisposedException(); // TODO
     588             : 
     589         459 :     if ( m_xClientSite != xClient)
     590             :     {
     591         371 :         if ( m_nObjectState != embed::EmbedStates::LOADED && m_nObjectState != embed::EmbedStates::RUNNING )
     592             :             throw embed::WrongStateException(
     593             :                                     "The client site can not be set currently!",
     594           0 :                                      static_cast< ::cppu::OWeakObject* >(this) );
     595             : 
     596         371 :         m_xClientSite = xClient;
     597         460 :     }
     598         459 : }
     599             : 
     600             : 
     601         953 : uno::Reference< embed::XEmbeddedClient > SAL_CALL OCommonEmbeddedObject::getClientSite()
     602             :         throw ( embed::WrongStateException,
     603             :                 uno::RuntimeException, std::exception )
     604             : {
     605         953 :     if ( m_bDisposed )
     606           0 :         throw lang::DisposedException(); // TODO
     607             : 
     608         953 :     if ( m_nObjectState == -1 )
     609             :         throw embed::WrongStateException( "The object has no persistence!",
     610           0 :                                           static_cast< ::cppu::OWeakObject* >(this) );
     611             : 
     612         953 :     return m_xClientSite;
     613             : }
     614             : 
     615             : 
     616           0 : void SAL_CALL OCommonEmbeddedObject::update()
     617             :         throw ( embed::WrongStateException,
     618             :                 uno::Exception,
     619             :                 uno::RuntimeException, std::exception )
     620             : {
     621           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     622           0 :     if ( m_bDisposed )
     623           0 :         throw lang::DisposedException(); // TODO
     624             : 
     625           0 :     if ( m_nObjectState == -1 )
     626             :         throw embed::WrongStateException( "The object has no persistence!",
     627           0 :                                           static_cast< ::cppu::OWeakObject* >(this) );
     628             : 
     629           0 :     PostEvent_Impl( OUString( "OnVisAreaChanged" ) );
     630           0 : }
     631             : 
     632             : 
     633           0 : void SAL_CALL OCommonEmbeddedObject::setUpdateMode( sal_Int32 nMode )
     634             :         throw ( embed::WrongStateException,
     635             :                 uno::RuntimeException, std::exception )
     636             : {
     637           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     638           0 :     if ( m_bDisposed )
     639           0 :         throw lang::DisposedException(); // TODO
     640             : 
     641           0 :     if ( m_nObjectState == -1 )
     642             :         throw embed::WrongStateException( "The object has no persistence!",
     643           0 :                                           static_cast< ::cppu::OWeakObject* >(this) );
     644             : 
     645             :     OSL_ENSURE( nMode == embed::EmbedUpdateModes::ALWAYS_UPDATE
     646             :                     || nMode == embed::EmbedUpdateModes::EXPLICIT_UPDATE,
     647             :                 "Unknown update mode!\n" );
     648           0 :     m_nUpdateMode = nMode;
     649           0 : }
     650             : 
     651             : 
     652         892 : sal_Int64 SAL_CALL OCommonEmbeddedObject::getStatus( sal_Int64 )
     653             :         throw ( embed::WrongStateException,
     654             :                 uno::RuntimeException, std::exception )
     655             : {
     656         892 :     if ( m_bDisposed )
     657           0 :         throw lang::DisposedException(); // TODO
     658             : 
     659         892 :     return m_nMiscStatus;
     660             : }
     661             : 
     662             : 
     663           0 : void SAL_CALL OCommonEmbeddedObject::setContainerName( const OUString& sName )
     664             :         throw ( uno::RuntimeException, std::exception )
     665             : {
     666           0 :     ::osl::MutexGuard aGuard( m_aMutex );
     667           0 :     if ( m_bDisposed )
     668           0 :         throw lang::DisposedException(); // TODO
     669             : 
     670           0 :     m_aContainerName = sName;
     671           0 : }
     672             : 
     673        1745 : com::sun::star::uno::Reference< com::sun::star::uno::XInterface > SAL_CALL OCommonEmbeddedObject::getParent() throw (::com::sun::star::uno::RuntimeException, std::exception)
     674             : {
     675        1745 :     return m_xParent;
     676             : }
     677             : 
     678        1211 : void SAL_CALL OCommonEmbeddedObject::setParent( const com::sun::star::uno::Reference< com::sun::star::uno::XInterface >& xParent ) throw (::com::sun::star::lang::NoSupportException, ::com::sun::star::uno::RuntimeException, std::exception)
     679             : {
     680        1211 :     m_xParent = xParent;
     681        1211 :     if ( m_nObjectState != -1 && m_nObjectState != embed::EmbedStates::LOADED )
     682             :     {
     683        1062 :         uno::Reference < container::XChild > xChild( m_pDocHolder->GetComponent(), uno::UNO_QUERY );
     684        1062 :         if ( xChild.is() )
     685        1062 :             xChild->setParent( xParent );
     686             :     }
     687        1211 : }
     688             : 
     689             : // XDefaultSizeTransmitter
     690         331 : void SAL_CALL OCommonEmbeddedObject::setDefaultSize( const ::com::sun::star::awt::Size& rSize_100TH_MM ) throw (::com::sun::star::uno::RuntimeException, std::exception)
     691             : {
     692             :     //#i103460# charts do not necessaryly have an own size within ODF files, in this case they need to use the size settings from the surrounding frame, which is made available with this method
     693         331 :     m_aDefaultSizeForChart_In_100TH_MM = rSize_100TH_MM;
     694         331 : }
     695             : 
     696             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.11