1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
9 * This file incorporates work covered by the following license notice:
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
20 #include <svx/svdoole2.hxx>
22 #include <com/sun/star/beans/XPropertySet.hpp>
23 #include <com/sun/star/util/XModifyBroadcaster.hpp>
24 #include <com/sun/star/util/XModifiable.hpp>
25 #include <com/sun/star/embed/EmbedStates.hpp>
26 #include <com/sun/star/embed/EmbedMisc.hpp>
27 #include <com/sun/star/embed/Aspects.hpp>
28 #include <com/sun/star/embed/ObjectSaveVetoException.hpp>
29 #include <com/sun/star/embed/XEmbeddedObject.hpp>
30 #include <com/sun/star/embed/XEmbedPersist2.hpp>
31 #include <com/sun/star/embed/XInplaceClient.hpp>
32 #include <com/sun/star/embed/XInplaceObject.hpp>
33 #include <com/sun/star/embed/XLinkageSupport.hpp>
34 #include <com/sun/star/embed/NoVisualAreaSizeException.hpp>
35 #include <com/sun/star/embed/XWindowSupplier.hpp>
36 #include <com/sun/star/document/XEventListener.hpp>
37 #include <com/sun/star/container/XChild.hpp>
38 #include <com/sun/star/document/XStorageBasedDocument.hpp>
39 #include <com/sun/star/lang/WrappedTargetRuntimeException.hpp>
41 #include <cppuhelper/exc_hlp.hxx>
43 #include <toolkit/helper/vclunohelper.hxx>
45 #include <svtools/colorcfg.hxx>
46 #include <svtools/embedhlp.hxx>
48 #include <sfx2/objsh.hxx>
49 #include <sfx2/ipclient.hxx>
50 #include <sfx2/lnkbase.hxx>
51 #include <sfx2/linkmgr.hxx>
52 #include <tools/debug.hxx>
53 #include <tools/globname.hxx>
54 #include <comphelper/diagnose_ex.hxx>
55 #include <comphelper/classids.hxx>
56 #include <comphelper/propertyvalue.hxx>
58 #include <sot/formats.hxx>
59 #include <cppuhelper/implbase.hxx>
61 #include <vcl/svapp.hxx>
62 #include <vcl/unohelp.hxx>
64 #include <svx/svdmodel.hxx>
65 #include <svx/dialmgr.hxx>
66 #include <svx/strings.hrc>
67 #include <svx/svdetc.hxx>
68 #include <unomlstr.hxx>
69 #include <sdr/contact/viewcontactofsdrole2obj.hxx>
70 #include <svx/svdograf.hxx>
71 #include <sdr/properties/oleproperties.hxx>
72 #include <svx/unoshape.hxx>
73 #include <svx/xlineit0.hxx>
74 #include <svx/xlnclit.hxx>
75 #include <svx/xbtmpit.hxx>
76 #include <svx/xfillit0.hxx>
77 #include <svx/xflbmtit.hxx>
78 #include <svx/xflbstit.hxx>
79 #include <basegfx/matrix/b2dhommatrix.hxx>
80 #include <basegfx/polygon/b2dpolypolygon.hxx>
81 #include <editeng/outlobj.hxx>
82 #include <svx/svdpage.hxx>
83 #include <rtl/ustrbuf.hxx>
84 #include <rtl/ref.hxx>
85 #include <bitmaps.hlst>
87 using namespace ::com::sun::star
;
89 static uno::Reference
< beans::XPropertySet
> lcl_getFrame_throw(const SdrOle2Obj
* _pObject
)
91 uno::Reference
< beans::XPropertySet
> xFrame
;
94 uno::Reference
< frame::XController
> xController
= _pObject
->GetParentXModel()->getCurrentController();
95 if ( xController
.is() )
97 xFrame
.set( xController
->getFrame(),uno::UNO_QUERY_THROW
);
105 class SdrLightEmbeddedClient_Impl
: public ::cppu::WeakImplHelper
106 < embed::XStateChangeListener
107 , document::XEventListener
108 , embed::XInplaceClient
109 , embed::XEmbeddedClient
110 , embed::XWindowSupplier
113 uno::Reference
< awt::XWindow
> m_xWindow
;
116 Fraction m_aScaleWidth
;
117 Fraction m_aScaleHeight
;
121 explicit SdrLightEmbeddedClient_Impl( SdrOle2Obj
* pObj
);
122 virtual ~SdrLightEmbeddedClient_Impl() override
;
124 void SetSizeScale( const Fraction
& aScaleWidth
, const Fraction
& aScaleHeight
)
126 m_aScaleWidth
= aScaleWidth
;
127 m_aScaleHeight
= aScaleHeight
;
130 const Fraction
& GetScaleWidth() const { return m_aScaleWidth
; }
131 const Fraction
& GetScaleHeight() const { return m_aScaleHeight
; }
133 void setWindow(const uno::Reference
< awt::XWindow
>& _xWindow
);
138 tools::Rectangle
impl_getScaledRect_nothrow() const;
139 // XStateChangeListener
140 virtual void SAL_CALL
changingState( const css::lang::EventObject
& aEvent
, ::sal_Int32 nOldState
, ::sal_Int32 nNewState
) override
;
141 virtual void SAL_CALL
stateChanged( const css::lang::EventObject
& aEvent
, ::sal_Int32 nOldState
, ::sal_Int32 nNewState
) override
;
142 virtual void SAL_CALL
disposing( const css::lang::EventObject
& aEvent
) override
;
144 // document::XEventListener
145 virtual void SAL_CALL
notifyEvent( const document::EventObject
& aEvent
) override
;
148 virtual void SAL_CALL
saveObject() override
;
149 virtual void SAL_CALL
visibilityChanged( sal_Bool bVisible
) override
;
151 // XComponentSupplier
152 virtual uno::Reference
< util::XCloseable
> SAL_CALL
getComponent() override
;
155 virtual sal_Bool SAL_CALL
canInplaceActivate() override
;
156 virtual void SAL_CALL
activatingInplace() override
;
157 virtual void SAL_CALL
activatingUI() override
;
158 virtual void SAL_CALL
deactivatedInplace() override
;
159 virtual void SAL_CALL
deactivatedUI() override
;
160 virtual uno::Reference
< css::frame::XLayoutManager
> SAL_CALL
getLayoutManager() override
;
161 virtual uno::Reference
< frame::XDispatchProvider
> SAL_CALL
getInplaceDispatchProvider() override
;
162 virtual awt::Rectangle SAL_CALL
getPlacement() override
;
163 virtual awt::Rectangle SAL_CALL
getClipRectangle() override
;
164 virtual void SAL_CALL
translateAccelerators( const uno::Sequence
< awt::KeyEvent
>& aKeys
) override
;
165 virtual void SAL_CALL
scrollObject( const awt::Size
& aOffset
) override
;
166 virtual void SAL_CALL
changedPlacement( const awt::Rectangle
& aPosRect
) override
;
169 virtual uno::Reference
< awt::XWindow
> SAL_CALL
getWindow() override
;
174 SdrLightEmbeddedClient_Impl::SdrLightEmbeddedClient_Impl( SdrOle2Obj
* pObj
)
178 SdrLightEmbeddedClient_Impl::~SdrLightEmbeddedClient_Impl()
182 tools::Rectangle
SdrLightEmbeddedClient_Impl::impl_getScaledRect_nothrow() const
184 tools::Rectangle
aLogicRect( mpObj
->GetLogicRect() );
185 // apply scaling to object area and convert to pixels
186 aLogicRect
.SetSize( Size( tools::Long( aLogicRect
.GetWidth() * m_aScaleWidth
),
187 tools::Long( aLogicRect
.GetHeight() * m_aScaleHeight
) ) );
191 void SAL_CALL
SdrLightEmbeddedClient_Impl::changingState( const css::lang::EventObject
& /*aEvent*/, ::sal_Int32
/*nOldState*/, ::sal_Int32
/*nNewState*/ )
195 void SAL_CALL
SdrLightEmbeddedClient_Impl::stateChanged( const css::lang::EventObject
& /*aEvent*/, ::sal_Int32 nOldState
, ::sal_Int32 nNewState
)
197 SolarMutexGuard aGuard
;
199 if ( mpObj
&& nOldState
== embed::EmbedStates::LOADED
&& nNewState
== embed::EmbedStates::RUNNING
)
201 mpObj
->ObjectLoaded();
202 GetSdrGlobalData().GetOLEObjCache().InsertObj(mpObj
);
204 else if ( mpObj
&& nNewState
== embed::EmbedStates::LOADED
&& nOldState
== embed::EmbedStates::RUNNING
)
206 GetSdrGlobalData().GetOLEObjCache().RemoveObj(mpObj
);
210 void SdrLightEmbeddedClient_Impl::disconnect()
212 SolarMutexGuard aGuard
;
215 GetSdrGlobalData().GetOLEObjCache().RemoveObj(mpObj
);
219 void SAL_CALL
SdrLightEmbeddedClient_Impl::disposing( const css::lang::EventObject
& /*aEvent*/ )
224 void SAL_CALL
SdrLightEmbeddedClient_Impl::notifyEvent( const document::EventObject
& aEvent
)
226 // TODO/LATER: when writer uses this implementation the code could be shared with SfxInPlaceClient_Impl
228 SolarMutexGuard aGuard
;
230 // the code currently makes sense only in case there is no other client
231 if ( !(mpObj
&& mpObj
->GetAspect() != embed::Aspects::MSOLE_ICON
&& aEvent
.EventName
== "OnVisAreaChanged"
232 && mpObj
->GetObjRef().is() && mpObj
->GetObjRef()->getClientSite() == uno::Reference
< embed::XEmbeddedClient
>( this )) )
237 MapUnit
aContainerMapUnit( MapUnit::Map100thMM
);
238 uno::Reference
< embed::XVisualObject
> xParentVis( mpObj
->GetParentXModel(), uno::UNO_QUERY
);
239 if ( xParentVis
.is() )
240 aContainerMapUnit
= VCLUnoHelper::UnoEmbed2VCLMapUnit( xParentVis
->getMapUnit( mpObj
->GetAspect() ) );
242 MapUnit aObjMapUnit
= VCLUnoHelper::UnoEmbed2VCLMapUnit( mpObj
->GetObjRef()->getMapUnit( mpObj
->GetAspect() ) );
244 tools::Rectangle aVisArea
;
248 aSz
= mpObj
->GetObjRef()->getVisualAreaSize( mpObj
->GetAspect() );
250 catch( embed::NoVisualAreaSizeException
& )
252 TOOLS_WARN_EXCEPTION("svx.svdraw", "No visual area size!");
256 catch( uno::Exception
& )
258 TOOLS_WARN_EXCEPTION("svx.svdraw", "");
263 aVisArea
.SetSize( Size( aSz
.Width
, aSz
.Height
) );
264 aVisArea
= OutputDevice::LogicToLogic(aVisArea
, MapMode(aObjMapUnit
), MapMode(aContainerMapUnit
));
265 Size
aScaledSize( static_cast< tools::Long
>( m_aScaleWidth
* Fraction( aVisArea
.GetWidth() ) ),
266 static_cast< tools::Long
>( m_aScaleHeight
* Fraction( aVisArea
.GetHeight() ) ) );
267 tools::Rectangle
aLogicRect( mpObj
->GetLogicRect() );
269 // react to the change if the difference is bigger than one pixel
271 Application::GetDefaultDevice()->LogicToPixel(
272 Size( aLogicRect
.GetWidth() - aScaledSize
.Width(),
273 aLogicRect
.GetHeight() - aScaledSize
.Height() ),
274 MapMode(aContainerMapUnit
));
275 if( aPixelDiff
.Width() || aPixelDiff
.Height() )
277 mpObj
->SetLogicRect( tools::Rectangle( aLogicRect
.TopLeft(), aScaledSize
) );
278 mpObj
->BroadcastObjectChange();
281 mpObj
->ActionChanged();
283 catch( uno::Exception
& )
285 TOOLS_WARN_EXCEPTION("svx.svdraw", "");
289 void SAL_CALL
SdrLightEmbeddedClient_Impl::saveObject()
291 // TODO/LATER: when writer uses this implementation the code could be shared with SfxInPlaceClient_Impl
292 uno::Reference
< embed::XCommonEmbedPersist
> xPersist
;
293 uno::Reference
< util::XModifiable
> xModifiable
;
296 SolarMutexGuard aGuard
;
299 throw embed::ObjectSaveVetoException();
301 // the common persistence is supported by objects and links
302 xPersist
.set( mpObj
->GetObjRef(), uno::UNO_QUERY_THROW
);
303 xModifiable
.set( mpObj
->GetParentXModel(), uno::UNO_QUERY
);
306 xPersist
->storeOwn();
308 if ( xModifiable
.is() )
309 xModifiable
->setModified( true );
312 void SAL_CALL
SdrLightEmbeddedClient_Impl::visibilityChanged( sal_Bool
/*bVisible*/ )
314 // nothing to do currently
315 // TODO/LATER: when writer uses this implementation the code could be shared with SfxInPlaceClient_Impl
318 tools::Rectangle
aLogicRect( mpObj
->GetLogicRect() );
319 Size
aLogicSize( aLogicRect
.GetWidth(), aLogicRect
.GetHeight() );
321 if( mpObj
->IsChart() )
323 //charts never should be stretched see #i84323# for example
324 mpObj
->SetLogicRect( tools::Rectangle( aLogicRect
.TopLeft(), aLogicSize
) );
325 mpObj
->BroadcastObjectChange();
326 } // if( mpObj->IsChart() )
330 uno::Reference
< util::XCloseable
> SAL_CALL
SdrLightEmbeddedClient_Impl::getComponent()
332 uno::Reference
< util::XCloseable
> xResult
;
334 SolarMutexGuard aGuard
;
336 xResult
.set( mpObj
->GetParentXModel(), uno::UNO_QUERY
);
342 sal_Bool SAL_CALL
SdrLightEmbeddedClient_Impl::canInplaceActivate()
345 SolarMutexGuard aGuard
;
348 uno::Reference
< embed::XEmbeddedObject
> xObject
= mpObj
->GetObjRef();
350 throw uno::RuntimeException();
351 // we don't want to switch directly from outplace to inplace mode
352 bRet
= ( xObject
->getCurrentState() != embed::EmbedStates::ACTIVE
&& mpObj
->GetAspect() != embed::Aspects::MSOLE_ICON
);
357 void SAL_CALL
SdrLightEmbeddedClient_Impl::activatingInplace()
361 void SAL_CALL
SdrLightEmbeddedClient_Impl::activatingUI()
363 SolarMutexGuard aGuard
;
365 uno::Reference
< beans::XPropertySet
> xFrame( lcl_getFrame_throw(mpObj
));
366 uno::Reference
< frame::XFrame
> xOwnFrame( xFrame
,uno::UNO_QUERY
);
367 uno::Reference
< frame::XFramesSupplier
> xParentFrame
= xOwnFrame
->getCreator();
368 if ( xParentFrame
.is() )
369 xParentFrame
->setActiveFrame( xOwnFrame
);
371 OLEObjCache
& rObjCache
= GetSdrGlobalData().GetOLEObjCache();
372 const size_t nCount
= rObjCache
.size();
373 for(sal_Int32 i
= nCount
-1 ; i
>= 0;--i
)
375 SdrOle2Obj
* pObj
= rObjCache
[i
];
378 // only deactivate ole objects which belongs to the same frame
379 if ( xFrame
== lcl_getFrame_throw(pObj
) )
381 const uno::Reference
< embed::XEmbeddedObject
>& xObject
= pObj
->GetObjRef();
384 if ( xObject
->getStatus( pObj
->GetAspect() ) & embed::EmbedMisc::MS_EMBED_ACTIVATEWHENVISIBLE
)
385 xObject
->changeState( embed::EmbedStates::INPLACE_ACTIVE
);
388 // the links should not stay in running state for long time because of locking
389 uno::Reference
< embed::XLinkageSupport
> xLink( xObject
, uno::UNO_QUERY
);
390 if ( xLink
.is() && xLink
->isLink() )
391 xObject
->changeState( embed::EmbedStates::LOADED
);
393 xObject
->changeState( embed::EmbedStates::RUNNING
);
396 catch (css::uno::Exception
& )
400 } // for(sal_Int32 i = nCount-1 ; i >= 0;--i)
403 void SAL_CALL
SdrLightEmbeddedClient_Impl::deactivatedInplace()
407 void SAL_CALL
SdrLightEmbeddedClient_Impl::deactivatedUI()
409 SolarMutexGuard aGuard
;
410 css::uno::Reference
< css::frame::XLayoutManager
> xLayoutManager(getLayoutManager());
411 if ( xLayoutManager
.is() )
413 static constexpr OUString aMenuBarURL
= u
"private:resource/menubar/menubar"_ustr
;
414 if ( !xLayoutManager
->isElementVisible( aMenuBarURL
) )
415 xLayoutManager
->createElement( aMenuBarURL
);
419 uno::Reference
< css::frame::XLayoutManager
> SAL_CALL
SdrLightEmbeddedClient_Impl::getLayoutManager()
421 uno::Reference
< css::frame::XLayoutManager
> xMan
;
422 SolarMutexGuard aGuard
;
423 uno::Reference
< beans::XPropertySet
> xFrame( lcl_getFrame_throw(mpObj
));
426 xMan
.set(xFrame
->getPropertyValue(u
"LayoutManager"_ustr
),uno::UNO_QUERY
);
428 catch ( uno::Exception
& ex
)
430 css::uno::Any anyEx
= cppu::getCaughtException();
431 throw css::lang::WrappedTargetRuntimeException( ex
.Message
,
438 uno::Reference
< frame::XDispatchProvider
> SAL_CALL
SdrLightEmbeddedClient_Impl::getInplaceDispatchProvider()
440 SolarMutexGuard aGuard
;
441 return uno::Reference
< frame::XDispatchProvider
>( lcl_getFrame_throw(mpObj
), uno::UNO_QUERY_THROW
);
444 awt::Rectangle SAL_CALL
SdrLightEmbeddedClient_Impl::getPlacement()
446 SolarMutexGuard aGuard
;
448 throw uno::RuntimeException();
450 tools::Rectangle aLogicRect
= impl_getScaledRect_nothrow();
451 MapUnit
aContainerMapUnit( MapUnit::Map100thMM
);
452 uno::Reference
< embed::XVisualObject
> xParentVis( mpObj
->GetParentXModel(), uno::UNO_QUERY
);
453 if ( xParentVis
.is() )
454 aContainerMapUnit
= VCLUnoHelper::UnoEmbed2VCLMapUnit( xParentVis
->getMapUnit( mpObj
->GetAspect() ) );
456 aLogicRect
= Application::GetDefaultDevice()->LogicToPixel(aLogicRect
, MapMode(aContainerMapUnit
));
457 return vcl::unohelper::ConvertToAWTRect(aLogicRect
);
460 awt::Rectangle SAL_CALL
SdrLightEmbeddedClient_Impl::getClipRectangle()
462 return getPlacement();
465 void SAL_CALL
SdrLightEmbeddedClient_Impl::translateAccelerators( const uno::Sequence
< awt::KeyEvent
>& /*aKeys*/ )
469 void SAL_CALL
SdrLightEmbeddedClient_Impl::scrollObject( const awt::Size
& /*aOffset*/ )
473 void SAL_CALL
SdrLightEmbeddedClient_Impl::changedPlacement( const awt::Rectangle
& aPosRect
)
475 SolarMutexGuard aGuard
;
477 throw uno::RuntimeException();
479 uno::Reference
< embed::XInplaceObject
> xInplace( mpObj
->GetObjRef(), uno::UNO_QUERY_THROW
);
481 // check if the change is at least one pixel in size
482 awt::Rectangle aOldRect
= getPlacement();
483 tools::Rectangle aNewPixelRect
= vcl::unohelper::ConvertToVCLRect(aPosRect
);
484 tools::Rectangle aOldPixelRect
= vcl::unohelper::ConvertToVCLRect(aOldRect
);
485 if ( aOldPixelRect
== aNewPixelRect
)
486 // nothing has changed
489 // new scaled object area
490 MapUnit
aContainerMapUnit( MapUnit::Map100thMM
);
491 uno::Reference
< embed::XVisualObject
> xParentVis( mpObj
->GetParentXModel(), uno::UNO_QUERY
);
492 if ( xParentVis
.is() )
493 aContainerMapUnit
= VCLUnoHelper::UnoEmbed2VCLMapUnit( xParentVis
->getMapUnit( mpObj
->GetAspect() ) );
495 tools::Rectangle aNewLogicRect
= Application::GetDefaultDevice()->PixelToLogic(aNewPixelRect
, MapMode(aContainerMapUnit
));
496 tools::Rectangle aLogicRect
= impl_getScaledRect_nothrow();
498 if ( aNewLogicRect
== aLogicRect
)
501 // the calculation of the object area has not changed the object size
502 // it should be done here then
503 //SfxBooleanFlagGuard aGuard( m_bResizeNoScale, true );
505 // new size of the object area without scaling
506 Size
aNewObjSize( tools::Long( aNewLogicRect
.GetWidth() / m_aScaleWidth
),
507 tools::Long( aNewLogicRect
.GetHeight() / m_aScaleHeight
) );
509 // now remove scaling from new placement and keep this at the new object area
510 aNewLogicRect
.SetSize( aNewObjSize
);
511 // react to the change if the difference is bigger than one pixel
513 Application::GetDefaultDevice()->LogicToPixel(
514 Size( aLogicRect
.GetWidth() - aNewObjSize
.Width(),
515 aLogicRect
.GetHeight() - aNewObjSize
.Height() ),
516 MapMode(aContainerMapUnit
));
517 if( aPixelDiff
.Width() || aPixelDiff
.Height() )
519 mpObj
->SetLogicRect( tools::Rectangle( aLogicRect
.TopLeft(), aNewObjSize
) );
520 mpObj
->BroadcastObjectChange();
523 mpObj
->ActionChanged();
527 uno::Reference
< awt::XWindow
> SAL_CALL
SdrLightEmbeddedClient_Impl::getWindow()
529 SolarMutexGuard aGuard
;
530 uno::Reference
< awt::XWindow
> xCurrent
= m_xWindow
;
531 if ( !xCurrent
.is() )
534 throw uno::RuntimeException();
535 uno::Reference
< frame::XFrame
> xFrame(lcl_getFrame_throw(mpObj
),uno::UNO_QUERY_THROW
);
536 xCurrent
= xFrame
->getComponentWindow();
537 } // if ( !xCurrent.is() )
540 void SdrLightEmbeddedClient_Impl::setWindow(const uno::Reference
< awt::XWindow
>& _xWindow
)
542 m_xWindow
= _xWindow
;
545 SdrEmbedObjectLink::SdrEmbedObjectLink(SdrOle2Obj
* pObject
):
546 ::sfx2::SvBaseLink( ::SfxLinkUpdateMode::ONCALL
, SotClipboardFormatId::SVXB
),
549 SetSynchron( false );
552 SdrEmbedObjectLink::~SdrEmbedObjectLink()
556 ::sfx2::SvBaseLink::UpdateResult
SdrEmbedObjectLink::DataChanged(
557 const OUString
& /*rMimeType*/, const css::uno::Any
& /*rValue*/ )
559 if ( !pObj
->UpdateLinkURL_Impl() )
561 // the link URL was not changed
562 uno::Reference
< embed::XEmbeddedObject
> xObject
= pObj
->GetObjRef();
563 OSL_ENSURE( xObject
.is(), "The object must exist always!" );
566 // let the object reload the link
567 // TODO/LATER: reload call could be used for this case
571 sal_Int32 nState
= xObject
->getCurrentState();
572 if ( nState
!= embed::EmbedStates::LOADED
)
574 // in some cases the linked file probably is not locked so it could be changed
575 xObject
->changeState( embed::EmbedStates::LOADED
);
576 xObject
->changeState( nState
);
579 catch ( uno::Exception
& )
585 pObj
->GetNewReplacement();
591 void SdrEmbedObjectLink::Closed()
593 pObj
->BreakFileLink_Impl();
594 SvBaseLink::Closed();
597 SdrIFrameLink::SdrIFrameLink(SdrOle2Obj
* pObject
)
598 : ::sfx2::SvBaseLink(::SfxLinkUpdateMode::ONCALL
, SotClipboardFormatId::SVXB
)
601 SetSynchron( false );
604 ::sfx2::SvBaseLink::UpdateResult
SdrIFrameLink::DataChanged(
605 const OUString
&, const uno::Any
& )
607 uno::Reference
<embed::XEmbeddedObject
> xObject
= m_pObject
->GetObjRef();
608 uno::Reference
<embed::XCommonEmbedPersist
> xPersObj(xObject
, uno::UNO_QUERY
);
611 // let the IFrameObject reload the link
614 xPersObj
->reload(uno::Sequence
<beans::PropertyValue
>(), uno::Sequence
<beans::PropertyValue
>());
616 catch (const uno::Exception
&)
620 m_pObject
->SetChanged();
629 svt::EmbeddedObjectRef mxObjRef
;
631 std::optional
<Graphic
> moGraphic
;
633 OUString aPersistName
; // name of object in persist
634 rtl::Reference
<SdrLightEmbeddedClient_Impl
> mxLightClient
; // must be registered as client only using AddOwnLightClient() call
636 bool mbFrame
:1; // Due to compatibility at SdrTextObj for now
637 bool mbSuppressSetVisAreaSize
:1; // #i118524#
638 mutable bool mbTypeAsked
:1;
639 mutable bool mbIsChart
:1;
640 bool mbLoadingOLEObjectFailed
:1; // New local var to avoid repeated loading if load of OLE2 fails
642 bool mbIgnoreOLEObjectScale
: 1 = false; // See SdXMLObjectShapeContext::createFastChildContext
644 sfx2::SvBaseLink
* mpObjectLink
;
647 rtl::Reference
<SvxUnoShapeModifyListener
> mxModifyListener
;
649 explicit SdrOle2ObjImpl( bool bFrame
) :
651 mbSuppressSetVisAreaSize(false),
654 mbLoadingOLEObjectFailed(false),
656 mpObjectLink(nullptr)
661 SdrOle2ObjImpl( bool bFrame
, const svt::EmbeddedObjectRef
& rObjRef
) :
664 mbSuppressSetVisAreaSize(false),
667 mbLoadingOLEObjectFailed(false),
669 mpObjectLink(nullptr)
678 if (mxModifyListener
.is())
680 mxModifyListener
->invalidate();
685 // Predicate determining whether the given OLE is an internal math
687 static bool ImplIsMathObj( const uno::Reference
< embed::XEmbeddedObject
>& rObjRef
)
692 SvGlobalName
aClassName( rObjRef
->getClassID() );
693 return aClassName
== SvGlobalName(SO3_SM_CLASSID_30
) ||
694 aClassName
== SvGlobalName(SO3_SM_CLASSID_40
) ||
695 aClassName
== SvGlobalName(SO3_SM_CLASSID_50
) ||
696 aClassName
== SvGlobalName(SO3_SM_CLASSID_60
) ||
697 aClassName
== SvGlobalName(SO3_SM_CLASSID
);
700 // BaseProperties section
702 std::unique_ptr
<sdr::properties::BaseProperties
> SdrOle2Obj::CreateObjectSpecificProperties()
704 return std::make_unique
<sdr::properties::OleProperties
>(*this);
707 // DrawContact section
709 std::unique_ptr
<sdr::contact::ViewContact
> SdrOle2Obj::CreateObjectSpecificViewContact()
711 return std::make_unique
<sdr::contact::ViewContactOfSdrOle2Obj
>(*this);
714 void SdrOle2Obj::Init()
716 // Stuff that was done from old SetModel:
717 // #i43086# #i85304 redo the change for charts for the above bugfix, as #i43086# does not occur anymore
718 // so maybe the ImpSetVisAreaSize call can be removed here completely
719 // Nevertheless I leave it in for other objects as I am not sure about the side effects when removing now
720 if(!getSdrModelFromSdrObject().isLocked() && !IsChart())
725 ::comphelper::IEmbeddedHelper
* pDestPers(getSdrModelFromSdrObject().GetPersist());
726 if(pDestPers
&& !IsEmptyPresObj())
728 // object wasn't connected, now it should be
735 SdrOle2Obj::SdrOle2Obj(
738 : SdrRectObj(rSdrModel
),
739 mpImpl(new SdrOle2ObjImpl(bFrame_
))
744 SdrOle2Obj::SdrOle2Obj(SdrModel
& rSdrModel
, SdrOle2Obj
const & rSource
)
745 : SdrRectObj(rSdrModel
, rSource
),
746 mpImpl(new SdrOle2ObjImpl(/*bFrame*/false))
750 // Manually copying bClosedObj attribute
751 SetClosedObj( rSource
.IsClosedObj() );
753 mpImpl
->aPersistName
= rSource
.mpImpl
->aPersistName
;
754 mpImpl
->maProgName
= rSource
.mpImpl
->maProgName
;
755 mpImpl
->mbFrame
= rSource
.mpImpl
->mbFrame
;
757 if (rSource
.mpImpl
->moGraphic
)
759 mpImpl
->moGraphic
.emplace(*rSource
.mpImpl
->moGraphic
);
762 if( IsEmptyPresObj() )
765 ::comphelper::IEmbeddedHelper
* pDestPers(getSdrModelFromSdrObject().GetPersist());
766 ::comphelper::IEmbeddedHelper
* pSrcPers(rSource
.getSdrModelFromSdrObject().GetPersist());
767 if( !(pDestPers
&& pSrcPers
) )
770 DBG_ASSERT( !mpImpl
->mxObjRef
.is(), "Object already existing!" );
771 comphelper::EmbeddedObjectContainer
& rContainer
= pSrcPers
->getEmbeddedObjectContainer();
772 uno::Reference
< embed::XEmbeddedObject
> xObj
= rContainer
.GetEmbeddedObject( mpImpl
->aPersistName
);
776 mpImpl
->mxObjRef
.Assign( pDestPers
->getEmbeddedObjectContainer().CopyAndGetEmbeddedObject(
777 rContainer
, xObj
, aTmp
, pSrcPers
->getDocumentBaseURL(), pDestPers
->getDocumentBaseURL()), rSource
.GetAspect());
778 mpImpl
->mbTypeAsked
= false;
779 mpImpl
->aPersistName
= aTmp
;
780 CheckFileLink_Impl();
786 SdrOle2Obj::SdrOle2Obj(
788 const svt::EmbeddedObjectRef
& rNewObjRef
,
789 const OUString
& rNewObjName
,
790 const tools::Rectangle
& rNewRect
)
791 : SdrRectObj(rSdrModel
, rNewRect
),
792 mpImpl(new SdrOle2ObjImpl(false/*bFrame_*/, rNewObjRef
))
794 osl_atomic_increment(&m_refCount
);
796 mpImpl
->aPersistName
= rNewObjName
;
798 if (mpImpl
->mxObjRef
.is() && (mpImpl
->mxObjRef
->getStatus( GetAspect() ) & embed::EmbedMisc::EMBED_NEVERRESIZE
) )
801 // For math objects, set closed state to transparent
802 SetClosedObj(!ImplIsMathObj( mpImpl
->mxObjRef
.GetObject() ));
806 osl_atomic_decrement(&m_refCount
);
809 OUString
SdrOle2Obj::GetStyleString()
812 if (mpImpl
->mxObjRef
.is() && mpImpl
->mxObjRef
.IsChart())
814 strStyle
= mpImpl
->mxObjRef
.GetChartType();
819 SdrOle2Obj::~SdrOle2Obj()
821 if ( mpImpl
->mbConnected
)
824 DisconnectFileLink_Impl();
826 if (mpImpl
->mxLightClient
)
828 mpImpl
->mxLightClient
->disconnect();
829 mpImpl
->mxLightClient
.clear();
833 void SdrOle2Obj::SetAspect( sal_Int64 nAspect
)
835 mpImpl
->mxObjRef
.SetViewAspect( nAspect
);
838 const svt::EmbeddedObjectRef
& SdrOle2Obj::getEmbeddedObjectRef() const
840 return mpImpl
->mxObjRef
;
843 sal_Int64
SdrOle2Obj::GetAspect() const
845 return mpImpl
->mxObjRef
.GetViewAspect();
848 bool SdrOle2Obj::isInplaceActive() const
850 return mpImpl
->mxObjRef
.is() && embed::EmbedStates::INPLACE_ACTIVE
== mpImpl
->mxObjRef
->getCurrentState();
853 bool SdrOle2Obj::isUiActive() const
855 return mpImpl
->mxObjRef
.is() && embed::EmbedStates::UI_ACTIVE
== mpImpl
->mxObjRef
->getCurrentState();
858 void SdrOle2Obj::SetGraphic(const Graphic
& rGrf
)
860 // only for setting a preview graphic
861 mpImpl
->moGraphic
.emplace(rGrf
);
864 BroadcastObjectChange();
867 void SdrOle2Obj::ClearGraphic()
869 mpImpl
->moGraphic
.reset();
872 BroadcastObjectChange();
875 void SdrOle2Obj::SetProgName( const OUString
& rName
)
877 mpImpl
->maProgName
= rName
;
880 const OUString
& SdrOle2Obj::GetProgName() const
882 return mpImpl
->maProgName
;
885 bool SdrOle2Obj::IsEmpty() const
887 return !mpImpl
->mxObjRef
.is();
890 void SdrOle2Obj::Connect(SvxOle2Shape
* pCreator
)
892 if( IsEmptyPresObj() )
895 if( mpImpl
->mbConnected
)
897 // currently there are situations where it seems to be unavoidable to have multiple connects
898 // changing this would need a larger code rewrite, so for now I remove the assertion
899 // OSL_FAIL("Connect() called on connected object!");
903 Connect_Impl(pCreator
);
907 bool SdrOle2Obj::UpdateLinkURL_Impl()
909 bool bResult
= false;
911 if ( mpImpl
->mpObjectLink
)
913 sfx2::LinkManager
* pLinkManager(getSdrModelFromSdrObject().GetLinkManager());
917 OUString aNewLinkURL
;
918 sfx2::LinkManager::GetDisplayNames( mpImpl
->mpObjectLink
, nullptr, &aNewLinkURL
);
919 if ( !aNewLinkURL
.equalsIgnoreAsciiCase( mpImpl
->maLinkURL
) )
922 uno::Reference
<embed::XCommonEmbedPersist
> xPersObj( mpImpl
->mxObjRef
.GetObject(), uno::UNO_QUERY
);
923 OSL_ENSURE( xPersObj
.is(), "The object must exist!" );
928 sal_Int32 nCurState
= mpImpl
->mxObjRef
->getCurrentState();
929 if ( nCurState
!= embed::EmbedStates::LOADED
)
930 mpImpl
->mxObjRef
->changeState(embed::EmbedStates::LOADED
);
932 // TODO/LATER: there should be possible to get current mediadescriptor settings from the object
933 uno::Sequence
< beans::PropertyValue
> aArgs
{ comphelper::makePropertyValue(
934 u
"URL"_ustr
, aNewLinkURL
) };
935 xPersObj
->reload( aArgs
, uno::Sequence
< beans::PropertyValue
>() );
937 mpImpl
->maLinkURL
= aNewLinkURL
;
940 if ( nCurState
!= embed::EmbedStates::LOADED
)
941 mpImpl
->mxObjRef
->changeState(nCurState
);
943 catch( css::uno::Exception
const & )
945 TOOLS_WARN_EXCEPTION( "svx", "SdrOle2Obj::UpdateLinkURL_Impl()" );
951 // TODO/LATER: return the old name to the link manager, is it possible?
960 void SdrOle2Obj::BreakFileLink_Impl()
962 uno::Reference
<document::XStorageBasedDocument
> xDoc(getSdrModelFromSdrObject().getUnoModel(), uno::UNO_QUERY
);
967 uno::Reference
< embed::XStorage
> xStorage
= xDoc
->getDocumentStorage();
968 if ( !xStorage
.is() )
973 uno::Reference
< embed::XLinkageSupport
> xLinkSupport( mpImpl
->mxObjRef
.GetObject(), uno::UNO_QUERY_THROW
);
974 xLinkSupport
->breakLink( xStorage
, mpImpl
->aPersistName
);
975 DisconnectFileLink_Impl();
976 mpImpl
->maLinkURL
.clear();
978 catch( css::uno::Exception
& )
980 TOOLS_WARN_EXCEPTION( "svx", "SdrOle2Obj::BreakFileLink_Impl()" );
984 void SdrOle2Obj::DisconnectFileLink_Impl()
986 sfx2::LinkManager
* pLinkManager(getSdrModelFromSdrObject().GetLinkManager());
988 if ( pLinkManager
&& mpImpl
->mpObjectLink
)
990 pLinkManager
->Remove( mpImpl
->mpObjectLink
);
991 mpImpl
->mpObjectLink
= nullptr;
995 void SdrOle2Obj::CheckFileLink_Impl()
997 if (!mpImpl
->mxObjRef
.GetObject().is() || mpImpl
->mpObjectLink
)
1002 uno::Reference
<embed::XEmbeddedObject
> xObject
= mpImpl
->mxObjRef
.GetObject();
1006 bool bIFrame
= false;
1009 uno::Reference
<embed::XLinkageSupport
> xLinkSupport(xObject
, uno::UNO_QUERY
);
1012 if (xLinkSupport
->isLink())
1013 aLinkURL
= xLinkSupport
->getLinkURL();
1017 // get IFrame (Floating Frames) listed and updatable from the
1018 // manage links dialog
1019 SvGlobalName
aClassId(xObject
->getClassID());
1020 if (aClassId
== SvGlobalName(SO3_IFRAME_CLASSID
))
1022 uno::Reference
<beans::XPropertySet
> xSet(xObject
->getComponent(), uno::UNO_QUERY
);
1024 xSet
->getPropertyValue(u
"FrameURL"_ustr
) >>= aLinkURL
;
1029 if (!aLinkURL
.isEmpty()) // this is a file link so the model link manager should handle it
1031 sfx2::LinkManager
* pLinkManager(getSdrModelFromSdrObject().GetLinkManager());
1035 SdrEmbedObjectLink
* pEmbedObjectLink
= nullptr;
1038 pEmbedObjectLink
= new SdrEmbedObjectLink(this);
1039 mpImpl
->mpObjectLink
= pEmbedObjectLink
;
1042 mpImpl
->mpObjectLink
= new SdrIFrameLink(this);
1043 mpImpl
->maLinkURL
= aLinkURL
;
1044 pLinkManager
->InsertFileLink( *mpImpl
->mpObjectLink
, sfx2::SvBaseLinkObjectType::ClientOle
, aLinkURL
);
1045 if (pEmbedObjectLink
)
1046 pEmbedObjectLink
->Connect();
1050 catch (const css::uno::Exception
&)
1052 TOOLS_WARN_EXCEPTION("svx", "SdrOle2Obj::CheckFileLink_Impl()");
1056 void SdrOle2Obj::Connect_Impl(SvxOle2Shape
* pCreator
)
1058 if(mpImpl
->aPersistName
.isEmpty() )
1063 ::comphelper::IEmbeddedHelper
* pPers(getSdrModelFromSdrObject().GetPersist());
1067 comphelper::EmbeddedObjectContainer
& rContainer
= pPers
->getEmbeddedObjectContainer();
1069 if ( !rContainer
.HasEmbeddedObject( mpImpl
->aPersistName
)
1070 || ( mpImpl
->mxObjRef
.is() && !rContainer
.HasEmbeddedObject( mpImpl
->mxObjRef
.GetObject() ) ) )
1072 // object not known to container document
1073 // No object -> disaster!
1074 DBG_ASSERT( mpImpl
->mxObjRef
.is(), "No object in connect!");
1075 if ( mpImpl
->mxObjRef
.is() )
1077 // object came from the outside, now add it to the container
1079 rContainer
.InsertEmbeddedObject( mpImpl
->mxObjRef
.GetObject(), aTmp
);
1080 mpImpl
->aPersistName
= aTmp
;
1083 else if ( !mpImpl
->mxObjRef
.is() )
1085 mpImpl
->mxObjRef
.Assign( rContainer
.GetEmbeddedObject( mpImpl
->aPersistName
), mpImpl
->mxObjRef
.GetViewAspect() );
1086 mpImpl
->mbTypeAsked
= false;
1089 if ( mpImpl
->mxObjRef
.GetObject().is() )
1091 mpImpl
->mxObjRef
.AssignToContainer( &rContainer
, mpImpl
->aPersistName
);
1092 mpImpl
->mbConnected
= true;
1093 mpImpl
->mxObjRef
.Lock();
1099 OUString
sFrameURL(pCreator
->GetAndClearInitialFrameURL());
1100 if (!sFrameURL
.isEmpty() && svt::EmbeddedObjectRef::TryRunningState(mpImpl
->mxObjRef
.GetObject()))
1102 uno::Reference
<beans::XPropertySet
> xSet(mpImpl
->mxObjRef
->getComponent(), uno::UNO_QUERY
);
1104 xSet
->setPropertyValue(u
"FrameURL"_ustr
, uno::Any(sFrameURL
));
1108 if ( mpImpl
->mxObjRef
.is() )
1110 if ( !mpImpl
->mxLightClient
.is() )
1111 mpImpl
->mxLightClient
= new SdrLightEmbeddedClient_Impl( this );
1113 mpImpl
->mxObjRef
->addStateChangeListener( mpImpl
->mxLightClient
);
1114 mpImpl
->mxObjRef
->addEventListener( mpImpl
->mxLightClient
);
1116 if ( mpImpl
->mxObjRef
->getCurrentState() != embed::EmbedStates::LOADED
)
1117 GetSdrGlobalData().GetOLEObjCache().InsertObj(this);
1119 CheckFileLink_Impl();
1121 uno::Reference
< container::XChild
> xChild( mpImpl
->mxObjRef
.GetObject(), uno::UNO_QUERY
);
1124 uno::Reference
< uno::XInterface
> xParent( getSdrModelFromSdrObject().getUnoModel());
1126 xChild
->setParent( getSdrModelFromSdrObject().getUnoModel() );
1131 catch( css::uno::Exception
& )
1133 TOOLS_WARN_EXCEPTION( "svx", "SdrOle2Obj::Connect_Impl()" );
1137 void SdrOle2Obj::ObjectLoaded()
1139 AddListeners_Impl();
1142 void SdrOle2Obj::AddListeners_Impl()
1144 if( !(mpImpl
->mxObjRef
.is() && mpImpl
->mxObjRef
->getCurrentState() != embed::EmbedStates::LOADED
) )
1147 // register modify listener
1148 if (!mpImpl
->mxModifyListener
.is())
1150 mpImpl
->mxModifyListener
= new SvxUnoShapeModifyListener(this);
1153 uno::Reference
< util::XModifyBroadcaster
> xBC( getXModel(), uno::UNO_QUERY
);
1156 xBC
->addModifyListener( mpImpl
->mxModifyListener
);
1160 void SdrOle2Obj::Disconnect()
1162 if( IsEmptyPresObj() )
1165 if( !mpImpl
->mbConnected
)
1167 OSL_FAIL("Disconnect() called on disconnected object!");
1171 RemoveListeners_Impl();
1175 void SdrOle2Obj::RemoveListeners_Impl()
1177 if ( !mpImpl
->mxObjRef
.is() || mpImpl
->aPersistName
.isEmpty() )
1182 sal_Int32 nState
= mpImpl
->mxObjRef
->getCurrentState();
1183 if ( nState
!= embed::EmbedStates::LOADED
)
1185 uno::Reference
< util::XModifyBroadcaster
> xBC( getXModel(), uno::UNO_QUERY
);
1186 if (xBC
.is() && mpImpl
->mxModifyListener
.is())
1188 xBC
->removeModifyListener( mpImpl
->mxModifyListener
);
1192 catch( css::uno::Exception
& )
1194 TOOLS_WARN_EXCEPTION( "svx", "SdrOle2Obj::RemoveListeners_Impl()" );
1198 void SdrOle2Obj::Disconnect_Impl()
1202 if ( !mpImpl
->aPersistName
.isEmpty() )
1204 if( getSdrModelFromSdrObject().IsInDestruction() )
1206 // TODO/LATER: here we must assume that the destruction of the model is enough to make clear that we will not
1207 // remove the object from the container, even if the DrawingObject itself is not destroyed (unfortunately this
1208 // There is no real need to do the following removing of the object from the container
1209 // in case the model has correct persistence, but in case of problems such a removing
1210 // would make the behavior of the office more stable
1212 comphelper::EmbeddedObjectContainer
* pContainer
= mpImpl
->mxObjRef
.GetContainer();
1215 pContainer
->CloseEmbeddedObject( mpImpl
->mxObjRef
.GetObject() );
1216 mpImpl
->mxObjRef
.AssignToContainer( nullptr, mpImpl
->aPersistName
);
1219 // happens later than the destruction of the model, so we can't assert that).
1220 //DBG_ASSERT( bInDestruction, "Model is destroyed, but not me?!" );
1221 //TODO/LATER: should be make sure that the ObjectShell also forgets the object, because we will close it soon?
1223 uno::Reference < util::XCloseable > xClose( xObjRef, uno::UNO_QUERY );
1228 xClose->close( true );
1230 catch ( util::CloseVetoException& )
1232 // there's still someone who needs the object!
1238 else if ( mpImpl
->mxObjRef
.is() )
1240 if ( getSdrModelFromSdrObject().getUnoModel().is() )
1242 // remove object, but don't close it (that's up to someone else)
1243 comphelper::EmbeddedObjectContainer
* pContainer
= mpImpl
->mxObjRef
.GetContainer();
1246 pContainer
->RemoveEmbeddedObject( mpImpl
->mxObjRef
.GetObject() );
1248 // TODO/LATER: mpImpl->aPersistName contains outdated information, to keep it updated
1249 // it should be returned from RemoveEmbeddedObject call. Currently it is no problem,
1250 // since no container is adjusted, actually the empty string could be provided as a name here
1251 mpImpl
->mxObjRef
.AssignToContainer( nullptr, mpImpl
->aPersistName
);
1254 DisconnectFileLink_Impl();
1259 if ( mpImpl
->mxObjRef
.is() && mpImpl
->mxLightClient
.is() )
1261 mpImpl
->mxObjRef
->removeStateChangeListener ( mpImpl
->mxLightClient
);
1262 mpImpl
->mxObjRef
->removeEventListener( mpImpl
->mxLightClient
);
1263 mpImpl
->mxObjRef
->setClientSite( nullptr );
1265 GetSdrGlobalData().GetOLEObjCache().RemoveObj(this);
1268 catch( css::uno::Exception
& )
1270 TOOLS_WARN_EXCEPTION( "svx", "SdrOle2Obj::Disconnect_Impl()" );
1273 mpImpl
->mbConnected
= false;
1276 rtl::Reference
<SdrObject
> SdrOle2Obj::createSdrGrafObjReplacement(bool bAddText
) const
1278 const Graphic
* pOLEGraphic
= GetGraphic();
1282 // #i118485# allow creating a SdrGrafObj representation
1283 rtl::Reference
<SdrGrafObj
> pClone
= new SdrGrafObj(
1284 getSdrModelFromSdrObject(),
1287 // copy transformation
1288 basegfx::B2DHomMatrix aMatrix
;
1289 basegfx::B2DPolyPolygon aPolyPolygon
;
1291 TRGetBaseGeometry(aMatrix
, aPolyPolygon
);
1292 pClone
->TRSetBaseGeometry(aMatrix
, aPolyPolygon
);
1294 // copy all attributes to support graphic styles for OLEs
1295 pClone
->SetStyleSheet(GetStyleSheet(), false);
1296 pClone
->SetMergedItemSet(GetMergedItemSet());
1300 // #i118485# copy text (Caution! Model needed, as guaranteed in aw080)
1301 OutlinerParaObject
* pOPO
= GetOutlinerParaObject();
1305 pClone
->NbcSetOutlinerParaObject(*pOPO
);
1309 return rtl::Reference
<SdrObject
>(pClone
);
1313 // #i100710# pOLEGraphic may be zero (no visualisation available),
1314 // so we need to use the OLE replacement graphic
1315 rtl::Reference
<SdrRectObj
> pClone
= new SdrRectObj(
1316 getSdrModelFromSdrObject(),
1320 pClone
->SetMergedItem(XLineStyleItem(css::drawing::LineStyle_SOLID
));
1321 const svtools::ColorConfig aColorConfig
;
1322 const svtools::ColorConfigValue
aColor(aColorConfig
.GetColorValue(svtools::DOCBOUNDARIES
));
1323 pClone
->SetMergedItem(XLineColorItem(OUString(), aColor
.nColor
));
1326 pClone
->SetMergedItem(XFillStyleItem(drawing::FillStyle_BITMAP
));
1327 pClone
->SetMergedItem(XFillBitmapItem(OUString(), GetEmptyOLEReplacementGraphic()));
1328 pClone
->SetMergedItem(XFillBmpTileItem(false));
1329 pClone
->SetMergedItem(XFillBmpStretchItem(false));
1331 return rtl::Reference
<SdrObject
>(pClone
);
1335 rtl::Reference
<SdrObject
> SdrOle2Obj::DoConvertToPolyObj(bool bBezier
, bool bAddText
) const
1337 // #i118485# missing converter added
1338 rtl::Reference
<SdrObject
> pRetval
= createSdrGrafObjReplacement(true);
1342 return pRetval
->DoConvertToPolyObj(bBezier
, bAddText
);
1348 void SdrOle2Obj::handlePageChange(SdrPage
* pOldPage
, SdrPage
* pNewPage
)
1350 const bool bRemove(pNewPage
== nullptr && pOldPage
!= nullptr);
1351 const bool bInsert(pNewPage
!= nullptr && pOldPage
== nullptr);
1353 if (bRemove
&& mpImpl
->mbConnected
)
1359 SdrRectObj::handlePageChange(pOldPage
, pNewPage
);
1361 if (bInsert
&& !mpImpl
->mbConnected
)
1367 void SdrOle2Obj::SetObjRef( const css::uno::Reference
< css::embed::XEmbeddedObject
>& rNewObjRef
)
1369 DBG_ASSERT( !rNewObjRef
.is() || !mpImpl
->mxObjRef
.GetObject().is(), "SetObjRef called on already initialized object!");
1370 if( rNewObjRef
== mpImpl
->mxObjRef
.GetObject() )
1373 // the caller of the method is responsible to control the old object, it will not be closed here
1374 // Otherwise WW8 import crashes because it transfers control to OLENode by this method
1375 if ( mpImpl
->mxObjRef
.GetObject().is() )
1376 mpImpl
->mxObjRef
.Lock( false );
1378 // avoid removal of object in Disconnect! It is definitely a HACK to call SetObjRef(0)!
1379 // This call will try to close the objects; so if anybody else wants to keep it, it must be locked by a CloseListener
1380 mpImpl
->mxObjRef
.Clear();
1382 if ( mpImpl
->mbConnected
)
1385 mpImpl
->mxObjRef
.Assign( rNewObjRef
, GetAspect() );
1386 mpImpl
->mbTypeAsked
= false;
1388 if ( mpImpl
->mxObjRef
.is() )
1390 mpImpl
->moGraphic
.reset();
1392 if ( mpImpl
->mxObjRef
->getStatus( GetAspect() ) & embed::EmbedMisc::EMBED_NEVERRESIZE
)
1393 SetResizeProtect(true);
1395 // For math objects, set closed state to transparent
1396 SetClosedObj(!ImplIsMathObj( rNewObjRef
));
1402 BroadcastObjectChange();
1405 void SdrOle2Obj::SetClosedObj( bool bIsClosed
)
1407 // TODO/LATER: do we still need this hack?
1408 // Allow changes to the closed state of OLE objects
1409 m_bClosedObj
= bIsClosed
;
1412 rtl::Reference
<SdrObject
> SdrOle2Obj::getFullDragClone() const
1414 // #i118485# use central replacement generator
1415 return createSdrGrafObjReplacement(false);
1418 void SdrOle2Obj::SetPersistName( const OUString
& rPersistName
, SvxOle2Shape
* pCreator
)
1420 DBG_ASSERT( mpImpl
->aPersistName
.isEmpty(), "Persist name changed!");
1422 mpImpl
->aPersistName
= rPersistName
;
1423 mpImpl
->mbLoadingOLEObjectFailed
= false;
1429 void SdrOle2Obj::AbandonObject()
1431 mpImpl
->aPersistName
.clear();
1432 mpImpl
->mbLoadingOLEObjectFailed
= false;
1436 const OUString
& SdrOle2Obj::GetPersistName() const
1438 return mpImpl
->aPersistName
;
1441 void SdrOle2Obj::TakeObjInfo(SdrObjTransformInfoRec
& rInfo
) const
1443 // #i118485# Allowing much more attributes for OLEs
1444 rInfo
.bRotateFreeAllowed
= true;
1445 rInfo
.bRotate90Allowed
= true;
1446 rInfo
.bMirrorFreeAllowed
= true;
1447 rInfo
.bMirror45Allowed
= true;
1448 rInfo
.bMirror90Allowed
= true;
1449 rInfo
.bTransparenceAllowed
= true;
1450 rInfo
.bShearAllowed
= true;
1451 rInfo
.bEdgeRadiusAllowed
= false;
1452 rInfo
.bNoOrthoDesired
= false;
1453 rInfo
.bCanConvToPath
= true;
1454 rInfo
.bCanConvToPoly
= true;
1455 rInfo
.bCanConvToPathLineToArea
= false;
1456 rInfo
.bCanConvToPolyLineToArea
= false;
1457 rInfo
.bCanConvToContour
= true;
1460 SdrObjKind
SdrOle2Obj::GetObjIdentifier() const
1462 return mpImpl
->mbFrame
? SdrObjKind::OLEPluginFrame
: SdrObjKind::OLE2
;
1465 OUString
SdrOle2Obj::TakeObjNameSingul() const
1467 OUStringBuffer
sName(SvxResId(mpImpl
->mbFrame
? STR_ObjNameSingulFrame
: STR_ObjNameSingulOLE2
));
1469 const OUString
aName(GetName());
1471 if (!aName
.isEmpty())
1473 sName
.append(" '" + aName
+ "\'");
1476 return sName
.makeStringAndClear();
1479 OUString
SdrOle2Obj::TakeObjNamePlural() const
1481 return SvxResId(mpImpl
->mbFrame
? STR_ObjNamePluralFrame
: STR_ObjNamePluralOLE2
);
1484 rtl::Reference
<SdrObject
> SdrOle2Obj::CloneSdrObject(SdrModel
& rTargetModel
) const
1486 return new SdrOle2Obj(rTargetModel
, *this);
1489 void SdrOle2Obj::ImpSetVisAreaSize()
1491 // #i118524# do not again set VisAreaSize when the call comes from OLE client (e.g. ObjectAreaChanged)
1492 if (mpImpl
->mbSuppressSetVisAreaSize
)
1495 // currently there is no need to recalculate scaling for iconified objects
1496 // TODO/LATER: it might be needed in future when it is possible to change the icon
1497 if ( GetAspect() == embed::Aspects::MSOLE_ICON
)
1500 // the object area of an embedded object was changed, e.g. by user interaction an a selected object
1502 if (!mpImpl
->mxObjRef
.is())
1505 sal_Int64 nMiscStatus
= mpImpl
->mxObjRef
->getStatus( GetAspect() );
1507 // the client is required to get access to scaling
1508 SfxInPlaceClient
* pClient(
1509 SfxInPlaceClient::GetClient(
1510 dynamic_cast<SfxObjectShell
*>(
1511 getSdrModelFromSdrObject().GetPersist()),
1512 mpImpl
->mxObjRef
.GetObject()));
1513 const bool bHasOwnClient(
1514 mpImpl
->mxLightClient
.is() &&
1515 mpImpl
->mxObjRef
->getClientSite() == uno::Reference
< embed::XEmbeddedClient
>( mpImpl
->mxLightClient
) );
1517 if ( pClient
|| bHasOwnClient
)
1519 // TODO: IMHO we need to do similar things when object is UIActive or OutplaceActive?!
1520 if ( ((nMiscStatus
& embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE
) &&
1521 svt::EmbeddedObjectRef::TryRunningState( mpImpl
->mxObjRef
.GetObject() ))
1522 || mpImpl
->mxObjRef
->getCurrentState() == embed::EmbedStates::INPLACE_ACTIVE
1525 Fraction aScaleWidth
;
1526 Fraction aScaleHeight
;
1529 aScaleWidth
= pClient
->GetScaleWidth();
1530 aScaleHeight
= pClient
->GetScaleHeight();
1534 aScaleWidth
= mpImpl
->mxLightClient
->GetScaleWidth();
1535 aScaleHeight
= mpImpl
->mxLightClient
->GetScaleHeight();
1538 // The object wants to resize itself (f.e. Chart wants to recalculate the layout)
1539 // or object is inplace active and so has a window that must be resized also
1540 // In these cases the change in the object area size will be reflected in a change of the
1541 // objects' visual area. The scaling will not change, but it might exist already and must
1542 // be used in calculations
1543 MapUnit aMapUnit
= VCLUnoHelper::UnoEmbed2VCLMapUnit( mpImpl
->mxObjRef
->getMapUnit( GetAspect() ) );
1545 if (sal_Int32(aScaleWidth
) != 0 && sal_Int32(aScaleHeight
) != 0) // avoid div by zero
1546 aVisSize
= Size( static_cast<tools::Long
>( Fraction( getRectangle().GetWidth() ) / aScaleWidth
),
1547 static_cast<tools::Long
>( Fraction( getRectangle().GetHeight() ) / aScaleHeight
) );
1549 aVisSize
= OutputDevice::LogicToLogic(
1551 MapMode(getSdrModelFromSdrObject().GetScaleUnit()),
1554 aSz
.Width
= aVisSize
.Width();
1555 aSz
.Height
= aVisSize
.Height();
1556 mpImpl
->mxObjRef
->setVisualAreaSize( GetAspect(), aSz
);
1560 aSz
= mpImpl
->mxObjRef
->getVisualAreaSize( GetAspect() );
1562 catch( embed::NoVisualAreaSizeException
& )
1565 tools::Rectangle aAcceptedVisArea
;
1566 aAcceptedVisArea
.SetSize( Size( static_cast<tools::Long
>( Fraction( tools::Long( aSz
.Width
) ) * aScaleWidth
),
1567 static_cast<tools::Long
>( Fraction( tools::Long( aSz
.Height
) ) * aScaleHeight
) ) );
1568 if (aVisSize
!= aAcceptedVisArea
.GetSize())
1570 // server changed VisArea to its liking and the VisArea is different than the suggested one
1571 // store the new value as given by the object
1572 MapUnit aNewMapUnit
= VCLUnoHelper::UnoEmbed2VCLMapUnit( mpImpl
->mxObjRef
->getMapUnit( GetAspect() ) );
1573 auto aSize
= OutputDevice::LogicToLogic(aAcceptedVisArea
.GetSize(), MapMode(aNewMapUnit
), MapMode(getSdrModelFromSdrObject().GetScaleUnit()));
1574 setRectangleSize(aSize
.Width(), aSize
.Height());
1577 // make the new object area known to the client
1578 // compared to the "else" branch aRect might have been changed by the object and no additional scaling was applied
1579 // WHY this -> OSL_ASSERT( pClient );
1581 pClient
->SetObjArea(getRectangle());
1583 // we need a new replacement image as the object has resized itself
1585 //#i79578# don't request a new replacement image for charts to often
1586 //a chart sends a modified call to the framework if it was changed
1587 //thus the replacement update is already handled there
1589 mpImpl
->mxObjRef
.UpdateReplacement();
1593 // The object isn't active and does not want to resize itself so the changed object area size
1594 // will be reflected in a changed object scaling
1595 Fraction aScaleWidth
;
1596 Fraction aScaleHeight
;
1598 if ( CalculateNewScaling( aScaleWidth
, aScaleHeight
, aObjAreaSize
) )
1602 tools::Rectangle
aScaleRect(getRectangle().TopLeft(), aObjAreaSize
);
1603 pClient
->SetObjAreaAndScale( aScaleRect
, aScaleWidth
, aScaleHeight
);
1607 mpImpl
->mxLightClient
->SetSizeScale( aScaleWidth
, aScaleHeight
);
1612 else if( (nMiscStatus
& embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE
) &&
1613 svt::EmbeddedObjectRef::TryRunningState( mpImpl
->mxObjRef
.GetObject() ) )
1615 //also handle not sfx based ole objects e.g. charts
1616 //#i83860# resizing charts in impress distorts fonts
1617 uno::Reference
< embed::XVisualObject
> xVisualObject( getXModel(), uno::UNO_QUERY
);
1618 if( xVisualObject
.is() )
1620 const MapUnit
aMapUnit(
1621 VCLUnoHelper::UnoEmbed2VCLMapUnit(
1622 mpImpl
->mxObjRef
->getMapUnit(GetAspect())));
1623 const Point
aTL( getRectangle().TopLeft() );
1624 const Point
aBR( getRectangle().BottomRight() );
1626 OutputDevice::LogicToLogic(
1628 MapMode(getSdrModelFromSdrObject().GetScaleUnit()),
1629 MapMode(aMapUnit
)));
1631 OutputDevice::LogicToLogic(
1633 MapMode(getSdrModelFromSdrObject().GetScaleUnit()),
1634 MapMode(aMapUnit
)));
1635 const tools::Rectangle
aNewRect(
1639 xVisualObject
->setVisualAreaSize(
1642 aNewRect
.GetWidth(),
1643 aNewRect
.GetHeight()));
1648 void SdrOle2Obj::NbcResize(const Point
& rRef
, const Fraction
& xFact
, const Fraction
& yFact
)
1650 if(!getSdrModelFromSdrObject().isLocked())
1654 if ( mpImpl
->mxObjRef
.is() && ( mpImpl
->mxObjRef
->getStatus( GetAspect() ) & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE
) )
1656 // if the object needs recompose on resize
1657 // the client site should be created before the resize will take place
1658 // check whether there is no client site and create it if necessary
1659 AddOwnLightClient();
1663 SdrRectObj::NbcResize(rRef
,xFact
,yFact
);
1665 if( !getSdrModelFromSdrObject().isLocked() )
1666 ImpSetVisAreaSize();
1669 void SdrOle2Obj::SetGeoData(const SdrObjGeoData
& rGeo
)
1671 SdrRectObj::SetGeoData(rGeo
);
1673 if( !getSdrModelFromSdrObject().isLocked() )
1674 ImpSetVisAreaSize();
1677 void SdrOle2Obj::NbcSetSnapRect(const tools::Rectangle
& rRect
)
1679 SdrRectObj::NbcSetSnapRect(rRect
);
1681 if( !getSdrModelFromSdrObject().isLocked() )
1682 ImpSetVisAreaSize();
1684 if ( mpImpl
->mxObjRef
.is() && IsChart() )
1686 //#i103460# charts do not necessarily have an own size within ODF files,
1687 //for this case they need to use the size settings from the surrounding frame,
1688 //which is made available with this method as there is no other way
1689 mpImpl
->mxObjRef
.SetDefaultSizeForChart( Size( rRect
.GetWidth(), rRect
.GetHeight() ) );
1693 void SdrOle2Obj::NbcSetLogicRect(const tools::Rectangle
& rRect
, bool bAdaptTextMinSize
)
1695 SdrRectObj::NbcSetLogicRect(rRect
, bAdaptTextMinSize
);
1697 if( !getSdrModelFromSdrObject().isLocked() )
1698 ImpSetVisAreaSize();
1701 const Graphic
* SdrOle2Obj::GetGraphic() const
1703 if ( mpImpl
->mxObjRef
.is() )
1704 return mpImpl
->mxObjRef
.GetGraphic();
1705 return mpImpl
->moGraphic
? &*mpImpl
->moGraphic
: nullptr;
1708 void SdrOle2Obj::GetNewReplacement()
1710 if ( mpImpl
->mxObjRef
.is() )
1711 mpImpl
->mxObjRef
.UpdateReplacement();
1714 Size
SdrOle2Obj::GetOrigObjSize( MapMode
const * pTargetMapMode
) const
1716 return mpImpl
->mxObjRef
.GetSize( pTargetMapMode
);
1719 void SdrOle2Obj::setSuppressSetVisAreaSize( bool bNew
)
1721 mpImpl
->mbSuppressSetVisAreaSize
= bNew
;
1724 void SdrOle2Obj::NbcMove(const Size
& rSize
)
1726 SdrRectObj::NbcMove(rSize
);
1728 if( !getSdrModelFromSdrObject().isLocked() )
1729 ImpSetVisAreaSize();
1732 bool SdrOle2Obj::CanUnloadRunningObj( const uno::Reference
< embed::XEmbeddedObject
>& xObj
, sal_Int64 nAspect
)
1734 uno::Reference
<embed::XEmbedPersist2
> xPersist(xObj
, uno::UNO_QUERY
);
1737 if (!xPersist
->isStored())
1738 // It doesn't have persistent storage. We can't unload this.
1742 bool bResult
= false;
1744 sal_Int32 nState
= xObj
->getCurrentState();
1745 if ( nState
== embed::EmbedStates::LOADED
)
1747 // the object is already unloaded
1752 uno::Reference
< util::XModifiable
> xModifiable( xObj
->getComponent(), uno::UNO_QUERY
);
1753 if ( !xModifiable
.is() )
1757 sal_Int64 nMiscStatus
= xObj
->getStatus( nAspect
);
1759 if ( embed::EmbedMisc::MS_EMBED_ALWAYSRUN
!= ( nMiscStatus
& embed::EmbedMisc::MS_EMBED_ALWAYSRUN
) &&
1760 embed::EmbedMisc::EMBED_ACTIVATEIMMEDIATELY
!= ( nMiscStatus
& embed::EmbedMisc::EMBED_ACTIVATEIMMEDIATELY
) &&
1761 !( xModifiable
.is() && xModifiable
->isModified() ) &&
1762 !( nState
== embed::EmbedStates::INPLACE_ACTIVE
|| nState
== embed::EmbedStates::UI_ACTIVE
|| nState
== embed::EmbedStates::ACTIVE
) )
1772 bool SdrOle2Obj::Unload( const uno::Reference
< embed::XEmbeddedObject
>& xObj
, sal_Int64 nAspect
)
1774 bool bResult
= false;
1776 if ( CanUnloadRunningObj( xObj
, nAspect
) )
1780 xObj
->changeState( embed::EmbedStates::LOADED
);
1783 catch( css::uno::Exception
& )
1785 TOOLS_WARN_EXCEPTION( "svx", "SdrOle2Obj::Unload()" );
1792 bool SdrOle2Obj::Unload()
1794 if (!mpImpl
->mxObjRef
.is())
1795 // Already unloaded.
1798 return Unload(mpImpl
->mxObjRef
.GetObject(), GetAspect());
1801 void SdrOle2Obj::GetObjRef_Impl()
1803 if ( !mpImpl
->mxObjRef
.is() && !mpImpl
->aPersistName
.isEmpty() && getSdrModelFromSdrObject().GetPersist() )
1805 // Only try loading if it did not went wrong up to now
1806 if(!mpImpl
->mbLoadingOLEObjectFailed
)
1808 mpImpl
->mxObjRef
.Assign(
1809 getSdrModelFromSdrObject().GetPersist()->getEmbeddedObjectContainer().GetEmbeddedObject(mpImpl
->aPersistName
),
1811 mpImpl
->mbTypeAsked
= false;
1812 CheckFileLink_Impl();
1814 // If loading of OLE object failed, remember that to not invoke an endless
1815 // loop trying to load it again and again.
1816 if( mpImpl
->mxObjRef
.is() )
1818 mpImpl
->mbLoadingOLEObjectFailed
= true;
1821 // For math objects, set closed state to transparent
1822 SetClosedObj(!ImplIsMathObj( mpImpl
->mxObjRef
.GetObject() ));
1825 if ( mpImpl
->mxObjRef
.is() )
1827 if( !IsEmptyPresObj() )
1829 // remember modified status of model
1830 const bool bWasChanged(getSdrModelFromSdrObject().IsChanged());
1832 // perhaps preview not valid anymore
1833 // This line changes the modified state of the model
1836 // if status was not set before, force it back
1837 // to not set, so that SetGraphic(0) above does not
1838 // set the modified state of the model.
1839 if(!bWasChanged
&& getSdrModelFromSdrObject().IsChanged())
1841 getSdrModelFromSdrObject().SetChanged( false );
1846 if ( mpImpl
->mxObjRef
.is() )
1850 if ( mpImpl
->mbConnected
)
1852 // move object to first position in cache
1853 GetSdrGlobalData().GetOLEObjCache().InsertObj(this);
1857 uno::Reference
< embed::XEmbeddedObject
> const & SdrOle2Obj::GetObjRef() const
1859 const_cast<SdrOle2Obj
*>(this)->GetObjRef_Impl();
1860 return mpImpl
->mxObjRef
.GetObject();
1863 uno::Reference
< embed::XEmbeddedObject
> const & SdrOle2Obj::GetObjRef_NoInit() const
1865 return mpImpl
->mxObjRef
.GetObject();
1868 uno::Reference
< frame::XModel
> SdrOle2Obj::getXModel() const
1870 if (svt::EmbeddedObjectRef::TryRunningState(GetObjRef()))
1871 return uno::Reference
< frame::XModel
>( mpImpl
->mxObjRef
->getComponent(), uno::UNO_QUERY
);
1873 return uno::Reference
< frame::XModel
>();
1876 bool SdrOle2Obj::IsChart() const
1878 if (!mpImpl
->mbTypeAsked
)
1880 mpImpl
->mbIsChart
= mpImpl
->mxObjRef
.IsChart();
1881 mpImpl
->mbTypeAsked
= true;
1883 return mpImpl
->mbIsChart
;
1886 void SdrOle2Obj::SetGraphicToObj( const Graphic
& aGraphic
)
1888 mpImpl
->mxObjRef
.SetGraphic( aGraphic
, OUString() );
1889 // if the object isn't valid, e.g. link to something that doesn't exist, set the fallback
1890 // graphic as mxGraphic so SdrOle2Obj::GetGraphic will show the fallback
1891 if (const Graphic
* pObjGraphic
= mpImpl
->mxObjRef
.is() ? nullptr : mpImpl
->mxObjRef
.GetGraphic())
1892 mpImpl
->moGraphic
.emplace(*pObjGraphic
);
1895 void SdrOle2Obj::SetGraphicToObj( const uno::Reference
< io::XInputStream
>& xGrStream
, const OUString
& aMediaType
)
1897 mpImpl
->mxObjRef
.SetGraphicStream( xGrStream
, aMediaType
);
1898 // if the object isn't valid, e.g. link to something that doesn't exist, set the fallback
1899 // graphic as mxGraphic so SdrOle2Obj::GetGraphic will show the fallback
1900 if (const Graphic
* pObjGraphic
= mpImpl
->mxObjRef
.is() ? nullptr : mpImpl
->mxObjRef
.GetGraphic())
1901 mpImpl
->moGraphic
.emplace(*pObjGraphic
);
1904 bool SdrOle2Obj::IsCalc() const
1906 if ( !mpImpl
->mxObjRef
.is() )
1909 SvGlobalName
aObjClsId( mpImpl
->mxObjRef
->getClassID() );
1910 return SvGlobalName(SO3_SC_CLASSID_30
) == aObjClsId
1911 || SvGlobalName(SO3_SC_CLASSID_40
) == aObjClsId
1912 || SvGlobalName(SO3_SC_CLASSID_50
) == aObjClsId
1913 || SvGlobalName(SO3_SC_CLASSID_60
) == aObjClsId
1914 || SvGlobalName(SO3_SC_OLE_EMBED_CLASSID_60
) == aObjClsId
1915 || SvGlobalName(SO3_SC_OLE_EMBED_CLASSID_8
) == aObjClsId
1916 || SvGlobalName(SO3_SC_CLASSID
) == aObjClsId
;
1919 const uno::Reference
< frame::XModel
> & SdrOle2Obj::GetParentXModel() const
1921 return getSdrModelFromSdrObject().getUnoModel();
1924 bool SdrOle2Obj::CalculateNewScaling( Fraction
& aScaleWidth
, Fraction
& aScaleHeight
, Size
& aObjAreaSize
)
1926 // TODO/LEAN: to avoid rounding errors scaling always uses the VisArea.
1927 // If we don't cache it for own objects also we must load the object here
1928 if (!mpImpl
->mxObjRef
.is())
1931 MapMode
aMapMode(getSdrModelFromSdrObject().GetScaleUnit());
1932 aObjAreaSize
= mpImpl
->mxObjRef
.GetSize( &aMapMode
);
1934 Size aSize
= getRectangle().GetSize();
1935 if (!aObjAreaSize
.Width() || !aObjAreaSize
.Height())
1937 // avoid invalid fractions
1938 aScaleWidth
= Fraction(1,1);
1939 aScaleHeight
= Fraction(1,1);
1943 aScaleWidth
= Fraction(aSize
.Width(), aObjAreaSize
.Width() );
1944 aScaleHeight
= Fraction(aSize
.Height(), aObjAreaSize
.Height() );
1945 // reduce to 10 binary digits
1946 aScaleHeight
.ReduceInaccurate(10);
1947 aScaleWidth
.ReduceInaccurate(10);
1953 void SdrOle2Obj::SetIgnoreOLEObjectScale(bool val
) { mpImpl
->mbIgnoreOLEObjectScale
= val
; }
1955 bool SdrOle2Obj::AddOwnLightClient()
1957 // The Own Light Client must be registered in object only using this method!
1958 if ( !SfxInPlaceClient::GetClient( dynamic_cast<SfxObjectShell
*>(getSdrModelFromSdrObject().GetPersist()), mpImpl
->mxObjRef
.GetObject() )
1959 && !( mpImpl
->mxLightClient
.is() && mpImpl
->mxObjRef
->getClientSite() == uno::Reference
< embed::XEmbeddedClient
>( mpImpl
->mxLightClient
) ) )
1963 if (!mpImpl
->mbIgnoreOLEObjectScale
&& mpImpl
->mxObjRef
.is() && mpImpl
->mxLightClient
.is())
1965 Fraction aScaleWidth
;
1966 Fraction aScaleHeight
;
1968 if ( CalculateNewScaling( aScaleWidth
, aScaleHeight
, aObjAreaSize
) )
1970 mpImpl
->mxLightClient
->SetSizeScale( aScaleWidth
, aScaleHeight
);
1972 mpImpl
->mxObjRef
->setClientSite( mpImpl
->mxLightClient
);
1974 } catch( uno::Exception
& )
1986 Graphic
SdrOle2Obj::GetEmptyOLEReplacementGraphic()
1988 return Graphic(BitmapEx(BMP_SVXOLEOBJ
));
1991 void SdrOle2Obj::SetWindow(const css::uno::Reference
< css::awt::XWindow
>& _xWindow
)
1993 if ( mpImpl
->mxObjRef
.is() && mpImpl
->mxLightClient
.is() )
1995 mpImpl
->mxLightClient
->setWindow(_xWindow
);
1999 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */