LibreOffice Module sw (master)  1
ndole.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 <com/sun/star/container/XChild.hpp>
21 #include <com/sun/star/embed/XEmbeddedObject.hpp>
22 #include <com/sun/star/embed/XEmbedPersist.hpp>
23 #include <com/sun/star/embed/XLinkageSupport.hpp>
24 #include <com/sun/star/embed/EmbedMisc.hpp>
25 #include <com/sun/star/embed/EmbedStates.hpp>
26 #include <com/sun/star/util/XModifiable.hpp>
27 #include <com/sun/star/chart2/XChartDocument.hpp>
28 #include <cppuhelper/implbase.hxx>
29 
30 #include <sot/exchange.hxx>
31 #include <tools/globname.hxx>
32 #include <hintids.hxx>
33 #include <sfx2/docfile.hxx>
34 #include <sfx2/app.hxx>
35 #include <sfx2/linkmgr.hxx>
36 #include <unotools/configitem.hxx>
37 #include <vcl/outdev.hxx>
38 #include <fmtanchr.hxx>
39 #include <frmfmt.hxx>
40 #include <doc.hxx>
41 #include <docsh.hxx>
42 #include <pam.hxx>
43 #include <section.hxx>
44 #include <cntfrm.hxx>
45 #include <frmatr.hxx>
46 #include <ndole.hxx>
47 #include <viewsh.hxx>
51 #include <comphelper/classids.hxx>
52 #include <vcl/graph.hxx>
53 #include <sot/formats.hxx>
54 #include <vcl/svapp.hxx>
55 #include <vcl/graphicfilter.hxx>
56 #include <strings.hrc>
57 #include <svx/charthelper.hxx>
59 #include <atomic>
60 #include <deque>
61 
62 using namespace utl;
63 using namespace com::sun::star::uno;
64 using namespace com::sun::star;
65 
67  : private utl::ConfigItem
68 {
69 private:
70  typedef std::deque<SwOLEObj *> OleObjects_t;
71  OleObjects_t m_OleObjects;
72  sal_Int32 m_nLRU_InitSize;
73  static uno::Sequence< OUString > GetPropertyNames();
74 
75  virtual void ImplCommit() override;
76 
77 public:
78  SwOLELRUCache();
79 
80  virtual void Notify( const uno::Sequence<
81  OUString>& aPropertyNames ) override;
82  void Load();
83 
84  void InsertObj( SwOLEObj& rObj );
85  void RemoveObj( SwOLEObj& rObj );
86 };
87 
88 static std::shared_ptr<SwOLELRUCache> g_pOLELRU_Cache;
89 
90 class SwOLEListener_Impl : public ::cppu::WeakImplHelper< embed::XStateChangeListener >
91 {
93 public:
94  explicit SwOLEListener_Impl( SwOLEObj* pObj );
95  void dispose();
96  virtual void SAL_CALL changingState( const lang::EventObject& aEvent, ::sal_Int32 nOldState, ::sal_Int32 nNewState ) override;
97  virtual void SAL_CALL stateChanged( const lang::EventObject& aEvent, ::sal_Int32 nOldState, ::sal_Int32 nNewState ) override;
98  virtual void SAL_CALL disposing( const lang::EventObject& aEvent ) override;
99 };
100 
102 : mpObj( pObj )
103 {
104  if ( mpObj->IsOleRef() && mpObj->GetOleRef()->getCurrentState() == embed::EmbedStates::RUNNING )
105  {
106  g_pOLELRU_Cache->InsertObj( *mpObj );
107  }
108 }
109 
110 void SAL_CALL SwOLEListener_Impl::changingState( const lang::EventObject&, ::sal_Int32 , ::sal_Int32 )
111 {
112 }
113 
114 void SAL_CALL SwOLEListener_Impl::stateChanged( const lang::EventObject&, ::sal_Int32 nOldState, ::sal_Int32 nNewState )
115 {
116  if ( mpObj && nOldState == embed::EmbedStates::LOADED && nNewState == embed::EmbedStates::RUNNING )
117  {
118  if (!g_pOLELRU_Cache)
119  g_pOLELRU_Cache.reset(new SwOLELRUCache);
120  g_pOLELRU_Cache->InsertObj( *mpObj );
121  }
122  else if ( mpObj && nNewState == embed::EmbedStates::LOADED && nOldState == embed::EmbedStates::RUNNING )
123  {
124  if (g_pOLELRU_Cache)
125  g_pOLELRU_Cache->RemoveObj( *mpObj );
126  }
127  else if(mpObj && nNewState == embed::EmbedStates::RUNNING)
128  {
130  }
131 }
132 
134 {
135  if (mpObj && g_pOLELRU_Cache)
136  g_pOLELRU_Cache->RemoveObj( *mpObj );
137  mpObj = nullptr;
138 }
139 
140 void SAL_CALL SwOLEListener_Impl::disposing( const lang::EventObject& )
141 {
142  if (mpObj && g_pOLELRU_Cache)
143  g_pOLELRU_Cache->RemoveObj( *mpObj );
144 }
145 
146 // TODO/LATER: actually SwEmbedObjectLink should be used here, but because different objects are used to control
147 // embedded object different link objects with the same functionality had to be implemented
148 
150 {
152 
153 public:
154  explicit SwEmbedObjectLink(SwOLENode* pNode);
155 
156  virtual void Closed() override;
157  virtual ::sfx2::SvBaseLink::UpdateResult DataChanged(
158  const OUString& rMimeType, const css::uno::Any & rValue ) override;
159 
160  void Connect() { GetRealObject(); }
161 };
162 
164  ::sfx2::SvBaseLink( ::SfxLinkUpdateMode::ONCALL, SotClipboardFormatId::SVXB ),
165  pOleNode(pNode)
166 {
167  SetSynchron( false );
168 }
169 
171  const OUString&, const uno::Any& )
172 {
173  if ( !pOleNode->UpdateLinkURL_Impl() )
174  {
175  // the link URL was not changed
176  uno::Reference< embed::XEmbeddedObject > xObject = pOleNode->GetOLEObj().GetOleRef();
177  OSL_ENSURE( xObject.is(), "The object must exist always!" );
178  if ( xObject.is() )
179  {
180  // let the object reload the link
181  // TODO/LATER: reload call could be used for this case
182 
183  try
184  {
185  sal_Int32 nState = xObject->getCurrentState();
186  if ( nState != embed::EmbedStates::LOADED )
187  {
188  // in some cases the linked file probably is not locked so it could be changed
189  xObject->changeState( embed::EmbedStates::LOADED );
190  xObject->changeState( nState );
191  }
192  }
193  catch (const uno::Exception&)
194  {
195  }
196  }
197  }
198 
200  pOleNode->SetChanged();
201 
202  return SUCCESS;
203 }
204 
206 {
208  SvBaseLink::Closed();
209 }
210 
212  const svt::EmbeddedObjectRef& xObj,
213  SwGrfFormatColl *pGrfColl,
214  SwAttrSet const * pAutoAttr ) :
215  SwNoTextNode( rWhere, SwNodeType::Ole, pGrfColl, pAutoAttr ),
216  maOLEObj( xObj ),
217  mbOLESizeInvalid( false ),
218  mpObjectLink( nullptr )
219 {
220  maOLEObj.SetNode( this );
221 }
222 
224  const OUString &rString,
225  sal_Int64 nAspect,
226  SwGrfFormatColl *pGrfColl,
227  SwAttrSet const * pAutoAttr ) :
228  SwNoTextNode( rWhere, SwNodeType::Ole, pGrfColl, pAutoAttr ),
229  maOLEObj( rString, nAspect ),
230  mbOLESizeInvalid( false ),
231  mpObjectLink( nullptr )
232 {
233  maOLEObj.SetNode( this );
234 }
235 
237 {
239 }
240 
242 {
243  if ( maOLEObj.GetOleRef().is() )
244  return maOLEObj.m_xOLERef.GetGraphic();
245  return nullptr;
246 }
247 
252 {
253  OSL_ENSURE( maOLEObj.GetOleRef().is(), "No object to restore!" );
254  if ( maOLEObj.m_xOLERef.is() )
255  {
256  // If a SvPersist instance already exists, we use it
257  SfxObjectShell* p = GetDoc()->GetPersist();
258  if( !p )
259  {
260  // TODO/LATER: Isn't a EmbeddedObjectContainer sufficient here?
261  // What happens to this document?
262  OSL_ENSURE( false, "Why are we creating a DocShell here?" );
263  p = new SwDocShell( GetDoc(), SfxObjectCreateMode::INTERNAL );
264  p->DoInitNew();
265  }
266 
267  uno::Reference < container::XChild > xChild( maOLEObj.m_xOLERef.GetObject(), uno::UNO_QUERY );
268  if ( xChild.is() )
269  xChild->setParent( p->GetModel() );
270 
271  OSL_ENSURE( !maOLEObj.m_aName.isEmpty(), "No object name!" );
272  OUString aObjName;
274  {
275  if ( xChild.is() )
276  xChild->setParent( nullptr );
277  OSL_FAIL( "InsertObject failed" );
278  }
279  else
280  {
281  maOLEObj.m_aName = aObjName;
284  }
285  }
286 
287  return true;
288 }
289 
294 {
295  if( maOLEObj.m_xOLERef.is() )
296  {
298 
299 #if OSL_DEBUG_LEVEL > 0
300  SfxObjectShell* p = GetDoc()->GetPersist();
301  OSL_ENSURE( p, "No document!" );
302  if( p )
303  {
305  OSL_ENSURE( !pCnt || &rCnt == pCnt, "The helper is assigned to unexpected container!" );
306  }
307 #endif
308 
309  if ( pCnt && pCnt->HasEmbeddedObject( maOLEObj.m_aName ) )
310  {
311  uno::Reference < container::XChild > xChild( maOLEObj.m_xOLERef.GetObject(), uno::UNO_QUERY );
312  if ( xChild.is() )
313  xChild->setParent( nullptr );
314 
315  /*
316  #i119941
317  When cut or move the chart, SwUndoFlyBase::DelFly will call SaveSection
318  to store the content to storage. In this step, chart filter functions
319  will be called. And chart filter will call chart core functions to create
320  the chart again. Then chart core function will call the class
321  ExplicitCategoryProvider to create data source. In this step, when SW data
322  source provider create the data source, a UnoActionRemoveContext
323  will mess with the layout and create a new SwFlyFrame.
324  But later in SwUndoFlyBase::DelFly, it will clear anchor related attributes
325  of SwFlyFrame. Then finally null pointer occur.
326  Resolution:
327  In pCnt->RemoveEmbeddedObject in SaveSection process of table chart,
328  only remove the object from the object container, without removing it's
329  storage and graphic stream. The chart already removed from formatter.
330  */
331  bool bKeepObjectToTempStorage = true;
332  uno::Reference < embed::XEmbeddedObject > xIP = GetOLEObj().GetOleRef();
333  if (IsChart() && !msChartTableName.isEmpty()
335  {
336  uno::Reference< chart2::XChartDocument > xChart( xIP->getComponent(), UNO_QUERY );
337  if (xChart.is() && !xChart->hasInternalDataProvider())
338  {
339  bKeepObjectToTempStorage = false;
340  }
341  }
342 
343  pCnt->RemoveEmbeddedObject( maOLEObj.m_aName, bKeepObjectToTempStorage );
344 
345  // TODO/LATER: aOLEObj.aName has no meaning here, since the undo container contains the object
346  // by different name, in future it might makes sense that the name is transported here.
348  try
349  {
350  // "unload" object
351  maOLEObj.m_xOLERef->changeState( embed::EmbedStates::LOADED );
352  }
353  catch (const uno::Exception&)
354  {
355  }
356  }
357  }
358 
360 
361  return true;
362 }
363 
365  const svt::EmbeddedObjectRef& xObj,
366  SwGrfFormatColl* pGrfColl )
367 {
368  OSL_ENSURE( pGrfColl,"SwNodes::MakeOLENode: Formatpointer is 0." );
369 
370  SwOLENode *pNode =
371  new SwOLENode( rWhere, xObj, pGrfColl, nullptr );
372 
373  // set parent if XChild is supported
375  uno::Reference< container::XChild > xChild( pNode->GetOLEObj().GetObject().GetObject(), UNO_QUERY );
376  if (xChild.is())
377  {
378  SwDocShell *pDocSh = GetDoc()->GetDocShell();
379  if (pDocSh)
380  xChild->setParent( pDocSh->GetModel() );
381  }
382 
383  return pNode;
384 }
385 
387  const OUString &rName, sal_Int64 nAspect, SwGrfFormatColl* pGrfColl, SwAttrSet const * pAutoAttr )
388 {
389  OSL_ENSURE( pGrfColl,"SwNodes::MakeOLENode: Formatpointer is 0." );
390 
391  SwOLENode *pNode =
392  new SwOLENode( rWhere, rName, nAspect, pGrfColl, pAutoAttr );
393 
394  // set parent if XChild is supported
396  uno::Reference< container::XChild > xChild( pNode->GetOLEObj().GetObject().GetObject(), UNO_QUERY );
397  if (xChild.is())
398  {
399  SwDocShell *pDocSh= GetDoc()->GetDocShell();
400  if (pDocSh)
401  xChild->setParent( pDocSh->GetModel() );
402  }
403 
404  return pNode;
405 }
406 
408 {
409  MapMode aMapMode( MapUnit::MapTwip );
410  return const_cast<SwOLENode*>(this)->maOLEObj.GetObject().GetSize( &aMapMode );
411 }
412 
413 SwContentNode* SwOLENode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx, bool) const
414 {
415  // If there's already a SvPersist instance, we use it
416  SfxObjectShell* pPersistShell = pDoc->GetPersist();
417  if( !pPersistShell )
418  {
419  // TODO/LATER: is EmbeddedObjectContainer not enough?
420  // the created document will be closed by pDoc ( should use SfxObjectShellLock )
421  pPersistShell = new SwDocShell( pDoc, SfxObjectCreateMode::INTERNAL );
422  pDoc->SetTmpDocShell( pPersistShell );
423  pPersistShell->DoInitNew();
424  }
425 
426  // We insert it at SvPersist level
427  // TODO/LATER: check if using the same naming scheme for all apps works here
428  OUString aNewName/*( Sw3Io::UniqueName( p->GetStorage(), "Obj" ) )*/;
429  SfxObjectShell* pSrc = GetDoc()->GetPersist();
430 
434  aNewName,
435  pSrc->getDocumentBaseURL(),
436  pPersistShell->getDocumentBaseURL());
437 
438  SwOLENode* pOLENd = pDoc->GetNodes().MakeOLENode( rIdx, aNewName, GetAspect(),
439  pDoc->GetDfltGrfFormatColl(),
440  GetpSwAttrSet() );
441 
443  pOLENd->SetTitle( GetTitle() );
444  pOLENd->SetDescription( GetDescription() );
445  pOLENd->SetContour( HasContour(), HasAutomaticContour() );
446  pOLENd->SetAspect( GetAspect() ); // the replacement image must be already copied
447 
448  pOLENd->SetOLESizeInvalid( true );
449  pDoc->SetOLEPrtNotifyPending();
450 
451  return pOLENd;
452 }
453 
455 {
456  // Find the "Body Anchor"
457  sal_uLong nEndExtraIdx = GetNodes().GetEndOfExtras().GetIndex();
458  const SwNode* pAnchorNd = this;
459  do {
460  SwFrameFormat* pFlyFormat = pAnchorNd->GetFlyFormat();
461  if( !pFlyFormat )
462  return false;
463 
464  const SwFormatAnchor& rAnchor = pFlyFormat->GetAnchor();
465  if( !rAnchor.GetContentAnchor() )
466  return false;
467 
468  pAnchorNd = &rAnchor.GetContentAnchor()->nNode.GetNode();
469  } while( pAnchorNd->GetIndex() < nEndExtraIdx );
470 
471  const SwSectionNode* pSectNd = pAnchorNd->FindSectionNode();
472  if( !pSectNd )
473  return false;
474 
475  while( pSectNd )
476  {
477  pAnchorNd = pSectNd;
478  pSectNd = pAnchorNd->StartOfSectionNode()->FindSectionNode();
479  }
480 
481  // pAnchorNd contains the most recently found Section Node, which
482  // now must fulfill the prerequisites for the GlobalDoc
483  pSectNd = static_cast<const SwSectionNode*>(pAnchorNd);
484  return FILE_LINK_SECTION == pSectNd->GetSection().GetType() &&
485  pSectNd->GetIndex() > nEndExtraIdx;
486 }
487 
489 {
490  if( maOLEObj.m_xOLERef.is() )
491  {
492  SfxObjectShell* p = GetDoc()->GetPersist();
493  if( p ) // Must be there
494  {
496  }
497  }
498  return false;
499 }
500 
502 {
503  if ( maOLEObj.m_xOLERef.is() )
505 }
506 
508 {
509  bool bResult = false;
510 
511  if ( mpObjectLink )
512  {
513  OUString aNewLinkURL;
514  sfx2::LinkManager::GetDisplayNames( mpObjectLink, nullptr, &aNewLinkURL );
515  if ( !aNewLinkURL.equalsIgnoreAsciiCase( maLinkURL ) )
516  {
517  if ( !maOLEObj.m_xOLERef.is() )
519 
520  uno::Reference< embed::XEmbeddedObject > xObj = maOLEObj.m_xOLERef.GetObject();
521  uno::Reference< embed::XCommonEmbedPersist > xPersObj( xObj, uno::UNO_QUERY );
522  OSL_ENSURE( xPersObj.is(), "The object must exist!" );
523  if ( xPersObj.is() )
524  {
525  try
526  {
527  sal_Int32 nCurState = xObj->getCurrentState();
528  if ( nCurState != embed::EmbedStates::LOADED )
529  xObj->changeState( embed::EmbedStates::LOADED );
530 
531  // TODO/LATER: there should be possible to get current mediadescriptor settings from the object
532  uno::Sequence< beans::PropertyValue > aArgs( 1 );
533  aArgs[0].Name = "URL";
534  aArgs[0].Value <<= aNewLinkURL;
535  xPersObj->reload( aArgs, uno::Sequence< beans::PropertyValue >() );
536 
537  maLinkURL = aNewLinkURL;
538  bResult = true;
539 
540  if ( nCurState != embed::EmbedStates::LOADED )
541  xObj->changeState( nCurState );
542  }
543  catch (const uno::Exception&)
544  {
545  }
546  }
547 
548  if ( !bResult )
549  {
550  // TODO/LATER: return the old name to the link manager, is it possible?
551  }
552  }
553  }
554 
555  return bResult;
556 }
557 
559 {
560  SfxObjectShell* pPers = GetDoc()->GetPersist();
561 
562  if ( pPers )
563  {
564  uno::Reference< embed::XStorage > xStorage = pPers->GetStorage();
565  if ( xStorage.is() )
566  {
567  try
568  {
569  uno::Reference< embed::XLinkageSupport > xLinkSupport( maOLEObj.GetOleRef(), uno::UNO_QUERY_THROW );
570  xLinkSupport->breakLink( xStorage, maOLEObj.GetCurrentPersistName() );
572  maLinkURL.clear();
573  }
574  catch( uno::Exception& )
575  {
576  }
577  }
578  }
579 }
580 
582 {
583  if ( mpObjectLink )
584  {
586  mpObjectLink = nullptr;
587  }
588 }
589 
591 {
592  if ( maOLEObj.m_xOLERef.GetObject().is() && !mpObjectLink )
593  {
594  try
595  {
596  uno::Reference< embed::XLinkageSupport > xLinkSupport( maOLEObj.m_xOLERef.GetObject(), uno::UNO_QUERY_THROW );
597  if ( xLinkSupport->isLink() )
598  {
599  const OUString aLinkURL = xLinkSupport->getLinkURL();
600  if ( !aLinkURL.isEmpty() )
601  {
602  // this is a file link so the model link manager should handle it
603  mpObjectLink = new SwEmbedObjectLink( this );
604  maLinkURL = aLinkURL;
607  }
608  }
609  }
610  catch( uno::Exception& )
611  {
612  }
613  }
614 }
615 
616 // #i99665#
617 bool SwOLENode::IsChart() const
618 {
619  bool bIsChart( false );
620 
621  const uno::Reference< embed::XEmbeddedObject > xEmbObj =
622  const_cast<SwOLEObj&>(GetOLEObj()).GetOleRef();
623  if ( xEmbObj.is() )
624  {
625  SvGlobalName aClassID( xEmbObj->getClassID() );
626  bIsChart = SotExchange::IsChart( aClassID );
627  }
628 
629  return bIsChart;
630 }
631 
632 // react on visual change (invalidate)
634 {
635  SwFrame* pFrame(getLayoutFrame(nullptr));
636 
637  if(nullptr == pFrame)
638  {
639  return;
640  }
641 
642  const SwRect aFrameArea(pFrame->getFrameArea());
643  SwViewShell* pVSh(GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell());
644 
645  if(nullptr == pVSh)
646  {
647  return;
648  }
649 
650  for(SwViewShell& rShell : pVSh->GetRingContainer())
651  {
652  SET_CURR_SHELL(&rShell);
653 
654  if(rShell.VisArea().IsOver(aFrameArea) && OUTDEV_WINDOW == rShell.GetOut()->GetOutDevType())
655  {
656  // invalidate instead of painting
657  rShell.GetWin()->Invalidate(aFrameArea.SVRect());
658  }
659  }
660 }
661 
662 namespace { class DeflateThread; }
663 
666 {
667 private:
669  friend class SwOLEObj;
670 
671  uno::Reference< frame::XModel > maXModel;
674 
675  // evtl.set from the SwOLEObj destructor when a WorkerThread is still active
676  // since it is not possible to kill it - let it terminate and delete the
677  // data working on itself
678  std::atomic< bool> mbKilled;
679 
680  std::shared_ptr<comphelper::ThreadTaskTag> mpTag;
681 
682 public:
683  explicit DeflateData(const uno::Reference< frame::XModel >& rXModel)
684  : maXModel(rXModel),
685  maPrimitive2DSequence(),
686  maRange(),
687  mbKilled(false),
688  mpTag( comphelper::ThreadPool::createThreadTaskTag() )
689  {
690  }
691 
693  {
694  return maPrimitive2DSequence;
695  }
696 
698  {
699  return maRange;
700  }
701 
702  bool isFinished() const
703  {
705  }
706 
708  {
709  // need to wait until the load in progress is finished.
710  // WorkerThreads need the SolarMutex to be able to continue
711  // and finish the running import.
712  SolarMutexReleaser aReleaser;
714  }
715 };
716 
717 namespace {
718 
720 class DeflateThread : public comphelper::ThreadTask
721 {
722  // the data to work on
723  DeflateData& mrDeflateData;
724 
725 public:
726  explicit DeflateThread(DeflateData& rDeflateData)
727  : comphelper::ThreadTask(rDeflateData.mpTag), mrDeflateData(rDeflateData)
728  {
729  }
730 
731 private:
732  virtual void doWork() override
733  {
734  try
735  {
736  // load the chart data and get the primitives
738  mrDeflateData.maXModel,
739  mrDeflateData.maRange);
740 
741  // model no longer needed and done
742  mrDeflateData.maXModel.clear();
743  }
744  catch (const uno::Exception&)
745  {
746  }
747 
748  if(mrDeflateData.mbKilled)
749  {
750  // need to cleanup myself - data will not be used
751  delete &mrDeflateData;
752  }
753  }
754 };
755 
756 }
757 
759 
761  m_pOLENode( nullptr ),
762  m_xOLERef( xObj ),
763  m_aPrimitive2DSequence(),
764  m_aRange()
765 {
766  m_xOLERef.Lock();
767  if ( xObj.is() )
768  {
769  m_xListener = new SwOLEListener_Impl( this );
770  xObj->addStateChangeListener( m_xListener.get() );
771  }
772 }
773 
774 SwOLEObj::SwOLEObj( const OUString &rString, sal_Int64 nAspect ) :
775  m_pOLENode( nullptr ),
776  m_aName( rString ),
777  m_aPrimitive2DSequence(),
778  m_aRange()
779 {
780  m_xOLERef.Lock();
781  m_xOLERef.SetViewAspect( nAspect );
782 }
783 
784 SwOLEObj::~SwOLEObj() COVERITY_NOEXCEPT_FALSE
785 {
786  if(m_pDeflateData)
787  {
788  // set flag so that the worker thread will delete m_pDeflateData
789  // when finished and forget about it
790  m_pDeflateData->mbKilled = true;
791  m_pDeflateData = nullptr;
792  }
793 
794  if( m_xListener )
795  {
796  if ( m_xOLERef.is() )
797  m_xOLERef->removeStateChangeListener( m_xListener.get() );
798  m_xListener->dispose();
799  m_xListener.clear();
800  }
801 
802  if( m_pOLENode && !m_pOLENode->GetDoc()->IsInDtor() )
803  {
804  // if the model is not currently in destruction it means that this object should be removed from the model
806 
807 #if OSL_DEBUG_LEVEL > 0
809  OSL_ENSURE( p, "No document!" );
810  if( p )
811  {
813  OSL_ENSURE( !pCnt || &rCnt == pCnt, "The helper is assigned to unexpected container!" );
814  }
815 #endif
816 
817  if ( pCnt && pCnt->HasEmbeddedObject( m_aName ) )
818  {
819  uno::Reference < container::XChild > xChild( m_xOLERef.GetObject(), uno::UNO_QUERY );
820  if ( xChild.is() )
821  xChild->setParent( nullptr );
822 
823  // not already removed by deleting the object
824  m_xOLERef.AssignToContainer( nullptr, m_aName );
825 
826  // unlock object so that object can be closed in RemoveEmbeddedObject
827  // successful closing of the object will automatically clear the reference then
828  m_xOLERef.Lock(false);
829 
830  // Always remove object from container it is connected to
831  try
832  {
833  // remove object from container but don't close it
834  pCnt->RemoveEmbeddedObject( m_aName );
835  }
836  catch ( uno::Exception& )
837  {
838  }
839  }
840 
841  }
842 
843  if ( m_xOLERef.is() )
844  // in case the object wasn't closed: release it
845  // in case the object was not in the container: it's still locked, try to close
846  m_xOLERef.Clear();
847 }
848 
850 {
851  m_pOLENode = pNode;
852  if ( m_aName.isEmpty() )
853  {
854  SwDoc* pDoc = pNode->GetDoc();
855 
856  // If there's already a SvPersist instance, we use it
857  SfxObjectShell* p = pDoc->GetPersist();
858  if( !p )
859  {
860  // TODO/LATER: Isn't a EmbeddedObjectContainer sufficient here?
861  // What happens to the document?
862  OSL_ENSURE( false, "Why are we creating a DocShell here??" );
863  p = new SwDocShell( pDoc, SfxObjectCreateMode::INTERNAL );
864  p->DoInitNew();
865  }
866 
867  OUString aObjName;
868  uno::Reference < container::XChild > xChild( m_xOLERef.GetObject(), uno::UNO_QUERY );
869  if ( xChild.is() && xChild->getParent() != p->GetModel() )
870  // it is possible that the parent was set already
871  xChild->setParent( p->GetModel() );
873  {
874  OSL_FAIL( "InsertObject failed" );
875  if ( xChild.is() )
876  xChild->setParent( nullptr );
877  }
878  else
880 
881  const_cast<SwOLENode*>(m_pOLENode)->CheckFileLink_Impl(); // for this notification nonconst access is required
882 
883  m_aName = aObjName;
884  }
885 }
886 
888 {
889  OUString strStyle;
890  if (m_xOLERef.is() && m_xOLERef.IsChart())
891  strStyle = m_xOLERef.GetChartType();
892  return strStyle;
893 }
894 
895 bool SwOLEObj::IsOleRef() const
896 {
897  return m_xOLERef.is();
898 }
899 
900 uno::Reference < embed::XEmbeddedObject > const & SwOLEObj::GetOleRef()
901 {
902  if( !m_xOLERef.is() )
903  {
905  assert(p && "No SvPersist present");
906 
907  OUString sDocumentBaseURL = p->getDocumentBaseURL();
908  uno::Reference < embed::XEmbeddedObject > xObj = p->GetEmbeddedObjectContainer().GetEmbeddedObject(m_aName, &sDocumentBaseURL);
909  OSL_ENSURE( !m_xOLERef.is(), "Calling GetOleRef() recursively is not permitted" );
910 
911  if ( !xObj.is() )
912  {
913  // We could not load this part (probably broken)
914  tools::Rectangle aArea;
915  SwFrame *pFrame = m_pOLENode->getLayoutFrame(nullptr);
916  if ( pFrame )
917  {
918  Size aSz( pFrame->getFrameArea().SSize() );
919  const MapMode aSrc ( MapUnit::MapTwip );
920  const MapMode aDest( MapUnit::Map100thMM );
921  aSz = OutputDevice::LogicToLogic( aSz, aSrc, aDest );
922  aArea.SetSize( aSz );
923  }
924  else
925  aArea.SetSize( Size( 5000, 5000 ) );
926  // TODO/LATER: set replacement graphic for dead object
927  // It looks as if it should work even without the object, because the replace will be generated automatically
928  OUString aTmpName;
929  xObj = p->GetEmbeddedObjectContainer().CreateEmbeddedObject( SvGlobalName( SO3_DUMMY_CLASSID ).GetByteSequence(), aTmpName );
930  }
931  if (xObj.is())
932  {
935  m_xListener = new SwOLEListener_Impl( this );
936  xObj->addStateChangeListener( m_xListener.get() );
937  }
938 
939  const_cast<SwOLENode*>(m_pOLENode)->CheckFileLink_Impl(); // for this notification nonconst access is required
940  }
941  else if ( m_xOLERef->getCurrentState() == embed::EmbedStates::RUNNING )
942  {
943  // move object to first position in cache
944  if (!g_pOLELRU_Cache)
945  g_pOLELRU_Cache.reset(new SwOLELRUCache);
946  g_pOLELRU_Cache->InsertObj( *this );
947  }
948 
949  return m_xOLERef.GetObject();
950 }
951 
953 {
954  GetOleRef();
955  return m_xOLERef;
956 }
957 
959 {
960  bool bRet = true;
961  if ( m_pOLENode )
962  {
963  const SwDoc* pDoc = m_pOLENode->GetDoc();
965  }
966 
967  return bRet;
968 }
969 
970 bool SwOLEObj::UnloadObject( uno::Reference< embed::XEmbeddedObject > const & xObj, const SwDoc* pDoc, sal_Int64 nAspect )
971 {
972  if ( !pDoc )
973  return false;
974 
975  bool bRet = true;
976  sal_Int32 nState = xObj.is() ? xObj->getCurrentState() : embed::EmbedStates::LOADED;
977  bool bIsActive = ( nState != embed::EmbedStates::LOADED && nState != embed::EmbedStates::RUNNING );
978  sal_Int64 nMiscStatus = xObj->getStatus( nAspect );
979 
980  if( nState != embed::EmbedStates::LOADED && !pDoc->IsInDtor() && !bIsActive &&
981  embed::EmbedMisc::MS_EMBED_ALWAYSRUN != ( nMiscStatus & embed::EmbedMisc::MS_EMBED_ALWAYSRUN ) &&
982  embed::EmbedMisc::EMBED_ACTIVATEIMMEDIATELY != ( nMiscStatus & embed::EmbedMisc::EMBED_ACTIVATEIMMEDIATELY ) )
983  {
984  SfxObjectShell* p = pDoc->GetPersist();
985  if( p )
986  {
988  {
989  try
990  {
991  uno::Reference < util::XModifiable > xMod( xObj->getComponent(), uno::UNO_QUERY );
992  if( xMod.is() && xMod->isModified() )
993  {
994  uno::Reference < embed::XEmbedPersist > xPers( xObj, uno::UNO_QUERY );
995  assert(xPers.is() && "Modified object without persistence in cache!");
996  xPers->storeOwn();
997  }
998 
999  // setting object to loaded state will remove it from cache
1000  xObj->changeState( embed::EmbedStates::LOADED );
1001  }
1002  catch (const uno::Exception&)
1003  {
1004  bRet = false;
1005  }
1006  }
1007  else
1008  bRet = false;
1009  }
1010  }
1011 
1012  return bRet;
1013 }
1014 
1016 {
1017  uno::Reference< embed::XEmbeddedObject > xEmbObj = GetOleRef();
1018  if ( !xEmbObj.is() )
1019  return OUString();
1020 
1021  SvGlobalName aClassID( xEmbObj->getClassID() );
1022  if ( SotExchange::IsMath( aClassID ) )
1023  return SwResId(STR_MATH_FORMULA);
1024 
1025  if ( SotExchange::IsChart( aClassID ) )
1026  return SwResId(STR_CHART);
1027 
1028  return SwResId(STR_OLE);
1029 }
1030 
1032  basegfx::B2DRange& rRange,
1033  bool bSynchron)
1034 {
1035  if(m_pDeflateData)
1036  {
1037  if(bSynchron)
1038  {
1039  // data in high quality is requested, wait until the data is available
1040  // since a WorkerThread was already started to load it
1041  m_pDeflateData->waitFinished();
1042  }
1043 
1044  if(m_pDeflateData->isFinished())
1045  {
1046  // copy the result data and cleanup
1047  m_aPrimitive2DSequence = m_pDeflateData->getSequence();
1048  m_aRange = m_pDeflateData->getRange();
1049  m_pDeflateData.reset();
1050  }
1051  }
1052 
1054  {
1055  const uno::Reference< frame::XModel > aXModel(m_xOLERef->getComponent(), uno::UNO_QUERY);
1056 
1057  if(aXModel.is())
1058  {
1059  // disabled for now, need to check deeper
1060  static bool bAsynchronousLoadingAllowed = false; // loplugin:constvars:ignore
1061 
1062  if(bSynchron ||
1063  !bAsynchronousLoadingAllowed)
1064  {
1065  // load chart synchron in this Thread
1067  aXModel,
1068  m_aRange);
1069  }
1070  else
1071  {
1072  // if not yet setup, initiate and start a WorkerThread to load the chart
1073  // and it's primitives asynchron. If it already works, returning nothing
1074  // is okay (preview will be reused)
1075  if(!m_pDeflateData)
1076  {
1077  m_pDeflateData.reset( new DeflateData(aXModel) );
1078  std::unique_ptr<DeflateThread> pNew( new DeflateThread(*m_pDeflateData) );
1080  }
1081  }
1082  }
1083  }
1084 
1085  if(!m_aPrimitive2DSequence.empty() && !m_aRange.isEmpty())
1086  {
1087  // when we have data, also copy the buffered Range data as output
1088  rRange = m_aRange;
1089  }
1090 
1091  return m_aPrimitive2DSequence;
1092 }
1093 
1095 {
1097  m_aRange.reset();
1098 
1099  if(m_pDeflateData)
1100  {
1101  // load is in progress, wait until finished and cleanup without using it
1102  m_pDeflateData->waitFinished();
1103  m_pDeflateData.reset();
1104  }
1105 }
1106 
1108  : utl::ConfigItem("Office.Common/Cache")
1109  , m_nLRU_InitSize( 20 )
1110 {
1112  Load();
1113 }
1114 
1115 uno::Sequence< OUString > SwOLELRUCache::GetPropertyNames()
1116 {
1117  Sequence< OUString > aNames { "Writer/OLE_Objects" };
1118  return aNames;
1119 }
1120 
1121 void SwOLELRUCache::Notify( const uno::Sequence< OUString>& )
1122 {
1123  Load();
1124 }
1125 
1127 {
1128 }
1129 
1131 {
1133  Sequence< Any > aValues = GetProperties( aNames );
1134  const Any* pValues = aValues.getConstArray();
1135  OSL_ENSURE( aValues.getLength() == aNames.getLength(), "GetProperties failed" );
1136  if (aValues.getLength() != aNames.getLength() || !pValues->hasValue())
1137  return;
1138 
1139  sal_Int32 nVal = 0;
1140  *pValues >>= nVal;
1141 
1142  if (nVal < m_nLRU_InitSize)
1143  {
1144  std::shared_ptr<SwOLELRUCache> tmp(g_pOLELRU_Cache); // prevent delete this
1145  // size of cache has been changed
1146  sal_Int32 nCount = m_OleObjects.size();
1147  sal_Int32 nPos = nCount;
1148 
1149  // try to remove the last entries until new maximum size is reached
1150  while( nCount > nVal )
1151  {
1152  SwOLEObj *const pObj = m_OleObjects[ --nPos ];
1153  if ( pObj->UnloadObject() )
1154  nCount--;
1155  if ( !nPos )
1156  break;
1157  }
1158  }
1159 
1160  m_nLRU_InitSize = nVal;
1161 }
1162 
1164 {
1165  SwOLEObj* pObj = &rObj;
1166  OleObjects_t::iterator it =
1167  std::find(m_OleObjects.begin(), m_OleObjects.end(), pObj);
1168  if (it != m_OleObjects.end() && it != m_OleObjects.begin())
1169  {
1170  // object in cache but is currently not the first in cache
1171  m_OleObjects.erase(it);
1172  it = m_OleObjects.end();
1173  }
1174  if (it == m_OleObjects.end())
1175  {
1176  std::shared_ptr<SwOLELRUCache> tmp(g_pOLELRU_Cache); // prevent delete this
1177  // try to remove objects if necessary
1178  sal_Int32 nCount = m_OleObjects.size();
1179  sal_Int32 nPos = nCount-1;
1180  while (nPos >= 0 && nCount >= m_nLRU_InitSize)
1181  {
1182  pObj = m_OleObjects[ nPos-- ];
1183  if ( pObj->UnloadObject() )
1184  nCount--;
1185  }
1186  m_OleObjects.push_front(&rObj);
1187  }
1188 }
1189 
1191 {
1192  OleObjects_t::iterator const it =
1193  std::find(m_OleObjects.begin(), m_OleObjects.end(), &rObj);
1194  if (it != m_OleObjects.end())
1195  {
1196  m_OleObjects.erase(it);
1197  }
1198  if (m_OleObjects.empty())
1199  {
1200  if (g_pOLELRU_Cache.use_count() == 1) // test that we're not in InsertObj()
1201  {
1202  g_pOLELRU_Cache.reset();
1203  }
1204  }
1205 }
1206 
1207 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetAspect(sal_Int64 nAspect)
Definition: ndole.hxx:133
bool UnloadObject()
Definition: ndole.cxx:958
virtual void SAL_CALL stateChanged(const lang::EventObject &aEvent,::sal_Int32 nOldState,::sal_Int32 nNewState) override
Definition: ndole.cxx:114
SwSectionNode * FindSectionNode()
Search section node, in which it is.
Definition: ndsect.cxx:960
void SetDescription(const OUString &rDescription)
Definition: ndnotxt.cxx:272
css::uno::Reference< css::embed::XEmbeddedObject > CreateEmbeddedObject(const css::uno::Sequence< sal_Int8 > &, OUString &, OUString const *pBaseURL=nullptr)
Base class of the Writer layout elements.
Definition: frame.hxx:295
const css::uno::Reference< css::embed::XEmbeddedObject > & GetObject() const
const char *const aClassID
sal_uLong GetIndex() const
Definition: node.hxx:282
SwOLENode(const SwNodeIndex &rWhere, const svt::EmbeddedObjectRef &, SwGrfFormatColl *pGrfColl, SwAttrSet const *pAutoAttr)
Definition: ndole.cxx:211
sal_Int64 GetAspect() const
Definition: ndole.hxx:132
SwOLEObj maOLEObj
Definition: ndole.hxx:86
friend DeflateThread
Definition: ndole.cxx:668
bool HasAutomaticContour() const
Definition: ndnotxt.hxx:78
const SwOLEObj & GetOLEObj() const
Definition: ndole.hxx:110
void Notify(SwFlyFrame *pFly, SwPageFrame *pOld, const SwRect &rOld, const SwRect *pOldRect=nullptr)
Notify the background based on the difference between old and new rectangle.
Definition: frmtool.cxx:2924
virtual bool get(DocumentSettingId id) const override
Return the specified document setting.
OUString msChartTableName
with chart objects: name of referenced table.
Definition: ndole.hxx:87
SwDocShell * GetDocShell()
Definition: doc.hxx:1340
void waitUntilDone(const std::shared_ptr< ThreadTaskTag > &, bool bJoinAll=true)
Point LogicToLogic(const Point &rPtSource, const MapMode *pMapModeSource, const MapMode *pMapModeDest) const
SwNodeIndex nNode
Definition: pam.hxx:37
OUString GetDescription()
Definition: ndole.cxx:1015
sal_uIntPtr sal_uLong
const OUString & GetChartTableName() const
Definition: ndole.hxx:148
std::unique_ptr< DeflateData > m_pDeflateData
Definition: ndole.hxx:49
void SetTitle(const OUString &rTitle)
Definition: ndnotxt.cxx:247
#define OBJECT_CLIENT_OLE
css::uno::Reference< css::embed::XEmbeddedObject > const & GetOleRef()
Definition: ndole.cxx:900
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1150
rtl::Reference< SwOLEListener_Impl > m_xListener
Definition: ndole.hxx:39
void RemoveObj(SwOLEObj &rObj)
Definition: ndole.cxx:1190
Definition: doc.hxx:185
IDocumentLinksAdministration const & getIDocumentLinksAdministration() const
Definition: doc.cxx:292
SwOLEObj * mpObj
Definition: ndole.cxx:92
bool HasEmbeddedObject(const OUString &)
SwNode & GetNode() const
Definition: ndindex.hxx:118
void SetTmpDocShell(SfxObjectShellLock rLock)
in case during copying of embedded object a new shell is created, it should be set here and cleaned l...
Definition: doc.hxx:1346
void Load()
Definition: ndole.cxx:1130
css::uno::Reference< css::frame::XModel > GetModel() const
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
virtual OUString getDocumentBaseURL() const override
std::atomic< bool > mbKilled
Definition: ndole.cxx:678
void DisconnectFileLink_Impl()
Definition: ndole.cxx:581
static sal_uInt16 IsChart(const SvGlobalName &rName)
virtual ~SwOLENode() override
Definition: ndole.cxx:236
const tools::PolyPolygon * HasContour() const
Definition: ndnotxt.cxx:107
const SwSection & GetSection() const
Definition: node.hxx:541
css::uno::Reference< css::embed::XStorage > const & GetStorage()
bool IsChart() const
Definition: ndole.cxx:617
bool UpdateLinkURL_Impl()
Definition: ndole.cxx:507
drawinglayer::primitive2d::Primitive2DContainer const & tryToGetChartContentAsPrimitive2DSequence(basegfx::B2DRange &rRange, bool bSynchron)
Definition: ndole.cxx:1031
void InsertObj(SwOLEObj &rObj)
Definition: ndole.cxx:1163
static drawinglayer::primitive2d::Primitive2DContainer tryToGetChartContentAsPrimitive2DSequence(const css::uno::Reference< css::frame::XModel > &rXModel, basegfx::B2DRange &rRange)
~SwOLEObj() COVERITY_NOEXCEPT_FALSE
Definition: ndole.cxx:784
const SwRect & getFrameArea() const
Definition: frame.hxx:175
OUTDEV_WINDOW
svt::EmbeddedObjectRef & GetObject()
Definition: ndole.cxx:952
drawinglayer::primitive2d::Primitive2DContainer m_aPrimitive2DSequence
Definition: ndole.hxx:47
const Graphic * GetGraphic() const
sal_Int32 m_nLRU_InitSize
Definition: ndole.cxx:72
bool EnableNotification(const css::uno::Sequence< OUString > &rNames, bool bEnableInternalNotification=false)
SotClipboardFormatId
const SwOLENode * m_pOLENode
Definition: ndole.hxx:38
static sal_uInt16 IsMath(const SvGlobalName &rName)
virtual void Notify(const uno::Sequence< OUString > &aPropertyNames) override
Definition: ndole.cxx:1121
uno::Reference< frame::XModel > maXModel
Definition: ndole.cxx:671
const OUString & GetCurrentPersistName() const
Definition: ndole.hxx:69
virtual SwContentNode * MakeCopy(SwDoc *, const SwNodeIndex &, bool bNewFrames) const override
Is in ndcopy.cxx.
Definition: ndole.cxx:413
basegfx::B2DRange maRange
Definition: ndole.cxx:673
static ThreadPool & getSharedOptimalPool()
SwOLENode * MakeOLENode(const SwNodeIndex &rWhere, const svt::EmbeddedObjectRef &, SwGrfFormatColl *pColl)
in ndole.cxx
Definition: ndole.cxx:364
bool isEmpty() const
const SwAttrSet * GetpSwAttrSet() const
Definition: node.hxx:443
void SetOLEPrtNotifyPending(bool bSet=true)
Definition: doc.hxx:1665
Style of a layout element.
Definition: frmfmt.hxx:57
void AssignToContainer(comphelper::EmbeddedObjectContainer *pContainer, const OUString &rPersistName)
Holder for local data for a parallel-executed task to load a chart model.
Definition: ndole.cxx:665
SwNodeType
Definition: ndtyp.hxx:28
OUString m_aName
Definition: ndole.hxx:44
comphelper::EmbeddedObjectContainer * GetContainer() const
void waitFinished()
Definition: ndole.cxx:707
drawinglayer::primitive2d::Primitive2DContainer maPrimitive2DSequence
Definition: ndole.cxx:672
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:81
void pushTask(std::unique_ptr< ThreadTask > pTask)
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:131
void Remove(SvBaseLink const *pLink)
const SwPosition * GetContentAnchor() const
Definition: fmtanchr.hxx:67
void InsertFileLink(sfx2::SvBaseLink &, sal_uInt16 nFileType, const OUString &rFileNm, const OUString *pFilterNm=nullptr, const OUString *pRange=nullptr)
#define SO3_DUMMY_CLASSID
OUString maLinkURL
Definition: ndole.hxx:92
void SetSize(const Size &rSize)
void Assign(const css::uno::Reference< css::embed::XEmbeddedObject > &xObj, sal_Int64 nAspect)
const Graphic * GetGraphic()
Definition: ndole.cxx:241
FlyAnchors.
Definition: fmtanchr.hxx:34
SwDoc * GetDoc()
Definition: node.hxx:702
static bool isTaskTagDone(const std::shared_ptr< ThreadTaskTag > &)
css::uno::Sequence< css::uno::Any > GetProperties(const css::uno::Sequence< OUString > &rNames)
bool isFinished() const
Definition: ndole.cxx:702
#define SET_CURR_SHELL(shell)
Definition: swtypes.hxx:101
Marks a node in the document model.
Definition: ndindex.hxx:31
OUString GetStyleString()
Definition: ndole.cxx:887
SwNodes & GetNodes()
Node is in which nodes-array/doc?
Definition: node.hxx:693
SwEmbedObjectLink * mpObjectLink
Definition: ndole.hxx:91
ring_container GetRingContainer()
Definition: ring.hxx:240
OUString SwResId(const char *pId)
Definition: swmodule.cxx:191
std::shared_ptr< comphelper::ThreadTaskTag > mpTag
Definition: ndole.cxx:680
void SSize(const Size &rNew)
Definition: swrect.hxx:176
virtual Size GetTwipSize() const override
Definition: ndole.cxx:407
DeflateData(const uno::Reference< frame::XModel > &rXModel)
Definition: ndole.cxx:683
virtual bool SavePersistentData() override
OLE object is transported into UNDO area.
Definition: ndole.cxx:293
virtual void SAL_CALL changingState(const lang::EventObject &aEvent,::sal_Int32 nOldState,::sal_Int32 nNewState) override
Definition: ndole.cxx:110
void SetNode(SwOLENode *pNode)
Definition: ndole.cxx:849
bool IsOLEObjectDeleted() const
Definition: ndole.cxx:488
SwDoc * GetDoc()
Which Doc contains the nodes-array?
Definition: ndarr.hxx:305
static uno::Sequence< OUString > GetPropertyNames()
Definition: ndole.cxx:1115
const IDocumentLayoutAccess & getIDocumentLayoutAccess() const
Provides access to the document layout interface.
Definition: node.cxx:2044
css::uno::Reference< css::embed::XEmbeddedObject > GetEmbeddedObject(const OUString &, OUString const *pBaseURL=nullptr)
bool IsOleRef() const
To avoid unnecessary loading of object.
Definition: ndole.cxx:895
OleObjects_t m_OleObjects
Definition: ndole.cxx:71
void SetChartTableName(const OUString &rNm)
Definition: ndole.hxx:149
static bool GetDisplayNames(const SvBaseLink *, OUString *pType, OUString *pFile=nullptr, OUString *pLink=nullptr, OUString *pFilter=nullptr)
void RemoveEmbeddedObject(const OUString &rName, bool bKeepToTempStorage=true)
static std::shared_ptr< SwOLELRUCache > g_pOLELRU_Cache
Definition: ndole.cxx:88
comphelper::EmbeddedObjectContainer & GetEmbeddedObjectContainer() const
void SetViewAspect(sal_Int64 nAspect)
SwOLEListener_Impl(SwOLEObj *pObj)
Definition: ndole.cxx:101
OUString GetTitle() const
Definition: ndnotxt.cxx:260
void CheckFileLink_Impl()
Definition: ndole.cxx:590
virtual void SAL_CALL disposing(const lang::EventObject &aEvent) override
Definition: ndole.cxx:140
virtual bool RestorePersistentData() override
Loading a OLE object that has been moved to the Undo Area.
Definition: ndole.cxx:251
void BreakFileLink_Impl()
Definition: ndole.cxx:558
void SetChanged()
Definition: ndole.cxx:633
virtual void ImplCommit() override
Definition: ndole.cxx:1126
bool DoInitNew(SfxMedium *pMedium=nullptr)
SwNodes & GetNodes()
Definition: doc.hxx:403
::sw::DocumentSettingManager & GetDocumentSettingManager()
Definition: doc.cxx:218
SfxObjectShell * GetPersist() const
Definition: docnew.cxx:634
Size GetSize(MapMode const *pTargetMapMode) const
svt::EmbeddedObjectRef m_xOLERef
Either ref or name are known.
Definition: ndole.hxx:43
bool IsChart() const
bool InsertEmbeddedObject(const css::uno::Reference< css::embed::XEmbeddedObject > &, OUString &)
SwOLEObj(const SwOLEObj &rObj)=delete
void SetOLESizeInvalid(bool b)
Definition: ndole.hxx:130
virtual sfx2::LinkManager & GetLinkManager()=0
const basegfx::B2DRange & getRange() const
Definition: ndole.cxx:697
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)
bool IsInDtor() const
Definition: doc.hxx:398
const drawinglayer::primitive2d::Primitive2DContainer & getSequence() const
Definition: ndole.cxx:692
static bool TryRunningState(const css::uno::Reference< css::embed::XEmbeddedObject > &)
basegfx::B2DRange m_aRange
Definition: ndole.hxx:48
SectionType GetType() const
Definition: section.hxx:171
sal_Int64 GetViewAspect() const
void resetBufferedData()
Definition: ndole.cxx:1094
const SwGrfFormatColl * GetDfltGrfFormatColl() const
Definition: doc.hxx:799
SwNode & GetEndOfExtras() const
This is the last EndNode of a special section.
Definition: ndarr.hxx:162
sal_Int32 nPos
void Lock(bool bLock=true)
std::deque< SwOLEObj * > OleObjects_t
Definition: ndole.cxx:70
SwFrameFormat * GetFlyFormat() const
If node is in a fly return the respective format.
Definition: node.cxx:710
SfxLinkUpdateMode
void SetContour(const tools::PolyPolygon *pPoly, bool bAutomatic=false)
Definition: ndnotxt.cxx:87
void GetNewReplacement()
Definition: ndole.cxx:501
Base class of the Writer document model elements.
Definition: node.hxx:79
OUString GetDescription() const
Remove OLE-object from "memory".
Definition: ndole.hxx:137
bool IsInGlobalDocSection() const
Definition: ndole.cxx:454