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