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 auto nIdx =
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 const SwFrameFormats& rFormats = *rDoc.GetSpzFrameFormats();
160 const size_t nSize = rFormats.size();
161 for ( size_t i = 0; i < nSize; i++)
162 {
163 const SwFrameFormat* pFormat = rFormats[ i ];
164 const SwFormatAnchor& rAnchor = pFormat->GetAnchor();
165 const SwPosition* pAnchorPos;
166 if( rAnchor.GetAnchorId() == nChkType &&
167 nullptr != (pAnchorPos = rAnchor.GetContentAnchor()) &&
168 pAnchorPos->GetNode() == rNd )
169 {
170
171 // OD 2004-05-07 #i28701# - determine insert position for
172 // sorted <rFrameArr>
173 const sal_Int32 nIndex = pAnchorPos->GetContentIndex();
174 sal_uInt32 nOrder = rAnchor.GetOrder();
175
176 rFrames.emplace_back(nIndex, nOrder, std::make_unique<sw::FrameClient>(const_cast<SwFrameFormat*>(pFormat)));
177 }
178 }
179 std::sort(rFrames.begin(), rFrames.end(), FrameClientSortListLess());
180 }
181}
182
184 : m_pDoc(pDoc)
185{
187 if (pRootFrame)
188 {
189 pRootFrame->StartAllAction();
190 }
191}
192
193UnoActionContext::~UnoActionContext() COVERITY_NOEXCEPT_FALSE
194{
195 // Doc may already have been removed here
196 if (m_pDoc)
197 {
199 if (pRootFrame)
200 {
201 pRootFrame->EndAllAction();
202 }
203 }
204}
205
206static void lcl_RemoveImpl(SwDoc *const pDoc)
207{
208 assert(pDoc);
209 SwRootFrame *const pRootFrame = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
210 if (pRootFrame)
211 {
212 pRootFrame->UnoRemoveAllActions();
213 }
214}
215
217 : m_pDoc(pDoc)
218{
220}
221
223{
224 SwTableNode *const pTableNode = rCursor.GetPointNode().FindTableNode();
225 return (pTableNode && !pTableNode->GetTable().IsNewModel())
226 ? &rCursor.GetDoc()
227 : nullptr;
228}
229
231 : m_pDoc(lcl_IsNewStyleTable(rCursor))
232{
233 // this insanity is only necessary for old-style tables
234 // because SwRootFrame::MakeTableCursors() creates the table cursor for these
235 if (m_pDoc)
236 {
238 }
239}
240
242{
243 if (m_pDoc)
244 {
246 if (pRootFrame)
247 {
248 pRootFrame->UnoRestoreAllActions();
249 }
250 }
251}
252
254 const SfxItemSet& rSet,
255 const SetAttrMode nAttrMode, const bool bTableMode)
256{
257 const SetAttrMode nFlags = nAttrMode | SetAttrMode::APICALL;
258 SwDoc& rDoc = rPam.GetDoc();
259 //StartEndAction
260 UnoActionContext aAction(&rDoc);
261 if (rPam.GetNext() != &rPam) // Ring of Cursors
262 {
264
265 for(SwPaM& rCurrent : rPam.GetRingContainer())
266 {
267 if (rCurrent.HasMark() &&
268 ( bTableMode ||
269 (*rCurrent.GetPoint() != *rCurrent.GetMark()) ))
270 {
271 rDoc.getIDocumentContentOperations().InsertItemSet(rCurrent, rSet, nFlags);
272 }
273 }
274
276 }
277 else
278 {
279 rDoc.getIDocumentContentOperations().InsertItemSet( rPam, rSet, nFlags );
280 }
281
282 if( rSet.GetItemState( RES_PARATR_OUTLINELEVEL, false ) >= SfxItemState::DEFAULT )
283 {
284 SwTextNode * pTmpNode = rPam.GetPointNode().GetTextNode();
285 if ( pTmpNode )
286 {
287 rPam.GetDoc().GetNodes().UpdateOutlineNode( *pTmpNode );
288 }
289 }
290}
291
292// #i63870#
293// split third parameter <bCurrentAttrOnly> into new parameters <bOnlyTextAttr>
294// and <bGetFromChrFormat> to get better control about resulting <SfxItemSet>
296 SfxItemSet & rSet, const bool bOnlyTextAttr, const bool bGetFromChrFormat)
297{
298 static const sal_uLong nMaxLookup = 1000;
299 SfxItemSet aSet( *rSet.GetPool(), rSet.GetRanges() );
300 SfxItemSet *pSet = &rSet;
301 for(SwPaM& rCurrent : rPam.GetRingContainer())
302 {
303 SwPosition const & rStart( *rCurrent.Start() );
304 SwPosition const & rEnd( *rCurrent.End() );
305 const SwNodeOffset nSttNd = rStart.GetNodeIndex();
306 const SwNodeOffset nEndNd = rEnd .GetNodeIndex();
307
308 if (nEndNd - nSttNd >= SwNodeOffset(nMaxLookup))
309 {
310 rSet.ClearItem();
312 return;// uno::Any();
313 }
314
315 // the first node inserts the values into the get set
316 // all other nodes merge their values into the get set
317 for (SwNodeOffset n = nSttNd; n <= nEndNd; ++n)
318 {
319 SwNode *const pNd = rPam.GetDoc().GetNodes()[ n ];
320 switch (pNd->GetNodeType())
321 {
322 case SwNodeType::Text:
323 {
324 const sal_Int32 nStart = (n == nSttNd)
325 ? rStart.GetContentIndex() : 0;
326 const sal_Int32 nEnd = (n == nEndNd)
327 ? rEnd.GetContentIndex()
328 : pNd->GetTextNode()->GetText().getLength();
329 pNd->GetTextNode()->GetParaAttr(*pSet, nStart, nEnd, bOnlyTextAttr, bGetFromChrFormat);
330 }
331 break;
332
333 case SwNodeType::Grf:
334 case SwNodeType::Ole:
335 static_cast<SwContentNode*>(pNd)->GetAttr( *pSet );
336 break;
337
338 default:
339 continue; // skip this node
340 }
341
342 if (pSet != &rSet)
343 {
344 rSet.MergeValues( aSet );
345 }
346 else
347 {
348 pSet = &aSet;
349 }
350
351 if (aSet.Count())
352 {
353 aSet.ClearItem();
354 }
355 }
356 }
357}
358
359namespace {
360
361struct SwXParagraphEnumerationImpl final : public SwXParagraphEnumeration
362{
363 uno::Reference< text::XText > const m_xParentText;
364 const CursorType m_eCursorType;
368 SwStartNode const*const m_pOwnStartNode;
369 SwTable const*const m_pOwnTable;
370 const SwNodeOffset m_nEndIndex;
371 sal_Int32 m_nFirstParaStart;
372 sal_Int32 m_nLastParaEnd;
373 bool m_bFirstParagraph;
374 uno::Reference< text::XTextContent > m_xNextPara;
375 sw::UnoCursorPointer m_pCursor;
376
377 SwXParagraphEnumerationImpl(
378 uno::Reference< text::XText > xParent,
379 const std::shared_ptr<SwUnoCursor>& pCursor,
380 const CursorType eType,
381 SwStartNode const*const pStartNode, SwTable const*const pTable)
382 : m_xParentText(std::move( xParent ))
383 , m_eCursorType( eType )
384 // remember table and start node for later travelling
385 // (used in export of tables in tables)
386 , m_pOwnStartNode( pStartNode )
387 // for import of tables in tables we have to remember the actual
388 // table and start node of the current position in the enumeration.
389 , m_pOwnTable( pTable )
390 , m_nEndIndex( pCursor->End()->GetNodeIndex() )
391 , m_nFirstParaStart( -1 )
392 , m_nLastParaEnd( -1 )
393 , m_bFirstParagraph( true )
394 , m_pCursor(pCursor)
395 {
396 OSL_ENSURE(m_xParentText.is(), "SwXParagraphEnumeration: no parent?");
397 assert( !((CursorType::SelectionInTable == eType)
398 || (CursorType::TableText == eType))
399 || (m_pOwnTable && m_pOwnStartNode));
400
401 if ((CursorType::Selection == m_eCursorType) ||
402 (CursorType::SelectionInTable == m_eCursorType))
403 {
404 SwUnoCursor & rCursor = GetCursor();
405 rCursor.Normalize();
406 m_nFirstParaStart = rCursor.GetPoint()->GetContentIndex();
407 m_nLastParaEnd = rCursor.GetMark()->GetContentIndex();
408 rCursor.DeleteMark();
409 }
410 }
411
412 virtual ~SwXParagraphEnumerationImpl() override
413 { m_pCursor.reset(nullptr); }
414 virtual void SAL_CALL release() noexcept override
415 {
417 OWeakObject::release();
418 }
419
420 // XServiceInfo
421 virtual OUString SAL_CALL getImplementationName() override
422 { return "SwXParagraphEnumeration"; }
423 virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName) override
424 { return cppu::supportsService(this, rServiceName); };
425 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
426 { return {"com.sun.star.text.ParagraphEnumeration"}; };
427
428 // XEnumeration
429 virtual sal_Bool SAL_CALL hasMoreElements() override;
430 virtual css::uno::Any SAL_CALL nextElement() override;
431
432 SwUnoCursor& GetCursor()
433 { return *m_pCursor; }
437 uno::Reference< text::XTextContent > NextElement_Impl();
438
443 bool IgnoreLastElement(SwUnoCursor& rCursor, bool bMovedFromTable);
444};
445
446}
447
449 uno::Reference< text::XText > const& xParent,
450 const std::shared_ptr<SwUnoCursor>& pCursor,
451 const CursorType eType,
452 SwTableBox const*const pTableBox)
453{
454 SwStartNode const* pStartNode(nullptr);
455 SwTable const* pTable(nullptr);
456 assert((eType == CursorType::TableText) == (pTableBox != nullptr));
457 switch (eType)
458 {
460 {
461 pStartNode = pTableBox->GetSttNd();
462 pTable = & pStartNode->FindTableNode()->GetTable();
463 break;
464 }
466 {
467 SwTableNode const*const pTableNode(
468 pCursor->GetPoint()->GetNode().FindTableNode());
469 pStartNode = pTableNode;
470 pTable = & pTableNode->GetTable();
471 break;
472 }
473 default:
474 break;
475 }
476 return new SwXParagraphEnumerationImpl(xParent, pCursor, eType, pStartNode, pTable);
477}
478
479sal_Bool SAL_CALL
480SwXParagraphEnumerationImpl::hasMoreElements()
481{
482 SolarMutexGuard aGuard;
483 return m_bFirstParagraph || m_xNextPara.is();
484}
485
487static SwTableNode *
489 SwTableNode *const pTableNode, SwTable const*const pOwnTable)
490{
491 // find top-most table in current context (section) level
492
493 SwTableNode * pLast = pTableNode;
494 for (SwTableNode* pTmp = pLast;
495 pTmp != nullptr && &pTmp->GetTable() != pOwnTable; /* we must not go up higher than the own table! */
496 pTmp = pTmp->StartOfSectionNode()->FindTableNode() )
497 {
498 pLast = pTmp;
499 }
500 return pLast;
501}
502
503static bool
505 SwUnoCursor const*const pUnoCursor, SwStartNode const*const pOwnStartNode)
506{
507 // returns true if the cursor is in the section (or in a sub section!)
508 // represented by pOwnStartNode
509
510 bool bRes = true;
511 if (pUnoCursor && pOwnStartNode)
512 {
513 const SwEndNode * pOwnEndNode = pOwnStartNode->EndOfSectionNode();
514 bRes = pOwnStartNode->GetIndex() <= pUnoCursor->Start()->GetNodeIndex() &&
515 pUnoCursor->End()->GetNodeIndex() <= pOwnEndNode->GetIndex();
516 }
517 return bRes;
518}
519
520bool SwXParagraphEnumerationImpl::IgnoreLastElement(SwUnoCursor& rCursor, bool bMovedFromTable)
521{
522 // Ignore the last element of a selection enumeration if this is a stub
523 // paragraph (directly after table, selection ends at paragraph start).
524
525 if (rCursor.Start()->GetNodeIndex() != m_nEndIndex)
526 return false;
527
528 if (m_eCursorType != CursorType::Selection)
529 return false;
530
531 if (!bMovedFromTable)
532 return false;
533
534 return m_nLastParaEnd == 0;
535}
536
537uno::Reference< text::XTextContent >
538SwXParagraphEnumerationImpl::NextElement_Impl()
539{
540 SwUnoCursor& rUnoCursor = GetCursor();
541
542 // check for exceeding selections
543 if (!m_bFirstParagraph &&
544 ((CursorType::Selection == m_eCursorType) ||
545 (CursorType::SelectionInTable == m_eCursorType)))
546 {
547 SwPosition* pStart = rUnoCursor.Start();
548 auto aNewCursor(rUnoCursor.GetDoc().CreateUnoCursor(*pStart));
549 // one may also go into tables here
550 if (CursorType::SelectionInTable != m_eCursorType)
551 {
552 aNewCursor->SetRemainInSection( false );
553 }
554
555 // os 2005-01-14: This part is only necessary to detect movements out
556 // of a selection; if there is no selection we don't have to care
557 SwTableNode *const pTableNode = aNewCursor->GetPointNode().FindTableNode();
558 bool bMovedFromTable = false;
559 if (CursorType::SelectionInTable != m_eCursorType && pTableNode)
560 {
561 aNewCursor->GetPoint()->Assign( pTableNode->EndOfSectionIndex() );
562 aNewCursor->Move(fnMoveForward, GoInNode);
563 bMovedFromTable = true;
564 }
565 else
566 {
567 aNewCursor->MovePara(GoNextPara, fnParaStart);
568 }
569 if (m_nEndIndex < aNewCursor->Start()->GetNodeIndex())
570 {
571 return nullptr;
572 }
573
574 if (IgnoreLastElement(*aNewCursor, bMovedFromTable))
575 {
576 return nullptr;
577 }
578 }
579
580 bool bInTable = false;
581 if (!m_bFirstParagraph)
582 {
583 rUnoCursor.SetRemainInSection( false );
584 // what to do if already in a table?
585 SwTableNode * pTableNode = rUnoCursor.GetPointNode().FindTableNode();
586 pTableNode = lcl_FindTopLevelTable( pTableNode, m_pOwnTable );
587 if (pTableNode && (&pTableNode->GetTable() != m_pOwnTable))
588 {
589 // this is a foreign table: go to end
590 rUnoCursor.GetPoint()->Assign( pTableNode->EndOfSectionIndex() );
591 if (!rUnoCursor.Move(fnMoveForward, GoInNode))
592 {
593 return nullptr;
594 }
595 bInTable = true;
596 }
597 }
598
599 uno::Reference< text::XTextContent > xRef;
600 // the cursor must remain in the current section or a subsection
601 // before AND after the movement...
602 if (lcl_CursorIsInSection( &rUnoCursor, m_pOwnStartNode ) &&
603 (m_bFirstParagraph || bInTable ||
604 (rUnoCursor.MovePara(GoNextPara, fnParaStart) &&
605 lcl_CursorIsInSection( &rUnoCursor, m_pOwnStartNode ))))
606 {
607 if (m_eCursorType == CursorType::Selection || m_eCursorType == CursorType::SelectionInTable)
608 {
609 // This is a selection, check if the cursor would go past the end
610 // of the selection.
611 if (rUnoCursor.Start()->GetNodeIndex() > m_nEndIndex)
612 return nullptr;
613 }
614
615 SwPosition* pStart = rUnoCursor.Start();
616 const sal_Int32 nFirstContent =
617 m_bFirstParagraph ? m_nFirstParaStart : -1;
618 const sal_Int32 nLastContent =
619 (m_nEndIndex == pStart->GetNodeIndex()) ? m_nLastParaEnd : -1;
620
621 // position in a table, or in a simple paragraph?
622 SwTableNode * pTableNode = rUnoCursor.GetPointNode().FindTableNode();
623 pTableNode = lcl_FindTopLevelTable( pTableNode, m_pOwnTable );
624 if (/*CursorType::TableText != eCursorType && CursorType::SelectionInTable != eCursorType && */
625 pTableNode && (&pTableNode->GetTable() != m_pOwnTable))
626 {
627 // this is a foreign table
628 SwFrameFormat* pTableFormat = pTableNode->GetTable().GetFrameFormat();
629 xRef = SwXTextTable::CreateXTextTable(pTableFormat);
630 }
631 else
632 {
633 text::XText *const pText = m_xParentText.get();
634 xRef = SwXParagraph::CreateXParagraph(rUnoCursor.GetDoc(),
635 pStart->GetNode().GetTextNode(),
636 static_cast<SwXText*>(pText), nFirstContent, nLastContent);
637 }
638 }
639
640 return xRef;
641}
642
643uno::Any SAL_CALL SwXParagraphEnumerationImpl::nextElement()
644{
645 SolarMutexGuard aGuard;
646 if (m_bFirstParagraph)
647 {
648 m_xNextPara = NextElement_Impl();
649 m_bFirstParagraph = false;
650 }
651 const uno::Reference< text::XTextContent > xRef = m_xNextPara;
652 if (!xRef.is())
653 {
654 throw container::NoSuchElementException();
655 }
656 m_xNextPara = NextElement_Impl();
657
658 uno::Any aRet;
659 aRet <<= xRef;
660 return aRet;
661}
662
664 : public SvtListener
665{
666public:
670 uno::Reference<text::XText> m_xParentText;
672 const ::sw::mark::IMark* m_pMark;
673
674 Impl(SwDoc& rDoc, const enum RangePosition eRange,
675 SwFrameFormat* const pTableOrSectionFormat,
676 uno::Reference<text::XText> xParent = nullptr)
678 , m_eRangePosition(eRange)
679 , m_rDoc(rDoc)
680 , m_xParentText(std::move(xParent))
681 , m_pTableOrSectionFormat(pTableOrSectionFormat)
682 , m_pMark(nullptr)
683 {
685 {
687 StartListening(pTableOrSectionFormat->GetNotifier());
688 }
689 else
690 {
692 }
693 }
694
695 virtual ~Impl() override
696 {
697 // Impl owns the bookmark; delete it here: SolarMutex is locked
698 Invalidate();
699 }
700
702 {
703 if (m_pMark)
704 {
706 m_pMark = nullptr;
707 }
708 m_pTableOrSectionFormat = nullptr;
710 }
711
712 const ::sw::mark::IMark* GetBookmark() const { return m_pMark; }
714 {
716 m_pTableOrSectionFormat = nullptr;
717 m_pMark = &rMark;
719 }
720
721protected:
722 virtual void Notify(const SfxHint&) override;
723};
724
726{
727 if(rHint.GetId() == SfxHintId::Dying)
728 {
730 m_pTableOrSectionFormat = nullptr;
731 m_pMark = nullptr;
732 }
733}
734
736 const uno::Reference< text::XText > & xParent,
737 const enum RangePosition eRange)
738 : m_pImpl( new SwXTextRange::Impl(rPam.GetDoc(), eRange, nullptr, xParent) )
739{
740 SetPositions(rPam);
741}
742
744 : m_pImpl(
745 new SwXTextRange::Impl(*rTableFormat.GetDoc(), RANGE_IS_TABLE, &rTableFormat) )
746{
747 SwTable *const pTable = SwTable::FindTable( &rTableFormat );
748 SwTableNode *const pTableNode = pTable->GetTableNode();
749 SwPaM aPam( *pTableNode );
750
751 SetPositions( aPam );
752}
753
755 : m_pImpl(
756 new SwXTextRange::Impl(*rSectionFormat.GetDoc(), RANGE_IS_SECTION, &rSectionFormat) )
757{
758 // no SetPositions here for now
759}
760
762{
763}
764
766{
767 return m_pImpl->m_rDoc;
768}
769
771{
772 return m_pImpl->m_rDoc;
773}
774
776{
777 m_pImpl->Invalidate();
778}
779
781{
782 m_pImpl->Invalidate();
783 IDocumentMarkAccess* const pMA = m_pImpl->m_rDoc.getIDocumentMarkAccess();
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 const OUString& rText, ::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 (!rText.isEmpty() || eMode & ::sw::DeleteAndInsertMode::ForceReplace) ? SwDeleteFlags::ArtificialSelection : SwDeleteFlags::Default);
890 }
891
892 if (!rText.isEmpty())
893 {
895 m_pImpl->m_rDoc, aCursor, rText, bool(eMode & ::sw::DeleteAndInsertMode::ForceExpandHints));
896
897 SwUnoCursorHelper::SelectPam(aCursor, true);
898 aCursor.Left(rText.getLength());
899 }
900 SetPositions(aCursor);
901 m_pImpl->m_rDoc.GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT, nullptr);
902}
903
904const uno::Sequence< sal_Int8 > & SwXTextRange::getUnoTunnelId()
905{
906 static const comphelper::UnoIdInit theSwXTextRangeUnoTunnelId;
907 return theSwXTextRangeUnoTunnelId.getSeq();
908}
909
910// XUnoTunnel
911sal_Int64 SAL_CALL
912SwXTextRange::getSomething(const uno::Sequence< sal_Int8 >& rId)
913{
914 return comphelper::getSomethingImpl<SwXTextRange>(rId, this);
915}
916
917OUString SAL_CALL
919{
920 return "SwXTextRange";
921}
922
923sal_Bool SAL_CALL SwXTextRange::supportsService(const OUString& rServiceName)
924{
925 return cppu::supportsService(this, rServiceName);
926}
927
928uno::Sequence< OUString > SAL_CALL
930{
931 return {
932 "com.sun.star.text.TextRange",
933 "com.sun.star.style.CharacterProperties",
934 "com.sun.star.style.CharacterPropertiesAsian",
935 "com.sun.star.style.CharacterPropertiesComplex",
936 "com.sun.star.style.ParagraphProperties",
937 "com.sun.star.style.ParagraphPropertiesAsian",
938 "com.sun.star.style.ParagraphPropertiesComplex"
939 };
940}
941
942uno::Reference< text::XText > SAL_CALL
944{
945 SolarMutexGuard aGuard;
946
947 if (!m_pImpl->m_xParentText.is() && m_pImpl->m_pTableOrSectionFormat)
948 {
949 std::optional<SwPosition> oPosition;
950 if (m_pImpl->m_eRangePosition == RANGE_IS_TABLE)
951 {
952 SwTable const*const pTable = SwTable::FindTable( m_pImpl->m_pTableOrSectionFormat );
953 SwTableNode const*const pTableNode = pTable->GetTableNode();
954 oPosition.emplace(*pTableNode);
955 }
956 else
957 {
958 assert(m_pImpl->m_eRangePosition == RANGE_IS_SECTION);
959 auto const pSectFormat(static_cast<SwSectionFormat const*>(m_pImpl->m_pTableOrSectionFormat));
960 oPosition.emplace(pSectFormat->GetContent().GetContentIdx()->GetNode());
961 }
962 m_pImpl->m_xParentText =
963 ::sw::CreateParentXText(m_pImpl->m_rDoc, *oPosition);
964 }
965 OSL_ENSURE(m_pImpl->m_xParentText.is(), "SwXTextRange::getText: no text");
966 return m_pImpl->m_xParentText;
967}
968
969uno::Reference< text::XTextRange > SAL_CALL
971{
972 SolarMutexGuard aGuard;
973
974 uno::Reference< text::XTextRange > xRet;
975 ::sw::mark::IMark const * const pBkmk = m_pImpl->GetBookmark();
976 if (!m_pImpl->m_xParentText.is())
977 {
978 getText();
979 }
980 if(pBkmk)
981 {
982 SwPaM aPam(pBkmk->GetMarkStart());
983 xRet = new SwXTextRange(aPam, m_pImpl->m_xParentText);
984 }
985 else if (RANGE_IS_TABLE == m_pImpl->m_eRangePosition)
986 {
987 // start and end are this, if it's a table
988 xRet = this;
989 }
990 else if (RANGE_IS_SECTION == m_pImpl->m_eRangePosition
991 && m_pImpl->m_pTableOrSectionFormat)
992 {
993 auto const pSectFormat(static_cast<SwSectionFormat const*>(m_pImpl->m_pTableOrSectionFormat));
994 SwPaM aPaM(*pSectFormat->GetContent().GetContentIdx());
996 assert(aPaM.GetPoint()->GetNode() < *pSectFormat->GetContent().GetContentIdx()->GetNode().EndOfSectionNode());
997 xRet = new SwXTextRange(aPaM, m_pImpl->m_xParentText);
998 }
999 else
1000 {
1001 throw uno::RuntimeException("disposed?");
1002 }
1003 return xRet;
1004}
1005
1006uno::Reference< text::XTextRange > SAL_CALL
1008{
1009 SolarMutexGuard aGuard;
1010
1011 uno::Reference< text::XTextRange > xRet;
1012 ::sw::mark::IMark const * const pBkmk = m_pImpl->GetBookmark();
1013 if (!m_pImpl->m_xParentText.is())
1014 {
1015 getText();
1016 }
1017 if(pBkmk)
1018 {
1019 SwPaM aPam(pBkmk->GetMarkEnd());
1020 xRet = new SwXTextRange(aPam, m_pImpl->m_xParentText);
1021 }
1022 else if (RANGE_IS_TABLE == m_pImpl->m_eRangePosition)
1023 {
1024 // start and end are this, if it's a table
1025 xRet = this;
1026 }
1027 else if (RANGE_IS_SECTION == m_pImpl->m_eRangePosition
1028 && m_pImpl->m_pTableOrSectionFormat)
1029 {
1030 auto const pSectFormat(static_cast<SwSectionFormat const*>(m_pImpl->m_pTableOrSectionFormat));
1031 SwPaM aPaM(*pSectFormat->GetContent().GetContentIdx()->GetNode().EndOfSectionNode());
1033 assert(*pSectFormat->GetContent().GetContentIdx() < aPaM.GetPoint()->GetNode());
1034 xRet = new SwXTextRange(aPaM, m_pImpl->m_xParentText);
1035 }
1036 else
1037 {
1038 throw uno::RuntimeException("disposed?");
1039 }
1040 return xRet;
1041}
1042
1043OUString SAL_CALL SwXTextRange::getString()
1044{
1045 SolarMutexGuard aGuard;
1046
1047 OUString sRet;
1048 // for tables there is no bookmark, thus also no text
1049 // one could export the table as ASCII here maybe?
1050 SwPaM aPaM(GetDoc().GetNodes());
1052 {
1054 }
1055 return sRet;
1056}
1057
1058void SAL_CALL SwXTextRange::setString(const OUString& rString)
1059{
1060 SolarMutexGuard aGuard;
1061
1063}
1064
1066{
1067 if (RANGE_IS_SECTION == m_pImpl->m_eRangePosition
1068 && eMode == ::sw::TextRangeMode::AllowNonTextNode)
1069 {
1070 if (auto const pSectFormat = static_cast<SwSectionFormat const*>(m_pImpl->m_pTableOrSectionFormat))
1071 {
1072 SwNodeIndex const*const pSectionNode(pSectFormat->GetContent().GetContentIdx());
1073 assert(pSectionNode);
1074 assert(pSectionNode->GetNodes().IsDocNodes());
1075 rToFill.GetPoint()->Assign( pSectionNode->GetNode(), SwNodeOffset(1) );
1076 rToFill.SetMark();
1077 rToFill.GetMark()->Assign( *pSectionNode->GetNode().EndOfSectionNode(), SwNodeOffset(-1) );
1078 if (const SwContentNode* pCNd = rToFill.GetMark()->GetContentNode())
1079 rToFill.GetMark()->AssignEndIndex(*pCNd);
1080 return true;
1081 }
1082 }
1083 ::sw::mark::IMark const * const pBkmk = m_pImpl->GetBookmark();
1084 if(pBkmk)
1085 {
1086 *rToFill.GetPoint() = pBkmk->GetMarkPos();
1087 if(pBkmk->IsExpanded())
1088 {
1089 rToFill.SetMark();
1090 *rToFill.GetMark() = pBkmk->GetOtherMarkPos();
1091 }
1092 else
1093 {
1094 rToFill.DeleteMark();
1095 }
1096 return true;
1097 }
1098 return false;
1099}
1100
1101namespace sw {
1102
1104 const uno::Reference<text::XTextRange> & xTextRange,
1105 ::sw::TextRangeMode const eMode)
1106{
1107 bool bRet = false;
1108
1109 uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY);
1110 SwXTextRange* pRange = comphelper::getFromUnoTunnel<SwXTextRange>(xRangeTunnel);
1111 OTextCursorHelper* pCursor = comphelper::getFromUnoTunnel<OTextCursorHelper>(xRangeTunnel);
1112 SwXTextPortion* pPortion = comphelper::getFromUnoTunnel<SwXTextPortion>(xRangeTunnel);
1113 SwXText* pText = comphelper::getFromUnoTunnel<SwXText>(xRangeTunnel);
1114 SwXParagraph* pPara = comphelper::getFromUnoTunnel<SwXParagraph>(xRangeTunnel);
1115 SwXHeadFootText* pHeadText
1116 = eMode == TextRangeMode::AllowTableNode ? dynamic_cast<SwXHeadFootText*>(pText) : nullptr;
1117
1118 // if it's a text then create a temporary cursor there and re-use
1119 // the pCursor variable
1120 // #i108489#: Reference in outside scope to keep cursor alive
1121 uno::Reference< text::XTextCursor > xTextCursor;
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.set(pHeadText->CreateTextCursor(true));
1128 xTextCursor->gotoEnd(true);
1129 pCursor =
1130 comphelper::getFromUnoTunnel<OTextCursorHelper>(xTextCursor);
1131 pCursor->GetPaM()->Normalize();
1132 }
1133 else
1134 if (pText)
1135 {
1136 xTextCursor.set( pText->CreateCursor() );
1137 xTextCursor->gotoEnd(true);
1138 pCursor =
1139 comphelper::getFromUnoTunnel<OTextCursorHelper>(xTextCursor);
1140 }
1141 if(pRange && &pRange->GetDoc() == &rToFill.GetDoc())
1142 {
1143 bRet = pRange->GetPositions(rToFill, eMode);
1144 }
1145 else
1146 {
1147 if (pPara)
1148 {
1149 bRet = pPara->SelectPaM(rToFill);
1150 }
1151 else
1152 {
1153 SwDoc* const pDoc = pCursor ? pCursor->GetDoc()
1154 : (pPortion ? &pPortion->GetCursor().GetDoc() : nullptr);
1155 const SwPaM* const pUnoCursor = pCursor ? pCursor->GetPaM()
1156 : (pPortion ? &pPortion->GetCursor() : nullptr);
1157 if (pUnoCursor && pDoc == &rToFill.GetDoc())
1158 {
1159 OSL_ENSURE(!pUnoCursor->IsMultiSelection(),
1160 "what to do about rings?");
1161 bRet = true;
1162 *rToFill.GetPoint() = *pUnoCursor->GetPoint();
1163 if (pUnoCursor->HasMark())
1164 {
1165 rToFill.SetMark();
1166 *rToFill.GetMark() = *pUnoCursor->GetMark();
1167 }
1168 else
1169 rToFill.DeleteMark();
1170 }
1171 }
1172 }
1173 return bRet;
1174}
1175
1176static bool
1177lcl_IsStartNodeInFormat(const bool bHeader, SwStartNode const *const pSttNode,
1178 SwFrameFormat const*const pFrameFormat, SwFrameFormat*& rpFormat)
1179{
1180 bool bRet = false;
1181 const SfxItemSet& rSet = pFrameFormat->GetAttrSet();
1182 const SfxPoolItem* pItem;
1183 if (SfxItemState::SET == rSet.GetItemState(
1184 bHeader ? sal_uInt16(RES_HEADER) : sal_uInt16(RES_FOOTER),
1185 true, &pItem))
1186 {
1187 SfxPoolItem *const pItemNonConst(const_cast<SfxPoolItem *>(pItem));
1188 SwFrameFormat *const pHeadFootFormat = bHeader ?
1189 static_cast<SwFormatHeader*>(pItemNonConst)->GetHeaderFormat() :
1190 static_cast<SwFormatFooter*>(pItemNonConst)->GetFooterFormat();
1191 if (pHeadFootFormat)
1192 {
1193 const SwFormatContent& rFlyContent = pHeadFootFormat->GetContent();
1194 const SwNode& rNode = rFlyContent.GetContentIdx()->GetNode();
1195 SwStartNode const*const pCurSttNode = rNode.FindSttNodeByType(
1197 if (pCurSttNode && (pCurSttNode == pSttNode))
1198 {
1199 rpFormat = pHeadFootFormat;
1200 bRet = true;
1201 }
1202 }
1203 }
1204 return bRet;
1205}
1206
1207} // namespace sw
1208
1209uno::Reference< text::XTextRange >
1211 SwDoc & rDoc, const SwPosition& rPos, const SwPosition *const pMark)
1212{
1213 const uno::Reference<text::XText> xParentText(
1214 ::sw::CreateParentXText(rDoc, rPos));
1215 const auto pNewCursor(rDoc.CreateUnoCursor(rPos));
1216 if(pMark)
1217 {
1218 pNewCursor->SetMark();
1219 *pNewCursor->GetMark() = *pMark;
1220 }
1221 const bool isCell( dynamic_cast<SwXCell*>(xParentText.get()) );
1222 const uno::Reference< text::XTextRange > xRet(
1223 new SwXTextRange(*pNewCursor, xParentText,
1224 isCell ? RANGE_IN_CELL : RANGE_IN_TEXT) );
1225 return xRet;
1226}
1227
1228namespace sw {
1229
1230uno::Reference< text::XText >
1232{
1233 uno::Reference< text::XText > xParentText;
1234 SwStartNode* pSttNode = rPos.GetNode().StartOfSectionNode();
1235 while(pSttNode && pSttNode->IsSectionNode())
1236 {
1237 pSttNode = pSttNode->StartOfSectionNode();
1238 }
1239 SwStartNodeType eType = pSttNode ? pSttNode->GetStartNodeType() : SwNormalStartNode;
1240 switch(eType)
1241 {
1243 {
1244 SwTableNode const*const pTableNode = pSttNode->FindTableNode();
1245 SwFrameFormat *const pTableFormat =
1246 pTableNode->GetTable().GetFrameFormat();
1247 SwTableBox *const pBox = pSttNode->GetTableBox();
1248
1249 xParentText = pBox
1250 ? SwXCell::CreateXCell( pTableFormat, pBox )
1251 : new SwXCell( pTableFormat, *pSttNode );
1252 }
1253 break;
1254 case SwFlyStartNode:
1255 {
1256 SwFrameFormat *const pFormat = pSttNode->GetFlyFormat();
1257 if (nullptr != pFormat)
1258 {
1259 xParentText = SwXTextFrame::CreateXTextFrame(rDoc, pFormat);
1260 }
1261 }
1262 break;
1263 case SwHeaderStartNode:
1264 case SwFooterStartNode:
1265 {
1266 const bool bHeader = (SwHeaderStartNode == eType);
1267 const size_t nPDescCount = rDoc.GetPageDescCnt();
1268 for(size_t i = 0; i < nPDescCount; i++)
1269 {
1270 const SwPageDesc& rDesc = rDoc.GetPageDesc( i );
1271
1272 const SwFrameFormat* pFrameFormatMaster = &rDesc.GetMaster();
1273 const SwFrameFormat* pFrameFormatLeft = &rDesc.GetLeft();
1274 const SwFrameFormat* pFrameFormatFirstMaster = &rDesc.GetFirstMaster();
1275 const SwFrameFormat* pFrameFormatFirstLeft = &rDesc.GetFirstLeft();
1276
1277 SwFrameFormat* pHeadFootFormat = nullptr;
1278 if (!lcl_IsStartNodeInFormat(bHeader, pSttNode, pFrameFormatMaster,
1279 pHeadFootFormat))
1280 {
1281 if (!lcl_IsStartNodeInFormat(bHeader, pSttNode, pFrameFormatLeft,
1282 pHeadFootFormat))
1283 {
1284 if (!lcl_IsStartNodeInFormat(bHeader, pSttNode, pFrameFormatFirstMaster,
1285 pHeadFootFormat))
1286 {
1287 lcl_IsStartNodeInFormat(bHeader, pSttNode, pFrameFormatFirstLeft, pHeadFootFormat);
1288 }
1289 }
1290 }
1291
1292 if (pHeadFootFormat)
1293 {
1295 *pHeadFootFormat, bHeader);
1296 }
1297 }
1298 }
1299 break;
1301 {
1302 const size_t nFootnoteCnt = rDoc.GetFootnoteIdxs().size();
1303 for (size_t n = 0; n < nFootnoteCnt; ++n )
1304 {
1305 const SwTextFootnote* pTextFootnote = rDoc.GetFootnoteIdxs()[ n ];
1306 const SwFormatFootnote& rFootnote = pTextFootnote->GetFootnote();
1307 pTextFootnote = rFootnote.GetTextFootnote();
1308
1309 if (pSttNode == pTextFootnote->GetStartNode()->GetNode().
1310 FindSttNodeByType(SwFootnoteStartNode))
1311 {
1312 xParentText.set(SwXFootnote::CreateXFootnote(rDoc,
1313 &const_cast<SwFormatFootnote&>(rFootnote)));
1314 break;
1315 }
1316 }
1317 }
1318 break;
1319 default:
1320 {
1321 // then it is the body text
1322 const uno::Reference<frame::XModel> xModel =
1323 rDoc.GetDocShell()->GetBaseModel();
1324 const uno::Reference< text::XTextDocument > xDoc(
1325 xModel, uno::UNO_QUERY);
1326 xParentText = xDoc->getText();
1327 }
1328 }
1329 OSL_ENSURE(xParentText.is(), "no parent text?");
1330 return xParentText;
1331}
1332
1333} // namespace sw
1334
1335uno::Reference< container::XEnumeration > SAL_CALL
1336SwXTextRange::createContentEnumeration(const OUString& rServiceName)
1337{
1339
1340 if ( rServiceName != "com.sun.star.text.TextContent" )
1341 {
1342 throw uno::RuntimeException("unsupported service");
1343 }
1344
1345 if (!m_pImpl->GetBookmark())
1346 {
1347 throw uno::RuntimeException("range has no mark (table?)");
1348 }
1349 const SwPosition aPos(GetDoc().GetNodes().GetEndOfContent());
1350 const auto pNewCursor(m_pImpl->m_rDoc.CreateUnoCursor(aPos));
1351 if (!GetPositions(*pNewCursor))
1352 {
1353 throw uno::RuntimeException("range has no positions");
1354 }
1355
1357}
1358
1359uno::Reference< container::XEnumeration > SAL_CALL
1361{
1363
1364 if (!m_pImpl->GetBookmark())
1365 {
1366 throw uno::RuntimeException("range has no mark (table?)");
1367 }
1368 const SwPosition aPos(GetDoc().GetNodes().GetEndOfContent());
1369 auto pNewCursor(m_pImpl->m_rDoc.CreateUnoCursor(aPos));
1370 if (!GetPositions(*pNewCursor))
1371 {
1372 throw uno::RuntimeException("range has no positions");
1373 }
1374 if (!m_pImpl->m_xParentText.is())
1375 {
1376 getText();
1377 }
1378
1379 const CursorType eSetType = (RANGE_IN_CELL == m_pImpl->m_eRangePosition)
1381 return SwXParagraphEnumeration::Create(m_pImpl->m_xParentText, pNewCursor, eSetType);
1382}
1383
1385{
1387}
1388
1390{
1391 return true;
1392}
1393
1394uno::Sequence< OUString > SAL_CALL
1396{
1397 uno::Sequence<OUString> aRet { "com.sun.star.text.TextContent" };
1398 return aRet;
1399}
1400
1401uno::Reference< beans::XPropertySetInfo > SAL_CALL
1403{
1404 SolarMutexGuard aGuard;
1405
1406 static uno::Reference< beans::XPropertySetInfo > xRef =
1407 m_pImpl->m_rPropSet.getPropertySetInfo();
1408 return xRef;
1409}
1410
1411void SAL_CALL
1413 const OUString& rPropertyName, const uno::Any& rValue)
1414{
1415 SolarMutexGuard aGuard;
1416
1417 if (!m_pImpl->GetBookmark())
1418 {
1419 throw uno::RuntimeException("range has no mark (table?)");
1420 }
1421 SwPaM aPaM(GetDoc().GetNodes());
1422 GetPositions(aPaM);
1424 rPropertyName, rValue);
1425}
1426
1427uno::Any SAL_CALL
1428SwXTextRange::getPropertyValue(const OUString& rPropertyName)
1429{
1430 SolarMutexGuard aGuard;
1431
1432 if (!m_pImpl->GetBookmark())
1433 {
1434 throw uno::RuntimeException("range has no mark (table?)");
1435 }
1436 SwPaM aPaM(GetDoc().GetNodes());
1437 GetPositions(aPaM);
1438 return SwUnoCursorHelper::GetPropertyValue(aPaM, m_pImpl->m_rPropSet,
1439 rPropertyName);
1440}
1441
1442void SAL_CALL
1444 const OUString& /*rPropertyName*/,
1445 const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
1446{
1447 OSL_FAIL("SwXTextRange::addPropertyChangeListener(): not implemented");
1448}
1449
1450void SAL_CALL
1452 const OUString& /*rPropertyName*/,
1453 const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
1454{
1455 OSL_FAIL("SwXTextRange::removePropertyChangeListener(): not implemented");
1456}
1457
1458void SAL_CALL
1460 const OUString& /*rPropertyName*/,
1461 const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
1462{
1463 OSL_FAIL("SwXTextRange::addVetoableChangeListener(): not implemented");
1464}
1465
1466void SAL_CALL
1468 const OUString& /*rPropertyName*/,
1469 const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
1470{
1471 OSL_FAIL("SwXTextRange::removeVetoableChangeListener(): not implemented");
1472}
1473
1474beans::PropertyState SAL_CALL
1475SwXTextRange::getPropertyState(const OUString& rPropertyName)
1476{
1477 SolarMutexGuard aGuard;
1478
1479 if (!m_pImpl->GetBookmark())
1480 {
1481 throw uno::RuntimeException("range has no mark (table?)");
1482 }
1483 SwPaM aPaM(GetDoc().GetNodes());
1484 GetPositions(aPaM);
1485 return SwUnoCursorHelper::GetPropertyState(aPaM, m_pImpl->m_rPropSet,
1486 rPropertyName);
1487}
1488
1489uno::Sequence< beans::PropertyState > SAL_CALL
1490SwXTextRange::getPropertyStates(const uno::Sequence< OUString >& rPropertyName)
1491{
1493
1494 if (!m_pImpl->GetBookmark())
1495 {
1496 throw uno::RuntimeException("range has no mark (table?)");
1497 }
1498 SwPaM aPaM(GetDoc().GetNodes());
1499 GetPositions(aPaM);
1500 return SwUnoCursorHelper::GetPropertyStates(aPaM, m_pImpl->m_rPropSet,
1501 rPropertyName);
1502}
1503
1504void SAL_CALL SwXTextRange::setPropertyToDefault(const OUString& rPropertyName)
1505{
1506 SolarMutexGuard aGuard;
1507
1508 if (!m_pImpl->GetBookmark())
1509 {
1510 throw uno::RuntimeException("range has no mark (table?)");
1511 }
1512 SwPaM aPaM(GetDoc().GetNodes());
1513 GetPositions(aPaM);
1515 rPropertyName);
1516}
1517
1518uno::Any SAL_CALL
1519SwXTextRange::getPropertyDefault(const OUString& rPropertyName)
1520{
1521 SolarMutexGuard aGuard;
1522
1523 if (!m_pImpl->GetBookmark())
1524 {
1525 throw uno::RuntimeException("range has no mark (table?)");
1526 }
1527 SwPaM aPaM(GetDoc().GetNodes());
1528 GetPositions(aPaM);
1529 return SwUnoCursorHelper::GetPropertyDefault(aPaM, m_pImpl->m_rPropSet,
1530 rPropertyName);
1531}
1532
1533void SAL_CALL
1535 const OUString& rRedlineType,
1536 const uno::Sequence< beans::PropertyValue >& rRedlineProperties )
1537{
1538 SolarMutexGuard aGuard;
1539
1540 if (!m_pImpl->GetBookmark())
1541 {
1542 throw uno::RuntimeException("range has no mark (table?)");
1543 }
1544 SwPaM aPaM(GetDoc().GetNodes());
1546 SwUnoCursorHelper::makeRedline( aPaM, rRedlineType, rRedlineProperties );
1547}
1548
1549namespace {
1550
1551struct SwXTextRangesImpl final : public SwXTextRanges
1552{
1553
1554 // XUnoTunnel
1555 virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& rIdentifier) override;
1556
1557 // XServiceInfo
1558 virtual OUString SAL_CALL getImplementationName() override
1559 { return "SwXTextRanges"; };
1560 virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName) override
1561 { return cppu::supportsService(this, rServiceName); };
1562 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
1563 { return { "com.sun.star.text.TextRanges" }; };
1564
1565 // XElementAccess
1566 virtual css::uno::Type SAL_CALL getElementType() override
1568 virtual sal_Bool SAL_CALL hasElements() override
1569 { return getCount() > 0; };
1570 // XIndexAccess
1571 virtual sal_Int32 SAL_CALL getCount() override;
1572 virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override;
1573
1574 explicit SwXTextRangesImpl(SwPaM *const pPaM)
1575 {
1576 if (pPaM)
1577 {
1578 m_pUnoCursor.reset(pPaM->GetDoc().CreateUnoCursor(*pPaM->GetPoint()));
1579 ::sw::DeepCopyPaM(*pPaM, *GetCursor());
1580 }
1581 MakeRanges();
1582 }
1583 virtual void SAL_CALL release() noexcept override
1584 {
1586 OWeakObject::release();
1587 }
1588 virtual SwUnoCursor* GetCursor() override
1589 { return &(*m_pUnoCursor); };
1590 void MakeRanges();
1591 std::vector< uno::Reference< text::XTextRange > > m_Ranges;
1592 sw::UnoCursorPointer m_pUnoCursor;
1593};
1594
1595}
1596
1597void SwXTextRangesImpl::MakeRanges()
1598{
1599 if (!GetCursor())
1600 return;
1601
1602 for(SwPaM& rTmpCursor : GetCursor()->GetRingContainer())
1603 {
1604 const uno::Reference< text::XTextRange > xRange(
1606 rTmpCursor.GetDoc(),
1607 *rTmpCursor.GetPoint(), rTmpCursor.GetMark()));
1608 if (xRange.is())
1609 {
1610 m_Ranges.push_back(xRange);
1611 }
1612 }
1613}
1614
1616 { return new SwXTextRangesImpl(pPaM); }
1617
1618const uno::Sequence< sal_Int8 > & SwXTextRanges::getUnoTunnelId()
1619{
1620 static const comphelper::UnoIdInit theSwXTextRangesUnoTunnelId;
1621 return theSwXTextRangesUnoTunnelId.getSeq();
1622}
1623
1624sal_Int64 SAL_CALL
1625SwXTextRangesImpl::getSomething(const uno::Sequence< sal_Int8 >& rId)
1626{
1627 return comphelper::getSomethingImpl<SwXTextRanges>(rId, this);
1628}
1629
1630/*
1631 * Text positions
1632 * Up to the first access to a text position, only a SwCursor is stored.
1633 * Afterwards, an array with uno::Reference<XTextPosition> will be created.
1634 */
1635
1636sal_Int32 SAL_CALL SwXTextRangesImpl::getCount()
1637{
1638 SolarMutexGuard aGuard;
1639 return static_cast<sal_Int32>(m_Ranges.size());
1640}
1641
1642uno::Any SAL_CALL SwXTextRangesImpl::getByIndex(sal_Int32 nIndex)
1643{
1644 SolarMutexGuard aGuard;
1645 if ((nIndex < 0) || (o3tl::make_unsigned(nIndex) >= m_Ranges.size()))
1646 throw lang::IndexOutOfBoundsException();
1647 uno::Any ret;
1648 ret <<= m_Ranges.at(nIndex);
1649 return ret;
1650}
1651
1652void SwUnoCursorHelper::SetString(SwCursor & rCursor, const OUString& rString)
1653{
1654 // Start/EndAction
1655 SwDoc& rDoc = rCursor.GetDoc();
1656 UnoActionContext aAction(&rDoc);
1658 if (rCursor.HasMark())
1659 {
1661 }
1662 if (!rString.isEmpty())
1663 {
1664 const bool bSuccess( SwUnoCursorHelper::DocInsertStringSplitCR(
1665 rDoc, rCursor, rString, false ) );
1666 OSL_ENSURE( bSuccess, "DocInsertStringSplitCR" );
1667 SwUnoCursorHelper::SelectPam(rCursor, true);
1668 rCursor.Left(rString.getLength());
1669 }
1671}
1672
1673namespace {
1674
1675struct SwXParaFrameEnumerationImpl final : public SwXParaFrameEnumeration
1676{
1677 // XServiceInfo
1678 virtual OUString SAL_CALL getImplementationName() override
1679 { return "SwXParaFrameEnumeration"; };
1680 virtual sal_Bool SAL_CALL supportsService(const OUString& rServiceName) override
1681 { return cppu::supportsService(this, rServiceName); };
1682 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
1683 { return {"com.sun.star.util.ContentEnumeration"}; };
1684
1685 // XEnumeration
1686 virtual sal_Bool SAL_CALL hasMoreElements() override;
1687 virtual css::uno::Any SAL_CALL nextElement() override;
1688
1689 SwXParaFrameEnumerationImpl(const SwPaM& rPaM, const enum ParaFrameMode eParaFrameMode, SwFrameFormat* const pFormat);
1690 virtual void SAL_CALL release() noexcept override
1691 {
1693 OWeakObject::release();
1694 }
1695 SwUnoCursor& GetCursor()
1696 { return *m_pUnoCursor; }
1697 void PurgeFrameClients()
1698 {
1699 if(!m_pUnoCursor)
1700 {
1701 m_vFrames.clear();
1702 m_xNextObject = nullptr;
1703 }
1704 else
1705 {
1706 // removing orphaned Clients
1707 const auto iter = std::remove_if(m_vFrames.begin(), m_vFrames.end(),
1708 [] (std::unique_ptr<sw::FrameClient>& rEntry) -> bool { return !rEntry->GetRegisteredIn(); });
1709 m_vFrames.erase(iter, m_vFrames.end());
1710 }
1711 }
1712 void FillFrame();
1713 bool CreateNextObject();
1714 uno::Reference< text::XTextContent > m_xNextObject;
1715 std::deque< std::unique_ptr<sw::FrameClient> > m_vFrames;
1716 ::sw::UnoCursorPointer m_pUnoCursor;
1717};
1718
1719}
1720
1722 { return new SwXParaFrameEnumerationImpl(rPaM, eParaFrameMode, pFormat); }
1723
1724SwXParaFrameEnumerationImpl::SwXParaFrameEnumerationImpl(
1725 const SwPaM& rPaM, const enum ParaFrameMode eParaFrameMode,
1726 SwFrameFormat* const pFormat)
1727 : m_pUnoCursor(rPaM.GetDoc().CreateUnoCursor(*rPaM.GetPoint()))
1728{
1729 if (rPaM.HasMark())
1730 {
1731 GetCursor().SetMark();
1732 *GetCursor().GetMark() = *rPaM.GetMark();
1733 }
1734 if (PARAFRAME_PORTION_PARAGRAPH == eParaFrameMode)
1735 {
1736 FrameClientSortList_t vFrames;
1737 ::CollectFrameAtNode(rPaM.GetPoint()->GetNode(), vFrames, false);
1738 std::transform(vFrames.begin(), vFrames.end(),
1739 std::back_inserter(m_vFrames),
1740 [] (FrameClientSortListEntry& rEntry) { return std::move(rEntry.pFrameClient); });
1741 }
1742 else if (pFormat)
1743 {
1744 m_vFrames.push_back(std::make_unique<sw::FrameClient>(pFormat));
1745 }
1746 else if ((PARAFRAME_PORTION_CHAR == eParaFrameMode) ||
1747 (PARAFRAME_PORTION_TEXTRANGE == eParaFrameMode))
1748 {
1749 if (PARAFRAME_PORTION_TEXTRANGE == eParaFrameMode)
1750 {
1751 //get all frames that are bound at paragraph or at character
1752 for(const SwPosFlyFrame& rFlyFrame : rPaM.GetDoc().GetAllFlyFormats(&GetCursor(), false, true))
1753 {
1754 const auto pFrameFormat = const_cast<SwFrameFormat*>(&rFlyFrame.GetFormat());
1755 m_vFrames.push_back(std::make_unique<sw::FrameClient>(pFrameFormat));
1756 }
1757 }
1758 FillFrame();
1759 }
1760}
1761
1762// Search for a FLYCNT text attribute at the cursor point and fill the frame
1763// into the array
1764void SwXParaFrameEnumerationImpl::FillFrame()
1765{
1766 if(!m_pUnoCursor->GetPointNode().IsTextNode())
1767 return;
1768 // search for objects at the cursor - anchored at/as char
1769 const auto pTextAttr = m_pUnoCursor->GetPointNode().GetTextNode()->GetTextAttrForCharAt(
1770 m_pUnoCursor->GetPoint()->GetContentIndex(), RES_TXTATR_FLYCNT);
1771 if(!pTextAttr)
1772 return;
1773 const SwFormatFlyCnt& rFlyCnt = pTextAttr->GetFlyCnt();
1774 SwFrameFormat* const pFrameFormat = rFlyCnt.GetFrameFormat();
1775 m_vFrames.push_back(std::make_unique<sw::FrameClient>(pFrameFormat));
1776}
1777
1778bool SwXParaFrameEnumerationImpl::CreateNextObject()
1779{
1780 if (m_vFrames.empty())
1781 return false;
1782
1783 SwFrameFormat* const pFormat = static_cast<SwFrameFormat*>(
1784 m_vFrames.front()->GetRegisteredIn());
1785 m_vFrames.pop_front();
1786 // the format should be valid here, otherwise the client
1787 // would have been removed by PurgeFrameClients
1788 // check for a shape first
1789 if(pFormat->Which() == RES_DRAWFRMFMT)
1790 {
1791 SdrObject* pObject(nullptr);
1792 pFormat->CallSwClientNotify(sw::FindSdrObjectHint(pObject));
1793 if(pObject)
1794 m_xNextObject.set(pObject->getUnoShape(), uno::UNO_QUERY);
1795 }
1796 else
1797 {
1798 const SwNodeIndex* pIdx = pFormat->GetContent().GetContentIdx();
1799 OSL_ENSURE(pIdx, "where is the index?");
1800 SwNode const*const pNd =
1801 m_pUnoCursor->GetDoc().GetNodes()[ pIdx->GetIndex() + 1 ];
1802
1803 if (!pNd->IsNoTextNode())
1804 {
1805 m_xNextObject = static_cast<SwXFrame*>(SwXTextFrame::CreateXTextFrame(
1806 *pFormat->GetDoc(), pFormat).get());
1807 }
1808 else if (pNd->IsGrfNode())
1809 {
1811 *pFormat->GetDoc(), pFormat));
1812 }
1813 else
1814 {
1815 assert(pNd->IsOLENode());
1817 *pFormat->GetDoc(), pFormat));
1818 }
1819 }
1820 return m_xNextObject.is();
1821}
1822
1823sal_Bool SAL_CALL
1824SwXParaFrameEnumerationImpl::hasMoreElements()
1825{
1826 SolarMutexGuard aGuard;
1827 PurgeFrameClients();
1828 return m_xNextObject.is() || CreateNextObject();
1829}
1830
1831uno::Any SAL_CALL SwXParaFrameEnumerationImpl::nextElement()
1832{
1833 SolarMutexGuard aGuard;
1834 PurgeFrameClients();
1835 if (!m_xNextObject.is() && !m_vFrames.empty())
1836 CreateNextObject();
1837 if (!m_xNextObject.is())
1838 throw container::NoSuchElementException();
1839 uno::Any aRet;
1840 aRet <<= m_xNextObject;
1841 m_xNextObject = nullptr;
1842 return aRet;
1843}
1844
1845/* 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.
virtual SwUndoId EndUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Closes undo block.
virtual SwUndoId StartUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter)=0
Opens undo block.
virtual const SwDoc * GetDoc() const =0
virtual const SwPaM * GetPaM() const =0
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:1224
bool Left(sal_uInt16 nCnt)
Definition: swcrsr.hxx:172
bool MovePara(SwWhichPara, SwMoveFnCollection const &)
Definition: swcrsr.cxx:2284
Definition: doc.hxx:192
size_t GetPageDescCnt() const
Definition: doc.hxx:884
IDocumentContentOperations const & getIDocumentContentOperations() const
Definition: doc.cxx:316
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:145
SwNodes & GetNodes()
Definition: doc.hxx:413
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:406
SwFootnoteIdxs & GetFootnoteIdxs()
Definition: doc.hxx:638
IDocumentMarkAccess * getIDocumentMarkAccess()
Definition: docbm.cxx:1793
SwPosFlyFrames GetAllFlyFormats(const SwPaM *, bool bDrawAlso, bool bAsCharAlso=false) const
Returns positions of all FlyFrames in the document.
Definition: doclay.cxx:499
std::shared_ptr< SwUnoCursor > CreateUnoCursor(const SwPosition &rPos, bool bTableCursor=false)
Definition: doc.cxx:1774
bool DeleteRowCol(const SwSelBoxes &rBoxes, RowColMode eMode=RowColMode::DeleteRow)
Definition: ndtbl.cxx:1931
const SwFrameFormats * GetSpzFrameFormats() const
Definition: doc.hxx:748
SwDocShell * GetDocShell()
Definition: doc.hxx:1355
const SwPageDesc & GetPageDesc(const size_t i) const
Definition: doc.hxx:885
Ends a section of nodes in the document model.
Definition: node.hxx:355
FlyAnchors.
Definition: fmtanchr.hxx:37
sal_uInt32 GetOrder() const
Definition: fmtanchr.hxx:71
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:67
const SwPosition * GetContentAnchor() const
Definition: fmtanchr.hxx:69
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:83
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:84
bool IsGrfNode() const
Definition: node.hxx:684
SwFrameFormat * GetFlyFormat() const
If node is in a fly return the respective format.
Definition: node.cxx:731
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:876
SwNodeOffset GetIndex() const
Definition: node.hxx:296
bool IsNoTextNode() const
Definition: node.hxx:676
SwTableBox * GetTableBox() const
If node is in a table return the respective table box.
Definition: node.cxx:766
SwDoc & GetDoc()
Definition: node.hxx:217
bool IsEndNode() const
Definition: node.hxx:660
bool IsSectionNode() const
Definition: node.hxx:672
bool IsTextNode() const
Definition: node.hxx:664
SwTableNode * FindTableNode()
Search table node, in which it is.
Definition: node.cxx:370
SwStartNode * FindSttNodeByType(SwStartNodeType eTyp)
Definition: node.cxx:776
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:137
SwNodeOffset EndOfSectionIndex() const
Definition: node.hxx:705
SwContentNode * GetContentNode()
Definition: node.hxx:643
SwTableNode * GetTableNode()
Definition: node.hxx:627
SwNodeType GetNodeType() const
Definition: node.hxx:150
bool IsOLENode() const
Definition: node.hxx:680
const SwEndNode * EndOfSectionNode() const
Definition: node.hxx:710
bool IsDocNodes() const
Is the NodesArray the regular one of Doc? (and not the UndoNds, ...) Implementation in doc....
Definition: nodes.cxx:2531
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:612
void Normalize(bool bPointFirst=true)
Normalizes PaM, i.e.
Definition: pam.cxx:670
bool IsMultiSelection() const
Definition: pam.hxx:328
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
Definition: pam.cxx:638
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:82
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
Starts a section of nodes in the document model.
Definition: node.hxx:325
SwStartNodeType GetStartNodeType() const
Definition: node.hxx:341
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:419
const SwStartNode * GetSttNd() const
Definition: swtable.hxx:471
const SwTable & GetTable() const
Definition: node.hxx:521
SwTable is one table in the document model, containing rows (which contain cells).
Definition: swtable.hxx:113
SwTableNode * GetTableNode() const
Definition: swtable.cxx:2111
SwTableFormat * GetFrameFormat()
Definition: swtable.hxx:204
static SwTable * FindTable(SwFrameFormat const *const pFormat)
Definition: swtable.cxx:2104
SwTableSortBoxes & GetTabSortBoxes()
Definition: swtable.hxx:262
bool IsNewModel() const
Definition: swtable.hxx:188
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:86
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:2135
const OUString & GetText() const
Definition: ndtxt.hxx:222
void SetRemainInSection(bool bFlag)
Definition: unocrsr.hxx:66
static rtl::Reference< SwXCell > CreateXCell(SwFrameFormat *pTableFormat, SwTableBox *pBox, SwTable *pTable=nullptr)
Definition: unotbl.cxx:1133
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:2675
css::uno::Reference< css::text::XTextCursor > CreateTextCursor(const bool bIgnoreTables=false)
Definition: unotext.cxx:2758
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:3509
static SW_DLLPUBLIC rtl::Reference< SwXTextFrame > CreateXTextFrame(SwDoc &rDoc, SwFrameFormat *pFrameFormat)
Definition: unoframe.cxx:3224
static rtl::Reference< SwXTextGraphicObject > CreateXTextGraphicObject(SwDoc &rDoc, SwFrameFormat *pFrameFormat)
Definition: unoframe.cxx:3462
SwUnoCursor & GetCursor() const
Definition: unoport.hxx:243
enum RangePosition m_eRangePosition
Definition: unoobj2.cxx:668
const ::sw::mark::IMark * m_pMark
Definition: unoobj2.cxx:672
const SwFrameFormat * m_pTableOrSectionFormat
Definition: unoobj2.cxx:671
void SetMark(::sw::mark::IMark &rMark)
Definition: unoobj2.cxx:713
const ::sw::mark::IMark * GetBookmark() const
Definition: unoobj2.cxx:712
const SfxItemPropertySet & m_rPropSet
Definition: unoobj2.cxx:667
uno::Reference< text::XText > m_xParentText
Definition: unoobj2.cxx:670
virtual ~Impl() override
Definition: unoobj2.cxx:695
virtual void Notify(const SfxHint &) override
Definition: unoobj2.cxx:725
Impl(SwDoc &rDoc, const enum RangePosition eRange, SwFrameFormat *const pTableOrSectionFormat, uno::Reference< text::XText > xParent=nullptr)
Definition: unoobj2.cxx:674
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unoobj2.cxx:904
virtual sal_Bool SAL_CALL hasElements() override
Definition: unoobj2.cxx:1389
virtual css::uno::Reference< css::text::XText > SAL_CALL getText() override
Definition: unoobj2.cxx:943
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &rIdentifier) override
Definition: unoobj2.cxx:912
const SwDoc & GetDoc() const
Definition: unoobj2.cxx:765
virtual OUString SAL_CALL getString() override
Definition: unoobj2.cxx:1043
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override
Definition: unoobj2.cxx:970
virtual void SAL_CALL addPropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unoobj2.cxx:1443
virtual void SAL_CALL removeVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unoobj2.cxx:1467
virtual OUString SAL_CALL getImplementationName() override
Definition: unoobj2.cxx:918
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unoobj2.cxx:929
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createContentEnumeration(const OUString &rServiceName) override
Definition: unoobj2.cxx:1336
virtual void SAL_CALL makeRedline(const OUString &rRedlineType, const css::uno::Sequence< css::beans::PropertyValue > &RedlineProperties) override
Definition: unoobj2.cxx:1534
void SetPositions(SwPaM const &rPam)
Definition: unoobj2.cxx:780
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override
Definition: unoobj2.cxx:1007
bool GetPositions(SwPaM &rToFill, ::sw::TextRangeMode eMode=::sw::TextRangeMode::RequireTextNode) const
Definition: unoobj2.cxx:1065
void DeleteAndInsert(const OUString &rText, ::sw::DeleteAndInsertMode eMode)
Definition: unoobj2.cxx:800
virtual css::beans::PropertyState SAL_CALL getPropertyState(const OUString &rPropertyName) override
Definition: unoobj2.cxx:1475
virtual void SAL_CALL setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue) override
Definition: unoobj2.cxx:1412
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: unoobj2.cxx:1360
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unoobj2.cxx:923
virtual void SAL_CALL setPropertyToDefault(const OUString &rPropertyName) override
Definition: unoobj2.cxx:1504
virtual void SAL_CALL setString(const OUString &rString) override
Definition: unoobj2.cxx:1058
virtual void SAL_CALL removePropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unoobj2.cxx:1451
void Invalidate()
Definition: unoobj2.cxx:775
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unoobj2.cxx:1384
virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates(const css::uno::Sequence< OUString > &rPropertyNames) override
Definition: unoobj2.cxx:1490
::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:1402
static css::uno::Reference< css::text::XTextRange > CreateXTextRange(SwDoc &rDoc, const SwPosition &rPos, const SwPosition *const pMark)
Definition: unoobj2.cxx:1210
virtual ~SwXTextRange() override
Definition: unoobj2.cxx:761
virtual css::uno::Sequence< OUString > SAL_CALL getAvailableServiceNames() override
Definition: unoobj2.cxx:1395
virtual css::uno::Any SAL_CALL getPropertyDefault(const OUString &rPropertyName) override
Definition: unoobj2.cxx:1519
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
Definition: unoobj2.cxx:1428
virtual void SAL_CALL addVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unoobj2.cxx:1459
static rtl::Reference< SwXTextTable > CreateXTextTable(SwFrameFormat *pFrameFormat)
Definition: unotbl.cxx:2001
virtual css::uno::Reference< css::text::XTextCursor > CreateCursor()
Definition: unotext.cxx:181
UnoActionContext(SwDoc *const pDoc)
Definition: unoobj2.cxx:183
~UnoActionContext() COVERITY_NOEXCEPT_FALSE
Definition: unoobj2.cxx:193
~UnoActionRemoveContext() COVERITY_NOEXCEPT_FALSE
Definition: unoobj2.cxx:241
UnoActionRemoveContext(SwDoc *const pDoc)
Definition: unoobj2.cxx:216
const css::uno::Sequence< sal_Int8 > & getSeq() const
css::uno::Type const & get()
size_type size() const
std::pair< const_iterator, bool > insert(Value &&x)
SvtBroadcaster & GetNotifier()
Definition: calbck.hxx:101
virtual void CallSwClientNotify(const SfxHint &rHint) const override
Definition: calbck.cxx:325
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:253
css::beans::PropertyState GetPropertyState(SwPaM &rPaM, const SfxItemPropertySet &rPropSet, const OUString &rPropertyName)
Definition: unoobj.cxx:2092
void makeRedline(SwPaM const &rPaM, std::u16string_view rRedlineType, const uno::Sequence< beans::PropertyValue > &rRedlineProperties)
bool DocInsertStringSplitCR(SwDoc &rDoc, const SwPaM &rNewCursor, const OUString &rText, const bool bForceExpandHints)
void GetCursorAttr(SwPaM &rPam, SfxItemSet &rSet, const bool bOnlyTextAttr=false, const bool bGetFromChrFormat=true)
Definition: unoobj2.cxx:295
void SetPropertyToDefault(SwPaM &rPaM, const SfxItemPropertySet &rPropSet, std::u16string_view rPropertyName)
Definition: unoobj.cxx:2125
css::uno::Any GetPropertyValue(SwPaM &rPaM, const SfxItemPropertySet &rPropSet, std::u16string_view rPropertyName)
Definition: unoobj.cxx:1847
void SetString(SwCursor &rCursor, const OUString &rString)
Definition: unoobj2.cxx:1652
void GetTextFromPam(SwPaM &rPam, OUString &rBuffer, SwRootFrame const *pLayout=nullptr)
Definition: unoobj.cxx:130
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:115
css::uno::Any GetPropertyDefault(SwPaM const &rPaM, const SfxItemPropertySet &rPropSet, std::u16string_view rPropertyName)
Definition: unoobj.cxx:2164
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:1231
bool XTextRangeToSwPaM(SwUnoInternalPaM &rToFill, const uno::Reference< text::XTextRange > &xTextRange, ::sw::TextRangeMode const eMode)
Definition: unoobj2.cxx:1103
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:1177
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:1133
bool GoNextPara(SwPaM &rPam, SwMoveFnCollection const &aPosPara)
Definition: pam.cxx:1216
bool GoInContent(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:1142
SwMoveFnCollection const & fnParaStart
Definition: paminit.cxx:46
SwMoveFnCollection const & fnMoveBackward
Definition: paminit.cxx:58
SwMoveFnCollection const & fnMoveForward
SwPam::Move()/Find() default argument.
Definition: paminit.cxx:59
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:1721
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:448
static rtl::Reference< SwXTextRanges > Create(SwPaM *const pCursor)
Definition: unoobj2.cxx:1615
virtual SwUnoCursor * GetCursor()=0
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unoobj2.cxx:1618
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:222
static bool lcl_CursorIsInSection(SwUnoCursor const *const pUnoCursor, SwStartNode const *const pOwnStartNode)
Definition: unoobj2.cxx:504
static SwTableNode * lcl_FindTopLevelTable(SwTableNode *const pTableNode, SwTable const *const pOwnTable)
! compare to SwShellTableCursor::FillRects() in viscrs.cxx
Definition: unoobj2.cxx:488
static void lcl_RemoveImpl(SwDoc *const pDoc)
Definition: unoobj2.cxx:206
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:788
std::deque< FrameClientSortListEntry > FrameClientSortList_t
ParaFrameMode
@ PARAFRAME_PORTION_TEXTRANGE
@ PARAFRAME_PORTION_CHAR
@ PARAFRAME_PORTION_PARAGRAPH