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