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