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>
29
30#include <sot/exchange.hxx>
31#include <tools/globname.hxx>
32#include <sfx2/linkmgr.hxx>
34#include <utility>
35#include <vcl/outdev.hxx>
36#include <fmtanchr.hxx>
37#include <frmfmt.hxx>
38#include <doc.hxx>
39#include <docsh.hxx>
40#include <pam.hxx>
41#include <section.hxx>
42#include <cntfrm.hxx>
43#include <ndole.hxx>
44#include <viewsh.hxx>
50#include <vcl/graph.hxx>
51#include <sot/formats.hxx>
52#include <vcl/svapp.hxx>
53#include <strings.hrc>
54#include <svx/charthelper.hxx>
56#include <atomic>
57#include <deque>
58#include <libxml/xmlwriter.h>
59#include <osl/diagnose.h>
60#include <flyfrm.hxx>
61
62using namespace utl;
63using namespace com::sun::star::uno;
64using namespace com::sun::star;
65
66namespace {
67
68class SwOLELRUCache
69 : private utl::ConfigItem
70{
71private:
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
78public:
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
91static std::shared_ptr<SwOLELRUCache> g_pOLELRU_Cache;
92
93class SwOLEListener_Impl : public ::cppu::WeakImplHelper< embed::XStateChangeListener >
94{
96public:
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
113void SAL_CALL SwOLEListener_Impl::changingState( const lang::EventObject&, ::sal_Int32 , ::sal_Int32 )
114{
115}
116
117void 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
143void 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
152namespace {
153
154class SwEmbedObjectLink : public sfx2::SvBaseLink
155{
156 SwOLENode* m_pOleNode;
157
158public:
159 explicit SwEmbedObjectLink(SwOLENode* pNode);
160
161 virtual void Closed() override;
162 virtual ::sfx2::SvBaseLink::UpdateResult DataChanged(
163 const OUString& rMimeType, const css::uno::Any & rValue ) override;
164
165 void Connect() { GetRealObject(); }
166};
167
168SwEmbedObjectLink::SwEmbedObjectLink(SwOLENode* pNode)
170 , m_pOleNode(pNode)
171{
172 SetSynchron( false );
173}
174
175::sfx2::SvBaseLink::UpdateResult SwEmbedObjectLink::DataChanged(
176 const OUString&, const uno::Any& )
177{
178 if (!m_pOleNode->UpdateLinkURL_Impl())
179 {
180 // the link URL was not changed
181 uno::Reference<embed::XEmbeddedObject> xObject = m_pOleNode->GetOLEObj().GetOleRef();
182 OSL_ENSURE( xObject.is(), "The object must exist always!" );
183 if ( xObject.is() )
184 {
185 // let the object reload the link
186 // TODO/LATER: reload call could be used for this case
187
188 try
189 {
190 sal_Int32 nState = xObject->getCurrentState();
191 if ( nState != embed::EmbedStates::LOADED )
192 {
193 // in some cases the linked file probably is not locked so it could be changed
194 xObject->changeState( embed::EmbedStates::LOADED );
195 xObject->changeState( nState );
196 }
197 }
198 catch (const uno::Exception&)
199 {
200 }
201 }
202 }
203
204 m_pOleNode->GetNewReplacement();
205 m_pOleNode->SetChanged();
206
207 return SUCCESS;
208}
209
210void SwEmbedObjectLink::Closed()
211{
212 m_pOleNode->BreakFileLink_Impl();
213 SvBaseLink::Closed();
214}
215
216class SwIFrameLink : public sfx2::SvBaseLink
217{
218 SwOLENode* m_pOleNode;
219
220public:
221 explicit SwIFrameLink(SwOLENode* pNode)
223 , m_pOleNode(pNode)
224 {
225 SetSynchron( false );
226 }
227
229 const OUString&, const uno::Any& )
230 {
231 uno::Reference<embed::XEmbeddedObject> xObject = m_pOleNode->GetOLEObj().GetOleRef();
232 uno::Reference<embed::XCommonEmbedPersist> xPersObj(xObject, uno::UNO_QUERY);
233 if (xPersObj.is())
234 {
235 // let the IFrameObject reload the link
236 try
237 {
238 xPersObj->reload(uno::Sequence<beans::PropertyValue>(), uno::Sequence<beans::PropertyValue>());
239 }
240 catch (const uno::Exception&)
241 {
242 }
243
244 m_pOleNode->SetChanged();
245 }
246
247 return SUCCESS;
248 }
249
250};
251
252}
253
255 const svt::EmbeddedObjectRef& xObj,
256 SwGrfFormatColl *pGrfColl,
257 SwAttrSet const * pAutoAttr ) :
258 SwNoTextNode( rWhere, SwNodeType::Ole, pGrfColl, pAutoAttr ),
259 maOLEObj( xObj ),
260 mbOLESizeInvalid( false ),
261 mpObjectLink( nullptr )
262{
263 maOLEObj.SetNode( this );
264}
265
267 const OUString &rString,
268 sal_Int64 nAspect,
269 SwGrfFormatColl *pGrfColl,
270 SwAttrSet const * pAutoAttr ) :
271 SwNoTextNode( rWhere, SwNodeType::Ole, pGrfColl, pAutoAttr ),
272 maOLEObj( rString, nAspect ),
273 mbOLESizeInvalid( false ),
274 mpObjectLink( nullptr )
275{
276 maOLEObj.SetNode( this );
277}
278
280{
283}
284
286{
287 if ( maOLEObj.GetOleRef().is() )
289 return nullptr;
290}
291
296{
297 OSL_ENSURE( maOLEObj.GetOleRef().is(), "No object to restore!" );
298 if ( maOLEObj.m_xOLERef.is() )
299 {
300 // If a SvPersist instance already exists, we use it
302 if( !p )
303 {
304 // TODO/LATER: Isn't an EmbeddedObjectContainer sufficient here?
305 // What happens to this document?
306 OSL_ENSURE( false, "Why are we creating a DocShell here?" );
307 p = new SwDocShell( GetDoc(), SfxObjectCreateMode::INTERNAL );
308 p->DoInitNew();
309 }
310
311 uno::Reference < container::XChild > xChild( maOLEObj.m_xOLERef.GetObject(), uno::UNO_QUERY );
312 if ( xChild.is() )
313 xChild->setParent( p->GetModel() );
314
315 OSL_ENSURE( !maOLEObj.m_aName.isEmpty(), "No object name!" );
316 OUString aObjName;
317 if ( !p->GetEmbeddedObjectContainer().InsertEmbeddedObject( maOLEObj.m_xOLERef.GetObject(), aObjName ) )
318 {
319 if ( xChild.is() )
320 xChild->setParent( nullptr );
321 OSL_FAIL( "InsertObject failed" );
322 }
323 else
324 {
325 maOLEObj.m_aName = aObjName;
326 maOLEObj.m_xOLERef.AssignToContainer( &p->GetEmbeddedObjectContainer(), aObjName );
328 }
329 }
330
331 return true;
332}
333
335{
336 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwOLENode"));
337 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
338 (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("index"),
339 BAD_CAST(OString::number(sal_Int32(GetIndex())).getStr()));
340
341 GetOLEObj().dumpAsXml(pWriter);
342
343 (void)xmlTextWriterEndElement(pWriter);
344}
345
350{
351 if( maOLEObj.m_xOLERef.is() )
352 {
354
355#if OSL_DEBUG_LEVEL > 0
357 OSL_ENSURE( p, "No document!" );
358 if( p )
359 {
360 comphelper::EmbeddedObjectContainer& rCnt = p->GetEmbeddedObjectContainer();
361 OSL_ENSURE( !pCnt || &rCnt == pCnt, "The helper is assigned to unexpected container!" );
362 }
363#endif
364
365 if ( pCnt && pCnt->HasEmbeddedObject( maOLEObj.m_aName ) )
366 {
367 uno::Reference < container::XChild > xChild( maOLEObj.m_xOLERef.GetObject(), uno::UNO_QUERY );
368 if ( xChild.is() )
369 xChild->setParent( nullptr );
370
371 /*
372 #i119941
373 When cut or move the chart, SwUndoFlyBase::DelFly will call SaveSection
374 to store the content to storage. In this step, chart filter functions
375 will be called. And chart filter will call chart core functions to create
376 the chart again. Then chart core function will call the class
377 ExplicitCategoryProvider to create data source. In this step, when SW data
378 source provider create the data source, a UnoActionRemoveContext
379 will mess with the layout and create a new SwFlyFrame.
380 But later in SwUndoFlyBase::DelFly, it will clear anchor related attributes
381 of SwFlyFrame. Then finally null pointer occur.
382 Resolution:
383 In pCnt->RemoveEmbeddedObject in SaveSection process of table chart,
384 only remove the object from the object container, without removing it's
385 storage and graphic stream. The chart already removed from formatter.
386 */
387 bool bKeepObjectToTempStorage = true;
388 uno::Reference < embed::XEmbeddedObject > xIP = GetOLEObj().GetOleRef();
389 if (IsChart() && !msChartTableName.isEmpty()
391 {
392 uno::Reference< chart2::XChartDocument > xChart( xIP->getComponent(), UNO_QUERY );
393 if (xChart.is() && !xChart->hasInternalDataProvider())
394 {
395 bKeepObjectToTempStorage = false;
396 }
397 }
398
399 pCnt->RemoveEmbeddedObject( maOLEObj.m_aName, bKeepObjectToTempStorage );
400
401 // TODO/LATER: aOLEObj.aName has no meaning here, since the undo container contains the object
402 // by different name, in future it might makes sense that the name is transported here.
404 try
405 {
406 // "unload" object
407 maOLEObj.m_xOLERef->changeState( embed::EmbedStates::LOADED );
408 }
409 catch (const uno::Exception&)
410 {
411 }
412 }
413 }
414
416
417 return true;
418}
419
421 const svt::EmbeddedObjectRef& xObj,
422 SwGrfFormatColl* pGrfColl )
423{
424 OSL_ENSURE( pGrfColl,"SwNodes::MakeOLENode: Formatpointer is 0." );
425
426 SwOLENode *pNode =
427 new SwOLENode( rWhere, xObj, pGrfColl, nullptr );
428
429 // set parent if XChild is supported
431 uno::Reference< container::XChild > xChild( pNode->GetOLEObj().GetObject().GetObject(), UNO_QUERY );
432 if (xChild.is())
433 {
434 SwDocShell *pDocSh = GetDoc().GetDocShell();
435 if (pDocSh)
436 xChild->setParent( pDocSh->GetModel() );
437 }
438
439 return pNode;
440}
441
443 const OUString &rName, sal_Int64 nAspect, SwGrfFormatColl* pGrfColl, SwAttrSet const * pAutoAttr )
444{
445 OSL_ENSURE( pGrfColl,"SwNodes::MakeOLENode: Formatpointer is 0." );
446
447 SwOLENode *pNode =
448 new SwOLENode( rWhere, rName, nAspect, pGrfColl, pAutoAttr );
449
450 // set parent if XChild is supported
452 uno::Reference< container::XChild > xChild( pNode->GetOLEObj().GetObject().GetObject(), UNO_QUERY );
453 if (xChild.is())
454 {
455 SwDocShell *pDocSh = GetDoc().GetDocShell();
456 if (pDocSh)
457 xChild->setParent( pDocSh->GetModel() );
458 }
459
460 return pNode;
461}
462
464{
465 MapMode aMapMode( MapUnit::MapTwip );
466 return const_cast<SwOLENode*>(this)->maOLEObj.GetObject().GetSize( &aMapMode );
467}
468
470{
471 // If there's already a SvPersist instance, we use it
472 SfxObjectShell* pPersistShell = rDoc.GetPersist();
473 if( !pPersistShell )
474 {
475 // TODO/LATER: is EmbeddedObjectContainer not enough?
476 // the created document will be closed by rDoc ( should use SfxObjectShellLock )
477 pPersistShell = new SwDocShell( rDoc, SfxObjectCreateMode::INTERNAL );
478 rDoc.SetTmpDocShell( pPersistShell );
479 pPersistShell->DoInitNew();
480 }
481
482 // We insert it at SvPersist level
483 // TODO/LATER: check if using the same naming scheme for all apps works here
484 OUString aNewName/*( Sw3Io::UniqueName( p->GetStorage(), "Obj" ) )*/;
485 SfxObjectShell* pSrc = GetDoc().GetPersist();
486
490 aNewName,
491 pSrc->getDocumentBaseURL(),
492 pPersistShell->getDocumentBaseURL());
493
494 SwOLENode* pOLENd = rDoc.GetNodes().MakeOLENode( rIdx, aNewName, GetAspect(),
496 GetpSwAttrSet() );
497
499 pOLENd->SetTitle( GetTitle() );
500 pOLENd->SetDescription( GetDescription() );
502 pOLENd->SetAspect( GetAspect() ); // the replacement image must be already copied
503
504 pOLENd->SetOLESizeInvalid( true );
506
507 return pOLENd;
508}
509
511{
512 // Find the "Body Anchor"
513 SwNodeOffset nEndExtraIdx = GetNodes().GetEndOfExtras().GetIndex();
514 const SwNode* pAnchorNd = this;
515 do {
516 SwFrameFormat* pFlyFormat = pAnchorNd->GetFlyFormat();
517 if( !pFlyFormat )
518 return false;
519
520 const SwFormatAnchor& rAnchor = pFlyFormat->GetAnchor();
521 if( !rAnchor.GetAnchorNode() )
522 return false;
523
524 pAnchorNd = rAnchor.GetAnchorNode();
525 } while( pAnchorNd->GetIndex() < nEndExtraIdx );
526
527 const SwSectionNode* pSectNd = pAnchorNd->FindSectionNode();
528 if( !pSectNd )
529 return false;
530
531 while( pSectNd )
532 {
533 pAnchorNd = pSectNd;
534 pSectNd = pAnchorNd->StartOfSectionNode()->FindSectionNode();
535 }
536
537 // pAnchorNd contains the most recently found Section Node, which
538 // now must fulfill the prerequisites for the GlobalDoc
539 pSectNd = static_cast<const SwSectionNode*>(pAnchorNd);
540 return SectionType::FileLink == pSectNd->GetSection().GetType() &&
541 pSectNd->GetIndex() > nEndExtraIdx;
542}
543
545{
546 if( maOLEObj.m_xOLERef.is() )
547 {
549 if( p ) // Must be there
550 {
551 return !p->GetEmbeddedObjectContainer().HasEmbeddedObject( maOLEObj.m_aName );
552 }
553 }
554 return false;
555}
556
558{
559 if ( maOLEObj.m_xOLERef.is() )
561}
562
564{
565 bool bResult = false;
566
567 if ( mpObjectLink )
568 {
569 OUString aNewLinkURL;
570 sfx2::LinkManager::GetDisplayNames( mpObjectLink, nullptr, &aNewLinkURL );
571 if ( !aNewLinkURL.equalsIgnoreAsciiCase( maLinkURL ) )
572 {
573 if ( !maOLEObj.m_xOLERef.is() )
575
576 uno::Reference< embed::XEmbeddedObject > xObj = maOLEObj.m_xOLERef.GetObject();
577 uno::Reference< embed::XCommonEmbedPersist > xPersObj( xObj, uno::UNO_QUERY );
578 OSL_ENSURE( xPersObj.is(), "The object must exist!" );
579 if ( xPersObj.is() )
580 {
581 try
582 {
583 sal_Int32 nCurState = xObj->getCurrentState();
584 if ( nCurState != embed::EmbedStates::LOADED )
585 xObj->changeState( embed::EmbedStates::LOADED );
586
587 // TODO/LATER: there should be possible to get current mediadescriptor settings from the object
588 uno::Sequence< beans::PropertyValue > aArgs{ comphelper::makePropertyValue(
589 "URL", aNewLinkURL) };
590 xPersObj->reload( aArgs, uno::Sequence< beans::PropertyValue >() );
591
592 maLinkURL = aNewLinkURL;
593 bResult = true;
594
595 if ( nCurState != embed::EmbedStates::LOADED )
596 xObj->changeState( nCurState );
597 }
598 catch (const uno::Exception&)
599 {
600 }
601 }
602
603 if ( !bResult )
604 {
605 // TODO/LATER: return the old name to the link manager, is it possible?
606 }
607 }
608 }
609
610 return bResult;
611}
612
614{
615 SfxObjectShell* pPers = GetDoc().GetPersist();
616
617 if ( !pPers )
618 return;
619
620 uno::Reference< embed::XStorage > xStorage = pPers->GetStorage();
621 if ( !xStorage.is() )
622 return;
623
624 try
625 {
626 uno::Reference< embed::XLinkageSupport > xLinkSupport( maOLEObj.GetOleRef(), uno::UNO_QUERY_THROW );
627 xLinkSupport->breakLink( xStorage, maOLEObj.GetCurrentPersistName() );
629 maLinkURL.clear();
630 }
631 catch( uno::Exception& )
632 {
633 }
634}
635
637{
638 if ( mpObjectLink )
639 {
641 mpObjectLink = nullptr;
642 }
643}
644
646{
647 if ( !maOLEObj.m_xOLERef.GetObject().is() || mpObjectLink )
648 return;
649
650 try
651 {
652 uno::Reference<embed::XEmbeddedObject> xObject = maOLEObj.m_xOLERef.GetObject();
653 if (!xObject)
654 return;
655
656 bool bIFrame = false;
657
658 OUString aLinkURL;
659 uno::Reference<embed::XLinkageSupport> xLinkSupport(xObject, uno::UNO_QUERY);
660 if (xLinkSupport)
661 {
662 if (xLinkSupport->isLink())
663 aLinkURL = xLinkSupport->getLinkURL();
664 }
665 else
666 {
667 // get IFrame (Floating Frames) listed and updatable from the
668 // manage links dialog
669 SvGlobalName aClassId(xObject->getClassID());
670 if (aClassId == SvGlobalName(SO3_IFRAME_CLASSID))
671 {
672 uno::Reference<beans::XPropertySet> xSet(xObject->getComponent(), uno::UNO_QUERY);
673 if (xSet.is())
674 xSet->getPropertyValue("FrameURL") >>= aLinkURL;
675 bIFrame = true;
676 }
677 }
678
679 if (!aLinkURL.isEmpty()) // this is a file link so the model link manager should handle it
680 {
681 SwEmbedObjectLink* pEmbedObjectLink = nullptr;
682 if (!bIFrame)
683 {
684 pEmbedObjectLink = new SwEmbedObjectLink(this);
685 mpObjectLink = pEmbedObjectLink;
686 }
687 else
688 {
689 mpObjectLink = new SwIFrameLink(this);
690 }
691 maLinkURL = aLinkURL;
693 if (pEmbedObjectLink)
694 pEmbedObjectLink->Connect();
695 }
696 }
697 catch( uno::Exception& )
698 {
699 }
700}
701
702// #i99665#
704{
705 bool bIsChart( false );
706
707 const uno::Reference< embed::XEmbeddedObject > xEmbObj =
708 const_cast<SwOLEObj&>(GetOLEObj()).GetOleRef();
709 if ( xEmbObj.is() )
710 {
711 SvGlobalName aClassID( xEmbObj->getClassID() );
712 bIsChart = SotExchange::IsChart( aClassID );
713 }
714
715 return bIsChart;
716}
717
718// react on visual change (invalidate)
720{
721 SwFrame* pFrame(getLayoutFrame(nullptr));
722
723 if(nullptr == pFrame)
724 {
725 return;
726 }
727
728 const SwRect aFrameArea(pFrame->getFrameArea());
729 SwViewShell* pVSh(GetDoc().getIDocumentLayoutAccess().GetCurrentViewShell());
730
731 if(nullptr == pVSh)
732 {
733 return;
734 }
735
736 for(SwViewShell& rShell : pVSh->GetRingContainer())
737 {
738 CurrShell aCurr(&rShell);
739
740 if(rShell.VisArea().Overlaps(aFrameArea) && OUTDEV_WINDOW == rShell.GetOut()->GetOutDevType())
741 {
742 // invalidate instead of painting
743 rShell.GetWin()->Invalidate(aFrameArea.SVRect());
744 }
745 }
746}
747
748namespace { class DeflateThread; }
749
752{
753private:
755 friend class SwOLEObj;
756
757 uno::Reference< frame::XModel > maXModel;
760
761 // evtl.set from the SwOLEObj destructor when a WorkerThread is still active
762 // since it is not possible to kill it - let it terminate and delete the
763 // data working on itself
764 std::atomic< bool> mbKilled;
765
766 std::shared_ptr<comphelper::ThreadTaskTag> mpTag;
767
768public:
769 explicit DeflateData(uno::Reference< frame::XModel > xXModel)
770 : maXModel(std::move(xXModel)),
771 mbKilled(false),
772 mpTag( comphelper::ThreadPool::createThreadTaskTag() )
773 {
774 }
775
777 {
779 }
780
782 {
783 return maRange;
784 }
785
786 bool isFinished() const
787 {
789 }
790
792 {
793 // need to wait until the load in progress is finished.
794 // WorkerThreads need the SolarMutex to be able to continue
795 // and finish the running import.
796 SolarMutexReleaser aReleaser;
798 }
799};
800
801namespace {
802
804class DeflateThread : public comphelper::ThreadTask
805{
806 // the data to work on
807 DeflateData& mrDeflateData;
808
809public:
810 explicit DeflateThread(DeflateData& rDeflateData)
811 : comphelper::ThreadTask(rDeflateData.mpTag), mrDeflateData(rDeflateData)
812 {
813 }
814
815private:
816 virtual void doWork() override
817 {
818 try
819 {
820 // load the chart data and get the primitives
822 mrDeflateData.maXModel,
823 mrDeflateData.maRange);
824
825 // model no longer needed and done
826 mrDeflateData.maXModel.clear();
827 }
828 catch (const uno::Exception&)
829 {
830 }
831
832 if(mrDeflateData.mbKilled)
833 {
834 // need to cleanup myself - data will not be used
835 delete &mrDeflateData;
836 }
837 }
838};
839
840}
841
843
845 m_pOLENode( nullptr ),
846 m_xOLERef( xObj ),
847 m_nGraphicVersion( 0 )
848{
849 m_xOLERef.Lock();
850 if ( xObj.is() )
851 {
852 m_xListener = new SwOLEListener_Impl( this );
853 xObj->addStateChangeListener( m_xListener );
854 }
855}
856
857SwOLEObj::SwOLEObj( OUString aString, sal_Int64 nAspect ) :
858 m_pOLENode( nullptr ),
859 m_aName( std::move(aString) ),
860 m_nGraphicVersion( 0 )
861{
862 m_xOLERef.Lock();
863 m_xOLERef.SetViewAspect( nAspect );
864}
865
866SwOLEObj::~SwOLEObj() COVERITY_NOEXCEPT_FALSE
867{
869 {
870 // set flag so that the worker thread will delete m_pDeflateData
871 // when finished and forget about it
872 m_pDeflateData->mbKilled = true;
873 m_pDeflateData = nullptr;
874 }
875
876 if( m_xListener )
877 {
878 if ( m_xOLERef.is() )
879 m_xOLERef->removeStateChangeListener( m_xListener );
880 m_xListener->dispose();
881 m_xListener.clear();
882 }
883
884 if( m_pOLENode && !m_pOLENode->GetDoc().IsInDtor() )
885 {
886 // if the model is not currently in destruction it means that this object should be removed from the model
888
889#if OSL_DEBUG_LEVEL > 0
891 OSL_ENSURE( p, "No document!" );
892 if( p )
893 {
894 comphelper::EmbeddedObjectContainer& rCnt = p->GetEmbeddedObjectContainer();
895 OSL_ENSURE( !pCnt || &rCnt == pCnt, "The helper is assigned to unexpected container!" );
896 }
897#endif
898
899 if ( pCnt && pCnt->HasEmbeddedObject( m_aName ) )
900 {
901 uno::Reference < container::XChild > xChild( m_xOLERef.GetObject(), uno::UNO_QUERY );
902 if ( xChild.is() )
903 xChild->setParent( nullptr );
904
905 // not already removed by deleting the object
907
908 // unlock object so that object can be closed in RemoveEmbeddedObject
909 // successful closing of the object will automatically clear the reference then
910 m_xOLERef.Lock(false);
911
912 // Always remove object from container it is connected to
913 try
914 {
915 // remove object from container but don't close it
917 }
918 catch ( uno::Exception& )
919 {
920 }
921 }
922
923 }
924
925 if ( m_xOLERef.is() )
926 // in case the object wasn't closed: release it
927 // in case the object was not in the container: it's still locked, try to close
929}
930
932{
933 m_pOLENode = pNode;
934 if ( !m_aName.isEmpty() )
935 return;
936
937 SwDoc& rDoc = pNode->GetDoc();
938
939 // If there's already a SvPersist instance, we use it
940 SfxObjectShell* p = rDoc.GetPersist();
941 if( !p )
942 {
943 // TODO/LATER: Isn't an EmbeddedObjectContainer sufficient here?
944 // What happens to the document?
945 OSL_ENSURE( false, "Why are we creating a DocShell here??" );
946 p = new SwDocShell( rDoc, SfxObjectCreateMode::INTERNAL );
947 p->DoInitNew();
948 }
949
950 OUString aObjName;
951 uno::Reference < container::XChild > xChild( m_xOLERef.GetObject(), uno::UNO_QUERY );
952 if ( xChild.is() && xChild->getParent() != p->GetModel() )
953 // it is possible that the parent was set already
954 xChild->setParent( p->GetModel() );
955 if (!p->GetEmbeddedObjectContainer().InsertEmbeddedObject( m_xOLERef.GetObject(), aObjName ) )
956 {
957 OSL_FAIL( "InsertObject failed" );
958 if ( xChild.is() )
959 xChild->setParent( nullptr );
960 }
961 else
962 m_xOLERef.AssignToContainer( &p->GetEmbeddedObjectContainer(), aObjName );
963
964 const_cast<SwOLENode*>(m_pOLENode)->CheckFileLink_Impl(); // for this notification nonconst access is required
965
966 m_aName = aObjName;
967}
968
970{
971 OUString strStyle;
972 if (m_xOLERef.is() && m_xOLERef.IsChart())
973 strStyle = m_xOLERef.GetChartType();
974 return strStyle;
975}
976
978{
979 return m_xOLERef.is();
980}
981
982IMPL_LINK_NOARG(SwOLEObj, IsProtectedHdl, LinkParamNone*, bool) { return IsProtected(); }
983
985{
986 if (!m_pOLENode)
987 {
988 return false;
989 }
990
991 SwFrame* pFrame = m_pOLENode->getLayoutFrame(nullptr);
992 if (!pFrame)
993 {
994 return false;
995 }
996 SwFrame* pUpper = pFrame->GetUpper();
997 if (!pUpper || !pUpper->IsFlyFrame())
998 {
999 return false;
1000 }
1001
1002 auto pFlyFrame = static_cast<SwFlyFrame*>(pUpper);
1003 const SwFrame* pAnchor = pFlyFrame->GetAnchorFrame();
1004 if (!pAnchor)
1005 {
1006 return false;
1007 }
1008
1009 return pAnchor->IsProtected();
1010}
1011
1012uno::Reference < embed::XEmbeddedObject > const & SwOLEObj::GetOleRef()
1013{
1014 if( !m_xOLERef.is() )
1015 {
1017 assert(p && "No SvPersist present");
1018
1019 OUString sDocumentBaseURL = p->getDocumentBaseURL();
1020 uno::Reference < embed::XEmbeddedObject > xObj = p->GetEmbeddedObjectContainer().GetEmbeddedObject(m_aName, &sDocumentBaseURL);
1021 OSL_ENSURE( !m_xOLERef.is(), "Calling GetOleRef() recursively is not permitted" );
1022
1023 if ( !xObj.is() )
1024 {
1025 // We could not load this part (probably broken)
1026 tools::Rectangle aArea;
1027 SwFrame *pFrame = m_pOLENode->getLayoutFrame(nullptr);
1028 if ( pFrame )
1029 {
1030 Size aSz( pFrame->getFrameArea().SSize() );
1032 aArea.SetSize( aSz );
1033 }
1034 else
1035 aArea.SetSize( Size( 5000, 5000 ) );
1036 // TODO/LATER: set replacement graphic for dead object
1037 // It looks as if it should work even without the object, because the replace will be generated automatically
1038 OUString aTmpName;
1039 xObj = p->GetEmbeddedObjectContainer().CreateEmbeddedObject( SvGlobalName( SO3_DUMMY_CLASSID ).GetByteSequence(), aTmpName );
1040 }
1041 if (xObj.is())
1042 {
1043 m_xOLERef.SetIsProtectedHdl(LINK(this, SwOLEObj, IsProtectedHdl));
1045 m_xOLERef.AssignToContainer( &p->GetEmbeddedObjectContainer(), m_aName );
1046 m_xListener = new SwOLEListener_Impl( this );
1047 xObj->addStateChangeListener( m_xListener );
1048 }
1049
1050 const_cast<SwOLENode*>(m_pOLENode)->CheckFileLink_Impl(); // for this notification nonconst access is required
1051 }
1052 else if ( m_xOLERef->getCurrentState() == embed::EmbedStates::RUNNING )
1053 {
1054 // move object to first position in cache
1055 if (!g_pOLELRU_Cache)
1056 g_pOLELRU_Cache = std::make_shared<SwOLELRUCache>();
1057 g_pOLELRU_Cache->InsertObj( *this );
1058 }
1059
1060 return m_xOLERef.GetObject();
1061}
1062
1064{
1065 GetOleRef();
1066 return m_xOLERef;
1067}
1068
1070{
1071 bool bRet = true;
1072 if ( m_pOLENode )
1073 {
1074 const SwDoc& rDoc = m_pOLENode->GetDoc();
1076 }
1077
1078 return bRet;
1079}
1080
1082 : m_rManager(const_cast<SwDoc&>(rDoc).GetDocumentSettingManager())
1083 , m_bOrigPurgeOle(m_rManager.get(DocumentSettingId::PURGE_OLE))
1084{
1086}
1087
1088PurgeGuard::~PurgeGuard() COVERITY_NOEXCEPT_FALSE
1089{
1091}
1092
1093bool SwOLEObj::UnloadObject( uno::Reference< embed::XEmbeddedObject > const & xObj, const SwDoc* pDoc, sal_Int64 nAspect )
1094{
1095 if ( !pDoc )
1096 return false;
1097
1098 bool bRet = true;
1099 sal_Int32 nState = xObj.is() ? xObj->getCurrentState() : embed::EmbedStates::LOADED;
1100 bool bIsActive = ( nState != embed::EmbedStates::LOADED && nState != embed::EmbedStates::RUNNING );
1101 sal_Int64 nMiscStatus = xObj->getStatus( nAspect );
1102
1103 if( nState != embed::EmbedStates::LOADED && !pDoc->IsInDtor() && !bIsActive &&
1104 embed::EmbedMisc::MS_EMBED_ALWAYSRUN != ( nMiscStatus & embed::EmbedMisc::MS_EMBED_ALWAYSRUN ) &&
1105 embed::EmbedMisc::EMBED_ACTIVATEIMMEDIATELY != ( nMiscStatus & embed::EmbedMisc::EMBED_ACTIVATEIMMEDIATELY ) )
1106 {
1107 SfxObjectShell* p = pDoc->GetPersist();
1108 if( p )
1109 {
1111 {
1112 try
1113 {
1114 uno::Reference < util::XModifiable > xMod( xObj->getComponent(), uno::UNO_QUERY );
1115 if( xMod.is() && xMod->isModified() )
1116 {
1117 uno::Reference < embed::XEmbedPersist > xPers( xObj, uno::UNO_QUERY );
1118 assert(xPers.is() && "Modified object without persistence in cache!");
1119
1120 PurgeGuard aGuard(*pDoc);
1121 xPers->storeOwn();
1122 }
1123
1124 // setting object to loaded state will remove it from cache
1125 xObj->changeState( embed::EmbedStates::LOADED );
1126 }
1127 catch (const uno::Exception&)
1128 {
1129 bRet = false;
1130 }
1131 }
1132 else
1133 bRet = false;
1134 }
1135 }
1136
1137 return bRet;
1138}
1139
1141{
1142 uno::Reference< embed::XEmbeddedObject > xEmbObj = GetOleRef();
1143 if ( !xEmbObj.is() )
1144 return OUString();
1145
1146 SvGlobalName aClassID( xEmbObj->getClassID() );
1148 return SwResId(STR_MATH_FORMULA);
1149
1151 return SwResId(STR_CHART);
1152
1153 return SwResId(STR_OLE);
1154}
1155
1157 basegfx::B2DRange& rRange,
1158 bool bSynchron)
1159{
1160 if(m_pDeflateData)
1161 {
1162 if(bSynchron)
1163 {
1164 // data in high quality is requested, wait until the data is available
1165 // since a WorkerThread was already started to load it
1166 m_pDeflateData->waitFinished();
1167 }
1168
1169 if(m_pDeflateData->isFinished())
1170 {
1171 // copy the result data and cleanup
1172 m_aPrimitive2DSequence = m_pDeflateData->getSequence();
1173 m_aRange = m_pDeflateData->getRange();
1175 m_pDeflateData.reset();
1176 }
1177 }
1178
1179 if(!m_aPrimitive2DSequence.empty() && !m_aRange.isEmpty()
1180 && m_nGraphicVersion != GetObject().getGraphicVersion())
1181 {
1182 // tdf#149189 use getGraphicVersion() from EmbeddedObjectRef
1183 // to decide when to reset buffered data. It gets incremented
1184 // at all occasions where the graphic changes. An alternative
1185 // would be to extend SwOLEListener_Impl with a XModifyListener
1186 // as it is done in EmbedEventListener_Impl, that would
1187 // require all the (add|remove)ModifyListener calls and
1188 // managing these, plus having a 2nd listener to these when
1189 // EmbeddedObjectRef already provides that. Tried that this
1190 // works also if an alternative would be needed.
1192 }
1193
1195 {
1196 const uno::Reference< frame::XModel > aXModel(m_xOLERef->getComponent(), uno::UNO_QUERY);
1197
1198 if(aXModel.is())
1199 {
1200 // disabled for now, need to check deeper
1201 static bool bAsynchronousLoadingAllowed = false; // loplugin:constvars:ignore
1202
1203 if(bSynchron ||
1204 !bAsynchronousLoadingAllowed)
1205 {
1206 // load chart synchron in this Thread
1208 aXModel,
1209 m_aRange);
1210 }
1211 else
1212 {
1213 // if not yet setup, initiate and start a WorkerThread to load the chart
1214 // and it's primitives asynchron. If it already works, returning nothing
1215 // is okay (preview will be reused)
1216 if(!m_pDeflateData)
1217 {
1218 m_pDeflateData.reset( new DeflateData(aXModel) );
1219 std::unique_ptr<DeflateThread> pNew( new DeflateThread(*m_pDeflateData) );
1221 }
1222 }
1223 }
1224 }
1225
1226 if(!m_aPrimitive2DSequence.empty() && !m_aRange.isEmpty())
1227 {
1228 // when we have data, also copy the buffered Range data as output
1229 rRange = m_aRange;
1230
1231 // tdf#149189 ..and the GraphicVersion number to identify changes
1233 }
1234
1236}
1237
1239{
1241 m_aRange.reset();
1242
1243 if(m_pDeflateData)
1244 {
1245 // load is in progress, wait until finished and cleanup without using it
1246 m_pDeflateData->waitFinished();
1247 m_pDeflateData.reset();
1248 }
1249}
1250
1252{
1253 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwOLEObj"));
1254 (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
1255
1256 m_xOLERef.dumpAsXml(pWriter);
1257
1258 (void)xmlTextWriterEndElement(pWriter);
1259}
1260
1261SwOLELRUCache::SwOLELRUCache()
1262 : utl::ConfigItem("Office.Common/Cache")
1263 , m_nLRU_InitSize( 20 )
1264{
1265 EnableNotification( GetPropertyNames() );
1266 Load();
1267}
1268
1269uno::Sequence< OUString > SwOLELRUCache::GetPropertyNames()
1270{
1271 Sequence< OUString > aNames { "Writer/OLE_Objects" };
1272 return aNames;
1273}
1274
1275void SwOLELRUCache::Notify( const uno::Sequence< OUString>& )
1276{
1277 Load();
1278}
1279
1280void SwOLELRUCache::ImplCommit()
1281{
1282}
1283
1284void SwOLELRUCache::Load()
1285{
1286 Sequence< OUString > aNames( GetPropertyNames() );
1287 Sequence< Any > aValues = GetProperties( aNames );
1288 const Any* pValues = aValues.getConstArray();
1289 OSL_ENSURE( aValues.getLength() == aNames.getLength(), "GetProperties failed" );
1290 if (aValues.getLength() != aNames.getLength() || !pValues->hasValue())
1291 return;
1292
1293 sal_Int32 nVal = 0;
1294 *pValues >>= nVal;
1295
1296 if (nVal < m_nLRU_InitSize)
1297 {
1298 std::shared_ptr<SwOLELRUCache> xKeepAlive(g_pOLELRU_Cache); // prevent delete this
1299 // size of cache has been changed
1300 sal_Int32 nCount = m_OleObjects.size();
1301 sal_Int32 nPos = nCount;
1302
1303 // try to remove the last entries until new maximum size is reached
1304 while( nCount > nVal )
1305 {
1306 SwOLEObj *const pObj = m_OleObjects[ --nPos ];
1307 if ( pObj->UnloadObject() )
1308 nCount--;
1309 if ( !nPos )
1310 break;
1311 }
1312 }
1313
1314 m_nLRU_InitSize = nVal;
1315}
1316
1317void SwOLELRUCache::InsertObj( SwOLEObj& rObj )
1318{
1319 SwOLEObj* pObj = &rObj;
1320 if (auto const it = std::find(m_OleObjects.begin(), m_OleObjects.end(), pObj);
1321 it != m_OleObjects.end())
1322 {
1323 if (it == m_OleObjects.begin())
1324 return; // Everything is already in place
1325 // object in cache but is currently not the first in cache
1326 m_OleObjects.erase(it);
1327 }
1328
1329 std::shared_ptr<SwOLELRUCache> xKeepAlive(g_pOLELRU_Cache); // prevent delete this
1330 // try to remove objects if necessary
1331 sal_Int32 nCount = m_OleObjects.size();
1332 sal_Int32 nPos = nCount-1;
1333 while (nPos >= 0 && nCount >= m_nLRU_InitSize)
1334 {
1335 pObj = m_OleObjects[ nPos-- ];
1336 if ( pObj->UnloadObject() )
1337 nCount--;
1338 }
1339 m_OleObjects.push_front(&rObj);
1340}
1341
1342void SwOLELRUCache::RemoveObj( SwOLEObj& rObj )
1343{
1344 auto const it = std::find(m_OleObjects.begin(), m_OleObjects.end(), &rObj);
1345 if (it != m_OleObjects.end())
1346 {
1347 m_OleObjects.erase(it);
1348 }
1349 if (m_OleObjects.empty())
1350 {
1351 if (g_pOLELRU_Cache.use_count() == 1) // test that we're not in InsertObj()
1352 {
1353 g_pOLELRU_Cache.reset();
1354 }
1355 }
1356}
1357
1358/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
const PropertyValue * pValues
constexpr OUStringLiteral sDocumentBaseURL
static drawinglayer::primitive2d::Primitive2DContainer tryToGetChartContentAsPrimitive2DSequence(const css::uno::Reference< css::frame::XModel > &rXModel, basegfx::B2DRange &rRange)
Holder for local data for a parallel-executed task to load a chart model.
Definition: ndole.cxx:752
drawinglayer::primitive2d::Primitive2DContainer maPrimitive2DSequence
Definition: ndole.cxx:758
DeflateData(uno::Reference< frame::XModel > xXModel)
Definition: ndole.cxx:769
bool isFinished() const
Definition: ndole.cxx:786
std::atomic< bool > mbKilled
Definition: ndole.cxx:764
void waitFinished()
Definition: ndole.cxx:791
friend DeflateThread
Definition: ndole.cxx:754
std::shared_ptr< comphelper::ThreadTaskTag > mpTag
Definition: ndole.cxx:766
basegfx::B2DRange maRange
Definition: ndole.cxx:759
const drawinglayer::primitive2d::Primitive2DContainer & getSequence() const
Definition: ndole.cxx:776
uno::Reference< frame::XModel > maXModel
Definition: ndole.cxx:757
const basegfx::B2DRange & getRange() const
Definition: ndole.cxx:781
virtual sfx2::LinkManager & GetLinkManager()=0
PurgeGuard(const SwDoc &rDoc)
Definition: ndole.cxx:1081
~PurgeGuard() COVERITY_NOEXCEPT_FALSE
Definition: ndole.cxx:1088
bool m_bOrigPurgeOle
Definition: ndole.hxx:184
::sw::DocumentSettingManager & m_rManager
Definition: ndole.hxx:183
comphelper::EmbeddedObjectContainer & GetEmbeddedObjectContainer() const
css::uno::Reference< css::frame::XModel3 > GetModel() const
virtual OUString getDocumentBaseURL() const override
css::uno::Reference< css::embed::XStorage > const & GetStorage()
static sal_uInt16 IsChart(const SvGlobalName &rName)
static sal_uInt16 IsMath(const SvGlobalName &rName)
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1223
const SwAttrSet * GetpSwAttrSet() const
Definition: node.hxx:493
virtual bool ResetAttr(sal_uInt16 nWhich1, sal_uInt16 nWhich2=0)
Definition: node.cxx:1679
Definition: doc.hxx:197
bool IsInDtor() const
Definition: doc.hxx:417
const SwGrfFormatColl * GetDfltGrfFormatColl() const
Definition: doc.hxx:819
void SetOLEPrtNotifyPending(bool bSet=true)
Definition: doc.hxx:1713
IDocumentLinksAdministration const & getIDocumentLinksAdministration() const
Definition: doc.cxx:274
SwNodes & GetNodes()
Definition: doc.hxx:422
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:1376
SfxObjectShell * GetPersist() const
Definition: docnew.cxx:653
::sw::DocumentSettingManager & GetDocumentSettingManager()
Definition: doc.cxx:200
SwDocShell * GetDocShell()
Definition: doc.hxx:1370
general base class for all free-flowing frames
Definition: flyfrm.hxx:79
FlyAnchors.
Definition: fmtanchr.hxx:37
SwNode * GetAnchorNode() const
Definition: atrfrm.cxx:1614
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:88
const SwRect & getFrameArea() const
Definition: frame.hxx:179
Style of a layout element.
Definition: frmfmt.hxx:72
Base class of the Writer layout elements.
Definition: frame.hxx:315
bool IsProtected() const
Is the Frame or rather the Section in which it lies protected?
Definition: trvlfrm.cxx:1639
SwLayoutFrame * GetUpper()
Definition: frame.hxx:684
bool IsFlyFrame() const
Definition: frame.hxx:1216
Layout frame for SwNoTextNode, i.e. graphics and OLE nodes (including charts).
Definition: ndnotxt.hxx:30
void SetContour(const tools::PolyPolygon *pPoly, bool bAutomatic=false)
Definition: ndnotxt.cxx:85
bool HasAutomaticContour() const
Definition: ndnotxt.hxx:77
OUString GetTitle() const
Definition: ndnotxt.cxx:258
const tools::PolyPolygon * HasContour() const
Definition: ndnotxt.cxx:105
void SetTitle(const OUString &rTitle)
Definition: ndnotxt.cxx:245
void SetDescription(const OUString &rDescription)
Definition: ndnotxt.cxx:270
Base class of the Writer document model elements.
Definition: node.hxx:98
SwFrameFormat * GetFlyFormat() const
If node is in a fly return the respective format.
Definition: node.cxx:738
SwNodeOffset GetIndex() const
Definition: node.hxx:312
SwNodes & GetNodes()
Node is in which nodes-array/doc?
Definition: node.hxx:706
SwDoc & GetDoc()
Definition: node.hxx:233
SwSectionNode * FindSectionNode()
Search section node, in which it is.
Definition: ndsect.cxx:968
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:153
const IDocumentLayoutAccess & getIDocumentLayoutAccess() const
Provides access to the document layout interface.
Definition: node.cxx:2143
SwNode & GetEndOfExtras() const
This is the last EndNode of a special section.
Definition: ndarr.hxx:163
SwOLENode * MakeOLENode(SwNode &rWhere, const svt::EmbeddedObjectRef &, SwGrfFormatColl *pColl)
in ndole.cxx
Definition: ndole.cxx:420
SwDoc & GetDoc()
Which Doc contains the nodes-array?
Definition: ndarr.hxx:307
virtual void SAL_CALL disposing(const lang::EventObject &aEvent) override
Definition: ndole.cxx:143
SwOLEObj * mpObj
Definition: ndole.cxx:95
virtual void SAL_CALL stateChanged(const lang::EventObject &aEvent, ::sal_Int32 nOldState, ::sal_Int32 nNewState) override
Definition: ndole.cxx:117
SwOLEListener_Impl(SwOLEObj *pObj)
Definition: ndole.cxx:104
virtual void SAL_CALL changingState(const lang::EventObject &aEvent, ::sal_Int32 nOldState, ::sal_Int32 nNewState) override
Definition: ndole.cxx:113
SwOLENode(SwNode &rWhere, const svt::EmbeddedObjectRef &, SwGrfFormatColl *pGrfColl, SwAttrSet const *pAutoAttr)
Definition: ndole.cxx:254
sfx2::SvBaseLink * mpObjectLink
Definition: ndole.hxx:97
bool IsOLEObjectDeleted() const
Definition: ndole.cxx:544
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:334
void SetChanged()
Definition: ndole.cxx:719
virtual Size GetTwipSize() const override
Definition: ndole.cxx:463
OUString GetDescription() const
Remove OLE-object from "memory".
Definition: ndole.hxx:145
bool IsChart() const
Definition: ndole.cxx:703
bool UpdateLinkURL_Impl()
Definition: ndole.cxx:563
sal_Int64 GetAspect() const
Definition: ndole.hxx:140
const SwOLEObj & GetOLEObj() const
Definition: ndole.hxx:116
SwOLEObj maOLEObj
Definition: ndole.hxx:92
virtual bool SavePersistentData() override
OLE object is transported into UNDO area.
Definition: ndole.cxx:349
virtual bool RestorePersistentData() override
Loading an OLE object that has been moved to the Undo Area.
Definition: ndole.cxx:295
void DisconnectFileLink_Impl()
Definition: ndole.cxx:636
bool IsInGlobalDocSection() const
Definition: ndole.cxx:510
void SetChartTableName(const OUString &rNm)
Definition: ndole.hxx:157
void SetOLESizeInvalid(bool b)
Definition: ndole.hxx:138
const Graphic * GetGraphic()
Definition: ndole.cxx:285
void BreakFileLink_Impl()
Definition: ndole.cxx:613
const OUString & GetChartTableName() const
Definition: ndole.hxx:156
OUString msChartTableName
with chart objects: name of referenced table.
Definition: ndole.hxx:93
void CheckFileLink_Impl()
Definition: ndole.cxx:645
OUString maLinkURL
Definition: ndole.hxx:98
void SetAspect(sal_Int64 nAspect)
Definition: ndole.hxx:141
void GetNewReplacement()
Definition: ndole.cxx:557
virtual ~SwOLENode() override
Definition: ndole.cxx:279
virtual SwContentNode * MakeCopy(SwDoc &, SwNode &rWhere, bool bNewFrames) const override
Is in ndcopy.cxx.
Definition: ndole.cxx:469
svt::EmbeddedObjectRef m_xOLERef
Either ref or name are known.
Definition: ndole.hxx:43
~SwOLEObj() COVERITY_NOEXCEPT_FALSE
Definition: ndole.cxx:866
void resetBufferedData()
Definition: ndole.cxx:1238
void SetNode(SwOLENode *pNode)
Definition: ndole.cxx:931
drawinglayer::primitive2d::Primitive2DContainer const & tryToGetChartContentAsPrimitive2DSequence(basegfx::B2DRange &rRange, bool bSynchron)
Definition: ndole.cxx:1156
sal_uInt32 m_nGraphicVersion
Definition: ndole.hxx:49
svt::EmbeddedObjectRef & GetObject()
Definition: ndole.cxx:1063
std::unique_ptr< DeflateData > m_pDeflateData
Definition: ndole.hxx:50
bool UnloadObject()
Definition: ndole.cxx:1069
bool IsOleRef() const
To avoid unnecessary loading of object.
Definition: ndole.cxx:977
css::uno::Reference< css::embed::XEmbeddedObject > const & GetOleRef()
Definition: ndole.cxx:1012
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: ndole.cxx:1251
OUString GetDescription()
Definition: ndole.cxx:1140
bool IsProtected() const
Definition: ndole.cxx:984
drawinglayer::primitive2d::Primitive2DContainer m_aPrimitive2DSequence
Definition: ndole.hxx:47
OUString m_aName
Definition: ndole.hxx:44
SwOLEObj(const SwOLEObj &rObj)=delete
const OUString & GetCurrentPersistName() const
Definition: ndole.hxx:72
const SwOLENode * m_pOLENode
Definition: ndole.hxx:38
rtl::Reference< SwOLEListener_Impl > m_xListener
Definition: ndole.hxx:39
OUString GetStyleString()
Definition: ndole.cxx:969
basegfx::B2DRange m_aRange
Definition: ndole.hxx:48
Of course Writer needs its own rectangles.
Definition: swrect.hxx:35
void SSize(const Size &rNew)
Definition: swrect.hxx:180
tools::Rectangle SVRect() const
Definition: swrect.hxx:292
A section node represents the start of a section on the UI, i.e.
Definition: node.hxx:575
const SwSection & GetSection() const
Definition: node.hxx:590
SectionType GetType() const
Definition: section.hxx:173
bool isEmpty() const
bool HasEmbeddedObject(const OUString &)
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)
void RemoveEmbeddedObject(const OUString &rName, bool bKeepToTempStorage=true)
css::uno::Reference< css::embed::XEmbeddedObject > GetEmbeddedObject(const OUString &, OUString const *pBaseURL=nullptr)
static ThreadPool & getSharedOptimalPool()
void waitUntilDone(const std::shared_ptr< ThreadTaskTag > &, bool bJoin=true)
void pushTask(std::unique_ptr< ThreadTask > pTask)
static bool isTaskTagDone(const std::shared_ptr< ThreadTaskTag > &)
#define SO3_DUMMY_CLASSID
#define SO3_IFRAME_CLASSID
void InsertFileLink(sfx2::SvBaseLink &, SvBaseLinkObjectType nFileType, std::u16string_view rFileNm, const OUString *pFilterNm=nullptr, const OUString *pRange=nullptr)
static bool GetDisplayNames(const SvBaseLink *, OUString *pType, OUString *pFile=nullptr, OUString *pLink=nullptr, OUString *pFilter=nullptr)
void Remove(SvBaseLink const *pLink)
void AssignToContainer(comphelper::EmbeddedObjectContainer *pContainer, const OUString &rPersistName)
void SetViewAspect(sal_Int64 nAspect)
void SetIsProtectedHdl(const Link< LinkParamNone *, bool > &rProtectedHdl)
sal_uInt32 getGraphicVersion() const
comphelper::EmbeddedObjectContainer * GetContainer() const
void dumpAsXml(xmlTextWriterPtr pWriter) const
static bool TryRunningState(const css::uno::Reference< css::embed::XEmbeddedObject > &)
void UpdateReplacement(bool bUpdateOle=false)
void Lock(bool bLock=true)
const Graphic * GetGraphic() const
sal_Int64 GetViewAspect() const
Size GetSize(MapMode const *pTargetMapMode) const
void Assign(const css::uno::Reference< css::embed::XEmbeddedObject > &xObj, sal_Int64 nAspect)
const css::uno::Reference< css::embed::XEmbeddedObject > & GetObject() const
virtual bool get(DocumentSettingId id) const override
Return the specified document setting.
virtual void set(DocumentSettingId id, bool value) override
Set the specified document setting.
ring_container GetRingContainer()
Definition: ring.hxx:240
void SetSize(const Size &)
virtual void Notify(const css::uno::Sequence< OUString > &aPropertyNames)=0
virtual void ImplCommit()=0
int nCount
struct _xmlTextWriter * xmlTextWriterPtr
sal_Int32 nState
SotClipboardFormatId
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:3254
constexpr TypedWhichId< SwFormatPageDesc > RES_PAGEDESC(99)
void * p
sal_uInt16 nPos
SfxLinkUpdateMode
css::beans::PropertyValue makePropertyValue(const OUString &rName, T &&rValue)
constexpr Point convert(const Point &rPoint, o3tl::Length eFrom, o3tl::Length eTo)
css::uno::Reference< css::linguistic2::XProofreadingIterator > get(css::uno::Reference< css::uno::XComponentContext > const &context)
IMPL_LINK_NOARG(SwOLEObj, IsProtectedHdl, LinkParamNone *, bool)
Definition: ndole.cxx:982
static std::shared_ptr< SwOLELRUCache > g_pOLELRU_Cache
Definition: ndole.cxx:91
SwNodeType
Definition: ndtyp.hxx:28
OUTDEV_WINDOW
OUString m_aName
const char *const aClassID
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:168