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>
49 #include <vcl/graph.hxx>
50 #include <sot/formats.hxx>
51 #include <vcl/svapp.hxx>
52 #include <strings.hrc>
53 #include <svx/charthelper.hxx>
55 #include <atomic>
56 #include <deque>
57 #include <libxml/xmlwriter.h>
58 #include <sfx2/xmldump.hxx>
59 #include <osl/diagnose.h>
60 #include <flyfrm.hxx>
61 
62 using namespace utl;
63 using namespace com::sun::star::uno;
64 using namespace com::sun::star;
65 
66 namespace {
67 
68 class SwOLELRUCache
69  : private utl::ConfigItem
70 {
71 private:
72  std::deque<SwOLEObj *> m_OleObjects;
73  sal_Int32 m_nLRU_InitSize;
74  static uno::Sequence< OUString > GetPropertyNames();
75 
76  virtual void ImplCommit() override;
77 
78 public:
79  SwOLELRUCache();
80 
81  virtual void Notify( const uno::Sequence<
82  OUString>& aPropertyNames ) override;
83  void Load();
84 
85  void InsertObj( SwOLEObj& rObj );
86  void RemoveObj( SwOLEObj& rObj );
87 };
88 
89 }
90 
91 static std::shared_ptr<SwOLELRUCache> g_pOLELRU_Cache;
92 
93 class SwOLEListener_Impl : public ::cppu::WeakImplHelper< embed::XStateChangeListener >
94 {
96 public:
97  explicit SwOLEListener_Impl( SwOLEObj* pObj );
98  void dispose();
99  virtual void SAL_CALL changingState( const lang::EventObject& aEvent, ::sal_Int32 nOldState, ::sal_Int32 nNewState ) override;
100  virtual void SAL_CALL stateChanged( const lang::EventObject& aEvent, ::sal_Int32 nOldState, ::sal_Int32 nNewState ) override;
101  virtual void SAL_CALL disposing( const lang::EventObject& aEvent ) override;
102 };
103 
105 : mpObj( pObj )
106 {
107  if ( mpObj->IsOleRef() && mpObj->GetOleRef()->getCurrentState() == embed::EmbedStates::RUNNING )
108  {
109  g_pOLELRU_Cache->InsertObj( *mpObj );
110  }
111 }
112 
113 void SAL_CALL SwOLEListener_Impl::changingState( const lang::EventObject&, ::sal_Int32 , ::sal_Int32 )
114 {
115 }
116 
117 void SAL_CALL SwOLEListener_Impl::stateChanged( const lang::EventObject&, ::sal_Int32 nOldState, ::sal_Int32 nNewState )
118 {
119  if ( mpObj && nOldState == embed::EmbedStates::LOADED && nNewState == embed::EmbedStates::RUNNING )
120  {
121  if (!g_pOLELRU_Cache)
122  g_pOLELRU_Cache = std::make_shared<SwOLELRUCache>();
123  g_pOLELRU_Cache->InsertObj( *mpObj );
124  }
125  else if ( mpObj && nNewState == embed::EmbedStates::LOADED && nOldState == embed::EmbedStates::RUNNING )
126  {
127  if (g_pOLELRU_Cache)
128  g_pOLELRU_Cache->RemoveObj( *mpObj );
129  }
130  else if(mpObj && nNewState == embed::EmbedStates::RUNNING)
131  {
133  }
134 }
135 
137 {
138  if (mpObj && g_pOLELRU_Cache)
139  g_pOLELRU_Cache->RemoveObj( *mpObj );
140  mpObj = nullptr;
141 }
142 
143 void SAL_CALL SwOLEListener_Impl::disposing( const lang::EventObject& )
144 {
145  if (mpObj && g_pOLELRU_Cache)
146  g_pOLELRU_Cache->RemoveObj( *mpObj );
147 }
148 
149 // TODO/LATER: actually SwEmbedObjectLink should be used here, but because different objects are used to control
150 // embedded object different link objects with the same functionality had to be implemented
151 
153 {
155 
156 public:
157  explicit SwEmbedObjectLink(SwOLENode* pNode);
158 
159  virtual void Closed() override;
160  virtual ::sfx2::SvBaseLink::UpdateResult DataChanged(
161  const OUString& rMimeType, const css::uno::Any & rValue ) override;
162 
163  void Connect() { GetRealObject(); }
164 };
165 
168  , m_pOleNode(pNode)
169 {
170  SetSynchron( false );
171 }
172 
174  const OUString&, const uno::Any& )
175 {
177  {
178  // the link URL was not changed
179  uno::Reference<embed::XEmbeddedObject> xObject = m_pOleNode->GetOLEObj().GetOleRef();
180  OSL_ENSURE( xObject.is(), "The object must exist always!" );
181  if ( xObject.is() )
182  {
183  // let the object reload the link
184  // TODO/LATER: reload call could be used for this case
185 
186  try
187  {
188  sal_Int32 nState = xObject->getCurrentState();
189  if ( nState != embed::EmbedStates::LOADED )
190  {
191  // in some cases the linked file probably is not locked so it could be changed
192  xObject->changeState( embed::EmbedStates::LOADED );
193  xObject->changeState( nState );
194  }
195  }
196  catch (const uno::Exception&)
197  {
198  }
199  }
200  }
201 
204 
205  return SUCCESS;
206 }
207 
209 {
211  SvBaseLink::Closed();
212 }
213 
215  const svt::EmbeddedObjectRef& xObj,
216  SwGrfFormatColl *pGrfColl,
217  SwAttrSet const * pAutoAttr ) :
218  SwNoTextNode( rWhere, SwNodeType::Ole, pGrfColl, pAutoAttr ),
219  maOLEObj( xObj ),
220  mbOLESizeInvalid( false ),
221  mpObjectLink( nullptr )
222 {
223  maOLEObj.SetNode( this );
224 }
225 
227  const OUString &rString,
228  sal_Int64 nAspect,
229  SwGrfFormatColl *pGrfColl,
230  SwAttrSet const * pAutoAttr ) :
231  SwNoTextNode( rWhere, SwNodeType::Ole, pGrfColl, pAutoAttr ),
232  maOLEObj( rString, nAspect ),
233  mbOLESizeInvalid( false ),
234  mpObjectLink( nullptr )
235 {
236  maOLEObj.SetNode( this );
237 }
238 
240 {
243 }
244 
246 {
247  if ( maOLEObj.GetOleRef().is() )
248  return maOLEObj.m_xOLERef.GetGraphic();
249  return nullptr;
250 }
251 
256 {
257  OSL_ENSURE( maOLEObj.GetOleRef().is(), "No object to restore!" );
258  if ( maOLEObj.m_xOLERef.is() )
259  {
260  // If a SvPersist instance already exists, we use it
262  if( !p )
263  {
264  // TODO/LATER: Isn't an EmbeddedObjectContainer sufficient here?
265  // What happens to this document?
266  OSL_ENSURE( false, "Why are we creating a DocShell here?" );
267  p = new SwDocShell( GetDoc(), SfxObjectCreateMode::INTERNAL );
268  p->DoInitNew();
269  }
270 
271  uno::Reference < container::XChild > xChild( maOLEObj.m_xOLERef.GetObject(), uno::UNO_QUERY );
272  if ( xChild.is() )
273  xChild->setParent( p->GetModel() );
274 
275  OSL_ENSURE( !maOLEObj.m_aName.isEmpty(), "No object name!" );
276  OUString aObjName;
278  {
279  if ( xChild.is() )
280  xChild->setParent( nullptr );
281  OSL_FAIL( "InsertObject failed" );
282  }
283  else
284  {
285  maOLEObj.m_aName = aObjName;
288  }
289  }
290 
291  return true;
292 }
293 
295 {
296  (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwOLENode"));
297  (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
298  (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("index"),
299  BAD_CAST(OString::number(sal_Int32(GetIndex())).getStr()));
300 
301  GetOLEObj().dumpAsXml(pWriter);
302 
303  (void)xmlTextWriterEndElement(pWriter);
304 }
305 
310 {
311  if( maOLEObj.m_xOLERef.is() )
312  {
314 
315 #if OSL_DEBUG_LEVEL > 0
317  OSL_ENSURE( p, "No document!" );
318  if( p )
319  {
321  OSL_ENSURE( !pCnt || &rCnt == pCnt, "The helper is assigned to unexpected container!" );
322  }
323 #endif
324 
325  if ( pCnt && pCnt->HasEmbeddedObject( maOLEObj.m_aName ) )
326  {
327  uno::Reference < container::XChild > xChild( maOLEObj.m_xOLERef.GetObject(), uno::UNO_QUERY );
328  if ( xChild.is() )
329  xChild->setParent( nullptr );
330 
331  /*
332  #i119941
333  When cut or move the chart, SwUndoFlyBase::DelFly will call SaveSection
334  to store the content to storage. In this step, chart filter functions
335  will be called. And chart filter will call chart core functions to create
336  the chart again. Then chart core function will call the class
337  ExplicitCategoryProvider to create data source. In this step, when SW data
338  source provider create the data source, a UnoActionRemoveContext
339  will mess with the layout and create a new SwFlyFrame.
340  But later in SwUndoFlyBase::DelFly, it will clear anchor related attributes
341  of SwFlyFrame. Then finally null pointer occur.
342  Resolution:
343  In pCnt->RemoveEmbeddedObject in SaveSection process of table chart,
344  only remove the object from the object container, without removing it's
345  storage and graphic stream. The chart already removed from formatter.
346  */
347  bool bKeepObjectToTempStorage = true;
348  uno::Reference < embed::XEmbeddedObject > xIP = GetOLEObj().GetOleRef();
349  if (IsChart() && !msChartTableName.isEmpty()
351  {
352  uno::Reference< chart2::XChartDocument > xChart( xIP->getComponent(), UNO_QUERY );
353  if (xChart.is() && !xChart->hasInternalDataProvider())
354  {
355  bKeepObjectToTempStorage = false;
356  }
357  }
358 
359  pCnt->RemoveEmbeddedObject( maOLEObj.m_aName, bKeepObjectToTempStorage );
360 
361  // TODO/LATER: aOLEObj.aName has no meaning here, since the undo container contains the object
362  // by different name, in future it might makes sense that the name is transported here.
364  try
365  {
366  // "unload" object
367  maOLEObj.m_xOLERef->changeState( embed::EmbedStates::LOADED );
368  }
369  catch (const uno::Exception&)
370  {
371  }
372  }
373  }
374 
376 
377  return true;
378 }
379 
381  const svt::EmbeddedObjectRef& xObj,
382  SwGrfFormatColl* pGrfColl )
383 {
384  OSL_ENSURE( pGrfColl,"SwNodes::MakeOLENode: Formatpointer is 0." );
385 
386  SwOLENode *pNode =
387  new SwOLENode( rWhere, xObj, pGrfColl, nullptr );
388 
389  // set parent if XChild is supported
391  uno::Reference< container::XChild > xChild( pNode->GetOLEObj().GetObject().GetObject(), UNO_QUERY );
392  if (xChild.is())
393  {
394  SwDocShell *pDocSh = GetDoc().GetDocShell();
395  if (pDocSh)
396  xChild->setParent( pDocSh->GetModel() );
397  }
398 
399  return pNode;
400 }
401 
403  const OUString &rName, sal_Int64 nAspect, SwGrfFormatColl* pGrfColl, SwAttrSet const * pAutoAttr )
404 {
405  OSL_ENSURE( pGrfColl,"SwNodes::MakeOLENode: Formatpointer is 0." );
406 
407  SwOLENode *pNode =
408  new SwOLENode( rWhere, rName, nAspect, pGrfColl, pAutoAttr );
409 
410  // set parent if XChild is supported
412  uno::Reference< container::XChild > xChild( pNode->GetOLEObj().GetObject().GetObject(), UNO_QUERY );
413  if (xChild.is())
414  {
415  SwDocShell *pDocSh = GetDoc().GetDocShell();
416  if (pDocSh)
417  xChild->setParent( pDocSh->GetModel() );
418  }
419 
420  return pNode;
421 }
422 
424 {
425  MapMode aMapMode( MapUnit::MapTwip );
426  return const_cast<SwOLENode*>(this)->maOLEObj.GetObject().GetSize( &aMapMode );
427 }
428 
429 SwContentNode* SwOLENode::MakeCopy( SwDoc& rDoc, const SwNodeIndex& rIdx, bool) const
430 {
431  // If there's already a SvPersist instance, we use it
432  SfxObjectShell* pPersistShell = rDoc.GetPersist();
433  if( !pPersistShell )
434  {
435  // TODO/LATER: is EmbeddedObjectContainer not enough?
436  // the created document will be closed by rDoc ( should use SfxObjectShellLock )
437  pPersistShell = new SwDocShell( rDoc, SfxObjectCreateMode::INTERNAL );
438  rDoc.SetTmpDocShell( pPersistShell );
439  pPersistShell->DoInitNew();
440  }
441 
442  // We insert it at SvPersist level
443  // TODO/LATER: check if using the same naming scheme for all apps works here
444  OUString aNewName/*( Sw3Io::UniqueName( p->GetStorage(), "Obj" ) )*/;
445  SfxObjectShell* pSrc = GetDoc().GetPersist();
446 
450  aNewName,
451  pSrc->getDocumentBaseURL(),
452  pPersistShell->getDocumentBaseURL());
453 
454  SwOLENode* pOLENd = rDoc.GetNodes().MakeOLENode( rIdx, aNewName, GetAspect(),
455  rDoc.GetDfltGrfFormatColl(),
456  GetpSwAttrSet() );
457 
459  pOLENd->SetTitle( GetTitle() );
460  pOLENd->SetDescription( GetDescription() );
461  pOLENd->SetContour( HasContour(), HasAutomaticContour() );
462  pOLENd->SetAspect( GetAspect() ); // the replacement image must be already copied
463 
464  pOLENd->SetOLESizeInvalid( true );
465  rDoc.SetOLEPrtNotifyPending();
466 
467  return pOLENd;
468 }
469 
471 {
472  // Find the "Body Anchor"
473  SwNodeOffset nEndExtraIdx = GetNodes().GetEndOfExtras().GetIndex();
474  const SwNode* pAnchorNd = this;
475  do {
476  SwFrameFormat* pFlyFormat = pAnchorNd->GetFlyFormat();
477  if( !pFlyFormat )
478  return false;
479 
480  const SwFormatAnchor& rAnchor = pFlyFormat->GetAnchor();
481  if( !rAnchor.GetContentAnchor() )
482  return false;
483 
484  pAnchorNd = &rAnchor.GetContentAnchor()->nNode.GetNode();
485  } while( pAnchorNd->GetIndex() < nEndExtraIdx );
486 
487  const SwSectionNode* pSectNd = pAnchorNd->FindSectionNode();
488  if( !pSectNd )
489  return false;
490 
491  while( pSectNd )
492  {
493  pAnchorNd = pSectNd;
494  pSectNd = pAnchorNd->StartOfSectionNode()->FindSectionNode();
495  }
496 
497  // pAnchorNd contains the most recently found Section Node, which
498  // now must fulfill the prerequisites for the GlobalDoc
499  pSectNd = static_cast<const SwSectionNode*>(pAnchorNd);
500  return SectionType::FileLink == pSectNd->GetSection().GetType() &&
501  pSectNd->GetIndex() > nEndExtraIdx;
502 }
503 
505 {
506  if( maOLEObj.m_xOLERef.is() )
507  {
509  if( p ) // Must be there
510  {
512  }
513  }
514  return false;
515 }
516 
518 {
519  if ( maOLEObj.m_xOLERef.is() )
521 }
522 
524 {
525  bool bResult = false;
526 
527  if ( mpObjectLink )
528  {
529  OUString aNewLinkURL;
530  sfx2::LinkManager::GetDisplayNames( mpObjectLink, nullptr, &aNewLinkURL );
531  if ( !aNewLinkURL.equalsIgnoreAsciiCase( maLinkURL ) )
532  {
533  if ( !maOLEObj.m_xOLERef.is() )
535 
536  uno::Reference< embed::XEmbeddedObject > xObj = maOLEObj.m_xOLERef.GetObject();
537  uno::Reference< embed::XCommonEmbedPersist > xPersObj( xObj, uno::UNO_QUERY );
538  OSL_ENSURE( xPersObj.is(), "The object must exist!" );
539  if ( xPersObj.is() )
540  {
541  try
542  {
543  sal_Int32 nCurState = xObj->getCurrentState();
544  if ( nCurState != embed::EmbedStates::LOADED )
545  xObj->changeState( embed::EmbedStates::LOADED );
546 
547  // TODO/LATER: there should be possible to get current mediadescriptor settings from the object
548  uno::Sequence< beans::PropertyValue > aArgs{ comphelper::makePropertyValue(
549  "URL", 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 IMPL_LINK_NOARG(SwOLEObj, IsProtectedHdl, LinkParamNone*, bool) { return IsProtected(); }
910 
912 {
913  if (!m_pOLENode)
914  {
915  return false;
916  }
917 
918  SwFrame* pFrame = m_pOLENode->getLayoutFrame(nullptr);
919  if (!pFrame)
920  {
921  return false;
922  }
923  SwFrame* pUpper = pFrame->GetUpper();
924  if (!pUpper || !pUpper->IsFlyFrame())
925  {
926  return false;
927  }
928 
929  auto pFlyFrame = static_cast<SwFlyFrame*>(pUpper);
930  const SwFrame* pAnchor = pFlyFrame->GetAnchorFrame();
931  if (!pAnchor)
932  {
933  return false;
934  }
935 
936  return pAnchor->IsProtected();
937 }
938 
939 uno::Reference < embed::XEmbeddedObject > const & SwOLEObj::GetOleRef()
940 {
941  if( !m_xOLERef.is() )
942  {
944  assert(p && "No SvPersist present");
945 
946  OUString sDocumentBaseURL = p->getDocumentBaseURL();
947  uno::Reference < embed::XEmbeddedObject > xObj = p->GetEmbeddedObjectContainer().GetEmbeddedObject(m_aName, &sDocumentBaseURL);
948  OSL_ENSURE( !m_xOLERef.is(), "Calling GetOleRef() recursively is not permitted" );
949 
950  if ( !xObj.is() )
951  {
952  // We could not load this part (probably broken)
953  tools::Rectangle aArea;
954  SwFrame *pFrame = m_pOLENode->getLayoutFrame(nullptr);
955  if ( pFrame )
956  {
957  Size aSz( pFrame->getFrameArea().SSize() );
959  aArea.SetSize( aSz );
960  }
961  else
962  aArea.SetSize( Size( 5000, 5000 ) );
963  // TODO/LATER: set replacement graphic for dead object
964  // It looks as if it should work even without the object, because the replace will be generated automatically
965  OUString aTmpName;
966  xObj = p->GetEmbeddedObjectContainer().CreateEmbeddedObject( SvGlobalName( SO3_DUMMY_CLASSID ).GetByteSequence(), aTmpName );
967  }
968  if (xObj.is())
969  {
970  m_xOLERef.SetIsProtectedHdl(LINK(this, SwOLEObj, IsProtectedHdl));
973  m_xListener = new SwOLEListener_Impl( this );
974  xObj->addStateChangeListener( m_xListener );
975  }
976 
977  const_cast<SwOLENode*>(m_pOLENode)->CheckFileLink_Impl(); // for this notification nonconst access is required
978  }
979  else if ( m_xOLERef->getCurrentState() == embed::EmbedStates::RUNNING )
980  {
981  // move object to first position in cache
982  if (!g_pOLELRU_Cache)
983  g_pOLELRU_Cache = std::make_shared<SwOLELRUCache>();
984  g_pOLELRU_Cache->InsertObj( *this );
985  }
986 
987  return m_xOLERef.GetObject();
988 }
989 
991 {
992  GetOleRef();
993  return m_xOLERef;
994 }
995 
997 {
998  bool bRet = true;
999  if ( m_pOLENode )
1000  {
1001  const SwDoc& rDoc = m_pOLENode->GetDoc();
1002  bRet = UnloadObject( m_xOLERef.GetObject(), &rDoc, m_xOLERef.GetViewAspect() );
1003  }
1004 
1005  return bRet;
1006 }
1007 
1009  : m_rManager(const_cast<SwDoc&>(rDoc).GetDocumentSettingManager())
1010  , m_bOrigPurgeOle(m_rManager.get(DocumentSettingId::PURGE_OLE))
1011 {
1013 }
1014 
1015 PurgeGuard::~PurgeGuard() COVERITY_NOEXCEPT_FALSE
1016 {
1018 }
1019 
1020 bool SwOLEObj::UnloadObject( uno::Reference< embed::XEmbeddedObject > const & xObj, const SwDoc* pDoc, sal_Int64 nAspect )
1021 {
1022  if ( !pDoc )
1023  return false;
1024 
1025  bool bRet = true;
1026  sal_Int32 nState = xObj.is() ? xObj->getCurrentState() : embed::EmbedStates::LOADED;
1027  bool bIsActive = ( nState != embed::EmbedStates::LOADED && nState != embed::EmbedStates::RUNNING );
1028  sal_Int64 nMiscStatus = xObj->getStatus( nAspect );
1029 
1030  if( nState != embed::EmbedStates::LOADED && !pDoc->IsInDtor() && !bIsActive &&
1031  embed::EmbedMisc::MS_EMBED_ALWAYSRUN != ( nMiscStatus & embed::EmbedMisc::MS_EMBED_ALWAYSRUN ) &&
1032  embed::EmbedMisc::EMBED_ACTIVATEIMMEDIATELY != ( nMiscStatus & embed::EmbedMisc::EMBED_ACTIVATEIMMEDIATELY ) )
1033  {
1034  SfxObjectShell* p = pDoc->GetPersist();
1035  if( p )
1036  {
1038  {
1039  try
1040  {
1041  uno::Reference < util::XModifiable > xMod( xObj->getComponent(), uno::UNO_QUERY );
1042  if( xMod.is() && xMod->isModified() )
1043  {
1044  uno::Reference < embed::XEmbedPersist > xPers( xObj, uno::UNO_QUERY );
1045  assert(xPers.is() && "Modified object without persistence in cache!");
1046 
1047  PurgeGuard aGuard(*pDoc);
1048  xPers->storeOwn();
1049  }
1050 
1051  // setting object to loaded state will remove it from cache
1052  xObj->changeState( embed::EmbedStates::LOADED );
1053  }
1054  catch (const uno::Exception&)
1055  {
1056  bRet = false;
1057  }
1058  }
1059  else
1060  bRet = false;
1061  }
1062  }
1063 
1064  return bRet;
1065 }
1066 
1068 {
1069  uno::Reference< embed::XEmbeddedObject > xEmbObj = GetOleRef();
1070  if ( !xEmbObj.is() )
1071  return OUString();
1072 
1073  SvGlobalName aClassID( xEmbObj->getClassID() );
1074  if ( SotExchange::IsMath( aClassID ) )
1075  return SwResId(STR_MATH_FORMULA);
1076 
1077  if ( SotExchange::IsChart( aClassID ) )
1078  return SwResId(STR_CHART);
1079 
1080  return SwResId(STR_OLE);
1081 }
1082 
1084  basegfx::B2DRange& rRange,
1085  bool bSynchron)
1086 {
1087  if(m_pDeflateData)
1088  {
1089  if(bSynchron)
1090  {
1091  // data in high quality is requested, wait until the data is available
1092  // since a WorkerThread was already started to load it
1093  m_pDeflateData->waitFinished();
1094  }
1095 
1096  if(m_pDeflateData->isFinished())
1097  {
1098  // copy the result data and cleanup
1099  m_aPrimitive2DSequence = m_pDeflateData->getSequence();
1100  m_aRange = m_pDeflateData->getRange();
1101  m_pDeflateData.reset();
1102  }
1103  }
1104 
1106  {
1107  const uno::Reference< frame::XModel > aXModel(m_xOLERef->getComponent(), uno::UNO_QUERY);
1108 
1109  if(aXModel.is())
1110  {
1111  // disabled for now, need to check deeper
1112  static bool bAsynchronousLoadingAllowed = false; // loplugin:constvars:ignore
1113 
1114  if(bSynchron ||
1115  !bAsynchronousLoadingAllowed)
1116  {
1117  // load chart synchron in this Thread
1119  aXModel,
1120  m_aRange);
1121  }
1122  else
1123  {
1124  // if not yet setup, initiate and start a WorkerThread to load the chart
1125  // and it's primitives asynchron. If it already works, returning nothing
1126  // is okay (preview will be reused)
1127  if(!m_pDeflateData)
1128  {
1129  m_pDeflateData.reset( new DeflateData(aXModel) );
1130  std::unique_ptr<DeflateThread> pNew( new DeflateThread(*m_pDeflateData) );
1132  }
1133  }
1134  }
1135  }
1136 
1137  if(!m_aPrimitive2DSequence.empty() && !m_aRange.isEmpty())
1138  {
1139  // when we have data, also copy the buffered Range data as output
1140  rRange = m_aRange;
1141  }
1142 
1143  return m_aPrimitive2DSequence;
1144 }
1145 
1147 {
1149  m_aRange.reset();
1150 
1151  if(m_pDeflateData)
1152  {
1153  // load is in progress, wait until finished and cleanup without using it
1154  m_pDeflateData->waitFinished();
1155  m_pDeflateData.reset();
1156  }
1157 }
1158 
1160 {
1161  (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwOLEObj"));
1162  (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
1163 
1164  m_xOLERef.dumpAsXml(pWriter);
1165 
1166  (void)xmlTextWriterEndElement(pWriter);
1167 }
1168 
1169 SwOLELRUCache::SwOLELRUCache()
1170  : utl::ConfigItem("Office.Common/Cache")
1171  , m_nLRU_InitSize( 20 )
1172 {
1173  EnableNotification( GetPropertyNames() );
1174  Load();
1175 }
1176 
1177 uno::Sequence< OUString > SwOLELRUCache::GetPropertyNames()
1178 {
1179  Sequence< OUString > aNames { "Writer/OLE_Objects" };
1180  return aNames;
1181 }
1182 
1183 void SwOLELRUCache::Notify( const uno::Sequence< OUString>& )
1184 {
1185  Load();
1186 }
1187 
1188 void SwOLELRUCache::ImplCommit()
1189 {
1190 }
1191 
1192 void SwOLELRUCache::Load()
1193 {
1194  Sequence< OUString > aNames( GetPropertyNames() );
1195  Sequence< Any > aValues = GetProperties( aNames );
1196  const Any* pValues = aValues.getConstArray();
1197  OSL_ENSURE( aValues.getLength() == aNames.getLength(), "GetProperties failed" );
1198  if (aValues.getLength() != aNames.getLength() || !pValues->hasValue())
1199  return;
1200 
1201  sal_Int32 nVal = 0;
1202  *pValues >>= nVal;
1203 
1204  if (nVal < m_nLRU_InitSize)
1205  {
1206  std::shared_ptr<SwOLELRUCache> xKeepAlive(g_pOLELRU_Cache); // prevent delete this
1207  // size of cache has been changed
1208  sal_Int32 nCount = m_OleObjects.size();
1209  sal_Int32 nPos = nCount;
1210 
1211  // try to remove the last entries until new maximum size is reached
1212  while( nCount > nVal )
1213  {
1214  SwOLEObj *const pObj = m_OleObjects[ --nPos ];
1215  if ( pObj->UnloadObject() )
1216  nCount--;
1217  if ( !nPos )
1218  break;
1219  }
1220  }
1221 
1222  m_nLRU_InitSize = nVal;
1223 }
1224 
1225 void SwOLELRUCache::InsertObj( SwOLEObj& rObj )
1226 {
1227  SwOLEObj* pObj = &rObj;
1228  if (auto const it = std::find(m_OleObjects.begin(), m_OleObjects.end(), pObj);
1229  it != m_OleObjects.end())
1230  {
1231  if (it == m_OleObjects.begin())
1232  return; // Everything is already in place
1233  // object in cache but is currently not the first in cache
1234  m_OleObjects.erase(it);
1235  }
1236 
1237  std::shared_ptr<SwOLELRUCache> xKeepAlive(g_pOLELRU_Cache); // prevent delete this
1238  // try to remove objects if necessary
1239  sal_Int32 nCount = m_OleObjects.size();
1240  sal_Int32 nPos = nCount-1;
1241  while (nPos >= 0 && nCount >= m_nLRU_InitSize)
1242  {
1243  pObj = m_OleObjects[ nPos-- ];
1244  if ( pObj->UnloadObject() )
1245  nCount--;
1246  }
1247  m_OleObjects.push_front(&rObj);
1248 }
1249 
1250 void SwOLELRUCache::RemoveObj( SwOLEObj& rObj )
1251 {
1252  auto const it = std::find(m_OleObjects.begin(), m_OleObjects.end(), &rObj);
1253  if (it != m_OleObjects.end())
1254  {
1255  m_OleObjects.erase(it);
1256  }
1257  if (m_OleObjects.empty())
1258  {
1259  if (g_pOLELRU_Cache.use_count() == 1) // test that we're not in InsertObj()
1260  {
1261  g_pOLELRU_Cache.reset();
1262  }
1263  }
1264 }
1265 
1266 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetAspect(sal_Int64 nAspect)
Definition: ndole.hxx:140
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
bool UnloadObject()
Definition: ndole.cxx:996
virtual void SAL_CALL stateChanged(const lang::EventObject &aEvent,::sal_Int32 nOldState,::sal_Int32 nNewState) override
Definition: ndole.cxx:117
SwSectionNode * FindSectionNode()
Search section node, in which it is.
Definition: ndsect.cxx:985
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:314
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:214
sal_Int64 GetAspect() const
Definition: ndole.hxx:139
~PurgeGuard() COVERITY_NOEXCEPT_FALSE
Definition: ndole.cxx:1015
SwOLEObj maOLEObj
Definition: ndole.hxx:91
friend DeflateThread
Definition: ndole.cxx:683
bool HasAutomaticContour() const
Definition: ndnotxt.hxx:77
virtual SwContentNode * MakeCopy(SwDoc &, const SwNodeIndex &, bool bNewFrames) const override
Is in ndcopy.cxx.
Definition: ndole.cxx:429
constexpr OUStringLiteral sDocumentBaseURL
const SwOLEObj & GetOLEObj() const
Definition: ndole.hxx:115
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:3242
virtual bool get(DocumentSettingId id) const override
Return the specified document setting.
OUString msChartTableName
with chart objects: name of referenced table.
Definition: ndole.hxx:92
SwDocShell * GetDocShell()
Definition: doc.hxx:1351
SwNodeIndex nNode
Definition: pam.hxx:38
SwDoc & GetDoc()
Which Doc contains the nodes-array?
Definition: ndarr.hxx:301
OUString GetDescription()
Definition: ndole.cxx:1067
void InsertFileLink(sfx2::SvBaseLink &, SvBaseLinkObjectType nFileType, std::u16string_view rFileNm, const OUString *pFilterNm=nullptr, const OUString *pRange=nullptr)
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
const OUString & GetChartTableName() const
Definition: ndole.hxx:155
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:939
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1210
rtl::Reference< SwOLEListener_Impl > m_xListener
Definition: ndole.hxx:39
css::uno::Reference< css::frame::XModel3 > GetModel() const
Definition: doc.hxx:187
IDocumentLinksAdministration const & getIDocumentLinksAdministration() const
Definition: doc.cxx:260
SwOLEObj * mpObj
Definition: ndole.cxx:95
virtual void set(DocumentSettingId id, bool value) override
Set the specified document setting.
bool HasEmbeddedObject(const OUString &)
SwNode & GetNode() const
Definition: ndindex.hxx:128
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:1357
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:239
void UpdateReplacement(bool bUpdateOle=false)
const tools::PolyPolygon * HasContour() const
Definition: ndnotxt.cxx:105
const SwSection & GetSection() const
Definition: node.hxx:549
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:294
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:164
bool IsChart() const
Definition: ndole.cxx:632
IMPL_LINK_NOARG(SwOLEObj, IsProtectedHdl, LinkParamNone *, bool)
Definition: ndole.cxx:909
bool UpdateLinkURL_Impl()
Definition: ndole.cxx:523
drawinglayer::primitive2d::Primitive2DContainer const & tryToGetChartContentAsPrimitive2DSequence(basegfx::B2DRange &rRange, bool bSynchron)
Definition: ndole.cxx:1083
bool IsFlyFrame() const
Definition: frame.hxx:1210
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:179
OUTDEV_WINDOW
svt::EmbeddedObjectRef & GetObject()
Definition: ndole.cxx:990
drawinglayer::primitive2d::Primitive2DContainer m_aPrimitive2DSequence
Definition: ndole.hxx:47
int nCount
const Graphic * GetGraphic() const
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: ndole.cxx:1159
SotClipboardFormatId
const SwOLENode * m_pOLENode
Definition: ndole.hxx:38
static sal_uInt16 IsMath(const SvGlobalName &rName)
uno::Reference< frame::XModel > maXModel
Definition: ndole.cxx:686
::sw::DocumentSettingManager & m_rManager
Definition: ndole.hxx:182
const OUString & GetCurrentPersistName() const
Definition: ndole.hxx:71
basegfx::B2DRange maRange
Definition: ndole.cxx:688
static ThreadPool & getSharedOptimalPool()
virtual bool ResetAttr(sal_uInt16 nWhich1, sal_uInt16 nWhich2=0)
Definition: node.cxx:1665
SwOLENode * MakeOLENode(const SwNodeIndex &rWhere, const svt::EmbeddedObjectRef &, SwGrfFormatColl *pColl)
in ndole.cxx
Definition: ndole.cxx:380
const SwAttrSet * GetpSwAttrSet() const
Definition: node.hxx:457
void SetOLEPrtNotifyPending(bool bSet=true)
Definition: doc.hxx:1687
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
bool IsProtected() const
Definition: ndole.cxx:911
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:97
void SetSize(const Size &rSize)
void Assign(const css::uno::Reference< css::embed::XEmbeddedObject > &xObj, sal_Int64 nAspect)
const Graphic * GetGraphic()
Definition: ndole.cxx:245
SwNodeOffset GetIndex() const
Definition: node.hxx:292
FlyAnchors.
Definition: fmtanchr.hxx:34
SwLayoutFrame * GetUpper()
Definition: frame.hxx:678
static bool isTaskTagDone(const std::shared_ptr< ThreadTaskTag > &)
bool isFinished() const
Definition: ndole.cxx:715
Layout frame for SwNoTextNode, i.e. graphics and OLE nodes (including charts).
Definition: ndnotxt.hxx:29
Marks a node in the document model.
Definition: ndindex.hxx:30
OUString GetStyleString()
Definition: ndole.cxx:896
SwNodes & GetNodes()
Node is in which nodes-array/doc?
Definition: node.hxx:703
SwEmbedObjectLink * mpObjectLink
Definition: ndole.hxx:96
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:423
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:309
virtual void SAL_CALL changingState(const lang::EventObject &aEvent,::sal_Int32 nOldState,::sal_Int32 nNewState) override
Definition: ndole.cxx:113
void SetNode(SwOLENode *pNode)
Definition: ndole.cxx:858
bool IsOLEObjectDeleted() const
Definition: ndole.cxx:504
const IDocumentLayoutAccess & getIDocumentLayoutAccess() const
Provides access to the document layout interface.
Definition: node.cxx:2105
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:156
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:91
const PropertyValue * pValues
comphelper::EmbeddedObjectContainer & GetEmbeddedObjectContainer() const
void SetViewAspect(sal_Int64 nAspect)
SwOLEListener_Impl(SwOLEObj *pObj)
Definition: ndole.cxx:104
void SetIsProtectedHdl(const Link< LinkParamNone *, bool > &rProtectedHdl)
general base class for all free-flowing frames
Definition: flyfrm.hxx:78
void dumpAsXml(xmlTextWriterPtr pWriter) const
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:143
virtual bool RestorePersistentData() override
Loading an OLE object that has been moved to the Undo Area.
Definition: ndole.cxx:255
void BreakFileLink_Impl()
Definition: ndole.cxx:573
bool m_bOrigPurgeOle
Definition: ndole.hxx:183
PurgeGuard(const SwDoc &rDoc)
Definition: ndole.cxx:1008
void SetChanged()
Definition: ndole.cxx:648
SwNodes & GetNodes()
Definition: doc.hxx:408
::sw::DocumentSettingManager & GetDocumentSettingManager()
Definition: doc.cxx:186
SfxObjectShell * GetPersist() const
Definition: docnew.cxx:640
Size GetSize(MapMode const *pTargetMapMode) const
void * p
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:137
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:403
const drawinglayer::primitive2d::Primitive2DContainer & getSequence() const
Definition: ndole.cxx:705
struct _xmlTextWriter * xmlTextWriterPtr
static bool TryRunningState(const css::uno::Reference< css::embed::XEmbeddedObject > &)
basegfx::B2DRange m_aRange
Definition: ndole.hxx:48
SectionType GetType() const
Definition: section.hxx:169
sal_Int64 GetViewAspect() const
void resetBufferedData()
Definition: ndole.cxx:1146
const SwGrfFormatColl * GetDfltGrfFormatColl() const
Definition: doc.hxx:803
SwNode & GetEndOfExtras() const
This is the last EndNode of a special section.
Definition: ndarr.hxx:160
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:517
bool m_bDetectedRangeSegmentation false
bool IsProtected() const
Is the Frame or rather the Section in which it lies protected?
Definition: trvlfrm.cxx:1628
Base class of the Writer document model elements.
Definition: node.hxx:81
OUString GetDescription() const
Remove OLE-object from "memory".
Definition: ndole.hxx:144
bool IsInGlobalDocSection() const
Definition: ndole.cxx:470
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo