LibreOffice Module svx (master) 1
svdoole2.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
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/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
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 .
18 */
19
20#include <svx/svdoole2.hxx>
21
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>
40
42
45
46#include <svtools/colorcfg.hxx>
47#include <svtools/embedhlp.hxx>
48
49#include <sfx2/objsh.hxx>
50#include <sfx2/ipclient.hxx>
51#include <sfx2/lnkbase.hxx>
52#include <sfx2/linkmgr.hxx>
53#include <tools/debug.hxx>
54#include <tools/globname.hxx>
58
59#include <sot/formats.hxx>
61
62#include <vcl/svapp.hxx>
63
64#include <svx/svdmodel.hxx>
65#include <svx/dialmgr.hxx>
66#include <svx/strings.hrc>
67#include <svx/svdetc.hxx>
68#include <unomlstr.hxx>
70#include <svx/svdograf.hxx>
72#include <svx/xlineit0.hxx>
73#include <svx/xlnclit.hxx>
74#include <svx/xbtmpit.hxx>
75#include <svx/xfillit0.hxx>
76#include <svx/xflbmtit.hxx>
77#include <svx/xflbstit.hxx>
80#include <editeng/outlobj.hxx>
81#include <svx/svdpage.hxx>
82#include <rtl/ustrbuf.hxx>
83#include <rtl/ref.hxx>
84#include <bitmaps.hlst>
85
86using namespace ::com::sun::star;
87
88static uno::Reference < beans::XPropertySet > lcl_getFrame_throw(const SdrOle2Obj* _pObject)
89{
90 uno::Reference < beans::XPropertySet > xFrame;
91 if ( _pObject )
92 {
93 uno::Reference< frame::XController> xController = _pObject->GetParentXModel()->getCurrentController();
94 if ( xController.is() )
95 {
96 xFrame.set( xController->getFrame(),uno::UNO_QUERY_THROW);
97 }
98 } // if ( _pObject )
99 return xFrame;
100}
101
102namespace {
103
104class SdrLightEmbeddedClient_Impl : public ::cppu::WeakImplHelper
105 < embed::XStateChangeListener
106 , document::XEventListener
107 , embed::XInplaceClient
108 , embed::XEmbeddedClient
109 , embed::XWindowSupplier
110 >
111{
112 uno::Reference< awt::XWindow > m_xWindow;
113 SdrOle2Obj* mpObj;
114
115 Fraction m_aScaleWidth;
116 Fraction m_aScaleHeight;
117
118
119public:
120 explicit SdrLightEmbeddedClient_Impl( SdrOle2Obj* pObj );
121 virtual ~SdrLightEmbeddedClient_Impl() override;
122
123 void SetSizeScale( const Fraction& aScaleWidth, const Fraction& aScaleHeight )
124 {
125 m_aScaleWidth = aScaleWidth;
126 m_aScaleHeight = aScaleHeight;
127 }
128
129 const Fraction& GetScaleWidth() const { return m_aScaleWidth; }
130 const Fraction& GetScaleHeight() const { return m_aScaleHeight; }
131
132 void setWindow(const uno::Reference< awt::XWindow >& _xWindow);
133
134 void disconnect();
135private:
136
137 tools::Rectangle impl_getScaledRect_nothrow() const;
138 // XStateChangeListener
139 virtual void SAL_CALL changingState( const css::lang::EventObject& aEvent, ::sal_Int32 nOldState, ::sal_Int32 nNewState ) override;
140 virtual void SAL_CALL stateChanged( const css::lang::EventObject& aEvent, ::sal_Int32 nOldState, ::sal_Int32 nNewState ) override;
141 virtual void SAL_CALL disposing( const css::lang::EventObject& aEvent ) override;
142
143 // document::XEventListener
144 virtual void SAL_CALL notifyEvent( const document::EventObject& aEvent ) override;
145
146 // XEmbeddedClient
147 virtual void SAL_CALL saveObject() override;
148 virtual void SAL_CALL visibilityChanged( sal_Bool bVisible ) override;
149
150 // XComponentSupplier
151 virtual uno::Reference< util::XCloseable > SAL_CALL getComponent() override;
152
153 // XInplaceClient
154 virtual sal_Bool SAL_CALL canInplaceActivate() override;
155 virtual void SAL_CALL activatingInplace() override;
156 virtual void SAL_CALL activatingUI() override;
157 virtual void SAL_CALL deactivatedInplace() override;
158 virtual void SAL_CALL deactivatedUI() override;
159 virtual uno::Reference< css::frame::XLayoutManager > SAL_CALL getLayoutManager() override;
160 virtual uno::Reference< frame::XDispatchProvider > SAL_CALL getInplaceDispatchProvider() override;
161 virtual awt::Rectangle SAL_CALL getPlacement() override;
162 virtual awt::Rectangle SAL_CALL getClipRectangle() override;
163 virtual void SAL_CALL translateAccelerators( const uno::Sequence< awt::KeyEvent >& aKeys ) override;
164 virtual void SAL_CALL scrollObject( const awt::Size& aOffset ) override;
165 virtual void SAL_CALL changedPlacement( const awt::Rectangle& aPosRect ) override;
166
167 // XWindowSupplier
168 virtual uno::Reference< awt::XWindow > SAL_CALL getWindow() override;
169};
170
171}
172
173SdrLightEmbeddedClient_Impl::SdrLightEmbeddedClient_Impl( SdrOle2Obj* pObj )
174: mpObj( pObj )
175{
176}
177SdrLightEmbeddedClient_Impl::~SdrLightEmbeddedClient_Impl()
178{
179 assert(!mpObj);
180}
181tools::Rectangle SdrLightEmbeddedClient_Impl::impl_getScaledRect_nothrow() const
182{
183 tools::Rectangle aLogicRect( mpObj->GetLogicRect() );
184 // apply scaling to object area and convert to pixels
185 aLogicRect.SetSize( Size( tools::Long( aLogicRect.GetWidth() * m_aScaleWidth),
186 tools::Long( aLogicRect.GetHeight() * m_aScaleHeight) ) );
187 return aLogicRect;
188}
189
190void SAL_CALL SdrLightEmbeddedClient_Impl::changingState( const css::lang::EventObject& /*aEvent*/, ::sal_Int32 /*nOldState*/, ::sal_Int32 /*nNewState*/ )
191{
192}
193
194void SAL_CALL SdrLightEmbeddedClient_Impl::stateChanged( const css::lang::EventObject& /*aEvent*/, ::sal_Int32 nOldState, ::sal_Int32 nNewState )
195{
196 SolarMutexGuard aGuard;
197
198 if ( mpObj && nOldState == embed::EmbedStates::LOADED && nNewState == embed::EmbedStates::RUNNING )
199 {
200 mpObj->ObjectLoaded();
202 }
203 else if ( mpObj && nNewState == embed::EmbedStates::LOADED && nOldState == embed::EmbedStates::RUNNING )
204 {
206 }
207}
208
209void SdrLightEmbeddedClient_Impl::disconnect()
210{
211 SolarMutexGuard aGuard;
212 if (!mpObj)
213 return;
215 mpObj = nullptr;
216}
217
218void SAL_CALL SdrLightEmbeddedClient_Impl::disposing( const css::lang::EventObject& /*aEvent*/ )
219{
220 disconnect();
221}
222
223void SAL_CALL SdrLightEmbeddedClient_Impl::notifyEvent( const document::EventObject& aEvent )
224{
225 // TODO/LATER: when writer uses this implementation the code could be shared with SfxInPlaceClient_Impl
226
227 SolarMutexGuard aGuard;
228
229 // the code currently makes sense only in case there is no other client
230 if ( !(mpObj && mpObj->GetAspect() != embed::Aspects::MSOLE_ICON && aEvent.EventName == "OnVisAreaChanged"
231 && mpObj->GetObjRef().is() && mpObj->GetObjRef()->getClientSite() == uno::Reference< embed::XEmbeddedClient >( this )) )
232 return;
233
234 try
235 {
236 MapUnit aContainerMapUnit( MapUnit::Map100thMM );
237 uno::Reference< embed::XVisualObject > xParentVis( mpObj->GetParentXModel(), uno::UNO_QUERY );
238 if ( xParentVis.is() )
239 aContainerMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xParentVis->getMapUnit( mpObj->GetAspect() ) );
240
241 MapUnit aObjMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( mpObj->GetObjRef()->getMapUnit( mpObj->GetAspect() ) );
242
243 tools::Rectangle aVisArea;
244 awt::Size aSz;
245 try
246 {
247 aSz = mpObj->GetObjRef()->getVisualAreaSize( mpObj->GetAspect() );
248 }
249 catch( embed::NoVisualAreaSizeException& )
250 {
251 TOOLS_WARN_EXCEPTION("svx.svdraw", "No visual area size!");
252 aSz.Width = 5000;
253 aSz.Height = 5000;
254 }
255 catch( uno::Exception& )
256 {
257 TOOLS_WARN_EXCEPTION("svx.svdraw", "");
258 aSz.Width = 5000;
259 aSz.Height = 5000;
260 }
261
262 aVisArea.SetSize( Size( aSz.Width, aSz.Height ) );
263 aVisArea = OutputDevice::LogicToLogic(aVisArea, MapMode(aObjMapUnit), MapMode(aContainerMapUnit));
264 Size aScaledSize( static_cast< tools::Long >( m_aScaleWidth * Fraction( aVisArea.GetWidth() ) ),
265 static_cast< tools::Long >( m_aScaleHeight * Fraction( aVisArea.GetHeight() ) ) );
266 tools::Rectangle aLogicRect( mpObj->GetLogicRect() );
267
268 // react to the change if the difference is bigger than one pixel
269 Size aPixelDiff =
271 Size( aLogicRect.GetWidth() - aScaledSize.Width(),
272 aLogicRect.GetHeight() - aScaledSize.Height() ),
273 MapMode(aContainerMapUnit));
274 if( aPixelDiff.Width() || aPixelDiff.Height() )
275 {
276 mpObj->SetLogicRect( tools::Rectangle( aLogicRect.TopLeft(), aScaledSize ) );
277 mpObj->BroadcastObjectChange();
278 }
279 else
280 mpObj->ActionChanged();
281 }
282 catch( uno::Exception& )
283 {
284 TOOLS_WARN_EXCEPTION("svx.svdraw", "");
285 }
286}
287
288void SAL_CALL SdrLightEmbeddedClient_Impl::saveObject()
289{
290 // TODO/LATER: when writer uses this implementation the code could be shared with SfxInPlaceClient_Impl
291 uno::Reference< embed::XCommonEmbedPersist > xPersist;
292 uno::Reference< util::XModifiable > xModifiable;
293
294 {
295 SolarMutexGuard aGuard;
296
297 if ( !mpObj )
298 throw embed::ObjectSaveVetoException();
299
300 // the common persistence is supported by objects and links
301 xPersist.set( mpObj->GetObjRef(), uno::UNO_QUERY_THROW );
302 xModifiable.set( mpObj->GetParentXModel(), uno::UNO_QUERY );
303 }
304
305 xPersist->storeOwn();
306
307 if ( xModifiable.is() )
308 xModifiable->setModified( true );
309}
310
311void SAL_CALL SdrLightEmbeddedClient_Impl::visibilityChanged( sal_Bool /*bVisible*/ )
312{
313 // nothing to do currently
314 // TODO/LATER: when writer uses this implementation the code could be shared with SfxInPlaceClient_Impl
315 if ( mpObj )
316 {
317 tools::Rectangle aLogicRect( mpObj->GetLogicRect() );
318 Size aLogicSize( aLogicRect.GetWidth(), aLogicRect.GetHeight() );
319
320 if( mpObj->IsChart() )
321 {
322 //charts never should be stretched see #i84323# for example
323 mpObj->SetLogicRect( tools::Rectangle( aLogicRect.TopLeft(), aLogicSize ) );
324 mpObj->BroadcastObjectChange();
325 } // if( mpObj->IsChart() )
326 }
327}
328
329uno::Reference< util::XCloseable > SAL_CALL SdrLightEmbeddedClient_Impl::getComponent()
330{
331 uno::Reference< util::XCloseable > xResult;
332
333 SolarMutexGuard aGuard;
334 if ( mpObj )
335 xResult.set( mpObj->GetParentXModel(), uno::UNO_QUERY );
336
337 return xResult;
338}
339// XInplaceClient
340
341sal_Bool SAL_CALL SdrLightEmbeddedClient_Impl::canInplaceActivate()
342{
343 bool bRet = false;
344 SolarMutexGuard aGuard;
345 if ( mpObj )
346 {
347 uno::Reference< embed::XEmbeddedObject > xObject = mpObj->GetObjRef();
348 if ( !xObject.is() )
349 throw uno::RuntimeException();
350 // we don't want to switch directly from outplace to inplace mode
351 bRet = ( xObject->getCurrentState() != embed::EmbedStates::ACTIVE && mpObj->GetAspect() != embed::Aspects::MSOLE_ICON );
352 } // if ( mpObj )
353 return bRet;
354}
355
356void SAL_CALL SdrLightEmbeddedClient_Impl::activatingInplace()
357{
358}
359
360void SAL_CALL SdrLightEmbeddedClient_Impl::activatingUI()
361{
362 SolarMutexGuard aGuard;
363
364 uno::Reference < beans::XPropertySet > xFrame( lcl_getFrame_throw(mpObj));
365 uno::Reference < frame::XFrame > xOwnFrame( xFrame,uno::UNO_QUERY);
366 uno::Reference < frame::XFramesSupplier > xParentFrame = xOwnFrame->getCreator();
367 if ( xParentFrame.is() )
368 xParentFrame->setActiveFrame( xOwnFrame );
369
371 const size_t nCount = rObjCache.size();
372 for(sal_Int32 i = nCount-1 ; i >= 0;--i)
373 {
374 SdrOle2Obj* pObj = rObjCache[i];
375 if ( pObj != mpObj )
376 {
377 // only deactivate ole objects which belongs to the same frame
378 if ( xFrame == lcl_getFrame_throw(pObj) )
379 {
380 const uno::Reference< embed::XEmbeddedObject >& xObject = pObj->GetObjRef();
381 try
382 {
383 if ( xObject->getStatus( pObj->GetAspect() ) & embed::EmbedMisc::MS_EMBED_ACTIVATEWHENVISIBLE )
384 xObject->changeState( embed::EmbedStates::INPLACE_ACTIVE );
385 else
386 {
387 // the links should not stay in running state for long time because of locking
388 uno::Reference< embed::XLinkageSupport > xLink( xObject, uno::UNO_QUERY );
389 if ( xLink.is() && xLink->isLink() )
390 xObject->changeState( embed::EmbedStates::LOADED );
391 else
392 xObject->changeState( embed::EmbedStates::RUNNING );
393 }
394 }
395 catch (css::uno::Exception& )
396 {}
397 }
398 }
399 } // for(sal_Int32 i = nCount-1 ; i >= 0;--i)
400}
401
402void SAL_CALL SdrLightEmbeddedClient_Impl::deactivatedInplace()
403{
404}
405
406void SAL_CALL SdrLightEmbeddedClient_Impl::deactivatedUI()
407{
408 SolarMutexGuard aGuard;
409 css::uno::Reference< css::frame::XLayoutManager > xLayoutManager(getLayoutManager());
410 if ( xLayoutManager.is() )
411 {
412 static constexpr OUStringLiteral aMenuBarURL = u"private:resource/menubar/menubar";
413 if ( !xLayoutManager->isElementVisible( aMenuBarURL ) )
414 xLayoutManager->createElement( aMenuBarURL );
415 }
416}
417
418uno::Reference< css::frame::XLayoutManager > SAL_CALL SdrLightEmbeddedClient_Impl::getLayoutManager()
419{
420 uno::Reference< css::frame::XLayoutManager > xMan;
421 SolarMutexGuard aGuard;
422 uno::Reference < beans::XPropertySet > xFrame( lcl_getFrame_throw(mpObj));
423 try
424 {
425 xMan.set(xFrame->getPropertyValue("LayoutManager"),uno::UNO_QUERY);
426 }
427 catch ( uno::Exception& ex )
428 {
429 css::uno::Any anyEx = cppu::getCaughtException();
430 throw css::lang::WrappedTargetRuntimeException( ex.Message,
431 nullptr, anyEx );
432 }
433
434 return xMan;
435}
436
437uno::Reference< frame::XDispatchProvider > SAL_CALL SdrLightEmbeddedClient_Impl::getInplaceDispatchProvider()
438{
439 SolarMutexGuard aGuard;
440 return uno::Reference < frame::XDispatchProvider >( lcl_getFrame_throw(mpObj), uno::UNO_QUERY_THROW );
441}
442
443awt::Rectangle SAL_CALL SdrLightEmbeddedClient_Impl::getPlacement()
444{
445 SolarMutexGuard aGuard;
446 if ( !mpObj )
447 throw uno::RuntimeException();
448
449 tools::Rectangle aLogicRect = impl_getScaledRect_nothrow();
450 MapUnit aContainerMapUnit( MapUnit::Map100thMM );
451 uno::Reference< embed::XVisualObject > xParentVis( mpObj->GetParentXModel(), uno::UNO_QUERY );
452 if ( xParentVis.is() )
453 aContainerMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xParentVis->getMapUnit( mpObj->GetAspect() ) );
454
455 aLogicRect = Application::GetDefaultDevice()->LogicToPixel(aLogicRect, MapMode(aContainerMapUnit));
456 return AWTRectangle( aLogicRect );
457}
458
459awt::Rectangle SAL_CALL SdrLightEmbeddedClient_Impl::getClipRectangle()
460{
461 return getPlacement();
462}
463
464void SAL_CALL SdrLightEmbeddedClient_Impl::translateAccelerators( const uno::Sequence< awt::KeyEvent >& /*aKeys*/ )
465{
466}
467
468void SAL_CALL SdrLightEmbeddedClient_Impl::scrollObject( const awt::Size& /*aOffset*/ )
469{
470}
471
472void SAL_CALL SdrLightEmbeddedClient_Impl::changedPlacement( const awt::Rectangle& aPosRect )
473{
474 SolarMutexGuard aGuard;
475 if ( !mpObj )
476 throw uno::RuntimeException();
477
478 uno::Reference< embed::XInplaceObject > xInplace( mpObj->GetObjRef(), uno::UNO_QUERY_THROW );
479
480 // check if the change is at least one pixel in size
481 awt::Rectangle aOldRect = getPlacement();
482 tools::Rectangle aNewPixelRect = VCLRectangle( aPosRect );
483 tools::Rectangle aOldPixelRect = VCLRectangle( aOldRect );
484 if ( aOldPixelRect == aNewPixelRect )
485 // nothing has changed
486 return;
487
488 // new scaled object area
489 MapUnit aContainerMapUnit( MapUnit::Map100thMM );
490 uno::Reference< embed::XVisualObject > xParentVis( mpObj->GetParentXModel(), uno::UNO_QUERY );
491 if ( xParentVis.is() )
492 aContainerMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( xParentVis->getMapUnit( mpObj->GetAspect() ) );
493
494 tools::Rectangle aNewLogicRect = Application::GetDefaultDevice()->PixelToLogic(aNewPixelRect, MapMode(aContainerMapUnit));
495 tools::Rectangle aLogicRect = impl_getScaledRect_nothrow();
496
497 if ( aNewLogicRect == aLogicRect )
498 return;
499
500 // the calculation of the object area has not changed the object size
501 // it should be done here then
502 //SfxBooleanFlagGuard aGuard( m_bResizeNoScale, true );
503
504 // new size of the object area without scaling
505 Size aNewObjSize( tools::Long( aNewLogicRect.GetWidth() / m_aScaleWidth ),
506 tools::Long( aNewLogicRect.GetHeight() / m_aScaleHeight ) );
507
508 // now remove scaling from new placement and keep this at the new object area
509 aNewLogicRect.SetSize( aNewObjSize );
510 // react to the change if the difference is bigger than one pixel
511 Size aPixelDiff =
513 Size( aLogicRect.GetWidth() - aNewObjSize.Width(),
514 aLogicRect.GetHeight() - aNewObjSize.Height() ),
515 MapMode(aContainerMapUnit));
516 if( aPixelDiff.Width() || aPixelDiff.Height() )
517 {
518 mpObj->SetLogicRect( tools::Rectangle( aLogicRect.TopLeft(), aNewObjSize ) );
519 mpObj->BroadcastObjectChange();
520 }
521 else
522 mpObj->ActionChanged();
523}
524// XWindowSupplier
525
526uno::Reference< awt::XWindow > SAL_CALL SdrLightEmbeddedClient_Impl::getWindow()
527{
528 SolarMutexGuard aGuard;
529 uno::Reference< awt::XWindow > xCurrent = m_xWindow;
530 if ( !xCurrent.is() )
531 {
532 if ( !mpObj )
533 throw uno::RuntimeException();
534 uno::Reference< frame::XFrame> xFrame(lcl_getFrame_throw(mpObj),uno::UNO_QUERY_THROW);
535 xCurrent = xFrame->getComponentWindow();
536 } // if ( !xCurrent.is() )
537 return xCurrent;
538}
539void SdrLightEmbeddedClient_Impl::setWindow(const uno::Reference< awt::XWindow >& _xWindow)
540{
541 m_xWindow = _xWindow;
542}
543
546 pObj(pObject)
547{
548 SetSynchron( false );
549}
550
552{
553}
554
556 const OUString& /*rMimeType*/, const css::uno::Any & /*rValue*/ )
557{
558 if ( !pObj->UpdateLinkURL_Impl() )
559 {
560 // the link URL was not changed
561 uno::Reference< embed::XEmbeddedObject > xObject = pObj->GetObjRef();
562 OSL_ENSURE( xObject.is(), "The object must exist always!" );
563 if ( xObject.is() )
564 {
565 // let the object reload the link
566 // TODO/LATER: reload call could be used for this case
567
568 try
569 {
570 sal_Int32 nState = xObject->getCurrentState();
571 if ( nState != embed::EmbedStates::LOADED )
572 {
573 // in some cases the linked file probably is not locked so it could be changed
574 xObject->changeState( embed::EmbedStates::LOADED );
575 xObject->changeState( nState );
576 }
577 }
578 catch ( uno::Exception& )
579 {
580 }
581 }
582 }
583
585 pObj->SetChanged();
586
587 return SUCCESS;
588}
589
591{
593 SvBaseLink::Closed();
594}
595
597{
598public:
600
601 std::optional<Graphic> moGraphic;
602 OUString maProgName;
603 OUString aPersistName; // name of object in persist
604 rtl::Reference<SdrLightEmbeddedClient_Impl> mxLightClient; // must be registered as client only using AddOwnLightClient() call
605
606 bool mbFrame:1; // Due to compatibility at SdrTextObj for now
607 bool mbSuppressSetVisAreaSize:1; // #i118524#
608 mutable bool mbTypeAsked:1;
609 mutable bool mbIsChart:1;
610 bool mbLoadingOLEObjectFailed:1; // New local var to avoid repeated loading if load of OLE2 fails
612
614 OUString maLinkURL;
615
617
618 explicit SdrOle2ObjImpl( bool bFrame ) :
619 mbFrame(bFrame),
621 mbTypeAsked(false),
622 mbIsChart(false),
624 mbConnected(false),
625 mpObjectLink(nullptr)
626 {
627 mxObjRef.Lock();
628 }
629
630 SdrOle2ObjImpl( bool bFrame, const svt::EmbeddedObjectRef& rObjRef ) :
631 mxObjRef(rObjRef),
632 mbFrame(bFrame),
634 mbTypeAsked(false),
635 mbIsChart(false),
637 mbConnected(false),
638 mpObjectLink(nullptr)
639 {
640 mxObjRef.Lock();
641 }
642
644 {
645 moGraphic.reset();
646
647 if (mxModifyListener.is())
648 {
649 mxModifyListener->invalidate();
650 }
651 }
652};
653
654// Predicate determining whether the given OLE is an internal math
655// object
656static bool ImplIsMathObj( const uno::Reference < embed::XEmbeddedObject >& rObjRef )
657{
658 if ( !rObjRef.is() )
659 return false;
660
661 SvGlobalName aClassName( rObjRef->getClassID() );
662 return aClassName == SvGlobalName(SO3_SM_CLASSID_30) ||
663 aClassName == SvGlobalName(SO3_SM_CLASSID_40) ||
664 aClassName == SvGlobalName(SO3_SM_CLASSID_50) ||
665 aClassName == SvGlobalName(SO3_SM_CLASSID_60) ||
666 aClassName == SvGlobalName(SO3_SM_CLASSID);
667}
668
669// BaseProperties section
670
671std::unique_ptr<sdr::properties::BaseProperties> SdrOle2Obj::CreateObjectSpecificProperties()
672{
673 return std::make_unique<sdr::properties::OleProperties>(*this);
674}
675
676// DrawContact section
677
678std::unique_ptr<sdr::contact::ViewContact> SdrOle2Obj::CreateObjectSpecificViewContact()
679{
680 return std::make_unique<sdr::contact::ViewContactOfSdrOle2Obj>(*this);
681}
682
684{
685 // Stuff that was done from old SetModel:
686 // #i43086# #i85304 redo the change for charts for the above bugfix, as #i43086# does not occur anymore
687 // so maybe the ImpSetVisAreaSize call can be removed here completely
688 // Nevertheless I leave it in for other objects as I am not sure about the side effects when removing now
689 if(!getSdrModelFromSdrObject().isLocked() && !IsChart())
690 {
692 }
693
695 if(pDestPers && !IsEmptyPresObj())
696 {
697 // object wasn't connected, now it should be
698 Connect_Impl();
699 }
700
702}
703
705 SdrModel& rSdrModel,
706 bool bFrame_)
707: SdrRectObj(rSdrModel),
708 mpImpl(new SdrOle2ObjImpl(bFrame_))
709{
710 Init();
711}
712
713SdrOle2Obj::SdrOle2Obj(SdrModel& rSdrModel, SdrOle2Obj const & rSource)
714: SdrRectObj(rSdrModel, rSource),
715 mpImpl(new SdrOle2ObjImpl(/*bFrame*/false))
716{
717 Init();
718
719 // Manually copying bClosedObj attribute
720 SetClosedObj( rSource.IsClosedObj() );
721
722 mpImpl->aPersistName = rSource.mpImpl->aPersistName;
723 mpImpl->maProgName = rSource.mpImpl->maProgName;
724 mpImpl->mbFrame = rSource.mpImpl->mbFrame;
725
726 if (rSource.mpImpl->moGraphic)
727 {
728 mpImpl->moGraphic.emplace(*rSource.mpImpl->moGraphic);
729 }
730
731 if( IsEmptyPresObj() )
732 return;
733
736 if( !(pDestPers && pSrcPers) )
737 return;
738
739 DBG_ASSERT( !mpImpl->mxObjRef.is(), "Object already existing!" );
741 uno::Reference < embed::XEmbeddedObject > xObj = rContainer.GetEmbeddedObject( mpImpl->aPersistName );
742 if ( xObj.is() )
743 {
744 OUString aTmp;
745 mpImpl->mxObjRef.Assign( pDestPers->getEmbeddedObjectContainer().CopyAndGetEmbeddedObject(
746 rContainer, xObj, aTmp, pSrcPers->getDocumentBaseURL(), pDestPers->getDocumentBaseURL()), rSource.GetAspect());
747 mpImpl->mbTypeAsked = false;
748 mpImpl->aPersistName = aTmp;
750 }
751
752 Connect();
753}
754
756 SdrModel& rSdrModel,
757 const svt::EmbeddedObjectRef& rNewObjRef,
758 const OUString& rNewObjName,
759 const tools::Rectangle& rNewRect)
760: SdrRectObj(rSdrModel, rNewRect),
761 mpImpl(new SdrOle2ObjImpl(false/*bFrame_*/, rNewObjRef))
762{
763 osl_atomic_increment(&m_refCount);
764
765 mpImpl->aPersistName = rNewObjName;
766
767 if (mpImpl->mxObjRef.is() && (mpImpl->mxObjRef->getStatus( GetAspect() ) & embed::EmbedMisc::EMBED_NEVERRESIZE ) )
768 m_bSizProt = true;
769
770 // For math objects, set closed state to transparent
771 SetClosedObj(!ImplIsMathObj( mpImpl->mxObjRef.GetObject() ));
772
773 Init();
774
775 osl_atomic_decrement(&m_refCount);
776}
777
779{
780 OUString strStyle;
781 if (mpImpl->mxObjRef.is() && mpImpl->mxObjRef.IsChart())
782 {
783 strStyle = mpImpl->mxObjRef.GetChartType();
784 }
785 return strStyle;
786}
787
789{
790 if ( mpImpl->mbConnected )
791 Disconnect();
792
794
795 if (mpImpl->mxLightClient)
796 {
797 mpImpl->mxLightClient->disconnect();
798 mpImpl->mxLightClient.clear();
799 }
800}
801
802void SdrOle2Obj::SetAspect( sal_Int64 nAspect )
803{
804 mpImpl->mxObjRef.SetViewAspect( nAspect );
805}
806
808{
809 return mpImpl->mxObjRef;
810}
811
812sal_Int64 SdrOle2Obj::GetAspect() const
813{
814 return mpImpl->mxObjRef.GetViewAspect();
815}
816
818{
819 return mpImpl->mxObjRef.is() && embed::EmbedStates::INPLACE_ACTIVE == mpImpl->mxObjRef->getCurrentState();
820}
821
823{
824 return mpImpl->mxObjRef.is() && embed::EmbedStates::UI_ACTIVE == mpImpl->mxObjRef->getCurrentState();
825}
826
828{
829 // only for setting a preview graphic
830 mpImpl->moGraphic.emplace(rGrf);
831
832 SetChanged();
834}
835
837{
838 mpImpl->moGraphic.reset();
839
840 SetChanged();
842}
843
844void SdrOle2Obj::SetProgName( const OUString& rName )
845{
846 mpImpl->maProgName = rName;
847}
848
849const OUString& SdrOle2Obj::GetProgName() const
850{
851 return mpImpl->maProgName;
852}
853
855{
856 return !mpImpl->mxObjRef.is();
857}
858
860{
861 if( IsEmptyPresObj() )
862 return;
863
864 if( mpImpl->mbConnected )
865 {
866 // currently there are situations where it seems to be unavoidable to have multiple connects
867 // changing this would need a larger code rewrite, so for now I remove the assertion
868 // OSL_FAIL("Connect() called on connected object!");
869 return;
870 }
871
872 Connect_Impl();
874}
875
877{
878 bool bResult = false;
879
880 if ( mpImpl->mpObjectLink )
881 {
882 sfx2::LinkManager* pLinkManager(getSdrModelFromSdrObject().GetLinkManager());
883
884 if ( pLinkManager )
885 {
886 OUString aNewLinkURL;
887 sfx2::LinkManager::GetDisplayNames( mpImpl->mpObjectLink, nullptr, &aNewLinkURL );
888 if ( !aNewLinkURL.equalsIgnoreAsciiCase( mpImpl->maLinkURL ) )
889 {
891 uno::Reference<embed::XCommonEmbedPersist> xPersObj( mpImpl->mxObjRef.GetObject(), uno::UNO_QUERY );
892 OSL_ENSURE( xPersObj.is(), "The object must exist!" );
893 if ( xPersObj.is() )
894 {
895 try
896 {
897 sal_Int32 nCurState = mpImpl->mxObjRef->getCurrentState();
898 if ( nCurState != embed::EmbedStates::LOADED )
899 mpImpl->mxObjRef->changeState(embed::EmbedStates::LOADED);
900
901 // TODO/LATER: there should be possible to get current mediadescriptor settings from the object
902 uno::Sequence< beans::PropertyValue > aArgs{ comphelper::makePropertyValue(
903 "URL", aNewLinkURL) };
904 xPersObj->reload( aArgs, uno::Sequence< beans::PropertyValue >() );
905
906 mpImpl->maLinkURL = aNewLinkURL;
907 bResult = true;
908
909 if ( nCurState != embed::EmbedStates::LOADED )
910 mpImpl->mxObjRef->changeState(nCurState);
911 }
912 catch( css::uno::Exception const & )
913 {
914 TOOLS_WARN_EXCEPTION( "svx", "SdrOle2Obj::UpdateLinkURL_Impl()" );
915 }
916 }
917
918 if ( !bResult )
919 {
920 // TODO/LATER: return the old name to the link manager, is it possible?
921 }
922 }
923 }
924 }
925
926 return bResult;
927}
928
930{
931 uno::Reference<document::XStorageBasedDocument> xDoc(getSdrModelFromSdrObject().getUnoModel(), uno::UNO_QUERY);
932
933 if ( !xDoc.is() )
934 return;
935
936 uno::Reference< embed::XStorage > xStorage = xDoc->getDocumentStorage();
937 if ( !xStorage.is() )
938 return;
939
940 try
941 {
942 uno::Reference< embed::XLinkageSupport > xLinkSupport( mpImpl->mxObjRef.GetObject(), uno::UNO_QUERY_THROW );
943 xLinkSupport->breakLink( xStorage, mpImpl->aPersistName );
945 mpImpl->maLinkURL.clear();
946 }
947 catch( css::uno::Exception& )
948 {
949 TOOLS_WARN_EXCEPTION( "svx", "SdrOle2Obj::BreakFileLink_Impl()" );
950 }
951}
952
954{
955 sfx2::LinkManager* pLinkManager(getSdrModelFromSdrObject().GetLinkManager());
956
957 if ( pLinkManager && mpImpl->mpObjectLink )
958 {
959 pLinkManager->Remove( mpImpl->mpObjectLink );
960 mpImpl->mpObjectLink = nullptr;
961 }
962}
963
965{
966 if (!mpImpl->mxObjRef.GetObject().is() || mpImpl->mpObjectLink)
967 return;
968
969 try
970 {
971 uno::Reference< embed::XLinkageSupport > xLinkSupport( mpImpl->mxObjRef.GetObject(), uno::UNO_QUERY );
972
973 if ( xLinkSupport.is() && xLinkSupport->isLink() )
974 {
975 OUString aLinkURL = xLinkSupport->getLinkURL();
976
977 if ( !aLinkURL.isEmpty() )
978 {
979 // this is a file link so the model link manager should handle it
980 sfx2::LinkManager* pLinkManager(getSdrModelFromSdrObject().GetLinkManager());
981
982 if ( pLinkManager )
983 {
984 mpImpl->mpObjectLink = new SdrEmbedObjectLink( this );
985 mpImpl->maLinkURL = aLinkURL;
986 pLinkManager->InsertFileLink( *mpImpl->mpObjectLink, sfx2::SvBaseLinkObjectType::ClientOle, aLinkURL );
987 mpImpl->mpObjectLink->Connect();
988 }
989 }
990 }
991 }
992 catch (const css::uno::Exception&)
993 {
994 TOOLS_WARN_EXCEPTION("svx", "SdrOle2Obj::CheckFileLink_Impl()");
995 }
996}
997
999{
1000 if(mpImpl->aPersistName.isEmpty() )
1001 return;
1002
1003 try
1004 {
1006
1007 if ( pPers )
1008 {
1010
1011 if ( !rContainer.HasEmbeddedObject( mpImpl->aPersistName )
1012 || ( mpImpl->mxObjRef.is() && !rContainer.HasEmbeddedObject( mpImpl->mxObjRef.GetObject() ) ) )
1013 {
1014 // object not known to container document
1015 // No object -> disaster!
1016 DBG_ASSERT( mpImpl->mxObjRef.is(), "No object in connect!");
1017 if ( mpImpl->mxObjRef.is() )
1018 {
1019 // object came from the outside, now add it to the container
1020 OUString aTmp;
1021 rContainer.InsertEmbeddedObject( mpImpl->mxObjRef.GetObject(), aTmp );
1022 mpImpl->aPersistName = aTmp;
1023 }
1024 }
1025 else if ( !mpImpl->mxObjRef.is() )
1026 {
1027 mpImpl->mxObjRef.Assign( rContainer.GetEmbeddedObject( mpImpl->aPersistName ), mpImpl->mxObjRef.GetViewAspect() );
1028 mpImpl->mbTypeAsked = false;
1029 }
1030
1031 if ( mpImpl->mxObjRef.GetObject().is() )
1032 {
1033 mpImpl->mxObjRef.AssignToContainer( &rContainer, mpImpl->aPersistName );
1034 mpImpl->mbConnected = true;
1035 mpImpl->mxObjRef.Lock();
1036 }
1037 }
1038
1039 if ( mpImpl->mxObjRef.is() )
1040 {
1041 if ( !mpImpl->mxLightClient.is() )
1042 mpImpl->mxLightClient = new SdrLightEmbeddedClient_Impl( this );
1043
1044 mpImpl->mxObjRef->addStateChangeListener( mpImpl->mxLightClient );
1045 mpImpl->mxObjRef->addEventListener( mpImpl->mxLightClient );
1046
1047 if ( mpImpl->mxObjRef->getCurrentState() != embed::EmbedStates::LOADED )
1049
1051
1052 uno::Reference< container::XChild > xChild( mpImpl->mxObjRef.GetObject(), uno::UNO_QUERY );
1053 if( xChild.is() )
1054 {
1055 uno::Reference< uno::XInterface > xParent( getSdrModelFromSdrObject().getUnoModel());
1056 if( xParent.is())
1057 xChild->setParent( getSdrModelFromSdrObject().getUnoModel() );
1058 }
1059
1060 }
1061 }
1062 catch( css::uno::Exception& )
1063 {
1064 TOOLS_WARN_EXCEPTION( "svx", "SdrOle2Obj::Connect_Impl()" );
1065 }
1066}
1067
1069{
1071}
1072
1074{
1075 if( !(mpImpl->mxObjRef.is() && mpImpl->mxObjRef->getCurrentState() != embed::EmbedStates::LOADED) )
1076 return;
1077
1078 // register modify listener
1079 if (!mpImpl->mxModifyListener.is())
1080 {
1081 mpImpl->mxModifyListener = new SvxUnoShapeModifyListener(this);
1082 }
1083
1084 uno::Reference< util::XModifyBroadcaster > xBC( getXModel(), uno::UNO_QUERY );
1085 if (xBC.is())
1086 {
1087 xBC->addModifyListener( mpImpl->mxModifyListener );
1088 }
1089}
1090
1092{
1093 if( IsEmptyPresObj() )
1094 return;
1095
1096 if( !mpImpl->mbConnected )
1097 {
1098 OSL_FAIL("Disconnect() called on disconnected object!");
1099 return;
1100 }
1101
1104}
1105
1107{
1108 if ( !mpImpl->mxObjRef.is() || mpImpl->aPersistName.isEmpty() )
1109 return;
1110
1111 try
1112 {
1113 sal_Int32 nState = mpImpl->mxObjRef->getCurrentState();
1114 if ( nState != embed::EmbedStates::LOADED )
1115 {
1116 uno::Reference< util::XModifyBroadcaster > xBC( getXModel(), uno::UNO_QUERY );
1117 if (xBC.is() && mpImpl->mxModifyListener.is())
1118 {
1119 xBC->removeModifyListener( mpImpl->mxModifyListener );
1120 }
1121 }
1122 }
1123 catch( css::uno::Exception& )
1124 {
1125 TOOLS_WARN_EXCEPTION( "svx", "SdrOle2Obj::RemoveListeners_Impl()" );
1126 }
1127}
1128
1130{
1131 try
1132 {
1133 if ( !mpImpl->aPersistName.isEmpty() )
1134 {
1136 {
1137 // TODO/LATER: here we must assume that the destruction of the model is enough to make clear that we will not
1138 // remove the object from the container, even if the DrawingObject itself is not destroyed (unfortunately this
1139 // There is no real need to do the following removing of the object from the container
1140 // in case the model has correct persistence, but in case of problems such a removing
1141 // would make the behavior of the office more stable
1142
1143 comphelper::EmbeddedObjectContainer* pContainer = mpImpl->mxObjRef.GetContainer();
1144 if ( pContainer )
1145 {
1146 pContainer->CloseEmbeddedObject( mpImpl->mxObjRef.GetObject() );
1147 mpImpl->mxObjRef.AssignToContainer( nullptr, mpImpl->aPersistName );
1148 }
1149
1150 // happens later than the destruction of the model, so we can't assert that).
1151 //DBG_ASSERT( bInDestruction, "Model is destroyed, but not me?!" );
1152 //TODO/LATER: should be make sure that the ObjectShell also forgets the object, because we will close it soon?
1153 /*
1154 uno::Reference < util::XCloseable > xClose( xObjRef, uno::UNO_QUERY );
1155 if ( xClose.is() )
1156 {
1157 try
1158 {
1159 xClose->close( true );
1160 }
1161 catch ( util::CloseVetoException& )
1162 {
1163 // there's still someone who needs the object!
1164 }
1165 }
1166
1167 xObjRef = NULL;*/
1168 }
1169 else if ( mpImpl->mxObjRef.is() )
1170 {
1171 if ( getSdrModelFromSdrObject().getUnoModel().is() )
1172 {
1173 // remove object, but don't close it (that's up to someone else)
1174 comphelper::EmbeddedObjectContainer* pContainer = mpImpl->mxObjRef.GetContainer();
1175 if ( pContainer )
1176 {
1177 pContainer->RemoveEmbeddedObject( mpImpl->mxObjRef.GetObject() );
1178
1179 // TODO/LATER: mpImpl->aPersistName contains outdated information, to keep it updated
1180 // it should be returned from RemoveEmbeddedObject call. Currently it is no problem,
1181 // since no container is adjusted, actually the empty string could be provided as a name here
1182 mpImpl->mxObjRef.AssignToContainer( nullptr, mpImpl->aPersistName );
1183 }
1184
1186 }
1187 }
1188 }
1189
1190 if ( mpImpl->mxObjRef.is() && mpImpl->mxLightClient.is() )
1191 {
1192 mpImpl->mxObjRef->removeStateChangeListener ( mpImpl->mxLightClient );
1193 mpImpl->mxObjRef->removeEventListener( mpImpl->mxLightClient );
1194 mpImpl->mxObjRef->setClientSite( nullptr );
1195
1197 }
1198 }
1199 catch( css::uno::Exception& )
1200 {
1201 TOOLS_WARN_EXCEPTION( "svx", "SdrOle2Obj::Disconnect_Impl()" );
1202 }
1203
1204 mpImpl->mbConnected = false;
1205}
1206
1208{
1209 const Graphic* pOLEGraphic = GetGraphic();
1210
1211 if(pOLEGraphic)
1212 {
1213 // #i118485# allow creating a SdrGrafObj representation
1216 *pOLEGraphic);
1217
1218 // copy transformation
1219 basegfx::B2DHomMatrix aMatrix;
1220 basegfx::B2DPolyPolygon aPolyPolygon;
1221
1222 TRGetBaseGeometry(aMatrix, aPolyPolygon);
1223 pClone->TRSetBaseGeometry(aMatrix, aPolyPolygon);
1224
1225 // copy all attributes to support graphic styles for OLEs
1226 pClone->SetStyleSheet(GetStyleSheet(), false);
1227 pClone->SetMergedItemSet(GetMergedItemSet());
1228
1229 if(bAddText)
1230 {
1231 // #i118485# copy text (Caution! Model needed, as guaranteed in aw080)
1233
1234 if(pOPO)
1235 {
1236 pClone->NbcSetOutlinerParaObject(*pOPO);
1237 }
1238 }
1239
1240 return rtl::Reference<SdrObject>(pClone);
1241 }
1242 else
1243 {
1244 // #i100710# pOLEGraphic may be zero (no visualisation available),
1245 // so we need to use the OLE replacement graphic
1248 GetSnapRect());
1249
1250 // gray outline
1251 pClone->SetMergedItem(XLineStyleItem(css::drawing::LineStyle_SOLID));
1252 const svtools::ColorConfig aColorConfig;
1254 pClone->SetMergedItem(XLineColorItem(OUString(), aColor.nColor));
1255
1256 // bitmap fill
1257 pClone->SetMergedItem(XFillStyleItem(drawing::FillStyle_BITMAP));
1258 pClone->SetMergedItem(XFillBitmapItem(OUString(), GetEmptyOLEReplacementGraphic()));
1259 pClone->SetMergedItem(XFillBmpTileItem(false));
1260 pClone->SetMergedItem(XFillBmpStretchItem(false));
1261
1262 return rtl::Reference<SdrObject>(pClone);
1263 }
1264}
1265
1267{
1268 // #i118485# missing converter added
1270
1271 if(pRetval)
1272 {
1273 return pRetval->DoConvertToPolyObj(bBezier, bAddText);
1274 }
1275
1276 return nullptr;
1277}
1278
1280{
1281 const bool bRemove(pNewPage == nullptr && pOldPage != nullptr);
1282 const bool bInsert(pNewPage != nullptr && pOldPage == nullptr);
1283
1284 if (bRemove && mpImpl->mbConnected )
1285 {
1286 Disconnect();
1287 }
1288
1289 // call parent
1290 SdrRectObj::handlePageChange(pOldPage, pNewPage);
1291
1292 if (bInsert && !mpImpl->mbConnected )
1293 {
1294 Connect();
1295 }
1296}
1297
1298void SdrOle2Obj::SetObjRef( const css::uno::Reference < css::embed::XEmbeddedObject >& rNewObjRef )
1299{
1300 DBG_ASSERT( !rNewObjRef.is() || !mpImpl->mxObjRef.GetObject().is(), "SetObjRef called on already initialized object!");
1301 if( rNewObjRef == mpImpl->mxObjRef.GetObject() )
1302 return;
1303
1304 // the caller of the method is responsible to control the old object, it will not be closed here
1305 // Otherwise WW8 import crashes because it transfers control to OLENode by this method
1306 if ( mpImpl->mxObjRef.GetObject().is() )
1307 mpImpl->mxObjRef.Lock( false );
1308
1309 // avoid removal of object in Disconnect! It is definitely a HACK to call SetObjRef(0)!
1310 // This call will try to close the objects; so if anybody else wants to keep it, it must be locked by a CloseListener
1311 mpImpl->mxObjRef.Clear();
1312
1313 if ( mpImpl->mbConnected )
1314 Disconnect();
1315
1316 mpImpl->mxObjRef.Assign( rNewObjRef, GetAspect() );
1317 mpImpl->mbTypeAsked = false;
1318
1319 if ( mpImpl->mxObjRef.is() )
1320 {
1321 mpImpl->moGraphic.reset();
1322
1323 if ( mpImpl->mxObjRef->getStatus( GetAspect() ) & embed::EmbedMisc::EMBED_NEVERRESIZE )
1324 SetResizeProtect(true);
1325
1326 // For math objects, set closed state to transparent
1327 SetClosedObj(!ImplIsMathObj( rNewObjRef ));
1328
1329 Connect();
1330 }
1331
1332 SetChanged();
1334}
1335
1336void SdrOle2Obj::SetClosedObj( bool bIsClosed )
1337{
1338 // TODO/LATER: do we still need this hack?
1339 // Allow changes to the closed state of OLE objects
1340 m_bClosedObj = bIsClosed;
1341}
1342
1344{
1345 // #i118485# use central replacement generator
1346 return createSdrGrafObjReplacement(false);
1347}
1348
1349void SdrOle2Obj::SetPersistName( const OUString& rPersistName )
1350{
1351 DBG_ASSERT( mpImpl->aPersistName.isEmpty(), "Persist name changed!");
1352
1353 mpImpl->aPersistName = rPersistName;
1354 mpImpl->mbLoadingOLEObjectFailed = false;
1355
1356 Connect();
1357 SetChanged();
1358}
1359
1361{
1362 mpImpl->aPersistName.clear();
1363 mpImpl->mbLoadingOLEObjectFailed = false;
1364 SetObjRef(nullptr);
1365}
1366
1367const OUString& SdrOle2Obj::GetPersistName() const
1368{
1369 return mpImpl->aPersistName;
1370}
1371
1373{
1374 // #i118485# Allowing much more attributes for OLEs
1375 rInfo.bRotateFreeAllowed = true;
1376 rInfo.bRotate90Allowed = true;
1377 rInfo.bMirrorFreeAllowed = true;
1378 rInfo.bMirror45Allowed = true;
1379 rInfo.bMirror90Allowed = true;
1380 rInfo.bTransparenceAllowed = true;
1381 rInfo.bShearAllowed = true;
1382 rInfo.bEdgeRadiusAllowed = false;
1383 rInfo.bNoOrthoDesired = false;
1384 rInfo.bCanConvToPath = true;
1385 rInfo.bCanConvToPoly = true;
1386 rInfo.bCanConvToPathLineToArea = false;
1387 rInfo.bCanConvToPolyLineToArea = false;
1388 rInfo.bCanConvToContour = true;
1389}
1390
1392{
1394}
1395
1397{
1398 OUStringBuffer sName(SvxResId(mpImpl->mbFrame ? STR_ObjNameSingulFrame : STR_ObjNameSingulOLE2));
1399
1400 const OUString aName(GetName());
1401
1402 if (!aName.isEmpty())
1403 {
1404 sName.append(" '" + aName + "\'");
1405 }
1406
1407 return sName.makeStringAndClear();
1408}
1409
1411{
1412 return SvxResId(mpImpl->mbFrame ? STR_ObjNamePluralFrame : STR_ObjNamePluralOLE2);
1413}
1414
1416{
1417 return new SdrOle2Obj(rTargetModel, *this);
1418}
1419
1421{
1422 // #i118524# do not again set VisAreaSize when the call comes from OLE client (e.g. ObjectAreaChanged)
1423 if (mpImpl->mbSuppressSetVisAreaSize)
1424 return;
1425
1426 // currently there is no need to recalculate scaling for iconified objects
1427 // TODO/LATER: it might be needed in future when it is possible to change the icon
1428 if ( GetAspect() == embed::Aspects::MSOLE_ICON )
1429 return;
1430
1431 // the object area of an embedded object was changed, e.g. by user interaction an a selected object
1432 GetObjRef();
1433 if (!mpImpl->mxObjRef.is())
1434 return;
1435
1436 sal_Int64 nMiscStatus = mpImpl->mxObjRef->getStatus( GetAspect() );
1437
1438 // the client is required to get access to scaling
1439 SfxInPlaceClient* pClient(
1441 dynamic_cast<SfxObjectShell*>(
1442 getSdrModelFromSdrObject().GetPersist()),
1443 mpImpl->mxObjRef.GetObject()));
1444 const bool bHasOwnClient(
1445 mpImpl->mxLightClient.is() &&
1446 mpImpl->mxObjRef->getClientSite() == uno::Reference< embed::XEmbeddedClient >( mpImpl->mxLightClient ) );
1447
1448 if ( pClient || bHasOwnClient )
1449 {
1450 // TODO: IMHO we need to do similar things when object is UIActive or OutplaceActive?!
1451 if ( ((nMiscStatus & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE) &&
1452 svt::EmbeddedObjectRef::TryRunningState( mpImpl->mxObjRef.GetObject() ))
1453 || mpImpl->mxObjRef->getCurrentState() == embed::EmbedStates::INPLACE_ACTIVE
1454 )
1455 {
1456 Fraction aScaleWidth;
1457 Fraction aScaleHeight;
1458 if ( pClient )
1459 {
1460 aScaleWidth = pClient->GetScaleWidth();
1461 aScaleHeight = pClient->GetScaleHeight();
1462 }
1463 else
1464 {
1465 aScaleWidth = mpImpl->mxLightClient->GetScaleWidth();
1466 aScaleHeight = mpImpl->mxLightClient->GetScaleHeight();
1467 }
1468
1469 // The object wants to resize itself (f.e. Chart wants to recalculate the layout)
1470 // or object is inplace active and so has a window that must be resized also
1471 // In these cases the change in the object area size will be reflected in a change of the
1472 // objects' visual area. The scaling will not change, but it might exist already and must
1473 // be used in calculations
1474 MapUnit aMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( mpImpl->mxObjRef->getMapUnit( GetAspect() ) );
1475 Size aVisSize;
1476 if (sal_Int32(aScaleWidth) != 0 && sal_Int32(aScaleHeight) != 0) // avoid div by zero
1477 aVisSize = Size( static_cast<tools::Long>( Fraction( getRectangle().GetWidth() ) / aScaleWidth ),
1478 static_cast<tools::Long>( Fraction( getRectangle().GetHeight() ) / aScaleHeight ) );
1479
1480 aVisSize = OutputDevice::LogicToLogic(
1481 aVisSize,
1482 MapMode(getSdrModelFromSdrObject().GetScaleUnit()),
1483 MapMode(aMapUnit));
1484 awt::Size aSz;
1485 aSz.Width = aVisSize.Width();
1486 aSz.Height = aVisSize.Height();
1487 mpImpl->mxObjRef->setVisualAreaSize( GetAspect(), aSz );
1488
1489 try
1490 {
1491 aSz = mpImpl->mxObjRef->getVisualAreaSize( GetAspect() );
1492 }
1493 catch( embed::NoVisualAreaSizeException& )
1494 {}
1495
1496 tools::Rectangle aAcceptedVisArea;
1497 aAcceptedVisArea.SetSize( Size( static_cast<tools::Long>( Fraction( tools::Long( aSz.Width ) ) * aScaleWidth ),
1498 static_cast<tools::Long>( Fraction( tools::Long( aSz.Height ) ) * aScaleHeight ) ) );
1499 if (aVisSize != aAcceptedVisArea.GetSize())
1500 {
1501 // server changed VisArea to its liking and the VisArea is different than the suggested one
1502 // store the new value as given by the object
1503 MapUnit aNewMapUnit = VCLUnoHelper::UnoEmbed2VCLMapUnit( mpImpl->mxObjRef->getMapUnit( GetAspect() ) );
1504 auto aSize = OutputDevice::LogicToLogic(aAcceptedVisArea.GetSize(), MapMode(aNewMapUnit), MapMode(getSdrModelFromSdrObject().GetScaleUnit()));
1505 setRectangleSize(aSize.Width(), aSize.Height());
1506 }
1507
1508 // make the new object area known to the client
1509 // compared to the "else" branch aRect might have been changed by the object and no additional scaling was applied
1510 // WHY this -> OSL_ASSERT( pClient );
1511 if( pClient )
1512 pClient->SetObjArea(getRectangle());
1513
1514 // we need a new replacement image as the object has resized itself
1515
1516 //#i79578# don't request a new replacement image for charts to often
1517 //a chart sends a modified call to the framework if it was changed
1518 //thus the replacement update is already handled there
1519 if( !IsChart() )
1520 mpImpl->mxObjRef.UpdateReplacement();
1521 }
1522 else
1523 {
1524 // The object isn't active and does not want to resize itself so the changed object area size
1525 // will be reflected in a changed object scaling
1526 Fraction aScaleWidth;
1527 Fraction aScaleHeight;
1528 Size aObjAreaSize;
1529 if ( CalculateNewScaling( aScaleWidth, aScaleHeight, aObjAreaSize ) )
1530 {
1531 if ( pClient )
1532 {
1533 tools::Rectangle aScaleRect(getRectangle().TopLeft(), aObjAreaSize);
1534 pClient->SetObjAreaAndScale( aScaleRect, aScaleWidth, aScaleHeight);
1535 }
1536 else
1537 {
1538 mpImpl->mxLightClient->SetSizeScale( aScaleWidth, aScaleHeight );
1539 }
1540 }
1541 }
1542 }
1543 else if( (nMiscStatus & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE) &&
1544 svt::EmbeddedObjectRef::TryRunningState( mpImpl->mxObjRef.GetObject() ) )
1545 {
1546 //also handle not sfx based ole objects e.g. charts
1547 //#i83860# resizing charts in impress distorts fonts
1548 uno::Reference< embed::XVisualObject > xVisualObject( getXModel(), uno::UNO_QUERY );
1549 if( xVisualObject.is() )
1550 {
1551 const MapUnit aMapUnit(
1553 mpImpl->mxObjRef->getMapUnit(GetAspect())));
1554 const Point aTL( getRectangle().TopLeft() );
1555 const Point aBR( getRectangle().BottomRight() );
1556 const Point aTL2(
1558 aTL,
1559 MapMode(getSdrModelFromSdrObject().GetScaleUnit()),
1560 MapMode(aMapUnit)));
1561 const Point aBR2(
1563 aBR,
1564 MapMode(getSdrModelFromSdrObject().GetScaleUnit()),
1565 MapMode(aMapUnit)));
1566 const tools::Rectangle aNewRect(
1567 aTL2,
1568 aBR2);
1569
1570 xVisualObject->setVisualAreaSize(
1571 GetAspect(),
1572 awt::Size(
1573 aNewRect.GetWidth(),
1574 aNewRect.GetHeight()));
1575 }
1576 }
1577}
1578
1579void SdrOle2Obj::NbcResize(const Point& rRef, const Fraction& xFact, const Fraction& yFact)
1580{
1581 if(!getSdrModelFromSdrObject().isLocked())
1582 {
1583 GetObjRef();
1584
1585 if ( mpImpl->mxObjRef.is() && ( mpImpl->mxObjRef->getStatus( GetAspect() ) & embed::EmbedMisc::MS_EMBED_RECOMPOSEONRESIZE ) )
1586 {
1587 // if the object needs recompose on resize
1588 // the client site should be created before the resize will take place
1589 // check whether there is no client site and create it if necessary
1591 }
1592 }
1593
1594 SdrRectObj::NbcResize(rRef,xFact,yFact);
1595
1596 if( !getSdrModelFromSdrObject().isLocked() )
1598}
1599
1601{
1603
1604 if( !getSdrModelFromSdrObject().isLocked() )
1606}
1607
1609{
1611
1612 if( !getSdrModelFromSdrObject().isLocked() )
1614
1615 if ( mpImpl->mxObjRef.is() && IsChart() )
1616 {
1617 //#i103460# charts do not necessarily have an own size within ODF files,
1618 //for this case they need to use the size settings from the surrounding frame,
1619 //which is made available with this method as there is no other way
1620 mpImpl->mxObjRef.SetDefaultSizeForChart( Size( rRect.GetWidth(), rRect.GetHeight() ) );
1621 }
1622}
1623
1625{
1627
1628 if( !getSdrModelFromSdrObject().isLocked() )
1630}
1631
1633{
1634 if ( mpImpl->mxObjRef.is() )
1635 return mpImpl->mxObjRef.GetGraphic();
1636 return mpImpl->moGraphic ? &*mpImpl->moGraphic : nullptr;
1637}
1638
1640{
1641 if ( mpImpl->mxObjRef.is() )
1642 mpImpl->mxObjRef.UpdateReplacement();
1643}
1644
1645Size SdrOle2Obj::GetOrigObjSize( MapMode const * pTargetMapMode ) const
1646{
1647 return mpImpl->mxObjRef.GetSize( pTargetMapMode );
1648}
1649
1651{
1652 mpImpl->mbSuppressSetVisAreaSize = bNew;
1653}
1654
1655void SdrOle2Obj::NbcMove(const Size& rSize)
1656{
1657 SdrRectObj::NbcMove(rSize);
1658
1659 if( !getSdrModelFromSdrObject().isLocked() )
1661}
1662
1663bool SdrOle2Obj::CanUnloadRunningObj( const uno::Reference< embed::XEmbeddedObject >& xObj, sal_Int64 nAspect )
1664{
1665 uno::Reference<embed::XEmbedPersist2> xPersist(xObj, uno::UNO_QUERY);
1666 if (xPersist.is())
1667 {
1668 if (!xPersist->isStored())
1669 // It doesn't have persistent storage. We can't unload this.
1670 return false;
1671 }
1672
1673 bool bResult = false;
1674
1675 sal_Int32 nState = xObj->getCurrentState();
1676 if ( nState == embed::EmbedStates::LOADED )
1677 {
1678 // the object is already unloaded
1679 bResult = true;
1680 }
1681 else
1682 {
1683 uno::Reference < util::XModifiable > xModifiable( xObj->getComponent(), uno::UNO_QUERY );
1684 if ( !xModifiable.is() )
1685 bResult = true;
1686 else
1687 {
1688 sal_Int64 nMiscStatus = xObj->getStatus( nAspect );
1689
1690 if ( embed::EmbedMisc::MS_EMBED_ALWAYSRUN != ( nMiscStatus & embed::EmbedMisc::MS_EMBED_ALWAYSRUN ) &&
1691 embed::EmbedMisc::EMBED_ACTIVATEIMMEDIATELY != ( nMiscStatus & embed::EmbedMisc::EMBED_ACTIVATEIMMEDIATELY ) &&
1692 !( xModifiable.is() && xModifiable->isModified() ) &&
1693 !( nState == embed::EmbedStates::INPLACE_ACTIVE || nState == embed::EmbedStates::UI_ACTIVE || nState == embed::EmbedStates::ACTIVE ) )
1694 {
1695 bResult = true;
1696 }
1697 }
1698 }
1699
1700 return bResult;
1701}
1702
1703bool SdrOle2Obj::Unload( const uno::Reference< embed::XEmbeddedObject >& xObj, sal_Int64 nAspect )
1704{
1705 bool bResult = false;
1706
1707 if ( CanUnloadRunningObj( xObj, nAspect ) )
1708 {
1709 try
1710 {
1711 xObj->changeState( embed::EmbedStates::LOADED );
1712 bResult = true;
1713 }
1714 catch( css::uno::Exception& )
1715 {
1716 TOOLS_WARN_EXCEPTION( "svx", "SdrOle2Obj::Unload()" );
1717 }
1718 }
1719
1720 return bResult;
1721}
1722
1724{
1725 if (!mpImpl->mxObjRef.is())
1726 // Already unloaded.
1727 return true;
1728
1729 return Unload(mpImpl->mxObjRef.GetObject(), GetAspect());
1730}
1731
1733{
1734 if ( !mpImpl->mxObjRef.is() && !mpImpl->aPersistName.isEmpty() && getSdrModelFromSdrObject().GetPersist() )
1735 {
1736 // Only try loading if it did not went wrong up to now
1737 if(!mpImpl->mbLoadingOLEObjectFailed)
1738 {
1739 mpImpl->mxObjRef.Assign(
1740 getSdrModelFromSdrObject().GetPersist()->getEmbeddedObjectContainer().GetEmbeddedObject(mpImpl->aPersistName),
1741 GetAspect());
1742 mpImpl->mbTypeAsked = false;
1744
1745 // If loading of OLE object failed, remember that to not invoke an endless
1746 // loop trying to load it again and again.
1747 if( mpImpl->mxObjRef.is() )
1748 {
1749 mpImpl->mbLoadingOLEObjectFailed = true;
1750 }
1751
1752 // For math objects, set closed state to transparent
1753 SetClosedObj(!ImplIsMathObj( mpImpl->mxObjRef.GetObject() ));
1754 }
1755
1756 if ( mpImpl->mxObjRef.is() )
1757 {
1758 if( !IsEmptyPresObj() )
1759 {
1760 // remember modified status of model
1761 const bool bWasChanged(getSdrModelFromSdrObject().IsChanged());
1762
1763 // perhaps preview not valid anymore
1764 // This line changes the modified state of the model
1765 ClearGraphic();
1766
1767 // if status was not set before, force it back
1768 // to not set, so that SetGraphic(0) above does not
1769 // set the modified state of the model.
1770 if(!bWasChanged && getSdrModelFromSdrObject().IsChanged())
1771 {
1773 }
1774 }
1775 }
1776
1777 if ( mpImpl->mxObjRef.is() )
1778 Connect();
1779 }
1780
1781 if ( mpImpl->mbConnected )
1782 {
1783 // move object to first position in cache
1785 }
1786}
1787
1788uno::Reference < embed::XEmbeddedObject > const & SdrOle2Obj::GetObjRef() const
1789{
1790 const_cast<SdrOle2Obj*>(this)->GetObjRef_Impl();
1791 return mpImpl->mxObjRef.GetObject();
1792}
1793
1794uno::Reference < embed::XEmbeddedObject > const & SdrOle2Obj::GetObjRef_NoInit() const
1795{
1796 return mpImpl->mxObjRef.GetObject();
1797}
1798
1799uno::Reference< frame::XModel > SdrOle2Obj::getXModel() const
1800{
1802 return uno::Reference< frame::XModel >( mpImpl->mxObjRef->getComponent(), uno::UNO_QUERY );
1803 else
1804 return uno::Reference< frame::XModel >();
1805}
1806
1808{
1809 if (!mpImpl->mbTypeAsked)
1810 {
1811 mpImpl->mbIsChart = mpImpl->mxObjRef.IsChart();
1812 mpImpl->mbTypeAsked = true;
1813 }
1814 return mpImpl->mbIsChart;
1815}
1816
1818{
1819 mpImpl->mxObjRef.SetGraphic( aGraphic, OUString() );
1820 // if the object isn't valid, e.g. link to something that doesn't exist, set the fallback
1821 // graphic as mxGraphic so SdrOle2Obj::GetGraphic will show the fallback
1822 if (const Graphic* pObjGraphic = mpImpl->mxObjRef.is() ? nullptr : mpImpl->mxObjRef.GetGraphic())
1823 mpImpl->moGraphic.emplace(*pObjGraphic);
1824}
1825
1826void SdrOle2Obj::SetGraphicToObj( const uno::Reference< io::XInputStream >& xGrStream, const OUString& aMediaType )
1827{
1828 mpImpl->mxObjRef.SetGraphicStream( xGrStream, aMediaType );
1829 // if the object isn't valid, e.g. link to something that doesn't exist, set the fallback
1830 // graphic as mxGraphic so SdrOle2Obj::GetGraphic will show the fallback
1831 if (const Graphic* pObjGraphic = mpImpl->mxObjRef.is() ? nullptr : mpImpl->mxObjRef.GetGraphic())
1832 mpImpl->moGraphic.emplace(*pObjGraphic);
1833}
1834
1836{
1837 if ( !mpImpl->mxObjRef.is() )
1838 return false;
1839
1840 SvGlobalName aObjClsId( mpImpl->mxObjRef->getClassID() );
1841 return SvGlobalName(SO3_SC_CLASSID_30) == aObjClsId
1842 || SvGlobalName(SO3_SC_CLASSID_40) == aObjClsId
1843 || SvGlobalName(SO3_SC_CLASSID_50) == aObjClsId
1844 || SvGlobalName(SO3_SC_CLASSID_60) == aObjClsId
1847 || SvGlobalName(SO3_SC_CLASSID) == aObjClsId;
1848}
1849
1850uno::Reference< frame::XModel > SdrOle2Obj::GetParentXModel() const
1851{
1852 uno::Reference< frame::XModel > xDoc(getSdrModelFromSdrObject().getUnoModel(), uno::UNO_QUERY);
1853 return xDoc;
1854}
1855
1856bool SdrOle2Obj::CalculateNewScaling( Fraction& aScaleWidth, Fraction& aScaleHeight, Size& aObjAreaSize )
1857{
1858 // TODO/LEAN: to avoid rounding errors scaling always uses the VisArea.
1859 // If we don't cache it for own objects also we must load the object here
1860 if (!mpImpl->mxObjRef.is())
1861 return false;
1862
1863 MapMode aMapMode(getSdrModelFromSdrObject().GetScaleUnit());
1864 aObjAreaSize = mpImpl->mxObjRef.GetSize( &aMapMode );
1865
1866 Size aSize = getRectangle().GetSize();
1867 aScaleWidth = Fraction(aSize.Width(), aObjAreaSize.Width() );
1868 aScaleHeight = Fraction(aSize.Height(), aObjAreaSize.Height() );
1869
1870 // reduce to 10 binary digits
1871 aScaleHeight.ReduceInaccurate(10);
1872 aScaleWidth.ReduceInaccurate(10);
1873
1874 return true;
1875}
1876
1878{
1879 // The Own Light Client must be registered in object only using this method!
1880 if ( !SfxInPlaceClient::GetClient( dynamic_cast<SfxObjectShell*>(getSdrModelFromSdrObject().GetPersist()), mpImpl->mxObjRef.GetObject() )
1881 && !( mpImpl->mxLightClient.is() && mpImpl->mxObjRef->getClientSite() == uno::Reference< embed::XEmbeddedClient >( mpImpl->mxLightClient ) ) )
1882 {
1883 Connect();
1884
1885 if ( mpImpl->mxObjRef.is() && mpImpl->mxLightClient.is() )
1886 {
1887 Fraction aScaleWidth;
1888 Fraction aScaleHeight;
1889 Size aObjAreaSize;
1890 if ( CalculateNewScaling( aScaleWidth, aScaleHeight, aObjAreaSize ) )
1891 {
1892 mpImpl->mxLightClient->SetSizeScale( aScaleWidth, aScaleHeight );
1893 try {
1894 mpImpl->mxObjRef->setClientSite( mpImpl->mxLightClient );
1895 return true;
1896 } catch( uno::Exception& )
1897 {}
1898 }
1899
1900 }
1901
1902 return false;
1903 }
1904
1905 return true;
1906}
1907
1909{
1910 return Graphic(BitmapEx(BMP_SVXOLEOBJ));
1911}
1912
1913void SdrOle2Obj::SetWindow(const css::uno::Reference < css::awt::XWindow >& _xWindow)
1914{
1915 if ( mpImpl->mxObjRef.is() && mpImpl->mxLightClient.is() )
1916 {
1917 mpImpl->mxLightClient->setWindow(_xWindow);
1918 }
1919}
1920
1921/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
AnyEventRef aEvent
static OutputDevice * GetDefaultDevice()
void ReduceInaccurate(unsigned nSignificantBits)
void InsertObj(SdrOle2Obj *pObj)
Definition: svdetc.cxx:168
SVXCORE_DLLPUBLIC size_t size() const
Definition: svdetc.cxx:204
void RemoveObj(SdrOle2Obj *pObj)
Definition: svdetc.cxx:195
SAL_WARN_UNUSED_RESULT Point PixelToLogic(const Point &rDevicePt) const
SAL_WARN_UNUSED_RESULT Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
virtual const tools::Rectangle & GetSnapRect() const override
Definition: svdoattr.cxx:49
OLEObjCache & GetOLEObjCache()
Definition: svdetc.hxx:193
This class represents an embedded or linked bitmap graphic object.
Definition: svdograf.hxx:68
::comphelper::IEmbeddedHelper * GetPersist() const
Definition: svdmodel.hxx:355
virtual void SetChanged(bool bFlg=true)
Definition: svdmodel.cxx:1144
All geometrical data of an arbitrary object for use in undo/redo.
Definition: svdobj.hxx:174
Provides information about various ZObject properties.
Definition: svdobj.hxx:196
void BroadcastObjectChange() const
Definition: svdobj.cxx:982
bool IsClosedObj() const
Definition: svdobj.hxx:744
bool IsEmptyPresObj() const
Definition: svdobj.hxx:832
void SetResizeProtect(bool bProt)
Definition: svdobj.cxx:2641
SdrModel & getSdrModelFromSdrObject() const
Definition: svdobj.cxx:289
virtual void SetGeoData(const SdrObjGeoData &rGeo)
Definition: svdobj.cxx:1921
SfxStyleSheet * GetStyleSheet() const
Definition: svdobj.cxx:2208
virtual const OUString & GetName() const
Definition: svdobj.cxx:769
virtual void SetChanged()
Definition: svdobj.cxx:1006
friend class SdrRectObj
Definition: svdobj.hxx:270
const SfxItemSet & GetMergedItemSet() const
Definition: svdobj.cxx:1938
bool IsInDestruction() const
Definition: svdobj.cxx:3006
bool m_bClosedObj
Definition: svdobj.hxx:914
bool m_bSizProt
Definition: svdobj.hxx:904
OUString maLinkURL
Definition: svdoole2.cxx:614
SdrOle2ObjImpl(bool bFrame, const svt::EmbeddedObjectRef &rObjRef)
Definition: svdoole2.cxx:630
svt::EmbeddedObjectRef mxObjRef
Definition: svdoole2.cxx:599
OUString aPersistName
Definition: svdoole2.cxx:603
std::optional< Graphic > moGraphic
Definition: svdoole2.cxx:601
rtl::Reference< SdrLightEmbeddedClient_Impl > mxLightClient
Definition: svdoole2.cxx:604
SdrOle2ObjImpl(bool bFrame)
Definition: svdoole2.cxx:618
bool mbLoadingOLEObjectFailed
Definition: svdoole2.cxx:610
rtl::Reference< SvxUnoShapeModifyListener > mxModifyListener
Definition: svdoole2.cxx:616
SdrEmbedObjectLink * mpObjectLink
Definition: svdoole2.cxx:613
bool mbSuppressSetVisAreaSize
Definition: svdoole2.cxx:607
OUString maProgName
Definition: svdoole2.cxx:602
void SetWindow(const css::uno::Reference< css::awt::XWindow > &_xWindow)
Definition: svdoole2.cxx:1913
SVX_DLLPRIVATE void Init()
Definition: svdoole2.cxx:683
static Graphic GetEmptyOLEReplacementGraphic()
Definition: svdoole2.cxx:1908
virtual std::unique_ptr< sdr::properties::BaseProperties > CreateObjectSpecificProperties() override
Definition: svdoole2.cxx:671
virtual ~SdrOle2Obj() override
Definition: svdoole2.cxx:788
virtual SdrObjKind GetObjIdentifier() const override
Definition: svdoole2.cxx:1391
sal_Int64 GetAspect() const
Definition: svdoole2.cxx:812
std::unique_ptr< SdrOle2ObjImpl > mpImpl
Definition: svdoole2.hxx:49
void Disconnect()
Definition: svdoole2.cxx:1091
static bool CanUnloadRunningObj(const css::uno::Reference< css::embed::XEmbeddedObject > &xObj, sal_Int64 nAspect)
Definition: svdoole2.cxx:1663
bool IsEmpty() const
Definition: svdoole2.cxx:854
SVX_DLLPRIVATE void Disconnect_Impl()
Definition: svdoole2.cxx:1129
css::uno::Reference< css::embed::XEmbeddedObject > const & GetObjRef() const
Definition: svdoole2.cxx:1788
const svt::EmbeddedObjectRef & getEmbeddedObjectRef() const
Definition: svdoole2.cxx:807
const Graphic * GetGraphic() const
Definition: svdoole2.cxx:1632
void SetProgName(const OUString &rName)
Definition: svdoole2.cxx:844
void BreakFileLink_Impl()
Definition: svdoole2.cxx:929
const OUString & GetProgName() const
Definition: svdoole2.cxx:849
virtual rtl::Reference< SdrObject > CloneSdrObject(SdrModel &rTargetModel) const override
Definition: svdoole2.cxx:1415
void setSuppressSetVisAreaSize(bool bNew)
Definition: svdoole2.cxx:1650
void ClearGraphic()
Definition: svdoole2.cxx:836
virtual rtl::Reference< SdrObject > DoConvertToPolyObj(bool bBezier, bool bAddText) const override
Definition: svdoole2.cxx:1266
SVX_DLLPRIVATE void Connect_Impl()
Definition: svdoole2.cxx:998
SVX_DLLPRIVATE css::uno::Reference< css::embed::XEmbeddedObject > const & GetObjRef_NoInit() const
Definition: svdoole2.cxx:1794
bool UpdateLinkURL_Impl()
Definition: svdoole2.cxx:876
const OUString & GetPersistName() const
Definition: svdoole2.cxx:1367
virtual void TakeObjInfo(SdrObjTransformInfoRec &rInfo) const override
Definition: svdoole2.cxx:1372
void CheckFileLink_Impl()
Definition: svdoole2.cxx:964
bool isUiActive() const
Definition: svdoole2.cxx:822
bool Unload()
Definition: svdoole2.cxx:1723
void GetNewReplacement()
Definition: svdoole2.cxx:1639
virtual void NbcResize(const Point &rRef, const Fraction &xFact, const Fraction &yFact) override
Definition: svdoole2.cxx:1579
SVX_DLLPRIVATE void RemoveListeners_Impl()
Definition: svdoole2.cxx:1106
bool isInplaceActive() const
Definition: svdoole2.cxx:817
void Connect()
Definition: svdoole2.cxx:859
SVX_DLLPRIVATE void AddListeners_Impl()
Definition: svdoole2.cxx:1073
void SetObjRef(const css::uno::Reference< css::embed::XEmbeddedObject > &rNewObjRef)
Definition: svdoole2.cxx:1298
void SetClosedObj(bool bIsClosed)
Change the IsClosedObj attribute.
Definition: svdoole2.cxx:1336
void AbandonObject()
Definition: svdoole2.cxx:1360
bool CalculateNewScaling(Fraction &aScaleWidth, Fraction &aScaleHeight, Size &aObjAreaSize)
Definition: svdoole2.cxx:1856
void SetGraphicToObj(const Graphic &aGraphic)
Definition: svdoole2.cxx:1817
void SetGraphic(const Graphic &rGrf)
Definition: svdoole2.cxx:827
virtual void SetGeoData(const SdrObjGeoData &rGeo) override
Definition: svdoole2.cxx:1600
virtual OUString TakeObjNameSingul() const override
Definition: svdoole2.cxx:1396
Size GetOrigObjSize(MapMode const *pTargetMapMode=nullptr) const
Definition: svdoole2.cxx:1645
virtual void NbcMove(const Size &rSize) override
The methods Move, Resize, Rotate, Mirror, Shear, SetSnapRect and SetLogicRect call the corresponding ...
Definition: svdoole2.cxx:1655
SVX_DLLPRIVATE rtl::Reference< SdrObject > createSdrGrafObjReplacement(bool bAddText) const
Definition: svdoole2.cxx:1207
bool AddOwnLightClient()
Definition: svdoole2.cxx:1877
SVX_DLLPRIVATE void ImpSetVisAreaSize()
Definition: svdoole2.cxx:1420
virtual rtl::Reference< SdrObject > getFullDragClone() const override
Definition: svdoole2.cxx:1343
OUString GetStyleString()
Definition: svdoole2.cxx:778
bool IsChart() const
Definition: svdoole2.cxx:1807
virtual OUString TakeObjNamePlural() const override
Definition: svdoole2.cxx:1410
css::uno::Reference< css::frame::XModel > GetParentXModel() const
Definition: svdoole2.cxx:1850
void SetPersistName(const OUString &rPersistName)
Definition: svdoole2.cxx:1349
SVX_DLLPRIVATE void GetObjRef_Impl()
Definition: svdoole2.cxx:1732
css::uno::Reference< css::frame::XModel > getXModel() const
Definition: svdoole2.cxx:1799
virtual void NbcSetSnapRect(const tools::Rectangle &rRect) override
Definition: svdoole2.cxx:1608
bool IsCalc() const
Definition: svdoole2.cxx:1835
void SetAspect(sal_Int64 nAspect)
Definition: svdoole2.cxx:802
void ObjectLoaded()
Definition: svdoole2.cxx:1068
virtual void handlePageChange(SdrPage *pOldPage, SdrPage *pNewPage) override
Definition: svdoole2.cxx:1279
virtual void NbcSetLogicRect(const tools::Rectangle &rRect) override
Definition: svdoole2.cxx:1624
virtual std::unique_ptr< sdr::contact::ViewContact > CreateObjectSpecificViewContact() override
Definition: svdoole2.cxx:678
SdrOle2Obj(SdrModel &rSdrModel, bool bFrame_=false)
Definition: svdoole2.cxx:704
void DisconnectFileLink_Impl()
Definition: svdoole2.cxx:953
A SdrPage contains exactly one SdrObjList and a description of the physical page dimensions (size / m...
Definition: svdpage.hxx:377
Rectangle objects (rectangle, circle, ...)
Definition: svdorect.hxx:39
virtual void NbcSetSnapRect(const tools::Rectangle &rRect) override
Definition: svdorect.cxx:269
virtual void NbcResize(const Point &rRef, const Fraction &xFact, const Fraction &yFact) override
Definition: svdorect.cxx:451
virtual void NbcSetLogicRect(const tools::Rectangle &rRect) override
Definition: svdorect.cxx:275
virtual void NbcMove(const Size &rSiz) override
The methods Move, Resize, Rotate, Mirror, Shear, SetSnapRect and SetLogicRect call the corresponding ...
Definition: svdorect.cxx:445
tools::Rectangle const & getRectangle() const
Definition: svdotext.hxx:170
virtual OutlinerParaObject * GetOutlinerParaObject() const override
Definition: svdotext.cxx:1452
virtual void handlePageChange(SdrPage *pOldPage, SdrPage *pNewPage) override
Definition: svdotext.cxx:480
void setRectangleSize(sal_Int32 nWidth, sal_Int32 nHeight)
Definition: svdotext.hxx:180
virtual bool TRGetBaseGeometry(basegfx::B2DHomMatrix &rMatrix, basegfx::B2DPolyPolygon &rPolyPolygon) const override
Definition: svdotext.cxx:1694
bool SetObjArea(const tools::Rectangle &)
void SetObjAreaAndScale(const tools::Rectangle &, const Fraction &, const Fraction &)
const Fraction & GetScaleHeight() const
const Fraction & GetScaleWidth() const
static SfxInPlaceClient * GetClient(SfxObjectShell const *pDoc, const css::uno::Reference< css::embed::XEmbeddedObject > &xObject)
constexpr tools::Long Height() const
constexpr tools::Long Width() const
static MapUnit UnoEmbed2VCLMapUnit(sal_Int32 nUnoEmbedMapUnit)
bool HasEmbeddedObject(const OUString &)
void CloseEmbeddedObject(const css::uno::Reference< css::embed::XEmbeddedObject > &)
css::uno::Reference< css::embed::XEmbeddedObject > CopyAndGetEmbeddedObject(EmbeddedObjectContainer &rSrc, const css::uno::Reference< css::embed::XEmbeddedObject > &xObj, OUString &rName, const OUString &rSrcShellID, const OUString &rDestShellID)
void RemoveEmbeddedObject(const OUString &rName, bool bKeepToTempStorage=true)
css::uno::Reference< css::embed::XEmbeddedObject > GetEmbeddedObject(const OUString &, OUString const *pBaseURL=nullptr)
bool InsertEmbeddedObject(const css::uno::Reference< css::embed::XEmbeddedObject > &, OUString &)
virtual EmbeddedObjectContainer & getEmbeddedObjectContainer() const=0
virtual OUString getDocumentBaseURL() const=0
oslInterlockedCount m_refCount
#define SO3_SC_CLASSID_30
#define SO3_SM_CLASSID_50
#define SO3_SC_CLASSID_60
#define SO3_SM_CLASSID_60
#define SO3_SC_CLASSID
#define SO3_SC_CLASSID_40
#define SO3_SM_CLASSID_30
#define SO3_SM_CLASSID_40
#define SO3_SC_OLE_EMBED_CLASSID_60
#define SO3_SC_CLASSID_50
#define SO3_SC_OLE_EMBED_CLASSID_8
#define SO3_SM_CLASSID
void InsertFileLink(sfx2::SvBaseLink &, SvBaseLinkObjectType nFileType, std::u16string_view rFileNm, const OUString *pFilterNm=nullptr, const OUString *pRange=nullptr)
static bool GetDisplayNames(const SvBaseLink *, OUString *pType, OUString *pFile=nullptr, OUString *pLink=nullptr, OUString *pFilter=nullptr)
void Remove(SvBaseLink const *pLink)
static bool TryRunningState(const css::uno::Reference< css::embed::XEmbeddedObject > &)
void Lock(bool bLock=true)
ColorConfigValue GetColorValue(ColorConfigEntry eEntry, bool bSmart=true) const
constexpr tools::Long GetWidth() const
void SetSize(const Size &)
constexpr Point TopLeft() const
constexpr Size GetSize() const
constexpr tools::Long GetHeight() const
css::awt::Rectangle AWTRectangle(const ::tools::Rectangle &rVCLRect)
inline ::tools::Rectangle VCLRectangle(const css::awt::Rectangle &rAWTRect)
int nCount
#define DBG_ASSERT(sCon, aError)
#define TOOLS_WARN_EXCEPTION(area, stream)
OUString SvxResId(TranslateId aId)
Definition: dialmgr.cxx:24
float u
EmbeddedObjectRef * pObject
sal_Int32 nState
SotClipboardFormatId
OUString sName
OUString aName
SfxLinkUpdateMode
MapUnit
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
Any SAL_CALL getCaughtException()
int i
long Long
Reference< XController > xController
Reference< XFrame > xFrame
SdrGlobalData & GetSdrGlobalData()
Definition: svdetc.cxx:82
SdrObjKind
Definition: svdobjkind.hxx:25
@ OLE2
foreign graphic (StarView Graphic)
@ OLEPluginFrame
measurement object
static bool ImplIsMathObj(const uno::Reference< embed::XEmbeddedObject > &rObjRef)
Definition: svdoole2.cxx:656
static uno::Reference< beans::XPropertySet > lcl_getFrame_throw(const SdrOle2Obj *_pObject)
Definition: svdoole2.cxx:88
unsigned char sal_Bool