LCOV - code coverage report
Current view: top level - svx/source/svdraw - svdoole2.cxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 253 868 29.1 %
Date: 2012-08-25 Functions: 44 106 41.5 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 314 2003 15.7 %

           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 <svx/svdoole2.hxx>
      31                 :            : #include <com/sun/star/util/XModifyBroadcaster.hpp>
      32                 :            : #include <com/sun/star/util/XModifiable.hpp>
      33                 :            : #include <com/sun/star/embed/EmbedStates.hpp>
      34                 :            : #include <com/sun/star/embed/ElementModes.hpp>
      35                 :            : #include <com/sun/star/embed/EmbedMisc.hpp>
      36                 :            : #include <com/sun/star/embed/Aspects.hpp>
      37                 :            : #include <com/sun/star/embed/XInplaceClient.hpp>
      38                 :            : #include <com/sun/star/embed/XInplaceObject.hpp>
      39                 :            : #include <com/sun/star/embed/XLinkageSupport.hpp>
      40                 :            : #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
      41                 :            : #include <com/sun/star/embed/XWindowSupplier.hpp>
      42                 :            : #include <com/sun/star/document/XEventListener.hpp>
      43                 :            : #include <com/sun/star/container/XChild.hpp>
      44                 :            : #include "com/sun/star/document/XStorageBasedDocument.hpp"
      45                 :            : 
      46                 :            : #include <comphelper/processfactory.hxx>
      47                 :            : #include <cppuhelper/exc_hlp.hxx>
      48                 :            : #include <unotools/ucbstreamhelper.hxx>
      49                 :            : 
      50                 :            : #include <toolkit/helper/vclunohelper.hxx>
      51                 :            : #include <toolkit/awt/vclxwindow.hxx>
      52                 :            : #include <toolkit/helper/convert.hxx>
      53                 :            : 
      54                 :            : #include <svtools/filter.hxx>
      55                 :            : #include <svtools/embedhlp.hxx>
      56                 :            : 
      57                 :            : #include <sfx2/objsh.hxx>
      58                 :            : #include <sfx2/ipclient.hxx>
      59                 :            : #include <sfx2/lnkbase.hxx>
      60                 :            : #include <tools/stream.hxx>
      61                 :            : #include <comphelper/anytostring.hxx>
      62                 :            : #include <svx/svdpagv.hxx>
      63                 :            : #include <tools/globname.hxx>
      64                 :            : #include <vcl/jobset.hxx>
      65                 :            : #include <sot/clsids.hxx>
      66                 :            : 
      67                 :            : #include <sot/formats.hxx>
      68                 :            : #include <sfx2/linkmgr.hxx>
      69                 :            : #include <svtools/transfer.hxx>
      70                 :            : #include <cppuhelper/implbase5.hxx>
      71                 :            : 
      72                 :            : #include <svl/solar.hrc>
      73                 :            : #include <svl/urihelper.hxx>
      74                 :            : #include <osl/mutex.hxx>
      75                 :            : #include <vcl/svapp.hxx>
      76                 :            : 
      77                 :            : #include <svx/svdmodel.hxx>
      78                 :            : #include "svx/svdglob.hxx"  // Stringcache
      79                 :            : #include "svx/svdstr.hrc"   // the object's name
      80                 :            : #include <svx/svdetc.hxx>
      81                 :            : #include <svx/svdview.hxx>
      82                 :            : #include "unomlstr.hxx"
      83                 :            : #include <svtools/chartprettypainter.hxx>
      84                 :            : #include <svx/sdr/contact/viewcontactofsdrole2obj.hxx>
      85                 :            : #include <svx/svdograf.hxx>
      86                 :            : #include <svx/sdr/properties/oleproperties.hxx>
      87                 :            : 
      88                 :            : // #i100710#
      89                 :            : #include <svx/xlnclit.hxx>
      90                 :            : #include <svx/xbtmpit.hxx>
      91                 :            : #include <svx/xflbmtit.hxx>
      92                 :            : #include <svx/xflbstit.hxx>
      93                 :            : 
      94                 :            : using namespace ::rtl;
      95                 :            : using namespace ::com::sun::star;
      96                 :            : 
      97                 :          0 : uno::Reference < beans::XPropertySet > lcl_getFrame_throw(const SdrOle2Obj* _pObject)
      98                 :            : {
      99                 :          0 :     uno::Reference < beans::XPropertySet > xFrame;
     100         [ #  # ]:          0 :     if ( _pObject )
     101                 :            :     {
     102 [ #  # ][ #  # ]:          0 :         uno::Reference< frame::XController> xController = _pObject->GetParentXModel()->getCurrentController();
                 [ #  # ]
     103         [ #  # ]:          0 :         if ( xController.is() )
     104                 :            :         {
     105 [ #  # ][ #  # ]:          0 :             xFrame.set( xController->getFrame(),uno::UNO_QUERY_THROW);
                 [ #  # ]
     106                 :          0 :         }
     107                 :            :     } // if ( _pObject )
     108                 :          0 :     return xFrame;
     109                 :            : }
     110                 :            : 
     111         [ -  + ]:         54 : class SdrLightEmbeddedClient_Impl : public ::cppu::WeakImplHelper5
     112                 :            :                                                             < embed::XStateChangeListener
     113                 :            :                                                             , document::XEventListener
     114                 :            :                                                             , embed::XInplaceClient
     115                 :            :                                                             , embed::XEmbeddedClient
     116                 :            :                                                             , embed::XWindowSupplier
     117                 :            :                                                             >
     118                 :            : {
     119                 :            :     uno::Reference< awt::XWindow > m_xWindow;
     120                 :            :     SdrOle2Obj* mpObj;
     121                 :            : 
     122                 :            :     Fraction m_aScaleWidth;
     123                 :            :     Fraction m_aScaleHeight;
     124                 :            : 
     125                 :            : 
     126                 :            : public:
     127                 :            :     SdrLightEmbeddedClient_Impl( SdrOle2Obj* pObj );
     128                 :            :     void Release();
     129                 :            : 
     130                 :          0 :     void SetSizeScale( const Fraction& aScaleWidth, const Fraction& aScaleHeight )
     131                 :            :     {
     132                 :          0 :         m_aScaleWidth = aScaleWidth;
     133                 :          0 :         m_aScaleHeight = aScaleHeight;
     134                 :          0 :     }
     135                 :            : 
     136                 :          0 :     Fraction GetScaleWidth() const { return m_aScaleWidth; }
     137                 :          0 :     Fraction GetScaleHeight() const { return m_aScaleHeight; }
     138                 :            : 
     139                 :            :     void setWindow(const uno::Reference< awt::XWindow >& _xWindow);
     140                 :            : 
     141                 :            : private:
     142                 :            :     Rectangle impl_getScaledRect_nothrow() const;
     143                 :            :     // XStateChangeListener
     144                 :            :     virtual void SAL_CALL changingState( const ::com::sun::star::lang::EventObject& aEvent, ::sal_Int32 nOldState, ::sal_Int32 nNewState ) throw (::com::sun::star::embed::WrongStateException, ::com::sun::star::uno::RuntimeException);
     145                 :            :     virtual void SAL_CALL stateChanged( const ::com::sun::star::lang::EventObject& aEvent, ::sal_Int32 nOldState, ::sal_Int32 nNewState ) throw (::com::sun::star::uno::RuntimeException);
     146                 :            :     virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& aEvent ) throw (::com::sun::star::uno::RuntimeException);
     147                 :            : 
     148                 :            :     // document::XEventListener
     149                 :            :     virtual void SAL_CALL       notifyEvent( const document::EventObject& aEvent ) throw( uno::RuntimeException );
     150                 :            : 
     151                 :            :     // XEmbeddedClient
     152                 :            :     virtual void SAL_CALL saveObject() throw ( embed::ObjectSaveVetoException, uno::Exception, uno::RuntimeException );
     153                 :            :     virtual void SAL_CALL visibilityChanged( sal_Bool bVisible ) throw ( embed::WrongStateException, uno::RuntimeException );
     154                 :            : 
     155                 :            :     // XComponentSupplier
     156                 :            :     virtual uno::Reference< util::XCloseable > SAL_CALL getComponent() throw ( uno::RuntimeException );
     157                 :            : 
     158                 :            :     // XInplaceClient
     159                 :            :     virtual sal_Bool SAL_CALL canInplaceActivate() throw ( uno::RuntimeException );
     160                 :            :     virtual void SAL_CALL activatingInplace() throw ( embed::WrongStateException, uno::RuntimeException );
     161                 :            :     virtual void SAL_CALL activatingUI() throw ( embed::WrongStateException, uno::RuntimeException );
     162                 :            :     virtual void SAL_CALL deactivatedInplace() throw ( embed::WrongStateException, uno::RuntimeException );
     163                 :            :     virtual void SAL_CALL deactivatedUI() throw ( embed::WrongStateException, uno::RuntimeException );
     164                 :            :     virtual uno::Reference< ::com::sun::star::frame::XLayoutManager > SAL_CALL getLayoutManager() throw ( embed::WrongStateException, uno::RuntimeException );
     165                 :            :     virtual uno::Reference< frame::XDispatchProvider > SAL_CALL getInplaceDispatchProvider() throw ( embed::WrongStateException, uno::RuntimeException );
     166                 :            :     virtual awt::Rectangle SAL_CALL getPlacement() throw ( embed::WrongStateException, uno::RuntimeException );
     167                 :            :     virtual awt::Rectangle SAL_CALL getClipRectangle() throw ( embed::WrongStateException, uno::RuntimeException );
     168                 :            :     virtual void SAL_CALL translateAccelerators( const uno::Sequence< awt::KeyEvent >& aKeys ) throw ( embed::WrongStateException, uno::RuntimeException );
     169                 :            :     virtual void SAL_CALL scrollObject( const awt::Size& aOffset ) throw ( embed::WrongStateException, uno::RuntimeException );
     170                 :            :     virtual void SAL_CALL changedPlacement( const awt::Rectangle& aPosRect ) throw ( embed::WrongStateException, uno::Exception, uno::RuntimeException );
     171                 :            : 
     172                 :            :     // XWindowSupplier
     173                 :            :     virtual uno::Reference< awt::XWindow > SAL_CALL getWindow() throw ( uno::RuntimeException );
     174                 :            : };
     175                 :            : 
     176                 :            : //--------------------------------------------------------------------
     177                 :         27 : SdrLightEmbeddedClient_Impl::SdrLightEmbeddedClient_Impl( SdrOle2Obj* pObj )
     178                 :         27 : : mpObj( pObj )
     179                 :            : {
     180                 :         27 : }
     181                 :          0 : Rectangle SdrLightEmbeddedClient_Impl::impl_getScaledRect_nothrow() const
     182                 :            : {
     183                 :          0 :     Rectangle aLogicRect( mpObj->GetLogicRect() );
     184                 :            :     // apply scaling to object area and convert to pixels
     185                 :            :     aLogicRect.SetSize( Size( Fraction( aLogicRect.GetWidth() ) * m_aScaleWidth,
     186 [ #  # ][ #  # ]:          0 :                                 Fraction( aLogicRect.GetHeight() ) * m_aScaleHeight ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
     187                 :          0 :     return aLogicRect;
     188                 :            : }
     189                 :            : //--------------------------------------------------------------------
     190                 :          1 : void SAL_CALL SdrLightEmbeddedClient_Impl::changingState( const ::com::sun::star::lang::EventObject& /*aEvent*/, ::sal_Int32 /*nOldState*/, ::sal_Int32 /*nNewState*/ ) throw (::com::sun::star::embed::WrongStateException, ::com::sun::star::uno::RuntimeException)
     191                 :            : {
     192                 :          1 : }
     193                 :            : 
     194                 :            : //--------------------------------------------------------------------
     195                 :         27 : void SdrLightEmbeddedClient_Impl::Release()
     196                 :            : {
     197                 :            :     {
     198         [ +  - ]:         27 :         SolarMutexGuard aGuard;
     199         [ +  - ]:         27 :         mpObj = NULL;
     200                 :            :     }
     201                 :            : 
     202                 :         27 :     release();
     203                 :         27 : }
     204                 :            : 
     205                 :            : //--------------------------------------------------------------------
     206                 :          1 : void SAL_CALL SdrLightEmbeddedClient_Impl::stateChanged( const ::com::sun::star::lang::EventObject& /*aEvent*/, ::sal_Int32 nOldState, ::sal_Int32 nNewState ) throw (::com::sun::star::uno::RuntimeException)
     207                 :            : {
     208         [ +  - ]:          1 :     SolarMutexGuard aGuard;
     209                 :            : 
     210 [ +  - ][ -  + ]:          1 :     if ( mpObj && nOldState == embed::EmbedStates::LOADED && nNewState == embed::EmbedStates::RUNNING )
                 [ #  # ]
     211                 :            :     {
     212         [ #  # ]:          0 :         mpObj->ObjectLoaded();
     213 [ #  # ][ #  # ]:          0 :         GetSdrGlobalData().GetOLEObjCache().InsertObj(mpObj);
     214                 :            :     }
     215 [ +  - ][ +  - ]:          1 :     else if ( mpObj && nNewState == embed::EmbedStates::LOADED && nOldState == embed::EmbedStates::RUNNING )
                 [ +  - ]
     216                 :            :     {
     217 [ +  - ][ +  - ]:          1 :         GetSdrGlobalData().GetOLEObjCache().RemoveObj(mpObj);
     218         [ +  - ]:          1 :     }
     219                 :          1 : }
     220                 :            : 
     221                 :            : //--------------------------------------------------------------------
     222                 :          0 : void SAL_CALL SdrLightEmbeddedClient_Impl::disposing( const ::com::sun::star::lang::EventObject& /*aEvent*/ ) throw (::com::sun::star::uno::RuntimeException)
     223                 :            : {
     224         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     225                 :            : 
     226 [ #  # ][ #  # ]:          0 :     GetSdrGlobalData().GetOLEObjCache().RemoveObj(mpObj);
                 [ #  # ]
     227                 :          0 : }
     228                 :            : 
     229                 :            : //--------------------------------------------------------------------
     230                 :        198 : void SAL_CALL SdrLightEmbeddedClient_Impl::notifyEvent( const document::EventObject& aEvent ) throw( uno::RuntimeException )
     231                 :            : {
     232                 :            :     // TODO/LATER: when writer uses this implementation the code could be shared with SfxInPlaceClient_Impl
     233                 :            : 
     234         [ +  - ]:        198 :     SolarMutexGuard aGuard;
     235                 :            : 
     236                 :            :     // the code currently makes sense only in case there is no other client
     237 [ +  - ][ +  - ]:        764 :     if ( mpObj && mpObj->GetAspect() != embed::Aspects::MSOLE_ICON && aEvent.EventName == "OnVisAreaChanged"
                 [ +  - ]
           [ +  +  +  - ]
         [ -  + ][ -  + ]
     238 [ +  - ][ +  - ]:        566 :       && mpObj->GetObjRef().is() && mpObj->GetObjRef()->getClientSite() == uno::Reference< embed::XEmbeddedClient >( this ) )
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ +  + ][ +  + ]
         [ +  + ][ +  + ]
           [ #  #  #  #  
             #  #  #  # ]
     239                 :            :     {
     240                 :            :         try
     241                 :            :         {
     242                 :          0 :             MapUnit aContainerMapUnit( MAP_100TH_MM );
     243 [ #  # ][ #  # ]:          0 :             uno::Reference< embed::XVisualObject > xParentVis( mpObj->GetParentXModel(), uno::UNO_QUERY );
     244         [ #  # ]:          0 :             if ( xParentVis.is() )
     245 [ #  # ][ #  # ]:          0 :                 aContainerMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xParentVis->getMapUnit( mpObj->GetAspect() ) );
         [ #  # ][ #  # ]
     246                 :            : 
     247 [ #  # ][ #  # ]:          0 :             MapUnit aObjMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( mpObj->GetObjRef()->getMapUnit( mpObj->GetAspect() ) );
         [ #  # ][ #  # ]
                 [ #  # ]
     248                 :            : 
     249         [ #  # ]:          0 :             Rectangle          aVisArea;
     250                 :          0 :             awt::Size aSz;
     251                 :            :             try
     252                 :            :             {
     253 [ #  # ][ #  # ]:          0 :                 aSz = mpObj->GetObjRef()->getVisualAreaSize( mpObj->GetAspect() );
                 [ #  # ]
              [ #  #  # ]
                 [ #  # ]
     254                 :            :             }
     255         [ #  # ]:          0 :             catch( embed::NoVisualAreaSizeException& )
     256                 :            :             {
     257                 :            :                 OSL_FAIL( "No visual area size!\n" );
     258                 :          0 :                 aSz.Width = 5000;
     259                 :          0 :                 aSz.Height = 5000;
     260                 :            :             }
     261         [ #  # ]:          0 :             catch( uno::Exception& )
     262                 :            :             {
     263                 :            :                 OSL_FAIL( "Unexpected exception!\n" );
     264                 :          0 :                 aSz.Width = 5000;
     265                 :          0 :                 aSz.Height = 5000;
     266                 :            :             }
     267                 :            : 
     268         [ #  # ]:          0 :             aVisArea.SetSize( Size( aSz.Width, aSz.Height ) );
     269 [ #  # ][ #  # ]:          0 :             aVisArea = OutputDevice::LogicToLogic( aVisArea, aObjMapUnit, aContainerMapUnit );
         [ #  # ][ #  # ]
                 [ #  # ]
     270                 :            :             Size aScaledSize( static_cast< long >( m_aScaleWidth * Fraction( aVisArea.GetWidth() ) ),
     271 [ #  # ][ #  # ]:          0 :                                 static_cast< long >( m_aScaleHeight * Fraction( aVisArea.GetHeight() ) ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     272         [ #  # ]:          0 :             Rectangle aLogicRect( mpObj->GetLogicRect() );
     273                 :            : 
     274                 :            :             // react to the change if the difference is bigger than one pixel
     275                 :            :             Size aPixelDiff =
     276                 :            :                 Application::GetDefaultDevice()->LogicToPixel(
     277         [ #  # ]:          0 :                     Size( aLogicRect.GetWidth() - aScaledSize.Width(),
     278         [ #  # ]:          0 :                           aLogicRect.GetHeight() - aScaledSize.Height() ),
     279   [ #  #  #  # ]:          0 :                     aContainerMapUnit );
         [ #  # ][ #  # ]
     280 [ #  # ][ #  # ]:          0 :             if( aPixelDiff.Width() || aPixelDiff.Height() )
                 [ #  # ]
     281                 :            :             {
     282 [ #  # ][ #  # ]:          0 :                 mpObj->SetLogicRect( Rectangle( aLogicRect.TopLeft(), aScaledSize ) );
     283         [ #  # ]:          0 :                 mpObj->BroadcastObjectChange();
     284                 :            :             }
     285                 :            :             else
     286 [ #  # ][ #  # ]:          0 :                 mpObj->ActionChanged();
     287                 :            :         }
     288         [ #  # ]:          0 :         catch( uno::Exception& )
     289                 :            :         {
     290                 :            :             OSL_FAIL( "Unexpected exception!\n" );
     291                 :            :         }
     292         [ +  - ]:        198 :     }
     293                 :        198 : }
     294                 :            : 
     295                 :            : //--------------------------------------------------------------------
     296                 :          0 : void SAL_CALL SdrLightEmbeddedClient_Impl::saveObject()
     297                 :            :     throw ( embed::ObjectSaveVetoException,
     298                 :            :             uno::Exception,
     299                 :            :             uno::RuntimeException )
     300                 :            : {
     301                 :            :     // TODO/LATER: when writer uses this implementation the code could be shared with SfxInPlaceClient_Impl
     302                 :          0 :     uno::Reference< embed::XCommonEmbedPersist > xPersist;
     303                 :          0 :     uno::Reference< util::XModifiable > xModifiable;
     304                 :            : 
     305                 :            :     {
     306         [ #  # ]:          0 :         SolarMutexGuard aGuard;
     307                 :            : 
     308         [ #  # ]:          0 :         if ( !mpObj )
     309         [ #  # ]:          0 :             throw embed::ObjectSaveVetoException();
     310                 :            : 
     311                 :            :         // the common persistence is supported by objects and links
     312 [ #  # ][ #  # ]:          0 :         xPersist = uno::Reference< embed::XCommonEmbedPersist >( mpObj->GetObjRef(), uno::UNO_QUERY_THROW );
                 [ #  # ]
     313 [ #  # ][ #  # ]:          0 :         xModifiable = uno::Reference< util::XModifiable >( mpObj->GetParentXModel(), uno::UNO_QUERY );
         [ #  # ][ #  # ]
     314                 :            :     }
     315                 :            : 
     316 [ #  # ][ #  # ]:          0 :     xPersist->storeOwn();
     317                 :            : 
     318         [ #  # ]:          0 :     if ( xModifiable.is() )
     319 [ #  # ][ #  # ]:          0 :         xModifiable->setModified( sal_True );
     320                 :          0 : }
     321                 :            : 
     322                 :            : //--------------------------------------------------------------------
     323                 :          0 : void SAL_CALL SdrLightEmbeddedClient_Impl::visibilityChanged( sal_Bool /*bVisible*/ )
     324                 :            :     throw ( embed::WrongStateException,
     325                 :            :             uno::RuntimeException )
     326                 :            : {
     327                 :            :     // nothing to do currently
     328                 :            :     // TODO/LATER: when writer uses this implementation the code could be shared with SfxInPlaceClient_Impl
     329         [ #  # ]:          0 :     if ( mpObj )
     330                 :            :     {
     331         [ #  # ]:          0 :         Rectangle aLogicRect( mpObj->GetLogicRect() );
     332 [ #  # ][ #  # ]:          0 :         Size aLogicSize( aLogicRect.GetWidth(), aLogicRect.GetHeight() );
     333                 :            : 
     334 [ #  # ][ #  # ]:          0 :         if( mpObj->IsChart() )
     335                 :            :         {
     336                 :            :             //charts never should be stretched see #i84323# for example
     337 [ #  # ][ #  # ]:          0 :             mpObj->SetLogicRect( Rectangle( aLogicRect.TopLeft(), aLogicSize ) );
     338         [ #  # ]:          0 :             mpObj->BroadcastObjectChange();
     339                 :            :         } // if( mpObj->IsChart() )
     340                 :            :     }
     341                 :          0 : }
     342                 :            : 
     343                 :            : //--------------------------------------------------------------------
     344                 :          0 : uno::Reference< util::XCloseable > SAL_CALL SdrLightEmbeddedClient_Impl::getComponent()
     345                 :            :     throw ( uno::RuntimeException )
     346                 :            : {
     347                 :          0 :     uno::Reference< util::XCloseable > xResult;
     348                 :            : 
     349         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     350         [ #  # ]:          0 :     if ( mpObj )
     351 [ #  # ][ #  # ]:          0 :         xResult = uno::Reference< util::XCloseable >( mpObj->GetParentXModel(), uno::UNO_QUERY );
                 [ #  # ]
     352                 :            : 
     353         [ #  # ]:          0 :     return xResult;
     354                 :            : }
     355                 :            : // XInplaceClient
     356                 :            : //--------------------------------------------------------------------
     357                 :          0 : sal_Bool SAL_CALL SdrLightEmbeddedClient_Impl::canInplaceActivate()
     358                 :            :     throw ( uno::RuntimeException )
     359                 :            : {
     360                 :          0 :     sal_Bool bRet = sal_False;
     361         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     362         [ #  # ]:          0 :     if ( mpObj )
     363                 :            :     {
     364         [ #  # ]:          0 :         uno::Reference< embed::XEmbeddedObject > xObject = mpObj->GetObjRef();
     365         [ #  # ]:          0 :         if ( !xObject.is() )
     366         [ #  # ]:          0 :             throw uno::RuntimeException();
     367                 :            :         // we don't want to switch directly from outplace to inplace mode
     368 [ #  # ][ #  # ]:          0 :         bRet = !( xObject->getCurrentState() == embed::EmbedStates::ACTIVE || mpObj->GetAspect() == embed::Aspects::MSOLE_ICON );
         [ #  # ][ #  # ]
                 [ #  # ]
     369                 :            :     } // if ( mpObj )
     370         [ #  # ]:          0 :     return bRet;
     371                 :            : }
     372                 :            : 
     373                 :            : //--------------------------------------------------------------------
     374                 :          0 : void SAL_CALL SdrLightEmbeddedClient_Impl::activatingInplace()
     375                 :            :     throw ( embed::WrongStateException,
     376                 :            :             uno::RuntimeException )
     377                 :            : {
     378                 :          0 : }
     379                 :            : 
     380                 :            : //--------------------------------------------------------------------
     381                 :          0 : void SAL_CALL SdrLightEmbeddedClient_Impl::activatingUI()
     382                 :            :     throw ( embed::WrongStateException,
     383                 :            :             uno::RuntimeException )
     384                 :            : {
     385         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     386                 :            : 
     387         [ #  # ]:          0 :     uno::Reference < beans::XPropertySet > xFrame( lcl_getFrame_throw(mpObj));
     388         [ #  # ]:          0 :     uno::Reference < frame::XFrame > xOwnFrame( xFrame,uno::UNO_QUERY);
     389 [ #  # ][ #  # ]:          0 :     uno::Reference < frame::XFramesSupplier > xParentFrame( xOwnFrame->getCreator(), uno::UNO_QUERY );
                 [ #  # ]
     390         [ #  # ]:          0 :     if ( xParentFrame.is() )
     391 [ #  # ][ #  # ]:          0 :         xParentFrame->setActiveFrame( xOwnFrame );
     392                 :            : 
     393         [ #  # ]:          0 :     OLEObjCache& rObjCache = GetSdrGlobalData().GetOLEObjCache();
     394                 :          0 :     const sal_uIntPtr nCount = rObjCache.size();
     395         [ #  # ]:          0 :     for(sal_Int32 i = nCount-1 ; i >= 0;--i)
     396                 :            :     {
     397         [ #  # ]:          0 :         SdrOle2Obj* pObj = rObjCache[i];
     398         [ #  # ]:          0 :         if ( pObj != mpObj )
     399                 :            :         {
     400                 :            :             // only deactivate ole objects which belongs to the same frame
     401 [ #  # ][ #  # ]:          0 :             if ( xFrame == lcl_getFrame_throw(pObj) )
                 [ #  # ]
     402                 :            :             {
     403         [ #  # ]:          0 :                 uno::Reference< embed::XEmbeddedObject > xObject = pObj->GetObjRef();
     404                 :            :                 try
     405                 :            :                 {
     406 [ #  # ][ #  # ]:          0 :                     if ( xObject->getStatus( pObj->GetAspect() ) & embed::EmbedMisc::MS_EMBED_ACTIVATEWHENVISIBLE )
         [ #  # ][ #  # ]
     407 [ #  # ][ #  # ]:          0 :                         xObject->changeState( embed::EmbedStates::INPLACE_ACTIVE );
     408                 :            :                     else
     409                 :            :                     {
     410                 :            :                         // the links should not stay in running state for long time because of locking
     411         [ #  # ]:          0 :                         uno::Reference< embed::XLinkageSupport > xLink( xObject, uno::UNO_QUERY );
     412 [ #  # ][ #  # ]:          0 :                         if ( xLink.is() && xLink->isLink() )
         [ #  # ][ #  # ]
                 [ #  # ]
     413 [ #  # ][ #  # ]:          0 :                             xObject->changeState( embed::EmbedStates::LOADED );
     414                 :            :                         else
     415 [ #  # ][ #  # ]:          0 :                             xObject->changeState( embed::EmbedStates::RUNNING );
                 [ #  # ]
     416                 :            :                     }
     417                 :            :                 }
     418         [ #  # ]:          0 :                 catch (com::sun::star::uno::Exception& )
     419                 :          0 :                 {}
     420                 :            :             }
     421                 :            :         }
     422         [ #  # ]:          0 :     } // for(sal_Int32 i = nCount-1 ; i >= 0;--i)
     423                 :          0 : }
     424                 :            : 
     425                 :            : //--------------------------------------------------------------------
     426                 :          0 : void SAL_CALL SdrLightEmbeddedClient_Impl::deactivatedInplace()
     427                 :            :     throw ( embed::WrongStateException,
     428                 :            :             uno::RuntimeException )
     429                 :            : {
     430                 :          0 : }
     431                 :            : 
     432                 :            : //--------------------------------------------------------------------
     433                 :          0 : void SAL_CALL SdrLightEmbeddedClient_Impl::deactivatedUI()
     434                 :            :     throw ( embed::WrongStateException,
     435                 :            :             uno::RuntimeException )
     436                 :            : {
     437         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     438         [ #  # ]:          0 :     com::sun::star::uno::Reference< ::com::sun::star::frame::XLayoutManager > xLayoutManager(getLayoutManager());
     439         [ #  # ]:          0 :     if ( xLayoutManager.is() )
     440                 :            :     {
     441 [ #  # ][ #  # ]:          0 :         const static rtl::OUString aMenuBarURL(  "private:resource/menubar/menubar" );
     442 [ #  # ][ #  # ]:          0 :         if ( !xLayoutManager->isElementVisible( aMenuBarURL ) )
                 [ #  # ]
     443 [ #  # ][ #  # ]:          0 :             xLayoutManager->createElement( aMenuBarURL );
     444         [ #  # ]:          0 :     }
     445                 :          0 : }
     446                 :            : 
     447                 :            : //--------------------------------------------------------------------
     448                 :          0 : uno::Reference< ::com::sun::star::frame::XLayoutManager > SAL_CALL SdrLightEmbeddedClient_Impl::getLayoutManager()
     449                 :            :     throw ( embed::WrongStateException,
     450                 :            :             uno::RuntimeException )
     451                 :            : {
     452                 :          0 :     uno::Reference< ::com::sun::star::frame::XLayoutManager > xMan;
     453         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     454         [ #  # ]:          0 :     uno::Reference < beans::XPropertySet > xFrame( lcl_getFrame_throw(mpObj));
     455                 :            :     try
     456                 :            :     {
     457 [ #  # ][ #  # ]:          0 :         xMan.set(xFrame->getPropertyValue( ::rtl::OUString("LayoutManager") ),uno::UNO_QUERY);
                 [ #  # ]
     458                 :            :     }
     459         [ #  # ]:          0 :     catch ( uno::Exception& )
     460                 :            :     {
     461         [ #  # ]:          0 :         throw uno::RuntimeException();
     462                 :            :     }
     463                 :            : 
     464         [ #  # ]:          0 :     return xMan;
     465                 :            : }
     466                 :            : 
     467                 :            : //--------------------------------------------------------------------
     468                 :          0 : uno::Reference< frame::XDispatchProvider > SAL_CALL SdrLightEmbeddedClient_Impl::getInplaceDispatchProvider()
     469                 :            :     throw ( embed::WrongStateException,
     470                 :            :             uno::RuntimeException )
     471                 :            : {
     472         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     473 [ #  # ][ #  # ]:          0 :     return uno::Reference < frame::XDispatchProvider >( lcl_getFrame_throw(mpObj), uno::UNO_QUERY_THROW );
                 [ #  # ]
     474                 :            : }
     475                 :            : 
     476                 :            : //--------------------------------------------------------------------
     477                 :          0 : awt::Rectangle SAL_CALL SdrLightEmbeddedClient_Impl::getPlacement()
     478                 :            :     throw ( embed::WrongStateException,
     479                 :            :             uno::RuntimeException )
     480                 :            : {
     481         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     482         [ #  # ]:          0 :     if ( !mpObj )
     483         [ #  # ]:          0 :         throw uno::RuntimeException();
     484                 :            : 
     485         [ #  # ]:          0 :     Rectangle aLogicRect = impl_getScaledRect_nothrow();
     486                 :          0 :     MapUnit aContainerMapUnit( MAP_100TH_MM );
     487 [ #  # ][ #  # ]:          0 :     uno::Reference< embed::XVisualObject > xParentVis( mpObj->GetParentXModel(), uno::UNO_QUERY );
     488         [ #  # ]:          0 :     if ( xParentVis.is() )
     489 [ #  # ][ #  # ]:          0 :         aContainerMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xParentVis->getMapUnit( mpObj->GetAspect() ) );
         [ #  # ][ #  # ]
     490                 :            : 
     491 [ #  # ][ #  # ]:          0 :     aLogicRect = Application::GetDefaultDevice()->LogicToPixel(aLogicRect,aContainerMapUnit);
         [ #  # ][ #  # ]
     492 [ #  # ][ #  # ]:          0 :     return AWTRectangle( aLogicRect );
     493                 :            : }
     494                 :            : 
     495                 :            : //--------------------------------------------------------------------
     496                 :          0 : awt::Rectangle SAL_CALL SdrLightEmbeddedClient_Impl::getClipRectangle()
     497                 :            :     throw ( embed::WrongStateException,
     498                 :            :             uno::RuntimeException )
     499                 :            : {
     500                 :          0 :     return getPlacement();
     501                 :            : }
     502                 :            : 
     503                 :            : //--------------------------------------------------------------------
     504                 :          0 : void SAL_CALL SdrLightEmbeddedClient_Impl::translateAccelerators( const uno::Sequence< awt::KeyEvent >& /*aKeys*/ )
     505                 :            :     throw ( embed::WrongStateException,
     506                 :            :             uno::RuntimeException )
     507                 :            : {
     508                 :          0 : }
     509                 :            : 
     510                 :            : //--------------------------------------------------------------------
     511                 :          0 : void SAL_CALL SdrLightEmbeddedClient_Impl::scrollObject( const awt::Size& /*aOffset*/ )
     512                 :            :     throw ( embed::WrongStateException,
     513                 :            :             uno::RuntimeException )
     514                 :            : {
     515                 :          0 : }
     516                 :            : 
     517                 :            : //--------------------------------------------------------------------
     518                 :          0 : void SAL_CALL SdrLightEmbeddedClient_Impl::changedPlacement( const awt::Rectangle& aPosRect )
     519                 :            :     throw ( embed::WrongStateException,
     520                 :            :             uno::Exception,
     521                 :            :             uno::RuntimeException )
     522                 :            : {
     523         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     524         [ #  # ]:          0 :     if ( !mpObj )
     525         [ #  # ]:          0 :         throw uno::RuntimeException();
     526                 :            : 
     527 [ #  # ][ #  # ]:          0 :     uno::Reference< embed::XInplaceObject > xInplace( mpObj->GetObjRef(), uno::UNO_QUERY );
     528         [ #  # ]:          0 :     if ( !xInplace.is() )
     529         [ #  # ]:          0 :         throw uno::RuntimeException();
     530                 :            : 
     531                 :            :     // check if the change is at least one pixel in size
     532         [ #  # ]:          0 :     awt::Rectangle aOldRect = getPlacement();
     533         [ #  # ]:          0 :     Rectangle aNewPixelRect = VCLRectangle( aPosRect );
     534         [ #  # ]:          0 :     Rectangle aOldPixelRect = VCLRectangle( aOldRect );
     535 [ #  # ][ #  # ]:          0 :     if ( aOldPixelRect == aNewPixelRect )
     536                 :            :         // nothing has changed
     537                 :          0 :         return;
     538                 :            : 
     539                 :            :     // new scaled object area
     540                 :          0 :     MapUnit aContainerMapUnit( MAP_100TH_MM );
     541 [ #  # ][ #  # ]:          0 :     uno::Reference< embed::XVisualObject > xParentVis( mpObj->GetParentXModel(), uno::UNO_QUERY );
     542         [ #  # ]:          0 :     if ( xParentVis.is() )
     543 [ #  # ][ #  # ]:          0 :         aContainerMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xParentVis->getMapUnit( mpObj->GetAspect() ) );
         [ #  # ][ #  # ]
     544                 :            : 
     545 [ #  # ][ #  # ]:          0 :     Rectangle aNewLogicRect = Application::GetDefaultDevice()->PixelToLogic(aNewPixelRect,aContainerMapUnit);
         [ #  # ][ #  # ]
     546         [ #  # ]:          0 :     Rectangle aLogicRect = impl_getScaledRect_nothrow();
     547                 :            : 
     548 [ #  # ][ #  # ]:          0 :     if ( aNewLogicRect != aLogicRect )
     549                 :            :     {
     550                 :            :         // the calculation of the object area has not changed the object size
     551                 :            :         // it should be done here then
     552                 :            :         //SfxBooleanFlagGuard aGuard( m_bResizeNoScale, sal_True );
     553                 :            : 
     554                 :            :         // new size of the object area without scaling
     555                 :            :         Size aNewObjSize( Fraction( aNewLogicRect.GetWidth() ) / m_aScaleWidth,
     556 [ #  # ][ #  # ]:          0 :                           Fraction( aNewLogicRect.GetHeight() ) / m_aScaleHeight );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
     557                 :            : 
     558                 :            :         // now remove scaling from new placement and keep this a the new object area
     559         [ #  # ]:          0 :         aNewLogicRect.SetSize( aNewObjSize );
     560                 :            :         // react to the change if the difference is bigger than one pixel
     561                 :            :         Size aPixelDiff =
     562                 :            :             Application::GetDefaultDevice()->LogicToPixel(
     563         [ #  # ]:          0 :                 Size( aLogicRect.GetWidth() - aNewObjSize.Width(),
     564         [ #  # ]:          0 :                       aLogicRect.GetHeight() - aNewObjSize.Height() ),
     565   [ #  #  #  # ]:          0 :                 aContainerMapUnit );
         [ #  # ][ #  # ]
     566 [ #  # ][ #  # ]:          0 :         if( aPixelDiff.Width() || aPixelDiff.Height() )
                 [ #  # ]
     567                 :            :         {
     568 [ #  # ][ #  # ]:          0 :             mpObj->SetLogicRect( Rectangle( aLogicRect.TopLeft(), aNewObjSize ) );
     569         [ #  # ]:          0 :             mpObj->BroadcastObjectChange();
     570                 :            :         }
     571                 :            :         else
     572         [ #  # ]:          0 :             mpObj->ActionChanged();
     573 [ #  # ][ #  # ]:          0 :     }
                 [ #  # ]
     574                 :            : }
     575                 :            : // XWindowSupplier
     576                 :            : //--------------------------------------------------------------------
     577                 :          0 : uno::Reference< awt::XWindow > SAL_CALL SdrLightEmbeddedClient_Impl::getWindow()
     578                 :            :     throw ( uno::RuntimeException )
     579                 :            : {
     580         [ #  # ]:          0 :     SolarMutexGuard aGuard;
     581                 :          0 :     uno::Reference< awt::XWindow > xCurrent = m_xWindow;
     582         [ #  # ]:          0 :     if ( !xCurrent.is() )
     583                 :            :     {
     584         [ #  # ]:          0 :         if ( !mpObj )
     585         [ #  # ]:          0 :             throw uno::RuntimeException();
     586 [ #  # ][ #  # ]:          0 :         uno::Reference< frame::XFrame> xFrame(lcl_getFrame_throw(mpObj),uno::UNO_QUERY_THROW);
     587 [ #  # ][ #  # ]:          0 :         xCurrent = xFrame->getComponentWindow();
                 [ #  # ]
     588                 :            :     } // if ( !xCurrent.is() )
     589         [ #  # ]:          0 :     return xCurrent;
     590                 :            : }
     591                 :          0 : void SdrLightEmbeddedClient_Impl::setWindow(const uno::Reference< awt::XWindow >& _xWindow)
     592                 :            : {
     593                 :          0 :     m_xWindow = _xWindow;
     594                 :          0 : }
     595                 :            : 
     596                 :            : ////////////////////////////////////////////////////////////////////////////////////////////////////
     597                 :            : 
     598                 :            : class SdrEmbedObjectLink : public sfx2::SvBaseLink
     599                 :            : {
     600                 :            :     SdrOle2Obj*         pObj;
     601                 :            : 
     602                 :            : public:
     603                 :            :                         SdrEmbedObjectLink(SdrOle2Obj* pObj);
     604                 :            :     virtual             ~SdrEmbedObjectLink();
     605                 :            : 
     606                 :            :     virtual void        Closed();
     607                 :            :     virtual ::sfx2::SvBaseLink::UpdateResult DataChanged(
     608                 :            :         const String& rMimeType, const ::com::sun::star::uno::Any & rValue );
     609                 :            : 
     610                 :          0 :     sal_Bool            Connect() { return GetRealObject() != NULL; }
     611                 :            : };
     612                 :            : 
     613                 :            : // -----------------------------------------------------------------------------
     614                 :            : 
     615                 :          0 : SdrEmbedObjectLink::SdrEmbedObjectLink(SdrOle2Obj* pObject):
     616                 :            :     ::sfx2::SvBaseLink( ::sfx2::LINKUPDATE_ONCALL, SOT_FORMATSTR_ID_SVXB ),
     617                 :          0 :     pObj(pObject)
     618                 :            : {
     619                 :          0 :     SetSynchron( sal_False );
     620                 :          0 : }
     621                 :            : 
     622                 :            : // -----------------------------------------------------------------------------
     623                 :            : 
     624                 :          0 : SdrEmbedObjectLink::~SdrEmbedObjectLink()
     625                 :            : {
     626         [ #  # ]:          0 : }
     627                 :            : 
     628                 :            : // -----------------------------------------------------------------------------
     629                 :            : 
     630                 :          0 : ::sfx2::SvBaseLink::UpdateResult SdrEmbedObjectLink::DataChanged(
     631                 :            :     const String& /*rMimeType*/, const ::com::sun::star::uno::Any & /*rValue*/ )
     632                 :            : {
     633         [ #  # ]:          0 :     if ( !pObj->UpdateLinkURL_Impl() )
     634                 :            :     {
     635                 :            :         // the link URL was not changed
     636         [ #  # ]:          0 :         uno::Reference< embed::XEmbeddedObject > xObject = pObj->GetObjRef();
     637                 :            :         OSL_ENSURE( xObject.is(), "The object must exist always!\n" );
     638         [ #  # ]:          0 :         if ( xObject.is() )
     639                 :            :         {
     640                 :            :             // let the object reload the link
     641                 :            :             // TODO/LATER: reload call could be used for this case
     642                 :            : 
     643                 :            :             try
     644                 :            :             {
     645 [ #  # ][ #  # ]:          0 :                 sal_Int32 nState = xObject->getCurrentState();
     646         [ #  # ]:          0 :                 if ( nState != embed::EmbedStates::LOADED )
     647                 :            :                 {
     648                 :            :                     // in some cases the linked file probably is not locked so it could be changed
     649 [ #  # ][ #  # ]:          0 :                     xObject->changeState( embed::EmbedStates::LOADED );
     650 [ #  # ][ #  # ]:          0 :                     xObject->changeState( nState );
     651                 :            :                 }
     652                 :            :             }
     653         [ #  # ]:          0 :             catch ( uno::Exception& )
     654                 :            :             {
     655                 :            :             }
     656                 :          0 :         }
     657                 :            :     }
     658                 :            : 
     659                 :          0 :     pObj->GetNewReplacement();
     660                 :          0 :     pObj->SetChanged();
     661                 :            : 
     662         [ #  # ]:          0 :     return SUCCESS;
     663                 :            : }
     664                 :            : 
     665                 :            : // -----------------------------------------------------------------------------
     666                 :            : 
     667                 :          0 : void SdrEmbedObjectLink::Closed()
     668                 :            : {
     669                 :          0 :     pObj->BreakFileLink_Impl();
     670                 :          0 :     SvBaseLink::Closed();
     671                 :          0 : }
     672                 :            : 
     673                 :            : ////////////////////////////////////////////////////////////////////////////////////////////////////
     674                 :            : 
     675         [ +  - ]:         27 : class SdrOle2ObjImpl
     676                 :            : {
     677                 :            : public:
     678                 :            :     // TODO/LATER: do we really need this pointer?
     679                 :            :     GraphicObject*  pGraphicObject;
     680                 :            :     String          aPersistName;       // name of object in persist
     681                 :            :     SdrLightEmbeddedClient_Impl* pLightClient; // must be registered as client only using AddOwnLightClient() call
     682                 :            : 
     683                 :            :     // New local var to avoid repeated loading if load of OLE2 fails
     684                 :            :     sal_Bool        mbLoadingOLEObjectFailed;
     685                 :            :     sal_Bool        mbConnected;
     686                 :            : 
     687                 :            :     SdrEmbedObjectLink* mpObjectLink;
     688                 :            :     String maLinkURL;
     689                 :            : 
     690                 :         27 :     SdrOle2ObjImpl()
     691                 :            :     : pGraphicObject( NULL )
     692                 :            :     , pLightClient ( NULL )
     693                 :            :     // init to start situation, loading did not fail
     694                 :            :     , mbLoadingOLEObjectFailed( sal_False )
     695                 :            :     , mbConnected( sal_False )
     696         [ +  - ]:         27 :     , mpObjectLink( NULL )
     697                 :            :     {
     698                 :         27 :     }
     699                 :            : };
     700                 :            : 
     701                 :            : ////////////////////////////////////////////////////////////////////////////////////////////////////
     702                 :            : 
     703                 :            : // Predicate determining whether the given OLE is an internal math
     704                 :            : // object
     705                 :         25 : static bool ImplIsMathObj( const uno::Reference < embed::XEmbeddedObject >& rObjRef )
     706                 :            : {
     707         [ -  + ]:         25 :     if ( !rObjRef.is() )
     708                 :          0 :         return false;
     709                 :            : 
     710 [ +  - ][ +  - ]:         25 :     SvGlobalName aClassName( rObjRef->getClassID() );
         [ +  - ][ +  - ]
     711 [ +  - ][ +  - ]:        150 :     if( aClassName == SvGlobalName(SO3_SM_CLASSID_30) ||
         [ +  - ][ +  - ]
         [ +  - ][ +  - ]
         [ -  + ][ +  - ]
                 [ +  - ]
           [ -  +  #  # ]
     712 [ +  - ][ +  - ]:         50 :         aClassName == SvGlobalName(SO3_SM_CLASSID_40) ||
         [ +  - ][ +  - ]
                 [ #  # ]
     713 [ +  - ][ +  - ]:         50 :         aClassName == SvGlobalName(SO3_SM_CLASSID_50) ||
         [ +  - ][ +  - ]
                 [ #  # ]
     714 [ +  - ][ +  - ]:         50 :         aClassName == SvGlobalName(SO3_SM_CLASSID_60) ||
         [ +  - ][ +  - ]
                 [ #  # ]
     715 [ +  - ][ +  - ]:         50 :         aClassName == SvGlobalName(SO3_SM_CLASSID)      )
         [ +  - ][ +  - ]
                 [ #  # ]
     716                 :            :     {
     717                 :          0 :         return true;
     718                 :            :     }
     719                 :            :     else
     720                 :            :     {
     721                 :         25 :         return false;
     722         [ +  - ]:         25 :     }
     723                 :            : }
     724                 :            : 
     725                 :            : //////////////////////////////////////////////////////////////////////////////
     726                 :            : // BaseProperties section
     727                 :            : 
     728                 :         27 : sdr::properties::BaseProperties* SdrOle2Obj::CreateObjectSpecificProperties()
     729                 :            : {
     730         [ +  - ]:         27 :     return new sdr::properties::OleProperties(*this);
     731                 :            : }
     732                 :            : 
     733                 :            : //////////////////////////////////////////////////////////////////////////////
     734                 :            : // DrawContact section
     735                 :            : 
     736                 :         27 : sdr::contact::ViewContact* SdrOle2Obj::CreateObjectSpecificViewContact()
     737                 :            : {
     738         [ +  - ]:         27 :     return new sdr::contact::ViewContactOfSdrOle2Obj(*this);
     739                 :            : }
     740                 :            : 
     741                 :            : // -----------------------------------------------------------------------------
     742                 :            : 
     743 [ +  + ][ +  + ]:       4484 : TYPEINIT1(SdrOle2Obj,SdrRectObj);
     744                 :            : DBG_NAME(SdrOle2Obj)
     745                 :          2 : SdrOle2Obj::SdrOle2Obj(bool bFrame_) : m_bTypeAsked(false)
     746 [ +  - ][ +  - ]:          2 : ,m_bChart(false)
     747                 :            : {
     748                 :            :     DBG_CTOR( SdrOle2Obj,NULL);
     749                 :          2 :     bInDestruction = false;
     750         [ +  - ]:          2 :     Init();
     751                 :          2 :     bFrame=bFrame_;
     752                 :          2 : }
     753                 :            : 
     754                 :            : // -----------------------------------------------------------------------------
     755                 :            : 
     756                 :         25 : SdrOle2Obj::SdrOle2Obj( const svt::EmbeddedObjectRef&  rNewObjRef, const XubString& rNewObjName, const Rectangle& rNewRect, bool bFrame_)
     757                 :            :     : SdrRectObj(rNewRect)
     758                 :            :     , xObjRef( rNewObjRef )
     759                 :            :     , m_bTypeAsked(false)
     760 [ +  - ][ +  - ]:         25 :     , m_bChart(false)
     761                 :            : {
     762                 :            :     DBG_CTOR( SdrOle2Obj,NULL);
     763                 :         25 :     bInDestruction = false;
     764         [ +  - ]:         25 :     Init();
     765                 :            : 
     766         [ +  - ]:         25 :     mpImpl->aPersistName = rNewObjName;
     767                 :         25 :     bFrame=bFrame_;
     768                 :            : 
     769 [ +  - ][ +  - ]:         25 :     if ( xObjRef.is() && (xObjRef->getStatus( GetAspect() ) & embed::EmbedMisc::EMBED_NEVERRESIZE ) )
         [ +  - ][ +  - ]
         [ -  + ][ -  + ]
     770         [ #  # ]:          0 :         SetResizeProtect(sal_True);
     771                 :            : 
     772                 :            :     // For math objects, set closed state to transparent
     773 [ +  - ][ -  + ]:         25 :     if( ImplIsMathObj( xObjRef.GetObject() ) )
     774         [ #  # ]:          0 :         SetClosedObj( false );
     775                 :         25 : }
     776                 :            : 
     777                 :            : // -----------------------------------------------------------------------------
     778                 :            : 
     779                 :         27 : void SdrOle2Obj::Init()
     780                 :            : {
     781         [ +  - ]:         27 :     mpImpl = new SdrOle2ObjImpl;
     782                 :         27 :     pModifyListener = NULL;
     783                 :         27 :     pGraphic=NULL;
     784                 :         27 :     mpImpl->pGraphicObject=NULL;
     785                 :         27 :     mpImpl->pLightClient = 0;
     786                 :            : 
     787                 :         27 :     xObjRef.Lock( sal_True );
     788                 :         27 : }
     789                 :            : 
     790                 :            : // -----------------------------------------------------------------------------
     791                 :            : 
     792 [ +  - ][ +  - ]:         27 : SdrOle2Obj::~SdrOle2Obj()
     793                 :            : {
     794                 :            :     DBG_DTOR( SdrOle2Obj,NULL);
     795                 :         27 :     bInDestruction = true;
     796                 :            : 
     797         [ -  + ]:         27 :     if ( mpImpl->mbConnected )
     798         [ #  # ]:          0 :         Disconnect();
     799                 :            : 
     800         [ -  + ]:         27 :     if( pGraphic!=NULL )
     801 [ #  # ][ #  # ]:          0 :         delete pGraphic;
     802                 :            : 
     803         [ -  + ]:         27 :     if(mpImpl->pGraphicObject!=NULL)
     804 [ #  # ][ #  # ]:          0 :         delete mpImpl->pGraphicObject;
     805                 :            : 
     806         [ +  + ]:         27 :     if(pModifyListener)
     807                 :            :     {
     808                 :         18 :         pModifyListener->invalidate();
     809                 :         18 :         pModifyListener->release();
     810                 :            :     }
     811                 :            : 
     812         [ +  - ]:         27 :     DisconnectFileLink_Impl();
     813                 :            : 
     814         [ +  - ]:         27 :     if ( mpImpl->pLightClient )
     815                 :            :     {
     816         [ +  - ]:         27 :         mpImpl->pLightClient->Release();
     817                 :         27 :         mpImpl->pLightClient = NULL;
     818                 :            :     }
     819                 :            : 
     820 [ +  - ][ +  - ]:         27 :     delete mpImpl;
     821         [ -  + ]:         54 : }
     822                 :            : 
     823                 :            : // -----------------------------------------------------------------------------
     824                 :          0 : void SdrOle2Obj::SetAspect( sal_Int64 nAspect )
     825                 :            : {
     826                 :          0 :     xObjRef.SetViewAspect( nAspect );
     827                 :          0 : }
     828                 :            : 
     829                 :            : // -----------------------------------------------------------------------------
     830                 :            : 
     831                 :          0 : void SdrOle2Obj::SetGraphic_Impl(const Graphic* pGrf)
     832                 :            : {
     833         [ #  # ]:          0 :     if ( pGraphic )
     834                 :            :     {
     835         [ #  # ]:          0 :         delete pGraphic;
     836                 :          0 :         pGraphic = NULL;
     837         [ #  # ]:          0 :         delete mpImpl->pGraphicObject;
     838                 :          0 :         mpImpl->pGraphicObject = NULL;
     839                 :            :     }
     840                 :            : 
     841         [ #  # ]:          0 :     if (pGrf!=NULL)
     842                 :            :     {
     843         [ #  # ]:          0 :         pGraphic = new Graphic(*pGrf);
     844         [ #  # ]:          0 :         mpImpl->pGraphicObject = new GraphicObject( *pGraphic );
     845                 :            :     }
     846                 :            : 
     847                 :          0 :     SetChanged();
     848                 :          0 :     BroadcastObjectChange();
     849                 :          0 : }
     850                 :            : 
     851                 :          0 : void SdrOle2Obj::SetGraphic(const Graphic* pGrf)
     852                 :            : {
     853                 :            :     // only for setting a preview graphic
     854                 :          0 :     SetGraphic_Impl( pGrf );
     855                 :          0 : }
     856                 :            : 
     857                 :            : // -----------------------------------------------------------------------------
     858                 :            : 
     859                 :          4 : bool SdrOle2Obj::IsEmpty() const
     860                 :            : {
     861                 :          4 :     return !(xObjRef.is());
     862                 :            : }
     863                 :            : 
     864                 :            : // -----------------------------------------------------------------------------
     865                 :            : 
     866                 :          4 : void SdrOle2Obj::Connect()
     867                 :            : {
     868         [ -  + ]:          4 :     if( IsEmptyPresObj() )
     869                 :          0 :         return;
     870                 :            : 
     871         [ -  + ]:          4 :     if( mpImpl->mbConnected )
     872                 :            :     {
     873                 :            :         // currently there are situations where it seems to be unavoidable to have multiple connects
     874                 :            :         // changing this would need a larger code rewrite, so for now I remove the assertion
     875                 :            :         // OSL_FAIL("Connect() called on connected object!");
     876                 :          0 :         return;
     877                 :            :     }
     878                 :            : 
     879                 :          4 :     Connect_Impl();
     880                 :          4 :     AddListeners_Impl();
     881                 :            : }
     882                 :            : 
     883                 :            : // -----------------------------------------------------------------------------
     884                 :            : 
     885                 :          0 : sal_Bool SdrOle2Obj::UpdateLinkURL_Impl()
     886                 :            : {
     887                 :          0 :     sal_Bool bResult = sal_False;
     888                 :            : 
     889         [ #  # ]:          0 :     if ( mpImpl->mpObjectLink )
     890                 :            :     {
     891         [ #  # ]:          0 :         sfx2::LinkManager* pLinkManager = pModel ? pModel->GetLinkManager() : NULL;
     892         [ #  # ]:          0 :         if ( pLinkManager )
     893                 :            :         {
     894         [ #  # ]:          0 :             String aNewLinkURL;
     895         [ #  # ]:          0 :             pLinkManager->GetDisplayNames( mpImpl->mpObjectLink, 0, &aNewLinkURL, 0, 0 );
     896 [ #  # ][ #  # ]:          0 :             if ( !aNewLinkURL.EqualsIgnoreCaseAscii( mpImpl->maLinkURL ) )
     897                 :            :             {
     898         [ #  # ]:          0 :                 const_cast<SdrOle2Obj*>(this)->GetObjRef_Impl();
     899         [ #  # ]:          0 :                 uno::Reference< embed::XCommonEmbedPersist > xPersObj( xObjRef.GetObject(), uno::UNO_QUERY );
     900                 :            :                 OSL_ENSURE( xPersObj.is(), "The object must exist!\n" );
     901         [ #  # ]:          0 :                 if ( xPersObj.is() )
     902                 :            :                 {
     903                 :            :                     try
     904                 :            :                     {
     905 [ #  # ][ #  # ]:          0 :                         sal_Int32 nCurState = xObjRef->getCurrentState();
     906         [ #  # ]:          0 :                         if ( nCurState != embed::EmbedStates::LOADED )
     907 [ #  # ][ #  # ]:          0 :                             xObjRef->changeState( embed::EmbedStates::LOADED );
     908                 :            : 
     909                 :            :                         // TODO/LATER: there should be possible to get current mediadescriptor settings from the object
     910         [ #  # ]:          0 :                         uno::Sequence< beans::PropertyValue > aArgs( 1 );
     911         [ #  # ]:          0 :                         aArgs[0].Name = ::rtl::OUString(  "URL"  );
     912 [ #  # ][ #  # ]:          0 :                         aArgs[0].Value <<= ::rtl::OUString( aNewLinkURL );
                 [ #  # ]
     913 [ #  # ][ #  # ]:          0 :                         xPersObj->reload( aArgs, uno::Sequence< beans::PropertyValue >() );
         [ #  # ][ #  # ]
     914                 :            : 
     915         [ #  # ]:          0 :                         mpImpl->maLinkURL = aNewLinkURL;
     916                 :          0 :                         bResult = sal_True;
     917                 :            : 
     918         [ #  # ]:          0 :                         if ( nCurState != embed::EmbedStates::LOADED )
     919 [ #  # ][ #  # ]:          0 :                             xObjRef->changeState( nCurState );
         [ #  # ][ #  # ]
     920                 :            :                     }
     921         [ #  # ]:          0 :                     catch( ::com::sun::star::uno::Exception& )
     922                 :            :                     {
     923                 :            :                         OSL_FAIL(
     924                 :            :                             (OString("SdrOle2Obj::UpdateLinkURL_Impl(), "
     925                 :            :                                     "exception caught: ") +
     926                 :            :                             rtl::OUStringToOString(
     927                 :            :                                 comphelper::anyToString( cppu::getCaughtException() ),
     928                 :            :                                 RTL_TEXTENCODING_UTF8 )).getStr() );
     929                 :            :                     }
     930                 :            :                 }
     931                 :            : 
     932                 :            :                 if ( !bResult )
     933                 :            :                 {
     934                 :            :                     // TODO/LATER: return the old name to the link manager, is it possible?
     935                 :          0 :                 }
     936         [ #  # ]:          0 :             }
     937                 :            :         }
     938                 :            :     }
     939                 :            : 
     940                 :          0 :     return bResult;
     941                 :            : }
     942                 :            : 
     943                 :            : // -----------------------------------------------------------------------------
     944                 :            : 
     945                 :          0 : void SdrOle2Obj::BreakFileLink_Impl()
     946                 :            : {
     947                 :          0 :     uno::Reference<document::XStorageBasedDocument> xDoc;
     948         [ #  # ]:          0 :     if ( pModel )
     949 [ #  # ][ #  # ]:          0 :         xDoc.set( pModel->getUnoModel(),uno::UNO_QUERY);
     950                 :            : 
     951         [ #  # ]:          0 :     if ( xDoc.is() )
     952                 :            :     {
     953 [ #  # ][ #  # ]:          0 :         uno::Reference< embed::XStorage > xStorage = xDoc->getDocumentStorage();
     954         [ #  # ]:          0 :         if ( xStorage.is() )
     955                 :            :         {
     956                 :            :             try
     957                 :            :             {
     958         [ #  # ]:          0 :                 uno::Reference< embed::XLinkageSupport > xLinkSupport( xObjRef.GetObject(), uno::UNO_QUERY_THROW );
     959 [ #  # ][ #  # ]:          0 :                 xLinkSupport->breakLink( xStorage, mpImpl->aPersistName );
                 [ #  # ]
     960         [ #  # ]:          0 :                 DisconnectFileLink_Impl();
     961 [ #  # ][ #  # ]:          0 :                 mpImpl->maLinkURL = String();
         [ #  # ][ #  # ]
     962                 :            :             }
     963         [ #  # ]:          0 :             catch( ::com::sun::star::uno::Exception& )
     964                 :            :             {
     965                 :            :                 OSL_FAIL(
     966                 :            :                     (OString("SdrOle2Obj::BreakFileLink_Impl(), "
     967                 :            :                             "exception caught: ") +
     968                 :            :                     rtl::OUStringToOString(
     969                 :            :                         comphelper::anyToString( cppu::getCaughtException() ),
     970                 :            :                         RTL_TEXTENCODING_UTF8 )).getStr() );
     971                 :            :             }
     972                 :          0 :         }
     973                 :          0 :     }
     974                 :          0 : }
     975                 :            : 
     976                 :            : // -----------------------------------------------------------------------------
     977                 :            : 
     978                 :         28 : void SdrOle2Obj::DisconnectFileLink_Impl()
     979                 :            : {
     980         [ +  - ]:         28 :     sfx2::LinkManager* pLinkManager = pModel ? pModel->GetLinkManager() : NULL;
     981 [ +  - ][ -  + ]:         28 :     if ( pLinkManager && mpImpl->mpObjectLink )
     982                 :            :     {
     983                 :          0 :         pLinkManager->Remove( mpImpl->mpObjectLink );
     984                 :          0 :         mpImpl->mpObjectLink = NULL;
     985                 :            :     }
     986                 :         28 : }
     987                 :            : 
     988                 :            : // -----------------------------------------------------------------------------
     989                 :            : 
     990                 :         27 : void SdrOle2Obj::CheckFileLink_Impl()
     991                 :            : {
     992 [ +  - ][ +  - ]:         27 :     if ( pModel && xObjRef.GetObject().is() && !mpImpl->mpObjectLink )
         [ +  - ][ +  - ]
     993                 :            :     {
     994                 :            :         try
     995                 :            :         {
     996         [ +  - ]:         27 :             uno::Reference< embed::XLinkageSupport > xLinkSupport( xObjRef.GetObject(), uno::UNO_QUERY );
     997 [ +  + ][ +  - ]:         27 :             if ( xLinkSupport.is() && xLinkSupport->isLink() )
         [ +  - ][ -  + ]
                 [ -  + ]
     998                 :            :             {
     999 [ #  # ][ #  # ]:          0 :                 String aLinkURL = xLinkSupport->getLinkURL();
                 [ #  # ]
    1000         [ #  # ]:          0 :                 if ( aLinkURL.Len() )
    1001                 :            :                 {
    1002                 :            :                     // this is a file link so the model link manager should handle it
    1003                 :          0 :                     sfx2::LinkManager* pLinkManager = pModel->GetLinkManager();
    1004         [ #  # ]:          0 :                     if ( pLinkManager )
    1005                 :            :                     {
    1006 [ #  # ][ #  # ]:          0 :                         mpImpl->mpObjectLink = new SdrEmbedObjectLink( this );
    1007         [ #  # ]:          0 :                         mpImpl->maLinkURL = aLinkURL;
    1008         [ #  # ]:          0 :                         pLinkManager->InsertFileLink( *mpImpl->mpObjectLink, OBJECT_CLIENT_OLE, aLinkURL, NULL, NULL );
    1009         [ #  # ]:          0 :                         mpImpl->mpObjectLink->Connect();
    1010                 :            :                     }
    1011         [ #  # ]:          0 :                 }
    1012         [ #  # ]:         27 :             }
    1013                 :            :         }
    1014                 :          0 :         catch( ::com::sun::star::uno::Exception& )
    1015                 :            :         {
    1016                 :            :             OSL_FAIL(
    1017                 :            :                 (OString("SdrOle2Obj::CheckFileLink_Impl(), "
    1018                 :            :                         "exception caught: ") +
    1019                 :            :                 rtl::OUStringToOString(
    1020                 :            :                     comphelper::anyToString( cppu::getCaughtException() ),
    1021                 :            :                     RTL_TEXTENCODING_UTF8 )).getStr() );
    1022                 :            :         }
    1023                 :            :     }
    1024                 :         27 : }
    1025                 :            : 
    1026                 :            : // -----------------------------------------------------------------------------
    1027                 :            : 
    1028                 :          0 : void SdrOle2Obj::Reconnect_Impl()
    1029                 :            : {
    1030                 :            :     DBG_ASSERT( mpImpl->mbConnected, "Assigned unconnected object?!" );
    1031                 :          0 :     Connect_Impl();
    1032                 :          0 : }
    1033                 :            : 
    1034                 :         31 : void SdrOle2Obj::Connect_Impl()
    1035                 :            : {
    1036 [ +  - ][ +  + ]:         31 :     if( pModel && mpImpl->aPersistName.Len() )
                 [ +  + ]
    1037                 :            :     {
    1038                 :            :         try
    1039                 :            :         {
    1040                 :         27 :             ::comphelper::IEmbeddedHelper* pPers = pModel->GetPersist();
    1041         [ +  - ]:         27 :             if ( pPers )
    1042                 :            :             {
    1043         [ +  - ]:         27 :                 comphelper::EmbeddedObjectContainer& rContainer = pPers->getEmbeddedObjectContainer();
    1044 [ +  - ][ +  - ]:         79 :                 if ( !rContainer.HasEmbeddedObject( mpImpl->aPersistName )
           [ +  -  +  + ]
         [ -  + ][ +  - ]
           [ -  +  #  # ]
    1045         [ +  - ]:         52 :                   || ( xObjRef.is() && !rContainer.HasEmbeddedObject( xObjRef.GetObject() ) ) )
    1046                 :            :                 {
    1047                 :            :                     // object not known to container document
    1048                 :            :                     // No object -> disaster!
    1049                 :            :                     DBG_ASSERT( xObjRef.is(), "No object in connect!");
    1050         [ #  # ]:          0 :                     if ( xObjRef.is() )
    1051                 :            :                     {
    1052                 :            :                         // object came from the outside, now add it to the container
    1053                 :          0 :                         ::rtl::OUString aTmp;
    1054         [ #  # ]:          0 :                         rContainer.InsertEmbeddedObject( xObjRef.GetObject(), aTmp );
    1055         [ #  # ]:          0 :                         mpImpl->aPersistName = aTmp;
    1056                 :            :                     }
    1057                 :            :                 }
    1058         [ +  + ]:         27 :                 else if ( !xObjRef.is() )
    1059                 :            :                 {
    1060 [ +  - ][ +  - ]:          2 :                     xObjRef.Assign( rContainer.GetEmbeddedObject( mpImpl->aPersistName ), xObjRef.GetViewAspect() );
         [ +  - ][ +  - ]
    1061                 :          2 :                     m_bTypeAsked = false;
    1062                 :            :                 }
    1063                 :            : 
    1064         [ +  - ]:         27 :                 if ( xObjRef.GetObject().is() )
    1065                 :            :                 {
    1066 [ +  - ][ +  - ]:         27 :                     xObjRef.AssignToContainer( &rContainer, mpImpl->aPersistName );
    1067                 :         27 :                     mpImpl->mbConnected = true;
    1068         [ +  - ]:         27 :                     xObjRef.Lock( sal_True );
    1069                 :            :                 }
    1070                 :            :             }
    1071                 :            : 
    1072         [ +  - ]:         27 :             if ( xObjRef.is() )
    1073                 :            :             {
    1074         [ +  - ]:         27 :                 if ( !mpImpl->pLightClient )
    1075                 :            :                 {
    1076         [ +  - ]:         27 :                     mpImpl->pLightClient = new SdrLightEmbeddedClient_Impl( this );
    1077                 :         27 :                     mpImpl->pLightClient->acquire();
    1078                 :            :                 }
    1079                 :            : 
    1080 [ +  - ][ +  - ]:         27 :                 xObjRef->addStateChangeListener( mpImpl->pLightClient );
         [ +  - ][ +  - ]
    1081 [ +  - ][ +  - ]:         27 :                 xObjRef->addEventListener( uno::Reference< document::XEventListener >( mpImpl->pLightClient ) );
         [ +  - ][ +  - ]
    1082                 :            : 
    1083 [ +  - ][ +  + ]:         27 :                 if ( xObjRef->getCurrentState() != embed::EmbedStates::LOADED )
                 [ +  - ]
    1084 [ +  - ][ +  - ]:         18 :                     GetSdrGlobalData().GetOLEObjCache().InsertObj(this);
    1085                 :            : 
    1086         [ +  - ]:         27 :                 CheckFileLink_Impl();
    1087                 :            : 
    1088         [ +  - ]:         27 :                 uno::Reference< container::XChild > xChild( xObjRef.GetObject(), uno::UNO_QUERY );
    1089         [ +  + ]:         27 :                 if( xChild.is() )
    1090                 :            :                 {
    1091         [ +  - ]:         18 :                     uno::Reference< uno::XInterface > xParent( pModel->getUnoModel());
    1092         [ +  - ]:         18 :                     if( xParent.is())
    1093 [ +  - ][ +  - ]:         18 :                         xChild->setParent( pModel->getUnoModel() );
                 [ +  - ]
    1094         [ #  # ]:         27 :                 }
    1095                 :            : 
    1096                 :            :             }
    1097                 :            :         }
    1098                 :          0 :         catch( ::com::sun::star::uno::Exception& )
    1099                 :            :         {
    1100                 :            :             OSL_FAIL(
    1101                 :            :                 (OString("SdrOle2Obj::Connect_Impl(), "
    1102                 :            :                         "exception caught: ") +
    1103                 :            :                 rtl::OUStringToOString(
    1104                 :            :                     comphelper::anyToString( cppu::getCaughtException() ),
    1105                 :            :                     RTL_TEXTENCODING_UTF8 )).getStr() );
    1106                 :            :         }
    1107                 :            :     }
    1108                 :            : 
    1109                 :            :     //TODO/LATER: wait for definition of MiscStatus RESIZEONPRINTERCHANGE
    1110                 :            :     //if ( xObjRef.is() && (*ppObjRef)->GetMiscStatus() & SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE )
    1111                 :            :     {
    1112                 :            :         //TODO/LATER: needs a new handling for OnPrinterChanged
    1113                 :            :         /*
    1114                 :            :         if (pModel && pModel->GetRefDevice() &&
    1115                 :            :             pModel->GetRefDevice()->GetOutDevType() == OUTDEV_PRINTER)
    1116                 :            :         {
    1117                 :            :             // Kein RefDevice oder RefDevice kein Printer
    1118                 :            :             sal_Bool bModified = (*ppObjRef)->IsModified();
    1119                 :            :             Printer* pPrinter = (Printer*) pModel->GetRefDevice();
    1120                 :            :             (*ppObjRef)->OnDocumentPrinterChanged( pPrinter );
    1121                 :            :             (*ppObjRef)->SetModified( bModified );
    1122                 :            :         }*/
    1123                 :            :     }
    1124                 :         31 : }
    1125                 :            : 
    1126                 :          0 : void SdrOle2Obj::ObjectLoaded()
    1127                 :            : {
    1128                 :          0 :     AddListeners_Impl();
    1129                 :          0 : }
    1130                 :            : 
    1131                 :         31 : void SdrOle2Obj::AddListeners_Impl()
    1132                 :            : {
    1133 [ +  + ][ +  + ]:         31 :     if( xObjRef.is() && xObjRef->getCurrentState() != embed::EmbedStates::LOADED )
                 [ +  + ]
    1134                 :            :     {
    1135                 :            :         // register modify listener
    1136         [ +  - ]:         18 :         if( !pModifyListener )
    1137                 :            :         {
    1138                 :         18 :             ((SdrOle2Obj*)this)->pModifyListener = new SvxUnoShapeModifyListener( (SdrOle2Obj*)this );
    1139                 :         18 :             pModifyListener->acquire();
    1140                 :            :         }
    1141                 :            : 
    1142 [ +  - ][ +  - ]:         18 :         uno::Reference< util::XModifyBroadcaster > xBC( getXModel(), uno::UNO_QUERY );
    1143 [ +  - ][ +  - ]:         18 :         if( xBC.is() && pModifyListener )
                 [ +  - ]
    1144                 :            :         {
    1145 [ +  - ][ +  - ]:         18 :             uno::Reference< util::XModifyListener > xListener( pModifyListener );
    1146 [ +  - ][ +  - ]:         18 :             xBC->addModifyListener( xListener );
    1147                 :         18 :         }
    1148                 :            :     }
    1149                 :         31 : }
    1150                 :            : 
    1151                 :            : // -----------------------------------------------------------------------------
    1152                 :            : 
    1153                 :         27 : void SdrOle2Obj::Disconnect()
    1154                 :            : {
    1155         [ -  + ]:         27 :     if( IsEmptyPresObj() )
    1156                 :          0 :         return;
    1157                 :            : 
    1158         [ -  + ]:         27 :     if( !mpImpl->mbConnected )
    1159                 :            :     {
    1160                 :            :         OSL_FAIL("Disconnect() called on disconnected object!");
    1161                 :          0 :         return;
    1162                 :            :     }
    1163                 :            : 
    1164                 :         27 :     RemoveListeners_Impl();
    1165                 :         27 :     Disconnect_Impl();
    1166                 :            : }
    1167                 :            : 
    1168                 :         54 : void SdrOle2Obj::RemoveListeners_Impl()
    1169                 :            : {
    1170 [ +  + ][ +  - ]:         54 :     if( xObjRef.is() && mpImpl->aPersistName.Len() )
                 [ +  + ]
    1171                 :            :     {
    1172                 :            :         try
    1173                 :            :         {
    1174 [ +  - ][ +  - ]:         52 :             sal_Int32 nState = xObjRef->getCurrentState();
    1175         [ +  + ]:         52 :             if ( nState != embed::EmbedStates::LOADED )
    1176                 :            :             {
    1177 [ +  - ][ +  - ]:         34 :                 uno::Reference< util::XModifyBroadcaster > xBC( getXModel(), uno::UNO_QUERY );
    1178 [ +  + ][ +  + ]:         34 :                 if( xBC.is() && pModifyListener )
                 [ +  - ]
    1179                 :            :                 {
    1180 [ +  - ][ +  - ]:         18 :                     uno::Reference< util::XModifyListener > xListener( pModifyListener );
    1181 [ +  - ][ +  - ]:         18 :                     xBC->removeModifyListener( xListener );
    1182         [ #  # ]:         34 :                 }
    1183                 :            :             }
    1184                 :            :         }
    1185                 :          0 :         catch( ::com::sun::star::uno::Exception& )
    1186                 :            :         {
    1187                 :            :             OSL_FAIL(
    1188                 :            :                 (OString("SdrOle2Obj::RemoveListeners_Impl(), "
    1189                 :            :                         "exception caught: ") +
    1190                 :            :                 rtl::OUStringToOString(
    1191                 :            :                     comphelper::anyToString( cppu::getCaughtException() ),
    1192                 :            :                     RTL_TEXTENCODING_UTF8 )).getStr() );
    1193                 :            :         }
    1194                 :            :     }
    1195                 :         54 : }
    1196                 :            : 
    1197                 :         27 : void SdrOle2Obj::Disconnect_Impl()
    1198                 :            : {
    1199                 :            :     try
    1200                 :            :     {
    1201 [ +  - ][ +  - ]:         27 :         if ( pModel && mpImpl->aPersistName.Len() )
                 [ +  - ]
    1202                 :            :         {
    1203 [ +  - ][ +  + ]:         27 :             if( pModel->IsInDestruction() )
    1204                 :            :             {
    1205                 :            :                 // TODO/LATER: here we must assume that the destruction of the model is enough to make clear that we will not
    1206                 :            :                 // remove the object from the container, even if the DrawingObject itself is not destroyed (unfortunately this
    1207                 :            :                 // There is no real need to do the following removing of the object from the container
    1208                 :            :                 // in case the model has correct persistence, but in case of problems such a removing
    1209                 :            :                 // would make the behavior of the office more stable
    1210                 :            : 
    1211         [ +  - ]:         26 :                 comphelper::EmbeddedObjectContainer* pContainer = xObjRef.GetContainer();
    1212         [ +  - ]:         26 :                 if ( pContainer )
    1213                 :            :                 {
    1214         [ +  - ]:         26 :                     pContainer->CloseEmbeddedObject( xObjRef.GetObject() );
    1215 [ +  - ][ +  - ]:         26 :                     xObjRef.AssignToContainer( NULL, mpImpl->aPersistName );
    1216                 :            :                 }
    1217                 :            : 
    1218                 :            :                 // happens later than the destruction of the model, so we can't assert that).
    1219                 :            :                 //DBG_ASSERT( bInDestruction, "Model is destroyed, but not me?!" );
    1220                 :            :                 //TODO/LATER: should be make sure that the ObjectShell also forgets the object, because we will close it soon?
    1221                 :            :                 /*
    1222                 :            :                 uno::Reference < util::XCloseable > xClose( xObjRef, uno::UNO_QUERY );
    1223                 :            :                 if ( xClose.is() )
    1224                 :            :                 {
    1225                 :            :                     try
    1226                 :            :                     {
    1227                 :            :                         xClose->close( sal_True );
    1228                 :            :                     }
    1229                 :            :                     catch ( util::CloseVetoException& )
    1230                 :            :                     {
    1231                 :            :                         // there's still someone who needs the object!
    1232                 :            :                     }
    1233                 :            :                 }
    1234                 :            : 
    1235                 :            :                 xObjRef = NULL;*/
    1236                 :            :             }
    1237         [ +  - ]:          1 :             else if ( xObjRef.is() )
    1238                 :            :             {
    1239 [ +  - ][ +  - ]:          1 :                 if ( pModel->getUnoModel().is() )
    1240                 :            :                 {
    1241                 :            :                     // remove object, but don't close it (that's up to someone else)
    1242         [ +  - ]:          1 :                     comphelper::EmbeddedObjectContainer* pContainer = xObjRef.GetContainer();
    1243         [ +  - ]:          1 :                     if ( pContainer )
    1244                 :            :                     {
    1245         [ +  - ]:          1 :                         pContainer->RemoveEmbeddedObject( xObjRef.GetObject(), sal_False);
    1246                 :            : 
    1247                 :            :                         // TODO/LATER: mpImpl->aPersistName contains outdated information, to keep it updated
    1248                 :            :                         // it should be returned from RemoveEmbeddedObject call. Currently it is no problem,
    1249                 :            :                         // since no container is adjusted, actually the empty string could be provided as a name here
    1250 [ +  - ][ +  - ]:          1 :                         xObjRef.AssignToContainer( NULL, mpImpl->aPersistName );
    1251                 :            :                     }
    1252                 :            : 
    1253         [ +  - ]:          1 :                     DisconnectFileLink_Impl();
    1254                 :            :                 }
    1255                 :            :             }
    1256                 :            :         }
    1257                 :            : 
    1258 [ +  - ][ +  - ]:         27 :         if ( xObjRef.is() && mpImpl->pLightClient )
                 [ +  - ]
    1259                 :            :         {
    1260 [ +  - ][ +  - ]:         27 :             xObjRef->removeStateChangeListener ( mpImpl->pLightClient );
         [ +  - ][ +  - ]
    1261 [ +  - ][ +  - ]:         27 :             xObjRef->removeEventListener( uno::Reference< document::XEventListener >( mpImpl->pLightClient ) );
         [ +  - ][ +  - ]
    1262 [ +  - ][ +  - ]:         27 :             xObjRef->setClientSite( NULL );
         [ #  # ][ +  - ]
    1263                 :            : 
    1264 [ +  - ][ +  - ]:         27 :             GetSdrGlobalData().GetOLEObjCache().RemoveObj(this);
    1265                 :            :         }
    1266                 :            :     }
    1267                 :          0 :     catch( ::com::sun::star::uno::Exception& )
    1268                 :            :     {
    1269                 :            :         OSL_FAIL(
    1270                 :            :             (OString("SdrOle2Obj::Disconnect_Impl(), "
    1271                 :            :                     "exception caught: ") +
    1272                 :            :             rtl::OUStringToOString(
    1273                 :            :                 comphelper::anyToString( cppu::getCaughtException() ),
    1274                 :            :                 RTL_TEXTENCODING_UTF8 )).getStr() );
    1275                 :            :     }
    1276                 :            : 
    1277                 :         27 :     mpImpl->mbConnected = false;
    1278                 :         27 : }
    1279                 :            : 
    1280                 :            : // -----------------------------------------------------------------------------
    1281                 :            : 
    1282                 :         27 : void SdrOle2Obj::SetModel(SdrModel* pNewModel)
    1283                 :            : {
    1284         [ +  - ]:         27 :     ::comphelper::IEmbeddedHelper* pDestPers = pNewModel ? pNewModel->GetPersist() : 0;
    1285         [ -  + ]:         27 :     ::comphelper::IEmbeddedHelper* pSrcPers  = pModel ? pModel->GetPersist() : 0;
    1286                 :            : 
    1287         [ -  + ]:         27 :     if ( pNewModel == pModel )
    1288                 :            :     {
    1289                 :            :         // don't know if this is necessary or if it will ever happen, but who knows?!
    1290                 :          0 :         SdrRectObj::SetModel( pNewModel );
    1291                 :          0 :         return;
    1292                 :            :     }
    1293                 :            : 
    1294                 :            :     // assignment to model has changed
    1295                 :            :     DBG_ASSERT( pSrcPers || !mpImpl->mbConnected, "Connected object without a model?!" );
    1296                 :            : 
    1297                 :            :     DBG_ASSERT( pDestPers, "The destination model must have a persistence! Please submit an issue!" );
    1298                 :            :     DBG_ASSERT( pDestPers != pSrcPers, "The source and the destination models should have different persistences! Problems are possible!" );
    1299                 :            : 
    1300                 :            :     // this is a bug if the target model has no persistence
    1301                 :            :     // no error handling is possible so just do nothing in this method
    1302         [ -  + ]:         27 :     if ( !pDestPers )
    1303                 :          0 :         return;
    1304                 :            : 
    1305                 :         27 :     RemoveListeners_Impl();
    1306                 :            : 
    1307 [ -  + ][ #  # ]:         27 :     if( pDestPers && pSrcPers && !IsEmptyPresObj() )
         [ -  + ][ +  - ]
    1308                 :            :     {
    1309                 :            :         try
    1310                 :            :         {
    1311                 :            :             // move the object's storage; ObjectRef remains the same, but PersistName may change
    1312                 :          0 :             ::rtl::OUString aTmp;
    1313         [ #  # ]:          0 :             comphelper::EmbeddedObjectContainer& rContainer = pSrcPers->getEmbeddedObjectContainer();
    1314 [ #  # ][ #  # ]:          0 :             uno::Reference < embed::XEmbeddedObject > xObj = rContainer.GetEmbeddedObject( mpImpl->aPersistName );
    1315                 :            :             DBG_ASSERT( !xObjRef.is() || xObjRef.GetObject() == xObj, "Wrong object identity!" );
    1316         [ #  # ]:          0 :             if ( xObj.is() )
    1317                 :            :             {
    1318 [ #  # ][ #  # ]:          0 :                 pDestPers->getEmbeddedObjectContainer().MoveEmbeddedObject( rContainer, xObj, aTmp );
    1319         [ #  # ]:          0 :                 mpImpl->aPersistName = aTmp;
    1320 [ #  # ][ #  # ]:          0 :                 xObjRef.AssignToContainer( &pDestPers->getEmbeddedObjectContainer(), aTmp );
    1321                 :            :             }
    1322         [ #  # ]:          0 :             DBG_ASSERT( !aTmp.isEmpty(), "Copying embedded object failed!" );
    1323                 :            :         }
    1324                 :          0 :         catch( ::com::sun::star::uno::Exception& )
    1325                 :            :         {
    1326                 :            :             OSL_FAIL(
    1327                 :            :                 (OString("SdrOle2Obj::SetModel(), "
    1328                 :            :                         "exception caught: ") +
    1329                 :            :                 rtl::OUStringToOString(
    1330                 :            :                     comphelper::anyToString( cppu::getCaughtException() ),
    1331                 :            :                     RTL_TEXTENCODING_UTF8 )).getStr() );
    1332                 :            :         }
    1333                 :            :     }
    1334                 :            : 
    1335                 :         27 :     SdrRectObj::SetModel( pNewModel );
    1336                 :            : 
    1337                 :            :     // #i43086#
    1338                 :            :     // #i85304 redo the change for charts for the above bugfix, as #i43086# does not occur anymore
    1339                 :            :     //so maybe the ImpSetVisAreaSize call can be removed here completely
    1340                 :            :     //Nevertheless I leave it in for other objects as I am not sure about the side effects when removing now
    1341 [ +  + ][ +  + ]:         27 :     if( pModel && !pModel->isLocked() && !IsChart() )
         [ +  + ][ +  - ]
    1342                 :          2 :         ImpSetVisAreaSize();
    1343                 :            : 
    1344 [ +  - ][ +  - ]:         27 :     if( pDestPers && !IsEmptyPresObj() )
                 [ +  - ]
    1345                 :            :     {
    1346 [ -  + ][ #  # ]:         27 :         if ( !pSrcPers || IsEmptyPresObj() )
                 [ +  - ]
    1347                 :            :             // object wasn't connected, now it should be
    1348                 :         27 :             Connect_Impl();
    1349                 :            :         else
    1350                 :          0 :             Reconnect_Impl();
    1351                 :            :     }
    1352                 :            : 
    1353                 :         27 :     AddListeners_Impl();
    1354                 :            : }
    1355                 :            : 
    1356                 :            : // -----------------------------------------------------------------------------
    1357                 :            : 
    1358                 :         30 : void SdrOle2Obj::SetPage(SdrPage* pNewPage)
    1359                 :            : {
    1360 [ +  + ][ +  - ]:         30 :     bool bRemove=pNewPage==NULL && pPage!=NULL;
    1361 [ +  + ][ +  + ]:         30 :     bool bInsert=pNewPage!=NULL && pPage==NULL;
    1362                 :            : 
    1363 [ +  + ][ +  - ]:         30 :     if (bRemove && mpImpl->mbConnected )
    1364                 :          1 :         Disconnect();
    1365                 :            : 
    1366                 :         30 :     SdrRectObj::SetPage(pNewPage);
    1367                 :            : 
    1368 [ +  + ][ +  + ]:         30 :     if (bInsert && !mpImpl->mbConnected )
    1369                 :          2 :         Connect();
    1370                 :         30 : }
    1371                 :            : 
    1372                 :            : // -----------------------------------------------------------------------------
    1373                 :            : 
    1374                 :          0 : void SdrOle2Obj::SetObjRef( const com::sun::star::uno::Reference < com::sun::star::embed::XEmbeddedObject >& rNewObjRef )
    1375                 :            : {
    1376                 :            :     DBG_ASSERT( !rNewObjRef.is() || !xObjRef.GetObject().is(), "SetObjRef called on already initialized object!");
    1377         [ #  # ]:          0 :     if( rNewObjRef == xObjRef.GetObject() )
    1378                 :          0 :         return;
    1379                 :            : 
    1380                 :            :     // the caller of the method is responsible to control the old object, it will not be closed here
    1381                 :            :     // Otherwise WW8 import crashes because it transfers control to OLENode by this method
    1382         [ #  # ]:          0 :     if ( xObjRef.GetObject().is() )
    1383                 :          0 :         xObjRef.Lock( sal_False );
    1384                 :            : 
    1385                 :            :     // avoid removal of object in Disconnect! It is definitely a HACK to call SetObjRef(0)!
    1386                 :            :     // This call will try to close the objects; so if anybody else wants to keep it, it must be locked by a CloseListener
    1387                 :          0 :     xObjRef.Clear();
    1388                 :            : 
    1389         [ #  # ]:          0 :     if ( mpImpl->mbConnected )
    1390                 :          0 :         Disconnect();
    1391                 :            : 
    1392                 :          0 :     xObjRef.Assign( rNewObjRef, GetAspect() );
    1393                 :          0 :     m_bTypeAsked = false;
    1394                 :            : 
    1395         [ #  # ]:          0 :     if ( xObjRef.is() )
    1396                 :            :     {
    1397         [ #  # ]:          0 :         DELETEZ( pGraphic );
    1398                 :            : 
    1399         [ #  # ]:          0 :         if ( (xObjRef->getStatus( GetAspect() ) & embed::EmbedMisc::EMBED_NEVERRESIZE ) )
    1400                 :          0 :             SetResizeProtect(sal_True);
    1401                 :            : 
    1402                 :            :         // For math objects, set closed state to transparent
    1403         [ #  # ]:          0 :         if( ImplIsMathObj( rNewObjRef ) )
    1404                 :          0 :             SetClosedObj( false );
    1405                 :            : 
    1406                 :          0 :         Connect();
    1407                 :            :     }
    1408                 :            : 
    1409                 :          0 :     SetChanged();
    1410                 :          0 :     BroadcastObjectChange();
    1411                 :            : }
    1412                 :            : 
    1413                 :            : // -----------------------------------------------------------------------------
    1414                 :            : 
    1415                 :          0 : void SdrOle2Obj::SetClosedObj( bool bIsClosed )
    1416                 :            : {
    1417                 :            :     // TODO/LATER: do we still need this hack?
    1418                 :            :     // Allow changes to the closed state of OLE objects
    1419                 :          0 :     bClosedObj = bIsClosed;
    1420                 :          0 : }
    1421                 :            : 
    1422                 :            : // -----------------------------------------------------------------------------
    1423                 :            : 
    1424                 :          0 : SdrObject* SdrOle2Obj::getFullDragClone() const
    1425                 :            : {
    1426                 :            :     // special handling for OLE. The default handling works, but is too
    1427                 :            :     // slow when the whole OLE needs to be cloned. Get the Metafile and
    1428                 :            :     // create a graphic object with it
    1429                 :          0 :     Graphic* pOLEGraphic = GetGraphic();
    1430                 :          0 :     SdrObject* pClone = 0;
    1431                 :            : 
    1432         [ #  # ]:          0 :     if(pOLEGraphic)
    1433                 :            :     {
    1434         [ #  # ]:          0 :         pClone = new SdrGrafObj(*pOLEGraphic, GetSnapRect());
    1435                 :            : 
    1436                 :            :         // this would be the place where to copy all attributes
    1437                 :            :         // when OLE will support fill and line style
    1438                 :            :         // pClone->SetMergedItem(pOleObject->GetMergedItemSet());
    1439                 :            :     }
    1440                 :            :     else
    1441                 :            :     {
    1442                 :            :         // #i100710# pOLEGraphic may be zero (no visualisation available),
    1443                 :            :         // so we need to use the OLE replacement graphic
    1444 [ #  # ][ #  # ]:          0 :         pClone = new SdrRectObj(GetSnapRect());
                 [ #  # ]
    1445                 :            : 
    1446                 :            :         // gray outline
    1447 [ #  # ][ #  # ]:          0 :         pClone->SetMergedItem(XLineStyleItem(XLINE_SOLID));
                 [ #  # ]
    1448         [ #  # ]:          0 :         const svtools::ColorConfig aColorConfig;
    1449         [ #  # ]:          0 :         const svtools::ColorConfigValue aColor(aColorConfig.GetColorValue(svtools::OBJECTBOUNDARIES));
    1450 [ #  # ][ #  # ]:          0 :         pClone->SetMergedItem(XLineColorItem(String(), aColor.nColor));
         [ #  # ][ #  # ]
                 [ #  # ]
    1451                 :            : 
    1452                 :            :         // bitmap fill
    1453 [ #  # ][ #  # ]:          0 :         pClone->SetMergedItem(XFillStyleItem(XFILL_BITMAP));
                 [ #  # ]
    1454 [ #  # ][ #  # ]:          0 :         pClone->SetMergedItem(XFillBitmapItem(String(), GetEmtyOLEReplacementBitmap()));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1455 [ #  # ][ #  # ]:          0 :         pClone->SetMergedItem(XFillBmpTileItem(false));
                 [ #  # ]
    1456 [ #  # ][ #  # ]:          0 :         pClone->SetMergedItem(XFillBmpStretchItem(false));
         [ #  # ][ #  # ]
    1457                 :            :     }
    1458                 :            : 
    1459                 :          0 :     return pClone;
    1460                 :            : }
    1461                 :            : 
    1462                 :            : // -----------------------------------------------------------------------------
    1463                 :            : 
    1464                 :          2 : void SdrOle2Obj::SetPersistName( const String& rPersistName )
    1465                 :            : {
    1466                 :            :     DBG_ASSERT( !mpImpl->aPersistName.Len(), "Persist name changed!");
    1467                 :            : 
    1468                 :          2 :     mpImpl->aPersistName = rPersistName;
    1469                 :          2 :     mpImpl->mbLoadingOLEObjectFailed = false;
    1470                 :            : 
    1471                 :          2 :     Connect();
    1472                 :          2 :     SetChanged();
    1473                 :          2 : }
    1474                 :            : 
    1475                 :          0 : void SdrOle2Obj::AbandonObject()
    1476                 :            : {
    1477                 :          0 :     mpImpl->aPersistName.Erase();
    1478                 :          0 :     mpImpl->mbLoadingOLEObjectFailed = false;
    1479         [ #  # ]:          0 :     SetObjRef(0);
    1480                 :          0 : }
    1481                 :            : 
    1482                 :            : // -----------------------------------------------------------------------------
    1483                 :            : 
    1484                 :         71 : String SdrOle2Obj::GetPersistName() const
    1485                 :            : {
    1486                 :         71 :     return mpImpl->aPersistName;
    1487                 :            : }
    1488                 :            : 
    1489                 :            : // -----------------------------------------------------------------------------
    1490                 :            : 
    1491                 :          0 : void SdrOle2Obj::TakeObjInfo(SdrObjTransformInfoRec& rInfo) const
    1492                 :            : {
    1493                 :          0 :     rInfo.bRotateFreeAllowed=sal_False;
    1494                 :          0 :     rInfo.bRotate90Allowed  =sal_False;
    1495                 :          0 :     rInfo.bMirrorFreeAllowed=sal_False;
    1496                 :          0 :     rInfo.bMirror45Allowed  =sal_False;
    1497                 :          0 :     rInfo.bMirror90Allowed  =sal_False;
    1498                 :          0 :     rInfo.bTransparenceAllowed = sal_False;
    1499                 :          0 :     rInfo.bGradientAllowed = sal_False;
    1500                 :          0 :     rInfo.bShearAllowed     =sal_False;
    1501                 :          0 :     rInfo.bEdgeRadiusAllowed=sal_False;
    1502                 :          0 :     rInfo.bNoOrthoDesired   =sal_False;
    1503                 :          0 :     rInfo.bCanConvToPath    =sal_False;
    1504                 :          0 :     rInfo.bCanConvToPoly    =sal_False;
    1505                 :          0 :     rInfo.bCanConvToPathLineToArea=sal_False;
    1506                 :          0 :     rInfo.bCanConvToPolyLineToArea=sal_False;
    1507                 :          0 :     rInfo.bCanConvToContour = sal_False;
    1508                 :          0 : }
    1509                 :            : 
    1510                 :            : // -----------------------------------------------------------------------------
    1511                 :            : 
    1512                 :        226 : sal_uInt16 SdrOle2Obj::GetObjIdentifier() const
    1513                 :            : {
    1514         [ -  + ]:        226 :     return bFrame ? sal_uInt16(OBJ_FRAME) : sal_uInt16(OBJ_OLE2);
    1515                 :            : }
    1516                 :            : 
    1517                 :            : // -----------------------------------------------------------------------------
    1518                 :            : 
    1519                 :          3 : void SdrOle2Obj::TakeObjNameSingul(XubString& rName) const
    1520                 :            : {
    1521 [ -  + ][ +  - ]:          3 :     rName = ImpGetResStr(bFrame ? STR_ObjNameSingulFrame : STR_ObjNameSingulOLE2);
         [ +  - ][ +  - ]
    1522                 :            : 
    1523 [ +  - ][ +  - ]:          3 :     const String aName(GetName());
    1524                 :            : 
    1525         [ -  + ]:          3 :     if( aName.Len() )
    1526                 :            :     {
    1527         [ #  # ]:          0 :         rName.AppendAscii(" '");
    1528         [ #  # ]:          0 :         rName += aName;
    1529         [ #  # ]:          0 :         rName += sal_Unicode('\'');
    1530         [ +  - ]:          3 :     }
    1531                 :          3 : }
    1532                 :            : 
    1533                 :            : // -----------------------------------------------------------------------------
    1534                 :            : 
    1535                 :          0 : void SdrOle2Obj::TakeObjNamePlural(XubString& rName) const
    1536                 :            : {
    1537 [ #  # ][ #  # ]:          0 :     rName=ImpGetResStr(bFrame ? STR_ObjNamePluralFrame : STR_ObjNamePluralOLE2);
    1538                 :          0 : }
    1539                 :            : 
    1540                 :            : // -----------------------------------------------------------------------------
    1541                 :            : 
    1542                 :          0 : SdrOle2Obj* SdrOle2Obj::Clone() const
    1543                 :            : {
    1544                 :          0 :     return CloneHelper< SdrOle2Obj >();
    1545                 :            : }
    1546                 :            : 
    1547                 :          0 : SdrOle2Obj& SdrOle2Obj::operator=(const SdrOle2Obj& rObj)
    1548                 :            : {
    1549                 :            :     //TODO/LATER: who takes over control of my old object?!
    1550         [ #  # ]:          0 :     if( &rObj != this )
    1551                 :            :     {
    1552                 :            :         // #116235#
    1553                 :            :         // ImpAssign( rObj );
    1554                 :          0 :         const SdrOle2Obj& rOle2Obj = static_cast< const SdrOle2Obj& >( rObj );
    1555                 :            : 
    1556         [ #  # ]:          0 :         uno::Reference < util::XCloseable > xClose( xObjRef.GetObject(), uno::UNO_QUERY );
    1557                 :            : 
    1558 [ #  # ][ #  # ]:          0 :         if( pModel && mpImpl->mbConnected )
    1559         [ #  # ]:          0 :             Disconnect();
    1560                 :            : 
    1561         [ #  # ]:          0 :         SdrRectObj::operator=( rObj );
    1562                 :            : 
    1563                 :            :         // Manually copying bClosedObj attribute
    1564 [ #  # ][ #  # ]:          0 :         SetClosedObj( rObj.IsClosedObj() );
    1565                 :            : 
    1566         [ #  # ]:          0 :         mpImpl->aPersistName = rOle2Obj.mpImpl->aPersistName;
    1567         [ #  # ]:          0 :         aProgName = rOle2Obj.aProgName;
    1568                 :          0 :         bFrame = rOle2Obj.bFrame;
    1569                 :            : 
    1570         [ #  # ]:          0 :         if( rOle2Obj.pGraphic )
    1571                 :            :         {
    1572         [ #  # ]:          0 :             if( pGraphic )
    1573                 :            :             {
    1574 [ #  # ][ #  # ]:          0 :                 delete pGraphic;
    1575 [ #  # ][ #  # ]:          0 :                 delete mpImpl->pGraphicObject;
    1576                 :            :             }
    1577                 :            : 
    1578 [ #  # ][ #  # ]:          0 :             pGraphic = new Graphic( *rOle2Obj.pGraphic );
    1579 [ #  # ][ #  # ]:          0 :             mpImpl->pGraphicObject = new GraphicObject( *pGraphic );
    1580                 :            :         }
    1581                 :            : 
    1582 [ #  # ][ #  # ]:          0 :         if( pModel && rObj.GetModel() && !IsEmptyPresObj() )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1583                 :            :         {
    1584                 :          0 :             ::comphelper::IEmbeddedHelper* pDestPers = pModel->GetPersist();
    1585         [ #  # ]:          0 :             ::comphelper::IEmbeddedHelper* pSrcPers = rObj.GetModel()->GetPersist();
    1586 [ #  # ][ #  # ]:          0 :             if( pDestPers && pSrcPers )
    1587                 :            :             {
    1588                 :            :                 DBG_ASSERT( !xObjRef.is(), "Object already existing!" );
    1589         [ #  # ]:          0 :                 comphelper::EmbeddedObjectContainer& rContainer = pSrcPers->getEmbeddedObjectContainer();
    1590 [ #  # ][ #  # ]:          0 :                 uno::Reference < embed::XEmbeddedObject > xObj = rContainer.GetEmbeddedObject( mpImpl->aPersistName );
    1591         [ #  # ]:          0 :                 if ( xObj.is() )
    1592                 :            :                 {
    1593                 :          0 :                     ::rtl::OUString aTmp;
    1594 [ #  # ][ #  # ]:          0 :                     xObjRef.Assign( pDestPers->getEmbeddedObjectContainer().CopyAndGetEmbeddedObject( rContainer, xObj, aTmp ), rOle2Obj.GetAspect() );
         [ #  # ][ #  # ]
    1595                 :          0 :                     m_bTypeAsked = false;
    1596         [ #  # ]:          0 :                     mpImpl->aPersistName = aTmp;
    1597         [ #  # ]:          0 :                     CheckFileLink_Impl();
    1598                 :            :                 }
    1599                 :            : 
    1600         [ #  # ]:          0 :                 Connect();
    1601                 :            :             }
    1602                 :          0 :         }
    1603                 :            :     }
    1604                 :          0 :     return *this;
    1605                 :            : }
    1606                 :            : 
    1607                 :            : // -----------------------------------------------------------------------------
    1608                 :            : 
    1609                 :          6 : void SdrOle2Obj::ImpSetVisAreaSize()
    1610                 :            : {
    1611                 :            :     // currently there is no need to recalculate scaling for iconified objects
    1612                 :            :     // TODO/LATER: it might be needed in future when it is possible to change the icon
    1613         [ -  + ]:          6 :     if ( GetAspect() == embed::Aspects::MSOLE_ICON )
    1614                 :          6 :         return;
    1615                 :            : 
    1616                 :            :     // the object area of an embedded object was changed, e.g. by user interaction an a selected object
    1617                 :          6 :     GetObjRef();
    1618         [ -  + ]:          6 :     if ( xObjRef.is() )
    1619                 :            :     {
    1620                 :            :         OSL_ASSERT( pModel );
    1621                 :          0 :         sal_Int64 nMiscStatus = xObjRef->getStatus( GetAspect() );
    1622                 :            : 
    1623                 :            :         // the client is required to get access to scaling
    1624         [ #  # ]:          0 :         SfxInPlaceClient* pClient = SfxInPlaceClient::GetClient( dynamic_cast<SfxObjectShell*>(pModel->GetPersist()), xObjRef.GetObject() );
    1625                 :            :         sal_Bool bHasOwnClient =
    1626                 :            :                         ( mpImpl->pLightClient
    1627 [ #  # ][ #  # ]:          0 :                         && xObjRef->getClientSite() == uno::Reference< embed::XEmbeddedClient >( mpImpl->pLightClient ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
    1628                 :            : 
    1629 [ #  # ][ #  # ]:          0 :         if ( pClient || bHasOwnClient )
    1630                 :            :         {
    1631                 :            :             // TODO: IMHO we need to do similar things when object is UIActive or OutplaceActive?!
    1632   [ #  #  #  #  :          0 :             if ( ((nMiscStatus & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE) &&
           #  # ][ #  # ]
    1633                 :          0 :                     svt::EmbeddedObjectRef::TryRunningState( xObjRef.GetObject() ))
    1634                 :          0 :                     || xObjRef->getCurrentState() == embed::EmbedStates::INPLACE_ACTIVE
    1635                 :            :                     )
    1636                 :            :             {
    1637                 :          0 :                 Fraction aScaleWidth;
    1638                 :          0 :                 Fraction aScaleHeight;
    1639         [ #  # ]:          0 :                 if ( pClient )
    1640                 :            :                 {
    1641 [ #  # ][ #  # ]:          0 :                     aScaleWidth = pClient->GetScaleWidth();
    1642 [ #  # ][ #  # ]:          0 :                     aScaleHeight = pClient->GetScaleHeight();
    1643                 :            :                 }
    1644                 :            :                 else
    1645                 :            :                 {
    1646 [ #  # ][ #  # ]:          0 :                     aScaleWidth = mpImpl->pLightClient->GetScaleWidth();
    1647 [ #  # ][ #  # ]:          0 :                     aScaleHeight = mpImpl->pLightClient->GetScaleHeight();
    1648                 :            :                 }
    1649                 :            : 
    1650                 :            :                 // The object wants to resize itself (f.e. Chart wants to recalculate the layout)
    1651                 :            :                 // or object is inplace active and so has a window that must be resized also
    1652                 :            :                 // In these cases the change in the object area size will be reflected in a change of the
    1653                 :            :                 // objects' visual area. The scaling will not change, but it might exist already and must
    1654                 :            :                 // be used in calculations
    1655 [ #  # ][ #  # ]:          0 :                 MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObjRef->getMapUnit( GetAspect() ) );
         [ #  # ][ #  # ]
    1656                 :            :                 Size aVisSize( (long)( Fraction( aRect.GetWidth() ) / aScaleWidth ),
    1657 [ #  # ][ #  # ]:          0 :                                 (long)( Fraction( aRect.GetHeight() ) / aScaleHeight ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
    1658                 :            : 
    1659 [ #  # ][ #  # ]:          0 :                 aVisSize = OutputDevice::LogicToLogic( aVisSize, pModel->GetScaleUnit(), aMapUnit);
                 [ #  # ]
           [ #  #  #  # ]
                 [ #  # ]
    1660                 :          0 :                 awt::Size aSz;
    1661                 :          0 :                 aSz.Width = aVisSize.Width();
    1662                 :          0 :                 aSz.Height = aVisSize.Height();
    1663 [ #  # ][ #  # ]:          0 :                 xObjRef->setVisualAreaSize( GetAspect(), aSz );
                 [ #  # ]
    1664                 :            : 
    1665                 :            :                 try
    1666                 :            :                 {
    1667 [ #  # ][ #  # ]:          0 :                     aSz = xObjRef->getVisualAreaSize( GetAspect() );
                 [ #  # ]
    1668                 :            :                 }
    1669         [ #  # ]:          0 :                 catch( embed::NoVisualAreaSizeException& )
    1670                 :            :                 {}
    1671                 :            : 
    1672         [ #  # ]:          0 :                 Rectangle aAcceptedVisArea;
    1673                 :            :                 aAcceptedVisArea.SetSize( Size( (long)( Fraction( long( aSz.Width ) ) * aScaleWidth ),
    1674 [ #  # ][ #  # ]:          0 :                                                 (long)( Fraction( long( aSz.Height ) ) * aScaleHeight ) ) );
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1675 [ #  # ][ #  # ]:          0 :                 if (aVisSize != aAcceptedVisArea.GetSize())
    1676                 :            :                 {
    1677                 :            :                     // server changed VisArea to its liking and the VisArea is different than the suggested one
    1678                 :            :                     // store the new value as given by the object
    1679 [ #  # ][ #  # ]:          0 :                     MapUnit aNewMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObjRef->getMapUnit( GetAspect() ) );
         [ #  # ][ #  # ]
    1680 [ #  # ][ #  # ]:          0 :                     aRect.SetSize(OutputDevice::LogicToLogic( aAcceptedVisArea.GetSize(), aNewMapUnit, pModel->GetScaleUnit()));
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
    1681                 :            :                 }
    1682                 :            : 
    1683                 :            :                 // make the new object area known to the client
    1684                 :            :                 // compared to the "else" branch aRect might have been changed by the object and no additional scaling was applied
    1685                 :            :                 // WHY this -> OSL_ASSERT( pClient );
    1686         [ #  # ]:          0 :                 if( pClient )
    1687         [ #  # ]:          0 :                     pClient->SetObjArea(aRect);
    1688                 :            : 
    1689                 :            :                 // we need a new replacement image as the object has resized itself
    1690                 :            : 
    1691                 :            :                 //#i79578# don't request a new replacement image for charts to often
    1692                 :            :                 //a chart sends a modified call to the framework if it was changed
    1693                 :            :                 //thus the replacement update is already handled there
    1694 [ #  # ][ #  # ]:          0 :                 if( !IsChart() )
    1695         [ #  # ]:          0 :                     xObjRef.UpdateReplacement();
    1696                 :            :             }
    1697                 :            :             else
    1698                 :            :             {
    1699                 :            :                 // The object isn't active and does not want to resize itself so the changed object area size
    1700                 :            :                 // will be reflected in a changed object scaling
    1701                 :          0 :                 Fraction aScaleWidth;
    1702                 :          0 :                 Fraction aScaleHeight;
    1703                 :          0 :                 Size aObjAreaSize;
    1704 [ #  # ][ #  # ]:          0 :                 if ( CalculateNewScaling( aScaleWidth, aScaleHeight, aObjAreaSize ) )
    1705                 :            :                 {
    1706         [ #  # ]:          0 :                     if ( pClient )
    1707                 :            :                     {
    1708         [ #  # ]:          0 :                         Rectangle aScaleRect(aRect.TopLeft(), aObjAreaSize);
    1709         [ #  # ]:          0 :                         pClient->SetObjAreaAndScale( aScaleRect, aScaleWidth, aScaleHeight);
    1710                 :            :                     }
    1711                 :            :                     else
    1712                 :            :                     {
    1713         [ #  # ]:          0 :                         mpImpl->pLightClient->SetSizeScale( aScaleWidth, aScaleHeight );
    1714                 :            :                     }
    1715                 :            :                 }
    1716                 :          0 :             }
    1717                 :            :         }
    1718   [ #  #  #  # ]:          0 :         else if( (nMiscStatus & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE) &&
                 [ #  # ]
    1719                 :          0 :             svt::EmbeddedObjectRef::TryRunningState( xObjRef.GetObject() ) )
    1720                 :            :         {
    1721                 :            :             //also handle not sfx based ole objects e.g. charts
    1722                 :            :             //#i83860# resizing charts in impress distorts fonts
    1723 [ #  # ][ #  # ]:          0 :             uno::Reference< embed::XVisualObject > xVisualObject( this->getXModel(), uno::UNO_QUERY );
    1724         [ #  # ]:          0 :             if( xVisualObject.is() )
    1725                 :            :             {
    1726 [ #  # ][ #  # ]:          0 :                 MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xObjRef->getMapUnit( GetAspect() ) );
         [ #  # ][ #  # ]
    1727                 :          0 :                 Point aTL( aRect.TopLeft() );
    1728         [ #  # ]:          0 :                 Point aBR( aRect.BottomRight() );
    1729 [ #  # ][ #  # ]:          0 :                 Point aTL2( OutputDevice::LogicToLogic( aTL, pModel->GetScaleUnit(), aMapUnit) );
         [ #  # ][ #  # ]
                 [ #  # ]
    1730 [ #  # ][ #  # ]:          0 :                 Point aBR2( OutputDevice::LogicToLogic( aBR, pModel->GetScaleUnit(), aMapUnit) );
         [ #  # ][ #  # ]
                 [ #  # ]
    1731         [ #  # ]:          0 :                 Rectangle aNewRect( aTL2, aBR2 );
    1732 [ #  # ][ #  # ]:          0 :                 xVisualObject->setVisualAreaSize( GetAspect(), awt::Size( aNewRect.GetWidth(), aNewRect.GetHeight() ) );
         [ #  # ][ #  # ]
                 [ #  # ]
    1733                 :          0 :             }
    1734                 :            :         }
    1735                 :            :     }
    1736                 :            : }
    1737                 :            : 
    1738                 :            : // -----------------------------------------------------------------------------
    1739                 :            : 
    1740                 :          0 : void SdrOle2Obj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
    1741                 :            : {
    1742 [ #  # ][ #  # ]:          0 :     if( pModel && !pModel->isLocked() )
                 [ #  # ]
    1743                 :            :     {
    1744                 :          0 :         GetObjRef();
    1745 [ #  # ][ #  # ]:          0 :         if ( xObjRef.is() && ( xObjRef->getStatus( GetAspect() ) & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE ) )
                 [ #  # ]
    1746                 :            :         {
    1747                 :            :             // if the object needs recompose on resize
    1748                 :            :             // the client site should be created before the resize will take place
    1749                 :            :             // check whether there is no client site and create it if necessary
    1750                 :          0 :             AddOwnLightClient();
    1751                 :            :         }
    1752                 :            :     }
    1753                 :            : 
    1754                 :          0 :     SdrRectObj::NbcResize(rRef,xFact,yFact);
    1755 [ #  # ][ #  # ]:          0 :     if (aGeo.nShearWink!=0 || aGeo.nDrehWink!=0) { // little corrections
    1756 [ #  # ][ #  # ]:          0 :         if (aGeo.nDrehWink>=9000 && aGeo.nDrehWink<27000) {
    1757                 :          0 :             aRect.Move(aRect.Left()-aRect.Right(),aRect.Top()-aRect.Bottom());
    1758                 :            :         }
    1759                 :          0 :         aGeo.nDrehWink=0;
    1760                 :          0 :         aGeo.nShearWink=0;
    1761                 :          0 :         aGeo.nSin=0.0;
    1762                 :          0 :         aGeo.nCos=1.0;
    1763                 :          0 :         aGeo.nTan=0.0;
    1764                 :          0 :         SetRectsDirty();
    1765                 :            :     }
    1766 [ #  # ][ #  # ]:          0 :     if( pModel && !pModel->isLocked() )
                 [ #  # ]
    1767                 :          0 :         ImpSetVisAreaSize();
    1768                 :          0 : }
    1769                 :            : 
    1770                 :            : // -----------------------------------------------------------------------------
    1771                 :            : 
    1772                 :          0 : void SdrOle2Obj::SetGeoData(const SdrObjGeoData& rGeo)
    1773                 :            : {
    1774                 :          0 :     SdrRectObj::SetGeoData(rGeo);
    1775 [ #  # ][ #  # ]:          0 :     if( pModel && !pModel->isLocked() )
                 [ #  # ]
    1776                 :          0 :         ImpSetVisAreaSize();
    1777                 :          0 : }
    1778                 :            : 
    1779                 :            : // -----------------------------------------------------------------------------
    1780                 :            : 
    1781                 :          2 : void SdrOle2Obj::NbcSetSnapRect(const Rectangle& rRect)
    1782                 :            : {
    1783                 :          2 :     SdrRectObj::NbcSetSnapRect(rRect);
    1784 [ +  - ][ +  - ]:          2 :     if( pModel && !pModel->isLocked() )
                 [ +  - ]
    1785                 :          2 :         ImpSetVisAreaSize();
    1786                 :            : 
    1787 [ -  + ][ #  # ]:          2 :     if ( xObjRef.is() && IsChart() )
                 [ -  + ]
    1788                 :            :     {
    1789                 :            :         //#i103460# charts do not necessarily have an own size within ODF files,
    1790                 :            :         //for this case they need to use the size settings from the surrounding frame,
    1791                 :            :         //which is made available with this method as there is no other way
    1792         [ #  # ]:          0 :         xObjRef.SetDefaultSizeForChart( Size( rRect.GetWidth(), rRect.GetHeight() ) );
    1793                 :            :     }
    1794                 :          2 : }
    1795                 :            : 
    1796                 :            : // -----------------------------------------------------------------------------
    1797                 :            : 
    1798                 :         11 : void SdrOle2Obj::NbcSetLogicRect(const Rectangle& rRect)
    1799                 :            : {
    1800                 :         11 :     SdrRectObj::NbcSetLogicRect(rRect);
    1801 [ +  + ][ +  + ]:         11 :     if( pModel && !pModel->isLocked() )
                 [ +  - ]
    1802                 :          2 :         ImpSetVisAreaSize();
    1803                 :         11 : }
    1804                 :            : 
    1805                 :        230 : Graphic* SdrOle2Obj::GetGraphic() const
    1806                 :            : {
    1807         [ +  + ]:        230 :     if ( xObjRef.is() )
    1808                 :        221 :         return xObjRef.GetGraphic();
    1809                 :        230 :     return pGraphic;
    1810                 :            : }
    1811                 :            : 
    1812                 :          0 : void SdrOle2Obj::GetNewReplacement()
    1813                 :            : {
    1814         [ #  # ]:          0 :     if ( xObjRef.is() )
    1815                 :          0 :         xObjRef.UpdateReplacement();
    1816                 :          0 : }
    1817                 :            : 
    1818                 :            : // -----------------------------------------------------------------------------
    1819                 :            : 
    1820                 :          0 : Size SdrOle2Obj::GetOrigObjSize( MapMode* pTargetMapMode ) const
    1821                 :            : {
    1822                 :          0 :     return xObjRef.GetSize( pTargetMapMode );
    1823                 :            : }
    1824                 :            : 
    1825                 :            : // -----------------------------------------------------------------------------
    1826                 :            : 
    1827                 :          0 : void SdrOle2Obj::NbcMove(const Size& rSize)
    1828                 :            : {
    1829                 :          0 :     SdrRectObj::NbcMove(rSize);
    1830 [ #  # ][ #  # ]:          0 :     if( pModel && !pModel->isLocked() )
                 [ #  # ]
    1831                 :          0 :         ImpSetVisAreaSize();
    1832                 :          0 : }
    1833                 :            : 
    1834                 :            : // -----------------------------------------------------------------------------
    1835                 :            : 
    1836                 :          0 : sal_Bool SdrOle2Obj::CanUnloadRunningObj( const uno::Reference< embed::XEmbeddedObject >& xObj, sal_Int64 nAspect )
    1837                 :            : {
    1838                 :          0 :     sal_Bool bResult = sal_False;
    1839                 :            : 
    1840                 :          0 :     sal_Int32 nState = xObj->getCurrentState();
    1841         [ #  # ]:          0 :     if ( nState == embed::EmbedStates::LOADED )
    1842                 :            :     {
    1843                 :            :         // the object is already unloaded
    1844                 :          0 :         bResult = sal_True;
    1845                 :            :     }
    1846                 :            :     else
    1847                 :            :     {
    1848 [ #  # ][ #  # ]:          0 :         uno::Reference < util::XModifiable > xModifiable( xObj->getComponent(), uno::UNO_QUERY );
                 [ #  # ]
    1849         [ #  # ]:          0 :         if ( !xModifiable.is() )
    1850                 :          0 :             bResult = sal_True;
    1851                 :            :         else
    1852                 :            :         {
    1853 [ #  # ][ #  # ]:          0 :             sal_Int64 nMiscStatus = xObj->getStatus( nAspect );
    1854                 :            : 
    1855         [ #  # ]:          0 :             if ( embed::EmbedMisc::MS_EMBED_ALWAYSRUN != ( nMiscStatus & embed::EmbedMisc::MS_EMBED_ALWAYSRUN ) &&
           [ #  #  #  # ]
         [ #  # ][ #  # ]
    1856                 :            :             embed::EmbedMisc::EMBED_ACTIVATEIMMEDIATELY != ( nMiscStatus & embed::EmbedMisc::EMBED_ACTIVATEIMMEDIATELY ) &&
    1857 [ #  # ][ #  # ]:          0 :             !( xModifiable.is() && xModifiable->isModified() ) &&
                 [ #  # ]
    1858 [ #  # ][ #  # ]:          0 :             !( nState == embed::EmbedStates::INPLACE_ACTIVE || nState == embed::EmbedStates::UI_ACTIVE || nState == embed::EmbedStates::ACTIVE ) )
    1859                 :            :             {
    1860                 :          0 :                 bResult = sal_True;
    1861                 :            :             }
    1862                 :          0 :         }
    1863                 :            :     }
    1864                 :            : 
    1865                 :          0 :     return bResult;
    1866                 :            : }
    1867                 :            : 
    1868                 :            : // -----------------------------------------------------------------------------
    1869                 :            : 
    1870                 :          0 : sal_Bool SdrOle2Obj::Unload( const uno::Reference< embed::XEmbeddedObject >& xObj, sal_Int64 nAspect )
    1871                 :            : {
    1872                 :          0 :     sal_Bool bResult = sal_False;
    1873                 :            : 
    1874         [ #  # ]:          0 :     if ( CanUnloadRunningObj( xObj, nAspect ) )
    1875                 :            :     {
    1876                 :            :         try
    1877                 :            :         {
    1878 [ #  # ][ #  # ]:          0 :             xObj->changeState( embed::EmbedStates::LOADED );
    1879                 :          0 :             bResult = sal_True;
    1880                 :            :         }
    1881                 :          0 :         catch( ::com::sun::star::uno::Exception& )
    1882                 :            :         {
    1883                 :            :             OSL_FAIL(
    1884                 :            :                 (OString("SdrOle2Obj::Unload=(), "
    1885                 :            :                         "exception caught: ") +
    1886                 :            :                 rtl::OUStringToOString(
    1887                 :            :                     comphelper::anyToString( cppu::getCaughtException() ),
    1888                 :            :                     RTL_TEXTENCODING_UTF8 )).getStr() );
    1889                 :            :         }
    1890                 :            :     }
    1891                 :            : 
    1892         [ #  # ]:          0 :     return bResult;
    1893                 :            : }
    1894                 :            : 
    1895                 :            : // -----------------------------------------------------------------------------
    1896                 :            : 
    1897                 :          0 : sal_Bool SdrOle2Obj::Unload()
    1898                 :            : {
    1899                 :          0 :     sal_Bool bUnloaded = sal_False;
    1900                 :            : 
    1901         [ #  # ]:          0 :     if( xObjRef.is() )
    1902                 :            :     {
    1903                 :            :         //TODO/LATER: no refcounting tricks anymore!
    1904                 :            :         //"customers" must register as state change listeners
    1905                 :            :         // Not necessary in Doc DTor (MM)
    1906                 :            :         //sal_uIntPtr nRefCount = (*ppObjRef)->GetRefCount();
    1907                 :            :         // prevent Unload if there are external references
    1908                 :            :         //if( nRefCount > 2 )
    1909                 :            :         //    return sal_False;
    1910                 :            :         //DBG_ASSERT( nRefCount == 2, "Wrong RefCount for unload" );
    1911                 :            :     }
    1912                 :            :     else
    1913                 :          0 :         bUnloaded = sal_True;
    1914                 :            : 
    1915 [ #  # ][ #  # ]:          0 :     if ( pModel && xObjRef.is() )
                 [ #  # ]
    1916                 :            :     {
    1917                 :          0 :         bUnloaded = Unload( xObjRef.GetObject(), GetAspect() );
    1918                 :            :     }
    1919                 :            : 
    1920                 :          0 :     return bUnloaded;
    1921                 :            : }
    1922                 :            : 
    1923                 :            : // -----------------------------------------------------------------------------
    1924                 :            : 
    1925                 :        507 : void SdrOle2Obj::GetObjRef_Impl()
    1926                 :            : {
    1927 [ +  + ][ -  + ]:        507 :     if ( !xObjRef.is() && mpImpl->aPersistName.Len() && pModel && pModel->GetPersist() )
         [ #  # ][ #  # ]
                 [ -  + ]
    1928                 :            :     {
    1929                 :            :         // Only try loading if it did not went wrong up to now
    1930         [ #  # ]:          0 :         if(!mpImpl->mbLoadingOLEObjectFailed)
    1931                 :            :         {
    1932 [ #  # ][ #  # ]:          0 :             xObjRef.Assign( pModel->GetPersist()->getEmbeddedObjectContainer().GetEmbeddedObject( mpImpl->aPersistName ), GetAspect() );
                 [ #  # ]
    1933                 :          0 :             m_bTypeAsked = false;
    1934                 :          0 :             CheckFileLink_Impl();
    1935                 :            : 
    1936                 :            :             // If loading of OLE object failed, remember that to not invoke a endless
    1937                 :            :             // loop trying to load it again and again.
    1938         [ #  # ]:          0 :             if( xObjRef.is() )
    1939                 :            :             {
    1940                 :          0 :                 mpImpl->mbLoadingOLEObjectFailed = sal_True;
    1941                 :            :             }
    1942                 :            : 
    1943                 :            :             // For math objects, set closed state to transparent
    1944         [ #  # ]:          0 :             if( ImplIsMathObj( xObjRef.GetObject() ) )
    1945                 :          0 :                 SetClosedObj( false );
    1946                 :            :         }
    1947                 :            : 
    1948         [ #  # ]:          0 :         if ( xObjRef.is() )
    1949                 :            :         {
    1950         [ #  # ]:          0 :             if( !IsEmptyPresObj() )
    1951                 :            :             {
    1952                 :            :                 // remember modified status of model
    1953         [ #  # ]:          0 :                 const sal_Bool bWasChanged(pModel ? pModel->IsChanged() : sal_False);
    1954                 :            : 
    1955                 :            :                 // perhaps preview not valid anymore
    1956                 :            :                 // This line changes the modified state of the model
    1957                 :          0 :                 SetGraphic_Impl( NULL );
    1958                 :            : 
    1959                 :            :                 // if status was not set before, force it back
    1960                 :            :                 // to not set, so that SetGraphic(0L) above does not
    1961                 :            :                 // set the modified state of the model.
    1962 [ #  # ][ #  # ]:          0 :                 if(!bWasChanged && pModel && pModel->IsChanged())
         [ #  # ][ #  # ]
    1963                 :            :                 {
    1964                 :          0 :                     pModel->SetChanged( sal_False );
    1965                 :            :                 }
    1966                 :            :             }
    1967                 :            : 
    1968                 :          0 :             sal_Int64 nMiscStatus = xObjRef->getStatus( GetAspect() );
    1969                 :            :             (void)nMiscStatus;
    1970                 :            :             //TODO/LATER: wait until ResizeOnPrinterChange is defined
    1971                 :            :             //if ( nMiscStatus & SVOBJ_MISCSTATUS_RESIZEONPRINTERCHANGE )
    1972                 :            :             {
    1973   [ #  #  #  # ]:          0 :                 if (pModel && pModel->GetRefDevice() &&
         [ #  # ][ #  # ]
    1974                 :          0 :                     pModel->GetRefDevice()->GetOutDevType() == OUTDEV_PRINTER)
    1975                 :            :                 {
    1976                 :          0 :                     if(!bInDestruction)
    1977                 :            :                     {
    1978                 :            :                         //TODO/LATER: printerchange notification
    1979                 :            :                         /*
    1980                 :            :                         // prevent SetModified (don't want no update here)
    1981                 :            :                         sal_Bool bWasEnabled = (*ppObjRef)->IsEnableSetModified();
    1982                 :            :                         if ( bWasEnabled )
    1983                 :            :                             (*ppObjRef)->EnableSetModified( sal_False );
    1984                 :            : 
    1985                 :            :                         // Kein RefDevice oder RefDevice kein Printer
    1986                 :            :                         Printer* pPrinter = (Printer*) pModel->GetRefDevice();
    1987                 :            :                         (*ppObjRef)->OnDocumentPrinterChanged( pPrinter );
    1988                 :            : 
    1989                 :            :                         // reset state
    1990                 :            :                         (*ppObjRef)->EnableSetModified( bWasEnabled );*/
    1991                 :            :                     }
    1992                 :            :                 }
    1993                 :            :             }
    1994                 :            :         }
    1995                 :            : 
    1996         [ #  # ]:          0 :         if ( xObjRef.is() )
    1997                 :          0 :             Connect();
    1998                 :            :     }
    1999                 :            : 
    2000         [ +  + ]:        507 :     if ( mpImpl->mbConnected )
    2001                 :            :         // move object to first position in cache
    2002                 :        479 :         GetSdrGlobalData().GetOLEObjCache().InsertObj(this);
    2003                 :        507 : }
    2004                 :            : 
    2005                 :        507 : uno::Reference < embed::XEmbeddedObject > SdrOle2Obj::GetObjRef() const
    2006                 :            : {
    2007                 :        507 :     const_cast<SdrOle2Obj*>(this)->GetObjRef_Impl();
    2008                 :        507 :     return xObjRef.GetObject();
    2009                 :            : }
    2010                 :            : 
    2011                 :          0 : uno::Reference < embed::XEmbeddedObject > SdrOle2Obj::GetObjRef_NoInit() const
    2012                 :            : {
    2013                 :          0 :     return xObjRef.GetObject();
    2014                 :            : }
    2015                 :            : 
    2016                 :            : // -----------------------------------------------------------------------------
    2017                 :            : 
    2018                 :         52 : uno::Reference< frame::XModel > SdrOle2Obj::getXModel() const
    2019                 :            : {
    2020                 :         52 :     GetObjRef();
    2021         [ +  - ]:         52 :     if ( svt::EmbeddedObjectRef::TryRunningState(xObjRef.GetObject()) )
    2022         [ +  - ]:         52 :         return uno::Reference< frame::XModel >( xObjRef->getComponent(), uno::UNO_QUERY );
    2023                 :            :     else
    2024                 :         52 :         return uno::Reference< frame::XModel >();
    2025                 :            : }
    2026                 :            : 
    2027                 :            : // -----------------------------------------------------------------------------
    2028                 :            : 
    2029                 :        238 : sal_Bool SdrOle2Obj::IsChart() const
    2030                 :            : {
    2031         [ +  + ]:        238 :     if ( !m_bTypeAsked )
    2032                 :            :     {
    2033                 :         20 :         m_bChart = ChartPrettyPainter::IsChart(xObjRef);
    2034                 :         20 :         m_bTypeAsked = true;
    2035                 :            :     }
    2036                 :        238 :     return m_bChart;
    2037                 :            : }
    2038                 :            : 
    2039                 :            : // -----------------------------------------------------------------------------
    2040                 :          0 : void SdrOle2Obj::SetGraphicToObj( const Graphic& aGraphic, const ::rtl::OUString& aMediaType )
    2041                 :            : {
    2042                 :          0 :     xObjRef.SetGraphic( aGraphic, aMediaType );
    2043                 :          0 : }
    2044                 :            : 
    2045                 :            : // -----------------------------------------------------------------------------
    2046                 :          0 : void SdrOle2Obj::SetGraphicToObj( const uno::Reference< io::XInputStream >& xGrStream, const ::rtl::OUString& aMediaType )
    2047                 :            : {
    2048                 :          0 :     xObjRef.SetGraphicStream( xGrStream, aMediaType );
    2049                 :          0 : }
    2050                 :            : 
    2051                 :            : // -----------------------------------------------------------------------------
    2052                 :          0 : sal_Bool SdrOle2Obj::IsCalc() const
    2053                 :            : {
    2054         [ #  # ]:          0 :     if ( !xObjRef.is() )
    2055                 :          0 :         return false;
    2056                 :            : 
    2057 [ #  # ][ #  # ]:          0 :     SvGlobalName aObjClsId( xObjRef->getClassID() );
         [ #  # ][ #  # ]
    2058 [ #  # ][ #  # ]:          0 :     if(    SvGlobalName(SO3_SC_CLASSID_30) == aObjClsId
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
                 [ #  # ]
           [ #  #  #  # ]
    2059 [ #  # ][ #  # ]:          0 :         || SvGlobalName(SO3_SC_CLASSID_40) == aObjClsId
         [ #  # ][ #  # ]
                 [ #  # ]
    2060 [ #  # ][ #  # ]:          0 :         || SvGlobalName(SO3_SC_CLASSID_50) == aObjClsId
         [ #  # ][ #  # ]
                 [ #  # ]
    2061 [ #  # ][ #  # ]:          0 :         || SvGlobalName(SO3_SC_CLASSID_60) == aObjClsId
         [ #  # ][ #  # ]
                 [ #  # ]
    2062 [ #  # ][ #  # ]:          0 :         || SvGlobalName(SO3_SC_OLE_EMBED_CLASSID_60) == aObjClsId
         [ #  # ][ #  # ]
                 [ #  # ]
    2063 [ #  # ][ #  # ]:          0 :         || SvGlobalName(SO3_SC_OLE_EMBED_CLASSID_8) == aObjClsId
         [ #  # ][ #  # ]
                 [ #  # ]
    2064 [ #  # ][ #  # ]:          0 :         || SvGlobalName(SO3_SC_CLASSID) == aObjClsId )
         [ #  # ][ #  # ]
                 [ #  # ]
    2065                 :            :     {
    2066                 :          0 :         return sal_True;
    2067                 :            :     }
    2068                 :            : 
    2069         [ #  # ]:          0 :     return sal_False;
    2070                 :            : }
    2071                 :            : 
    2072                 :            : // -----------------------------------------------------------------------------
    2073                 :          0 : uno::Reference< frame::XModel > SdrOle2Obj::GetParentXModel() const
    2074                 :            : {
    2075                 :          0 :     uno::Reference< frame::XModel > xDoc;
    2076         [ #  # ]:          0 :     if ( pModel )
    2077 [ #  # ][ #  # ]:          0 :         xDoc.set( pModel->getUnoModel(),uno::UNO_QUERY);
    2078                 :          0 :     return xDoc;
    2079                 :            : }
    2080                 :            : 
    2081                 :            : // -----------------------------------------------------------------------------
    2082                 :          0 : sal_Bool SdrOle2Obj::CalculateNewScaling( Fraction& aScaleWidth, Fraction& aScaleHeight, Size& aObjAreaSize )
    2083                 :            : {
    2084                 :            :     // TODO/LEAN: to avoid rounding errors scaling always uses the VisArea.
    2085                 :            :     // If we don't cache it for own objects also we must load the object here
    2086 [ #  # ][ #  # ]:          0 :     if ( !xObjRef.is() || !pModel )
                 [ #  # ]
    2087                 :          0 :         return sal_False;
    2088                 :            : 
    2089         [ #  # ]:          0 :     MapMode aMapMode( pModel->GetScaleUnit() );
    2090         [ #  # ]:          0 :     aObjAreaSize = xObjRef.GetSize( &aMapMode );
    2091                 :            : 
    2092         [ #  # ]:          0 :     Size aSize = aRect.GetSize();
    2093 [ #  # ][ #  # ]:          0 :     aScaleWidth = Fraction(aSize.Width(),  aObjAreaSize.Width() );
    2094 [ #  # ][ #  # ]:          0 :     aScaleHeight = Fraction(aSize.Height(), aObjAreaSize.Height() );
    2095                 :            : 
    2096                 :            :     // reduce to 10 binary digits
    2097         [ #  # ]:          0 :     Kuerzen(aScaleHeight, 10);
    2098         [ #  # ]:          0 :     Kuerzen(aScaleWidth,  10);
    2099                 :            : 
    2100         [ #  # ]:          0 :     return sal_True;
    2101                 :            : }
    2102                 :            : 
    2103                 :            : // -----------------------------------------------------------------------------
    2104                 :          0 : sal_Bool SdrOle2Obj::AddOwnLightClient()
    2105                 :            : {
    2106                 :            :     // The Own Light Client must be registered in object only using this method!
    2107 [ #  # ][ #  # ]:          0 :     if ( !SfxInPlaceClient::GetClient( dynamic_cast<SfxObjectShell*>(pModel->GetPersist()), xObjRef.GetObject() )
         [ #  # ][ #  # ]
                 [ #  # ]
    2108 [ #  # ][ #  # ]:          0 :       && !( mpImpl->pLightClient && xObjRef->getClientSite() == uno::Reference< embed::XEmbeddedClient >( mpImpl->pLightClient ) ) )
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
         [ #  # ][ #  # ]
           [ #  #  #  # ]
    2109                 :            :     {
    2110                 :          0 :         Connect();
    2111                 :            : 
    2112 [ #  # ][ #  # ]:          0 :         if ( xObjRef.is() && mpImpl->pLightClient )
                 [ #  # ]
    2113                 :            :         {
    2114                 :          0 :             Fraction aScaleWidth;
    2115                 :          0 :             Fraction aScaleHeight;
    2116                 :          0 :             Size aObjAreaSize;
    2117 [ #  # ][ #  # ]:          0 :             if ( CalculateNewScaling( aScaleWidth, aScaleHeight, aObjAreaSize ) )
    2118                 :            :             {
    2119         [ #  # ]:          0 :                 mpImpl->pLightClient->SetSizeScale( aScaleWidth, aScaleHeight );
    2120                 :            :                 try {
    2121 [ #  # ][ #  # ]:          0 :                     xObjRef->setClientSite( mpImpl->pLightClient );
         [ #  # ][ #  # ]
                 [ #  # ]
    2122                 :          0 :                     return sal_True;
    2123         [ #  # ]:          0 :                 } catch( uno::Exception& )
    2124                 :            :                 {}
    2125                 :            :             }
    2126                 :            : 
    2127                 :            :         }
    2128                 :            : 
    2129                 :          0 :         return sal_False;
    2130                 :            :     }
    2131                 :            : 
    2132                 :          0 :        return sal_True;
    2133                 :            : }
    2134                 :            : 
    2135                 :            : //////////////////////////////////////////////////////////////////////////////
    2136                 :            : 
    2137                 :          3 : Bitmap SdrOle2Obj::GetEmtyOLEReplacementBitmap()
    2138                 :            : {
    2139         [ +  - ]:          3 :     return Bitmap(ResId(BMP_SVXOLEOBJ, *ImpGetResMgr()));
    2140                 :            : }
    2141                 :            : 
    2142                 :            : //////////////////////////////////////////////////////////////////////////////
    2143                 :            : 
    2144                 :          0 : void SdrOle2Obj::SetWindow(const com::sun::star::uno::Reference < com::sun::star::awt::XWindow >& _xWindow)
    2145                 :            : {
    2146 [ #  # ][ #  # ]:          0 :     if ( xObjRef.is() && mpImpl->pLightClient )
                 [ #  # ]
    2147                 :            :     {
    2148                 :          0 :         mpImpl->pLightClient->setWindow(_xWindow);
    2149                 :            :     }
    2150                 :          0 : }
    2151                 :            : 
    2152                 :            : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10