LibreOffice Module sw (master) 1
unoobj2.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 <sal/config.h>
21
24#include <o3tl/safeint.hxx>
25#include <svl/listener.hxx>
26#include <svx/svdobj.hxx>
27#include <utility>
28#include <vcl/svapp.hxx>
29
30#include <anchoredobject.hxx>
31#include <swtypes.hxx>
32#include <hintids.hxx>
33#include <IMark.hxx>
34#include <frmfmt.hxx>
35#include <doc.hxx>
36#include <IDocumentUndoRedo.hxx>
39#include <textboxhelper.hxx>
40#include <ndtxt.hxx>
41#include <unocrsr.hxx>
42#include <swundo.hxx>
43#include <rootfrm.hxx>
44#include <ftnidx.hxx>
45#include <pam.hxx>
46#include <swtblfmt.hxx>
47#include <docsh.hxx>
48#include <pagedesc.hxx>
49#include <cntfrm.hxx>
50#include <unoparaframeenum.hxx>
51#include <unofootnote.hxx>
52#include <unotextbodyhf.hxx>
53#include <unotextrange.hxx>
54#include <unoparagraph.hxx>
55#include <unomap.hxx>
56#include <unoport.hxx>
57#include <unocrsrhelper.hxx>
58#include <unotbl.hxx>
59#include <fmtanchr.hxx>
60#include <flypos.hxx>
61#include <txtftn.hxx>
62#include <fmtftn.hxx>
63#include <fmtcntnt.hxx>
64#include <com/sun/star/text/XTextDocument.hpp>
65#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
66#include <unoframe.hxx>
67#include <fmthdft.hxx>
68#include <fmtflcnt.hxx>
69#include <vector>
70#include <sortedobjs.hxx>
71#include <frameformats.hxx>
72#include <algorithm>
73#include <iterator>
74
75using namespace ::com::sun::star;
76
77namespace sw {
78
79void DeepCopyPaM(SwPaM const & rSource, SwPaM & rTarget)
80{
81 rTarget = rSource;
82
83 if (rSource.GetNext() == &rSource)
84 return;
85
86 SwPaM *pPam = const_cast<SwPaM*>(rSource.GetNext());
87 do
88 {
89 // create new PaM
90 SwPaM *const pNew = new SwPaM(*pPam, nullptr);
91 // insert into ring
92 pNew->MoveTo(&rTarget);
93 pPam = pPam->GetNext();
94 }
95 while (pPam != &rSource);
96}
97
98} // namespace sw
99
100namespace {
101
102struct FrameClientSortListLess
103{
104 bool operator() (FrameClientSortListEntry const& r1,
105 FrameClientSortListEntry const& r2) const
106 {
107 return (r1.nIndex < r2.nIndex)
108 || ((r1.nIndex == r2.nIndex) && (r1.nOrder < r2.nOrder));
109 }
110};
111
112 void lcl_CollectFrameAtNodeWithLayout(const SwContentFrame* pCFrame,
113 FrameClientSortList_t& rFrames,
114 const RndStdIds nAnchorType)
115 {
116 auto pObjs = pCFrame->GetDrawObjs();
117 if(!pObjs)
118 return;
119 for(const auto pAnchoredObj : *pObjs)
120 {
121 SwFrameFormat& rFormat = pAnchoredObj->GetFrameFormat();
122 // Filter out textboxes, which are not interesting at a UNO level.
124 continue;
125 if(rFormat.GetAnchor().GetAnchorId() == nAnchorType)
126 {
127 const sal_Int32 nIdx = rFormat.GetAnchor().GetAnchorContentOffset();
128 const auto nOrder = rFormat.GetAnchor().GetOrder();
129 rFrames.emplace_back(nIdx, nOrder, std::make_unique<sw::FrameClient>(&rFormat));
130 }
131 }
132 }
133}
134
135
136void CollectFrameAtNode( const SwNode& rNd,
137 FrameClientSortList_t& rFrames,
138 const bool bAtCharAnchoredObjs )
139{
140 // _bAtCharAnchoredObjs:
141 // <true>: at-character anchored objects are collected
142 // <false>: at-paragraph anchored objects are collected
143
144 // search all borders, images, and OLEs that are connected to the paragraph
145 const SwDoc& rDoc = rNd.GetDoc();
146
147 const auto nChkType = bAtCharAnchoredObjs ? RndStdIds::FLY_AT_CHAR : RndStdIds::FLY_AT_PARA;
148 const SwContentFrame* pCFrame;
149 const SwContentNode* pCNd;
151 nullptr != (pCNd = rNd.GetContentNode()) &&
152 nullptr != (pCFrame = pCNd->getLayoutFrame( rDoc.getIDocumentLayoutAccess().GetCurrentLayout())) )
153 {
154 lcl_CollectFrameAtNodeWithLayout(pCFrame, rFrames, nChkType);
155 }
156 else
157 {
158 const SwFrameFormats& rFormats = *rDoc.GetSpzFrameFormats();
159 const size_t nSize = rFormats.size();
160 for ( size_t i = 0; i < nSize; i++)
161 {
162 const SwFrameFormat* pFormat = rFormats[ i ];
163 const SwFormatAnchor& rAnchor = pFormat->GetAnchor();
164 const SwNode* pAnchorNode;
165 if( rAnchor.GetAnchorId() == nChkType &&
166 nullptr != (pAnchorNode = rAnchor.GetAnchorNode()) &&
167 *pAnchorNode == rNd )
168 {
169
170 // OD 2004-05-07 #i28701# - determine insert position for
171 // sorted <rFrameArr>
172 const sal_Int32 nIndex = rAnchor.GetAnchorContentOffset();
173 sal_uInt32 nOrder = rAnchor.GetOrder();
174
175 rFrames.emplace_back(nIndex, nOrder, std::make_unique<sw::FrameClient>(const_cast<SwFrameFormat*>(pFormat)));
176 }
177 }
178 std::sort(rFrames.begin(), rFrames.end(), FrameClientSortListLess());
179 }
180}
181
183 : m_pDoc(pDoc)
184{
186 if (pRootFrame)
187 {
188 pRootFrame->StartAllAction();
189 }
190}
191
192UnoActionContext::~UnoActionContext() COVERITY_NOEXCEPT_FALSE
193{
194 // Doc may already have been removed here
195 if (m_pDoc)
196 {
198 if (pRootFrame)
199 {
200 pRootFrame->EndAllAction();
201 }
202 }
203}
204
205static void lcl_RemoveImpl(SwDoc *const pDoc)
206{
207 assert(pDoc);
208 SwRootFrame *const pRootFrame = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
209 if (pRootFrame)
210 {
211 pRootFrame->UnoRemoveAllActions();
212 }
213}
214
216 : m_pDoc(pDoc)
217{
219}
220
222{
223 SwTableNode *const pTableNode = rCursor.GetPointNode().FindTableNode();
224 return (pTableNode && !pTableNode->GetTable().IsNewModel())
225 ? &rCursor.GetDoc()
226 : nullptr;
227}
228
230 : m_pDoc(lcl_IsNewStyleTable(rCursor))
231{
232 // this insanity is only necessary for old-style tables
233 // because SwRootFrame::MakeTableCursors() creates the table cursor for these
234 if (m_pDoc)
235 {
237 }
238}
239
241{
242 if (m_pDoc)
243 {
245 if (pRootFrame)
246 {
247 pRootFrame->UnoRestoreAllActions();
248 }
249 }
250}
251
253 const SfxItemSet& rSet,
254 const SetAttrMode nAttrMode, const bool bTableMode)
255{
256 const SetAttrMode nFlags = nAttrMode | SetAttrMode::APICALL;
257 SwDoc& rDoc = rPam.GetDoc();
258 //StartEndAction
259 UnoActionContext aAction(&rDoc);
260 if (rPam.GetNext() != &rPam) // Ring of Cursors
261 {
262 rDoc.GetIDocumentUndoRedo().StartUndo(SwUndoId::INSATTR, nullptr);
263
264 for(SwPaM& rCurrent : rPam.GetRingContainer())
265 {
266 if (rCurrent.HasMark() &&
267 ( bTableMode ||
268 (*rCurrent.GetPoint() != *rCurrent.GetMark()) ))
269 {
270 rDoc.getIDocumentContentOperations().InsertItemSet(rCurrent, rSet, nFlags);
271 }
272 }
273
274 rDoc.GetIDocumentUndoRedo().EndUndo(SwUndoId::INSATTR, nullptr);
275 }
276 else
277 {
278 rDoc.getIDocumentContentOperations().InsertItemSet( rPam, rSet, nFlags );
279 }
280
281 if( rSet.GetItemState( RES_PARATR_OUTLINELEVEL, false ) >= SfxItemState::DEFAULT )
282 {
283 SwTextNode * pTmpNode = rPam.GetPointNode().GetTextNode();
284 if ( pTmpNode )
285 {
286 rPam.GetDoc().GetNodes().UpdateOutlineNode( *pTmpNode );
287 }
288 }
289}
290
291// #i63870#
292// split third parameter <bCurrentAttrOnly> into new parameters <bOnlyTextAttr>
293// and <bGetFromChrFormat> to get better control about resulting <SfxItemSet>
295 SfxItemSet & rSet, const bool bOnlyTextAttr, const bool bGetFromChrFormat)
296{
297 static const sal_uLong nMaxLookup = 1000;
298 SfxItemSet aSet( *rSet.GetPool(), rSet.GetRanges() );
299 SfxItemSet *pSet = &rSet;
300 for(SwPaM& rCurrent : rPam.GetRingContainer())
301 {
302 SwPosition const & rStart( *rCurrent.Start() );
303 SwPosition const & rEnd( *rCurrent.End() );
304 const SwNodeOffset nSttNd = rStart.GetNodeIndex();
305 const SwNodeOffset nEndNd = rEnd .GetNodeIndex();
306
307 if (nEndNd - nSttNd >= SwNodeOffset(nMaxLookup))
308 {
309 rSet.ClearItem();
311 return;// uno::Any();
312 }
313
314 // the first node inserts the values into the get set
315 // all other nodes merge their values into the get set
316 for (SwNodeOffset n = nSttNd; n <= nEndNd; ++n)
317 {
318 SwNode *const pNd = rPam.GetDoc().GetNodes()[ n ];
319 switch (pNd->GetNodeType())
320 {
321 case SwNodeType::Text:
322 {
323 const sal_Int32 nStart = (n == nSttNd)
324 ? rStart.GetContentIndex() : 0;
325 const sal_Int32 nEnd = (n == nEndNd)
326 ? rEnd.GetContentIndex()
327 : pNd->GetTextNode()->GetText().getLength();
328 pNd->GetTextNode()->GetParaAttr(*pSet, nStart, nEnd, bOnlyTextAttr, bGetFromChrFormat);
329 }
330 break;
331
332 case SwNodeType::Grf:
333 case SwNodeType::Ole:
334 static_cast<SwContentNode*>(pNd)->GetAttr( *pSet );
335 break;
336
337 default:
338 continue; // skip this node
339 }
340
341 if (pSet != &rSet)
342 {
343 rSet.MergeValues( aSet );
344 }
345 else
346 {
347 pSet = &aSet;
348 }
349
350 if (aSet.Count())
351 {
352 aSet.ClearItem();
353 }
354 }
355 }
356}
357
358namespace {
359
360struct SwXParagraphEnumerationImpl final : public SwXParagraphEnumeration
361{
362 uno::Reference< text::XText > const m_xParentText;
363 const CursorType m_eCursorType;
367 SwStartNode const*const m_pOwnStartNode;
368 SwTable const*const m_pOwnTable;
369 const SwNodeOffset m_nEndIndex;
370 sal_Int32 m_nFirstParaStart;
371 sal_Int32 m_nLastParaEnd;
372 bool m_bFirstParagraph;
373 uno::Reference< text::XTextContent > m_xNextPara;
374 sw::UnoCursorPointer m_pCursor;
375
376 SwXParagraphEnumerationImpl(
377 uno::Reference< text::XText > xParent,
378 const std::shared_ptr<SwUnoCursor>& pCursor,
379 const CursorType eType,
380 SwStartNode const*const pStartNode, SwTable const*const pTable)
381 : m_xParentText(std::move( xParent ))
382 , m_eCursorType( eType )
383 // remember table and start node for later travelling
384 // (used in export of tables in tables)
385 , m_pOwnStartNode( pStartNode )
386 // for import of tables in tables we have to remember the actual
387 // table and start node of the current position in the enumeration.
388 , m_pOwnTable( pTable )
389 , m_nEndIndex( pCursor->End()->GetNodeIndex() )
390 , m_nFirstParaStart( -1 )
391 , m_nLastParaEnd( -1 )
392 , m_bFirstParagraph( true )
393 , m_pCursor(pCursor)
394 {
395 OSL_ENSURE(m_xParentText.is(), "SwXParagraphEnumeration: no parent?");
396 assert( !((CursorType::SelectionInTable == eType)
397 || (CursorType::TableText == eType))
398 || (m_pOwnTable && m_pOwnStartNode));
399
400 if ((CursorType::Selection == m_eCursorType) ||
401 (CursorType::SelectionInTable == m_eCursorType))
402 {
403 SwUnoCursor & rCursor = GetCursor();
404 rCursor.Normalize();
405 m_nFirstParaStart = rCursor.GetPoint()->GetContentIndex();
406 m_nLastParaEnd = rCursor.GetMark()->GetContentIndex();
407 rCursor.DeleteMark();
408 }
409 }
410
411 virtual ~SwXParagraphEnumerationImpl() override
412 { m_pCursor.reset(nullptr); }
413 virtual void SAL_CALL release() noexcept override
414 {
416 OWeakObject::release();
417 }
418
419 // XServiceInfo
420 virtual OUString SAL_CALL getImplementationName() override
421 { return "SwXParagraphEnumeration"; }
422 virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName) override
423 { return cppu::supportsService(this, rServiceName); };
424 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
425 { return {"com.sun.star.text.ParagraphEnumeration"}; };
426
427 // XEnumeration
428 virtual sal_Bool SAL_CALL hasMoreElements() override;
429 virtual css::uno::Any SAL_CALL nextElement() override;
430
431 SwUnoCursor& GetCursor()
432 { return *m_pCursor; }
436 uno::Reference< text::XTextContent > NextElement_Impl();
437
442 bool IgnoreLastElement(SwUnoCursor& rCursor, bool bMovedFromTable);
443};
444
445}
446
448 uno::Reference< text::XText > const& xParent,
449 const std::shared_ptr<SwUnoCursor>& pCursor,
450 const CursorType eType,
451 SwTableBox const*const pTableBox)
452{
453 SwStartNode const* pStartNode(nullptr);
454 SwTable const* pTable(nullptr);
455 assert((eType == CursorType::TableText) == (pTableBox != nullptr));
456 switch (eType)
457 {
459 {
460 pStartNode = pTableBox->GetSttNd();
461 pTable = & pStartNode->FindTableNode()->GetTable();
462 break;
463 }
465 {
466 SwTableNode const*const pTableNode(
467 pCursor->GetPoint()->GetNode().FindTableNode());
468 pStartNode = pTableNode;
469 pTable = & pTableNode->GetTable();
470 break;
471 }
472 default:
473 break;
474 }
475 return new SwXParagraphEnumerationImpl(xParent, pCursor, eType, pStartNode, pTable);
476}
477
478sal_Bool SAL_CALL
479SwXParagraphEnumerationImpl::hasMoreElements()
480{
481 SolarMutexGuard aGuard;
482 return m_bFirstParagraph || m_xNextPara.is();
483}
484
486static SwTableNode *
488 SwTableNode *const pTableNode, SwTable const*const pOwnTable)
489{
490 // find top-most table in current context (section) level
491
492 SwTableNode * pLast = pTableNode;
493 for (SwTableNode* pTmp = pLast;
494 pTmp != nullptr && &pTmp->GetTable() != pOwnTable; /* we must not go up higher than the own table! */
495 pTmp = pTmp->StartOfSectionNode()->FindTableNode() )
496 {
497 pLast = pTmp;
498 }
499 return pLast;
500}
501
502static bool
504 SwUnoCursor const*const pUnoCursor, SwStartNode const*const pOwnStartNode)
505{
506 // returns true if the cursor is in the section (or in a sub section!)
507 // represented by pOwnStartNode
508
509 bool bRes = true;
510 if (pUnoCursor && pOwnStartNode)
511 {
512 const SwEndNode * pOwnEndNode = pOwnStartNode->EndOfSectionNode();
513 bRes = pOwnStartNode->GetIndex() <= pUnoCursor->Start()->GetNodeIndex() &&
514 pUnoCursor->End()->GetNodeIndex() <= pOwnEndNode->GetIndex();
515 }
516 return bRes;
517}
518
519bool SwXParagraphEnumerationImpl::IgnoreLastElement(SwUnoCursor& rCursor, bool bMovedFromTable)
520{
521 // Ignore the last element of a selection enumeration if this is a stub
522 // paragraph (directly after table, selection ends at paragraph start).
523
524 if (rCursor.Start()->GetNodeIndex() != m_nEndIndex)
525 return false;
526
527 if (m_eCursorType != CursorType::Selection)
528 return false;
529
530 if (!bMovedFromTable)
531 return false;
532
533 return m_nLastParaEnd == 0;
534}
535
536uno::Reference< text::XTextContent >
537SwXParagraphEnumerationImpl::NextElement_Impl()
538{
539 SwUnoCursor& rUnoCursor = GetCursor();
540
541 // check for exceeding selections
542 if (!m_bFirstParagraph &&
543 ((CursorType::Selection == m_eCursorType) ||
544 (CursorType::SelectionInTable == m_eCursorType)))
545 {
546 SwPosition* pStart = rUnoCursor.Start();
547 auto aNewCursor(rUnoCursor.GetDoc().CreateUnoCursor(*pStart));
548 // one may also go into tables here
549 if (CursorType::SelectionInTable != m_eCursorType)
550 {
551 aNewCursor->SetRemainInSection( false );
552 }
553
554 // os 2005-01-14: This part is only necessary to detect movements out
555 // of a selection; if there is no selection we don't have to care
556 SwTableNode *const pTableNode = aNewCursor->GetPointNode().FindTableNode();
557 bool bMovedFromTable = false;
558 if (CursorType::SelectionInTable != m_eCursorType && pTableNode)
559 {
560 aNewCursor->GetPoint()->Assign( pTableNode->EndOfSectionIndex() );
561 aNewCursor->Move(fnMoveForward, GoInNode);
562 bMovedFromTable = true;
563 }
564 else
565 {
566 aNewCursor->MovePara(GoNextPara, fnParaStart);
567 }
568 if (m_nEndIndex < aNewCursor->Start()->GetNodeIndex())
569 {
570 return nullptr;
571 }
572
573 if (IgnoreLastElement(*aNewCursor, bMovedFromTable))
574 {
575 return nullptr;
576 }
577 }
578
579 bool bInTable = false;
580 if (!m_bFirstParagraph)
581 {
582 rUnoCursor.SetRemainInSection( false );
583 // what to do if already in a table?
584 SwTableNode * pTableNode = rUnoCursor.GetPointNode().FindTableNode();
585 pTableNode = lcl_FindTopLevelTable( pTableNode, m_pOwnTable );
586 if (pTableNode && (&pTableNode->GetTable() != m_pOwnTable))
587 {
588 // this is a foreign table: go to end
589 rUnoCursor.GetPoint()->Assign( pTableNode->EndOfSectionIndex() );
590 if (!rUnoCursor.Move(fnMoveForward, GoInNode))
591 {
592 return nullptr;
593 }
594 bInTable = true;
595 }
596 }
597
598 uno::Reference< text::XTextContent > xRef;
599 // the cursor must remain in the current section or a subsection
600 // before AND after the movement...
601 if (lcl_CursorIsInSection( &rUnoCursor, m_pOwnStartNode ) &&
602 (m_bFirstParagraph || bInTable ||
603 (rUnoCursor.MovePara(GoNextPara, fnParaStart) &&
604 lcl_CursorIsInSection( &rUnoCursor, m_pOwnStartNode ))))
605 {
606 if (m_eCursorType == CursorType::Selection || m_eCursorType == CursorType::SelectionInTable)
607 {
608 // This is a selection, check if the cursor would go past the end
609 // of the selection.
610 if (rUnoCursor.Start()->GetNodeIndex() > m_nEndIndex)
611 return nullptr;
612 }
613
614 SwPosition* pStart = rUnoCursor.Start();
615 const sal_Int32 nFirstContent =
616 m_bFirstParagraph ? m_nFirstParaStart : -1;
617 const sal_Int32 nLastContent =
618 (m_nEndIndex == pStart->GetNodeIndex()) ? m_nLastParaEnd : -1;
619
620 // position in a table, or in a simple paragraph?
621 SwTableNode * pTableNode = rUnoCursor.GetPointNode().FindTableNode();
622 pTableNode = lcl_FindTopLevelTable( pTableNode, m_pOwnTable );
623 if (/*CursorType::TableText != eCursorType && CursorType::SelectionInTable != eCursorType && */
624 pTableNode && (&pTableNode->GetTable() != m_pOwnTable))
625 {
626 // this is a foreign table
627 SwFrameFormat* pTableFormat = pTableNode->GetTable().GetFrameFormat();
628 xRef = SwXTextTable::CreateXTextTable(pTableFormat);
629 }
630 else
631 {
632 text::XText *const pText = m_xParentText.get();
633 xRef = SwXParagraph::CreateXParagraph(rUnoCursor.GetDoc(),
634 pStart->GetNode().GetTextNode(),
635 static_cast<SwXText*>(pText), nFirstContent, nLastContent);
636 }
637 }
638
639 return xRef;
640}
641
642uno::Any SAL_CALL SwXParagraphEnumerationImpl::nextElement()
643{
644 SolarMutexGuard aGuard;
645 if (m_bFirstParagraph)
646 {
647 m_xNextPara = NextElement_Impl();
648 m_bFirstParagraph = false;
649 }
650 const uno::Reference< text::XTextContent > xRef = m_xNextPara;
651 if (!xRef.is())
652 {
653 throw container::NoSuchElementException();
654 }
655 m_xNextPara = NextElement_Impl();
656
657 uno::Any aRet;
658 aRet <<= xRef;
659 return aRet;
660}
661
663 : public SvtListener
664{
665public:
669 uno::Reference<text::XText> m_xParentText;
671 const ::sw::mark::IMark* m_pMark;
672
673 Impl(SwDoc& rDoc, const enum RangePosition eRange,
674 SwFrameFormat* const pTableOrSectionFormat,
675 uno::Reference<text::XText> xParent = nullptr)
677 , m_eRangePosition(eRange)
678 , m_rDoc(rDoc)
679 , m_xParentText(std::move(xParent))
680 , m_pTableOrSectionFormat(pTableOrSectionFormat)
681 , m_pMark(nullptr)
682 {
684 {
686 StartListening(pTableOrSectionFormat->GetNotifier());
687 }
688 else
689 {
691 }
692 }
693
694 virtual ~Impl() override
695 {
696 // Impl owns the bookmark; delete it here: SolarMutex is locked
697 Invalidate();
698 }
699
701 {
702 if (m_pMark)
703 {
705 m_pMark = nullptr;
706 }
707 m_pTableOrSectionFormat = nullptr;
709 }
710
711 const ::sw::mark::IMark* GetBookmark() const { return m_pMark; }
713 {
715 m_pTableOrSectionFormat = nullptr;
716 m_pMark = &rMark;
717 StartListening(rMark.GetNotifier());
718 }
719
720protected:
721 virtual void Notify(const SfxHint&) override;
722};
723
725{
726 if(rHint.GetId() == SfxHintId::Dying)
727 {
729 m_pTableOrSectionFormat = nullptr;
730 m_pMark = nullptr;
731 }
732}
733
735 const uno::Reference< text::XText > & xParent,
736 const enum RangePosition eRange)
737 : m_pImpl( new SwXTextRange::Impl(rPam.GetDoc(), eRange, nullptr, xParent) )
738{
739 SetPositions(rPam);
740}
741
743 : m_pImpl(
744 new SwXTextRange::Impl(*rTableFormat.GetDoc(), RANGE_IS_TABLE, &rTableFormat) )
745{
746 SwTable *const pTable = SwTable::FindTable( &rTableFormat );
747 SwTableNode *const pTableNode = pTable->GetTableNode();
748 SwPaM aPam( *pTableNode );
749
750 SetPositions( aPam );
751}
752
754 : m_pImpl(
755 new SwXTextRange::Impl(*rSectionFormat.GetDoc(), RANGE_IS_SECTION, &rSectionFormat) )
756{
757 // no SetPositions here for now
758}
759
761{
762}
763
765{
766 return m_pImpl->m_rDoc;
767}
768
770{
771 return m_pImpl->m_rDoc;
772}
773
775{
776 m_pImpl->Invalidate();
777}
778
780{
781 m_pImpl->Invalidate();
782 IDocumentMarkAccess* const pMA = m_pImpl->m_rDoc.getIDocumentMarkAccess();
784 if (pMark)
785 m_pImpl->SetMark(*pMark);
786}
787
788static void DeleteTable(SwDoc & rDoc, SwTable& rTable)
789{
790 SwSelBoxes aSelBoxes;
791 for (auto& rBox : rTable.GetTabSortBoxes())
792 {
793 aSelBoxes.insert(rBox);
794 }
795 // note: if the table is the content in the section, this will create
796 // a new text node - that's desirable here
798}
799
801 std::u16string_view aText, ::sw::DeleteAndInsertMode const eMode)
802{
803 if (RANGE_IS_TABLE == m_pImpl->m_eRangePosition)
804 {
805 // setString on table not allowed
806 throw uno::RuntimeException("not possible for table");
807 }
808
809 const SwPosition aPos(GetDoc().GetNodes().GetEndOfContent());
810 SwCursor aCursor(aPos, nullptr);
811
812 UnoActionContext aAction(& m_pImpl->m_rDoc);
813
814 if (RANGE_IS_SECTION == m_pImpl->m_eRangePosition)
815 {
816 SwSectionNode const* pSectionNode = m_pImpl->m_pTableOrSectionFormat ?
817 static_cast<SwSectionFormat const*>(m_pImpl->m_pTableOrSectionFormat)->GetSectionNode() :
818 nullptr;
819 if (!pSectionNode)
820 {
821 throw uno::RuntimeException("disposed?");
822 }
823 m_pImpl->m_rDoc.GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT, nullptr);
824 SwNodeIndex const start(*pSectionNode);
825 SwNodeIndex const end(*start.GetNode().EndOfSectionNode());
826
827 // delete tables at start
828 for (SwNodeIndex i = start; i < end; )
829 {
830 SwNode & rNode(i.GetNode());
831 if (rNode.IsSectionNode())
832 {
833 ++i;
834 continue;
835 }
836 else if (SwTableNode *const pTableNode = rNode.GetTableNode())
837 {
838 DeleteTable(m_pImpl->m_rDoc, pTableNode->GetTable());
839 // where does that leave index? presumably behind?
840 }
841 else
842 {
843 assert(rNode.IsTextNode());
844 break;
845 }
846 }
847 // delete tables at end
848 for (SwNodeIndex i = end; start <= i; )
849 {
850 --i;
851 SwNode & rNode(i.GetNode());
852 if (rNode.IsEndNode())
853 {
854 if (SwTableNode *const pTableNode = rNode.StartOfSectionNode()->GetTableNode())
855 {
856 DeleteTable(m_pImpl->m_rDoc, pTableNode->GetTable());
857 }
858 else
859 {
860 assert(rNode.StartOfSectionNode()->IsSectionNode());
861 continue;
862 }
863 }
864 else
865 {
866 assert(rNode.IsTextNode());
867 break;
868 }
869 }
870 // now there should be a text node at the start and end of it!
871 aCursor.GetPoint()->Assign(start);
872 aCursor.Move( fnMoveForward, GoInContent );
873 assert(aCursor.GetPoint()->GetNode() <= end.GetNode());
874 aCursor.SetMark();
875 aCursor.GetPoint()->Assign(end);
876 aCursor.Move( fnMoveBackward, GoInContent );
877 assert(start <= aCursor.GetPoint()->GetNode());
878 }
879 else
880 {
881 if (!GetPositions(aCursor))
882 return;
883 m_pImpl->m_rDoc.GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT, nullptr);
884 }
885
886 if (aCursor.HasMark())
887 {
888 m_pImpl->m_rDoc.getIDocumentContentOperations().DeleteAndJoin(aCursor,
889 (!aText.empty() || eMode & ::sw::DeleteAndInsertMode::ForceReplace) ? SwDeleteFlags::ArtificialSelection : SwDeleteFlags::Default);
890 }
891
892 if (!aText.empty())
893 {
895 m_pImpl->m_rDoc, aCursor, aText, bool(eMode & ::sw::DeleteAndInsertMode::ForceExpandHints));
896
897 SwUnoCursorHelper::SelectPam(aCursor, true);
898 aCursor.Left(aText.size());
899 }
900 SetPositions(aCursor);
901 m_pImpl->m_rDoc.GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT, nullptr);
902}
903
904OUString SAL_CALL
906{
907 return "SwXTextRange";
908}
909
910sal_Bool SAL_CALL SwXTextRange::supportsService(const OUString& rServiceName)
911{
912 return cppu::supportsService(this, rServiceName);
913}
914
915uno::Sequence< OUString > SAL_CALL
917{
918 return {
919 "com.sun.star.text.TextRange",
920 "com.sun.star.style.CharacterProperties",
921 "com.sun.star.style.CharacterPropertiesAsian",
922 "com.sun.star.style.CharacterPropertiesComplex",
923 "com.sun.star.style.ParagraphProperties",
924 "com.sun.star.style.ParagraphPropertiesAsian",
925 "com.sun.star.style.ParagraphPropertiesComplex"
926 };
927}
928
929uno::Reference< text::XText > SAL_CALL
931{
932 SolarMutexGuard aGuard;
933
934 if (!m_pImpl->m_xParentText.is() && m_pImpl->m_pTableOrSectionFormat)
935 {
936 std::optional<SwPosition> oPosition;
937 if (m_pImpl->m_eRangePosition == RANGE_IS_TABLE)
938 {
939 SwTable const*const pTable = SwTable::FindTable( m_pImpl->m_pTableOrSectionFormat );
940 SwTableNode const*const pTableNode = pTable->GetTableNode();
941 oPosition.emplace(*pTableNode);
942 }
943 else
944 {
945 assert(m_pImpl->m_eRangePosition == RANGE_IS_SECTION);
946 auto const pSectFormat(static_cast<SwSectionFormat const*>(m_pImpl->m_pTableOrSectionFormat));
947 oPosition.emplace(pSectFormat->GetContent().GetContentIdx()->GetNode());
948 }
949 m_pImpl->m_xParentText =
950 ::sw::CreateParentXText(m_pImpl->m_rDoc, *oPosition);
951 }
952 OSL_ENSURE(m_pImpl->m_xParentText.is(), "SwXTextRange::getText: no text");
953 return m_pImpl->m_xParentText;
954}
955
956uno::Reference< text::XTextRange > SAL_CALL
958{
959 SolarMutexGuard aGuard;
960
961 uno::Reference< text::XTextRange > xRet;
962 ::sw::mark::IMark const * const pBkmk = m_pImpl->GetBookmark();
963 if (!m_pImpl->m_xParentText.is())
964 {
965 getText();
966 }
967 if(pBkmk)
968 {
969 SwPaM aPam(pBkmk->GetMarkStart());
970 xRet = new SwXTextRange(aPam, m_pImpl->m_xParentText);
971 }
972 else if (RANGE_IS_TABLE == m_pImpl->m_eRangePosition)
973 {
974 // start and end are this, if it's a table
975 xRet = this;
976 }
977 else if (RANGE_IS_SECTION == m_pImpl->m_eRangePosition
978 && m_pImpl->m_pTableOrSectionFormat)
979 {
980 auto const pSectFormat(static_cast<SwSectionFormat const*>(m_pImpl->m_pTableOrSectionFormat));
981 SwPaM aPaM(*pSectFormat->GetContent().GetContentIdx());
983 assert(aPaM.GetPoint()->GetNode() < *pSectFormat->GetContent().GetContentIdx()->GetNode().EndOfSectionNode());
984 xRet = new SwXTextRange(aPaM, m_pImpl->m_xParentText);
985 }
986 else
987 {
988 throw uno::RuntimeException("disposed?");
989 }
990 return xRet;
991}
992
993uno::Reference< text::XTextRange > SAL_CALL
995{
996 SolarMutexGuard aGuard;
997
998 uno::Reference< text::XTextRange > xRet;
999 ::sw::mark::IMark const * const pBkmk = m_pImpl->GetBookmark();
1000 if (!m_pImpl->m_xParentText.is())
1001 {
1002 getText();
1003 }
1004 if(pBkmk)
1005 {
1006 SwPaM aPam(pBkmk->GetMarkEnd());
1007 xRet = new SwXTextRange(aPam, m_pImpl->m_xParentText);
1008 }
1009 else if (RANGE_IS_TABLE == m_pImpl->m_eRangePosition)
1010 {
1011 // start and end are this, if it's a table
1012 xRet = this;
1013 }
1014 else if (RANGE_IS_SECTION == m_pImpl->m_eRangePosition
1015 && m_pImpl->m_pTableOrSectionFormat)
1016 {
1017 auto const pSectFormat(static_cast<SwSectionFormat const*>(m_pImpl->m_pTableOrSectionFormat));
1018 SwPaM aPaM(*pSectFormat->GetContent().GetContentIdx()->GetNode().EndOfSectionNode());
1020 assert(*pSectFormat->GetContent().GetContentIdx() < aPaM.GetPoint()->GetNode());
1021 xRet = new SwXTextRange(aPaM, m_pImpl->m_xParentText);
1022 }
1023 else
1024 {
1025 throw uno::RuntimeException("disposed?");
1026 }
1027 return xRet;
1028}
1029
1030OUString SAL_CALL SwXTextRange::getString()
1031{
1032 SolarMutexGuard aGuard;
1033
1034 OUString sRet;
1035 // for tables there is no bookmark, thus also no text
1036 // one could export the table as ASCII here maybe?
1037 SwPaM aPaM(GetDoc().GetNodes());
1039 {
1041 }
1042 return sRet;
1043}
1044
1045void SAL_CALL SwXTextRange::setString(const OUString& rString)
1046{
1047 SolarMutexGuard aGuard;
1048
1050}
1051
1053{
1054 if (RANGE_IS_SECTION == m_pImpl->m_eRangePosition
1055 && eMode == ::sw::TextRangeMode::AllowNonTextNode)
1056 {
1057 if (auto const pSectFormat = static_cast<SwSectionFormat const*>(m_pImpl->m_pTableOrSectionFormat))
1058 {
1059 SwNodeIndex const*const pSectionNode(pSectFormat->GetContent().GetContentIdx());
1060 assert(pSectionNode);
1061 assert(pSectionNode->GetNodes().IsDocNodes());
1062 rToFill.GetPoint()->Assign( pSectionNode->GetNode(), SwNodeOffset(1) );
1063 rToFill.SetMark();
1064 rToFill.GetMark()->Assign( *pSectionNode->GetNode().EndOfSectionNode(), SwNodeOffset(-1) );
1065 if (const SwContentNode* pCNd = rToFill.GetMark()->GetContentNode())
1066 rToFill.GetMark()->AssignEndIndex(*pCNd);
1067 return true;
1068 }
1069 }
1070 ::sw::mark::IMark const * const pBkmk = m_pImpl->GetBookmark();
1071 if(pBkmk)
1072 {
1073 *rToFill.GetPoint() = pBkmk->GetMarkPos();
1074 if(pBkmk->IsExpanded())
1075 {
1076 rToFill.SetMark();
1077 *rToFill.GetMark() = pBkmk->GetOtherMarkPos();
1078 }
1079 else
1080 {
1081 rToFill.DeleteMark();
1082 }
1083 return true;
1084 }
1085 return false;
1086}
1087
1088namespace sw {
1089
1091 const uno::Reference<text::XTextRange> & xTextRange,
1092 ::sw::TextRangeMode const eMode)
1093{
1094 bool bRet = false;
1095
1096 SwXTextRange* pRange = dynamic_cast<SwXTextRange*>(xTextRange.get());
1097 OTextCursorHelper* pCursor = dynamic_cast<OTextCursorHelper*>(xTextRange.get());
1098 SwXTextPortion* pPortion = dynamic_cast<SwXTextPortion*>(xTextRange.get());
1099 SwXText* pText = dynamic_cast<SwXText*>(xTextRange.get());
1100 SwXParagraph* pPara = dynamic_cast<SwXParagraph*>(xTextRange.get());
1101 SwXHeadFootText* pHeadText
1102 = eMode == TextRangeMode::AllowTableNode ? dynamic_cast<SwXHeadFootText*>(pText) : nullptr;
1103
1104 // if it's a text then create a temporary cursor there and re-use
1105 // the pCursor variable
1106 // #i108489#: Reference in outside scope to keep cursor alive
1107 uno::Reference< text::XTextCursor > xTextCursor;
1108 if (pHeadText)
1109 {
1110 // if it is a header / footer text, and eMode == TextRangeMode::AllowTableNode
1111 // then set the cursor to the beginning of the text
1112 // if it is started with a table then set into the table
1113 xTextCursor.set(pHeadText->CreateTextCursor(true));
1114 xTextCursor->gotoEnd(true);
1115 pCursor = dynamic_cast<OTextCursorHelper*>(xTextCursor.get());
1116 assert(pCursor && "cant must succeed");
1117 pCursor->GetPaM()->Normalize();
1118 }
1119 else
1120 if (pText)
1121 {
1122 xTextCursor.set( pText->CreateCursor() );
1123 xTextCursor->gotoEnd(true);
1124 pCursor = dynamic_cast<OTextCursorHelper*>(xTextCursor.get());
1125 assert(pCursor && "cant must succeed");
1126 }
1127 if(pRange && &pRange->GetDoc() == &rToFill.GetDoc())
1128 {
1129 bRet = pRange->GetPositions(rToFill, eMode);
1130 }
1131 else
1132 {
1133 if (pPara)
1134 {
1135 bRet = pPara->SelectPaM(rToFill);
1136 }
1137 else
1138 {
1139 SwDoc* const pDoc = pCursor ? pCursor->GetDoc()
1140 : (pPortion ? &pPortion->GetCursor().GetDoc() : nullptr);
1141 const SwPaM* const pUnoCursor = pCursor ? pCursor->GetPaM()
1142 : (pPortion ? &pPortion->GetCursor() : nullptr);
1143 if (pUnoCursor && pDoc == &rToFill.GetDoc())
1144 {
1145 OSL_ENSURE(!pUnoCursor->IsMultiSelection(),
1146 "what to do about rings?");
1147 bRet = true;
1148 *rToFill.GetPoint() = *pUnoCursor->GetPoint();
1149 if (pUnoCursor->HasMark())
1150 {
1151 rToFill.SetMark();
1152 *rToFill.GetMark() = *pUnoCursor->GetMark();
1153 }
1154 else
1155 rToFill.DeleteMark();
1156 }
1157 }
1158 }
1159 return bRet;
1160}
1161
1162static bool
1163lcl_IsStartNodeInFormat(const bool bHeader, SwStartNode const *const pSttNode,
1164 SwFrameFormat const*const pFrameFormat, SwFrameFormat*& rpFormat)
1165{
1166 bool bRet = false;
1167 const SfxItemSet& rSet = pFrameFormat->GetAttrSet();
1168 const SfxPoolItem* pItem;
1169 if (SfxItemState::SET == rSet.GetItemState(
1170 bHeader ? sal_uInt16(RES_HEADER) : sal_uInt16(RES_FOOTER),
1171 true, &pItem))
1172 {
1173 SfxPoolItem *const pItemNonConst(const_cast<SfxPoolItem *>(pItem));
1174 SwFrameFormat *const pHeadFootFormat = bHeader ?
1175 static_cast<SwFormatHeader*>(pItemNonConst)->GetHeaderFormat() :
1176 static_cast<SwFormatFooter*>(pItemNonConst)->GetFooterFormat();
1177 if (pHeadFootFormat)
1178 {
1179 const SwFormatContent& rFlyContent = pHeadFootFormat->GetContent();
1180 // tdf#146248 avoid Undo crash at shared first page
1181 if ( !rFlyContent.GetContentIdx() )
1182 return false;
1183 const SwNode& rNode = rFlyContent.GetContentIdx()->GetNode();
1184 SwStartNode const*const pCurSttNode = rNode.FindSttNodeByType(
1186 if (pCurSttNode && (pCurSttNode == pSttNode))
1187 {
1188 rpFormat = pHeadFootFormat;
1189 bRet = true;
1190 }
1191 }
1192 }
1193 return bRet;
1194}
1195
1196} // namespace sw
1197
1200 SwDoc & rDoc, const SwPosition& rPos, const SwPosition *const pMark)
1201{
1202 const uno::Reference<text::XText> xParentText(
1203 ::sw::CreateParentXText(rDoc, rPos));
1204 const auto pNewCursor(rDoc.CreateUnoCursor(rPos));
1205 if(pMark)
1206 {
1207 pNewCursor->SetMark();
1208 *pNewCursor->GetMark() = *pMark;
1209 }
1210 const bool isCell( dynamic_cast<SwXCell*>(xParentText.get()) );
1211 return new SwXTextRange(*pNewCursor, xParentText,
1212 isCell ? RANGE_IN_CELL : RANGE_IN_TEXT);
1213}
1214
1215namespace sw {
1216
1217uno::Reference< text::XText >
1219{
1220 uno::Reference< text::XText > xParentText;
1221 SwStartNode* pSttNode = rPos.GetNode().StartOfSectionNode();
1222 while(pSttNode && pSttNode->IsSectionNode())
1223 {
1224 pSttNode = pSttNode->StartOfSectionNode();
1225 }
1226 SwStartNodeType eType = pSttNode ? pSttNode->GetStartNodeType() : SwNormalStartNode;
1227 switch(eType)
1228 {
1230 {
1231 SwTableNode const*const pTableNode = pSttNode->FindTableNode();
1232 SwFrameFormat *const pTableFormat =
1233 pTableNode->GetTable().GetFrameFormat();
1234 SwTableBox *const pBox = pSttNode->GetTableBox();
1235
1236 xParentText = pBox
1237 ? SwXCell::CreateXCell( pTableFormat, pBox )
1238 : new SwXCell( pTableFormat, *pSttNode );
1239 }
1240 break;
1241 case SwFlyStartNode:
1242 {
1243 SwFrameFormat *const pFormat = pSttNode->GetFlyFormat();
1244 if (nullptr != pFormat)
1245 {
1246 xParentText = SwXTextFrame::CreateXTextFrame(rDoc, pFormat);
1247 }
1248 }
1249 break;
1250 case SwHeaderStartNode:
1251 case SwFooterStartNode:
1252 {
1253 const bool bHeader = (SwHeaderStartNode == eType);
1254 const size_t nPDescCount = rDoc.GetPageDescCnt();
1255 for(size_t i = 0; i < nPDescCount; i++)
1256 {
1257 const SwPageDesc& rDesc = rDoc.GetPageDesc( i );
1258
1259 const SwFrameFormat* pFrameFormatMaster = &rDesc.GetMaster();
1260 const SwFrameFormat* pFrameFormatLeft = &rDesc.GetLeft();
1261 const SwFrameFormat* pFrameFormatFirstMaster = &rDesc.GetFirstMaster();
1262 const SwFrameFormat* pFrameFormatFirstLeft = &rDesc.GetFirstLeft();
1263
1264 SwFrameFormat* pHeadFootFormat = nullptr;
1265 if (!lcl_IsStartNodeInFormat(bHeader, pSttNode, pFrameFormatMaster,
1266 pHeadFootFormat))
1267 {
1268 if (!lcl_IsStartNodeInFormat(bHeader, pSttNode, pFrameFormatLeft,
1269 pHeadFootFormat))
1270 {
1271 if (!lcl_IsStartNodeInFormat(bHeader, pSttNode, pFrameFormatFirstMaster,
1272 pHeadFootFormat))
1273 {
1274 lcl_IsStartNodeInFormat(bHeader, pSttNode, pFrameFormatFirstLeft, pHeadFootFormat);
1275 }
1276 }
1277 }
1278
1279 if (pHeadFootFormat)
1280 {
1282 *pHeadFootFormat, bHeader);
1283 }
1284 }
1285 }
1286 break;
1288 {
1289 const size_t nFootnoteCnt = rDoc.GetFootnoteIdxs().size();
1290 for (size_t n = 0; n < nFootnoteCnt; ++n )
1291 {
1292 const SwTextFootnote* pTextFootnote = rDoc.GetFootnoteIdxs()[ n ];
1293 const SwFormatFootnote& rFootnote = pTextFootnote->GetFootnote();
1294 pTextFootnote = rFootnote.GetTextFootnote();
1295
1296 if (pSttNode == pTextFootnote->GetStartNode()->GetNode().
1297 FindSttNodeByType(SwFootnoteStartNode))
1298 {
1299 xParentText.set(SwXFootnote::CreateXFootnote(rDoc,
1300 &const_cast<SwFormatFootnote&>(rFootnote)));
1301 break;
1302 }
1303 }
1304 }
1305 break;
1306 default:
1307 {
1308 // then it is the body text
1309 const uno::Reference<frame::XModel> xModel =
1310 rDoc.GetDocShell()->GetBaseModel();
1311 const uno::Reference< text::XTextDocument > xDoc(
1312 xModel, uno::UNO_QUERY);
1313 xParentText = xDoc->getText();
1314 }
1315 }
1316 OSL_ENSURE(xParentText.is(), "no parent text?");
1317 return xParentText;
1318}
1319
1320} // namespace sw
1321
1322uno::Reference< container::XEnumeration > SAL_CALL
1323SwXTextRange::createContentEnumeration(const OUString& rServiceName)
1324{
1326
1327 if ( rServiceName != "com.sun.star.text.TextContent" )
1328 {
1329 throw uno::RuntimeException("unsupported service");
1330 }
1331
1332 if (!m_pImpl->GetBookmark())
1333 {
1334 throw uno::RuntimeException("range has no mark (table?)");
1335 }
1336 const SwPosition aPos(GetDoc().GetNodes().GetEndOfContent());
1337 const auto pNewCursor(m_pImpl->m_rDoc.CreateUnoCursor(aPos));
1338 if (!GetPositions(*pNewCursor))
1339 {
1340 throw uno::RuntimeException("range has no positions");
1341 }
1342
1344}
1345
1346uno::Reference< container::XEnumeration > SAL_CALL
1348{
1350
1351 if (!m_pImpl->GetBookmark())
1352 {
1353 throw uno::RuntimeException("range has no mark (table?)");
1354 }
1355 const SwPosition aPos(GetDoc().GetNodes().GetEndOfContent());
1356 auto pNewCursor(m_pImpl->m_rDoc.CreateUnoCursor(aPos));
1357 if (!GetPositions(*pNewCursor))
1358 {
1359 throw uno::RuntimeException("range has no positions");
1360 }
1361 if (!m_pImpl->m_xParentText.is())
1362 {
1363 getText();
1364 }
1365
1366 const CursorType eSetType = (RANGE_IN_CELL == m_pImpl->m_eRangePosition)
1368 return SwXParagraphEnumeration::Create(m_pImpl->m_xParentText, pNewCursor, eSetType);
1369}
1370
1372{
1374}
1375
1377{
1378 return true;
1379}
1380
1381uno::Sequence< OUString > SAL_CALL
1383{
1384 uno::Sequence<OUString> aRet { "com.sun.star.text.TextContent" };
1385 return aRet;
1386}
1387
1388uno::Reference< beans::XPropertySetInfo > SAL_CALL
1390{
1391 SolarMutexGuard aGuard;
1392
1393 static uno::Reference< beans::XPropertySetInfo > xRef =
1394 m_pImpl->m_rPropSet.getPropertySetInfo();
1395 return xRef;
1396}
1397
1398void SAL_CALL
1400 const OUString& rPropertyName, const uno::Any& rValue)
1401{
1402 SolarMutexGuard aGuard;
1403
1404 if (!m_pImpl->GetBookmark())
1405 {
1406 throw uno::RuntimeException("range has no mark (table?)");
1407 }
1408 SwPaM aPaM(GetDoc().GetNodes());
1409 GetPositions(aPaM);
1411 rPropertyName, rValue);
1412}
1413
1414uno::Any SAL_CALL
1415SwXTextRange::getPropertyValue(const OUString& rPropertyName)
1416{
1417 SolarMutexGuard aGuard;
1418
1419 if (!m_pImpl->GetBookmark())
1420 {
1421 throw uno::RuntimeException("range has no mark (table?)");
1422 }
1423 SwPaM aPaM(GetDoc().GetNodes());
1424 GetPositions(aPaM);
1425 return SwUnoCursorHelper::GetPropertyValue(aPaM, m_pImpl->m_rPropSet,
1426 rPropertyName);
1427}
1428
1429void SAL_CALL
1431 const OUString& /*rPropertyName*/,
1432 const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
1433{
1434 OSL_FAIL("SwXTextRange::addPropertyChangeListener(): not implemented");
1435}
1436
1437void SAL_CALL
1439 const OUString& /*rPropertyName*/,
1440 const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
1441{
1442 OSL_FAIL("SwXTextRange::removePropertyChangeListener(): not implemented");
1443}
1444
1445void SAL_CALL
1447 const OUString& /*rPropertyName*/,
1448 const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
1449{
1450 OSL_FAIL("SwXTextRange::addVetoableChangeListener(): not implemented");
1451}
1452
1453void SAL_CALL
1455 const OUString& /*rPropertyName*/,
1456 const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
1457{
1458 OSL_FAIL("SwXTextRange::removeVetoableChangeListener(): not implemented");
1459}
1460
1461beans::PropertyState SAL_CALL
1462SwXTextRange::getPropertyState(const OUString& rPropertyName)
1463{
1464 SolarMutexGuard aGuard;
1465
1466 if (!m_pImpl->GetBookmark())
1467 {
1468 throw uno::RuntimeException("range has no mark (table?)");
1469 }
1470 SwPaM aPaM(GetDoc().GetNodes());
1471 GetPositions(aPaM);
1472 return SwUnoCursorHelper::GetPropertyState(aPaM, m_pImpl->m_rPropSet,
1473 rPropertyName);
1474}
1475
1476uno::Sequence< beans::PropertyState > SAL_CALL
1477SwXTextRange::getPropertyStates(const uno::Sequence< OUString >& rPropertyName)
1478{
1480
1481 if (!m_pImpl->GetBookmark())
1482 {
1483 throw uno::RuntimeException("range has no mark (table?)");
1484 }
1485 SwPaM aPaM(GetDoc().GetNodes());
1486 GetPositions(aPaM);
1487 return SwUnoCursorHelper::GetPropertyStates(aPaM, m_pImpl->m_rPropSet,
1488 rPropertyName);
1489}
1490
1491void SAL_CALL SwXTextRange::setPropertyToDefault(const OUString& rPropertyName)
1492{
1493 SolarMutexGuard aGuard;
1494
1495 if (!m_pImpl->GetBookmark())
1496 {
1497 throw uno::RuntimeException("range has no mark (table?)");
1498 }
1499 SwPaM aPaM(GetDoc().GetNodes());
1500 GetPositions(aPaM);
1502 rPropertyName);
1503}
1504
1505uno::Any SAL_CALL
1506SwXTextRange::getPropertyDefault(const OUString& rPropertyName)
1507{
1508 SolarMutexGuard aGuard;
1509
1510 if (!m_pImpl->GetBookmark())
1511 {
1512 throw uno::RuntimeException("range has no mark (table?)");
1513 }
1514 SwPaM aPaM(GetDoc().GetNodes());
1515 GetPositions(aPaM);
1516 return SwUnoCursorHelper::GetPropertyDefault(aPaM, m_pImpl->m_rPropSet,
1517 rPropertyName);
1518}
1519
1520void SAL_CALL
1522 const OUString& rRedlineType,
1523 const uno::Sequence< beans::PropertyValue >& rRedlineProperties )
1524{
1525 SolarMutexGuard aGuard;
1526
1527 if (!m_pImpl->GetBookmark())
1528 {
1529 throw uno::RuntimeException("range has no mark (table?)");
1530 }
1531 SwPaM aPaM(GetDoc().GetNodes());
1533 SwUnoCursorHelper::makeRedline( aPaM, rRedlineType, rRedlineProperties );
1534}
1535
1536namespace {
1537
1538struct SwXTextRangesImpl final : public SwXTextRanges
1539{
1540
1541 // XServiceInfo
1542 virtual OUString SAL_CALL getImplementationName() override
1543 { return "SwXTextRanges"; };
1544 virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName) override
1545 { return cppu::supportsService(this, rServiceName); };
1546 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
1547 { return { "com.sun.star.text.TextRanges" }; };
1548
1549 // XElementAccess
1550 virtual css::uno::Type SAL_CALL getElementType() override
1552 virtual sal_Bool SAL_CALL hasElements() override
1553 { return getCount() > 0; };
1554 // XIndexAccess
1555 virtual sal_Int32 SAL_CALL getCount() override;
1556 virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override;
1557
1558 explicit SwXTextRangesImpl(SwPaM *const pPaM)
1559 {
1560 if (pPaM)
1561 {
1562 m_pUnoCursor.reset(pPaM->GetDoc().CreateUnoCursor(*pPaM->GetPoint()));
1563 ::sw::DeepCopyPaM(*pPaM, *GetCursor());
1564 }
1565 MakeRanges();
1566 }
1567 virtual void SAL_CALL release() noexcept override
1568 {
1570 OWeakObject::release();
1571 }
1572 virtual SwUnoCursor* GetCursor() override
1573 { return &(*m_pUnoCursor); };
1574 void MakeRanges();
1575 std::vector< rtl::Reference<SwXTextRange> > m_Ranges;
1576 sw::UnoCursorPointer m_pUnoCursor;
1577};
1578
1579}
1580
1581void SwXTextRangesImpl::MakeRanges()
1582{
1583 if (!GetCursor())
1584 return;
1585
1586 for(SwPaM& rTmpCursor : GetCursor()->GetRingContainer())
1587 {
1588 const rtl::Reference<SwXTextRange> xRange(
1590 rTmpCursor.GetDoc(),
1591 *rTmpCursor.GetPoint(), rTmpCursor.GetMark()));
1592 if (xRange.is())
1593 {
1594 m_Ranges.push_back(xRange);
1595 }
1596 }
1597}
1598
1600 { return new SwXTextRangesImpl(pPaM); }
1601
1602/*
1603 * Text positions
1604 * Up to the first access to a text position, only a SwCursor is stored.
1605 * Afterwards, an array with uno::Reference<XTextPosition> will be created.
1606 */
1607
1608sal_Int32 SAL_CALL SwXTextRangesImpl::getCount()
1609{
1610 SolarMutexGuard aGuard;
1611 return static_cast<sal_Int32>(m_Ranges.size());
1612}
1613
1614uno::Any SAL_CALL SwXTextRangesImpl::getByIndex(sal_Int32 nIndex)
1615{
1616 SolarMutexGuard aGuard;
1617 if ((nIndex < 0) || (o3tl::make_unsigned(nIndex) >= m_Ranges.size()))
1618 throw lang::IndexOutOfBoundsException();
1619 uno::Any ret(uno::Reference<text::XTextRange>(m_Ranges.at(nIndex)));
1620 return ret;
1621}
1622
1623void SwUnoCursorHelper::SetString(SwCursor & rCursor, std::u16string_view aString)
1624{
1625 // Start/EndAction
1626 SwDoc& rDoc = rCursor.GetDoc();
1627 UnoActionContext aAction(&rDoc);
1628 rDoc.GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT, nullptr);
1629 if (rCursor.HasMark())
1630 {
1632 }
1633 if (!aString.empty())
1634 {
1635 const bool bSuccess( SwUnoCursorHelper::DocInsertStringSplitCR(
1636 rDoc, rCursor, aString, false ) );
1637 OSL_ENSURE( bSuccess, "DocInsertStringSplitCR" );
1638 SwUnoCursorHelper::SelectPam(rCursor, true);
1639 rCursor.Left(aString.size());
1640 }
1641 rDoc.GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT, nullptr);
1642}
1643
1644namespace {
1645
1646struct SwXParaFrameEnumerationImpl final : public SwXParaFrameEnumeration
1647{
1648 // XServiceInfo
1649 virtual OUString SAL_CALL getImplementationName() override
1650 { return "SwXParaFrameEnumeration"; };
1651 virtual sal_Bool SAL_CALL supportsService(const OUString& rServiceName) override
1652 { return cppu::supportsService(this, rServiceName); };
1653 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
1654 { return {"com.sun.star.util.ContentEnumeration"}; };
1655
1656 // XEnumeration
1657 virtual sal_Bool SAL_CALL hasMoreElements() override;
1658 virtual css::uno::Any SAL_CALL nextElement() override;
1659
1660 SwXParaFrameEnumerationImpl(const SwPaM& rPaM, const enum ParaFrameMode eParaFrameMode, SwFrameFormat* const pFormat);
1661 virtual void SAL_CALL release() noexcept override
1662 {
1664 OWeakObject::release();
1665 }
1666 SwUnoCursor& GetCursor()
1667 { return *m_pUnoCursor; }
1668 void PurgeFrameClients()
1669 {
1670 if(!m_pUnoCursor)
1671 {
1672 m_vFrames.clear();
1673 m_xNextObject = nullptr;
1674 }
1675 else
1676 {
1677 // removing orphaned Clients
1678 const auto iter = std::remove_if(m_vFrames.begin(), m_vFrames.end(),
1679 [] (std::unique_ptr<sw::FrameClient>& rEntry) -> bool { return !rEntry->GetRegisteredIn(); });
1680 m_vFrames.erase(iter, m_vFrames.end());
1681 }
1682 }
1683 void FillFrame();
1684 bool CreateNextObject();
1685 uno::Reference< text::XTextContent > m_xNextObject;
1686 std::deque< std::unique_ptr<sw::FrameClient> > m_vFrames;
1687 ::sw::UnoCursorPointer m_pUnoCursor;
1688};
1689
1690}
1691
1693 { return new SwXParaFrameEnumerationImpl(rPaM, eParaFrameMode, pFormat); }
1694
1695SwXParaFrameEnumerationImpl::SwXParaFrameEnumerationImpl(
1696 const SwPaM& rPaM, const enum ParaFrameMode eParaFrameMode,
1697 SwFrameFormat* const pFormat)
1698 : m_pUnoCursor(rPaM.GetDoc().CreateUnoCursor(*rPaM.GetPoint()))
1699{
1700 if (rPaM.HasMark())
1701 {
1702 GetCursor().SetMark();
1703 *GetCursor().GetMark() = *rPaM.GetMark();
1704 }
1705 if (PARAFRAME_PORTION_PARAGRAPH == eParaFrameMode)
1706 {
1707 FrameClientSortList_t vFrames;
1708 ::CollectFrameAtNode(rPaM.GetPoint()->GetNode(), vFrames, false);
1709 std::transform(vFrames.begin(), vFrames.end(),
1710 std::back_inserter(m_vFrames),
1711 [] (FrameClientSortListEntry& rEntry) { return std::move(rEntry.pFrameClient); });
1712 }
1713 else if (pFormat)
1714 {
1715 m_vFrames.push_back(std::make_unique<sw::FrameClient>(pFormat));
1716 }
1717 else if ((PARAFRAME_PORTION_CHAR == eParaFrameMode) ||
1718 (PARAFRAME_PORTION_TEXTRANGE == eParaFrameMode))
1719 {
1720 if (PARAFRAME_PORTION_TEXTRANGE == eParaFrameMode)
1721 {
1722 //get all frames that are bound at paragraph or at character
1723 for(const SwPosFlyFrame& rFlyFrame : rPaM.GetDoc().GetAllFlyFormats(&GetCursor(), false, true))
1724 {
1725 const auto pFrameFormat = const_cast<SwFrameFormat*>(&rFlyFrame.GetFormat());
1726 m_vFrames.push_back(std::make_unique<sw::FrameClient>(pFrameFormat));
1727 }
1728 }
1729 FillFrame();
1730 }
1731}
1732
1733// Search for a FLYCNT text attribute at the cursor point and fill the frame
1734// into the array
1735void SwXParaFrameEnumerationImpl::FillFrame()
1736{
1737 if(!m_pUnoCursor->GetPointNode().IsTextNode())
1738 return;
1739 // search for objects at the cursor - anchored at/as char
1740 const auto pTextAttr = m_pUnoCursor->GetPointNode().GetTextNode()->GetTextAttrForCharAt(
1741 m_pUnoCursor->GetPoint()->GetContentIndex(), RES_TXTATR_FLYCNT);
1742 if(!pTextAttr)
1743 return;
1744 const SwFormatFlyCnt& rFlyCnt = pTextAttr->GetFlyCnt();
1745 SwFrameFormat* const pFrameFormat = rFlyCnt.GetFrameFormat();
1746 m_vFrames.push_back(std::make_unique<sw::FrameClient>(pFrameFormat));
1747}
1748
1749bool SwXParaFrameEnumerationImpl::CreateNextObject()
1750{
1751 if (m_vFrames.empty())
1752 return false;
1753
1754 SwFrameFormat* const pFormat = static_cast<SwFrameFormat*>(
1755 m_vFrames.front()->GetRegisteredIn());
1756 m_vFrames.pop_front();
1757 // the format should be valid here, otherwise the client
1758 // would have been removed by PurgeFrameClients
1759 // check for a shape first
1760 if(pFormat->Which() == RES_DRAWFRMFMT)
1761 {
1762 SdrObject* pObject(nullptr);
1763 pFormat->CallSwClientNotify(sw::FindSdrObjectHint(pObject));
1764 if(pObject)
1765 m_xNextObject.set(pObject->getUnoShape(), uno::UNO_QUERY);
1766 }
1767 else
1768 {
1769 const SwNodeIndex* pIdx = pFormat->GetContent().GetContentIdx();
1770 OSL_ENSURE(pIdx, "where is the index?");
1771 SwNode const*const pNd =
1772 m_pUnoCursor->GetDoc().GetNodes()[ pIdx->GetIndex() + 1 ];
1773
1774 if (!pNd->IsNoTextNode())
1775 {
1776 m_xNextObject = static_cast<SwXFrame*>(SwXTextFrame::CreateXTextFrame(
1777 *pFormat->GetDoc(), pFormat).get());
1778 }
1779 else if (pNd->IsGrfNode())
1780 {
1782 *pFormat->GetDoc(), pFormat));
1783 }
1784 else
1785 {
1786 assert(pNd->IsOLENode());
1788 *pFormat->GetDoc(), pFormat));
1789 }
1790 }
1791 return m_xNextObject.is();
1792}
1793
1794sal_Bool SAL_CALL
1795SwXParaFrameEnumerationImpl::hasMoreElements()
1796{
1797 SolarMutexGuard aGuard;
1798 PurgeFrameClients();
1799 return m_xNextObject.is() || CreateNextObject();
1800}
1801
1802uno::Any SAL_CALL SwXParaFrameEnumerationImpl::nextElement()
1803{
1804 SolarMutexGuard aGuard;
1805 PurgeFrameClients();
1806 if (!m_xNextObject.is() && !m_vFrames.empty())
1807 CreateNextObject();
1808 if (!m_xNextObject.is())
1809 throw container::NoSuchElementException();
1810 uno::Any aRet;
1811 aRet <<= m_xNextObject;
1812 m_xNextObject = nullptr;
1813 return aRet;
1814}
1815
1816/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
@ ArtificialSelection
keyboard delete, artificial selection, avoid deleting flys
::std::unique_ptr< XmlIdRegistry_Impl > m_pImpl
virtual bool DeleteAndJoin(SwPaM &, SwDeleteFlags flags=SwDeleteFlags::Default)=0
complete delete of a given PaM
virtual void InsertItemSet(const SwPaM &rRg, const SfxItemSet &, const SetAttrMode nFlags=SetAttrMode::DEFAULT, SwRootFrame const *pLayout=nullptr)=0
virtual const SwRootFrame * GetCurrentLayout() const =0
virtual const SwViewShell * GetCurrentViewShell() const =0
Returns the layout set at the document.
Provides access to the marks of a document.
virtual ::sw::mark::IMark * makeMark(const SwPaM &rPaM, const OUString &rProposedName, MarkType eMark, ::sw::mark::InsertMode eMode, SwPosition const *pSepPos=nullptr)=0
Generates a new mark in the document for a certain selection.
virtual std::unique_ptr< ILazyDeleter > deleteMark(const IDocumentMarkAccess::const_iterator_t &ppMark, bool isMoveNodes)=0
Deletes a mark.
SfxHintId GetId() const
void MergeValues(const SfxItemSet &rSet)
const WhichRangesContainer & GetRanges() const
SfxItemPool * GetPool() const
sal_uInt16 Count() const
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
void InvalidateAllItems()
SfxItemState GetItemState(sal_uInt16 nWhich, bool bSrchInParent=true, const SfxPoolItem **ppItem=nullptr) const
css::uno::Reference< css::frame::XModel3 > GetBaseModel() const
void EndListeningAll()
bool StartListening(SvtBroadcaster &rBroadcaster)
SwContentFrame is the layout for content nodes: a common base class for text (paragraph) and non-text...
Definition: cntfrm.hxx:58
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1230
bool Left(sal_uInt16 nCnt)
Definition: swcrsr.hxx:172
bool MovePara(SwWhichPara, SwMoveFnCollection const &)
Definition: swcrsr.cxx:2287
Definition: doc.hxx:195
size_t GetPageDescCnt() const
Definition: doc.hxx:889
IDocumentContentOperations const & getIDocumentContentOperations() const
Definition: doc.cxx:323
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:152
SwNodes & GetNodes()
Definition: doc.hxx:418
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:413
SwFootnoteIdxs & GetFootnoteIdxs()
Definition: doc.hxx:643
IDocumentMarkAccess * getIDocumentMarkAccess()
Definition: docbm.cxx:1872
SwPosFlyFrames GetAllFlyFormats(const SwPaM *, bool bDrawAlso, bool bAsCharAlso=false) const
Returns positions of all FlyFrames in the document.
Definition: doclay.cxx:498
std::shared_ptr< SwUnoCursor > CreateUnoCursor(const SwPosition &rPos, bool bTableCursor=false)
Definition: doc.cxx:1803
bool DeleteRowCol(const SwSelBoxes &rBoxes, RowColMode eMode=RowColMode::DeleteRow)
Definition: ndtbl.cxx:1924
const SwFrameFormats * GetSpzFrameFormats() const
Definition: doc.hxx:753
SwDocShell * GetDocShell()
Definition: doc.hxx:1362
const SwPageDesc & GetPageDesc(const size_t i) const
Definition: doc.hxx:890
Ends a section of nodes in the document model.
Definition: node.hxx:378
FlyAnchors.
Definition: fmtanchr.hxx:37
sal_Int32 GetAnchorContentOffset() const
Definition: atrfrm.cxx:1623
sal_uInt32 GetOrder() const
Definition: fmtanchr.hxx:80
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:67
SwNode * GetAnchorNode() const
Definition: atrfrm.cxx:1606
Content, content of frame (header, footer, fly).
Definition: fmtcntnt.hxx:32
const SwNodeIndex * GetContentIdx() const
Definition: fmtcntnt.hxx:46
Format of a fly content.
Definition: fmtflcnt.hxx:33
SwFrameFormat * GetFrameFormat() const
Definition: fmtflcnt.hxx:45
Footer, for pageformats Client of FrameFormat describing the footer.
Definition: fmthdft.hxx:65
const SwTextFootnote * GetTextFootnote() const
Definition: fmtftn.hxx:85
Header, for PageFormats Client of FrameFormat describing the header.
Definition: fmthdft.hxx:34
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:139
sal_uInt16 Which() const
for Querying of Writer-functions.
Definition: format.hxx:82
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:88
const SwAttrSet & GetAttrSet() const
For querying the attribute array.
Definition: format.hxx:136
const SwFormatContent & GetContent(bool=true) const
Definition: fmtcntnt.hxx:55
Style of a layout element.
Definition: frmfmt.hxx:62
Specific frame formats (frames, DrawObjects).
size_t size() const
const SwSortedObjs * GetDrawObjs() const
Definition: frame.hxx:564
Marks a node in the document model.
Definition: ndindex.hxx:31
const SwNodes & GetNodes() const
Definition: ndindex.hxx:175
SwNode & GetNode() const
Definition: ndindex.hxx:136
SwNodeOffset GetIndex() const
Definition: ndindex.hxx:171
Base class of the Writer document model elements.
Definition: node.hxx:98
bool IsGrfNode() const
Definition: node.hxx:707
SwFrameFormat * GetFlyFormat() const
If node is in a fly return the respective format.
Definition: node.cxx:739
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:897
SwNodeOffset GetIndex() const
Definition: node.hxx:312
bool IsNoTextNode() const
Definition: node.hxx:699
SwTableBox * GetTableBox() const
If node is in a table return the respective table box.
Definition: node.cxx:774
SwDoc & GetDoc()
Definition: node.hxx:233
bool IsEndNode() const
Definition: node.hxx:683
bool IsSectionNode() const
Definition: node.hxx:695
bool IsTextNode() const
Definition: node.hxx:687
SwTableNode * FindTableNode()
Search table node, in which it is.
Definition: node.cxx:380
SwStartNode * FindSttNodeByType(SwStartNodeType eTyp)
Definition: node.cxx:784
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:153
SwNodeOffset EndOfSectionIndex() const
Definition: node.hxx:728
SwContentNode * GetContentNode()
Definition: node.hxx:666
SwTableNode * GetTableNode()
Definition: node.hxx:650
SwNodeType GetNodeType() const
Definition: node.hxx:166
bool IsOLENode() const
Definition: node.hxx:703
const SwEndNode * EndOfSectionNode() const
Definition: node.hxx:733
bool IsDocNodes() const
Is the NodesArray the regular one of Doc? (and not the UndoNds, ...) Implementation in doc....
Definition: nodes.cxx:2543
void UpdateOutlineNode(SwNode &rNd)
Update all Nodes - Rule/Format-Change.
Definition: ndnum.cxx:39
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:187
const SwPosition * GetMark() const
Definition: pam.hxx:263
SwNode & GetPointNode() const
Definition: pam.hxx:283
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:642
void Normalize(bool bPointFirst=true)
Normalizes PaM, i.e.
Definition: pam.cxx:700
bool IsMultiSelection() const
Definition: pam.hxx:328
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
Definition: pam.cxx:668
const SwPosition * End() const
Definition: pam.hxx:271
SwPaM * GetNext()
Definition: pam.hxx:320
SwDoc & GetDoc() const
Definition: pam.hxx:299
void DeleteMark()
Definition: pam.hxx:231
const SwPosition * GetPoint() const
Definition: pam.hxx:261
const SwPosition * Start() const
Definition: pam.hxx:266
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:259
SwFrameFormat & GetMaster()
Definition: pagedesc.hxx:238
SwFrameFormat & GetFirstLeft()
Definition: pagedesc.hxx:241
SwFrameFormat & GetFirstMaster()
Definition: pagedesc.hxx:240
SwFrameFormat & GetLeft()
Definition: pagedesc.hxx:239
For querying current flys in document.
Definition: flypos.hxx:31
The root element of a Writer document layout.
Definition: rootfrm.hxx:83
void StartAllAction()
Set up Start-/EndAction for all Shells on an as high as possible (Shell section) level.
Definition: pagechg.cxx:1911
void EndAllAction(bool bVirDev=false)
Definition: pagechg.cxx:1923
void UnoRestoreAllActions()
Definition: pagechg.cxx:1980
void UnoRemoveAllActions()
Certain UNO Actions (e.g.
Definition: pagechg.cxx:1945
A section node represents the start of a section on the UI, i.e.
Definition: node.hxx:575
Starts a section of nodes in the document model.
Definition: node.hxx:348
SwStartNodeType GetStartNodeType() const
Definition: node.hxx:364
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:426
const SwStartNode * GetSttNd() const
Definition: swtable.hxx:478
const SwTable & GetTable() const
Definition: node.hxx:542
SwTable is one table in the document model, containing rows (which contain cells).
Definition: swtable.hxx:113
SwTableNode * GetTableNode() const
Definition: swtable.cxx:2142
SwTableFormat * GetFrameFormat()
Definition: swtable.hxx:207
static SwTable * FindTable(SwFrameFormat const *const pFormat)
Definition: swtable.cxx:2135
SwTableSortBoxes & GetTabSortBoxes()
Definition: swtable.hxx:265
bool IsNewModel() const
Definition: swtable.hxx:191
const SwFormatFootnote & GetFootnote() const
Definition: txatbase.hxx:208
static bool isTextBox(const SwFrameFormat *pFormat, sal_uInt16 nType, const SdrObject *pObject=nullptr)
Is the frame format a text box?
const SwNodeIndex * GetStartNode() const
Definition: txtftn.hxx:41
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:111
bool GetParaAttr(SfxItemSet &rSet, sal_Int32 nStt, sal_Int32 nEnd, const bool bOnlyTextAttr=false, const bool bGetFromChrFormat=true, const bool bMergeIndentValuesOfNumRule=false, SwRootFrame const *pLayout=nullptr) const
Query the attributes of textnode over the range.
Definition: thints.cxx:2133
const OUString & GetText() const
Definition: ndtxt.hxx:242
void SetRemainInSection(bool bFlag)
Definition: unocrsr.hxx:66
static rtl::Reference< SwXCell > CreateXCell(SwFrameFormat *pTableFormat, SwTableBox *pBox, SwTable *pTable=nullptr)
Definition: unotbl.cxx:1122
static rtl::Reference< SwXFootnote > CreateXFootnote(SwDoc &rDoc, SwFormatFootnote *pFootnoteFormat, bool isEndnote=false)
Definition: unoftn.cxx:142
static css::uno::Reference< css::text::XText > CreateXHeadFootText(SwFrameFormat &rHeadFootFormat, const bool bIsHeader)
Definition: unotext.cxx:2566
css::uno::Reference< css::text::XTextCursor > CreateTextCursor(const bool bIgnoreTables=false)
Definition: unotext.cxx:2649
bool SelectPaM(SwPaM &rPaM)
make rPaM select the paragraph
static rtl::Reference< SwXParagraph > CreateXParagraph(SwDoc &rDoc, SwTextNode *pTextNode, css::uno::Reference< css::text::XText > const &xParentText=nullptr, const sal_Int32 nSelStart=-1, const sal_Int32 nSelEnd=- 1)
static rtl::Reference< SwXTextEmbeddedObject > CreateXTextEmbeddedObject(SwDoc &rDoc, SwFrameFormat *pFrameFormat)
Definition: unoframe.cxx:3494
static SW_DLLPUBLIC rtl::Reference< SwXTextFrame > CreateXTextFrame(SwDoc &rDoc, SwFrameFormat *pFrameFormat)
Definition: unoframe.cxx:3218
static rtl::Reference< SwXTextGraphicObject > CreateXTextGraphicObject(SwDoc &rDoc, SwFrameFormat *pFrameFormat)
Definition: unoframe.cxx:3447
SwUnoCursor & GetCursor() const
Definition: unoport.hxx:242
enum RangePosition m_eRangePosition
Definition: unoobj2.cxx:667
const ::sw::mark::IMark * m_pMark
Definition: unoobj2.cxx:671
const SwFrameFormat * m_pTableOrSectionFormat
Definition: unoobj2.cxx:670
void SetMark(::sw::mark::IMark &rMark)
Definition: unoobj2.cxx:712
const ::sw::mark::IMark * GetBookmark() const
Definition: unoobj2.cxx:711
const SfxItemPropertySet & m_rPropSet
Definition: unoobj2.cxx:666
uno::Reference< text::XText > m_xParentText
Definition: unoobj2.cxx:669
virtual ~Impl() override
Definition: unoobj2.cxx:694
virtual void Notify(const SfxHint &) override
Definition: unoobj2.cxx:724
Impl(SwDoc &rDoc, const enum RangePosition eRange, SwFrameFormat *const pTableOrSectionFormat, uno::Reference< text::XText > xParent=nullptr)
Definition: unoobj2.cxx:673
virtual sal_Bool SAL_CALL hasElements() override
Definition: unoobj2.cxx:1376
virtual css::uno::Reference< css::text::XText > SAL_CALL getText() override
Definition: unoobj2.cxx:930
const SwDoc & GetDoc() const
Definition: unoobj2.cxx:764
virtual OUString SAL_CALL getString() override
Definition: unoobj2.cxx:1030
static rtl::Reference< SwXTextRange > CreateXTextRange(SwDoc &rDoc, const SwPosition &rPos, const SwPosition *const pMark)
Definition: unoobj2.cxx:1199
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override
Definition: unoobj2.cxx:957
virtual void SAL_CALL addPropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unoobj2.cxx:1430
virtual void SAL_CALL removeVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unoobj2.cxx:1454
virtual OUString SAL_CALL getImplementationName() override
Definition: unoobj2.cxx:905
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unoobj2.cxx:916
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createContentEnumeration(const OUString &rServiceName) override
Definition: unoobj2.cxx:1323
virtual void SAL_CALL makeRedline(const OUString &rRedlineType, const css::uno::Sequence< css::beans::PropertyValue > &RedlineProperties) override
Definition: unoobj2.cxx:1521
void SetPositions(SwPaM const &rPam)
Definition: unoobj2.cxx:779
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override
Definition: unoobj2.cxx:994
bool GetPositions(SwPaM &rToFill, ::sw::TextRangeMode eMode=::sw::TextRangeMode::RequireTextNode) const
Definition: unoobj2.cxx:1052
virtual css::beans::PropertyState SAL_CALL getPropertyState(const OUString &rPropertyName) override
Definition: unoobj2.cxx:1462
virtual void SAL_CALL setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue) override
Definition: unoobj2.cxx:1399
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: unoobj2.cxx:1347
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unoobj2.cxx:910
virtual void SAL_CALL setPropertyToDefault(const OUString &rPropertyName) override
Definition: unoobj2.cxx:1491
virtual void SAL_CALL setString(const OUString &rString) override
Definition: unoobj2.cxx:1045
virtual void SAL_CALL removePropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unoobj2.cxx:1438
void Invalidate()
Definition: unoobj2.cxx:774
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unoobj2.cxx:1371
virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates(const css::uno::Sequence< OUString > &rPropertyNames) override
Definition: unoobj2.cxx:1477
::sw::UnoImplPtr< Impl > m_pImpl
SwXTextRange(SwPaM const &rPam, const css::uno::Reference< css::text::XText > &xParent, const enum RangePosition eRange=RANGE_IN_TEXT)
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unoobj2.cxx:1389
virtual ~SwXTextRange() override
Definition: unoobj2.cxx:760
virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() override
Definition: unoobj2.cxx:1382
virtual css::uno::Any SAL_CALL getPropertyDefault(const OUString &rPropertyName) override
Definition: unoobj2.cxx:1506
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
Definition: unoobj2.cxx:1415
void DeleteAndInsert(std::u16string_view aText, ::sw::DeleteAndInsertMode eMode)
Definition: unoobj2.cxx:800
virtual void SAL_CALL addVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unoobj2.cxx:1446
static rtl::Reference< SwXTextTable > CreateXTextTable(SwFrameFormat *pFrameFormat)
Definition: unotbl.cxx:1964
virtual css::uno::Reference< css::text::XTextCursor > CreateCursor()
Definition: unotext.cxx:179
UnoActionContext(SwDoc *const pDoc)
Definition: unoobj2.cxx:182
~UnoActionContext() COVERITY_NOEXCEPT_FALSE
Definition: unoobj2.cxx:192
~UnoActionRemoveContext() COVERITY_NOEXCEPT_FALSE
Definition: unoobj2.cxx:240
UnoActionRemoveContext(SwDoc *const pDoc)
Definition: unoobj2.cxx:215
css::uno::Type const & get()
size_type size() const
std::pair< const_iterator, bool > insert(Value &&x)
void MoveTo(value_type *pDestRing)
Removes this item from its current ring container and adds it to another ring container.
Definition: ring.hxx:135
ring_container GetRingContainer()
Definition: ring.hxx:240
void reset(std::shared_ptr< SwUnoCursor > pNew)
Definition: unocrsr.hxx:158
virtual const SwPosition & GetOtherMarkPos() const =0
virtual bool IsExpanded() const =0
virtual const SwPosition & GetMarkEnd() const =0
virtual const SwPosition & GetMarkStart() const =0
virtual const SwPosition & GetMarkPos() const =0
EmbeddedObjectRef * pObject
FilterGroup & rTarget
DocumentType eType
constexpr TypedWhichId< SwFormatHeader > RES_HEADER(96)
constexpr TypedWhichId< SwFlyFrameFormat > RES_FLYFRMFMT(156)
constexpr TypedWhichId< SwFormatFooter > RES_FOOTER(97)
constexpr TypedWhichId< SwDrawFrameFormat > RES_DRAWFRMFMT(159)
constexpr TypedWhichId< SwFormatFlyCnt > RES_TXTATR_FLYCNT(58)
constexpr TypedWhichId< SfxUInt16Item > RES_PARATR_OUTLINELEVEL(79)
sal_Int32 nIndex
Mode eMode
sal_Int64 n
void SetPropertyValue(SwPaM &rPaM, const SfxItemPropertySet &rPropSet, const OUString &rPropertyName, const css::uno::Any &rValue, const SetAttrMode nAttrMode=SetAttrMode::DEFAULT)
void SetCursorAttr(SwPaM &rPam, const SfxItemSet &rSet, const SetAttrMode nAttrMode, const bool bTableMode=false)
Definition: unoobj2.cxx:252
css::beans::PropertyState GetPropertyState(SwPaM &rPaM, const SfxItemPropertySet &rPropSet, const OUString &rPropertyName)
Definition: unoobj.cxx:2148
void makeRedline(SwPaM const &rPaM, std::u16string_view rRedlineType, const uno::Sequence< beans::PropertyValue > &rRedlineProperties)
void GetCursorAttr(SwPaM &rPam, SfxItemSet &rSet, const bool bOnlyTextAttr=false, const bool bGetFromChrFormat=true)
Definition: unoobj2.cxx:294
bool DocInsertStringSplitCR(SwDoc &rDoc, const SwPaM &rNewCursor, std::u16string_view rText, const bool bForceExpandHints)
void SetPropertyToDefault(SwPaM &rPaM, const SfxItemPropertySet &rPropSet, std::u16string_view rPropertyName)
Definition: unoobj.cxx:2181
void SetString(SwCursor &rCursor, std::u16string_view aString)
Definition: unoobj2.cxx:1623
css::uno::Any GetPropertyValue(SwPaM &rPaM, const SfxItemPropertySet &rPropSet, std::u16string_view rPropertyName)
Definition: unoobj.cxx:1893
void GetTextFromPam(SwPaM &rPam, OUString &rBuffer, SwRootFrame const *pLayout=nullptr)
Definition: unoobj.cxx:131
css::uno::Sequence< css::beans::PropertyState > GetPropertyStates(SwPaM &rPaM, const SfxItemPropertySet &rPropSet, const css::uno::Sequence< OUString > &rPropertyNames, const SwGetPropertyStatesCaller eCaller=SW_PROPERTY_STATE_CALLER_DEFAULT)
void SelectPam(SwPaM &rPam, const bool bExpand)
Definition: unoobj.cxx:116
css::uno::Any GetPropertyDefault(SwPaM const &rPaM, const SfxItemPropertySet &rPropSet, std::u16string_view rPropertyName)
Definition: unoobj.cxx:2220
css::uno::Sequence< OUString > getSupportedServiceNames()
OUString getImplementationName()
bool CPPUHELPER_DLLPUBLIC supportsService(css::lang::XServiceInfo *implementation, rtl::OUString const &name)
int i
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
end
Dialog to specify the properties of date form field.
DeleteAndInsertMode
uno::Reference< text::XText > CreateParentXText(SwDoc &rDoc, const SwPosition &rPos)
Definition: unoobj2.cxx:1218
bool XTextRangeToSwPaM(SwUnoInternalPaM &rToFill, const uno::Reference< text::XTextRange > &xTextRange, ::sw::TextRangeMode const eMode)
Definition: unoobj2.cxx:1090
void DeepCopyPaM(SwPaM const &rSource, SwPaM &rTarget)
Definition: unoobj2.cxx:79
TextRangeMode
static bool lcl_IsStartNodeInFormat(const bool bHeader, SwStartNode const *const pSttNode, SwFrameFormat const *const pFrameFormat, SwFrameFormat *&rpFormat)
Definition: unoobj2.cxx:1163
SwStartNodeType
Definition: ndtyp.hxx:51
@ SwNormalStartNode
Definition: ndtyp.hxx:52
@ SwHeaderStartNode
Definition: ndtyp.hxx:56
@ SwFooterStartNode
Definition: ndtyp.hxx:57
@ SwFlyStartNode
Definition: ndtyp.hxx:54
@ SwTableBoxStartNode
Definition: ndtyp.hxx:53
@ SwFootnoteStartNode
Definition: ndtyp.hxx:55
o3tl::strong_int< sal_Int32, struct Tag_SwNodeOffset > SwNodeOffset
Definition: nodeoffset.hxx:16
bool GoInNode(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:1171
bool GoNextPara(SwPaM &rPam, SwMoveFnCollection const &aPosPara)
Definition: pam.cxx:1252
bool GoInContent(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:1180
SwMoveFnCollection const & fnParaStart
Definition: paminit.cxx:48
SwMoveFnCollection const & fnMoveBackward
Definition: paminit.cxx:60
SwMoveFnCollection const & fnMoveForward
SwPam::Move()/Find() default argument.
Definition: paminit.cxx:61
static SfxItemSet & rSet
sal_uIntPtr sal_uLong
Marks a position in the document model.
Definition: pam.hxx:37
SwNode & GetNode() const
Definition: pam.hxx:80
void Assign(const SwNode &rNd, SwNodeOffset nDelta, sal_Int32 nContentOffset=0)
These all set both nNode and nContent.
Definition: pam.cxx:230
void AssignEndIndex(const SwContentNode &rNd)
Set nNode to rNd, and nContent to the end of rNd.
Definition: pam.cxx:276
const SwContentNode * GetContentNode() const
Definition: pam.hxx:83
SwNodeOffset GetNodeIndex() const
Definition: pam.hxx:77
sal_Int32 GetContentIndex() const
Definition: pam.hxx:84
static rtl::Reference< SwXParaFrameEnumeration > Create(const SwPaM &rPaM, const enum ParaFrameMode eParaFrameMode, SwFrameFormat *const pFormat=nullptr)
Definition: unoobj2.cxx:1692
static rtl::Reference< SwXParagraphEnumeration > Create(css::uno::Reference< css::text::XText > const &xParent, const std::shared_ptr< SwUnoCursor > &pCursor, const CursorType eType, SwTableBox const *const pTableBox=nullptr)
Definition: unoobj2.cxx:447
static rtl::Reference< SwXTextRanges > Create(SwPaM *const pCursor)
Definition: unoobj2.cxx:1599
virtual SwUnoCursor * GetCursor()=0
Reference< XModel > xModel
RndStdIds
SetAttrMode
Definition: swtypes.hxx:133
unsigned char sal_Bool
CursorType
SwUnoPropertyMapProvider aSwMapProvider
Definition: unomap1.cxx:87
#define PROPERTY_MAP_TEXT_CURSOR
Definition: unomap.hxx:28
static SwDoc * lcl_IsNewStyleTable(SwUnoTableCursor const &rCursor)
Definition: unoobj2.cxx:221
static bool lcl_CursorIsInSection(SwUnoCursor const *const pUnoCursor, SwStartNode const *const pOwnStartNode)
Definition: unoobj2.cxx:503
static SwTableNode * lcl_FindTopLevelTable(SwTableNode *const pTableNode, SwTable const *const pOwnTable)
! compare to SwShellTableCursor::FillRects() in viscrs.cxx
Definition: unoobj2.cxx:487
static void lcl_RemoveImpl(SwDoc *const pDoc)
Definition: unoobj2.cxx:205
void CollectFrameAtNode(const SwNode &rNd, FrameClientSortList_t &rFrames, const bool bAtCharAnchoredObjs)
Definition: unoobj2.cxx:136
static void DeleteTable(SwDoc &rDoc, SwTable &rTable)
Definition: unoobj2.cxx:788
std::deque< FrameClientSortListEntry > FrameClientSortList_t
ParaFrameMode
@ PARAFRAME_PORTION_TEXTRANGE
@ PARAFRAME_PORTION_CHAR
@ PARAFRAME_PORTION_PARAGRAPH