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