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