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