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(sal_Int32(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  SwNodeOffset 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().Overlaps(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  mbKilled(false),
701  mpTag( comphelper::ThreadPool::createThreadTaskTag() )
702  {
703  }
704 
706  {
707  return maPrimitive2DSequence;
708  }
709 
711  {
712  return maRange;
713  }
714 
715  bool isFinished() const
716  {
718  }
719 
721  {
722  // need to wait until the load in progress is finished.
723  // WorkerThreads need the SolarMutex to be able to continue
724  // and finish the running import.
725  SolarMutexReleaser aReleaser;
727  }
728 };
729 
730 namespace {
731 
733 class DeflateThread : public comphelper::ThreadTask
734 {
735  // the data to work on
736  DeflateData& mrDeflateData;
737 
738 public:
739  explicit DeflateThread(DeflateData& rDeflateData)
740  : comphelper::ThreadTask(rDeflateData.mpTag), mrDeflateData(rDeflateData)
741  {
742  }
743 
744 private:
745  virtual void doWork() override
746  {
747  try
748  {
749  // load the chart data and get the primitives
751  mrDeflateData.maXModel,
752  mrDeflateData.maRange);
753 
754  // model no longer needed and done
755  mrDeflateData.maXModel.clear();
756  }
757  catch (const uno::Exception&)
758  {
759  }
760 
761  if(mrDeflateData.mbKilled)
762  {
763  // need to cleanup myself - data will not be used
764  delete &mrDeflateData;
765  }
766  }
767 };
768 
769 }
770 
772 
774  m_pOLENode( nullptr ),
775  m_xOLERef( xObj )
776 {
777  m_xOLERef.Lock();
778  if ( xObj.is() )
779  {
780  m_xListener = new SwOLEListener_Impl( this );
781  xObj->addStateChangeListener( m_xListener );
782  }
783 }
784 
785 SwOLEObj::SwOLEObj( const OUString &rString, sal_Int64 nAspect ) :
786  m_pOLENode( nullptr ),
787  m_aName( rString )
788 {
789  m_xOLERef.Lock();
790  m_xOLERef.SetViewAspect( nAspect );
791 }
792 
793 SwOLEObj::~SwOLEObj() COVERITY_NOEXCEPT_FALSE
794 {
795  if(m_pDeflateData)
796  {
797  // set flag so that the worker thread will delete m_pDeflateData
798  // when finished and forget about it
799  m_pDeflateData->mbKilled = true;
800  m_pDeflateData = nullptr;
801  }
802 
803  if( m_xListener )
804  {
805  if ( m_xOLERef.is() )
806  m_xOLERef->removeStateChangeListener( m_xListener );
807  m_xListener->dispose();
808  m_xListener.clear();
809  }
810 
811  if( m_pOLENode && !m_pOLENode->GetDoc().IsInDtor() )
812  {
813  // if the model is not currently in destruction it means that this object should be removed from the model
815 
816 #if OSL_DEBUG_LEVEL > 0
818  OSL_ENSURE( p, "No document!" );
819  if( p )
820  {
822  OSL_ENSURE( !pCnt || &rCnt == pCnt, "The helper is assigned to unexpected container!" );
823  }
824 #endif
825 
826  if ( pCnt && pCnt->HasEmbeddedObject( m_aName ) )
827  {
828  uno::Reference < container::XChild > xChild( m_xOLERef.GetObject(), uno::UNO_QUERY );
829  if ( xChild.is() )
830  xChild->setParent( nullptr );
831 
832  // not already removed by deleting the object
833  m_xOLERef.AssignToContainer( nullptr, m_aName );
834 
835  // unlock object so that object can be closed in RemoveEmbeddedObject
836  // successful closing of the object will automatically clear the reference then
837  m_xOLERef.Lock(false);
838 
839  // Always remove object from container it is connected to
840  try
841  {
842  // remove object from container but don't close it
843  pCnt->RemoveEmbeddedObject( m_aName );
844  }
845  catch ( uno::Exception& )
846  {
847  }
848  }
849 
850  }
851 
852  if ( m_xOLERef.is() )
853  // in case the object wasn't closed: release it
854  // in case the object was not in the container: it's still locked, try to close
855  m_xOLERef.Clear();
856 }
857 
859 {
860  m_pOLENode = pNode;
861  if ( !m_aName.isEmpty() )
862  return;
863 
864  SwDoc& rDoc = pNode->GetDoc();
865 
866  // If there's already a SvPersist instance, we use it
867  SfxObjectShell* p = rDoc.GetPersist();
868  if( !p )
869  {
870  // TODO/LATER: Isn't an EmbeddedObjectContainer sufficient here?
871  // What happens to the document?
872  OSL_ENSURE( false, "Why are we creating a DocShell here??" );
873  p = new SwDocShell( rDoc, SfxObjectCreateMode::INTERNAL );
874  p->DoInitNew();
875  }
876 
877  OUString aObjName;
878  uno::Reference < container::XChild > xChild( m_xOLERef.GetObject(), uno::UNO_QUERY );
879  if ( xChild.is() && xChild->getParent() != p->GetModel() )
880  // it is possible that the parent was set already
881  xChild->setParent( p->GetModel() );
883  {
884  OSL_FAIL( "InsertObject failed" );
885  if ( xChild.is() )
886  xChild->setParent( nullptr );
887  }
888  else
890 
891  const_cast<SwOLENode*>(m_pOLENode)->CheckFileLink_Impl(); // for this notification nonconst access is required
892 
893  m_aName = aObjName;
894 }
895 
897 {
898  OUString strStyle;
899  if (m_xOLERef.is() && m_xOLERef.IsChart())
900  strStyle = m_xOLERef.GetChartType();
901  return strStyle;
902 }
903 
904 bool SwOLEObj::IsOleRef() const
905 {
906  return m_xOLERef.is();
907 }
908 
909 uno::Reference < embed::XEmbeddedObject > const & SwOLEObj::GetOleRef()
910 {
911  if( !m_xOLERef.is() )
912  {
914  assert(p && "No SvPersist present");
915 
916  OUString sDocumentBaseURL = p->getDocumentBaseURL();
917  uno::Reference < embed::XEmbeddedObject > xObj = p->GetEmbeddedObjectContainer().GetEmbeddedObject(m_aName, &sDocumentBaseURL);
918  OSL_ENSURE( !m_xOLERef.is(), "Calling GetOleRef() recursively is not permitted" );
919 
920  if ( !xObj.is() )
921  {
922  // We could not load this part (probably broken)
923  tools::Rectangle aArea;
924  SwFrame *pFrame = m_pOLENode->getLayoutFrame(nullptr);
925  if ( pFrame )
926  {
927  Size aSz( pFrame->getFrameArea().SSize() );
928  const MapMode aSrc ( MapUnit::MapTwip );
929  const MapMode aDest( MapUnit::Map100thMM );
930  aSz = OutputDevice::LogicToLogic( aSz, aSrc, aDest );
931  aArea.SetSize( aSz );
932  }
933  else
934  aArea.SetSize( Size( 5000, 5000 ) );
935  // TODO/LATER: set replacement graphic for dead object
936  // It looks as if it should work even without the object, because the replace will be generated automatically
937  OUString aTmpName;
938  xObj = p->GetEmbeddedObjectContainer().CreateEmbeddedObject( SvGlobalName( SO3_DUMMY_CLASSID ).GetByteSequence(), aTmpName );
939  }
940  if (xObj.is())
941  {
944  m_xListener = new SwOLEListener_Impl( this );
945  xObj->addStateChangeListener( m_xListener );
946  }
947 
948  const_cast<SwOLENode*>(m_pOLENode)->CheckFileLink_Impl(); // for this notification nonconst access is required
949  }
950  else if ( m_xOLERef->getCurrentState() == embed::EmbedStates::RUNNING )
951  {
952  // move object to first position in cache
953  if (!g_pOLELRU_Cache)
954  g_pOLELRU_Cache = std::make_shared<SwOLELRUCache>();
955  g_pOLELRU_Cache->InsertObj( *this );
956  }
957 
958  return m_xOLERef.GetObject();
959 }
960 
962 {
963  GetOleRef();
964  return m_xOLERef;
965 }
966 
968 {
969  bool bRet = true;
970  if ( m_pOLENode )
971  {
972  const SwDoc& rDoc = m_pOLENode->GetDoc();
974  }
975 
976  return bRet;
977 }
978 
980  : m_rManager(const_cast<SwDoc&>(rDoc).GetDocumentSettingManager())
981  , m_bOrigPurgeOle(m_rManager.get(DocumentSettingId::PURGE_OLE))
982 {
984 }
985 
986 PurgeGuard::~PurgeGuard() COVERITY_NOEXCEPT_FALSE
987 {
989 }
990 
991 bool SwOLEObj::UnloadObject( uno::Reference< embed::XEmbeddedObject > const & xObj, const SwDoc* pDoc, sal_Int64 nAspect )
992 {
993  if ( !pDoc )
994  return false;
995 
996  bool bRet = true;
997  sal_Int32 nState = xObj.is() ? xObj->getCurrentState() : embed::EmbedStates::LOADED;
998  bool bIsActive = ( nState != embed::EmbedStates::LOADED && nState != embed::EmbedStates::RUNNING );
999  sal_Int64 nMiscStatus = xObj->getStatus( nAspect );
1000 
1001  if( nState != embed::EmbedStates::LOADED && !pDoc->IsInDtor() && !bIsActive &&
1002  embed::EmbedMisc::MS_EMBED_ALWAYSRUN != ( nMiscStatus & embed::EmbedMisc::MS_EMBED_ALWAYSRUN ) &&
1003  embed::EmbedMisc::EMBED_ACTIVATEIMMEDIATELY != ( nMiscStatus & embed::EmbedMisc::EMBED_ACTIVATEIMMEDIATELY ) )
1004  {
1005  SfxObjectShell* p = pDoc->GetPersist();
1006  if( p )
1007  {
1009  {
1010  try
1011  {
1012  uno::Reference < util::XModifiable > xMod( xObj->getComponent(), uno::UNO_QUERY );
1013  if( xMod.is() && xMod->isModified() )
1014  {
1015  uno::Reference < embed::XEmbedPersist > xPers( xObj, uno::UNO_QUERY );
1016  assert(xPers.is() && "Modified object without persistence in cache!");
1017 
1018  PurgeGuard aGuard(*pDoc);
1019  xPers->storeOwn();
1020  }
1021 
1022  // setting object to loaded state will remove it from cache
1023  xObj->changeState( embed::EmbedStates::LOADED );
1024  }
1025  catch (const uno::Exception&)
1026  {
1027  bRet = false;
1028  }
1029  }
1030  else
1031  bRet = false;
1032  }
1033  }
1034 
1035  return bRet;
1036 }
1037 
1039 {
1040  uno::Reference< embed::XEmbeddedObject > xEmbObj = GetOleRef();
1041  if ( !xEmbObj.is() )
1042  return OUString();
1043 
1044  SvGlobalName aClassID( xEmbObj->getClassID() );
1045  if ( SotExchange::IsMath( aClassID ) )
1046  return SwResId(STR_MATH_FORMULA);
1047 
1048  if ( SotExchange::IsChart( aClassID ) )
1049  return SwResId(STR_CHART);
1050 
1051  return SwResId(STR_OLE);
1052 }
1053 
1055  basegfx::B2DRange& rRange,
1056  bool bSynchron)
1057 {
1058  if(m_pDeflateData)
1059  {
1060  if(bSynchron)
1061  {
1062  // data in high quality is requested, wait until the data is available
1063  // since a WorkerThread was already started to load it
1064  m_pDeflateData->waitFinished();
1065  }
1066 
1067  if(m_pDeflateData->isFinished())
1068  {
1069  // copy the result data and cleanup
1070  m_aPrimitive2DSequence = m_pDeflateData->getSequence();
1071  m_aRange = m_pDeflateData->getRange();
1072  m_pDeflateData.reset();
1073  }
1074  }
1075 
1077  {
1078  const uno::Reference< frame::XModel > aXModel(m_xOLERef->getComponent(), uno::UNO_QUERY);
1079 
1080  if(aXModel.is())
1081  {
1082  // disabled for now, need to check deeper
1083  static bool bAsynchronousLoadingAllowed = false; // loplugin:constvars:ignore
1084 
1085  if(bSynchron ||
1086  !bAsynchronousLoadingAllowed)
1087  {
1088  // load chart synchron in this Thread
1090  aXModel,
1091  m_aRange);
1092  }
1093  else
1094  {
1095  // if not yet setup, initiate and start a WorkerThread to load the chart
1096  // and it's primitives asynchron. If it already works, returning nothing
1097  // is okay (preview will be reused)
1098  if(!m_pDeflateData)
1099  {
1100  m_pDeflateData.reset( new DeflateData(aXModel) );
1101  std::unique_ptr<DeflateThread> pNew( new DeflateThread(*m_pDeflateData) );
1103  }
1104  }
1105  }
1106  }
1107 
1108  if(!m_aPrimitive2DSequence.empty() && !m_aRange.isEmpty())
1109  {
1110  // when we have data, also copy the buffered Range data as output
1111  rRange = m_aRange;
1112  }
1113 
1114  return m_aPrimitive2DSequence;
1115 }
1116 
1118 {
1120  m_aRange.reset();
1121 
1122  if(m_pDeflateData)
1123  {
1124  // load is in progress, wait until finished and cleanup without using it
1125  m_pDeflateData->waitFinished();
1126  m_pDeflateData.reset();
1127  }
1128 }
1129 
1131 {
1132  (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwOLEObj"));
1133  (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
1134 
1135  (void)xmlTextWriterStartElement(pWriter, BAD_CAST("m_xOLERef"));
1136  (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("symbol"),
1137  BAD_CAST(typeid(*m_xOLERef.GetObject()).name()));
1138 
1139  uno::Reference<embed::XEmbeddedObject> xIP = m_xOLERef.GetObject();
1140  auto pComponent = dynamic_cast<sfx2::XmlDump*>(xIP->getComponent().get());
1141  if (pComponent)
1142  {
1143  pComponent->dumpAsXml(pWriter);
1144  }
1145 
1146  (void)xmlTextWriterEndElement(pWriter);
1147 
1148  (void)xmlTextWriterEndElement(pWriter);
1149 }
1150 
1151 SwOLELRUCache::SwOLELRUCache()
1152  : utl::ConfigItem("Office.Common/Cache")
1153  , m_nLRU_InitSize( 20 )
1154 {
1155  EnableNotification( GetPropertyNames() );
1156  Load();
1157 }
1158 
1159 uno::Sequence< OUString > SwOLELRUCache::GetPropertyNames()
1160 {
1161  Sequence< OUString > aNames { "Writer/OLE_Objects" };
1162  return aNames;
1163 }
1164 
1165 void SwOLELRUCache::Notify( const uno::Sequence< OUString>& )
1166 {
1167  Load();
1168 }
1169 
1170 void SwOLELRUCache::ImplCommit()
1171 {
1172 }
1173 
1174 void SwOLELRUCache::Load()
1175 {
1176  Sequence< OUString > aNames( GetPropertyNames() );
1177  Sequence< Any > aValues = GetProperties( aNames );
1178  const Any* pValues = aValues.getConstArray();
1179  OSL_ENSURE( aValues.getLength() == aNames.getLength(), "GetProperties failed" );
1180  if (aValues.getLength() != aNames.getLength() || !pValues->hasValue())
1181  return;
1182 
1183  sal_Int32 nVal = 0;
1184  *pValues >>= nVal;
1185 
1186  if (nVal < m_nLRU_InitSize)
1187  {
1188  std::shared_ptr<SwOLELRUCache> xKeepAlive(g_pOLELRU_Cache); // prevent delete this
1189  // size of cache has been changed
1190  sal_Int32 nCount = m_OleObjects.size();
1191  sal_Int32 nPos = nCount;
1192 
1193  // try to remove the last entries until new maximum size is reached
1194  while( nCount > nVal )
1195  {
1196  SwOLEObj *const pObj = m_OleObjects[ --nPos ];
1197  if ( pObj->UnloadObject() )
1198  nCount--;
1199  if ( !nPos )
1200  break;
1201  }
1202  }
1203 
1204  m_nLRU_InitSize = nVal;
1205 }
1206 
1207 void SwOLELRUCache::InsertObj( SwOLEObj& rObj )
1208 {
1209  SwOLEObj* pObj = &rObj;
1210  OleObjects_t::iterator it =
1211  std::find(m_OleObjects.begin(), m_OleObjects.end(), pObj);
1212  if (it != m_OleObjects.end() && it != m_OleObjects.begin())
1213  {
1214  // object in cache but is currently not the first in cache
1215  m_OleObjects.erase(it);
1216  it = m_OleObjects.end();
1217  }
1218  if (it != m_OleObjects.end())
1219  return;
1220 
1221  std::shared_ptr<SwOLELRUCache> xKeepAlive(g_pOLELRU_Cache); // prevent delete this
1222  // try to remove objects if necessary
1223  sal_Int32 nCount = m_OleObjects.size();
1224  sal_Int32 nPos = nCount-1;
1225  while (nPos >= 0 && nCount >= m_nLRU_InitSize)
1226  {
1227  pObj = m_OleObjects[ nPos-- ];
1228  if ( pObj->UnloadObject() )
1229  nCount--;
1230  }
1231  m_OleObjects.push_front(&rObj);
1232 }
1233 
1234 void SwOLELRUCache::RemoveObj( SwOLEObj& rObj )
1235 {
1236  OleObjects_t::iterator const it =
1237  std::find(m_OleObjects.begin(), m_OleObjects.end(), &rObj);
1238  if (it != m_OleObjects.end())
1239  {
1240  m_OleObjects.erase(it);
1241  }
1242  if (m_OleObjects.empty())
1243  {
1244  if (g_pOLELRU_Cache.use_count() == 1) // test that we're not in InsertObj()
1245  {
1246  g_pOLELRU_Cache.reset();
1247  }
1248  }
1249 }
1250 
1251 /* 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:967
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:315
constexpr TypedWhichId< SwFormatPageDesc > RES_PAGEDESC(93)
const css::uno::Reference< css::embed::XEmbeddedObject > & GetObject() const
const char *const aClassID
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:986
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:3210
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:38
SwDoc & GetDoc()
Which Doc contains the nodes-array?
Definition: ndarr.hxx:300
OUString GetDescription()
Definition: ndole.cxx:1038
void InsertFileLink(sfx2::SvBaseLink &, SvBaseLinkObjectType nFileType, std::u16string_view rFileNm, const OUString *pFilterNm=nullptr, const OUString *pRange=nullptr)
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:909
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:121
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:34
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:543
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
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:165
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:1054
static drawinglayer::primitive2d::Primitive2DContainer tryToGetChartContentAsPrimitive2DSequence(const css::uno::Reference< css::frame::XModel > &rXModel, basegfx::B2DRange &rRange)
~SwOLEObj() COVERITY_NOEXCEPT_FALSE
Definition: ndole.cxx:793
const SwRect & getFrameArea() const
Definition: frame.hxx:180
OUTDEV_WINDOW
svt::EmbeddedObjectRef & GetObject()
Definition: ndole.cxx:961
drawinglayer::primitive2d::Primitive2DContainer m_aPrimitive2DSequence
Definition: ndole.hxx:47
int nCount
const Graphic * GetGraphic() const
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: ndole.cxx:1130
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:1658
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:451
void SetOLEPrtNotifyPending(bool bSet=true)
Definition: doc.hxx:1686
Style of a layout element.
Definition: frmfmt.hxx:59
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:720
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:133
SwDoc & GetDoc()
Definition: node.hxx:213
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
SwNodeOffset GetIndex() const
Definition: node.hxx:292
FlyAnchors.
Definition: fmtanchr.hxx:34
static bool isTaskTagDone(const std::shared_ptr< ThreadTaskTag > &)
bool isFinished() const
Definition: ndole.cxx:715
Marks a node in the document model.
Definition: ndindex.hxx:32
OUString GetStyleString()
Definition: ndole.cxx:896
SwNodes & GetNodes()
Node is in which nodes-array/doc?
Definition: node.hxx:695
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:180
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:858
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:904
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:979
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:639
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:710
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:705
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:1117
const SwGrfFormatColl * GetDfltGrfFormatColl() const
Definition: doc.hxx:804
SwNode & GetEndOfExtras() const
This is the last EndNode of a special section.
Definition: ndarr.hxx:159
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:81
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