LCOV - code coverage report
Current view: top level - svtools/source/misc - embedhlp.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 255 379 67.3 %
Date: 2012-08-25 Functions: 36 41 87.8 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 268 690 38.8 %

           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                 :            : 
      30                 :            : #include <svtools/embedhlp.hxx>
      31                 :            : #include <svtools/filter.hxx>
      32                 :            : #include <svtools/svtools.hrc>
      33                 :            : #include <svtools/svtresid.hxx>
      34                 :            : 
      35                 :            : #include <comphelper/embeddedobjectcontainer.hxx>
      36                 :            : #include <comphelper/seqstream.hxx>
      37                 :            : #include <toolkit/helper/vclunohelper.hxx>
      38                 :            : #include <unotools/ucbstreamhelper.hxx>
      39                 :            : #include <unotools/streamwrap.hxx>
      40                 :            : 
      41                 :            : #include <tools/globname.hxx>
      42                 :            : #include <sot/clsids.hxx>
      43                 :            : #include <com/sun/star/util/XModifyListener.hpp>
      44                 :            : #include <com/sun/star/util/XModifiable.hpp>
      45                 :            : #include <com/sun/star/embed/EmbedStates.hpp>
      46                 :            : #include <com/sun/star/embed/EmbedMisc.hpp>
      47                 :            : #include <com/sun/star/embed/XStateChangeListener.hpp>
      48                 :            : #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
      49                 :            : #include <com/sun/star/datatransfer/XTransferable.hpp>
      50                 :            : #include <com/sun/star/chart2/XDefaultSizeTransmitter.hpp>
      51                 :            : #include <cppuhelper/implbase4.hxx>
      52                 :            : #include "vcl/svapp.hxx"
      53                 :            : #include <rtl/logfile.hxx>
      54                 :            : #include <osl/mutex.hxx>
      55                 :            : 
      56                 :            : using namespace com::sun::star;
      57                 :            : 
      58                 :            : namespace svt
      59                 :            : {
      60                 :            : 
      61         [ -  + ]:       1888 : class EmbedEventListener_Impl : public ::cppu::WeakImplHelper4 < embed::XStateChangeListener,
      62                 :            :                                                                  document::XEventListener,
      63                 :            :                                                                  util::XModifyListener,
      64                 :            :                                                                  util::XCloseListener >
      65                 :            : {
      66                 :            : public:
      67                 :            :     EmbeddedObjectRef*          pObject;
      68                 :            :     sal_Int32                   nState;
      69                 :            : 
      70                 :       1133 :                                 EmbedEventListener_Impl( EmbeddedObjectRef* p ) :
      71                 :            :                                     pObject(p)
      72                 :       1133 :                                     , nState(-1)
      73                 :       1133 :                                 {}
      74                 :            : 
      75                 :            :     static EmbedEventListener_Impl* Create( EmbeddedObjectRef* );
      76                 :            : 
      77                 :            :     virtual void SAL_CALL changingState( const lang::EventObject& aEvent, ::sal_Int32 nOldState, ::sal_Int32 nNewState )
      78                 :            :                                     throw (embed::WrongStateException, uno::RuntimeException);
      79                 :            :     virtual void SAL_CALL stateChanged( const lang::EventObject& aEvent, ::sal_Int32 nOldState, ::sal_Int32 nNewState )
      80                 :            :                                     throw (uno::RuntimeException);
      81                 :            :     virtual void SAL_CALL queryClosing( const lang::EventObject& Source, ::sal_Bool GetsOwnership )
      82                 :            :                                     throw (util::CloseVetoException, uno::RuntimeException);
      83                 :            :     virtual void SAL_CALL notifyClosing( const lang::EventObject& Source ) throw (uno::RuntimeException);
      84                 :            :     virtual void SAL_CALL notifyEvent( const document::EventObject& aEvent ) throw( uno::RuntimeException );
      85                 :            :     virtual void SAL_CALL disposing( const lang::EventObject& aEvent ) throw( uno::RuntimeException );
      86                 :            :     virtual void SAL_CALL modified( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
      87                 :            : };
      88                 :            : 
      89                 :       1133 : EmbedEventListener_Impl* EmbedEventListener_Impl::Create( EmbeddedObjectRef* p )
      90                 :            : {
      91         [ +  - ]:       1133 :     EmbedEventListener_Impl* xRet = new EmbedEventListener_Impl( p );
      92                 :       1133 :     xRet->acquire();
      93                 :            : 
      94         [ +  - ]:       1133 :     if ( p->GetObject().is() )
      95                 :            :     {
      96 [ +  - ][ +  - ]:       1133 :         p->GetObject()->addStateChangeListener( xRet );
         [ +  - ][ +  - ]
      97                 :            : 
      98         [ +  - ]:       1133 :         uno::Reference < util::XCloseable > xClose( p->GetObject(), uno::UNO_QUERY );
      99                 :            :         DBG_ASSERT( xClose.is(), "Object does not support XCloseable!" );
     100         [ +  - ]:       1133 :         if ( xClose.is() )
     101 [ +  - ][ +  - ]:       1133 :             xClose->addCloseListener( xRet );
         [ +  - ][ +  - ]
     102                 :            : 
     103         [ +  - ]:       1133 :         uno::Reference < document::XEventBroadcaster > xBrd( p->GetObject(), uno::UNO_QUERY );
     104         [ +  - ]:       1133 :         if ( xBrd.is() )
     105 [ +  - ][ +  - ]:       1133 :             xBrd->addEventListener( xRet );
         [ +  - ][ +  - ]
     106                 :            : 
     107 [ +  - ][ +  - ]:       1133 :         xRet->nState = p->GetObject()->getCurrentState();
     108         [ +  + ]:       1133 :         if ( xRet->nState == embed::EmbedStates::RUNNING )
     109                 :            :         {
     110 [ +  - ][ +  - ]:       1113 :             uno::Reference < util::XModifiable > xMod( p->GetObject()->getComponent(), uno::UNO_QUERY );
                 [ +  - ]
     111         [ +  - ]:       1113 :             if ( xMod.is() )
     112                 :            :                 // listen for changes in running state (update replacements in case of changes)
     113 [ +  - ][ +  - ]:       1113 :                 xMod->addModifyListener( xRet );
         [ +  - ][ +  - ]
     114                 :       1133 :         }
     115                 :            :     }
     116                 :            : 
     117                 :       1133 :     return xRet;
     118                 :            : }
     119                 :            : 
     120                 :         43 : void SAL_CALL EmbedEventListener_Impl::changingState( const lang::EventObject&,
     121                 :            :                                                     ::sal_Int32,
     122                 :            :                                                     ::sal_Int32 )
     123                 :            :     throw ( embed::WrongStateException,
     124                 :            :             uno::RuntimeException )
     125                 :            : {
     126                 :         43 : }
     127                 :            : 
     128                 :         43 : void SAL_CALL EmbedEventListener_Impl::stateChanged( const lang::EventObject&,
     129                 :            :                                                     ::sal_Int32 nOldState,
     130                 :            :                                                     ::sal_Int32 nNewState )
     131                 :            :     throw ( uno::RuntimeException )
     132                 :            : {
     133         [ +  - ]:         43 :     SolarMutexGuard aGuard;
     134                 :         43 :     nState = nNewState;
     135         [ -  + ]:         43 :     if ( !pObject )
     136                 :         43 :         return;
     137                 :            : 
     138 [ +  - ][ +  - ]:         43 :     uno::Reference < util::XModifiable > xMod( pObject->GetObject()->getComponent(), uno::UNO_QUERY );
                 [ +  - ]
     139         [ +  + ]:         43 :     if ( nNewState == embed::EmbedStates::RUNNING )
     140                 :            :     {
     141                 :            :         // TODO/LATER: container must be set before!
     142                 :            :         // When is this event created? Who sets the new container when it changed?
     143 [ +  - ][ +  - ]:          2 :         if( ( pObject->GetViewAspect() != embed::Aspects::MSOLE_ICON ) && nOldState != embed::EmbedStates::LOADED && !pObject->IsChart() )
         [ +  - ][ +  - ]
         [ -  + ][ -  + ]
     144                 :            :             // get new replacement after deactivation
     145         [ #  # ]:          0 :             pObject->UpdateReplacement();
     146                 :            : 
     147 [ +  - ][ +  - ]:          2 :         if( pObject->IsChart() && nOldState == embed::EmbedStates::UI_ACTIVE )
         [ +  - ][ +  - ]
     148                 :            :         {
     149                 :            :             //create a new metafile replacement when leaving the edit mode
     150                 :            :             //for buggy documents where the old image looks different from the correct one
     151 [ +  - ][ +  - ]:          2 :             if( xMod.is() && !xMod->isModified() )//in case of modification a new replacement will be requested anyhow
         [ +  - ][ -  + ]
                 [ -  + ]
     152         [ #  # ]:          0 :                 pObject->UpdateReplacementOnDemand();
     153                 :            :         }
     154                 :            : 
     155 [ +  - ][ -  + ]:          2 :         if ( xMod.is() && nOldState == embed::EmbedStates::LOADED )
                 [ -  + ]
     156                 :            :             // listen for changes (update replacements in case of changes)
     157 [ #  # ][ #  # ]:          0 :             xMod->addModifyListener( this );
                 [ #  # ]
     158                 :            :     }
     159         [ +  + ]:         41 :     else if ( nNewState == embed::EmbedStates::LOADED )
     160                 :            :     {
     161                 :            :         // in loaded state we can't listen
     162         [ -  + ]:         39 :         if ( xMod.is() )
     163 [ #  # ][ #  # ]:          0 :             xMod->removeModifyListener( this );
                 [ #  # ]
     164 [ +  - ][ +  - ]:         43 :     }
     165                 :            : }
     166                 :            : 
     167                 :       7288 : void SAL_CALL EmbedEventListener_Impl::modified( const lang::EventObject& ) throw (uno::RuntimeException)
     168                 :            : {
     169         [ +  - ]:       7288 :     SolarMutexGuard aGuard;
     170 [ +  + ][ +  - ]:       7288 :     if ( pObject && pObject->GetViewAspect() != embed::Aspects::MSOLE_ICON )
         [ +  - ][ +  + ]
     171                 :            :     {
     172         [ +  + ]:       7040 :         if ( nState == embed::EmbedStates::RUNNING )
     173                 :            :         {
     174                 :            :             // updates only necessary in non-active states
     175 [ +  - ][ +  + ]:       7016 :             if( pObject->IsChart() )
     176         [ +  - ]:        200 :                 pObject->UpdateReplacementOnDemand();
     177                 :            :             else
     178         [ +  - ]:       6816 :                 pObject->UpdateReplacement();
     179                 :            :         }
     180 [ +  - ][ -  + ]:         24 :         else if ( nState == embed::EmbedStates::ACTIVE ||
                 [ #  # ]
     181                 :            :                   nState == embed::EmbedStates::UI_ACTIVE ||
     182                 :            :                   nState == embed::EmbedStates::INPLACE_ACTIVE )
     183                 :            :         {
     184                 :            :             // in case the object is inplace or UI active the replacement image should be updated on demand
     185         [ +  - ]:         24 :             pObject->UpdateReplacementOnDemand();
     186                 :            :         }
     187         [ +  - ]:       7288 :     }
     188                 :       7288 : }
     189                 :            : 
     190                 :      11746 : void SAL_CALL EmbedEventListener_Impl::notifyEvent( const document::EventObject& aEvent ) throw( uno::RuntimeException )
     191                 :            : {
     192         [ +  - ]:      11746 :     SolarMutexGuard aGuard;
     193                 :            : 
     194 [ +  - ][ +  + ]:      11746 :     if ( pObject && aEvent.EventName == "OnVisAreaChanged" && pObject->GetViewAspect() != embed::Aspects::MSOLE_ICON && !pObject->IsChart() )
         [ +  - ][ +  - ]
         [ +  - ][ -  + ]
                 [ -  + ]
     195                 :            :     {
     196         [ #  # ]:          0 :         pObject->UpdateReplacement();
     197         [ +  - ]:      11746 :     }
     198                 :      11746 : }
     199                 :            : 
     200                 :         26 : void SAL_CALL EmbedEventListener_Impl::queryClosing( const lang::EventObject& Source, ::sal_Bool )
     201                 :            :         throw ( util::CloseVetoException, uno::RuntimeException)
     202                 :            : {
     203                 :            :     // An embedded object can be shared between several objects (f.e. for undo purposes)
     204                 :            :     // the object will not be closed before the last "customer" is destroyed
     205                 :            :     // Now the EmbeddedObjectRef helper class works like a "lock" on the object
     206 [ +  - ][ +  - ]:         26 :     if ( pObject && pObject->IsLocked() && Source.Source == pObject->GetObject() )
         [ +  - ][ +  - ]
     207         [ +  - ]:         26 :         throw util::CloseVetoException();
     208                 :          0 : }
     209                 :            : 
     210                 :          0 : void SAL_CALL EmbedEventListener_Impl::notifyClosing( const lang::EventObject& Source ) throw (::com::sun::star::uno::RuntimeException)
     211                 :            : {
     212 [ #  # ][ #  # ]:          0 :     if ( pObject && Source.Source == pObject->GetObject() )
                 [ #  # ]
     213                 :            :     {
     214                 :          0 :         pObject->Clear();
     215                 :          0 :         pObject = 0;
     216                 :            :     }
     217                 :          0 : }
     218                 :            : 
     219                 :        960 : void SAL_CALL EmbedEventListener_Impl::disposing( const lang::EventObject& aEvent ) throw( uno::RuntimeException )
     220                 :            : {
     221 [ +  + ][ -  + ]:        960 :     if ( pObject && aEvent.Source == pObject->GetObject() )
                 [ -  + ]
     222                 :            :     {
     223                 :          0 :         pObject->Clear();
     224                 :          0 :         pObject = 0;
     225                 :            :     }
     226                 :        960 : }
     227                 :            : 
     228                 :       2179 : struct EmbeddedObjectRef_Impl
     229                 :            : {
     230                 :            :     EmbedEventListener_Impl*                    xListener;
     231                 :            :     ::rtl::OUString                             aPersistName;
     232                 :            :     ::rtl::OUString                             aMediaType;
     233                 :            :     comphelper::EmbeddedObjectContainer*        pContainer;
     234                 :            :     Graphic*                                    pGraphic;
     235                 :            :     sal_Int64                                   nViewAspect;
     236                 :            :     sal_Bool                                        bIsLocked;
     237                 :            :     sal_Bool                                    bNeedUpdate;
     238                 :            : 
     239                 :            :     // #i104867#
     240                 :            :     sal_uInt32                                  mnGraphicVersion;
     241                 :            :     awt::Size                                   aDefaultSizeForChart_In_100TH_MM;//#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 member
     242                 :            : };
     243                 :            : 
     244                 :        676 : void EmbeddedObjectRef::Construct_Impl()
     245                 :            : {
     246                 :        676 :     mpImp = new EmbeddedObjectRef_Impl;
     247                 :        676 :     mpImp->pContainer = 0;
     248                 :        676 :     mpImp->pGraphic = 0;
     249                 :        676 :     mpImp->nViewAspect = embed::Aspects::MSOLE_CONTENT;
     250                 :        676 :     mpImp->bIsLocked = sal_False;
     251                 :        676 :     mpImp->bNeedUpdate = sal_False;
     252                 :        676 :     mpImp->mnGraphicVersion = 0;
     253                 :        676 :     mpImp->aDefaultSizeForChart_In_100TH_MM = awt::Size(8000,7000);
     254                 :        676 : }
     255                 :            : 
     256                 :        430 : EmbeddedObjectRef::EmbeddedObjectRef()
     257                 :            : {
     258         [ +  - ]:        430 :     Construct_Impl();
     259                 :        430 : }
     260                 :            : 
     261                 :        246 : EmbeddedObjectRef::EmbeddedObjectRef( const uno::Reference < embed::XEmbeddedObject >& xObj, sal_Int64 nAspect )
     262                 :            : {
     263         [ +  - ]:        246 :     Construct_Impl();
     264                 :        246 :     mpImp->nViewAspect = nAspect;
     265         [ +  - ]:        246 :     mxObj = xObj;
     266         [ +  - ]:        246 :     mpImp->xListener = EmbedEventListener_Impl::Create( this );
     267                 :        246 : }
     268                 :            : 
     269                 :        457 : EmbeddedObjectRef::EmbeddedObjectRef( const EmbeddedObjectRef& rObj )
     270                 :            : {
     271         [ +  - ]:        457 :     mpImp = new EmbeddedObjectRef_Impl;
     272                 :        457 :     mpImp->pContainer = rObj.mpImp->pContainer;
     273                 :        457 :     mpImp->nViewAspect = rObj.mpImp->nViewAspect;
     274                 :        457 :     mpImp->bIsLocked = rObj.mpImp->bIsLocked;
     275         [ +  - ]:        457 :     mxObj = rObj.mxObj;
     276         [ +  - ]:        457 :     mpImp->xListener = EmbedEventListener_Impl::Create( this );
     277                 :        457 :     mpImp->aPersistName = rObj.mpImp->aPersistName;
     278                 :        457 :     mpImp->aMediaType = rObj.mpImp->aMediaType;
     279                 :        457 :     mpImp->bNeedUpdate = rObj.mpImp->bNeedUpdate;
     280                 :        457 :     mpImp->aDefaultSizeForChart_In_100TH_MM = rObj.mpImp->aDefaultSizeForChart_In_100TH_MM;
     281                 :            : 
     282 [ +  - ][ +  + ]:        457 :     if ( rObj.mpImp->pGraphic && !rObj.mpImp->bNeedUpdate )
     283 [ +  - ][ +  - ]:        435 :         mpImp->pGraphic = new Graphic( *rObj.mpImp->pGraphic );
     284                 :            :     else
     285                 :         22 :         mpImp->pGraphic = 0;
     286                 :            : 
     287                 :        457 :     mpImp->mnGraphicVersion = 0;
     288                 :        457 : }
     289                 :            : 
     290                 :       1046 : EmbeddedObjectRef::~EmbeddedObjectRef()
     291                 :            : {
     292 [ +  + ][ +  - ]:       1046 :     delete mpImp->pGraphic;
     293         [ +  - ]:       1046 :     Clear();
     294         [ +  - ]:       1046 :     delete mpImp;
     295                 :       1046 : }
     296                 :            : 
     297                 :        430 : void EmbeddedObjectRef::Assign( const uno::Reference < embed::XEmbeddedObject >& xObj, sal_Int64 nAspect )
     298                 :            : {
     299                 :            :     DBG_ASSERT( !mxObj.is(), "Never assign an already assigned object!" );
     300                 :            : 
     301                 :        430 :     Clear();
     302                 :        430 :     mpImp->nViewAspect = nAspect;
     303                 :        430 :     mxObj = xObj;
     304                 :        430 :     mpImp->xListener = EmbedEventListener_Impl::Create( this );
     305                 :            : 
     306                 :            :     //#i103460#
     307         [ +  + ]:        430 :     if ( IsChart() )
     308                 :            :     {
     309         [ +  - ]:          2 :         uno::Reference < chart2::XDefaultSizeTransmitter > xSizeTransmitter( xObj, uno::UNO_QUERY );
     310                 :            :         DBG_ASSERT( xSizeTransmitter.is(), "Object does not support XDefaultSizeTransmitter -> will cause #i103460#!" );
     311         [ +  - ]:          2 :         if( xSizeTransmitter.is() )
     312 [ +  - ][ +  - ]:          2 :             xSizeTransmitter->setDefaultSize( mpImp->aDefaultSizeForChart_In_100TH_MM );
     313                 :            :     }
     314                 :        430 : }
     315                 :            : 
     316                 :       1823 : void EmbeddedObjectRef::Clear()
     317                 :            : {
     318 [ +  + ][ +  - ]:       1823 :     if ( mxObj.is() && mpImp->xListener )
                 [ +  + ]
     319                 :            :     {
     320 [ +  - ][ +  - ]:       1046 :         mxObj->removeStateChangeListener( mpImp->xListener );
         [ +  - ][ +  - ]
     321                 :            : 
     322         [ +  - ]:       1046 :         uno::Reference < util::XCloseable > xClose( mxObj, uno::UNO_QUERY );
     323         [ +  - ]:       1046 :         if ( xClose.is() )
     324 [ +  - ][ +  - ]:       1046 :             xClose->removeCloseListener( mpImp->xListener );
         [ +  - ][ +  - ]
     325                 :            : 
     326         [ +  - ]:       1046 :         uno::Reference < document::XEventBroadcaster > xBrd( mxObj, uno::UNO_QUERY );
     327         [ +  - ]:       1046 :         if ( xBrd.is() )
     328 [ +  - ][ +  - ]:       1046 :             xBrd->removeEventListener( mpImp->xListener );
         [ +  - ][ +  - ]
              [ #  #  # ]
     329                 :            : 
     330         [ +  + ]:       1046 :         if ( mpImp->bIsLocked )
     331                 :            :         {
     332         [ +  - ]:        372 :             if ( xClose.is() )
     333                 :            :             {
     334                 :            :                 try
     335                 :            :                 {
     336 [ +  - ][ +  - ]:        372 :                     mxObj->changeState( embed::EmbedStates::LOADED );
     337 [ +  - ][ +  - ]:        372 :                     xClose->close( sal_True );
     338                 :            :                 }
     339         [ #  # ]:          0 :                 catch (const util::CloseVetoException&)
     340                 :            :                 {
     341                 :            :                     // there's still someone who needs the object!
     342                 :            :                 }
     343         [ #  # ]:          0 :                 catch (const uno::Exception&)
     344                 :            :                 {
     345                 :            :                     OSL_FAIL( "Error on switching of the object to loaded state and closing!\n" );
     346                 :            :                 }
     347                 :            :             }
     348                 :            :         }
     349                 :            : 
     350         [ +  - ]:       1046 :         if ( mpImp->xListener )
     351                 :            :         {
     352                 :       1046 :             mpImp->xListener->pObject = 0;
     353                 :       1046 :             mpImp->xListener->release();
     354                 :       1046 :             mpImp->xListener = 0;
     355                 :            :         }
     356                 :            : 
     357         [ +  - ]:       1046 :         mxObj = 0;
     358                 :       1046 :         mpImp->bNeedUpdate = sal_False;
     359                 :            :     }
     360                 :            : 
     361                 :       1823 :     mpImp->pContainer = 0;
     362                 :       1823 :     mpImp->bIsLocked = sal_False;
     363                 :       1823 :     mpImp->bNeedUpdate = sal_False;
     364                 :       1823 : }
     365                 :            : 
     366                 :        490 : void EmbeddedObjectRef::AssignToContainer( comphelper::EmbeddedObjectContainer* pContainer, const ::rtl::OUString& rPersistName )
     367                 :            : {
     368                 :        490 :     mpImp->pContainer = pContainer;
     369                 :        490 :     mpImp->aPersistName = rPersistName;
     370                 :            : 
     371 [ +  - ][ +  + ]:        490 :     if ( mpImp->pGraphic && !mpImp->bNeedUpdate && pContainer )
                 [ +  + ]
     372         [ +  - ]:        435 :         SetGraphicToContainer( *mpImp->pGraphic, *pContainer, mpImp->aPersistName, ::rtl::OUString() );
     373                 :        490 : }
     374                 :            : 
     375                 :         29 : comphelper::EmbeddedObjectContainer* EmbeddedObjectRef::GetContainer() const
     376                 :            : {
     377                 :         29 :     return mpImp->pContainer;
     378                 :            : }
     379                 :            : 
     380                 :       8954 : sal_Int64 EmbeddedObjectRef::GetViewAspect() const
     381                 :            : {
     382                 :       8954 :     return mpImp->nViewAspect;
     383                 :            : }
     384                 :            : 
     385                 :          4 : void EmbeddedObjectRef::SetViewAspect( sal_Int64 nAspect )
     386                 :            : {
     387                 :          4 :     mpImp->nViewAspect = nAspect;
     388                 :          4 : }
     389                 :            : 
     390                 :        488 : void EmbeddedObjectRef::Lock( sal_Bool bLock )
     391                 :            : {
     392                 :        488 :     mpImp->bIsLocked = bLock;
     393                 :        488 : }
     394                 :            : 
     395                 :         26 : sal_Bool EmbeddedObjectRef::IsLocked() const
     396                 :            : {
     397                 :         26 :     return mpImp->bIsLocked;
     398                 :            : }
     399                 :            : 
     400                 :       6907 : void EmbeddedObjectRef::GetReplacement( sal_Bool bUpdate )
     401                 :            : {
     402         [ +  + ]:       6907 :     if ( bUpdate )
     403                 :            :     {
     404         [ +  + ]:       6904 :         DELETEZ( mpImp->pGraphic );
     405                 :       6904 :         mpImp->aMediaType = ::rtl::OUString();
     406         [ +  - ]:       6904 :         mpImp->pGraphic = new Graphic;
     407                 :       6904 :         mpImp->mnGraphicVersion++;
     408                 :            :     }
     409         [ +  - ]:          3 :     else if ( !mpImp->pGraphic )
     410                 :            :     {
     411         [ +  - ]:          3 :         mpImp->pGraphic = new Graphic;
     412                 :          3 :         mpImp->mnGraphicVersion++;
     413                 :            :     }
     414                 :            :     else
     415                 :            :     {
     416                 :            :         OSL_FAIL("No update, but replacement exists already!");
     417                 :       6907 :         return;
     418                 :            :     }
     419                 :            : 
     420                 :       6907 :     SvStream* pGraphicStream = GetGraphicStream( bUpdate );
     421         [ +  - ]:       6907 :     if ( pGraphicStream )
     422                 :            :     {
     423                 :       6907 :         GraphicFilter& rGF = GraphicFilter::GetGraphicFilter();
     424         [ +  + ]:       6907 :         if( mpImp->pGraphic )
     425         [ +  - ]:       6905 :             rGF.ImportGraphic( *mpImp->pGraphic, String(), *pGraphicStream, GRFILTER_FORMAT_DONTKNOW );
     426                 :       6907 :         mpImp->mnGraphicVersion++;
     427         [ +  - ]:       6907 :         delete pGraphicStream;
     428                 :            :     }
     429                 :            : }
     430                 :            : 
     431                 :        511 : Graphic* EmbeddedObjectRef::GetGraphic( ::rtl::OUString* pMediaType ) const
     432                 :            : {
     433         [ +  + ]:        511 :     if ( mpImp->bNeedUpdate )
     434                 :            :         // bNeedUpdate will be set to false while retrieving new replacement
     435                 :         88 :         const_cast < EmbeddedObjectRef* >(this)->GetReplacement( sal_True );
     436         [ +  + ]:        423 :     else if ( !mpImp->pGraphic )
     437                 :          3 :         const_cast < EmbeddedObjectRef* >(this)->GetReplacement( sal_False );
     438                 :            : 
     439 [ +  + ][ -  + ]:        511 :     if ( mpImp->pGraphic && pMediaType )
     440                 :          0 :         *pMediaType = mpImp->aMediaType;
     441                 :        511 :     return mpImp->pGraphic;
     442                 :            : }
     443                 :            : 
     444                 :        300 : Size EmbeddedObjectRef::GetSize( MapMode* pTargetMapMode ) const
     445                 :            : {
     446         [ +  - ]:        300 :     MapMode aSourceMapMode( MAP_100TH_MM );
     447                 :        300 :     Size aResult;
     448                 :            : 
     449         [ -  + ]:        300 :     if ( mpImp->nViewAspect == embed::Aspects::MSOLE_ICON )
     450                 :            :     {
     451         [ #  # ]:          0 :         Graphic* pGraphic = GetGraphic();
     452         [ #  # ]:          0 :         if ( pGraphic )
     453                 :            :         {
     454 [ #  # ][ #  # ]:          0 :             aSourceMapMode = pGraphic->GetPrefMapMode();
           [ #  #  #  #  
                      # ]
     455         [ #  # ]:          0 :             aResult = pGraphic->GetPrefSize();
     456                 :            :         }
     457                 :            :         else
     458                 :          0 :             aResult = Size( 2500, 2500 );
     459                 :            :     }
     460                 :            :     else
     461                 :            :     {
     462                 :        300 :         awt::Size aSize;
     463                 :            : 
     464         [ +  - ]:        300 :         if ( mxObj.is() )
     465                 :            :         {
     466                 :            :             try
     467                 :            :             {
     468 [ +  - ][ +  - ]:        300 :                 aSize = mxObj->getVisualAreaSize( mpImp->nViewAspect );
     469                 :            :             }
     470         [ #  # ]:          0 :             catch(const embed::NoVisualAreaSizeException&)
     471                 :            :             {
     472                 :            :             }
     473         [ #  # ]:          0 :             catch(const uno::Exception&)
     474                 :            :             {
     475                 :            :                 OSL_FAIL( "Something went wrong on getting of the size of the object!" );
     476                 :            :             }
     477                 :            : 
     478                 :            :             try
     479                 :            :             {
     480 [ +  - ][ +  - ]:        300 :                 aSourceMapMode = VCLUnoHelper::UnoEmbed2VCLMapUnit( mxObj->getMapUnit( mpImp->nViewAspect ) );
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
                 [ #  # ]
     481                 :            :             }
     482         [ #  # ]:          0 :             catch(const uno::Exception&)
     483                 :            :             {
     484                 :            :                 OSL_FAIL( "Can not get the map mode!" );
     485                 :            :             }
     486                 :            :         }
     487                 :            : 
     488 [ -  + ][ #  # ]:        300 :         if ( !aSize.Height && !aSize.Width )
     489                 :            :         {
     490                 :          0 :             aSize.Width = 5000;
     491                 :          0 :             aSize.Height = 5000;
     492                 :            :         }
     493                 :            : 
     494                 :        300 :         aResult = Size( aSize.Width, aSize.Height );
     495                 :            :     }
     496                 :            : 
     497         [ +  - ]:        300 :     if ( pTargetMapMode )
     498         [ +  - ]:        300 :         aResult = OutputDevice::LogicToLogic( aResult, aSourceMapMode, *pTargetMapMode );
     499                 :            : 
     500         [ +  - ]:        300 :     return aResult;
     501                 :            : }
     502                 :            : 
     503                 :          0 : void EmbeddedObjectRef::SetGraphicStream( const uno::Reference< io::XInputStream >& xInGrStream,
     504                 :            :                                             const ::rtl::OUString& rMediaType )
     505                 :            : {
     506         [ #  # ]:          0 :     if ( mpImp->pGraphic )
     507         [ #  # ]:          0 :         delete mpImp->pGraphic;
     508         [ #  # ]:          0 :     mpImp->pGraphic = new Graphic();
     509                 :          0 :     mpImp->aMediaType = rMediaType;
     510                 :          0 :     mpImp->mnGraphicVersion++;
     511                 :            : 
     512         [ #  # ]:          0 :     SvStream* pGraphicStream = ::utl::UcbStreamHelper::CreateStream( xInGrStream );
     513                 :            : 
     514         [ #  # ]:          0 :     if ( pGraphicStream )
     515                 :            :     {
     516                 :          0 :         GraphicFilter& rGF = GraphicFilter::GetGraphicFilter();
     517         [ #  # ]:          0 :         rGF.ImportGraphic( *mpImp->pGraphic, String(), *pGraphicStream, GRFILTER_FORMAT_DONTKNOW );
     518                 :          0 :         mpImp->mnGraphicVersion++;
     519                 :            : 
     520         [ #  # ]:          0 :         if ( mpImp->pContainer )
     521                 :            :         {
     522         [ #  # ]:          0 :             pGraphicStream->Seek( 0 );
     523 [ #  # ][ #  # ]:          0 :             uno::Reference< io::XInputStream > xInSeekGrStream = new ::utl::OSeekableInputStreamWrapper( pGraphicStream );
                 [ #  # ]
     524                 :            : 
     525         [ #  # ]:          0 :             mpImp->pContainer->InsertGraphicStream( xInSeekGrStream, mpImp->aPersistName, rMediaType );
     526                 :            :         }
     527                 :            : 
     528         [ #  # ]:          0 :         delete pGraphicStream;
     529                 :            :     }
     530                 :            : 
     531                 :          0 :     mpImp->bNeedUpdate = sal_False;
     532                 :            : 
     533                 :          0 : }
     534                 :            : 
     535                 :          9 : void EmbeddedObjectRef::SetGraphic( const Graphic& rGraphic, const ::rtl::OUString& rMediaType )
     536                 :            : {
     537         [ -  + ]:          9 :     if ( mpImp->pGraphic )
     538         [ #  # ]:          0 :         delete mpImp->pGraphic;
     539         [ +  - ]:          9 :     mpImp->pGraphic = new Graphic( rGraphic );
     540                 :          9 :     mpImp->aMediaType = rMediaType;
     541                 :          9 :     mpImp->mnGraphicVersion++;
     542                 :            : 
     543         [ -  + ]:          9 :     if ( mpImp->pContainer )
     544                 :          0 :         SetGraphicToContainer( rGraphic, *mpImp->pContainer, mpImp->aPersistName, rMediaType );
     545                 :            : 
     546                 :          9 :     mpImp->bNeedUpdate = sal_False;
     547                 :          9 : }
     548                 :            : 
     549                 :       6907 : SvStream* EmbeddedObjectRef::GetGraphicStream( sal_Bool bUpdate ) const
     550                 :            : {
     551                 :            :     RTL_LOGFILE_CONTEXT( aLog, "svtools (mv76033) svt::EmbeddedObjectRef::GetGraphicStream" );
     552                 :            :     DBG_ASSERT( bUpdate || mpImp->pContainer, "Can't retrieve current graphic!" );
     553                 :       6907 :     uno::Reference < io::XInputStream > xStream;
     554 [ +  + ][ +  + ]:       6907 :     if ( mpImp->pContainer && !bUpdate )
     555                 :            :     {
     556                 :            :         RTL_LOGFILE_CONTEXT_TRACE( aLog, "getting stream from container" );
     557                 :            :         // try to get graphic stream from container storage
     558 [ +  - ][ +  - ]:          3 :         xStream = mpImp->pContainer->GetGraphicStream( mxObj, &mpImp->aMediaType );
     559         [ +  + ]:          3 :         if ( xStream.is() )
     560                 :            :         {
     561                 :          1 :             const sal_Int32 nConstBufferSize = 32000;
     562 [ +  - ][ +  - ]:          1 :             SvStream *pStream = new SvMemoryStream( 32000, 32000 );
     563                 :            :             try
     564                 :            :             {
     565                 :          1 :                 sal_Int32 nRead=0;
     566         [ +  - ]:          1 :                 uno::Sequence < sal_Int8 > aSequence ( nConstBufferSize );
     567         [ +  + ]:          2 :                 do
     568                 :            :                 {
     569 [ +  - ][ +  - ]:          2 :                     nRead = xStream->readBytes ( aSequence, nConstBufferSize );
     570         [ +  - ]:          2 :                     pStream->Write( aSequence.getConstArray(), nRead );
     571                 :            :                 }
     572                 :            :                 while ( nRead == nConstBufferSize );
     573         [ +  - ]:          1 :                 pStream->Seek(0);
     574         [ +  - ]:          1 :                 return pStream;
     575                 :            :             }
     576   [ #  #  #  # ]:          0 :             catch (const uno::Exception& ex)
     577                 :            :             {
     578                 :            :                 SAL_WARN("svtools", "discarding broken embedded object preview: " << ex.Message);
     579   [ #  #  #  # ]:          0 :                 delete pStream;
     580                 :          0 :                 xStream.clear();
     581                 :            :             }
     582                 :            :         }
     583                 :            :     }
     584                 :            : 
     585         [ +  - ]:       6906 :     if ( !xStream.is() )
     586                 :            :     {
     587                 :            :         RTL_LOGFILE_CONTEXT_TRACE( aLog, "getting stream from object" );
     588                 :            :         // update wanted or no stream in container storage available
     589         [ +  - ]:       6906 :         xStream = GetGraphicReplacementStream( mpImp->nViewAspect, mxObj, &mpImp->aMediaType );
     590                 :            : 
     591         [ +  - ]:       6906 :         if ( xStream.is() )
     592                 :            :         {
     593         [ +  + ]:       6906 :             if ( mpImp->pContainer )
     594         [ +  - ]:         90 :                 mpImp->pContainer->InsertGraphicStream( xStream, mpImp->aPersistName, mpImp->aMediaType );
     595                 :            : 
     596         [ +  - ]:       6906 :             SvStream* pResult = ::utl::UcbStreamHelper::CreateStream( xStream );
     597 [ +  + ][ +  - ]:       6906 :             if ( pResult && bUpdate )
     598                 :       6904 :                 mpImp->bNeedUpdate = sal_False;
     599                 :            : 
     600                 :       6906 :             return pResult;
     601                 :            :         }
     602                 :            :     }
     603                 :            : 
     604                 :       6907 :     return NULL;
     605                 :            : }
     606                 :            : 
     607                 :          0 : void EmbeddedObjectRef::DrawPaintReplacement( const Rectangle &rRect, const String &rText, OutputDevice *pOut )
     608                 :            : {
     609         [ #  # ]:          0 :     MapMode aMM( MAP_APPFONT );
     610         [ #  # ]:          0 :     Size aAppFontSz = pOut->LogicToLogic( Size( 0, 8 ), &aMM, NULL );
     611 [ #  # ][ #  # ]:          0 :     Font aFnt( rtl::OUString("Helvetica"), aAppFontSz );
                 [ #  # ]
     612         [ #  # ]:          0 :     aFnt.SetTransparent( sal_True );
     613         [ #  # ]:          0 :     aFnt.SetColor( Color( COL_LIGHTRED ) );
     614         [ #  # ]:          0 :     aFnt.SetWeight( WEIGHT_BOLD );
     615         [ #  # ]:          0 :     aFnt.SetFamily( FAMILY_SWISS );
     616                 :            : 
     617         [ #  # ]:          0 :     pOut->Push();
     618         [ #  # ]:          0 :     pOut->SetBackground();
     619         [ #  # ]:          0 :     pOut->SetFont( aFnt );
     620                 :            : 
     621                 :          0 :     Point aPt;
     622                 :            :     // Nun den Text so skalieren, dass er in das Rect passt.
     623                 :            :     // Wir fangen mit der Defaultsize an und gehen 1-AppFont runter
     624         [ #  # ]:          0 :     for( sal_uInt16 i = 8; i > 2; i-- )
     625                 :            :     {
     626 [ #  # ][ #  # ]:          0 :         aPt.X() = (rRect.GetWidth()  - pOut->GetTextWidth( rText )) / 2;
     627 [ #  # ][ #  # ]:          0 :         aPt.Y() = (rRect.GetHeight() - pOut->GetTextHeight()) / 2;
     628                 :            : 
     629                 :          0 :         sal_Bool bTiny = sal_False;
     630         [ #  # ]:          0 :         if( aPt.X() < 0 ) bTiny = sal_True, aPt.X() = 0;
     631         [ #  # ]:          0 :         if( aPt.Y() < 0 ) bTiny = sal_True, aPt.Y() = 0;
     632         [ #  # ]:          0 :         if( bTiny )
     633                 :            :         {
     634                 :            :             // heruntergehen bei kleinen Bildern
     635         [ #  # ]:          0 :             aFnt.SetSize( Size( 0, aAppFontSz.Height() * i / 8 ) );
     636         [ #  # ]:          0 :             pOut->SetFont( aFnt );
     637                 :            :         }
     638                 :            :         else
     639                 :          0 :             break;
     640                 :            :     }
     641                 :            : 
     642 [ #  # ][ #  # ]:          0 :     Bitmap aBmp( SvtResId( BMP_PLUGIN ) );
     643 [ #  # ][ #  # ]:          0 :     long nHeight = rRect.GetHeight() - pOut->GetTextHeight();
     644         [ #  # ]:          0 :     long nWidth = rRect.GetWidth();
     645         [ #  # ]:          0 :     if( nHeight > 0 )
     646                 :            :     {
     647                 :          0 :         aPt.Y() = nHeight;
     648                 :          0 :         Point   aP = rRect.TopLeft();
     649         [ #  # ]:          0 :         Size    aBmpSize = aBmp.GetSizePixel();
     650                 :            :         // Bitmap einpassen
     651         [ #  # ]:          0 :         if( nHeight * 10 / nWidth
     652                 :          0 :           > aBmpSize.Height() * 10 / aBmpSize.Width() )
     653                 :            :         {
     654                 :            :             // nach der Breite ausrichten
     655                 :            :             // Proportion beibehalten
     656                 :          0 :             long nH = nWidth * aBmpSize.Height() / aBmpSize.Width();
     657                 :            :             // zentrieren
     658                 :          0 :             aP.Y() += (nHeight - nH) / 2;
     659                 :          0 :             nHeight = nH;
     660                 :            :         }
     661                 :            :         else
     662                 :            :         {
     663                 :            :             // nach der H"ohe ausrichten
     664                 :            :             // Proportion beibehalten
     665                 :          0 :             long nW = nHeight * aBmpSize.Width() / aBmpSize.Height();
     666                 :            :             // zentrieren
     667                 :          0 :             aP.X() += (nWidth - nW) / 2;
     668                 :          0 :             nWidth = nW;
     669                 :            :         }
     670                 :            : 
     671         [ #  # ]:          0 :         pOut->DrawBitmap( aP, Size( nWidth, nHeight ), aBmp );
     672                 :            :     }
     673                 :            : 
     674         [ #  # ]:          0 :     pOut->IntersectClipRegion( rRect );
     675                 :          0 :     aPt += rRect.TopLeft();
     676         [ #  # ]:          0 :     pOut->DrawText( aPt, rText );
     677 [ #  # ][ #  # ]:          0 :     pOut->Pop();
         [ #  # ][ #  # ]
     678                 :          0 : }
     679                 :            : 
     680                 :          0 : void EmbeddedObjectRef::DrawShading( const Rectangle &rRect, OutputDevice *pOut )
     681                 :            : {
     682                 :          0 :     GDIMetaFile * pMtf = pOut->GetConnectMetaFile();
     683 [ #  # ][ #  # ]:          0 :     if( pMtf && pMtf->IsRecord() )
                 [ #  # ]
     684                 :          0 :         return;
     685                 :            : 
     686         [ #  # ]:          0 :     pOut->Push();
     687         [ #  # ]:          0 :     pOut->SetLineColor( Color( COL_BLACK ) );
     688                 :            : 
     689 [ #  # ][ #  # ]:          0 :     Size aPixSize = pOut->LogicToPixel( rRect.GetSize() );
     690                 :          0 :     aPixSize.Width() -= 1;
     691                 :          0 :     aPixSize.Height() -= 1;
     692         [ #  # ]:          0 :     Point aPixViewPos = pOut->LogicToPixel( rRect.TopLeft() );
     693                 :          0 :     sal_Int32 nMax = aPixSize.Width() + aPixSize.Height();
     694         [ #  # ]:          0 :     for( sal_Int32 i = 5; i < nMax; i += 5 )
     695                 :            :     {
     696                 :          0 :         Point a1( aPixViewPos ), a2( aPixViewPos );
     697         [ #  # ]:          0 :         if( i > aPixSize.Width() )
     698                 :          0 :             a1 += Point( aPixSize.Width(), i - aPixSize.Width() );
     699                 :            :         else
     700                 :          0 :             a1 += Point( i, 0 );
     701         [ #  # ]:          0 :         if( i > aPixSize.Height() )
     702                 :          0 :             a2 += Point( i - aPixSize.Height(), aPixSize.Height() );
     703                 :            :         else
     704                 :          0 :             a2 += Point( 0, i );
     705                 :            : 
     706 [ #  # ][ #  # ]:          0 :         pOut->DrawLine( pOut->PixelToLogic( a1 ), pOut->PixelToLogic( a2 ) );
                 [ #  # ]
     707                 :            :     }
     708                 :            : 
     709         [ #  # ]:          0 :     pOut->Pop();
     710                 :            : 
     711                 :            : }
     712                 :            : 
     713                 :        437 : sal_Bool EmbeddedObjectRef::TryRunningState( const uno::Reference < embed::XEmbeddedObject >& xEmbObj )
     714                 :            : {
     715         [ -  + ]:        437 :     if ( !xEmbObj.is() )
     716                 :          0 :         return sal_False;
     717                 :            : 
     718                 :            :     try
     719                 :            :     {
     720 [ +  - ][ +  - ]:        437 :         if ( xEmbObj->getCurrentState() == embed::EmbedStates::LOADED )
                 [ -  + ]
     721 [ #  # ][ #  # ]:          0 :             xEmbObj->changeState( embed::EmbedStates::RUNNING );
     722                 :            :     }
     723                 :          0 :     catch (const uno::Exception&)
     724                 :            :     {
     725                 :          0 :         return sal_False;
     726                 :            :     }
     727                 :            : 
     728         [ #  # ]:        437 :     return sal_True;
     729                 :            : }
     730                 :            : 
     731                 :        435 : void EmbeddedObjectRef::SetGraphicToContainer( const Graphic& rGraphic,
     732                 :            :                                                 comphelper::EmbeddedObjectContainer& aContainer,
     733                 :            :                                                 const ::rtl::OUString& aName,
     734                 :            :                                                 const ::rtl::OUString& aMediaType )
     735                 :            : {
     736         [ +  - ]:        435 :     SvMemoryStream aStream;
     737                 :        435 :     aStream.SetVersion( SOFFICE_FILEFORMAT_CURRENT );
     738 [ +  - ][ +  - ]:        435 :     if ( rGraphic.ExportNative( aStream ) )
     739                 :            :     {
     740         [ +  - ]:        435 :         aStream.Seek( 0 );
     741                 :            : 
     742 [ +  - ][ +  - ]:        435 :            uno::Reference < io::XInputStream > xStream = new ::utl::OSeekableInputStreamWrapper( aStream );
                 [ +  - ]
     743         [ +  - ]:        435 :            aContainer.InsertGraphicStream( xStream, aName, aMediaType );
     744                 :            :     }
     745                 :            :     else
     746         [ +  - ]:        435 :         OSL_FAIL( "Export of graphic is failed!\n" );
     747                 :        435 : }
     748                 :            : 
     749                 :       6906 : uno::Reference< io::XInputStream > EmbeddedObjectRef::GetGraphicReplacementStream(
     750                 :            :                                                                 sal_Int64 nViewAspect,
     751                 :            :                                                                 const uno::Reference< embed::XEmbeddedObject >& xObj,
     752                 :            :                                                                 ::rtl::OUString* pMediaType )
     753                 :            :     throw()
     754                 :            : {
     755                 :       6906 :     return ::comphelper::EmbeddedObjectContainer::GetGraphicReplacementStream(nViewAspect,xObj,pMediaType);
     756                 :            : }
     757                 :            : 
     758                 :        224 : void EmbeddedObjectRef::UpdateReplacementOnDemand()
     759                 :            : {
     760         [ +  + ]:        224 :     DELETEZ( mpImp->pGraphic );
     761                 :        224 :     mpImp->bNeedUpdate = sal_True;
     762                 :        224 :     mpImp->mnGraphicVersion++;
     763                 :            : 
     764         [ +  + ]:        224 :     if( mpImp->pContainer )
     765                 :            :     {
     766                 :            :         //remove graphic from container thus a new up to date one is requested on save
     767                 :        214 :         mpImp->pContainer->RemoveGraphicStream( mpImp->aPersistName );
     768                 :            :     }
     769                 :        224 : }
     770                 :            : 
     771                 :       7652 : sal_Bool EmbeddedObjectRef::IsChart() const
     772                 :            : {
     773                 :            :     //todo maybe for 3.0:
     774                 :            :     //if the changes work good for chart
     775                 :            :     //we should apply them for all own ole objects
     776                 :            : 
     777                 :            :     //#i83708# #i81857# #i79578# request an ole replacement image only if really necessary
     778                 :            :     //as this call can be very expensive and does block the user interface as long at it takes
     779                 :            : 
     780         [ -  + ]:       7652 :     if ( !mxObj.is() )
     781                 :          0 :         return false;
     782                 :            : 
     783 [ +  - ][ +  - ]:       7652 :     SvGlobalName aObjClsId( mxObj->getClassID() );
         [ +  - ][ +  - ]
     784 [ +  - ][ +  - ]:      38260 :     if(
         [ +  - ][ +  + ]
                 [ +  + ]
     785 [ +  - ][ +  - ]:      15304 :         SvGlobalName(SO3_SCH_CLASSID_30) == aObjClsId
         [ +  - ][ +  - ]
                 [ #  # ]
     786 [ +  - ][ +  - ]:      15304 :         || SvGlobalName(SO3_SCH_CLASSID_40) == aObjClsId
         [ +  - ][ +  - ]
                 [ #  # ]
     787 [ +  - ][ +  - ]:      15304 :         || SvGlobalName(SO3_SCH_CLASSID_50) == aObjClsId
         [ +  - ][ +  - ]
                 [ #  # ]
     788 [ +  - ][ +  - ]:      15304 :         || SvGlobalName(SO3_SCH_CLASSID_60) == aObjClsId)
         [ +  - ][ +  - ]
                 [ #  # ]
     789                 :            :     {
     790                 :        408 :         return sal_True;
     791                 :            :     }
     792                 :            : 
     793         [ +  - ]:       7652 :     return sal_False;
     794                 :            : }
     795                 :            : 
     796                 :            : // #i104867#
     797                 :        181 : sal_uInt32 EmbeddedObjectRef::getGraphicVersion() const
     798                 :            : {
     799                 :        181 :     return mpImp->mnGraphicVersion;
     800                 :            : }
     801                 :            : 
     802                 :          0 : void EmbeddedObjectRef::SetDefaultSizeForChart( const Size& rSizeIn_100TH_MM )
     803                 :            : {
     804                 :            :     //#i103460# charts do not necessaryly have an own size within ODF files,
     805                 :            :     //for this case they need to use the size settings from the surrounding frame,
     806                 :            :     //which is made available with this method
     807                 :            : 
     808                 :          0 :     mpImp->aDefaultSizeForChart_In_100TH_MM = awt::Size( rSizeIn_100TH_MM.getWidth(), rSizeIn_100TH_MM.getHeight() );
     809                 :            : 
     810         [ #  # ]:          0 :     uno::Reference < chart2::XDefaultSizeTransmitter > xSizeTransmitter( mxObj, uno::UNO_QUERY );
     811                 :            :     DBG_ASSERT( xSizeTransmitter.is(), "Object does not support XDefaultSizeTransmitter -> will cause #i103460#!" );
     812         [ #  # ]:          0 :     if( xSizeTransmitter.is() )
     813 [ #  # ][ #  # ]:          0 :         xSizeTransmitter->setDefaultSize( mpImp->aDefaultSizeForChart_In_100TH_MM );
     814                 :          0 : }
     815                 :            : 
     816                 :            : } // namespace svt
     817                 :            : 
     818                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10