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