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