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