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