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