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