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 <docary.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 
75 using namespace ::com::sun::star;
76 
77 namespace sw {
78 
79 void 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 
100 namespace {
101 
102 struct 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  FrameClientSortListEntry entry(nIdx, nOrder, std::make_shared<sw::FrameClient>(&rFormat));
131  rFrames.push_back(entry);
132  }
133  }
134  }
135 }
136 
137 
138 void CollectFrameAtNode( const SwNodeIndex& rIdx,
139  FrameClientSortList_t& rFrames,
140  const bool bAtCharAnchoredObjs )
141 {
142  // _bAtCharAnchoredObjs:
143  // <true>: at-character anchored objects are collected
144  // <false>: at-paragraph anchored objects are collected
145 
146  // search all borders, images, and OLEs that are connected to the paragraph
147  SwDoc* pDoc = rIdx.GetNode().GetDoc();
148 
149  const auto nChkType = bAtCharAnchoredObjs ? RndStdIds::FLY_AT_CHAR : RndStdIds::FLY_AT_PARA;
150  const SwContentFrame* pCFrame;
151  const SwContentNode* pCNd;
153  nullptr != (pCNd = rIdx.GetNode().GetContentNode()) &&
154  nullptr != (pCFrame = pCNd->getLayoutFrame( pDoc->getIDocumentLayoutAccess().GetCurrentLayout())) )
155  {
156  lcl_CollectFrameAtNodeWithLayout(pCFrame, rFrames, nChkType);
157  }
158  else
159  {
160  const SwFrameFormats& rFormats = *pDoc->GetSpzFrameFormats();
161  const size_t nSize = rFormats.size();
162  for ( size_t i = 0; i < nSize; i++)
163  {
164  const SwFrameFormat* pFormat = rFormats[ i ];
165  const SwFormatAnchor& rAnchor = pFormat->GetAnchor();
166  const SwPosition* pAnchorPos;
167  if( rAnchor.GetAnchorId() == nChkType &&
168  nullptr != (pAnchorPos = rAnchor.GetContentAnchor()) &&
169  pAnchorPos->nNode == rIdx )
170  {
171 
172  // OD 2004-05-07 #i28701# - determine insert position for
173  // sorted <rFrameArr>
174  const sal_Int32 nIndex = pAnchorPos->nContent.GetIndex();
175  sal_uInt32 nOrder = rAnchor.GetOrder();
176 
177  FrameClientSortListEntry entry(nIndex, nOrder, std::make_shared<sw::FrameClient>(const_cast<SwFrameFormat*>(pFormat)));
178  rFrames.push_back(entry);
179  }
180  }
181  std::sort(rFrames.begin(), rFrames.end(), FrameClientSortListLess());
182  }
183 }
184 
186  : m_pDoc(pDoc)
187 {
189  if (pRootFrame)
190  {
191  pRootFrame->StartAllAction();
192  }
193 }
194 
195 UnoActionContext::~UnoActionContext() COVERITY_NOEXCEPT_FALSE
196 {
197  // Doc may already have been removed here
198  if (m_pDoc)
199  {
201  if (pRootFrame)
202  {
203  pRootFrame->EndAllAction();
204  }
205  }
206 }
207 
208 static void lcl_RemoveImpl(SwDoc *const pDoc)
209 {
210  assert(pDoc);
211  SwRootFrame *const pRootFrame = pDoc->getIDocumentLayoutAccess().GetCurrentLayout();
212  if (pRootFrame)
213  {
214  pRootFrame->UnoRemoveAllActions();
215  }
216 }
217 
219  : m_pDoc(pDoc)
220 {
222 }
223 
225 {
226  SwTableNode *const pTableNode = rCursor.GetNode().FindTableNode();
227  return (pTableNode && !pTableNode->GetTable().IsNewModel())
228  ? rCursor.GetDoc()
229  : nullptr;
230 }
231 
233  : m_pDoc(lcl_IsNewStyleTable(rCursor))
234 {
235  // this insanity is only necessary for old-style tables
236  // because SwRootFrame::MakeTableCursors() creates the table cursor for these
237  if (m_pDoc)
238  {
240  }
241 }
242 
244 {
245  if (m_pDoc)
246  {
248  if (pRootFrame)
249  {
250  pRootFrame->UnoRestoreAllActions();
251  }
252  }
253 }
254 
256  const SfxItemSet& rSet,
257  const SetAttrMode nAttrMode, const bool bTableMode)
258 {
259  const SetAttrMode nFlags = nAttrMode | SetAttrMode::APICALL;
260  SwDoc* pDoc = rPam.GetDoc();
261  //StartEndAction
262  UnoActionContext aAction(pDoc);
263  if (rPam.GetNext() != &rPam) // Ring of Cursors
264  {
266 
267  for(SwPaM& rCurrent : rPam.GetRingContainer())
268  {
269  if (rCurrent.HasMark() &&
270  ( bTableMode ||
271  (*rCurrent.GetPoint() != *rCurrent.GetMark()) ))
272  {
273  pDoc->getIDocumentContentOperations().InsertItemSet(rCurrent, rSet, nFlags);
274  }
275  }
276 
278  }
279  else
280  {
281  pDoc->getIDocumentContentOperations().InsertItemSet( rPam, rSet, nFlags );
282  }
283 
284  if( rSet.GetItemState( RES_PARATR_OUTLINELEVEL, false ) >= SfxItemState::DEFAULT )
285  {
286  SwTextNode * pTmpNode = rPam.GetNode().GetTextNode();
287  if ( pTmpNode )
288  {
289  rPam.GetDoc()->GetNodes().UpdateOutlineNode( *pTmpNode );
290  }
291  }
292 }
293 
294 // #i63870#
295 // split third parameter <bCurrentAttrOnly> into new parameters <bOnlyTextAttr>
296 // and <bGetFromChrFormat> to get better control about resulting <SfxItemSet>
298  SfxItemSet & rSet, const bool bOnlyTextAttr, const bool bGetFromChrFormat)
299 {
300  static const sal_uLong nMaxLookup = 1000;
301  SfxItemSet aSet( *rSet.GetPool(), rSet.GetRanges() );
302  SfxItemSet *pSet = &rSet;
303  for(SwPaM& rCurrent : rPam.GetRingContainer())
304  {
305  SwPosition const & rStart( *rCurrent.Start() );
306  SwPosition const & rEnd( *rCurrent.End() );
307  const sal_uLong nSttNd = rStart.nNode.GetIndex();
308  const sal_uLong nEndNd = rEnd .nNode.GetIndex();
309 
310  if (nEndNd - nSttNd >= nMaxLookup)
311  {
312  rSet.ClearItem();
313  rSet.InvalidateAllItems();
314  return;// uno::Any();
315  }
316 
317  // the first node inserts the values into the get set
318  // all other nodes merge their values into the get set
319  for (sal_uLong n = nSttNd; n <= nEndNd; ++n)
320  {
321  SwNode *const pNd = rPam.GetDoc()->GetNodes()[ n ];
322  switch (pNd->GetNodeType())
323  {
324  case SwNodeType::Text:
325  {
326  const sal_Int32 nStart = (n == nSttNd)
327  ? rStart.nContent.GetIndex() : 0;
328  const sal_Int32 nEnd = (n == nEndNd)
329  ? rEnd.nContent.GetIndex()
330  : pNd->GetTextNode()->GetText().getLength();
331  pNd->GetTextNode()->GetParaAttr(*pSet, nStart, nEnd, bOnlyTextAttr, bGetFromChrFormat);
332  }
333  break;
334 
335  case SwNodeType::Grf:
336  case SwNodeType::Ole:
337  static_cast<SwContentNode*>(pNd)->GetAttr( *pSet );
338  break;
339 
340  default:
341  continue; // skip this node
342  }
343 
344  if (pSet != &rSet)
345  {
346  rSet.MergeValues( aSet );
347  }
348  else
349  {
350  pSet = &aSet;
351  }
352 
353  if (aSet.Count())
354  {
355  aSet.ClearItem();
356  }
357  }
358  }
359 }
360 
361 namespace {
362 
363 struct SwXParagraphEnumerationImpl final : public SwXParagraphEnumeration
364 {
365  uno::Reference< text::XText > const m_xParentText;
366  const CursorType m_eCursorType;
370  SwStartNode const*const m_pOwnStartNode;
371  SwTable const*const m_pOwnTable;
372  const sal_uLong m_nEndIndex;
373  sal_Int32 m_nFirstParaStart;
374  sal_Int32 m_nLastParaEnd;
375  bool m_bFirstParagraph;
376  uno::Reference< text::XTextContent > m_xNextPara;
377  sw::UnoCursorPointer m_pCursor;
378 
379  SwXParagraphEnumerationImpl(
380  uno::Reference< text::XText > const& xParent,
381  const std::shared_ptr<SwUnoCursor>& pCursor,
382  const CursorType eType,
383  SwStartNode const*const pStartNode, SwTable const*const pTable)
384  : m_xParentText( xParent )
385  , m_eCursorType( eType )
386  // remember table and start node for later travelling
387  // (used in export of tables in tables)
388  , m_pOwnStartNode( pStartNode )
389  // for import of tables in tables we have to remember the actual
390  // table and start node of the current position in the enumeration.
391  , m_pOwnTable( pTable )
392  , m_nEndIndex( pCursor->End()->nNode.GetIndex() )
393  , m_nFirstParaStart( -1 )
394  , m_nLastParaEnd( -1 )
395  , m_bFirstParagraph( true )
396  , m_pCursor(pCursor)
397  {
398  OSL_ENSURE(m_xParentText.is(), "SwXParagraphEnumeration: no parent?");
399  OSL_ENSURE( !((CursorType::SelectionInTable == eType) ||
400  (CursorType::TableText == eType))
401  || (m_pOwnTable && m_pOwnStartNode),
402  "SwXParagraphEnumeration: table type but no start node or table?");
403 
404  if ((CursorType::Selection == m_eCursorType) ||
405  (CursorType::SelectionInTable == m_eCursorType))
406  {
407  SwUnoCursor & rCursor = GetCursor();
408  rCursor.Normalize();
409  m_nFirstParaStart = rCursor.GetPoint()->nContent.GetIndex();
410  m_nLastParaEnd = rCursor.GetMark()->nContent.GetIndex();
411  rCursor.DeleteMark();
412  }
413  }
414 
415  virtual ~SwXParagraphEnumerationImpl() override
416  { m_pCursor.reset(nullptr); }
417  virtual void SAL_CALL release() throw () override
418  {
419  SolarMutexGuard g;
420  OWeakObject::release();
421  }
422 
423  // XServiceInfo
424  virtual OUString SAL_CALL getImplementationName() override
425  { return "SwXParagraphEnumeration"; }
426  virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName) override
427  { return cppu::supportsService(this, rServiceName); };
428  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
429  { return {"com.sun.star.text.ParagraphEnumeration"}; };
430 
431  // XEnumeration
432  virtual sal_Bool SAL_CALL hasMoreElements() override;
433  virtual css::uno::Any SAL_CALL nextElement() override;
434 
435  SwUnoCursor& GetCursor()
436  { return *m_pCursor; }
440  uno::Reference< text::XTextContent > NextElement_Impl();
441 
446  bool IgnoreLastElement(SwUnoCursor& rCursor, bool bMovedFromTable);
447 };
448 
449 }
450 
452  uno::Reference< text::XText > const& xParent,
453  const std::shared_ptr<SwUnoCursor>& pCursor,
454  const CursorType eType,
455  SwStartNode const*const pStartNode,
456  SwTable const*const pTable)
457 {
458  return new SwXParagraphEnumerationImpl(xParent, pCursor, eType, pStartNode, pTable);
459 }
460 
461 sal_Bool SAL_CALL
462 SwXParagraphEnumerationImpl::hasMoreElements()
463 {
464  SolarMutexGuard aGuard;
465  return m_bFirstParagraph || m_xNextPara.is();
466 }
467 
469 static SwTableNode *
471  SwTableNode *const pTableNode, SwTable const*const pOwnTable)
472 {
473  // find top-most table in current context (section) level
474 
475  SwTableNode * pLast = pTableNode;
476  for (SwTableNode* pTmp = pLast;
477  pTmp != nullptr && &pTmp->GetTable() != pOwnTable; /* we must not go up higher than the own table! */
478  pTmp = pTmp->StartOfSectionNode()->FindTableNode() )
479  {
480  pLast = pTmp;
481  }
482  return pLast;
483 }
484 
485 static bool
487  SwUnoCursor const*const pUnoCursor, SwStartNode const*const pOwnStartNode)
488 {
489  // returns true if the cursor is in the section (or in a sub section!)
490  // represented by pOwnStartNode
491 
492  bool bRes = true;
493  if (pUnoCursor && pOwnStartNode)
494  {
495  const SwEndNode * pOwnEndNode = pOwnStartNode->EndOfSectionNode();
496  bRes = pOwnStartNode->GetIndex() <= pUnoCursor->Start()->nNode.GetIndex() &&
497  pUnoCursor->End()->nNode.GetIndex() <= pOwnEndNode->GetIndex();
498  }
499  return bRes;
500 }
501 
502 bool SwXParagraphEnumerationImpl::IgnoreLastElement(SwUnoCursor& rCursor, bool bMovedFromTable)
503 {
504  // Ignore the last element of a selection enumeration if this is a stub
505  // paragraph (directly after table, selection ends at paragraph start).
506 
507  if (rCursor.Start()->nNode.GetIndex() != m_nEndIndex)
508  return false;
509 
510  if (m_eCursorType != CursorType::Selection)
511  return false;
512 
513  if (!bMovedFromTable)
514  return false;
515 
516  return m_nLastParaEnd == 0;
517 }
518 
519 uno::Reference< text::XTextContent >
520 SwXParagraphEnumerationImpl::NextElement_Impl()
521 {
522  SwUnoCursor& rUnoCursor = GetCursor();
523 
524  // check for exceeding selections
525  if (!m_bFirstParagraph &&
526  ((CursorType::Selection == m_eCursorType) ||
527  (CursorType::SelectionInTable == m_eCursorType)))
528  {
529  SwPosition* pStart = rUnoCursor.Start();
530  auto aNewCursor(rUnoCursor.GetDoc()->CreateUnoCursor(*pStart));
531  // one may also go into tables here
532  if (CursorType::SelectionInTable != m_eCursorType)
533  {
534  aNewCursor->SetRemainInSection( false );
535  }
536 
537  // os 2005-01-14: This part is only necessary to detect movements out
538  // of a selection; if there is no selection we don't have to care
539  SwTableNode *const pTableNode = aNewCursor->GetNode().FindTableNode();
540  bool bMovedFromTable = false;
541  if (CursorType::SelectionInTable != m_eCursorType && pTableNode)
542  {
543  aNewCursor->GetPoint()->nNode = pTableNode->EndOfSectionIndex();
544  aNewCursor->Move(fnMoveForward, GoInNode);
545  bMovedFromTable = true;
546  }
547  else
548  {
549  aNewCursor->MovePara(GoNextPara, fnParaStart);
550  }
551  if (m_nEndIndex < aNewCursor->Start()->nNode.GetIndex())
552  {
553  return nullptr;
554  }
555 
556  if (IgnoreLastElement(*aNewCursor, bMovedFromTable))
557  {
558  return nullptr;
559  }
560  }
561 
562  bool bInTable = false;
563  if (!m_bFirstParagraph)
564  {
565  rUnoCursor.SetRemainInSection( false );
566  // what to do if already in a table?
567  SwTableNode * pTableNode = rUnoCursor.GetNode().FindTableNode();
568  pTableNode = lcl_FindTopLevelTable( pTableNode, m_pOwnTable );
569  if (pTableNode && (&pTableNode->GetTable() != m_pOwnTable))
570  {
571  // this is a foreign table: go to end
572  rUnoCursor.GetPoint()->nNode = pTableNode->EndOfSectionIndex();
573  if (!rUnoCursor.Move(fnMoveForward, GoInNode))
574  {
575  return nullptr;
576  }
577  bInTable = true;
578  }
579  }
580 
581  uno::Reference< text::XTextContent > xRef;
582  // the cursor must remain in the current section or a subsection
583  // before AND after the movement...
584  if (lcl_CursorIsInSection( &rUnoCursor, m_pOwnStartNode ) &&
585  (m_bFirstParagraph || bInTable ||
586  (rUnoCursor.MovePara(GoNextPara, fnParaStart) &&
587  lcl_CursorIsInSection( &rUnoCursor, m_pOwnStartNode ))))
588  {
589  if (m_eCursorType == CursorType::Selection || m_eCursorType == CursorType::SelectionInTable)
590  {
591  // This is a selection, check if the cursor would go past the end
592  // of the selection.
593  if (rUnoCursor.Start()->nNode.GetIndex() > m_nEndIndex)
594  return nullptr;
595  }
596 
597  SwPosition* pStart = rUnoCursor.Start();
598  const sal_Int32 nFirstContent =
599  m_bFirstParagraph ? m_nFirstParaStart : -1;
600  const sal_Int32 nLastContent =
601  (m_nEndIndex == pStart->nNode.GetIndex()) ? m_nLastParaEnd : -1;
602 
603  // position in a table, or in a simple paragraph?
604  SwTableNode * pTableNode = rUnoCursor.GetNode().FindTableNode();
605  pTableNode = lcl_FindTopLevelTable( pTableNode, m_pOwnTable );
606  if (/*CursorType::TableText != eCursorType && CursorType::SelectionInTable != eCursorType && */
607  pTableNode && (&pTableNode->GetTable() != m_pOwnTable))
608  {
609  // this is a foreign table
610  SwFrameFormat* pTableFormat = pTableNode->GetTable().GetFrameFormat();
611  xRef = SwXTextTable::CreateXTextTable(pTableFormat);
612  }
613  else
614  {
615  text::XText *const pText = m_xParentText.get();
616  xRef = SwXParagraph::CreateXParagraph(*rUnoCursor.GetDoc(),
617  pStart->nNode.GetNode().GetTextNode(),
618  static_cast<SwXText*>(pText), nFirstContent, nLastContent);
619  }
620  }
621 
622  return xRef;
623 }
624 
625 uno::Any SAL_CALL SwXParagraphEnumerationImpl::nextElement()
626 {
627  SolarMutexGuard aGuard;
628  if (m_bFirstParagraph)
629  {
630  m_xNextPara = NextElement_Impl();
631  m_bFirstParagraph = false;
632  }
633  const uno::Reference< text::XTextContent > xRef = m_xNextPara;
634  if (!xRef.is())
635  {
636  throw container::NoSuchElementException();
637  }
638  m_xNextPara = NextElement_Impl();
639 
640  uno::Any aRet;
641  aRet <<= xRef;
642  return aRet;
643 }
644 
646  : public SvtListener
647 {
648 public:
652  uno::Reference<text::XText> m_xParentText;
654  const ::sw::mark::IMark* m_pMark;
655 
656  Impl(SwDoc& rDoc, const enum RangePosition eRange,
657  SwFrameFormat* const pTableFormat,
658  const uno::Reference<text::XText>& xParent = nullptr)
659  : m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR))
660  , m_eRangePosition(eRange)
661  , m_rDoc(rDoc)
662  , m_xParentText(xParent)
663  , m_pTableFormat(pTableFormat)
664  , m_pMark(nullptr)
665  {
666  m_pTableFormat && StartListening(pTableFormat->GetNotifier());
667  }
668 
669  virtual ~Impl() override
670  {
671  // Impl owns the bookmark; delete it here: SolarMutex is locked
672  Invalidate();
673  }
674 
675  void Invalidate()
676  {
677  if (m_pMark)
678  {
679  m_rDoc.getIDocumentMarkAccess()->deleteMark(m_pMark);
680  m_pMark = nullptr;
681  }
682  m_pTableFormat = nullptr;
683  EndListeningAll();
684  }
685 
686  const ::sw::mark::IMark* GetBookmark() const { return m_pMark; }
687  void SetMark(::sw::mark::IMark& rMark)
688  {
689  EndListeningAll();
690  m_pTableFormat = nullptr;
691  m_pMark = &rMark;
692  StartListening(rMark.GetNotifier());
693  }
694 
695 protected:
696  virtual void Notify(const SfxHint&) override;
697 };
698 
700 {
701  if(rHint.GetId() == SfxHintId::Dying)
702  {
703  EndListeningAll();
704  m_pTableFormat = nullptr;
705  m_pMark = nullptr;
706  }
707 }
708 
709 SwXTextRange::SwXTextRange(SwPaM const & rPam,
710  const uno::Reference< text::XText > & xParent,
711  const enum RangePosition eRange)
712  : m_pImpl( new SwXTextRange::Impl(*rPam.GetDoc(), eRange, nullptr, xParent) )
713 {
714  SetPositions(rPam);
715 }
716 
718  : m_pImpl(
719  new SwXTextRange::Impl(*rTableFormat.GetDoc(), RANGE_IS_TABLE, &rTableFormat) )
720 {
721  SwTable *const pTable = SwTable::FindTable( &rTableFormat );
722  SwTableNode *const pTableNode = pTable->GetTableNode();
723  SwPosition aPosition( *pTableNode );
724  SwPaM aPam( aPosition );
725 
726  SetPositions( aPam );
727 }
728 
730 {
731 }
732 
734 {
735  return m_pImpl->m_rDoc;
736 }
737 
739 {
740  return m_pImpl->m_rDoc;
741 }
742 
744 {
745  m_pImpl->Invalidate();
746 }
747 
749 {
750  m_pImpl->Invalidate();
751  IDocumentMarkAccess* const pMA = m_pImpl->m_rDoc.getIDocumentMarkAccess();
753  m_pImpl->SetMark(*pMark);
754 }
755 
757  const OUString& rText, const bool bForceExpandHints)
758 {
759  if (RANGE_IS_TABLE == m_pImpl->m_eRangePosition)
760  {
761  // setString on table not allowed
762  throw uno::RuntimeException();
763  }
764 
765  const SwPosition aPos(GetDoc().GetNodes().GetEndOfContent());
766  SwCursor aCursor(aPos, nullptr);
767  if (!GetPositions(aCursor))
768  return;
769 
770  UnoActionContext aAction(& m_pImpl->m_rDoc);
771  m_pImpl->m_rDoc.GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT, nullptr);
772  if (aCursor.HasMark())
773  {
774  m_pImpl->m_rDoc.getIDocumentContentOperations().DeleteAndJoin(aCursor);
775  }
776 
777  if (!rText.isEmpty())
778  {
780  m_pImpl->m_rDoc, aCursor, rText, bForceExpandHints);
781 
782  SwUnoCursorHelper::SelectPam(aCursor, true);
783  aCursor.Left(rText.getLength());
784  }
785  SetPositions(aCursor);
786  m_pImpl->m_rDoc.GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT, nullptr);
787 }
788 
789 namespace
790 {
791  class theSwXTextRangeUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXTextRangeUnoTunnelId > {};
792 }
793 
794 const uno::Sequence< sal_Int8 > & SwXTextRange::getUnoTunnelId()
795 {
796  return theSwXTextRangeUnoTunnelId::get().getSeq();
797 }
798 
799 // XUnoTunnel
800 sal_Int64 SAL_CALL
801 SwXTextRange::getSomething(const uno::Sequence< sal_Int8 >& rId)
802 {
803  return ::sw::UnoTunnelImpl<SwXTextRange>(rId, this);
804 }
805 
806 OUString SAL_CALL
808 {
809  return "SwXTextRange";
810 }
811 
812 sal_Bool SAL_CALL SwXTextRange::supportsService(const OUString& rServiceName)
813 {
814  return cppu::supportsService(this, rServiceName);
815 }
816 
817 uno::Sequence< OUString > SAL_CALL
819 {
820  return {
821  "com.sun.star.text.TextRange",
822  "com.sun.star.style.CharacterProperties",
823  "com.sun.star.style.CharacterPropertiesAsian",
824  "com.sun.star.style.CharacterPropertiesComplex",
825  "com.sun.star.style.ParagraphProperties",
826  "com.sun.star.style.ParagraphPropertiesAsian",
827  "com.sun.star.style.ParagraphPropertiesComplex"
828  };
829 }
830 
831 uno::Reference< text::XText > SAL_CALL
833 {
834  SolarMutexGuard aGuard;
835 
836  if (!m_pImpl->m_xParentText.is())
837  {
838  if (m_pImpl->m_eRangePosition == RANGE_IS_TABLE &&
839  m_pImpl->m_pTableFormat)
840  {
841  SwTable const*const pTable = SwTable::FindTable( m_pImpl->m_pTableFormat );
842  SwTableNode const*const pTableNode = pTable->GetTableNode();
843  const SwPosition aPosition( *pTableNode );
844  m_pImpl->m_xParentText =
845  ::sw::CreateParentXText(m_pImpl->m_rDoc, aPosition);
846  }
847  }
848  OSL_ENSURE(m_pImpl->m_xParentText.is(), "SwXTextRange::getText: no text");
849  return m_pImpl->m_xParentText;
850 }
851 
852 uno::Reference< text::XTextRange > SAL_CALL
854 {
855  SolarMutexGuard aGuard;
856 
857  uno::Reference< text::XTextRange > xRet;
858  ::sw::mark::IMark const * const pBkmk = m_pImpl->GetBookmark();
859  if (!m_pImpl->m_xParentText.is())
860  {
861  getText();
862  }
863  if(pBkmk)
864  {
865  SwPaM aPam(pBkmk->GetMarkStart());
866  xRet = new SwXTextRange(aPam, m_pImpl->m_xParentText);
867  }
868  else if (RANGE_IS_TABLE == m_pImpl->m_eRangePosition)
869  {
870  // start and end are this, if it's a table
871  xRet = this;
872  }
873  else
874  {
875  throw uno::RuntimeException();
876  }
877  return xRet;
878 }
879 
880 uno::Reference< text::XTextRange > SAL_CALL
882 {
883  SolarMutexGuard aGuard;
884 
885  uno::Reference< text::XTextRange > xRet;
886  ::sw::mark::IMark const * const pBkmk = m_pImpl->GetBookmark();
887  if (!m_pImpl->m_xParentText.is())
888  {
889  getText();
890  }
891  if(pBkmk)
892  {
893  SwPaM aPam(pBkmk->GetMarkEnd());
894  xRet = new SwXTextRange(aPam, m_pImpl->m_xParentText);
895  }
896  else if (RANGE_IS_TABLE == m_pImpl->m_eRangePosition)
897  {
898  // start and end are this, if it's a table
899  xRet = this;
900  }
901  else
902  {
903  throw uno::RuntimeException();
904  }
905  return xRet;
906 }
907 
908 OUString SAL_CALL SwXTextRange::getString()
909 {
910  SolarMutexGuard aGuard;
911 
912  OUString sRet;
913  // for tables there is no bookmark, thus also no text
914  // one could export the table as ASCII here maybe?
915  SwPaM aPaM(GetDoc().GetNodes());
916  if (GetPositions(aPaM) && aPaM.HasMark())
917  {
919  }
920  return sRet;
921 }
922 
923 void SAL_CALL SwXTextRange::setString(const OUString& rString)
924 {
925  SolarMutexGuard aGuard;
926 
927  DeleteAndInsert(rString, false);
928 }
929 
930 bool SwXTextRange::GetPositions(SwPaM& rToFill) const
931 {
932  ::sw::mark::IMark const * const pBkmk = m_pImpl->GetBookmark();
933  if(pBkmk)
934  {
935  *rToFill.GetPoint() = pBkmk->GetMarkPos();
936  if(pBkmk->IsExpanded())
937  {
938  rToFill.SetMark();
939  *rToFill.GetMark() = pBkmk->GetOtherMarkPos();
940  }
941  else
942  {
943  rToFill.DeleteMark();
944  }
945  return true;
946  }
947  return false;
948 }
949 
950 namespace sw {
951 
953  const uno::Reference< text::XTextRange > & xTextRange)
954 {
955  bool bRet = false;
956 
957  uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY);
958  SwXTextRange* pRange = nullptr;
959  OTextCursorHelper* pCursor = nullptr;
960  SwXTextPortion* pPortion = nullptr;
961  SwXText* pText = nullptr;
962  SwXParagraph* pPara = nullptr;
963  if(xRangeTunnel.is())
964  {
965  pRange = ::sw::UnoTunnelGetImplementation<SwXTextRange>(xRangeTunnel);
966  pCursor =
967  ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xRangeTunnel);
968  pPortion=
969  ::sw::UnoTunnelGetImplementation<SwXTextPortion>(xRangeTunnel);
970  pText = ::sw::UnoTunnelGetImplementation<SwXText>(xRangeTunnel);
971  pPara = ::sw::UnoTunnelGetImplementation<SwXParagraph>(xRangeTunnel);
972  }
973 
974  // if it's a text then create a temporary cursor there and re-use
975  // the pCursor variable
976  // #i108489#: Reference in outside scope to keep cursor alive
977  uno::Reference< text::XTextCursor > xTextCursor;
978  if (pText)
979  {
980  xTextCursor.set( pText->CreateCursor() );
981  xTextCursor->gotoEnd(true);
982  pCursor =
983  comphelper::getUnoTunnelImplementation<OTextCursorHelper>(xTextCursor);
984  }
985  if(pRange && &pRange->GetDoc() == rToFill.GetDoc())
986  {
987  bRet = pRange->GetPositions(rToFill);
988  }
989  else
990  {
991  if (pPara)
992  {
993  bRet = pPara->SelectPaM(rToFill);
994  }
995  else
996  {
997  SwDoc* const pDoc = pCursor ? pCursor->GetDoc()
998  : (pPortion ? pPortion->GetCursor().GetDoc() : nullptr);
999  const SwPaM* const pUnoCursor = pCursor ? pCursor->GetPaM()
1000  : (pPortion ? &pPortion->GetCursor() : nullptr);
1001  if (pUnoCursor && pDoc == rToFill.GetDoc())
1002  {
1003  OSL_ENSURE(!pUnoCursor->IsMultiSelection(),
1004  "what to do about rings?");
1005  bRet = true;
1006  *rToFill.GetPoint() = *pUnoCursor->GetPoint();
1007  if (pUnoCursor->HasMark())
1008  {
1009  rToFill.SetMark();
1010  *rToFill.GetMark() = *pUnoCursor->GetMark();
1011  }
1012  else
1013  rToFill.DeleteMark();
1014  }
1015  }
1016  }
1017  return bRet;
1018 }
1019 
1020 static bool
1021 lcl_IsStartNodeInFormat(const bool bHeader, SwStartNode const *const pSttNode,
1022  SwFrameFormat const*const pFrameFormat, SwFrameFormat*& rpFormat)
1023 {
1024  bool bRet = false;
1025  const SfxItemSet& rSet = pFrameFormat->GetAttrSet();
1026  const SfxPoolItem* pItem;
1027  if (SfxItemState::SET == rSet.GetItemState(
1028  bHeader ? sal_uInt16(RES_HEADER) : sal_uInt16(RES_FOOTER),
1029  true, &pItem))
1030  {
1031  SfxPoolItem *const pItemNonConst(const_cast<SfxPoolItem *>(pItem));
1032  SwFrameFormat *const pHeadFootFormat = bHeader ?
1033  static_cast<SwFormatHeader*>(pItemNonConst)->GetHeaderFormat() :
1034  static_cast<SwFormatFooter*>(pItemNonConst)->GetFooterFormat();
1035  if (pHeadFootFormat)
1036  {
1037  const SwFormatContent& rFlyContent = pHeadFootFormat->GetContent();
1038  const SwNode& rNode = rFlyContent.GetContentIdx()->GetNode();
1039  SwStartNode const*const pCurSttNode = rNode.FindSttNodeByType(
1040  bHeader ? SwHeaderStartNode : SwFooterStartNode);
1041  if (pCurSttNode && (pCurSttNode == pSttNode))
1042  {
1043  rpFormat = pHeadFootFormat;
1044  bRet = true;
1045  }
1046  }
1047  }
1048  return bRet;
1049 }
1050 
1051 } // namespace sw
1052 
1053 uno::Reference< text::XTextRange >
1055  SwDoc & rDoc, const SwPosition& rPos, const SwPosition *const pMark)
1056 {
1057  const uno::Reference<text::XText> xParentText(
1058  ::sw::CreateParentXText(rDoc, rPos));
1059  const auto pNewCursor(rDoc.CreateUnoCursor(rPos));
1060  if(pMark)
1061  {
1062  pNewCursor->SetMark();
1063  *pNewCursor->GetMark() = *pMark;
1064  }
1065  const bool isCell( dynamic_cast<SwXCell*>(xParentText.get()) );
1066  const uno::Reference< text::XTextRange > xRet(
1067  new SwXTextRange(*pNewCursor, xParentText,
1068  isCell ? RANGE_IN_CELL : RANGE_IN_TEXT) );
1069  return xRet;
1070 }
1071 
1072 namespace sw {
1073 
1074 uno::Reference< text::XText >
1075 CreateParentXText(SwDoc & rDoc, const SwPosition& rPos)
1076 {
1077  uno::Reference< text::XText > xParentText;
1078  SwStartNode* pSttNode = rPos.nNode.GetNode().StartOfSectionNode();
1079  while(pSttNode && pSttNode->IsSectionNode())
1080  {
1081  pSttNode = pSttNode->StartOfSectionNode();
1082  }
1083  SwStartNodeType eType = pSttNode ? pSttNode->GetStartNodeType() : SwNormalStartNode;
1084  switch(eType)
1085  {
1086  case SwTableBoxStartNode:
1087  {
1088  SwTableNode const*const pTableNode = pSttNode->FindTableNode();
1089  SwFrameFormat *const pTableFormat =
1090  pTableNode->GetTable().GetFrameFormat();
1091  SwTableBox *const pBox = pSttNode->GetTableBox();
1092 
1093  xParentText = pBox
1094  ? SwXCell::CreateXCell( pTableFormat, pBox )
1095  : new SwXCell( pTableFormat, *pSttNode );
1096  }
1097  break;
1098  case SwFlyStartNode:
1099  {
1100  SwFrameFormat *const pFormat = pSttNode->GetFlyFormat();
1101  if (nullptr != pFormat)
1102  {
1103  xParentText.set(SwXTextFrame::CreateXTextFrame(rDoc, pFormat),
1104  uno::UNO_QUERY);
1105  }
1106  }
1107  break;
1108  case SwHeaderStartNode:
1109  case SwFooterStartNode:
1110  {
1111  const bool bHeader = (SwHeaderStartNode == eType);
1112  const size_t nPDescCount = rDoc.GetPageDescCnt();
1113  for(size_t i = 0; i < nPDescCount; i++)
1114  {
1115  const SwPageDesc& rDesc = rDoc.GetPageDesc( i );
1116 
1117  const SwFrameFormat* pFrameFormatMaster = &rDesc.GetMaster();
1118  const SwFrameFormat* pFrameFormatLeft = &rDesc.GetLeft();
1119  const SwFrameFormat* pFrameFormatFirstMaster = &rDesc.GetFirstMaster();
1120  const SwFrameFormat* pFrameFormatFirstLeft = &rDesc.GetFirstLeft();
1121 
1122  SwFrameFormat* pHeadFootFormat = nullptr;
1123  if (!lcl_IsStartNodeInFormat(bHeader, pSttNode, pFrameFormatMaster,
1124  pHeadFootFormat))
1125  {
1126  if (!lcl_IsStartNodeInFormat(bHeader, pSttNode, pFrameFormatLeft,
1127  pHeadFootFormat))
1128  {
1129  if (!lcl_IsStartNodeInFormat(bHeader, pSttNode, pFrameFormatFirstMaster,
1130  pHeadFootFormat))
1131  {
1132  lcl_IsStartNodeInFormat(bHeader, pSttNode, pFrameFormatFirstLeft, pHeadFootFormat);
1133  }
1134  }
1135  }
1136 
1137  if (pHeadFootFormat)
1138  {
1140  *pHeadFootFormat, bHeader);
1141  }
1142  }
1143  }
1144  break;
1145  case SwFootnoteStartNode:
1146  {
1147  const size_t nFootnoteCnt = rDoc.GetFootnoteIdxs().size();
1148  for (size_t n = 0; n < nFootnoteCnt; ++n )
1149  {
1150  const SwTextFootnote* pTextFootnote = rDoc.GetFootnoteIdxs()[ n ];
1151  const SwFormatFootnote& rFootnote = pTextFootnote->GetFootnote();
1152  pTextFootnote = rFootnote.GetTextFootnote();
1153 
1154  if (pSttNode == pTextFootnote->GetStartNode()->GetNode().
1155  FindSttNodeByType(SwFootnoteStartNode))
1156  {
1157  xParentText.set(SwXFootnote::CreateXFootnote(rDoc,
1158  &const_cast<SwFormatFootnote&>(rFootnote)), uno::UNO_QUERY);
1159  break;
1160  }
1161  }
1162  }
1163  break;
1164  default:
1165  {
1166  // then it is the body text
1167  const uno::Reference<frame::XModel> xModel =
1168  rDoc.GetDocShell()->GetBaseModel();
1169  const uno::Reference< text::XTextDocument > xDoc(
1170  xModel, uno::UNO_QUERY);
1171  xParentText = xDoc->getText();
1172  }
1173  }
1174  OSL_ENSURE(xParentText.is(), "no parent text?");
1175  return xParentText;
1176 }
1177 
1178 } // namespace sw
1179 
1180 uno::Reference< container::XEnumeration > SAL_CALL
1181 SwXTextRange::createContentEnumeration(const OUString& rServiceName)
1182 {
1183  SolarMutexGuard g;
1184 
1185  if ( rServiceName != "com.sun.star.text.TextContent" )
1186  {
1187  throw uno::RuntimeException();
1188  }
1189 
1190  if (!m_pImpl->GetBookmark())
1191  {
1192  throw uno::RuntimeException();
1193  }
1194  const SwPosition aPos(GetDoc().GetNodes().GetEndOfContent());
1195  const auto pNewCursor(m_pImpl->m_rDoc.CreateUnoCursor(aPos));
1196  if (!GetPositions(*pNewCursor))
1197  {
1198  throw uno::RuntimeException();
1199  }
1200 
1202 }
1203 
1204 uno::Reference< container::XEnumeration > SAL_CALL
1206 {
1207  SolarMutexGuard g;
1208 
1209  if (!m_pImpl->GetBookmark())
1210  {
1211  throw uno::RuntimeException();
1212  }
1213  const SwPosition aPos(GetDoc().GetNodes().GetEndOfContent());
1214  auto pNewCursor(m_pImpl->m_rDoc.CreateUnoCursor(aPos));
1215  if (!GetPositions(*pNewCursor))
1216  {
1217  throw uno::RuntimeException();
1218  }
1219  if (!m_pImpl->m_xParentText.is())
1220  {
1221  getText();
1222  }
1223 
1224  const CursorType eSetType = (RANGE_IN_CELL == m_pImpl->m_eRangePosition)
1226  return SwXParagraphEnumeration::Create(m_pImpl->m_xParentText, pNewCursor, eSetType);
1227 }
1228 
1230 {
1232 }
1233 
1235 {
1236  return true;
1237 }
1238 
1239 uno::Sequence< OUString > SAL_CALL
1241 {
1242  uno::Sequence<OUString> aRet { "com.sun.star.text.TextContent" };
1243  return aRet;
1244 }
1245 
1246 uno::Reference< beans::XPropertySetInfo > SAL_CALL
1248 {
1249  SolarMutexGuard aGuard;
1250 
1251  static uno::Reference< beans::XPropertySetInfo > xRef =
1252  m_pImpl->m_rPropSet.getPropertySetInfo();
1253  return xRef;
1254 }
1255 
1256 void SAL_CALL
1258  const OUString& rPropertyName, const uno::Any& rValue)
1259 {
1260  SolarMutexGuard aGuard;
1261 
1262  if (!m_pImpl->GetBookmark())
1263  {
1264  throw uno::RuntimeException();
1265  }
1266  SwPaM aPaM(GetDoc().GetNodes());
1267  GetPositions(aPaM);
1268  SwUnoCursorHelper::SetPropertyValue(aPaM, m_pImpl->m_rPropSet,
1269  rPropertyName, rValue);
1270 }
1271 
1272 uno::Any SAL_CALL
1273 SwXTextRange::getPropertyValue(const OUString& rPropertyName)
1274 {
1275  SolarMutexGuard aGuard;
1276 
1277  if (!m_pImpl->GetBookmark())
1278  {
1279  throw uno::RuntimeException();
1280  }
1281  SwPaM aPaM(GetDoc().GetNodes());
1282  GetPositions(aPaM);
1283  return SwUnoCursorHelper::GetPropertyValue(aPaM, m_pImpl->m_rPropSet,
1284  rPropertyName);
1285 }
1286 
1287 void SAL_CALL
1289  const OUString& /*rPropertyName*/,
1290  const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
1291 {
1292  OSL_FAIL("SwXTextRange::addPropertyChangeListener(): not implemented");
1293 }
1294 
1295 void SAL_CALL
1297  const OUString& /*rPropertyName*/,
1298  const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
1299 {
1300  OSL_FAIL("SwXTextRange::removePropertyChangeListener(): not implemented");
1301 }
1302 
1303 void SAL_CALL
1305  const OUString& /*rPropertyName*/,
1306  const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
1307 {
1308  OSL_FAIL("SwXTextRange::addVetoableChangeListener(): not implemented");
1309 }
1310 
1311 void SAL_CALL
1313  const OUString& /*rPropertyName*/,
1314  const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
1315 {
1316  OSL_FAIL("SwXTextRange::removeVetoableChangeListener(): not implemented");
1317 }
1318 
1319 beans::PropertyState SAL_CALL
1320 SwXTextRange::getPropertyState(const OUString& rPropertyName)
1321 {
1322  SolarMutexGuard aGuard;
1323 
1324  if (!m_pImpl->GetBookmark())
1325  {
1326  throw uno::RuntimeException();
1327  }
1328  SwPaM aPaM(GetDoc().GetNodes());
1329  GetPositions(aPaM);
1330  return SwUnoCursorHelper::GetPropertyState(aPaM, m_pImpl->m_rPropSet,
1331  rPropertyName);
1332 }
1333 
1334 uno::Sequence< beans::PropertyState > SAL_CALL
1335 SwXTextRange::getPropertyStates(const uno::Sequence< OUString >& rPropertyName)
1336 {
1337  SolarMutexGuard g;
1338 
1339  if (!m_pImpl->GetBookmark())
1340  {
1341  throw uno::RuntimeException();
1342  }
1343  SwPaM aPaM(GetDoc().GetNodes());
1344  GetPositions(aPaM);
1345  return SwUnoCursorHelper::GetPropertyStates(aPaM, m_pImpl->m_rPropSet,
1346  rPropertyName);
1347 }
1348 
1349 void SAL_CALL SwXTextRange::setPropertyToDefault(const OUString& rPropertyName)
1350 {
1351  SolarMutexGuard aGuard;
1352 
1353  if (!m_pImpl->GetBookmark())
1354  {
1355  throw uno::RuntimeException();
1356  }
1357  SwPaM aPaM(GetDoc().GetNodes());
1358  GetPositions(aPaM);
1360  rPropertyName);
1361 }
1362 
1363 uno::Any SAL_CALL
1364 SwXTextRange::getPropertyDefault(const OUString& rPropertyName)
1365 {
1366  SolarMutexGuard aGuard;
1367 
1368  if (!m_pImpl->GetBookmark())
1369  {
1370  throw uno::RuntimeException();
1371  }
1372  SwPaM aPaM(GetDoc().GetNodes());
1373  GetPositions(aPaM);
1374  return SwUnoCursorHelper::GetPropertyDefault(aPaM, m_pImpl->m_rPropSet,
1375  rPropertyName);
1376 }
1377 
1378 void SAL_CALL
1380  const OUString& rRedlineType,
1381  const uno::Sequence< beans::PropertyValue >& rRedlineProperties )
1382 {
1383  SolarMutexGuard aGuard;
1384 
1385  if (!m_pImpl->GetBookmark())
1386  {
1387  throw uno::RuntimeException();
1388  }
1389  SwPaM aPaM(GetDoc().GetNodes());
1391  SwUnoCursorHelper::makeRedline( aPaM, rRedlineType, rRedlineProperties );
1392 }
1393 
1394 namespace {
1395 
1396 struct SwXTextRangesImpl final : public SwXTextRanges
1397 {
1398 
1399  // XUnoTunnel
1400  virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& rIdentifier) override;
1401 
1402  // XServiceInfo
1403  virtual OUString SAL_CALL getImplementationName() override
1404  { return "SwXTextRanges"; };
1405  virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName) override
1406  { return cppu::supportsService(this, rServiceName); };
1407  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
1408  { return { "com.sun.star.text.TextRanges" }; };
1409 
1410  // XElementAccess
1411  virtual css::uno::Type SAL_CALL getElementType() override
1413  virtual sal_Bool SAL_CALL hasElements() override
1414  { return getCount() > 0; };
1415  // XIndexAccess
1416  virtual sal_Int32 SAL_CALL getCount() override;
1417  virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override;
1418 
1419  explicit SwXTextRangesImpl(SwPaM *const pPaM)
1420  {
1421  if (pPaM)
1422  {
1423  m_pUnoCursor.reset(pPaM->GetDoc()->CreateUnoCursor(*pPaM->GetPoint()));
1424  ::sw::DeepCopyPaM(*pPaM, *GetCursor());
1425  }
1426  MakeRanges();
1427  }
1428  virtual void SAL_CALL release() throw () override
1429  {
1430  SolarMutexGuard g;
1431  OWeakObject::release();
1432  }
1433  virtual SwUnoCursor* GetCursor() override
1434  { return &(*m_pUnoCursor); };
1435  void MakeRanges();
1436  std::vector< uno::Reference< text::XTextRange > > m_Ranges;
1437  sw::UnoCursorPointer m_pUnoCursor;
1438 };
1439 
1440 }
1441 
1442 void SwXTextRangesImpl::MakeRanges()
1443 {
1444  if (!GetCursor())
1445  return;
1446 
1447  for(SwPaM& rTmpCursor : GetCursor()->GetRingContainer())
1448  {
1449  const uno::Reference< text::XTextRange > xRange(
1451  *rTmpCursor.GetDoc(),
1452  *rTmpCursor.GetPoint(), rTmpCursor.GetMark()));
1453  if (xRange.is())
1454  {
1455  m_Ranges.push_back(xRange);
1456  }
1457  }
1458 }
1459 
1461  { return new SwXTextRangesImpl(pPaM); }
1462 
1463 namespace
1464 {
1465  class theSwXTextRangesUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXTextRangesUnoTunnelId > {};
1466 }
1467 
1468 const uno::Sequence< sal_Int8 > & SwXTextRanges::getUnoTunnelId()
1469  { return theSwXTextRangesUnoTunnelId::get().getSeq(); }
1470 
1471 sal_Int64 SAL_CALL
1472 SwXTextRangesImpl::getSomething(const uno::Sequence< sal_Int8 >& rId)
1473 {
1474  return ::sw::UnoTunnelImpl<SwXTextRanges>(rId, this);
1475 }
1476 
1477 /*
1478  * Text positions
1479  * Up to the first access to a text position, only a SwCursor is stored.
1480  * Afterwards, an array with uno::Reference<XTextPosition> will be created.
1481  */
1482 
1483 sal_Int32 SAL_CALL SwXTextRangesImpl::getCount()
1484 {
1485  SolarMutexGuard aGuard;
1486  return static_cast<sal_Int32>(m_Ranges.size());
1487 }
1488 
1489 uno::Any SAL_CALL SwXTextRangesImpl::getByIndex(sal_Int32 nIndex)
1490 {
1491  SolarMutexGuard aGuard;
1492  if ((nIndex < 0) || (o3tl::make_unsigned(nIndex) >= m_Ranges.size()))
1493  throw lang::IndexOutOfBoundsException();
1494  uno::Any ret;
1495  ret <<= m_Ranges.at(nIndex);
1496  return ret;
1497 }
1498 
1499 void SwUnoCursorHelper::SetString(SwCursor & rCursor, const OUString& rString)
1500 {
1501  // Start/EndAction
1502  SwDoc *const pDoc = rCursor.GetDoc();
1503  UnoActionContext aAction(pDoc);
1505  if (rCursor.HasMark())
1506  {
1508  }
1509  if (!rString.isEmpty())
1510  {
1511  const bool bSuccess( SwUnoCursorHelper::DocInsertStringSplitCR(
1512  *pDoc, rCursor, rString, false ) );
1513  OSL_ENSURE( bSuccess, "DocInsertStringSplitCR" );
1514  SwUnoCursorHelper::SelectPam(rCursor, true);
1515  rCursor.Left(rString.getLength());
1516  }
1517  pDoc->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT, nullptr);
1518 }
1519 
1520 namespace {
1521 
1522 struct SwXParaFrameEnumerationImpl final : public SwXParaFrameEnumeration
1523 {
1524  // XServiceInfo
1525  virtual OUString SAL_CALL getImplementationName() override
1526  { return "SwXParaFrameEnumeration"; };
1527  virtual sal_Bool SAL_CALL supportsService(const OUString& rServiceName) override
1528  { return cppu::supportsService(this, rServiceName); };
1529  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
1530  { return {"com.sun.star.util.ContentEnumeration"}; };
1531 
1532  // XEnumeration
1533  virtual sal_Bool SAL_CALL hasMoreElements() override;
1534  virtual css::uno::Any SAL_CALL nextElement() override;
1535 
1536  SwXParaFrameEnumerationImpl(const SwPaM& rPaM, const enum ParaFrameMode eParaFrameMode, SwFrameFormat* const pFormat);
1537  virtual void SAL_CALL release() throw () override
1538  {
1539  SolarMutexGuard g;
1540  OWeakObject::release();
1541  }
1542  SwUnoCursor& GetCursor()
1543  { return *m_pUnoCursor; }
1544  void PurgeFrameClients()
1545  {
1546  if(!m_pUnoCursor)
1547  {
1548  m_vFrames.clear();
1549  m_xNextObject = nullptr;
1550  }
1551  else
1552  {
1553  // removing orphaned Clients
1554  const auto iter = std::remove_if(m_vFrames.begin(), m_vFrames.end(),
1555  [] (std::shared_ptr<sw::FrameClient>& rEntry) -> bool { return !rEntry->GetRegisteredIn(); });
1556  m_vFrames.erase(iter, m_vFrames.end());
1557  }
1558  }
1559  void FillFrame();
1560  bool CreateNextObject();
1561  uno::Reference< text::XTextContent > m_xNextObject;
1562  FrameClientList_t m_vFrames;
1563  ::sw::UnoCursorPointer m_pUnoCursor;
1564 };
1565 
1566 }
1567 
1568 SwXParaFrameEnumeration* SwXParaFrameEnumeration::Create(const SwPaM& rPaM, const enum ParaFrameMode eParaFrameMode, SwFrameFormat* const pFormat)
1569  { return new SwXParaFrameEnumerationImpl(rPaM, eParaFrameMode, pFormat); }
1570 
1571 SwXParaFrameEnumerationImpl::SwXParaFrameEnumerationImpl(
1572  const SwPaM& rPaM, const enum ParaFrameMode eParaFrameMode,
1573  SwFrameFormat* const pFormat)
1574  : m_pUnoCursor(rPaM.GetDoc()->CreateUnoCursor(*rPaM.GetPoint()))
1575 {
1576  if (rPaM.HasMark())
1577  {
1578  GetCursor().SetMark();
1579  *GetCursor().GetMark() = *rPaM.GetMark();
1580  }
1581  if (PARAFRAME_PORTION_PARAGRAPH == eParaFrameMode)
1582  {
1583  FrameClientSortList_t vFrames;
1584  ::CollectFrameAtNode(rPaM.GetPoint()->nNode, vFrames, false);
1585  std::transform(vFrames.begin(), vFrames.end(),
1586  std::back_inserter(m_vFrames),
1587  [] (const FrameClientSortListEntry& rEntry) { return rEntry.pFrameClient; });
1588  }
1589  else if (pFormat)
1590  {
1591  m_vFrames.push_back(std::make_shared<sw::FrameClient>(pFormat));
1592  }
1593  else if ((PARAFRAME_PORTION_CHAR == eParaFrameMode) ||
1594  (PARAFRAME_PORTION_TEXTRANGE == eParaFrameMode))
1595  {
1596  if (PARAFRAME_PORTION_TEXTRANGE == eParaFrameMode)
1597  {
1598  //get all frames that are bound at paragraph or at character
1599  for(const auto& pFlyFrame : rPaM.GetDoc()->GetAllFlyFormats(&GetCursor(), false, true))
1600  {
1601  const auto pFrameFormat = const_cast<SwFrameFormat*>(&pFlyFrame->GetFormat());
1602  m_vFrames.push_back(std::make_shared<sw::FrameClient>(pFrameFormat));
1603  }
1604  }
1605  FillFrame();
1606  }
1607 }
1608 
1609 // Search for a FLYCNT text attribute at the cursor point and fill the frame
1610 // into the array
1611 void SwXParaFrameEnumerationImpl::FillFrame()
1612 {
1613  if(!m_pUnoCursor->GetNode().IsTextNode())
1614  return;
1615  // search for objects at the cursor - anchored at/as char
1616  const auto pTextAttr = m_pUnoCursor->GetNode().GetTextNode()->GetTextAttrForCharAt(
1617  m_pUnoCursor->GetPoint()->nContent.GetIndex(), RES_TXTATR_FLYCNT);
1618  if(!pTextAttr)
1619  return;
1620  const SwFormatFlyCnt& rFlyCnt = pTextAttr->GetFlyCnt();
1621  SwFrameFormat* const pFrameFormat = rFlyCnt.GetFrameFormat();
1622  m_vFrames.push_back(std::make_shared<sw::FrameClient>(pFrameFormat));
1623 }
1624 
1625 bool SwXParaFrameEnumerationImpl::CreateNextObject()
1626 {
1627  if (m_vFrames.empty())
1628  return false;
1629 
1630  SwFrameFormat* const pFormat = static_cast<SwFrameFormat*>(
1631  m_vFrames.front()->GetRegisteredIn());
1632  m_vFrames.pop_front();
1633  // the format should be valid here, otherwise the client
1634  // would have been removed by PurgeFrameClients
1635  // check for a shape first
1636  if(pFormat->Which() == RES_DRAWFRMFMT)
1637  {
1638  SdrObject* pObject(nullptr);
1639  pFormat->CallSwClientNotify(sw::FindSdrObjectHint(pObject));
1640  if(pObject)
1641  m_xNextObject.set(pObject->getUnoShape(), uno::UNO_QUERY);
1642  }
1643  else
1644  {
1645  const SwNodeIndex* pIdx = pFormat->GetContent().GetContentIdx();
1646  OSL_ENSURE(pIdx, "where is the index?");
1647  SwNode const*const pNd =
1648  m_pUnoCursor->GetDoc()->GetNodes()[ pIdx->GetIndex() + 1 ];
1649 
1650  if (!pNd->IsNoTextNode())
1651  {
1652  m_xNextObject.set(SwXTextFrame::CreateXTextFrame(
1653  *pFormat->GetDoc(), pFormat));
1654  }
1655  else if (pNd->IsGrfNode())
1656  {
1658  *pFormat->GetDoc(), pFormat));
1659  }
1660  else
1661  {
1662  assert(pNd->IsOLENode());
1664  *pFormat->GetDoc(), pFormat));
1665  }
1666  }
1667  return m_xNextObject.is();
1668 }
1669 
1670 sal_Bool SAL_CALL
1671 SwXParaFrameEnumerationImpl::hasMoreElements()
1672 {
1673  SolarMutexGuard aGuard;
1674  PurgeFrameClients();
1675  return m_xNextObject.is() || CreateNextObject();
1676 }
1677 
1678 uno::Any SAL_CALL SwXParaFrameEnumerationImpl::nextElement()
1679 {
1680  SolarMutexGuard aGuard;
1681  PurgeFrameClients();
1682  if (!m_xNextObject.is() && !m_vFrames.empty())
1683  CreateNextObject();
1684  if (!m_xNextObject.is())
1685  throw container::NoSuchElementException();
1686  uno::Any aRet;
1687  aRet <<= m_xNextObject;
1688  m_xNextObject = nullptr;
1689  return aRet;
1690 }
1691 
1692 /* 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:759
const SwEndNode * EndOfSectionNode() const
Definition: node.hxx:682
Starts a section of nodes in the document model.
Definition: node.hxx:303
bool MovePara(SwWhichPara, SwMoveFnCollection const &)
Definition: swcrsr.cxx:2242
std::shared_ptr< SwUnoCursor > CreateUnoCursor(const SwPosition &rPos, bool bTableCursor=false)
Definition: doc.cxx:1779
void DeleteMark()
Definition: pam.hxx:177
static css::uno::Reference< css::text::XTextTable > CreateXTextTable(SwFrameFormat *pFrameFormat)
Definition: unotbl.cxx:2017
sal_uLong GetIndex() const
Definition: node.hxx:282
uno::Reference< text::XText > m_xParentText
Definition: unoobj2.cxx:652
SwNode & GetNode(bool bPoint=true) const
Definition: pam.hxx:223
sal_Int32 nIndex
virtual const SwDoc * GetDoc() const =0
const SwSortedObjs * GetDrawObjs() const
Definition: frame.hxx:545
Marks a position in the document model.
Definition: pam.hxx:35
void makeRedline(SwPaM const &rPaM, const OUString &rRedlineType, const uno::Sequence< beans::PropertyValue > &rRedlineProperties)
bool IsSectionNode() const
Definition: node.hxx:644
bool IsMultiSelection() const
Definition: pam.hxx:272
bool IsGrfNode() const
Definition: node.hxx:656
SwFrameFormat & GetLeft()
Definition: pagedesc.hxx:218
#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:749
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:2532
~UnoActionContext() COVERITY_NOEXCEPT_FALSE
Definition: unoobj2.cxx:195
SwDocShell * GetDocShell()
Definition: doc.hxx:1348
static SwXTextRanges * Create(SwPaM *const pCursor)
Definition: unoobj2.cxx:1460
constexpr TypedWhichId< SwFormatHeader > RES_HEADER(96)
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unoobj2.cxx:818
SwNodeIndex nNode
Definition: pam.hxx:37
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &rIdentifier) override
Definition: unoobj2.cxx:801
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:1312
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:743
const SwPosition * GetMark() const
Definition: pam.hxx:209
SwFrameFormat & GetFirstMaster()
Definition: pagedesc.hxx:219
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1190
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:184
SwMoveFnCollection const & fnParaStart
Definition: paminit.cxx:46
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getEnd() override
Definition: unoobj2.cxx:881
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:185
SwNode & GetNode() const
Definition: ndindex.hxx:119
Content, content of frame (header, footer, fly).
Definition: fmtcntnt.hxx:31
IDocumentMarkAccess * getIDocumentMarkAccess()
Definition: docbm.cxx:1682
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
virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates(const css::uno::Sequence< OUString > &rPropertyNames) override
Definition: unoobj2.cxx:1335
IDocumentContentOperations const & getIDocumentContentOperations() const
Definition: doc.cxx:315
EmbeddedObjectRef * pObject
The root element of a Writer document layout.
Definition: rootfrm.hxx:80
bool SelectPaM(SwPaM &rPaM)
make rPaM select the paragraph
SwTableFormat * GetFrameFormat()
Definition: swtable.hxx:201
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:739
SfxHintId GetId() const
SwPosFlyFrames GetAllFlyFormats(const SwPaM *, bool bDrawAlso, bool bAsCharAlso=false) const
Returns positions of all FlyFrames in the document.
Definition: doclay.cxx:502
void SetString(SwCursor &rCursor, const OUString &rString)
Definition: unoobj2.cxx:1499
SwDoc * m_pDoc
Definition: docbm.cxx:1190
const SwTextFootnote * GetTextFootnote() const
Definition: fmtftn.hxx:86
const SwDoc & GetDoc() const
Definition: unoobj2.cxx:733
void SetRemainInSection(bool bFlag)
Definition: unocrsr.hxx:65
SwNodeType GetNodeType() const
Definition: node.hxx:144
void GetCursorAttr(SwPaM &rPam, SfxItemSet &rSet, const bool bOnlyTextAttr=false, const bool bGetFromChrFormat=true)
Definition: unoobj2.cxx:297
void UnoRestoreAllActions()
Definition: pagechg.cxx:1934
SwIndex nContent
Definition: pam.hxx:38
const BorderLinePrimitive2D *pCandidateB assert(pCandidateA)
static void lcl_RemoveImpl(SwDoc *const pDoc)
Definition: unoobj2.cxx:208
Footer, for pageformats Client of FrameFormat describing the footer.
Definition: fmthdft.hxx:64
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:1568
constexpr TypedWhichId< SfxUInt16Item > RES_PARATR_OUTLINELEVEL(79)
sal_uLong GetIndex() const
Definition: ndindex.hxx:152
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:1349
const SwTable & GetTable() const
Definition: node.hxx:497
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:470
css::uno::Any GetPropertyDefault(SwPaM const &rPaM, const SfxItemPropertySet &rPropSet, const OUString &rPropertyName)
Definition: unoobj.cxx:2045
size_type size() const
bool XTextRangeToSwPaM(SwUnoInternalPaM &rToFill, const uno::Reference< text::XTextRange > &xTextRange)
Definition: unoobj2.cxx:952
css::uno::Reference< css::frame::XModel > GetBaseModel() const
const ::sw::mark::IMark * GetBookmark() const
Definition: unoobj2.cxx:686
SwPaM * GetNext()
Definition: pam.hxx:264
void Normalize(bool bPointFirst=true)
Normalizes PaM, i.e.
Definition: pam.cxx:538
static SwXCell * CreateXCell(SwFrameFormat *pTableFormat, SwTableBox *pBox, SwTable *pTable=nullptr)
Definition: unotbl.cxx:1147
Specific frame formats (frames, DrawObjects).
void SelectPam(SwPaM &rPam, const bool bExpand)
Definition: unoobj.cxx:111
bool IsOLENode() const
Definition: node.hxx:652
static bool lcl_CursorIsInSection(SwUnoCursor const *const pUnoCursor, SwStartNode const *const pOwnStartNode)
Definition: unoobj2.cxx:486
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unoobj2.cxx:812
virtual std::unique_ptr< ILazyDeleter > deleteMark(const IDocumentMarkAccess::const_iterator_t &ppMark)=0
Deletes a mark.
virtual css::uno::Reference< css::text::XText > SAL_CALL getText() override
Definition: unoobj2.cxx:832
void EndListeningAll()
virtual void SAL_CALL makeRedline(const OUString &rRedlineType, const css::uno::Sequence< css::beans::PropertyValue > &RedlineProperties) override
Definition: unoobj2.cxx:1379
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:756
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
Definition: pam.cxx:501
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:1922
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &rPropertyName) override
Definition: unoobj2.cxx:1273
virtual css::beans::PropertyState SAL_CALL getPropertyState(const OUString &rPropertyName) override
Definition: unoobj2.cxx:1320
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
Style of a layout element.
Definition: frmfmt.hxx:57
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:687
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:954
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:131
const SwPosition * GetPoint() const
Definition: pam.hxx:207
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:65
const SwPageDesc & GetPageDesc(const size_t i) const
Definition: doc.hxx:878
const SfxItemPropertySet & m_rPropSet
Definition: unoobj2.cxx:649
const SwPosition * GetContentAnchor() const
Definition: fmtanchr.hxx:67
virtual void SAL_CALL setString(const OUString &rString) override
Definition: unoobj2.cxx:923
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:2095
void CollectFrameAtNode(const SwNodeIndex &rIdx, FrameClientSortList_t &rFrames, const bool bAtCharAnchoredObjs)
Definition: unoobj2.cxx:138
const SwFrameFormat * m_pTableFormat
Definition: unoobj2.cxx:653
SetAttrMode
Definition: swtypes.hxx:135
SwContentNode * GetContentNode()
Definition: node.hxx:615
FlyAnchors.
Definition: fmtanchr.hxx:34
static SwXParagraphEnumeration * Create(css::uno::Reference< css::text::XText > const &xParent, const std::shared_ptr< SwUnoCursor > &pCursor, const CursorType eType, SwStartNode const *const pStartNode=nullptr, SwTable const *const pTable=nullptr)
Definition: unoobj2.cxx:451
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:205
SwDoc * GetDoc()
Definition: node.hxx:702
SwDoc * GetDoc() const
Definition: pam.hxx:243
std::deque< std::shared_ptr< sw::FrameClient > > FrameClientList_t
UnoActionRemoveContext(SwDoc *const pDoc)
Definition: unoobj2.cxx:218
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:1288
size_t GetPageDescCnt() const
Definition: doc.hxx:877
unsigned char sal_Bool
virtual css::uno::Reference< css::text::XTextCursor > CreateCursor()
Definition: unotext.cxx:174
virtual sal_Bool SAL_CALL hasElements() override
Definition: unoobj2.cxx:1234
bool IsNoTextNode() const
Definition: node.hxx:648
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override
Definition: unoobj2.cxx:853
virtual void SAL_CALL addVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unoobj2.cxx:1304
Marks a node in the document model.
Definition: ndindex.hxx:31
virtual ~Impl() override
Definition: unoobj2.cxx:669
Impl(SwDoc &rDoc, const enum RangePosition eRange, SwFrameFormat *const pTableFormat, const uno::Reference< text::XText > &xParent=nullptr)
Definition: unoobj2.cxx:656
css::uno::Type const & get()
static SwDoc * lcl_IsNewStyleTable(SwUnoTableCursor const &rCursor)
Definition: unoobj2.cxx:224
ring_container GetRingContainer()
Definition: ring.hxx:240
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createContentEnumeration(const OUString &rServiceName) override
Definition: unoobj2.cxx:1181
void MergeValues(const SfxItemSet &rSet)
SwStartNodeType GetStartNodeType() const
Definition: node.hxx:320
const SwDoc * GetDoc() const
The document is set in SwAttrPool now, therefore you always can access it.
Definition: format.hxx:119
bool StartListening(SvtBroadcaster &rBroadcaster)
virtual ~SwXTextRange() override
Definition: unoobj2.cxx:729
SfxItemPool * GetPool() const
const SwFormatFootnote & GetFootnote() const
Definition: txatbase.hxx:200
virtual void SAL_CALL setPropertyValue(const OUString &rPropertyName, const css::uno::Any &rValue) override
Definition: unoobj2.cxx:1257
virtual void SAL_CALL removePropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unoobj2.cxx:1296
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unoobj2.cxx:1229
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:405
SwTable is one table in the document model, containing rows (which contain cells).
Definition: swtable.hxx:110
const SwPosition * Start() const
Definition: pam.hxx:212
enum RangePosition m_eRangePosition
Definition: unoobj2.cxx:650
const SwNodeIndex * GetContentIdx() const
Definition: fmtcntnt.hxx:46
virtual OUString SAL_CALL getImplementationName() override
Definition: unoobj2.cxx:807
SvtBroadcaster & GetNotifier()
Definition: calbck.hxx:93
virtual const SwPaM * GetPaM() const =0
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: unoobj2.cxx:1247
sal_uInt16 Which() const
for Querying of Writer-functions.
Definition: format.hxx:78
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unoobj2.cxx:794
SwFrameFormat & GetMaster()
Definition: pagedesc.hxx:217
sal_uLong EndOfSectionIndex() const
Definition: node.hxx:677
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:80
ParaFrameMode
void SetPropertyToDefault(SwPaM &rPaM, const SfxItemPropertySet &rPropSet, const OUString &rPropertyName)
Definition: unoobj.cxx:2005
css::uno::Any GetPropertyValue(SwPaM &rPaM, const SfxItemPropertySet &rPropSet, const OUString &rPropertyName)
Definition: unoobj.cxx:1724
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:1899
bool GetPositions(SwPaM &rToFill) const
Definition: unoobj2.cxx:930
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:220
static bool lcl_IsStartNodeInFormat(const bool bHeader, SwStartNode const *const pSttNode, SwFrameFormat const *const pFrameFormat, SwFrameFormat *&rpFormat)
Definition: unoobj2.cxx:1021
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:403
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:1240
const ::sw::mark::IMark * m_pMark
Definition: unoobj2.cxx:654
bool GoNextPara(SwPaM &rPam, SwMoveFnCollection const &aPosPara)
Definition: pam.cxx:1037
static SW_DLLPUBLIC css::uno::Reference< css::text::XTextFrame > CreateXTextFrame(SwDoc &rDoc, SwFrameFormat *pFrameFormat)
Definition: unoframe.cxx:3178
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:386
SwUnoPropertyMapProvider aSwMapProvider
Definition: unomap1.cxx:89
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unoobj2.cxx:1468
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:699
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:376
~UnoActionRemoveContext() COVERITY_NOEXCEPT_FALSE
Definition: unoobj2.cxx:243
SwTableNode * FindTableNode()
Search table node, in which it is.
Definition: node.cxx:352
void SetCursorAttr(SwPaM &rPam, const SfxItemSet &rSet, const SetAttrMode nAttrMode, const bool bTableMode=false)
Definition: unoobj2.cxx:255
const sal_uInt16 * GetRanges() const
constexpr TypedWhichId< SwFormatFooter > RES_FOOTER(97)
SwNodeIndex * GetStartNode() const
Definition: txtftn.hxx:41
SwFootnoteIdxs & GetFootnoteIdxs()
Definition: doc.hxx:628
::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:1205
size_t size() const
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:3470
virtual const SwPosition & GetMarkStart() const =0
Ends a section of nodes in the document model.
Definition: node.hxx:333
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:1865
static css::uno::Reference< css::text::XTextContent > CreateXTextGraphicObject(SwDoc &rDoc, SwFrameFormat *pFrameFormat)
Definition: unoframe.cxx:3423
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:475
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:116
static css::uno::Reference< css::text::XTextRange > CreateXTextRange(SwDoc &rDoc, const SwPosition &rPos, const SwPosition *const pMark)
Definition: unoobj2.cxx:1054
void EndAllAction(bool bVirDev=false)
Definition: pagechg.cxx:1877
virtual css::uno::Any SAL_CALL getPropertyDefault(const OUString &rPropertyName) override
Definition: unoobj2.cxx:1364
bool IsNewModel() const
Definition: swtable.hxx:185
virtual bool IsExpanded() const =0
void DeepCopyPaM(SwPaM const &rSource, SwPaM &rTarget)
Definition: unoobj2.cxx:79
void SetPositions(SwPaM const &rPam)
Definition: unoobj2.cxx:748
virtual OUString SAL_CALL getString() override
Definition: unoobj2.cxx:908
SwFrameFormat * GetFlyFormat() const
If node is in a fly return the respective format.
Definition: node.cxx:714
uno::Reference< text::XText > CreateParentXText(SwDoc &rDoc, const SwPosition &rPos)
Definition: unoobj2.cxx:1075
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:844
virtual const SwPosition & GetOtherMarkPos() const =0
SwTableNode * GetTableNode() const
Definition: swtable.cxx:1929
Base class of the Writer document model elements.
Definition: node.hxx:79