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 OUString("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 =
667  static_cast<SwFrameFormat*>(pTableNode->GetTable().GetFrameFormat());
668  xRef = SwXTextTable::CreateXTextTable(pTableFormat);
669  }
670  else
671  {
672  text::XText *const pText = m_xParentText.get();
673  xRef = SwXParagraph::CreateXParagraph(*rUnoCursor.GetDoc(),
674  pStart->nNode.GetNode().GetTextNode(),
675  static_cast<SwXText*>(pText), nFirstContent, nLastContent);
676  }
677  }
678 
679  return xRef;
680 }
681 
683 {
684  SolarMutexGuard aGuard;
685  if (m_bFirstParagraph)
686  {
688  m_bFirstParagraph = false;
689  }
690  const uno::Reference< text::XTextContent > xRef = m_xNextPara;
691  if (!xRef.is())
692  {
693  throw container::NoSuchElementException();
694  }
696 
697  uno::Any aRet;
698  aRet <<= xRef;
699  return aRet;
700 }
701 
703  : public SvtListener
704 {
705 public:
709  uno::Reference<text::XText> m_xParentText;
711  const ::sw::mark::IMark* m_pMark;
712 
713  Impl(SwDoc& rDoc, const enum RangePosition eRange,
714  SwFrameFormat* const pTableFormat,
715  const uno::Reference<text::XText>& xParent = nullptr)
716  : m_rPropSet(*aSwMapProvider.GetPropertySet(PROPERTY_MAP_TEXT_CURSOR))
717  , m_eRangePosition(eRange)
718  , m_rDoc(rDoc)
719  , m_xParentText(xParent)
720  , m_pTableFormat(pTableFormat)
721  , m_pMark(nullptr)
722  {
723  m_pTableFormat && StartListening(pTableFormat->GetNotifier());
724  }
725 
726  virtual ~Impl() override
727  {
728  // Impl owns the bookmark; delete it here: SolarMutex is locked
729  Invalidate();
730  }
731 
732  void Invalidate()
733  {
734  if (m_pMark)
735  {
736  m_rDoc.getIDocumentMarkAccess()->deleteMark(m_pMark);
737  m_pMark = nullptr;
738  }
739  m_pTableFormat = nullptr;
740  EndListeningAll();
741  }
742 
743  const ::sw::mark::IMark* GetBookmark() const { return m_pMark; }
744  void SetMark(::sw::mark::IMark& rMark)
745  {
746  EndListeningAll();
747  m_pTableFormat = nullptr;
748  m_pMark = &rMark;
749  StartListening(rMark.GetNotifier());
750  }
751 
752 protected:
753  virtual void Notify(const SfxHint&) override;
754 };
755 
757 {
758  if(rHint.GetId() == SfxHintId::Dying)
759  {
760  EndListeningAll();
761  m_pTableFormat = nullptr;
762  m_pMark = nullptr;
763  }
764 }
765 
766 SwXTextRange::SwXTextRange(SwPaM const & rPam,
767  const uno::Reference< text::XText > & xParent,
768  const enum RangePosition eRange)
769  : m_pImpl( new SwXTextRange::Impl(*rPam.GetDoc(), eRange, nullptr, xParent) )
770 {
771  SetPositions(rPam);
772 }
773 
775  : m_pImpl(
776  new SwXTextRange::Impl(*rTableFormat.GetDoc(), RANGE_IS_TABLE, &rTableFormat) )
777 {
778  SwTable *const pTable = SwTable::FindTable( &rTableFormat );
779  SwTableNode *const pTableNode = pTable->GetTableNode();
780  SwPosition aPosition( *pTableNode );
781  SwPaM aPam( aPosition );
782 
783  SetPositions( aPam );
784 }
785 
787 {
788 }
789 
791 {
792  return m_pImpl->m_rDoc;
793 }
794 
796 {
797  return m_pImpl->m_rDoc;
798 }
799 
801 {
802  m_pImpl->Invalidate();
803 }
804 
806 {
807  m_pImpl->Invalidate();
808  IDocumentMarkAccess* const pMA = m_pImpl->m_rDoc.getIDocumentMarkAccess();
810  m_pImpl->SetMark(*pMark);
811 }
812 
814  const OUString& rText, const bool bForceExpandHints)
815 {
816  if (RANGE_IS_TABLE == m_pImpl->m_eRangePosition)
817  {
818  // setString on table not allowed
819  throw uno::RuntimeException();
820  }
821 
822  const SwPosition aPos(GetDoc().GetNodes().GetEndOfContent());
823  SwCursor aCursor(aPos, nullptr);
824  if (GetPositions(aCursor))
825  {
826  UnoActionContext aAction(& m_pImpl->m_rDoc);
827  m_pImpl->m_rDoc.GetIDocumentUndoRedo().StartUndo(SwUndoId::INSERT, nullptr);
828  if (aCursor.HasMark())
829  {
830  m_pImpl->m_rDoc.getIDocumentContentOperations().DeleteAndJoin(aCursor);
831  }
832 
833  if (!rText.isEmpty())
834  {
836  m_pImpl->m_rDoc, aCursor, rText, bForceExpandHints);
837 
838  SwUnoCursorHelper::SelectPam(aCursor, true);
839  aCursor.Left(rText.getLength());
840  }
841  SetPositions(aCursor);
842  m_pImpl->m_rDoc.GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT, nullptr);
843  }
844 }
845 
846 namespace
847 {
848  class theSwXTextRangeUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXTextRangeUnoTunnelId > {};
849 }
850 
851 const uno::Sequence< sal_Int8 > & SwXTextRange::getUnoTunnelId()
852 {
853  return theSwXTextRangeUnoTunnelId::get().getSeq();
854 }
855 
856 // XUnoTunnel
857 sal_Int64 SAL_CALL
858 SwXTextRange::getSomething(const uno::Sequence< sal_Int8 >& rId)
859 {
860  return ::sw::UnoTunnelImpl<SwXTextRange>(rId, this);
861 }
862 
863 OUString SAL_CALL
865 {
866  return OUString("SwXTextRange");
867 }
868 
869 sal_Bool SAL_CALL SwXTextRange::supportsService(const OUString& rServiceName)
870 {
871  return cppu::supportsService(this, rServiceName);
872 }
873 
874 uno::Sequence< OUString > SAL_CALL
876 {
877  return {
878  "com.sun.star.text.TextRange",
879  "com.sun.star.style.CharacterProperties",
880  "com.sun.star.style.CharacterPropertiesAsian",
881  "com.sun.star.style.CharacterPropertiesComplex",
882  "com.sun.star.style.ParagraphProperties",
883  "com.sun.star.style.ParagraphPropertiesAsian",
884  "com.sun.star.style.ParagraphPropertiesComplex"
885  };
886 }
887 
888 uno::Reference< text::XText > SAL_CALL
890 {
891  SolarMutexGuard aGuard;
892 
893  if (!m_pImpl->m_xParentText.is())
894  {
895  if (m_pImpl->m_eRangePosition == RANGE_IS_TABLE &&
896  m_pImpl->m_pTableFormat)
897  {
898  SwTable const*const pTable = SwTable::FindTable( m_pImpl->m_pTableFormat );
899  SwTableNode const*const pTableNode = pTable->GetTableNode();
900  const SwPosition aPosition( *pTableNode );
901  m_pImpl->m_xParentText =
902  ::sw::CreateParentXText(m_pImpl->m_rDoc, aPosition);
903  }
904  }
905  OSL_ENSURE(m_pImpl->m_xParentText.is(), "SwXTextRange::getText: no text");
906  return m_pImpl->m_xParentText;
907 }
908 
909 uno::Reference< text::XTextRange > SAL_CALL
911 {
912  SolarMutexGuard aGuard;
913 
914  uno::Reference< text::XTextRange > xRet;
915  ::sw::mark::IMark const * const pBkmk = m_pImpl->GetBookmark();
916  if (!m_pImpl->m_xParentText.is())
917  {
918  getText();
919  }
920  if(pBkmk)
921  {
922  SwPaM aPam(pBkmk->GetMarkStart());
923  xRet = new SwXTextRange(aPam, m_pImpl->m_xParentText);
924  }
925  else if (RANGE_IS_TABLE == m_pImpl->m_eRangePosition)
926  {
927  // start and end are this, if it's a table
928  xRet = this;
929  }
930  else
931  {
932  throw uno::RuntimeException();
933  }
934  return xRet;
935 }
936 
937 uno::Reference< text::XTextRange > SAL_CALL
939 {
940  SolarMutexGuard aGuard;
941 
942  uno::Reference< text::XTextRange > xRet;
943  ::sw::mark::IMark const * const pBkmk = m_pImpl->GetBookmark();
944  if (!m_pImpl->m_xParentText.is())
945  {
946  getText();
947  }
948  if(pBkmk)
949  {
950  SwPaM aPam(pBkmk->GetMarkEnd());
951  xRet = new SwXTextRange(aPam, m_pImpl->m_xParentText);
952  }
953  else if (RANGE_IS_TABLE == m_pImpl->m_eRangePosition)
954  {
955  // start and end are this, if it's a table
956  xRet = this;
957  }
958  else
959  {
960  throw uno::RuntimeException();
961  }
962  return xRet;
963 }
964 
965 OUString SAL_CALL SwXTextRange::getString()
966 {
967  SolarMutexGuard aGuard;
968 
969  OUString sRet;
970  // for tables there is no bookmark, thus also no text
971  // one could export the table as ASCII here maybe?
972  SwPaM aPaM(GetDoc().GetNodes());
973  if (GetPositions(aPaM) && aPaM.HasMark())
974  {
976  }
977  return sRet;
978 }
979 
980 void SAL_CALL SwXTextRange::setString(const OUString& rString)
981 {
982  SolarMutexGuard aGuard;
983 
984  DeleteAndInsert(rString, false);
985 }
986 
987 bool SwXTextRange::GetPositions(SwPaM& rToFill) const
988 {
989  ::sw::mark::IMark const * const pBkmk = m_pImpl->GetBookmark();
990  if(pBkmk)
991  {
992  *rToFill.GetPoint() = pBkmk->GetMarkPos();
993  if(pBkmk->IsExpanded())
994  {
995  rToFill.SetMark();
996  *rToFill.GetMark() = pBkmk->GetOtherMarkPos();
997  }
998  else
999  {
1000  rToFill.DeleteMark();
1001  }
1002  return true;
1003  }
1004  return false;
1005 }
1006 
1007 namespace sw {
1008 
1010  const uno::Reference< text::XTextRange > & xTextRange)
1011 {
1012  bool bRet = false;
1013 
1014  uno::Reference<lang::XUnoTunnel> xRangeTunnel( xTextRange, uno::UNO_QUERY);
1015  SwXTextRange* pRange = nullptr;
1016  OTextCursorHelper* pCursor = nullptr;
1017  SwXTextPortion* pPortion = nullptr;
1018  SwXText* pText = nullptr;
1019  SwXParagraph* pPara = nullptr;
1020  if(xRangeTunnel.is())
1021  {
1022  pRange = ::sw::UnoTunnelGetImplementation<SwXTextRange>(xRangeTunnel);
1023  pCursor =
1024  ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xRangeTunnel);
1025  pPortion=
1026  ::sw::UnoTunnelGetImplementation<SwXTextPortion>(xRangeTunnel);
1027  pText = ::sw::UnoTunnelGetImplementation<SwXText>(xRangeTunnel);
1028  pPara = ::sw::UnoTunnelGetImplementation<SwXParagraph>(xRangeTunnel);
1029  }
1030 
1031  // if it's a text then create a temporary cursor there and re-use
1032  // the pCursor variable
1033  // #i108489#: Reference in outside scope to keep cursor alive
1034  uno::Reference< text::XTextCursor > xTextCursor;
1035  if (pText)
1036  {
1037  xTextCursor.set( pText->CreateCursor() );
1038  xTextCursor->gotoEnd(true);
1039  const uno::Reference<lang::XUnoTunnel> xCursorTunnel(
1040  xTextCursor, uno::UNO_QUERY);
1041  pCursor =
1042  ::sw::UnoTunnelGetImplementation<OTextCursorHelper>(xCursorTunnel);
1043  }
1044  if(pRange && &pRange->GetDoc() == rToFill.GetDoc())
1045  {
1046  bRet = pRange->GetPositions(rToFill);
1047  }
1048  else
1049  {
1050  if (pPara)
1051  {
1052  bRet = pPara->SelectPaM(rToFill);
1053  }
1054  else
1055  {
1056  SwDoc* const pDoc = pCursor ? pCursor->GetDoc()
1057  : (pPortion ? pPortion->GetCursor().GetDoc() : nullptr);
1058  const SwPaM* const pUnoCursor = pCursor ? pCursor->GetPaM()
1059  : (pPortion ? &pPortion->GetCursor() : nullptr);
1060  if (pUnoCursor && pDoc == rToFill.GetDoc())
1061  {
1062  OSL_ENSURE(!pUnoCursor->IsMultiSelection(),
1063  "what to do about rings?");
1064  bRet = true;
1065  *rToFill.GetPoint() = *pUnoCursor->GetPoint();
1066  if (pUnoCursor->HasMark())
1067  {
1068  rToFill.SetMark();
1069  *rToFill.GetMark() = *pUnoCursor->GetMark();
1070  }
1071  else
1072  rToFill.DeleteMark();
1073  }
1074  }
1075  }
1076  return bRet;
1077 }
1078 
1079 static bool
1080 lcl_IsStartNodeInFormat(const bool bHeader, SwStartNode const *const pSttNode,
1081  SwFrameFormat const*const pFrameFormat, SwFrameFormat*& rpFormat)
1082 {
1083  bool bRet = false;
1084  const SfxItemSet& rSet = pFrameFormat->GetAttrSet();
1085  const SfxPoolItem* pItem;
1086  if (SfxItemState::SET == rSet.GetItemState(
1087  bHeader ? sal_uInt16(RES_HEADER) : sal_uInt16(RES_FOOTER),
1088  true, &pItem))
1089  {
1090  SfxPoolItem *const pItemNonConst(const_cast<SfxPoolItem *>(pItem));
1091  SwFrameFormat *const pHeadFootFormat = bHeader ?
1092  static_cast<SwFormatHeader*>(pItemNonConst)->GetHeaderFormat() :
1093  static_cast<SwFormatFooter*>(pItemNonConst)->GetFooterFormat();
1094  if (pHeadFootFormat)
1095  {
1096  const SwFormatContent& rFlyContent = pHeadFootFormat->GetContent();
1097  const SwNode& rNode = rFlyContent.GetContentIdx()->GetNode();
1098  SwStartNode const*const pCurSttNode = rNode.FindSttNodeByType(
1099  bHeader ? SwHeaderStartNode : SwFooterStartNode);
1100  if (pCurSttNode && (pCurSttNode == pSttNode))
1101  {
1102  rpFormat = pHeadFootFormat;
1103  bRet = true;
1104  }
1105  }
1106  }
1107  return bRet;
1108 }
1109 
1110 } // namespace sw
1111 
1112 uno::Reference< text::XTextRange >
1114  SwDoc & rDoc, const SwPosition& rPos, const SwPosition *const pMark)
1115 {
1116  const uno::Reference<text::XText> xParentText(
1117  ::sw::CreateParentXText(rDoc, rPos));
1118  const auto pNewCursor(rDoc.CreateUnoCursor(rPos));
1119  if(pMark)
1120  {
1121  pNewCursor->SetMark();
1122  *pNewCursor->GetMark() = *pMark;
1123  }
1124  const bool isCell( dynamic_cast<SwXCell*>(xParentText.get()) );
1125  const uno::Reference< text::XTextRange > xRet(
1126  new SwXTextRange(*pNewCursor, xParentText,
1127  isCell ? RANGE_IN_CELL : RANGE_IN_TEXT) );
1128  return xRet;
1129 }
1130 
1131 namespace sw {
1132 
1133 uno::Reference< text::XText >
1134 CreateParentXText(SwDoc & rDoc, const SwPosition& rPos)
1135 {
1136  uno::Reference< text::XText > xParentText;
1137  SwStartNode* pSttNode = rPos.nNode.GetNode().StartOfSectionNode();
1138  while(pSttNode && pSttNode->IsSectionNode())
1139  {
1140  pSttNode = pSttNode->StartOfSectionNode();
1141  }
1142  SwStartNodeType eType = pSttNode ? pSttNode->GetStartNodeType() : SwNormalStartNode;
1143  switch(eType)
1144  {
1145  case SwTableBoxStartNode:
1146  {
1147  SwTableNode const*const pTableNode = pSttNode->FindTableNode();
1148  SwFrameFormat *const pTableFormat =
1149  static_cast<SwFrameFormat*>(pTableNode->GetTable().GetFrameFormat());
1150  SwTableBox *const pBox = pSttNode->GetTableBox();
1151 
1152  xParentText = pBox
1153  ? SwXCell::CreateXCell( pTableFormat, pBox )
1154  : new SwXCell( pTableFormat, *pSttNode );
1155  }
1156  break;
1157  case SwFlyStartNode:
1158  {
1159  SwFrameFormat *const pFormat = pSttNode->GetFlyFormat();
1160  if (nullptr != pFormat)
1161  {
1162  xParentText.set(SwXTextFrame::CreateXTextFrame(rDoc, pFormat),
1163  uno::UNO_QUERY);
1164  }
1165  }
1166  break;
1167  case SwHeaderStartNode:
1168  case SwFooterStartNode:
1169  {
1170  const bool bHeader = (SwHeaderStartNode == eType);
1171  const size_t nPDescCount = rDoc.GetPageDescCnt();
1172  for(size_t i = 0; i < nPDescCount; i++)
1173  {
1174  const SwPageDesc& rDesc = rDoc.GetPageDesc( i );
1175  const SwFrameFormat* pFrameFormatMaster = &rDesc.GetMaster();
1176  const SwFrameFormat* pFrameFormatLeft = &rDesc.GetLeft();
1177 
1178  SwFrameFormat* pHeadFootFormat = nullptr;
1179  if (!lcl_IsStartNodeInFormat(bHeader, pSttNode, pFrameFormatMaster,
1180  pHeadFootFormat))
1181  {
1182  lcl_IsStartNodeInFormat(bHeader, pSttNode, pFrameFormatLeft,
1183  pHeadFootFormat);
1184  }
1185 
1186  if (pHeadFootFormat)
1187  {
1189  *pHeadFootFormat, bHeader);
1190  }
1191  }
1192  }
1193  break;
1194  case SwFootnoteStartNode:
1195  {
1196  const size_t nFootnoteCnt = rDoc.GetFootnoteIdxs().size();
1197  for (size_t n = 0; n < nFootnoteCnt; ++n )
1198  {
1199  const SwTextFootnote* pTextFootnote = rDoc.GetFootnoteIdxs()[ n ];
1200  const SwFormatFootnote& rFootnote = pTextFootnote->GetFootnote();
1201  pTextFootnote = rFootnote.GetTextFootnote();
1202 
1203  if (pSttNode == pTextFootnote->GetStartNode()->GetNode().
1204  FindSttNodeByType(SwFootnoteStartNode))
1205  {
1206  xParentText.set(SwXFootnote::CreateXFootnote(rDoc,
1207  &const_cast<SwFormatFootnote&>(rFootnote)), uno::UNO_QUERY);
1208  break;
1209  }
1210  }
1211  }
1212  break;
1213  default:
1214  {
1215  // then it is the body text
1216  const uno::Reference<frame::XModel> xModel =
1217  rDoc.GetDocShell()->GetBaseModel();
1218  const uno::Reference< text::XTextDocument > xDoc(
1219  xModel, uno::UNO_QUERY);
1220  xParentText = xDoc->getText();
1221  }
1222  }
1223  OSL_ENSURE(xParentText.is(), "no parent text?");
1224  return xParentText;
1225 }
1226 
1227 } // namespace sw
1228 
1229 uno::Reference< container::XEnumeration > SAL_CALL
1230 SwXTextRange::createContentEnumeration(const OUString& rServiceName)
1231 {
1232  SolarMutexGuard g;
1233 
1234  if ( rServiceName != "com.sun.star.text.TextContent" )
1235  {
1236  throw uno::RuntimeException();
1237  }
1238 
1239  if (!m_pImpl->GetBookmark())
1240  {
1241  throw uno::RuntimeException();
1242  }
1243  const SwPosition aPos(GetDoc().GetNodes().GetEndOfContent());
1244  const auto pNewCursor(m_pImpl->m_rDoc.CreateUnoCursor(aPos));
1245  if (!GetPositions(*pNewCursor))
1246  {
1247  throw uno::RuntimeException();
1248  }
1249 
1251 }
1252 
1253 uno::Reference< container::XEnumeration > SAL_CALL
1255 {
1256  SolarMutexGuard g;
1257 
1258  if (!m_pImpl->GetBookmark())
1259  {
1260  throw uno::RuntimeException();
1261  }
1262  const SwPosition aPos(GetDoc().GetNodes().GetEndOfContent());
1263  auto pNewCursor(m_pImpl->m_rDoc.CreateUnoCursor(aPos));
1264  if (!GetPositions(*pNewCursor))
1265  {
1266  throw uno::RuntimeException();
1267  }
1268  if (!m_pImpl->m_xParentText.is())
1269  {
1270  getText();
1271  }
1272 
1273  const CursorType eSetType = (RANGE_IN_CELL == m_pImpl->m_eRangePosition)
1275  return SwXParagraphEnumeration::Create(m_pImpl->m_xParentText, pNewCursor, eSetType);
1276 }
1277 
1279 {
1281 }
1282 
1284 {
1285  return true;
1286 }
1287 
1288 uno::Sequence< OUString > SAL_CALL
1290 {
1291  uno::Sequence<OUString> aRet { "com.sun.star.text.TextContent" };
1292  return aRet;
1293 }
1294 
1295 uno::Reference< beans::XPropertySetInfo > SAL_CALL
1297 {
1298  SolarMutexGuard aGuard;
1299 
1300  static uno::Reference< beans::XPropertySetInfo > xRef =
1301  m_pImpl->m_rPropSet.getPropertySetInfo();
1302  return xRef;
1303 }
1304 
1305 void SAL_CALL
1307  const OUString& rPropertyName, const uno::Any& rValue)
1308 {
1309  SolarMutexGuard aGuard;
1310 
1311  if (!m_pImpl->GetBookmark())
1312  {
1313  throw uno::RuntimeException();
1314  }
1315  SwPaM aPaM(GetDoc().GetNodes());
1316  GetPositions(aPaM);
1317  SwUnoCursorHelper::SetPropertyValue(aPaM, m_pImpl->m_rPropSet,
1318  rPropertyName, rValue);
1319 }
1320 
1321 uno::Any SAL_CALL
1322 SwXTextRange::getPropertyValue(const OUString& rPropertyName)
1323 {
1324  SolarMutexGuard aGuard;
1325 
1326  if (!m_pImpl->GetBookmark())
1327  {
1328  throw uno::RuntimeException();
1329  }
1330  SwPaM aPaM(GetDoc().GetNodes());
1331  GetPositions(aPaM);
1332  return SwUnoCursorHelper::GetPropertyValue(aPaM, m_pImpl->m_rPropSet,
1333  rPropertyName);
1334 }
1335 
1336 void SAL_CALL
1338  const OUString& /*rPropertyName*/,
1339  const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
1340 {
1341  OSL_FAIL("SwXTextRange::addPropertyChangeListener(): not implemented");
1342 }
1343 
1344 void SAL_CALL
1346  const OUString& /*rPropertyName*/,
1347  const uno::Reference< beans::XPropertyChangeListener >& /*xListener*/)
1348 {
1349  OSL_FAIL("SwXTextRange::removePropertyChangeListener(): not implemented");
1350 }
1351 
1352 void SAL_CALL
1354  const OUString& /*rPropertyName*/,
1355  const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
1356 {
1357  OSL_FAIL("SwXTextRange::addVetoableChangeListener(): not implemented");
1358 }
1359 
1360 void SAL_CALL
1362  const OUString& /*rPropertyName*/,
1363  const uno::Reference< beans::XVetoableChangeListener >& /*xListener*/)
1364 {
1365  OSL_FAIL("SwXTextRange::removeVetoableChangeListener(): not implemented");
1366 }
1367 
1368 beans::PropertyState SAL_CALL
1369 SwXTextRange::getPropertyState(const OUString& rPropertyName)
1370 {
1371  SolarMutexGuard aGuard;
1372 
1373  if (!m_pImpl->GetBookmark())
1374  {
1375  throw uno::RuntimeException();
1376  }
1377  SwPaM aPaM(GetDoc().GetNodes());
1378  GetPositions(aPaM);
1379  return SwUnoCursorHelper::GetPropertyState(aPaM, m_pImpl->m_rPropSet,
1380  rPropertyName);
1381 }
1382 
1383 uno::Sequence< beans::PropertyState > SAL_CALL
1384 SwXTextRange::getPropertyStates(const uno::Sequence< OUString >& rPropertyName)
1385 {
1386  SolarMutexGuard g;
1387 
1388  if (!m_pImpl->GetBookmark())
1389  {
1390  throw uno::RuntimeException();
1391  }
1392  SwPaM aPaM(GetDoc().GetNodes());
1393  GetPositions(aPaM);
1394  return SwUnoCursorHelper::GetPropertyStates(aPaM, m_pImpl->m_rPropSet,
1395  rPropertyName);
1396 }
1397 
1398 void SAL_CALL SwXTextRange::setPropertyToDefault(const OUString& rPropertyName)
1399 {
1400  SolarMutexGuard aGuard;
1401 
1402  if (!m_pImpl->GetBookmark())
1403  {
1404  throw uno::RuntimeException();
1405  }
1406  SwPaM aPaM(GetDoc().GetNodes());
1407  GetPositions(aPaM);
1409  rPropertyName);
1410 }
1411 
1412 uno::Any SAL_CALL
1413 SwXTextRange::getPropertyDefault(const OUString& rPropertyName)
1414 {
1415  SolarMutexGuard aGuard;
1416 
1417  if (!m_pImpl->GetBookmark())
1418  {
1419  throw uno::RuntimeException();
1420  }
1421  SwPaM aPaM(GetDoc().GetNodes());
1422  GetPositions(aPaM);
1423  return SwUnoCursorHelper::GetPropertyDefault(aPaM, m_pImpl->m_rPropSet,
1424  rPropertyName);
1425 }
1426 
1427 void SAL_CALL
1429  const OUString& rRedlineType,
1430  const uno::Sequence< beans::PropertyValue >& rRedlineProperties )
1431 {
1432  SolarMutexGuard aGuard;
1433 
1434  if (!m_pImpl->GetBookmark())
1435  {
1436  throw uno::RuntimeException();
1437  }
1438  SwPaM aPaM(GetDoc().GetNodes());
1440  SwUnoCursorHelper::makeRedline( aPaM, rRedlineType, rRedlineProperties );
1441 }
1442 
1443 struct SwXTextRangesImpl final : public SwXTextRanges
1444 {
1445 
1446  // XUnoTunnel
1447  virtual sal_Int64 SAL_CALL getSomething( const css::uno::Sequence< sal_Int8 >& rIdentifier) override;
1448 
1449  // XServiceInfo
1450  virtual OUString SAL_CALL getImplementationName() override
1451  { return OUString("SwXTextRanges"); };
1452  virtual sal_Bool SAL_CALL supportsService( const OUString& rServiceName) override
1453  { return cppu::supportsService(this, rServiceName); };
1454  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
1455  { return { "com.sun.star.text.TextRanges" }; };
1456 
1457  // XElementAccess
1458  virtual css::uno::Type SAL_CALL getElementType() override
1460  virtual sal_Bool SAL_CALL hasElements() override
1461  { return getCount() > 0; };
1462  // XIndexAccess
1463  virtual sal_Int32 SAL_CALL getCount() override;
1464  virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 nIndex) override;
1465 
1466  explicit SwXTextRangesImpl(SwPaM *const pPaM)
1467  {
1468  if (pPaM)
1469  {
1470  m_pUnoCursor.reset(pPaM->GetDoc()->CreateUnoCursor(*pPaM->GetPoint()));
1471  ::sw::DeepCopyPaM(*pPaM, *GetCursor());
1472  }
1473  MakeRanges();
1474  }
1475  virtual void SAL_CALL release() throw () override
1476  {
1477  SolarMutexGuard g;
1478  OWeakObject::release();
1479  }
1480  virtual SwUnoCursor* GetCursor() override
1481  { return &(*m_pUnoCursor); };
1482  void MakeRanges();
1483  std::vector< uno::Reference< text::XTextRange > > m_Ranges;
1485 };
1486 
1488 {
1489  if (GetCursor())
1490  {
1491  for(SwPaM& rTmpCursor : GetCursor()->GetRingContainer())
1492  {
1493  const uno::Reference< text::XTextRange > xRange(
1495  *rTmpCursor.GetDoc(),
1496  *rTmpCursor.GetPoint(), rTmpCursor.GetMark()));
1497  if (xRange.is())
1498  {
1499  m_Ranges.push_back(xRange);
1500  }
1501  }
1502  }
1503 }
1504 
1506  { return new SwXTextRangesImpl(pPaM); }
1507 
1508 namespace
1509 {
1510  class theSwXTextRangesUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSwXTextRangesUnoTunnelId > {};
1511 }
1512 
1513 const uno::Sequence< sal_Int8 > & SwXTextRanges::getUnoTunnelId()
1514  { return theSwXTextRangesUnoTunnelId::get().getSeq(); }
1515 
1516 sal_Int64 SAL_CALL
1517 SwXTextRangesImpl::getSomething(const uno::Sequence< sal_Int8 >& rId)
1518 {
1519  return ::sw::UnoTunnelImpl<SwXTextRanges>(rId, this);
1520 }
1521 
1522 /*
1523  * Text positions
1524  * Up to the first access to a text position, only a SwCursor is stored.
1525  * Afterwards, an array with uno::Reference<XTextPosition> will be created.
1526  */
1527 
1528 sal_Int32 SAL_CALL SwXTextRangesImpl::getCount()
1529 {
1530  SolarMutexGuard aGuard;
1531  return static_cast<sal_Int32>(m_Ranges.size());
1532 }
1533 
1534 uno::Any SAL_CALL SwXTextRangesImpl::getByIndex(sal_Int32 nIndex)
1535 {
1536  SolarMutexGuard aGuard;
1537  if ((nIndex < 0) || (static_cast<size_t>(nIndex) >= m_Ranges.size()))
1538  throw lang::IndexOutOfBoundsException();
1539  uno::Any ret;
1540  ret <<= m_Ranges.at(nIndex);
1541  return ret;
1542 }
1543 
1544 void SwUnoCursorHelper::SetString(SwCursor & rCursor, const OUString& rString)
1545 {
1546  // Start/EndAction
1547  SwDoc *const pDoc = rCursor.GetDoc();
1548  UnoActionContext aAction(pDoc);
1550  if (rCursor.HasMark())
1551  {
1553  }
1554  if (!rString.isEmpty())
1555  {
1556  const bool bSuccess( SwUnoCursorHelper::DocInsertStringSplitCR(
1557  *pDoc, rCursor, rString, false ) );
1558  OSL_ENSURE( bSuccess, "DocInsertStringSplitCR" );
1559  SwUnoCursorHelper::SelectPam(rCursor, true);
1560  rCursor.Left(rString.getLength());
1561  }
1562  pDoc->GetIDocumentUndoRedo().EndUndo(SwUndoId::INSERT, nullptr);
1563 }
1564 
1566 {
1567  // XServiceInfo
1568  virtual OUString SAL_CALL getImplementationName() override
1569  { return OUString("SwXParaFrameEnumeration"); };
1570  virtual sal_Bool SAL_CALL supportsService(const OUString& rServiceName) override
1571  { return cppu::supportsService(this, rServiceName); };
1572  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
1573  { return {"com.sun.star.util.ContentEnumeration"}; };
1574 
1575  // XEnumeration
1576  virtual sal_Bool SAL_CALL hasMoreElements() override;
1577  virtual css::uno::Any SAL_CALL nextElement() override;
1578 
1579  SwXParaFrameEnumerationImpl(const SwPaM& rPaM, const enum ParaFrameMode eParaFrameMode, SwFrameFormat* const pFormat);
1580  virtual void SAL_CALL release() throw () override
1581  {
1582  SolarMutexGuard g;
1583  OWeakObject::release();
1584  }
1586  { return *m_pUnoCursor; }
1588  {
1589  if(!m_pUnoCursor)
1590  {
1591  m_vFrames.clear();
1592  m_xNextObject = nullptr;
1593  }
1594  else
1595  {
1596  // removing orphaned Clients
1597  const auto iter = std::remove_if(m_vFrames.begin(), m_vFrames.end(),
1598  [] (std::shared_ptr<sw::FrameClient>& rEntry) -> bool { return !rEntry->GetRegisteredIn(); });
1599  m_vFrames.erase(iter, m_vFrames.end());
1600  }
1601  }
1602  void FillFrame();
1603  bool CreateNextObject();
1604  uno::Reference< text::XTextContent > m_xNextObject;
1607 };
1608 
1609 
1610 SwXParaFrameEnumeration* SwXParaFrameEnumeration::Create(const SwPaM& rPaM, const enum ParaFrameMode eParaFrameMode, SwFrameFormat* const pFormat)
1611  { return new SwXParaFrameEnumerationImpl(rPaM, eParaFrameMode, pFormat); }
1612 
1614  const SwPaM& rPaM, const enum ParaFrameMode eParaFrameMode,
1615  SwFrameFormat* const pFormat)
1616  : m_pUnoCursor(rPaM.GetDoc()->CreateUnoCursor(*rPaM.GetPoint()))
1617 {
1618  if (rPaM.HasMark())
1619  {
1620  GetCursor().SetMark();
1621  *GetCursor().GetMark() = *rPaM.GetMark();
1622  }
1623  if (PARAFRAME_PORTION_PARAGRAPH == eParaFrameMode)
1624  {
1625  FrameClientSortList_t vFrames;
1626  ::CollectFrameAtNode(rPaM.GetPoint()->nNode, vFrames, false);
1627  std::transform(vFrames.begin(), vFrames.end(),
1628  std::back_inserter(m_vFrames),
1629  [] (const FrameClientSortListEntry& rEntry) { return rEntry.pFrameClient; });
1630  }
1631  else if (pFormat)
1632  {
1633  m_vFrames.push_back(std::make_shared<sw::FrameClient>(pFormat));
1634  }
1635  else if ((PARAFRAME_PORTION_CHAR == eParaFrameMode) ||
1636  (PARAFRAME_PORTION_TEXTRANGE == eParaFrameMode))
1637  {
1638  if (PARAFRAME_PORTION_TEXTRANGE == eParaFrameMode)
1639  {
1640  //get all frames that are bound at paragraph or at character
1641  for(const auto& pFlyFrame : rPaM.GetDoc()->GetAllFlyFormats(&GetCursor(), false, true))
1642  {
1643  const auto pFrameFormat = const_cast<SwFrameFormat*>(&pFlyFrame->GetFormat());
1644  m_vFrames.push_back(std::make_shared<sw::FrameClient>(pFrameFormat));
1645  }
1646  }
1647  FillFrame();
1648  }
1649 }
1650 
1651 // Search for a FLYCNT text attribute at the cursor point and fill the frame
1652 // into the array
1654 {
1655  if(!m_pUnoCursor->GetNode().IsTextNode())
1656  return;
1657  // search for objects at the cursor - anchored at/as char
1658  const auto pTextAttr = m_pUnoCursor->GetNode().GetTextNode()->GetTextAttrForCharAt(
1660  if(!pTextAttr)
1661  return;
1662  const SwFormatFlyCnt& rFlyCnt = pTextAttr->GetFlyCnt();
1663  SwFrameFormat* const pFrameFormat = rFlyCnt.GetFrameFormat();
1664  m_vFrames.push_back(std::make_shared<sw::FrameClient>(pFrameFormat));
1665 }
1666 
1668 {
1669  if (m_vFrames.empty())
1670  return false;
1671 
1672  SwFrameFormat* const pFormat = static_cast<SwFrameFormat*>(
1673  m_vFrames.front()->GetRegisteredIn());
1674  m_vFrames.pop_front();
1675  // the format should be valid here, otherwise the client
1676  // would have been removed by PurgeFrameClients
1677  // check for a shape first
1678  if(pFormat->Which() == RES_DRAWFRMFMT)
1679  {
1680  SdrObject* pObject(nullptr);
1681  pFormat->CallSwClientNotify(sw::FindSdrObjectHint(pObject));
1682  if(pObject)
1683  m_xNextObject.set(pObject->getUnoShape(), uno::UNO_QUERY);
1684  }
1685  else
1686  {
1687  const SwNodeIndex* pIdx = pFormat->GetContent().GetContentIdx();
1688  OSL_ENSURE(pIdx, "where is the index?");
1689  SwNode const*const pNd =
1690  m_pUnoCursor->GetDoc()->GetNodes()[ pIdx->GetIndex() + 1 ];
1691 
1692  if (!pNd->IsNoTextNode())
1693  {
1695  *pFormat->GetDoc(), pFormat));
1696  }
1697  else if (pNd->IsGrfNode())
1698  {
1700  *pFormat->GetDoc(), pFormat));
1701  }
1702  else
1703  {
1704  assert(pNd->IsOLENode());
1706  *pFormat->GetDoc(), pFormat));
1707  }
1708  }
1709  return m_xNextObject.is();
1710 }
1711 
1712 sal_Bool SAL_CALL
1714 {
1715  SolarMutexGuard aGuard;
1717  return m_xNextObject.is() || CreateNextObject();
1718 }
1719 
1721 {
1722  SolarMutexGuard aGuard;
1724  if (!m_xNextObject.is() && !m_vFrames.empty())
1725  CreateNextObject();
1726  if (!m_xNextObject.is())
1727  throw container::NoSuchElementException();
1728  uno::Any aRet;
1729  aRet <<= m_xNextObject;
1730  m_xNextObject = nullptr;
1731  return aRet;
1732 }
1733 
1734 /* 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:1604
const SwEndNode * EndOfSectionNode() const
Definition: node.hxx:682
FrameClientList_t m_vFrames
Definition: unoobj2.cxx:1605
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:2045
sal_uLong GetIndex() const
Definition: node.hxx:282
uno::Reference< text::XText > m_xParentText
Definition: unoobj2.cxx:709
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:1450
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:2465
~UnoActionContext() COVERITY_NOEXCEPT_FALSE
Definition: unoobj2.cxx:236
SwDocShell * GetDocShell()
Definition: doc.hxx:1340
static SwXTextRanges * Create(SwPaM *const pCursor)
Definition: unoobj2.cxx:1505
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
Definition: unoobj2.cxx:875
SwNodeIndex nNode
Definition: pam.hxx:37
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &rIdentifier) override
Definition: unoobj2.cxx:858
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:1720
virtual void SAL_CALL removeVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unoobj2.cxx:1361
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:800
const SwPosition * GetMark() const
Definition: pam.hxx:209
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unoobj2.cxx:1570
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1150
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:938
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:40
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:1480
virtual css::uno::Sequence< css::beans::PropertyState > SAL_CALL getPropertyStates(const css::uno::Sequence< OUString > &rPropertyNames) override
Definition: unoobj2.cxx:1384
#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: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:516
virtual void SAL_CALL release() override
Definition: unoobj2.cxx:1580
void SetString(SwCursor &rCursor, const OUString &rString)
Definition: unoobj2.cxx:1544
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:3058
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:790
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:1458
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:1610
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:1398
SwXTextRangesImpl(SwPaM *const pPaM)
Definition: unoobj2.cxx:1466
const SwTable & GetTable() const
Definition: node.hxx:497
SwUnoCursor & GetCursor()
Definition: unoobj2.cxx:1585
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:1528
css::uno::Any GetPropertyDefault(SwPaM const &rPaM, const SfxItemPropertySet &rPropSet, const OUString &rPropertyName)
Definition: unoobj.cxx:2042
virtual sal_Int64 SAL_CALL getSomething(const css::uno::Sequence< sal_Int8 > &rIdentifier) override
Definition: unoobj2.cxx:1517
size_type size() const
bool XTextRangeToSwPaM(SwUnoInternalPaM &rToFill, const uno::Reference< text::XTextRange > &xTextRange)
Definition: unoobj2.cxx:1009
css::uno::Reference< css::frame::XModel > GetBaseModel() const
const ::sw::mark::IMark * GetBookmark() const
Definition: unoobj2.cxx:743
SwPaM * GetNext()
Definition: pam.hxx:264
void Normalize(bool bPointFirst=true)
Normalizes PaM, i.e.
Definition: pam.cxx:520
virtual sal_Bool SAL_CALL hasElements() override
Definition: unoobj2.cxx:1460
static SwXCell * CreateXCell(SwFrameFormat *pTableFormat, SwTableBox *pBox, SwTable *pTable=nullptr)
Definition: unotbl.cxx:1178
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:1475
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:869
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:889
void EndListeningAll()
virtual void SAL_CALL makeRedline(const OUString &rRedlineType, const css::uno::Sequence< css::beans::PropertyValue > &RedlineProperties) override
Definition: unoobj2.cxx:1428
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:813
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
Definition: pam.cxx:483
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:1322
virtual css::beans::PropertyState SAL_CALL getPropertyState(const OUString &rPropertyName) override
Definition: unoobj2.cxx:1369
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:744
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:894
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:875
const SfxItemPropertySet & m_rPropSet
Definition: unoobj2.cxx:706
virtual css::uno::Any SAL_CALL nextElement() override
Definition: unoobj2.cxx:682
const SwPosition * GetContentAnchor() const
Definition: fmtanchr.hxx:67
virtual void SAL_CALL setString(const OUString &rString) override
Definition: unoobj2.cxx:980
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:710
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:1454
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:1337
size_t GetPageDescCnt() const
Definition: doc.hxx:874
unsigned char sal_Bool
virtual css::uno::Reference< css::text::XTextCursor > CreateCursor()
Definition: unotext.cxx:177
sw::UnoCursorPointer m_pUnoCursor
Definition: unoobj2.cxx:1484
virtual sal_Bool SAL_CALL hasElements() override
Definition: unoobj2.cxx:1283
bool IsNoTextNode() const
Definition: node.hxx:648
virtual css::uno::Reference< css::text::XTextRange > SAL_CALL getStart() override
Definition: unoobj2.cxx:910
virtual void SAL_CALL addVetoableChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &xListener) override
Definition: unoobj2.cxx:1353
Marks a node in the document model.
Definition: ndindex.hxx:31
virtual ~Impl() override
Definition: unoobj2.cxx:726
Impl(SwDoc &rDoc, const enum RangePosition eRange, SwFrameFormat *const pTableFormat, const uno::Reference< text::XText > &xParent=nullptr)
Definition: unoobj2.cxx:713
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:1230
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:1534
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:786
DocumentType const eType
::sw::UnoCursorPointer m_pUnoCursor
Definition: unoobj2.cxx:1606
#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:1306
virtual void SAL_CALL removePropertyChangeListener(const OUString &rPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
Definition: unoobj2.cxx:1345
virtual css::uno::Type SAL_CALL getElementType() override
Definition: unoobj2.cxx:1278
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:707
const SwNodeIndex * GetContentIdx() const
Definition: fmtcntnt.hxx:46
virtual OUString SAL_CALL getImplementationName() override
Definition: unoobj2.cxx:864
#define RES_FOOTER
Definition: hintids.hxx:202
SwXParaFrameEnumerationImpl(const SwPaM &rPaM, const enum ParaFrameMode eParaFrameMode, SwFrameFormat *const pFormat)
Definition: unoobj2.cxx:1613
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:1296
sal_uInt16 Which() const
for Querying of Writer-functions.
Definition: format.hxx:78
static const css::uno::Sequence< sal_Int8 > & getUnoTunnelId()
Definition: unoobj2.cxx:851
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:1483
virtual sal_Bool SAL_CALL hasMoreElements() override
Definition: unoobj2.cxx:1713
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:2002
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:987
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:1568
static bool lcl_IsStartNodeInFormat(const bool bHeader, SwStartNode const *const pSttNode, SwFrameFormat const *const pFrameFormat, SwFrameFormat *&rpFormat)
Definition: unoobj2.cxx:1080
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: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:1289
const ::sw::mark::IMark * m_pMark
Definition: unoobj2.cxx:711
bool GoNextPara(SwPaM &rPam, SwMoveFnCollection const &aPosPara)
Definition: pam.cxx:977
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:3154
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:1513
virtual sal_Bool SAL_CALL supportsService(const OUString &rServiceName) override
Definition: unoobj2.cxx:1452
#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:756
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:628
::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:1254
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:3446
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 a 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:3399
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:457
css::beans::PropertyState GetPropertyState(SwPaM &rPaM, const SfxItemPropertySet &rPropSet, const OUString &rPropertyName)
Definition: unoobj.cxx:1969
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:1113
void EndAllAction(bool bVirDev=false)
Definition: pagechg.cxx:1878
virtual css::uno::Any SAL_CALL getPropertyDefault(const OUString &rPropertyName) override
Definition: unoobj2.cxx:1413
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:1572
bool IsTextNode() const
Definition: node.hxx:636
void SetPositions(SwPaM const &rPam)
Definition: unoobj2.cxx:805
virtual OUString SAL_CALL getString() override
Definition: unoobj2.cxx:965
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:1134
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