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 <sfx2/linkmgr.hxx>
33 #include <unotools/configitem.hxx>
34 #include <vcl/outdev.hxx>
35 #include <fmtanchr.hxx>
36 #include <frmfmt.hxx>
37 #include <doc.hxx>
38 #include <docsh.hxx>
39 #include <pam.hxx>
40 #include <section.hxx>
41 #include <cntfrm.hxx>
42 #include <ndole.hxx>
43 #include <viewsh.hxx>
47 #include <comphelper/classids.hxx>
48 #include <vcl/graph.hxx>
49 #include <sot/formats.hxx>
50 #include <vcl/svapp.hxx>
51 #include <strings.hrc>
52 #include <svx/charthelper.hxx>
54 #include <atomic>
55 #include <deque>
56 #include <libxml/xmlwriter.h>
57 
58 using namespace utl;
59 using namespace com::sun::star::uno;
60 using namespace com::sun::star;
61 
62 namespace {
63 
64 class SwOLELRUCache
65  : private utl::ConfigItem
66 {
67 private:
68  typedef std::deque<SwOLEObj *> OleObjects_t;
69  OleObjects_t m_OleObjects;
70  sal_Int32 m_nLRU_InitSize;
71  static uno::Sequence< OUString > GetPropertyNames();
72 
73  virtual void ImplCommit() override;
74 
75 public:
76  SwOLELRUCache();
77 
78  virtual void Notify( const uno::Sequence<
79  OUString>& aPropertyNames ) override;
80  void Load();
81 
82  void InsertObj( SwOLEObj& rObj );
83  void RemoveObj( SwOLEObj& rObj );
84 };
85 
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 = std::make_shared<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
258  if( !p )
259  {
260  // TODO/LATER: Isn't an 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 
291 {
292  xmlTextWriterStartElement(pWriter, BAD_CAST("SwOLENode"));
293  xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
294  xmlTextWriterWriteAttribute(pWriter, BAD_CAST("index"),
295  BAD_CAST(OString::number(GetIndex()).getStr()));
296 
297  GetOLEObj().dumpAsXml(pWriter);
298 
299  xmlTextWriterEndElement(pWriter);
300 }
301 
306 {
307  if( maOLEObj.m_xOLERef.is() )
308  {
310 
311 #if OSL_DEBUG_LEVEL > 0
313  OSL_ENSURE( p, "No document!" );
314  if( p )
315  {
317  OSL_ENSURE( !pCnt || &rCnt == pCnt, "The helper is assigned to unexpected container!" );
318  }
319 #endif
320 
321  if ( pCnt && pCnt->HasEmbeddedObject( maOLEObj.m_aName ) )
322  {
323  uno::Reference < container::XChild > xChild( maOLEObj.m_xOLERef.GetObject(), uno::UNO_QUERY );
324  if ( xChild.is() )
325  xChild->setParent( nullptr );
326 
327  /*
328  #i119941
329  When cut or move the chart, SwUndoFlyBase::DelFly will call SaveSection
330  to store the content to storage. In this step, chart filter functions
331  will be called. And chart filter will call chart core functions to create
332  the chart again. Then chart core function will call the class
333  ExplicitCategoryProvider to create data source. In this step, when SW data
334  source provider create the data source, a UnoActionRemoveContext
335  will mess with the layout and create a new SwFlyFrame.
336  But later in SwUndoFlyBase::DelFly, it will clear anchor related attributes
337  of SwFlyFrame. Then finally null pointer occur.
338  Resolution:
339  In pCnt->RemoveEmbeddedObject in SaveSection process of table chart,
340  only remove the object from the object container, without removing it's
341  storage and graphic stream. The chart already removed from formatter.
342  */
343  bool bKeepObjectToTempStorage = true;
344  uno::Reference < embed::XEmbeddedObject > xIP = GetOLEObj().GetOleRef();
345  if (IsChart() && !msChartTableName.isEmpty()
347  {
348  uno::Reference< chart2::XChartDocument > xChart( xIP->getComponent(), UNO_QUERY );
349  if (xChart.is() && !xChart->hasInternalDataProvider())
350  {
351  bKeepObjectToTempStorage = false;
352  }
353  }
354 
355  pCnt->RemoveEmbeddedObject( maOLEObj.m_aName, bKeepObjectToTempStorage );
356 
357  // TODO/LATER: aOLEObj.aName has no meaning here, since the undo container contains the object
358  // by different name, in future it might makes sense that the name is transported here.
360  try
361  {
362  // "unload" object
363  maOLEObj.m_xOLERef->changeState( embed::EmbedStates::LOADED );
364  }
365  catch (const uno::Exception&)
366  {
367  }
368  }
369  }
370 
372 
373  return true;
374 }
375 
377  const svt::EmbeddedObjectRef& xObj,
378  SwGrfFormatColl* pGrfColl )
379 {
380  OSL_ENSURE( pGrfColl,"SwNodes::MakeOLENode: Formatpointer is 0." );
381 
382  SwOLENode *pNode =
383  new SwOLENode( rWhere, xObj, pGrfColl, nullptr );
384 
385  // set parent if XChild is supported
387  uno::Reference< container::XChild > xChild( pNode->GetOLEObj().GetObject().GetObject(), UNO_QUERY );
388  if (xChild.is())
389  {
390  SwDocShell *pDocSh = GetDoc()->GetDocShell();
391  if (pDocSh)
392  xChild->setParent( pDocSh->GetModel() );
393  }
394 
395  return pNode;
396 }
397 
399  const OUString &rName, sal_Int64 nAspect, SwGrfFormatColl* pGrfColl, SwAttrSet const * pAutoAttr )
400 {
401  OSL_ENSURE( pGrfColl,"SwNodes::MakeOLENode: Formatpointer is 0." );
402 
403  SwOLENode *pNode =
404  new SwOLENode( rWhere, rName, nAspect, pGrfColl, pAutoAttr );
405 
406  // set parent if XChild is supported
408  uno::Reference< container::XChild > xChild( pNode->GetOLEObj().GetObject().GetObject(), UNO_QUERY );
409  if (xChild.is())
410  {
411  SwDocShell *pDocSh= GetDoc()->GetDocShell();
412  if (pDocSh)
413  xChild->setParent( pDocSh->GetModel() );
414  }
415 
416  return pNode;
417 }
418 
420 {
421  MapMode aMapMode( MapUnit::MapTwip );
422  return const_cast<SwOLENode*>(this)->maOLEObj.GetObject().GetSize( &aMapMode );
423 }
424 
425 SwContentNode* SwOLENode::MakeCopy( SwDoc* pDoc, const SwNodeIndex& rIdx, bool) const
426 {
427  // If there's already a SvPersist instance, we use it
428  SfxObjectShell* pPersistShell = pDoc->GetPersist();
429  if( !pPersistShell )
430  {
431  // TODO/LATER: is EmbeddedObjectContainer not enough?
432  // the created document will be closed by pDoc ( should use SfxObjectShellLock )
433  pPersistShell = new SwDocShell( pDoc, SfxObjectCreateMode::INTERNAL );
434  pDoc->SetTmpDocShell( pPersistShell );
435  pPersistShell->DoInitNew();
436  }
437 
438  // We insert it at SvPersist level
439  // TODO/LATER: check if using the same naming scheme for all apps works here
440  OUString aNewName/*( Sw3Io::UniqueName( p->GetStorage(), "Obj" ) )*/;
441  SfxObjectShell* pSrc = GetDoc()->GetPersist();
442 
446  aNewName,
447  pSrc->getDocumentBaseURL(),
448  pPersistShell->getDocumentBaseURL());
449 
450  SwOLENode* pOLENd = pDoc->GetNodes().MakeOLENode( rIdx, aNewName, GetAspect(),
451  pDoc->GetDfltGrfFormatColl(),
452  GetpSwAttrSet() );
453 
455  pOLENd->SetTitle( GetTitle() );
456  pOLENd->SetDescription( GetDescription() );
457  pOLENd->SetContour( HasContour(), HasAutomaticContour() );
458  pOLENd->SetAspect( GetAspect() ); // the replacement image must be already copied
459 
460  pOLENd->SetOLESizeInvalid( true );
461  pDoc->SetOLEPrtNotifyPending();
462 
463  return pOLENd;
464 }
465 
467 {
468  // Find the "Body Anchor"
469  sal_uLong nEndExtraIdx = GetNodes().GetEndOfExtras().GetIndex();
470  const SwNode* pAnchorNd = this;
471  do {
472  SwFrameFormat* pFlyFormat = pAnchorNd->GetFlyFormat();
473  if( !pFlyFormat )
474  return false;
475 
476  const SwFormatAnchor& rAnchor = pFlyFormat->GetAnchor();
477  if( !rAnchor.GetContentAnchor() )
478  return false;
479 
480  pAnchorNd = &rAnchor.GetContentAnchor()->nNode.GetNode();
481  } while( pAnchorNd->GetIndex() < nEndExtraIdx );
482 
483  const SwSectionNode* pSectNd = pAnchorNd->FindSectionNode();
484  if( !pSectNd )
485  return false;
486 
487  while( pSectNd )
488  {
489  pAnchorNd = pSectNd;
490  pSectNd = pAnchorNd->StartOfSectionNode()->FindSectionNode();
491  }
492 
493  // pAnchorNd contains the most recently found Section Node, which
494  // now must fulfill the prerequisites for the GlobalDoc
495  pSectNd = static_cast<const SwSectionNode*>(pAnchorNd);
496  return SectionType::FileLink == pSectNd->GetSection().GetType() &&
497  pSectNd->GetIndex() > nEndExtraIdx;
498 }
499 
501 {
502  if( maOLEObj.m_xOLERef.is() )
503  {
505  if( p ) // Must be there
506  {
508  }
509  }
510  return false;
511 }
512 
514 {
515  if ( maOLEObj.m_xOLERef.is() )
517 }
518 
520 {
521  bool bResult = false;
522 
523  if ( mpObjectLink )
524  {
525  OUString aNewLinkURL;
526  sfx2::LinkManager::GetDisplayNames( mpObjectLink, nullptr, &aNewLinkURL );
527  if ( !aNewLinkURL.equalsIgnoreAsciiCase( maLinkURL ) )
528  {
529  if ( !maOLEObj.m_xOLERef.is() )
531 
532  uno::Reference< embed::XEmbeddedObject > xObj = maOLEObj.m_xOLERef.GetObject();
533  uno::Reference< embed::XCommonEmbedPersist > xPersObj( xObj, uno::UNO_QUERY );
534  OSL_ENSURE( xPersObj.is(), "The object must exist!" );
535  if ( xPersObj.is() )
536  {
537  try
538  {
539  sal_Int32 nCurState = xObj->getCurrentState();
540  if ( nCurState != embed::EmbedStates::LOADED )
541  xObj->changeState( embed::EmbedStates::LOADED );
542 
543  // TODO/LATER: there should be possible to get current mediadescriptor settings from the object
544  uno::Sequence< beans::PropertyValue > aArgs( 1 );
545  aArgs[0].Name = "URL";
546  aArgs[0].Value <<= aNewLinkURL;
547  xPersObj->reload( aArgs, uno::Sequence< beans::PropertyValue >() );
548 
549  maLinkURL = aNewLinkURL;
550  bResult = true;
551 
552  if ( nCurState != embed::EmbedStates::LOADED )
553  xObj->changeState( nCurState );
554  }
555  catch (const uno::Exception&)
556  {
557  }
558  }
559 
560  if ( !bResult )
561  {
562  // TODO/LATER: return the old name to the link manager, is it possible?
563  }
564  }
565  }
566 
567  return bResult;
568 }
569 
571 {
572  SfxObjectShell* pPers = GetDoc()->GetPersist();
573 
574  if ( pPers )
575  {
576  uno::Reference< embed::XStorage > xStorage = pPers->GetStorage();
577  if ( xStorage.is() )
578  {
579  try
580  {
581  uno::Reference< embed::XLinkageSupport > xLinkSupport( maOLEObj.GetOleRef(), uno::UNO_QUERY_THROW );
582  xLinkSupport->breakLink( xStorage, maOLEObj.GetCurrentPersistName() );
584  maLinkURL.clear();
585  }
586  catch( uno::Exception& )
587  {
588  }
589  }
590  }
591 }
592 
594 {
595  if ( mpObjectLink )
596  {
598  mpObjectLink = nullptr;
599  }
600 }
601 
603 {
604  if ( maOLEObj.m_xOLERef.GetObject().is() && !mpObjectLink )
605  {
606  try
607  {
608  uno::Reference< embed::XLinkageSupport > xLinkSupport( maOLEObj.m_xOLERef.GetObject(), uno::UNO_QUERY_THROW );
609  if ( xLinkSupport->isLink() )
610  {
611  const OUString aLinkURL = xLinkSupport->getLinkURL();
612  if ( !aLinkURL.isEmpty() )
613  {
614  // this is a file link so the model link manager should handle it
615  mpObjectLink = new SwEmbedObjectLink( this );
616  maLinkURL = aLinkURL;
619  }
620  }
621  }
622  catch( uno::Exception& )
623  {
624  }
625  }
626 }
627 
628 // #i99665#
629 bool SwOLENode::IsChart() const
630 {
631  bool bIsChart( false );
632 
633  const uno::Reference< embed::XEmbeddedObject > xEmbObj =
634  const_cast<SwOLEObj&>(GetOLEObj()).GetOleRef();
635  if ( xEmbObj.is() )
636  {
637  SvGlobalName aClassID( xEmbObj->getClassID() );
638  bIsChart = SotExchange::IsChart( aClassID );
639  }
640 
641  return bIsChart;
642 }
643 
644 // react on visual change (invalidate)
646 {
647  SwFrame* pFrame(getLayoutFrame(nullptr));
648 
649  if(nullptr == pFrame)
650  {
651  return;
652  }
653 
654  const SwRect aFrameArea(pFrame->getFrameArea());
655  SwViewShell* pVSh(GetDoc()->getIDocumentLayoutAccess().GetCurrentViewShell());
656 
657  if(nullptr == pVSh)
658  {
659  return;
660  }
661 
662  for(SwViewShell& rShell : pVSh->GetRingContainer())
663  {
664  SET_CURR_SHELL(&rShell);
665 
666  if(rShell.VisArea().IsOver(aFrameArea) && OUTDEV_WINDOW == rShell.GetOut()->GetOutDevType())
667  {
668  // invalidate instead of painting
669  rShell.GetWin()->Invalidate(aFrameArea.SVRect());
670  }
671  }
672 }
673 
674 namespace { class DeflateThread; }
675 
678 {
679 private:
681  friend class SwOLEObj;
682 
683  uno::Reference< frame::XModel > maXModel;
686 
687  // evtl.set from the SwOLEObj destructor when a WorkerThread is still active
688  // since it is not possible to kill it - let it terminate and delete the
689  // data working on itself
690  std::atomic< bool> mbKilled;
691 
692  std::shared_ptr<comphelper::ThreadTaskTag> mpTag;
693 
694 public:
695  explicit DeflateData(const uno::Reference< frame::XModel >& rXModel)
696  : maXModel(rXModel),
697  maPrimitive2DSequence(),
698  maRange(),
699  mbKilled(false),
700  mpTag( comphelper::ThreadPool::createThreadTaskTag() )
701  {
702  }
703 
705  {
706  return maPrimitive2DSequence;
707  }
708 
710  {
711  return maRange;
712  }
713 
714  bool isFinished() const
715  {
717  }
718 
720  {
721  // need to wait until the load in progress is finished.
722  // WorkerThreads need the SolarMutex to be able to continue
723  // and finish the running import.
724  SolarMutexReleaser aReleaser;
726  }
727 };
728 
729 namespace {
730 
732 class DeflateThread : public comphelper::ThreadTask
733 {
734  // the data to work on
735  DeflateData& mrDeflateData;
736 
737 public:
738  explicit DeflateThread(DeflateData& rDeflateData)
739  : comphelper::ThreadTask(rDeflateData.mpTag), mrDeflateData(rDeflateData)
740  {
741  }
742 
743 private:
744  virtual void doWork() override
745  {
746  try
747  {
748  // load the chart data and get the primitives
750  mrDeflateData.maXModel,
751  mrDeflateData.maRange);
752 
753  // model no longer needed and done
754  mrDeflateData.maXModel.clear();
755  }
756  catch (const uno::Exception&)
757  {
758  }
759 
760  if(mrDeflateData.mbKilled)
761  {
762  // need to cleanup myself - data will not be used
763  delete &mrDeflateData;
764  }
765  }
766 };
767 
768 }
769 
771 
773  m_pOLENode( nullptr ),
774  m_xOLERef( xObj ),
775  m_aPrimitive2DSequence(),
776  m_aRange()
777 {
778  m_xOLERef.Lock();
779  if ( xObj.is() )
780  {
781  m_xListener = new SwOLEListener_Impl( this );
782  xObj->addStateChangeListener( m_xListener.get() );
783  }
784 }
785 
786 SwOLEObj::SwOLEObj( const OUString &rString, sal_Int64 nAspect ) :
787  m_pOLENode( nullptr ),
788  m_aName( rString ),
789  m_aPrimitive2DSequence(),
790  m_aRange()
791 {
792  m_xOLERef.Lock();
793  m_xOLERef.SetViewAspect( nAspect );
794 }
795 
796 SwOLEObj::~SwOLEObj() COVERITY_NOEXCEPT_FALSE
797 {
798  if(m_pDeflateData)
799  {
800  // set flag so that the worker thread will delete m_pDeflateData
801  // when finished and forget about it
802  m_pDeflateData->mbKilled = true;
803  m_pDeflateData = nullptr;
804  }
805 
806  if( m_xListener )
807  {
808  if ( m_xOLERef.is() )
809  m_xOLERef->removeStateChangeListener( m_xListener.get() );
810  m_xListener->dispose();
811  m_xListener.clear();
812  }
813 
814  if( m_pOLENode && !m_pOLENode->GetDoc()->IsInDtor() )
815  {
816  // if the model is not currently in destruction it means that this object should be removed from the model
818 
819 #if OSL_DEBUG_LEVEL > 0
821  OSL_ENSURE( p, "No document!" );
822  if( p )
823  {
825  OSL_ENSURE( !pCnt || &rCnt == pCnt, "The helper is assigned to unexpected container!" );
826  }
827 #endif
828 
829  if ( pCnt && pCnt->HasEmbeddedObject( m_aName ) )
830  {
831  uno::Reference < container::XChild > xChild( m_xOLERef.GetObject(), uno::UNO_QUERY );
832  if ( xChild.is() )
833  xChild->setParent( nullptr );
834 
835  // not already removed by deleting the object
836  m_xOLERef.AssignToContainer( nullptr, m_aName );
837 
838  // unlock object so that object can be closed in RemoveEmbeddedObject
839  // successful closing of the object will automatically clear the reference then
840  m_xOLERef.Lock(false);
841 
842  // Always remove object from container it is connected to
843  try
844  {
845  // remove object from container but don't close it
846  pCnt->RemoveEmbeddedObject( m_aName );
847  }
848  catch ( uno::Exception& )
849  {
850  }
851  }
852 
853  }
854 
855  if ( m_xOLERef.is() )
856  // in case the object wasn't closed: release it
857  // in case the object was not in the container: it's still locked, try to close
858  m_xOLERef.Clear();
859 }
860 
862 {
863  m_pOLENode = pNode;
864  if ( m_aName.isEmpty() )
865  {
866  SwDoc* pDoc = pNode->GetDoc();
867 
868  // If there's already a SvPersist instance, we use it
869  SfxObjectShell* p = pDoc->GetPersist();
870  if( !p )
871  {
872  // TODO/LATER: Isn't an EmbeddedObjectContainer sufficient here?
873  // What happens to the document?
874  OSL_ENSURE( false, "Why are we creating a DocShell here??" );
875  p = new SwDocShell( pDoc, SfxObjectCreateMode::INTERNAL );
876  p->DoInitNew();
877  }
878 
879  OUString aObjName;
880  uno::Reference < container::XChild > xChild( m_xOLERef.GetObject(), uno::UNO_QUERY );
881  if ( xChild.is() && xChild->getParent() != p->GetModel() )
882  // it is possible that the parent was set already
883  xChild->setParent( p->GetModel() );
885  {
886  OSL_FAIL( "InsertObject failed" );
887  if ( xChild.is() )
888  xChild->setParent( nullptr );
889  }
890  else
892 
893  const_cast<SwOLENode*>(m_pOLENode)->CheckFileLink_Impl(); // for this notification nonconst access is required
894 
895  m_aName = aObjName;
896  }
897 }
898 
900 {
901  OUString strStyle;
902  if (m_xOLERef.is() && m_xOLERef.IsChart())
903  strStyle = m_xOLERef.GetChartType();
904  return strStyle;
905 }
906 
907 bool SwOLEObj::IsOleRef() const
908 {
909  return m_xOLERef.is();
910 }
911 
912 uno::Reference < embed::XEmbeddedObject > const & SwOLEObj::GetOleRef()
913 {
914  if( !m_xOLERef.is() )
915  {
917  assert(p && "No SvPersist present");
918 
919  OUString sDocumentBaseURL = p->getDocumentBaseURL();
920  uno::Reference < embed::XEmbeddedObject > xObj = p->GetEmbeddedObjectContainer().GetEmbeddedObject(m_aName, &sDocumentBaseURL);
921  OSL_ENSURE( !m_xOLERef.is(), "Calling GetOleRef() recursively is not permitted" );
922 
923  if ( !xObj.is() )
924  {
925  // We could not load this part (probably broken)
926  tools::Rectangle aArea;
927  SwFrame *pFrame = m_pOLENode->getLayoutFrame(nullptr);
928  if ( pFrame )
929  {
930  Size aSz( pFrame->getFrameArea().SSize() );
931  const MapMode aSrc ( MapUnit::MapTwip );
932  const MapMode aDest( MapUnit::Map100thMM );
933  aSz = OutputDevice::LogicToLogic( aSz, aSrc, aDest );
934  aArea.SetSize( aSz );
935  }
936  else
937  aArea.SetSize( Size( 5000, 5000 ) );
938  // TODO/LATER: set replacement graphic for dead object
939  // It looks as if it should work even without the object, because the replace will be generated automatically
940  OUString aTmpName;
941  xObj = p->GetEmbeddedObjectContainer().CreateEmbeddedObject( SvGlobalName( SO3_DUMMY_CLASSID ).GetByteSequence(), aTmpName );
942  }
943  if (xObj.is())
944  {
947  m_xListener = new SwOLEListener_Impl( this );
948  xObj->addStateChangeListener( m_xListener.get() );
949  }
950 
951  const_cast<SwOLENode*>(m_pOLENode)->CheckFileLink_Impl(); // for this notification nonconst access is required
952  }
953  else if ( m_xOLERef->getCurrentState() == embed::EmbedStates::RUNNING )
954  {
955  // move object to first position in cache
956  if (!g_pOLELRU_Cache)
957  g_pOLELRU_Cache = std::make_shared<SwOLELRUCache>();
958  g_pOLELRU_Cache->InsertObj( *this );
959  }
960 
961  return m_xOLERef.GetObject();
962 }
963 
965 {
966  GetOleRef();
967  return m_xOLERef;
968 }
969 
971 {
972  bool bRet = true;
973  if ( m_pOLENode )
974  {
975  const SwDoc* pDoc = m_pOLENode->GetDoc();
977  }
978 
979  return bRet;
980 }
981 
983  : m_rManager(const_cast<SwDoc&>(rDoc).GetDocumentSettingManager())
984  , m_bOrigPurgeOle(m_rManager.get(DocumentSettingId::PURGE_OLE))
985 {
987 }
988 
990 {
992 }
993 
994 bool SwOLEObj::UnloadObject( uno::Reference< embed::XEmbeddedObject > const & xObj, const SwDoc* pDoc, sal_Int64 nAspect )
995 {
996  if ( !pDoc )
997  return false;
998 
999  bool bRet = true;
1000  sal_Int32 nState = xObj.is() ? xObj->getCurrentState() : embed::EmbedStates::LOADED;
1001  bool bIsActive = ( nState != embed::EmbedStates::LOADED && nState != embed::EmbedStates::RUNNING );
1002  sal_Int64 nMiscStatus = xObj->getStatus( nAspect );
1003 
1004  if( nState != embed::EmbedStates::LOADED && !pDoc->IsInDtor() && !bIsActive &&
1005  embed::EmbedMisc::MS_EMBED_ALWAYSRUN != ( nMiscStatus & embed::EmbedMisc::MS_EMBED_ALWAYSRUN ) &&
1006  embed::EmbedMisc::EMBED_ACTIVATEIMMEDIATELY != ( nMiscStatus & embed::EmbedMisc::EMBED_ACTIVATEIMMEDIATELY ) )
1007  {
1008  SfxObjectShell* p = pDoc->GetPersist();
1009  if( p )
1010  {
1012  {
1013  try
1014  {
1015  uno::Reference < util::XModifiable > xMod( xObj->getComponent(), uno::UNO_QUERY );
1016  if( xMod.is() && xMod->isModified() )
1017  {
1018  uno::Reference < embed::XEmbedPersist > xPers( xObj, uno::UNO_QUERY );
1019  assert(xPers.is() && "Modified object without persistence in cache!");
1020 
1021  PurgeGuard aGuard(*pDoc);
1022  xPers->storeOwn();
1023  }
1024 
1025  // setting object to loaded state will remove it from cache
1026  xObj->changeState( embed::EmbedStates::LOADED );
1027  }
1028  catch (const uno::Exception&)
1029  {
1030  bRet = false;
1031  }
1032  }
1033  else
1034  bRet = false;
1035  }
1036  }
1037 
1038  return bRet;
1039 }
1040 
1042 {
1043  uno::Reference< embed::XEmbeddedObject > xEmbObj = GetOleRef();
1044  if ( !xEmbObj.is() )
1045  return OUString();
1046 
1047  SvGlobalName aClassID( xEmbObj->getClassID() );
1048  if ( SotExchange::IsMath( aClassID ) )
1049  return SwResId(STR_MATH_FORMULA);
1050 
1051  if ( SotExchange::IsChart( aClassID ) )
1052  return SwResId(STR_CHART);
1053 
1054  return SwResId(STR_OLE);
1055 }
1056 
1058  basegfx::B2DRange& rRange,
1059  bool bSynchron)
1060 {
1061  if(m_pDeflateData)
1062  {
1063  if(bSynchron)
1064  {
1065  // data in high quality is requested, wait until the data is available
1066  // since a WorkerThread was already started to load it
1067  m_pDeflateData->waitFinished();
1068  }
1069 
1070  if(m_pDeflateData->isFinished())
1071  {
1072  // copy the result data and cleanup
1073  m_aPrimitive2DSequence = m_pDeflateData->getSequence();
1074  m_aRange = m_pDeflateData->getRange();
1075  m_pDeflateData.reset();
1076  }
1077  }
1078 
1080  {
1081  const uno::Reference< frame::XModel > aXModel(m_xOLERef->getComponent(), uno::UNO_QUERY);
1082 
1083  if(aXModel.is())
1084  {
1085  // disabled for now, need to check deeper
1086  static bool bAsynchronousLoadingAllowed = false; // loplugin:constvars:ignore
1087 
1088  if(bSynchron ||
1089  !bAsynchronousLoadingAllowed)
1090  {
1091  // load chart synchron in this Thread
1093  aXModel,
1094  m_aRange);
1095  }
1096  else
1097  {
1098  // if not yet setup, initiate and start a WorkerThread to load the chart
1099  // and it's primitives asynchron. If it already works, returning nothing
1100  // is okay (preview will be reused)
1101  if(!m_pDeflateData)
1102  {
1103  m_pDeflateData.reset( new DeflateData(aXModel) );
1104  std::unique_ptr<DeflateThread> pNew( new DeflateThread(*m_pDeflateData) );
1106  }
1107  }
1108  }
1109  }
1110 
1111  if(!m_aPrimitive2DSequence.empty() && !m_aRange.isEmpty())
1112  {
1113  // when we have data, also copy the buffered Range data as output
1114  rRange = m_aRange;
1115  }
1116 
1117  return m_aPrimitive2DSequence;
1118 }
1119 
1121 {
1123  m_aRange.reset();
1124 
1125  if(m_pDeflateData)
1126  {
1127  // load is in progress, wait until finished and cleanup without using it
1128  m_pDeflateData->waitFinished();
1129  m_pDeflateData.reset();
1130  }
1131 }
1132 
1134 {
1135  xmlTextWriterStartElement(pWriter, BAD_CAST("SwOLEObj"));
1136  xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
1137 
1138  xmlTextWriterStartElement(pWriter, BAD_CAST("m_xOLERef"));
1139  xmlTextWriterWriteAttribute(pWriter, BAD_CAST("symbol"),
1140  BAD_CAST(typeid(*m_xOLERef.GetObject()).name()));
1141  xmlTextWriterEndElement(pWriter);
1142 
1143  xmlTextWriterEndElement(pWriter);
1144 }
1145 
1146 SwOLELRUCache::SwOLELRUCache()
1147  : utl::ConfigItem("Office.Common/Cache")
1148  , m_nLRU_InitSize( 20 )
1149 {
1150  EnableNotification( GetPropertyNames() );
1151  Load();
1152 }
1153 
1154 uno::Sequence< OUString > SwOLELRUCache::GetPropertyNames()
1155 {
1156  Sequence< OUString > aNames { "Writer/OLE_Objects" };
1157  return aNames;
1158 }
1159 
1160 void SwOLELRUCache::Notify( const uno::Sequence< OUString>& )
1161 {
1162  Load();
1163 }
1164 
1165 void SwOLELRUCache::ImplCommit()
1166 {
1167 }
1168 
1169 void SwOLELRUCache::Load()
1170 {
1171  Sequence< OUString > aNames( GetPropertyNames() );
1172  Sequence< Any > aValues = GetProperties( aNames );
1173  const Any* pValues = aValues.getConstArray();
1174  OSL_ENSURE( aValues.getLength() == aNames.getLength(), "GetProperties failed" );
1175  if (aValues.getLength() != aNames.getLength() || !pValues->hasValue())
1176  return;
1177 
1178  sal_Int32 nVal = 0;
1179  *pValues >>= nVal;
1180 
1181  if (nVal < m_nLRU_InitSize)
1182  {
1183  std::shared_ptr<SwOLELRUCache> xKeepAlive(g_pOLELRU_Cache); // prevent delete this
1184  // size of cache has been changed
1185  sal_Int32 nCount = m_OleObjects.size();
1186  sal_Int32 nPos = nCount;
1187 
1188  // try to remove the last entries until new maximum size is reached
1189  while( nCount > nVal )
1190  {
1191  SwOLEObj *const pObj = m_OleObjects[ --nPos ];
1192  if ( pObj->UnloadObject() )
1193  nCount--;
1194  if ( !nPos )
1195  break;
1196  }
1197  }
1198 
1199  m_nLRU_InitSize = nVal;
1200 }
1201 
1202 void SwOLELRUCache::InsertObj( SwOLEObj& rObj )
1203 {
1204  SwOLEObj* pObj = &rObj;
1205  OleObjects_t::iterator it =
1206  std::find(m_OleObjects.begin(), m_OleObjects.end(), pObj);
1207  if (it != m_OleObjects.end() && it != m_OleObjects.begin())
1208  {
1209  // object in cache but is currently not the first in cache
1210  m_OleObjects.erase(it);
1211  it = m_OleObjects.end();
1212  }
1213  if (it == m_OleObjects.end())
1214  {
1215  std::shared_ptr<SwOLELRUCache> xKeepAlive(g_pOLELRU_Cache); // prevent delete this
1216  // try to remove objects if necessary
1217  sal_Int32 nCount = m_OleObjects.size();
1218  sal_Int32 nPos = nCount-1;
1219  while (nPos >= 0 && nCount >= m_nLRU_InitSize)
1220  {
1221  pObj = m_OleObjects[ nPos-- ];
1222  if ( pObj->UnloadObject() )
1223  nCount--;
1224  }
1225  m_OleObjects.push_front(&rObj);
1226  }
1227 }
1228 
1229 void SwOLELRUCache::RemoveObj( SwOLEObj& rObj )
1230 {
1231  OleObjects_t::iterator const it =
1232  std::find(m_OleObjects.begin(), m_OleObjects.end(), &rObj);
1233  if (it != m_OleObjects.end())
1234  {
1235  m_OleObjects.erase(it);
1236  }
1237  if (m_OleObjects.empty())
1238  {
1239  if (g_pOLELRU_Cache.use_count() == 1) // test that we're not in InsertObj()
1240  {
1241  g_pOLELRU_Cache.reset();
1242  }
1243  }
1244 }
1245 
1246 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetAspect(sal_Int64 nAspect)
Definition: ndole.hxx:137
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
bool UnloadObject()
Definition: ndole.cxx:970
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:955
void SetDescription(const OUString &rDescription)
Definition: ndnotxt.cxx:269
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:297
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:136
SwOLEObj maOLEObj
Definition: ndole.hxx:88
friend DeflateThread
Definition: ndole.cxx:680
bool HasAutomaticContour() const
Definition: ndnotxt.hxx:78
const SwOLEObj & GetOLEObj() const
Definition: ndole.hxx:112
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:3022
virtual bool get(DocumentSettingId id) const override
Return the specified document setting.
OUString msChartTableName
with chart objects: name of referenced table.
Definition: ndole.hxx:89
SwDocShell * GetDocShell()
Definition: doc.hxx:1350
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:1041
sal_uIntPtr sal_uLong
const OUString & GetChartTableName() const
Definition: ndole.hxx:152
std::unique_ptr< DeflateData > m_pDeflateData
Definition: ndole.hxx:49
void SetTitle(const OUString &rTitle)
Definition: ndnotxt.cxx:244
css::uno::Reference< css::embed::XEmbeddedObject > const & GetOleRef()
Definition: ndole.cxx:912
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1148
rtl::Reference< SwOLEListener_Impl > m_xListener
Definition: ndole.hxx:39
Definition: doc.hxx:186
IDocumentLinksAdministration const & getIDocumentLinksAdministration() const
Definition: doc.cxx:259
SwOLEObj * mpObj
Definition: ndole.cxx:92
virtual void set(DocumentSettingId id, bool value) override
Set the specified document setting.
bool HasEmbeddedObject(const OUString &)
SwNode & GetNode() const
Definition: ndindex.hxx:119
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:1356
css::uno::Reference< css::frame::XModel > GetModel() const
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
virtual OUString getDocumentBaseURL() const override
std::atomic< bool > mbKilled
Definition: ndole.cxx:690
void DisconnectFileLink_Impl()
Definition: ndole.cxx:593
static sal_uInt16 IsChart(const SvGlobalName &rName)
virtual ~SwOLENode() override
Definition: ndole.cxx:236
const tools::PolyPolygon * HasContour() const
Definition: ndnotxt.cxx:104
const SwSection & GetSection() const
Definition: node.hxx:541
css::uno::Reference< css::embed::XStorage > const & GetStorage()
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const override
Dumps the node structure to the given destination (file nodes.xml in the current directory by default...
Definition: ndole.cxx:290
bool IsChart() const
Definition: ndole.cxx:629
bool UpdateLinkURL_Impl()
Definition: ndole.cxx:519
drawinglayer::primitive2d::Primitive2DContainer const & tryToGetChartContentAsPrimitive2DSequence(basegfx::B2DRange &rRange, bool bSynchron)
Definition: ndole.cxx:1057
static drawinglayer::primitive2d::Primitive2DContainer tryToGetChartContentAsPrimitive2DSequence(const css::uno::Reference< css::frame::XModel > &rXModel, basegfx::B2DRange &rRange)
~SwOLEObj() COVERITY_NOEXCEPT_FALSE
Definition: ndole.cxx:796
const SwRect & getFrameArea() const
Definition: frame.hxx:177
OUTDEV_WINDOW
svt::EmbeddedObjectRef & GetObject()
Definition: ndole.cxx:964
drawinglayer::primitive2d::Primitive2DContainer m_aPrimitive2DSequence
Definition: ndole.hxx:47
int nCount
const Graphic * GetGraphic() const
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: ndole.cxx:1133
SotClipboardFormatId
const SwOLENode * m_pOLENode
Definition: ndole.hxx:38
static sal_uInt16 IsMath(const SvGlobalName &rName)
uno::Reference< frame::XModel > maXModel
Definition: ndole.cxx:683
::sw::DocumentSettingManager & m_rManager
Definition: ndole.hxx:179
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:425
void InsertFileLink(sfx2::SvBaseLink &, SvBaseLinkObjectType nFileType, const OUString &rFileNm, const OUString *pFilterNm=nullptr, const OUString *pRange=nullptr)
basegfx::B2DRange maRange
Definition: ndole.cxx:685
static ThreadPool & getSharedOptimalPool()
SwOLENode * MakeOLENode(const SwNodeIndex &rWhere, const svt::EmbeddedObjectRef &, SwGrfFormatColl *pColl)
in ndole.cxx
Definition: ndole.cxx:376
OUString m_aName
bool isEmpty() const
struct _xmlTextWriter * xmlTextWriterPtr
const SwAttrSet * GetpSwAttrSet() const
Definition: node.hxx:443
void SetOLEPrtNotifyPending(bool bSet=true)
Definition: doc.hxx:1674
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:677
SwNodeType
Definition: ndtyp.hxx:28
OUString m_aName
Definition: ndole.hxx:44
comphelper::EmbeddedObjectContainer * GetContainer() const
void waitFinished()
Definition: ndole.cxx:719
drawinglayer::primitive2d::Primitive2DContainer maPrimitive2DSequence
Definition: ndole.cxx:684
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
#define SO3_DUMMY_CLASSID
OUString maLinkURL
Definition: ndole.hxx:94
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 > &)
bool isFinished() const
Definition: ndole.cxx:714
#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:899
SwNodes & GetNodes()
Node is in which nodes-array/doc?
Definition: node.hxx:693
SwEmbedObjectLink * mpObjectLink
Definition: ndole.hxx:93
ring_container GetRingContainer()
Definition: ring.hxx:240
OUString SwResId(const char *pId)
Definition: swmodule.cxx:178
std::shared_ptr< comphelper::ThreadTaskTag > mpTag
Definition: ndole.cxx:692
void SSize(const Size &rNew)
Definition: swrect.hxx:177
virtual Size GetTwipSize() const override
Definition: ndole.cxx:419
DeflateData(const uno::Reference< frame::XModel > &rXModel)
Definition: ndole.cxx:695
virtual bool SavePersistentData() override
OLE object is transported into UNDO area.
Definition: ndole.cxx:305
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:861
bool IsOLEObjectDeleted() const
Definition: ndole.cxx:500
SwDoc * GetDoc()
Which Doc contains the nodes-array?
Definition: ndarr.hxx:302
const IDocumentLayoutAccess & getIDocumentLayoutAccess() const
Provides access to the document layout interface.
Definition: node.cxx:2069
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:907
void SetChartTableName(const OUString &rNm)
Definition: ndole.hxx:153
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
const PropertyValue * pValues
~PurgeGuard()
Definition: ndole.cxx:989
comphelper::EmbeddedObjectContainer & GetEmbeddedObjectContainer() const
void SetViewAspect(sal_Int64 nAspect)
SwOLEListener_Impl(SwOLEObj *pObj)
Definition: ndole.cxx:101
OUString GetTitle() const
Definition: ndnotxt.cxx:257
void CheckFileLink_Impl()
Definition: ndole.cxx:602
virtual void SAL_CALL disposing(const lang::EventObject &aEvent) override
Definition: ndole.cxx:140
virtual bool RestorePersistentData() override
Loading an OLE object that has been moved to the Undo Area.
Definition: ndole.cxx:251
void BreakFileLink_Impl()
Definition: ndole.cxx:570
bool m_bOrigPurgeOle
Definition: ndole.hxx:180
PurgeGuard(const SwDoc &rDoc)
Definition: ndole.cxx:982
void SetChanged()
Definition: ndole.cxx:645
bool DoInitNew(SfxMedium *pMedium=nullptr)
SwNodes & GetNodes()
Definition: doc.hxx:405
::sw::DocumentSettingManager & GetDocumentSettingManager()
Definition: doc.cxx:185
SfxObjectShell * GetPersist() const
Definition: docnew.cxx:615
Size GetSize(MapMode const *pTargetMapMode) const
void * p
const char * name
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:134
virtual sfx2::LinkManager & GetLinkManager()=0
const basegfx::B2DRange & getRange() const
Definition: ndole.cxx:709
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:400
const drawinglayer::primitive2d::Primitive2DContainer & getSequence() const
Definition: ndole.cxx:704
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:1120
const SwGrfFormatColl * GetDfltGrfFormatColl() const
Definition: doc.hxx:803
SwNode & GetEndOfExtras() const
This is the last EndNode of a special section.
Definition: ndarr.hxx:161
void Lock(bool bLock=true)
sal_Int32 nState
SwFrameFormat * GetFlyFormat() const
If node is in a fly return the respective format.
Definition: node.cxx:709
SfxLinkUpdateMode
sal_uInt16 nPos
void SetContour(const tools::PolyPolygon *pPoly, bool bAutomatic=false)
Definition: ndnotxt.cxx:84
void GetNewReplacement()
Definition: ndole.cxx:513
Base class of the Writer document model elements.
Definition: node.hxx:79
OUString GetDescription() const
Remove OLE-object from "memory".
Definition: ndole.hxx:141
bool IsInGlobalDocSection() const
Definition: ndole.cxx:466