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