LibreOffice Module sw (master)  1
docredln.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 <libxml/xmlwriter.h>
21 #include <boost/property_tree/json_parser.hpp>
22 
23 #include <sal/log.hxx>
24 #include <tools/datetimeutils.hxx>
25 #include <hintids.hxx>
26 #include <svl/itemiter.hxx>
27 #include <sfx2/app.hxx>
28 #include <editeng/colritem.hxx>
29 #include <editeng/udlnitem.hxx>
31 #include <comphelper/lok.hxx>
32 #include <comphelper/string.hxx>
33 #include <LibreOfficeKit/LibreOfficeKitEnums.h>
34 #include <unotools/datetime.hxx>
35 #include <sfx2/viewsh.hxx>
36 #include <swmodule.hxx>
37 #include <doc.hxx>
38 #include <docredln.hxx>
39 #include <IDocumentUndoRedo.hxx>
42 #include <IDocumentState.hxx>
45 #include <docary.hxx>
46 #include <ndtxt.hxx>
47 #include <redline.hxx>
48 #include <swundo.hxx>
49 #include <UndoCore.hxx>
50 #include <UndoRedline.hxx>
51 #include <hints.hxx>
52 #include <pamtyp.hxx>
53 #include <poolfmt.hxx>
54 #include <view.hxx>
55 #include <viewsh.hxx>
56 #include <viscrs.hxx>
57 #include <rootfrm.hxx>
58 #include <strings.hrc>
59 #include <unoport.hxx>
60 #include <wrtsh.hxx>
61 #include <txtfld.hxx>
62 
63 #include <flowfrm.hxx>
64 
65 using namespace com::sun::star;
66 
67 #ifdef DBG_UTIL
68 
69  void sw_DebugRedline( const SwDoc* pDoc )
70  {
71  static SwRedlineTable::size_type nWatch = 0; // loplugin:constvars:ignore
73  for( SwRedlineTable::size_type n = 0; n < rTable.size(); ++n )
74  {
75  SwRedlineTable::size_type nDummy = 0;
76  const SwRangeRedline* pCurrent = rTable[ n ];
77  const SwRangeRedline* pNext = n+1 < rTable.size() ? rTable[ n+1 ] : nullptr;
78  if( pCurrent == pNext )
79  ++nDummy;
80  if( n == nWatch )
81  ++nDummy; // Possible debugger breakpoint
82  }
83  }
84 
85 #endif
86 
87 
89 {
90  DeleteAndDestroyAll();
91 }
92 
94 {
95  xmlTextWriterStartElement(pWriter, BAD_CAST("SwExtraRedlineTable"));
96  xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
97 
98  for (sal_uInt16 nCurExtraRedlinePos = 0; nCurExtraRedlinePos < GetSize(); ++nCurExtraRedlinePos)
99  {
100  const SwExtraRedline* pExtraRedline = GetRedline(nCurExtraRedlinePos);
101  xmlTextWriterStartElement(pWriter, BAD_CAST("SwExtraRedline"));
102  xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
103  xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("symbol"), "%s", BAD_CAST(typeid(*pExtraRedline).name()));
104  xmlTextWriterEndElement(pWriter);
105  }
106  xmlTextWriterEndElement(pWriter);
107 }
108 
109 #if OSL_DEBUG_LEVEL > 0
110 static bool CheckPosition( const SwPosition* pStt, const SwPosition* pEnd )
111 {
112  int nError = 0;
113  SwNode* pSttNode = &pStt->nNode.GetNode();
114  SwNode* pEndNode = &pEnd->nNode.GetNode();
115  SwNode* pSttTab = pSttNode->StartOfSectionNode()->FindTableNode();
116  SwNode* pEndTab = pEndNode->StartOfSectionNode()->FindTableNode();
117  SwNode* pSttStart = pSttNode;
118  while( pSttStart && (!pSttStart->IsStartNode() || pSttStart->IsSectionNode() ||
119  pSttStart->IsTableNode() ) )
120  pSttStart = pSttStart->StartOfSectionNode();
121  SwNode* pEndStart = pEndNode;
122  while( pEndStart && (!pEndStart->IsStartNode() || pEndStart->IsSectionNode() ||
123  pEndStart->IsTableNode() ) )
124  pEndStart = pEndStart->StartOfSectionNode();
125  assert(pSttTab == pEndTab);
126  if( pSttTab != pEndTab )
127  nError = 1;
128  assert(pSttTab || pSttStart == pEndStart);
129  if( !pSttTab && pSttStart != pEndStart )
130  nError |= 2;
131  if( nError )
132  nError += 10;
133  return nError != 0;
134 }
135 #endif
136 
137 bool SwExtraRedlineTable::DeleteAllTableRedlines( SwDoc* pDoc, const SwTable& rTable, bool bSaveInUndo, RedlineType nRedlineTypeToDelete )
138 {
139  bool bChg = false;
140 
141  if (bSaveInUndo && pDoc->GetIDocumentUndoRedo().DoesUndo())
142  {
143  // #TODO - Add 'Undo' support for deleting 'Table Cell' redlines
144  /*
145  SwUndoRedline* pUndo = new SwUndoRedline( SwUndoId::REDLINE, rRange );
146  if( pUndo->GetRedlSaveCount() )
147  {
148  GetIDocumentUndoRedo().AppendUndo(pUndo);
149  }
150  else
151  delete pUndo;
152  */
153  }
154 
155  for (sal_uInt16 nCurRedlinePos = 0; nCurRedlinePos < GetSize(); )
156  {
157  SwExtraRedline* pExtraRedline = GetRedline(nCurRedlinePos);
158  const SwTableCellRedline* pTableCellRedline = dynamic_cast<const SwTableCellRedline*>(pExtraRedline);
159  if (pTableCellRedline)
160  {
161  const SwTableBox *pRedTabBox = &pTableCellRedline->GetTableBox();
162  const SwTable& rRedTable = pRedTabBox->GetSttNd()->FindTableNode()->GetTable();
163  if ( &rRedTable == &rTable )
164  {
165  // Redline for this table
166  const SwRedlineData& aRedlineData = pTableCellRedline->GetRedlineData();
167  const RedlineType nRedlineType = aRedlineData.GetType();
168 
169  // Check if this redline object type should be deleted
170  if (RedlineType::Any == nRedlineTypeToDelete || nRedlineTypeToDelete == nRedlineType)
171  {
172 
173  DeleteAndDestroy( nCurRedlinePos );
174  bChg = true;
175  continue; // don't increment position after delete
176  }
177  }
178  }
179  else
180  {
181  const SwTableRowRedline* pTableRowRedline = dynamic_cast<const SwTableRowRedline*>(pExtraRedline);
182  if (pTableRowRedline)
183  {
184  const SwTableLine *pRedTabLine = &pTableRowRedline->GetTableLine();
185  const SwTableBoxes &rRedTabBoxes = pRedTabLine->GetTabBoxes();
186  const SwTable& rRedTable = rRedTabBoxes[0]->GetSttNd()->FindTableNode()->GetTable();
187  if ( &rRedTable == &rTable )
188  {
189  // Redline for this table
190  const SwRedlineData& aRedlineData = pTableRowRedline->GetRedlineData();
191  const RedlineType nRedlineType = aRedlineData.GetType();
192 
193  // Check if this redline object type should be deleted
194  if (RedlineType::Any == nRedlineTypeToDelete || nRedlineTypeToDelete == nRedlineType)
195 
196  {
197  DeleteAndDestroy( nCurRedlinePos );
198  bChg = true;
199  continue; // don't increment position after delete
200  }
201  }
202  }
203  }
204  ++nCurRedlinePos;
205  }
206 
207  if( bChg )
208  pDoc->getIDocumentState().SetModified();
209 
210  return bChg;
211 }
212 
213 bool SwExtraRedlineTable::DeleteTableRowRedline( SwDoc* pDoc, const SwTableLine& rTableLine, bool bSaveInUndo, RedlineType nRedlineTypeToDelete )
214 {
215  bool bChg = false;
216 
217  if (bSaveInUndo && pDoc->GetIDocumentUndoRedo().DoesUndo())
218  {
219  // #TODO - Add 'Undo' support for deleting 'Table Cell' redlines
220  /*
221  SwUndoRedline* pUndo = new SwUndoRedline( SwUndoId::REDLINE, rRange );
222  if( pUndo->GetRedlSaveCount() )
223  {
224  GetIDocumentUndoRedo().AppendUndo(pUndo);
225  }
226  else
227  delete pUndo;
228  */
229  }
230 
231  for(sal_uInt16 nCurRedlinePos = 0; nCurRedlinePos < GetSize(); ++nCurRedlinePos )
232  {
233  SwExtraRedline* pExtraRedline = GetRedline(nCurRedlinePos);
234  const SwTableRowRedline* pTableRowRedline = dynamic_cast<const SwTableRowRedline*>(pExtraRedline);
235  const SwTableLine *pRedTabLine = pTableRowRedline ? &pTableRowRedline->GetTableLine() : nullptr;
236  if ( pRedTabLine == &rTableLine )
237  {
238  // Redline for this table row
239  const SwRedlineData& aRedlineData = pTableRowRedline->GetRedlineData();
240  const RedlineType nRedlineType = aRedlineData.GetType();
241 
242  // Check if this redline object type should be deleted
243  if( RedlineType::Any != nRedlineTypeToDelete && nRedlineTypeToDelete != nRedlineType )
244  continue;
245 
246  DeleteAndDestroy( nCurRedlinePos );
247  bChg = true;
248  }
249  }
250 
251  if( bChg )
252  pDoc->getIDocumentState().SetModified();
253 
254  return bChg;
255 }
256 
257 bool SwExtraRedlineTable::DeleteTableCellRedline( SwDoc* pDoc, const SwTableBox& rTableBox, bool bSaveInUndo, RedlineType nRedlineTypeToDelete )
258 {
259  bool bChg = false;
260 
261  if (bSaveInUndo && pDoc->GetIDocumentUndoRedo().DoesUndo())
262  {
263  // #TODO - Add 'Undo' support for deleting 'Table Cell' redlines
264  /*
265  SwUndoRedline* pUndo = new SwUndoRedline( SwUndoId::REDLINE, rRange );
266  if( pUndo->GetRedlSaveCount() )
267  {
268  GetIDocumentUndoRedo().AppendUndo(pUndo);
269  }
270  else
271  delete pUndo;
272  */
273  }
274 
275  for(sal_uInt16 nCurRedlinePos = 0; nCurRedlinePos < GetSize(); ++nCurRedlinePos )
276  {
277  SwExtraRedline* pExtraRedline = GetRedline(nCurRedlinePos);
278  const SwTableCellRedline* pTableCellRedline = dynamic_cast<const SwTableCellRedline*>(pExtraRedline);
279  const SwTableBox *pRedTabBox = pTableCellRedline ? &pTableCellRedline->GetTableBox() : nullptr;
280  if ( pRedTabBox == &rTableBox )
281  {
282  // Redline for this table cell
283  const SwRedlineData& aRedlineData = pTableCellRedline->GetRedlineData();
284  const RedlineType nRedlineType = aRedlineData.GetType();
285 
286  // Check if this redline object type should be deleted
287  if( RedlineType::Any != nRedlineTypeToDelete && nRedlineTypeToDelete != nRedlineType )
288  continue;
289 
290  DeleteAndDestroy( nCurRedlinePos );
291  bChg = true;
292  }
293  }
294 
295  if( bChg )
296  pDoc->getIDocumentState().SetModified();
297 
298  return bChg;
299 }
300 
301 namespace
302 {
303 
304 void lcl_LOKInvalidateFrames(const SwModify& rMod, const SwRootFrame* pLayout,
305  SwFrameType const nFrameType, const Point* pPoint)
306 {
308 
309  for (SwFrame* pTmpFrame = aIter.First(); pTmpFrame; pTmpFrame = aIter.Next() )
310  {
311  if ((pTmpFrame->GetType() & nFrameType) &&
312  (!pLayout || pLayout == pTmpFrame->getRootFrame()) &&
313  (!pTmpFrame->IsFlowFrame() || !SwFlowFrame::CastFlowFrame( pTmpFrame )->IsFollow()))
314  {
315  if (pPoint)
316  {
317  pTmpFrame->InvalidateSize();
318  }
319  }
320  }
321 }
322 
323 void lcl_LOKInvalidateStartEndFrames(SwShellCursor& rCursor)
324 {
325  if (!(rCursor.HasMark() &&
326  rCursor.GetPoint()->nNode.GetNode().IsContentNode() &&
327  rCursor.GetPoint()->nNode.GetNode().GetContentNode()->getLayoutFrame(rCursor.GetShell()->GetLayout()) &&
328  (rCursor.GetMark()->nNode == rCursor.GetPoint()->nNode ||
329  (rCursor.GetMark()->nNode.GetNode().IsContentNode() &&
330  rCursor.GetMark()->nNode.GetNode().GetContentNode()->getLayoutFrame(rCursor.GetShell()->GetLayout())))))
331  {
332  return;
333  }
334 
335 
336  SwPosition *pStartPos = rCursor.Start(),
337  *pEndPos = rCursor.GetPoint() == pStartPos ? rCursor.GetMark() : rCursor.GetPoint();
338 
339 
340  lcl_LOKInvalidateFrames(*(pStartPos->nNode.GetNode().GetContentNode()),
341  rCursor.GetShell()->GetLayout(),
342  FRM_CNTNT, &rCursor.GetSttPos());
343 
344  lcl_LOKInvalidateFrames(*(pEndPos->nNode.GetNode().GetContentNode()),
345  rCursor.GetShell()->GetLayout(),
346  FRM_CNTNT, &rCursor.GetEndPos());
347 }
348 
349 } // anonymous namespace
350 
353 {
354  // Disable since usability is very low beyond some small number of changes.
355  static bool bDisableRedlineComments = getenv("DISABLE_REDLINE") != nullptr;
356  if (!comphelper::LibreOfficeKit::isActive() || bDisableRedlineComments)
357  return;
358 
359  boost::property_tree::ptree aRedline;
360  aRedline.put("action", (nType == RedlineNotification::Add ? "Add" :
361  (nType == RedlineNotification::Remove ? "Remove" :
362  (nType == RedlineNotification::Modify ? "Modify" : "???"))));
363  aRedline.put("index", pRedline->GetId());
364  aRedline.put("author", pRedline->GetAuthorString(1).toUtf8().getStr());
365  aRedline.put("type", SwRedlineTypeToOUString(pRedline->GetRedlineData().GetType()).toUtf8().getStr());
366  aRedline.put("comment", pRedline->GetRedlineData().GetComment().toUtf8().getStr());
367  aRedline.put("description", pRedline->GetDescr().toUtf8().getStr());
368  OUString sDateTime = utl::toISO8601(pRedline->GetRedlineData().GetTimeStamp().GetUNODateTime());
369  aRedline.put("dateTime", sDateTime.toUtf8().getStr());
370 
371  SwPosition* pStartPos = pRedline->Start();
372  SwPosition* pEndPos = pRedline->End();
373  SwContentNode* pContentNd = pRedline->GetContentNode();
374  SwView* pView = dynamic_cast<SwView*>(SfxViewShell::Current());
375  if (pView && pContentNd)
376  {
377  SwShellCursor aCursor(pView->GetWrtShell(), *pStartPos);
378  aCursor.SetMark();
379  aCursor.GetMark()->nNode = *pContentNd;
380  aCursor.GetMark()->nContent.Assign(pContentNd, pEndPos->nContent.GetIndex());
381 
382  aCursor.FillRects();
383 
384  SwRects* pRects(&aCursor);
385  std::vector<OString> aRects;
386  for(SwRect& rNextRect : *pRects)
387  aRects.push_back(rNextRect.SVRect().toString());
388 
389  const OString sRects = comphelper::string::join("; ", aRects);
390  aRedline.put("textRange", sRects.getStr());
391 
392  lcl_LOKInvalidateStartEndFrames(aCursor);
393 
394  // When this notify method is called text invalidation is not done yet
395  // Calling FillRects updates the text area so invalidation will not run on the correct rects
396  // So we need to do an own invalidation here. It invalidates text frames containing the redlining
397  SwDoc* pDoc = pRedline->GetDoc();
398  SwViewShell* pSh;
399  if( pDoc && !pDoc->IsInDtor() &&
400  nullptr != ( pSh = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()) )
401  {
402  for(SwNodeIndex nIdx = pStartPos->nNode; nIdx <= pEndPos->nNode; ++nIdx)
403  {
404  SwContentNode* pContentNode = nIdx.GetNode().GetContentNode();
405  if (pContentNode)
406  pSh->InvalidateWindows(pContentNode->FindLayoutRect());
407  }
408  }
409  }
410 
411  boost::property_tree::ptree aTree;
412  aTree.add_child("redline", aRedline);
413  std::stringstream aStream;
414  boost::property_tree::write_json(aStream, aTree);
415  std::string aPayload = aStream.str();
416 
417  SfxViewShell* pViewShell = SfxViewShell::GetFirst();
418  while (pViewShell)
419  {
420  pViewShell->libreOfficeKitViewCallback(nType == RedlineNotification::Modify ? LOK_CALLBACK_REDLINE_TABLE_ENTRY_MODIFIED : LOK_CALLBACK_REDLINE_TABLE_SIZE_CHANGED, aPayload.c_str());
421  pViewShell = SfxViewShell::GetNext(*pViewShell);
422  }
423 }
424 
426 {
427  if( p->HasValidRange() )
428  {
429  std::pair<vector_type::const_iterator, bool> rv = maVector.insert( p );
430  size_type nP = rv.first - begin();
431  LOKRedlineNotification(RedlineNotification::Add, p);
432  p->CallDisplayFunc(nP);
433  return rv.second;
434  }
435  return InsertWithValidRanges( p );
436 }
437 
439 {
440  if( p->HasValidRange() )
441  {
442  std::pair<vector_type::const_iterator, bool> rv = maVector.insert( p );
443  rP = rv.first - begin();
444  p->CallDisplayFunc(rP);
445  return rv.second;
446  }
447  return InsertWithValidRanges( p, &rP );
448 }
449 
450 namespace sw {
451 
452 std::vector<SwRangeRedline*> GetAllValidRanges(std::unique_ptr<SwRangeRedline> p)
453 {
454  std::vector<SwRangeRedline*> ret;
455  // Create valid "sub-ranges" from the Selection
456  SwPosition* pStt = p->Start(),
457  * pEnd = pStt == p->GetPoint() ? p->GetMark() : p->GetPoint();
458  SwPosition aNewStt( *pStt );
459  SwNodes& rNds = aNewStt.nNode.GetNodes();
460  SwContentNode* pC;
461 
462  if( !aNewStt.nNode.GetNode().IsContentNode() )
463  {
464  pC = rNds.GoNext( &aNewStt.nNode );
465  if( pC )
466  aNewStt.nContent.Assign( pC, 0 );
467  else
468  aNewStt.nNode = rNds.GetEndOfContent();
469  }
470 
471  SwRangeRedline* pNew = nullptr;
472 
473  if( aNewStt < *pEnd )
474  do {
475  if( !pNew )
476  pNew = new SwRangeRedline( p->GetRedlineData(), aNewStt );
477  else
478  {
479  pNew->DeleteMark();
480  *pNew->GetPoint() = aNewStt;
481  }
482 
483  pNew->SetMark();
484  GoEndSection( pNew->GetPoint() );
485  // i60396: If the redlines starts before a table but the table is the last member
486  // of the section, the GoEndSection will end inside the table.
487  // This will result in an incorrect redline, so we've to go back
489  // We end in a table when pTab != 0
490  if( pTab && !pNew->GetMark()->nNode.GetNode().StartOfSectionNode()->FindTableNode() )
491  { // but our Mark was outside the table => Correction
492  do
493  {
494  // We want to be before the table
495  *pNew->GetPoint() = SwPosition(*pTab);
496  pC = GoPreviousNds( &pNew->GetPoint()->nNode, false ); // here we are.
497  if( pC )
498  pNew->GetPoint()->nContent.Assign( pC, 0 );
499  pTab = pNew->GetPoint()->nNode.GetNode().StartOfSectionNode()->FindTableNode();
500  } while( pTab ); // If there is another table we have to repeat our step backwards
501  }
502 
503  if( *pNew->GetPoint() > *pEnd )
504  {
505  pC = nullptr;
506  if( aNewStt.nNode != pEnd->nNode )
507  do {
508  SwNode& rCurNd = aNewStt.nNode.GetNode();
509  if( rCurNd.IsStartNode() )
510  {
511  if( rCurNd.EndOfSectionIndex() < pEnd->nNode.GetIndex() )
512  aNewStt.nNode = *rCurNd.EndOfSectionNode();
513  else
514  break;
515  }
516  else if( rCurNd.IsContentNode() )
517  pC = rCurNd.GetContentNode();
518  ++aNewStt.nNode;
519  } while( aNewStt.nNode.GetIndex() < pEnd->nNode.GetIndex() );
520 
521  if( aNewStt.nNode == pEnd->nNode )
522  aNewStt.nContent = pEnd->nContent;
523  else if( pC )
524  {
525  aNewStt.nNode = *pC;
526  aNewStt.nContent.Assign( pC, pC->Len() );
527  }
528 
529  if( aNewStt <= *pEnd )
530  *pNew->GetPoint() = aNewStt;
531  }
532  else
533  aNewStt = *pNew->GetPoint();
534 #if OSL_DEBUG_LEVEL > 0
535  CheckPosition( pNew->GetPoint(), pNew->GetMark() );
536 #endif
537 
538  if( *pNew->GetPoint() != *pNew->GetMark() &&
539  pNew->HasValidRange())
540  {
541  ret.push_back(pNew);
542  pNew = nullptr;
543  }
544 
545  if( aNewStt >= *pEnd ||
546  nullptr == (pC = rNds.GoNext( &aNewStt.nNode )) )
547  break;
548 
549  aNewStt.nContent.Assign( pC, 0 );
550 
551  } while( aNewStt < *pEnd );
552 
553  delete pNew;
554  p.reset();
555  return ret;
556 }
557 
558 } // namespace sw
559 
561 {
562  bool bAnyIns = false;
563  std::vector<SwRangeRedline*> const redlines(
564  GetAllValidRanges(std::unique_ptr<SwRangeRedline>(p)));
565  for (SwRangeRedline * pRedline : redlines)
566  {
567  assert(pRedline->HasValidRange());
568  size_type nInsPos;
569  if (Insert(pRedline, nInsPos))
570  {
571  pRedline->CallDisplayFunc(nInsPos);
572  bAnyIns = true;
573  if (pInsPos && *pInsPos < nInsPos)
574  {
575  *pInsPos = nInsPos;
576  }
577  }
578  }
579  p = nullptr;
580  return bAnyIns;
581 }
582 
584 {
585  return *lhs < *rhs;
586 }
587 
589 {
590  maVector.DeleteAndDestroyAll();
591 }
592 
594 {
595  vector_type::const_iterator it = maVector.find(const_cast<SwRangeRedline*>(p));
596  if( it == maVector.end() )
597  return npos;
598  return it - maVector.begin();
599 }
600 
602 {
603  const size_type nPos = GetPos(p);
604  if (nPos == npos)
605  return;
606  Remove(nPos);
607 }
608 
610 {
611  LOKRedlineNotification(RedlineNotification::Remove, maVector[nP]);
612  SwDoc* pDoc = nullptr;
613  if( !nP && 1 == size() )
614  pDoc = maVector.front()->GetDoc();
615 
616  maVector.erase( maVector.begin() + nP );
617 
618  SwViewShell* pSh;
619  if( pDoc && !pDoc->IsInDtor() &&
620  nullptr != ( pSh = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell()) )
622 }
623 
625 {
626  while (!maVector.empty())
627  {
628  auto const pRedline = maVector.back();
629  maVector.erase(maVector.size() - 1);
630  LOKRedlineNotification(RedlineNotification::Remove, pRedline);
631  delete pRedline;
632  }
633 }
634 
636 {
637  auto const pRedline = maVector[nP];
638  maVector.erase(maVector.begin() + nP);
639  LOKRedlineNotification(RedlineNotification::Remove, pRedline);
640  delete pRedline;
641 }
642 
644 {
645  return nSttPos + 1 < size()
646  ? FindNextSeqNo( operator[]( nSttPos )->GetSeqNo(), nSttPos+1 )
647  : npos;
648 }
649 
651 {
652  return nSttPos ? FindPrevSeqNo( operator[]( nSttPos )->GetSeqNo(), nSttPos-1 )
653  : npos;
654 }
655 
659 {
660  auto const nLookahead = 20;
661  size_type nRet = npos;
662  if( nSeqNo && nSttPos < size() )
663  {
664  size_type nEnd = size();
665  const size_type nTmp = nSttPos + nLookahead;
666  if (nTmp < nEnd)
667  {
668  nEnd = nTmp;
669  }
670 
671  for( ; nSttPos < nEnd; ++nSttPos )
672  if( nSeqNo == operator[]( nSttPos )->GetSeqNo() )
673  {
674  nRet = nSttPos;
675  break;
676  }
677  }
678  return nRet;
679 }
680 
682 {
683  auto const nLookahead = 20;
684  size_type nRet = npos;
685  if( nSeqNo && nSttPos < size() )
686  {
687  size_type nEnd = 0;
688  if( nSttPos > nLookahead )
689  nEnd = nSttPos - nLookahead;
690 
691  ++nSttPos;
692  while( nSttPos > nEnd )
693  if( nSeqNo == operator[]( --nSttPos )->GetSeqNo() )
694  {
695  nRet = nSttPos;
696  break;
697  }
698  }
699  return nRet;
700 }
701 
703  size_type& rPos,
704  bool bNext ) const
705 {
706  const SwRangeRedline* pFnd = nullptr;
707  for( ; rPos < maVector.size() ; ++rPos )
708  {
709  const SwRangeRedline* pTmp = (*this)[ rPos ];
710  if( pTmp->HasMark() && pTmp->IsVisible() )
711  {
712  const SwPosition* pRStt = pTmp->Start(),
713  * pREnd = pRStt == pTmp->GetPoint() ? pTmp->GetMark()
714  : pTmp->GetPoint();
715  if( bNext ? *pRStt <= rSttPos : *pRStt < rSttPos )
716  {
717  if( bNext ? *pREnd > rSttPos : *pREnd >= rSttPos )
718  {
719  pFnd = pTmp;
720  break;
721  }
722  }
723  else
724  break;
725  }
726  }
727  return pFnd;
728 }
729 
731 {
732  xmlTextWriterStartElement(pWriter, BAD_CAST("SwRedlineTable"));
733  xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
734 
735  for (SwRedlineTable::size_type nCurRedlinePos = 0; nCurRedlinePos < size(); ++nCurRedlinePos)
736  operator[](nCurRedlinePos)->dumpAsXml(pWriter);
737 
738  xmlTextWriterEndElement(pWriter);
739 }
740 
742 {
743 }
744 
746 {
747 }
748 
750 {
751  return false;
752 }
753 
755  sal_uInt16 nPoolFormatId,
756  const SfxItemSet* pItemSet )
757  : m_sFormatNm(rColl), m_nPoolId(nPoolFormatId)
758 {
759  if( pItemSet && pItemSet->Count() )
760  m_pSet.reset( new SfxItemSet( *pItemSet ) );
761 }
762 
764 {
765 }
766 
768 {
770 }
771 
773 {
774  SwDoc* pDoc = rPam.GetDoc();
775 
776  // What about Undo? Is it turned off?
780 
783 
784  if( pColl )
785  pDoc->SetTextFormatColl( rPam, pColl, false );
786 
787  if( m_pSet )
789 
791 }
792 
794 {
795  const SwRedlineExtraData_FormatColl& rCmp = static_cast<const SwRedlineExtraData_FormatColl&>(r);
796  return m_sFormatNm == rCmp.m_sFormatNm && m_nPoolId == rCmp.m_nPoolId &&
797  ( ( !m_pSet && !rCmp.m_pSet ) ||
798  ( m_pSet && rCmp.m_pSet && *m_pSet == *rCmp.m_pSet ) );
799 }
800 
802 {
803  if( rSet.Count() )
804  m_pSet.reset( new SfxItemSet( rSet ) );
805  else
806  m_pSet.reset();
807 }
808 
810 {
811  SfxItemIter aIter( rSet );
812  const SfxPoolItem* pItem = aIter.FirstItem();
813  while(pItem)
814  {
815  m_aWhichIds.push_back( pItem->Which() );
816  if( aIter.IsAtEnd() )
817  break;
818  pItem = aIter.NextItem();
819  }
820 }
821 
823  const SwRedlineExtraData_Format& rCpy )
825 {
826  m_aWhichIds.insert( m_aWhichIds.begin(), rCpy.m_aWhichIds.begin(), rCpy.m_aWhichIds.end() );
827 }
828 
830 {
831 }
832 
834 {
835  return new SwRedlineExtraData_Format( *this );
836 }
837 
839 {
840  SwDoc* pDoc = rPam.GetDoc();
841 
844 
845  // Actually we need to reset the Attribute here!
846  for( const auto& rWhichId : m_aWhichIds )
847  {
848  pDoc->getIDocumentContentOperations().InsertPoolItem( rPam, *GetDfltAttr( rWhichId ),
850  }
851 
853 }
854 
856 {
857  const size_t nEnd = m_aWhichIds.size();
858  if( nEnd != static_cast<const SwRedlineExtraData_Format&>(rCmp).m_aWhichIds.size() )
859  return false;
860 
861  for( size_t n = 0; n < nEnd; ++n )
862  {
863  if( static_cast<const SwRedlineExtraData_Format&>(rCmp).m_aWhichIds[n] != m_aWhichIds[n])
864  {
865  return false;
866  }
867  }
868  return true;
869 }
870 
872  : m_pNext( nullptr ), m_pExtraData( nullptr ),
873  m_aStamp( DateTime::SYSTEM ),
874  m_eType( eT ), m_bAutoFormat(false), m_nAuthor( nAut ), m_nSeqNo( 0 )
875 {
876  m_aStamp.SetNanoSec( 0 );
877 }
878 
880  const SwRedlineData& rCpy,
881  bool bCpyNext )
882  : m_pNext( ( bCpyNext && rCpy.m_pNext ) ? new SwRedlineData( *rCpy.m_pNext ) : nullptr )
883  , m_pExtraData( rCpy.m_pExtraData ? rCpy.m_pExtraData->CreateNew() : nullptr )
884  , m_sComment( rCpy.m_sComment )
885  , m_aStamp( rCpy.m_aStamp )
886  , m_eType( rCpy.m_eType )
887  , m_bAutoFormat(false)
888  , m_nAuthor( rCpy.m_nAuthor )
889  , m_nSeqNo( rCpy.m_nSeqNo )
890 {
891 }
892 
893 // For sw3io: We now own pNext!
894 SwRedlineData::SwRedlineData(RedlineType eT, std::size_t nAut, const DateTime& rDT,
895  const OUString& rCmnt, SwRedlineData *pNxt)
896  : m_pNext(pNxt), m_pExtraData(nullptr), m_sComment(rCmnt), m_aStamp(rDT),
897  m_eType(eT), m_bAutoFormat(false), m_nAuthor(nAut), m_nSeqNo(0)
898 {
899 }
900 
902 {
903  delete m_pExtraData;
904  delete m_pNext;
905 }
906 
908 {
909  DateTime aTime = GetTimeStamp();
910  aTime.SetSec(0);
911  DateTime aCompareTime = rCmp.GetTimeStamp();
912  aCompareTime.SetSec(0);
913  return m_nAuthor == rCmp.m_nAuthor &&
914  m_eType == rCmp.m_eType &&
915  m_sComment == rCmp.m_sComment &&
916  aTime == aCompareTime &&
917  (( !m_pNext && !rCmp.m_pNext ) ||
918  ( m_pNext && rCmp.m_pNext &&
919  m_pNext->CanCombine( *rCmp.m_pNext ))) &&
920  (( !m_pExtraData && !rCmp.m_pExtraData ) ||
921  ( m_pExtraData && rCmp.m_pExtraData &&
922  *m_pExtraData == *rCmp.m_pExtraData ));
923 }
924 
928 {
929  delete m_pExtraData;
930 
931  // Check if there is data - and if so - delete it
932  if( pData )
933  m_pExtraData = pData->CreateNew();
934  else
935  m_pExtraData = nullptr;
936 }
937 
938 static const char* STR_REDLINE_ARY[] =
939 {
940  STR_UNDO_REDLINE_INSERT,
941  STR_UNDO_REDLINE_DELETE,
942  STR_UNDO_REDLINE_FORMAT,
943  STR_UNDO_REDLINE_TABLE,
944  STR_UNDO_REDLINE_FMTCOLL,
945  STR_UNDO_REDLINE_PARAGRAPH_FORMAT,
946  STR_UNDO_REDLINE_TABLE_ROW_INSERT,
947  STR_UNDO_REDLINE_TABLE_ROW_DELETE,
948  STR_UNDO_REDLINE_TABLE_CELL_INSERT,
949  STR_UNDO_REDLINE_TABLE_CELL_DELETE
950 };
951 
952 OUString SwRedlineData::GetDescr() const
953 {
954  return SwResId(STR_REDLINE_ARY[static_cast<int>(GetType())]);
955 }
956 
957 sal_uInt32 SwRangeRedline::m_nLastId = 1;
958 
960  : SwPaM( *rPam.GetMark(), *rPam.GetPoint() ),
961  m_pRedlineData( new SwRedlineData( eTyp, GetDoc()->getIDocumentRedlineAccess().GetRedlineAuthor() ) ),
962  m_pContentSect( nullptr ),
963  m_nId( m_nLastId++ )
964 {
965  m_bDelLastPara = false;
966  m_bIsVisible = true;
967  if( !rPam.HasMark() )
968  DeleteMark();
969 }
970 
972  : SwPaM( *rPam.GetMark(), *rPam.GetPoint() ),
973  m_pRedlineData( new SwRedlineData( rData )),
974  m_pContentSect( nullptr ),
975  m_nId( m_nLastId++ )
976 {
977  m_bDelLastPara = false;
978  m_bIsVisible = true;
979  if( !rPam.HasMark() )
980  DeleteMark();
981 }
982 
984  : SwPaM( rPos ),
985  m_pRedlineData( new SwRedlineData( rData )),
986  m_pContentSect( nullptr ),
987  m_nId( m_nLastId++ )
988 {
989  m_bDelLastPara = false;
990  m_bIsVisible = true;
991 }
992 
994  : SwPaM( *rCpy.GetMark(), *rCpy.GetPoint() ),
995  m_pRedlineData( new SwRedlineData( *rCpy.m_pRedlineData )),
996  m_pContentSect( nullptr ),
997  m_nId( rCpy.m_nId )
998 {
999  m_bDelLastPara = false;
1000  m_bIsVisible = true;
1001  if( !rCpy.HasMark() )
1002  DeleteMark();
1003 }
1004 
1006 {
1007  if( m_pContentSect )
1008  {
1009  // delete the ContentSection
1010  if( !GetDoc()->IsInDtor() )
1012  delete m_pContentSect;
1013  }
1014  delete m_pRedlineData;
1015 }
1016 
1018 {
1020  return;
1021 
1022  const SwRedlineTable& rRedTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable();
1023  for (SwRedlineTable::size_type i = 0; i < rRedTable.size(); ++i)
1024  {
1025  if (rRedTable[i] == pRedline)
1026  {
1028  break;
1029  }
1030  }
1031 }
1032 
1034 {
1036  return;
1037 
1038  if(!m_oLOKLastNodeTop || *m_oLOKLastNodeTop != nTop)
1039  {
1040  m_oLOKLastNodeTop = nTop;
1042  }
1043 }
1044 
1045 void SwRangeRedline::SetStart( const SwPosition& rPos, SwPosition* pSttPtr )
1046 {
1047  if( !pSttPtr ) pSttPtr = Start();
1048  *pSttPtr = rPos;
1049 
1051 }
1052 
1053 void SwRangeRedline::SetEnd( const SwPosition& rPos, SwPosition* pEndPtr )
1054 {
1055  if( !pEndPtr ) pEndPtr = End();
1056  *pEndPtr = rPos;
1057 
1059 }
1060 
1063 {
1064  const SwNode* pPtNd = &GetPoint()->nNode.GetNode(),
1065  * pMkNd = &GetMark()->nNode.GetNode();
1066  if( pPtNd->StartOfSectionNode() == pMkNd->StartOfSectionNode() &&
1067  !pPtNd->StartOfSectionNode()->IsTableNode() &&
1068  // invalid if points on the end of content
1069  // end-of-content only invalid if no content index exists
1070  ( pPtNd != pMkNd || GetContentIdx() != nullptr ||
1071  pPtNd != &pPtNd->GetNodes().GetEndOfContent() )
1072  )
1073  return true;
1074  return false;
1075 }
1076 
1078 {
1081  Show(0, nMyPos);
1082  else if (eShow == RedlineFlags::ShowInsert)
1083  Hide(0, nMyPos);
1084  else if (eShow == RedlineFlags::ShowDelete)
1085  ShowOriginal(0, nMyPos);
1086 }
1087 
1088 void SwRangeRedline::Show(sal_uInt16 nLoop, size_t nMyPos)
1089 {
1090  if( 1 <= nLoop )
1091  {
1092  SwDoc* pDoc = GetDoc();
1095  ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
1096 
1097  switch( GetType() )
1098  {
1099  case RedlineType::Insert: // Content has been inserted
1100  m_bIsVisible = true;
1101  MoveFromSection(nMyPos);
1102  break;
1103 
1104  case RedlineType::Delete: // Content has been deleted
1105  m_bIsVisible = true;
1106  MoveFromSection(nMyPos);
1107  break;
1108 
1109  case RedlineType::Format: // Attributes have been applied
1110  case RedlineType::Table: // Table structure has been modified
1112  break;
1113  default:
1114  break;
1115  }
1117  }
1118 }
1119 
1120 void SwRangeRedline::Hide(sal_uInt16 nLoop, size_t nMyPos)
1121 {
1122  SwDoc* pDoc = GetDoc();
1125  ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
1126 
1127  switch( GetType() )
1128  {
1129  case RedlineType::Insert: // Content has been inserted
1130  m_bIsVisible = true;
1131  if( 1 <= nLoop )
1132  MoveFromSection(nMyPos);
1133  break;
1134 
1135  case RedlineType::Delete: // Content has been deleted
1136  m_bIsVisible = false;
1137  switch( nLoop )
1138  {
1139  case 0: MoveToSection(); break;
1140  case 1: CopyToSection(); break;
1141  case 2: DelCopyOfSection(nMyPos); break;
1142  }
1143  break;
1144 
1145  case RedlineType::Format: // Attributes have been applied
1146  case RedlineType::Table: // Table structure has been modified
1147  if( 1 <= nLoop )
1149  break;
1150  default:
1151  break;
1152  }
1154 }
1155 
1156 void SwRangeRedline::ShowOriginal(sal_uInt16 nLoop, size_t nMyPos)
1157 {
1158  SwDoc* pDoc = GetDoc();
1160  SwRedlineData* pCur;
1161 
1163  ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
1164 
1165  // Determine the Type, it's the first on Stack
1166  for( pCur = m_pRedlineData; pCur->m_pNext; )
1167  pCur = pCur->m_pNext;
1168 
1169  switch( pCur->m_eType )
1170  {
1171  case RedlineType::Insert: // Content has been inserted
1172  m_bIsVisible = false;
1173  switch( nLoop )
1174  {
1175  case 0: MoveToSection(); break;
1176  case 1: CopyToSection(); break;
1177  case 2: DelCopyOfSection(nMyPos); break;
1178  }
1179  break;
1180 
1181  case RedlineType::Delete: // Content has been deleted
1182  m_bIsVisible = true;
1183  if( 1 <= nLoop )
1184  MoveFromSection(nMyPos);
1185  break;
1186 
1187  case RedlineType::Format: // Attributes have been applied
1188  case RedlineType::Table: // Table structure has been modified
1189  if( 1 <= nLoop )
1191  break;
1192  default:
1193  break;
1194  }
1196 }
1197 
1198 // trigger the Layout
1200 {
1201  sal_uLong nSttNd = GetMark()->nNode.GetIndex(),
1202  nEndNd = GetPoint()->nNode.GetIndex();
1203  sal_Int32 nSttCnt = GetMark()->nContent.GetIndex();
1204  sal_Int32 nEndCnt = GetPoint()->nContent.GetIndex();
1205 
1206  if( nSttNd > nEndNd || ( nSttNd == nEndNd && nSttCnt > nEndCnt ))
1207  {
1208  sal_uLong nTmp = nSttNd; nSttNd = nEndNd; nEndNd = nTmp;
1209  sal_Int32 nTmp2 = nSttCnt; nSttCnt = nEndCnt; nEndCnt = nTmp2;
1210  }
1211 
1212  SwNodes& rNds = GetDoc()->GetNodes();
1213  for (sal_uLong n(nSttNd); n <= nEndNd; ++n)
1214  {
1215  SwNode* pNode = rNds[n];
1216 
1217  if (pNode && pNode->IsTextNode())
1218  {
1219  SwTextNode* pNd = pNode->GetTextNode();
1220 
1221  SwUpdateAttr aHt(
1222  n == nSttNd ? nSttCnt : 0,
1223  n == nEndNd ? nEndCnt : pNd->GetText().getLength(),
1224  RES_FMT_CHG);
1225 
1226  pNd->ModifyNotification(&aHt, &aHt);
1227 
1228  // SwUpdateAttr must be handled first, otherwise indexes are off
1229  if (GetType() == RedlineType::Delete)
1230  {
1231  sal_Int32 const nStart(n == nSttNd ? nSttCnt : 0);
1232  sal_Int32 const nLen((n == nEndNd ? nEndCnt : pNd->GetText().getLength()) - nStart);
1233  if (eWhy == Invalidation::Add)
1234  {
1235  sw::RedlineDelText const hint(nStart, nLen);
1236  pNd->CallSwClientNotify(hint);
1237  }
1238  else
1239  {
1240  sw::RedlineUnDelText const hint(nStart, nLen);
1241  pNd->CallSwClientNotify(hint);
1242  }
1243  }
1244  }
1245  }
1246 }
1247 
1250 void SwRangeRedline::CalcStartEnd( sal_uLong nNdIdx, sal_Int32& rStart, sal_Int32& rEnd ) const
1251 {
1252  const SwPosition *pRStt = Start(), *pREnd = End();
1253  if( pRStt->nNode < nNdIdx )
1254  {
1255  if( pREnd->nNode > nNdIdx )
1256  {
1257  rStart = 0; // Paragraph is completely enclosed
1258  rEnd = COMPLETE_STRING;
1259  }
1260  else if (pREnd->nNode == nNdIdx)
1261  {
1262  rStart = 0; // Paragraph is overlapped in the beginning
1263  rEnd = pREnd->nContent.GetIndex();
1264  }
1265  else // redline ends before paragraph
1266  {
1267  rStart = COMPLETE_STRING;
1268  rEnd = COMPLETE_STRING;
1269  }
1270  }
1271  else if( pRStt->nNode == nNdIdx )
1272  {
1273  rStart = pRStt->nContent.GetIndex();
1274  if( pREnd->nNode == nNdIdx )
1275  rEnd = pREnd->nContent.GetIndex(); // Within the Paragraph
1276  else
1277  rEnd = COMPLETE_STRING; // Paragraph is overlapped in the end
1278  }
1279  else
1280  {
1281  rStart = COMPLETE_STRING;
1282  rEnd = COMPLETE_STRING;
1283  }
1284 }
1285 
1287 {
1288  if( !m_pContentSect )
1289  {
1290  const SwPosition* pStt = Start(),
1291  * pEnd = pStt == GetPoint() ? GetMark() : GetPoint();
1292 
1293  SwDoc* pDoc = GetDoc();
1294  SwPaM aPam( *pStt, *pEnd );
1295  SwContentNode* pCSttNd = pStt->nNode.GetNode().GetContentNode();
1296  SwContentNode* pCEndNd = pEnd->nNode.GetNode().GetContentNode();
1297 
1298  if( !pCSttNd )
1299  {
1300  // In order to not move other Redlines' indices, we set them
1301  // to the end (is exclusive)
1302  const SwRedlineTable& rTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable();
1303  for(SwRangeRedline* pRedl : rTable)
1304  {
1305  if( pRedl->GetBound() == *pStt )
1306  pRedl->GetBound() = *pEnd;
1307  if( pRedl->GetBound(false) == *pStt )
1308  pRedl->GetBound(false) = *pEnd;
1309  }
1310  }
1311 
1312  SwStartNode* pSttNd;
1313  SwNodes& rNds = pDoc->GetNodes();
1314  if( pCSttNd || pCEndNd )
1315  {
1316  SwTextFormatColl* pColl = (pCSttNd && pCSttNd->IsTextNode() )
1317  ? pCSttNd->GetTextNode()->GetTextColl()
1318  : (pCEndNd && pCEndNd->IsTextNode() )
1319  ? pCEndNd->GetTextNode()->GetTextColl()
1321 
1322  pSttNd = rNds.MakeTextSection( SwNodeIndex( rNds.GetEndOfRedlines() ),
1323  SwNormalStartNode, pColl );
1324  SwTextNode* pTextNd = rNds[ pSttNd->GetIndex() + 1 ]->GetTextNode();
1325 
1326  SwNodeIndex aNdIdx( *pTextNd );
1327  SwPosition aPos( aNdIdx, SwIndex( pTextNd ));
1328  if( pCSttNd && pCEndNd )
1329  pDoc->getIDocumentContentOperations().MoveAndJoin( aPam, aPos );
1330  else
1331  {
1332  if( pCSttNd && !pCEndNd )
1333  m_bDelLastPara = true;
1334  pDoc->getIDocumentContentOperations().MoveRange( aPam, aPos,
1336  }
1337  }
1338  else
1339  {
1341 
1342  SwPosition aPos( *pSttNd->EndOfSectionNode() );
1343  pDoc->getIDocumentContentOperations().MoveRange( aPam, aPos,
1345  }
1346  m_pContentSect = new SwNodeIndex( *pSttNd );
1347 
1348  if( pStt == GetPoint() )
1349  Exchange();
1350 
1351  DeleteMark();
1352  }
1353  else
1355 }
1356 
1358 {
1359  if( m_pContentSect )
1360  return;
1361 
1362  const SwPosition* pStt = Start(),
1363  * pEnd = pStt == GetPoint() ? GetMark() : GetPoint();
1364 
1365  SwContentNode* pCSttNd = pStt->nNode.GetNode().GetContentNode();
1366  SwContentNode* pCEndNd = pEnd->nNode.GetNode().GetContentNode();
1367 
1368  SwStartNode* pSttNd;
1369  SwDoc* pDoc = GetDoc();
1370  SwNodes& rNds = pDoc->GetNodes();
1371 
1372  bool bSaveCopyFlag = pDoc->IsCopyIsMove(),
1373  bSaveRdlMoveFlg = pDoc->getIDocumentRedlineAccess().IsRedlineMove();
1374  pDoc->SetCopyIsMove( true );
1375 
1376  // The IsRedlineMove() flag causes the behaviour of the
1377  // DocumentContentOperationsManager::CopyFlyInFlyImpl() method to change,
1378  // which will eventually be called by the CopyRange() below.
1380 
1381  if( pCSttNd )
1382  {
1383  SwTextFormatColl* pColl = pCSttNd->IsTextNode()
1384  ? pCSttNd->GetTextNode()->GetTextColl()
1386 
1387  pSttNd = rNds.MakeTextSection( SwNodeIndex( rNds.GetEndOfRedlines() ),
1388  SwNormalStartNode, pColl );
1389 
1390  SwNodeIndex aNdIdx( *pSttNd, 1 );
1391  SwTextNode* pTextNd = aNdIdx.GetNode().GetTextNode();
1392  SwPosition aPos( aNdIdx, SwIndex( pTextNd ));
1393  pDoc->getIDocumentContentOperations().CopyRange( *this, aPos, /*bCopyAll=*/false, /*bCheckPos=*/true );
1394 
1395  // Take over the style from the EndNode if needed
1396  // We don't want this in Doc::Copy
1397  if( pCEndNd && pCEndNd != pCSttNd )
1398  {
1399  SwContentNode* pDestNd = aPos.nNode.GetNode().GetContentNode();
1400  if( pDestNd )
1401  {
1402  if( pDestNd->IsTextNode() && pCEndNd->IsTextNode() )
1403  pCEndNd->GetTextNode()->CopyCollFormat(*pDestNd->GetTextNode());
1404  else
1405  pDestNd->ChgFormatColl( pCEndNd->GetFormatColl() );
1406  }
1407  }
1408  }
1409  else
1410  {
1412 
1413  if( pCEndNd )
1414  {
1415  SwPosition aPos( *pSttNd->EndOfSectionNode() );
1416  pDoc->getIDocumentContentOperations().CopyRange( *this, aPos, /*bCopyAll=*/false, /*bCheckPos=*/true );
1417  }
1418  else
1419  {
1420  SwNodeIndex aInsPos( *pSttNd->EndOfSectionNode() );
1421  SwNodeRange aRg( pStt->nNode, 0, pEnd->nNode, 1 );
1422  pDoc->GetDocumentContentOperationsManager().CopyWithFlyInFly( aRg, 0, aInsPos );
1423  }
1424  }
1425  m_pContentSect = new SwNodeIndex( *pSttNd );
1426 
1427  pDoc->SetCopyIsMove( bSaveCopyFlag );
1428  pDoc->getIDocumentRedlineAccess().SetRedlineMove( bSaveRdlMoveFlg );
1429 
1430 }
1431 
1433 {
1434  if( m_pContentSect )
1435  {
1436  const SwPosition* pStt = Start(),
1437  * pEnd = pStt == GetPoint() ? GetMark() : GetPoint();
1438 
1439  SwDoc* pDoc = GetDoc();
1440  SwPaM aPam( *pStt, *pEnd );
1441  SwContentNode* pCSttNd = pStt->nNode.GetNode().GetContentNode();
1442  SwContentNode* pCEndNd = pEnd->nNode.GetNode().GetContentNode();
1443 
1444  if( !pCSttNd )
1445  {
1446  // In order to not move other Redlines' indices, we set them
1447  // to the end (is exclusive)
1448  const SwRedlineTable& rTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable();
1449  for(SwRangeRedline* pRedl : rTable)
1450  {
1451  if( pRedl->GetBound() == *pStt )
1452  pRedl->GetBound() = *pEnd;
1453  if( pRedl->GetBound(false) == *pStt )
1454  pRedl->GetBound(false) = *pEnd;
1455  }
1456  }
1457 
1458  if( pCSttNd && pCEndNd )
1459  {
1460  // #i100466# - force a <join next> on <delete and join> operation
1461  pDoc->getIDocumentContentOperations().DeleteAndJoin( aPam, true );
1462  }
1463  else if( pCSttNd || pCEndNd )
1464  {
1465  if( pCSttNd && !pCEndNd )
1466  m_bDelLastPara = true;
1468 
1469  if( m_bDelLastPara )
1470  {
1471  // To prevent dangling references to the paragraph to
1472  // be deleted, redline that point into this paragraph should be
1473  // moved to the new end position. Since redlines in the redline
1474  // table are sorted and the pEnd position is an endnode (see
1475  // bDelLastPara condition above), only redlines before the
1476  // current ones can be affected.
1477  const SwRedlineTable& rTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable();
1478  size_t n = nMyPos;
1479  for( bool bBreak = false; !bBreak && n > 0; )
1480  {
1481  --n;
1482  bBreak = true;
1483  if( rTable[ n ]->GetBound() == *aPam.GetPoint() )
1484  {
1485  rTable[ n ]->GetBound() = *pEnd;
1486  bBreak = false;
1487  }
1488  if( rTable[ n ]->GetBound(false) == *aPam.GetPoint() )
1489  {
1490  rTable[ n ]->GetBound(false) = *pEnd;
1491  bBreak = false;
1492  }
1493  }
1494 
1495  *GetPoint() = *pEnd;
1496  *GetMark() = *pEnd;
1497  DeleteMark();
1498 
1499  aPam.GetBound().nContent.Assign( nullptr, 0 );
1500  aPam.GetBound( false ).nContent.Assign( nullptr, 0 );
1501  aPam.DeleteMark();
1503  }
1504  }
1505  else
1506  {
1508  }
1509 
1510  if( pStt == GetPoint() )
1511  Exchange();
1512 
1513  DeleteMark();
1514  }
1515 }
1516 
1518 {
1519  if( m_pContentSect )
1520  {
1521  SwDoc* pDoc = GetDoc();
1522  const SwRedlineTable& rTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable();
1523  std::vector<SwPosition*> aBeforeArr, aBehindArr;
1524  bool bBreak = false;
1526 
1527  for( n = nMyPos+1; !bBreak && n < rTable.size(); ++n )
1528  {
1529  bBreak = true;
1530  if( rTable[ n ]->GetBound() == *GetPoint() )
1531  {
1532  SwRangeRedline* pRedl = rTable[n];
1533  aBehindArr.push_back(&pRedl->GetBound());
1534  bBreak = false;
1535  }
1536  if( rTable[ n ]->GetBound(false) == *GetPoint() )
1537  {
1538  SwRangeRedline* pRedl = rTable[n];
1539  aBehindArr.push_back(&pRedl->GetBound(false));
1540  bBreak = false;
1541  }
1542  }
1543  for( bBreak = false, n = nMyPos; !bBreak && n ; )
1544  {
1545  --n;
1546  bBreak = true;
1547  if( rTable[ n ]->GetBound() == *GetPoint() )
1548  {
1549  SwRangeRedline* pRedl = rTable[n];
1550  aBeforeArr.push_back(&pRedl->GetBound());
1551  bBreak = false;
1552  }
1553  if( rTable[ n ]->GetBound(false) == *GetPoint() )
1554  {
1555  SwRangeRedline* pRedl = rTable[n];
1556  aBeforeArr.push_back(&pRedl->GetBound(false));
1557  bBreak = false;
1558  }
1559  }
1560 
1561  const SwNode* pKeptContentSectNode( &m_pContentSect->GetNode() ); // #i95711#
1562  {
1563  SwPaM aPam( m_pContentSect->GetNode(),
1565  ( m_bDelLastPara ? -2 : -1 ) );
1566  SwContentNode* pCNd = aPam.GetContentNode();
1567  if( pCNd )
1568  aPam.GetPoint()->nContent.Assign( pCNd, pCNd->Len() );
1569  else
1570  ++aPam.GetPoint()->nNode;
1571 
1572  SwFormatColl* pColl = pCNd && pCNd->Len() && aPam.GetPoint()->nNode !=
1573  aPam.GetMark()->nNode
1574  ? pCNd->GetFormatColl() : nullptr;
1575 
1576  SwNodeIndex aNdIdx( GetPoint()->nNode, -1 );
1577  const sal_Int32 nPos = GetPoint()->nContent.GetIndex();
1578 
1579  SwPosition aPos( *GetPoint() );
1580  if( m_bDelLastPara && *aPam.GetPoint() == *aPam.GetMark() )
1581  {
1582  --aPos.nNode;
1583 
1585  }
1586  else
1587  {
1588  pDoc->getIDocumentContentOperations().MoveRange( aPam, aPos,
1590  }
1591 
1592  SetMark();
1593  *GetPoint() = aPos;
1594  GetMark()->nNode = aNdIdx.GetIndex() + 1;
1595  pCNd = GetMark()->nNode.GetNode().GetContentNode();
1596  GetMark()->nContent.Assign( pCNd, nPos );
1597 
1598  if( m_bDelLastPara )
1599  {
1600  ++GetPoint()->nNode;
1601  pCNd = GetContentNode();
1602  GetPoint()->nContent.Assign( pCNd, 0 );
1603  m_bDelLastPara = false;
1604  }
1605  else if( pColl )
1606  pCNd = GetContentNode();
1607 
1608  if( pColl && pCNd )
1609  pCNd->ChgFormatColl( pColl );
1610  }
1611 
1612  // #i95771#
1613  // Under certain conditions the previous <SwDoc::Move(..)> has already
1614  // removed the change tracking section of this <SwRangeRedline> instance from
1615  // the change tracking nodes area.
1616  // Thus, check if <pContentSect> still points to the change tracking section
1617  // by comparing it with the "indexed" <SwNode> instance copied before
1618  // perform the intrinsic move.
1619  // Note: Such condition is e.g. a "delete" change tracking only containing a table.
1620  if ( &m_pContentSect->GetNode() == pKeptContentSectNode )
1621  {
1623  }
1624  delete m_pContentSect;
1625  m_pContentSect = nullptr;
1626 
1627  // adjustment of redline table positions must take start and
1628  // end into account, not point and mark.
1629  for( auto& pItem : aBeforeArr )
1630  *pItem = *Start();
1631  for( auto& pItem : aBehindArr )
1632  *pItem = *End();
1633  }
1634  else
1636 }
1637 
1638 // for Undo
1640 {
1641  if( pIdx && !m_pContentSect )
1642  {
1643  m_pContentSect = new SwNodeIndex( *pIdx );
1644  m_bIsVisible = false;
1645  }
1646  else if( !pIdx && m_pContentSect )
1647  {
1648  delete m_pContentSect;
1649  m_pContentSect = nullptr;
1650  m_bIsVisible = false;
1651  }
1652  else
1653  {
1654  OSL_FAIL("SwRangeRedline::SetContentIdx: invalid state");
1655  }
1656 }
1657 
1658 bool SwRangeRedline::CanCombine( const SwRangeRedline& rRedl ) const
1659 {
1660  return IsVisible() && rRedl.IsVisible() &&
1662 }
1663 
1664 void SwRangeRedline::PushData( const SwRangeRedline& rRedl, bool bOwnAsNext )
1665 {
1666  SwRedlineData* pNew = new SwRedlineData( *rRedl.m_pRedlineData, false );
1667  if( bOwnAsNext )
1668  {
1669  pNew->m_pNext = m_pRedlineData;
1670  m_pRedlineData = pNew;
1671  }
1672  else
1673  {
1674  pNew->m_pNext = m_pRedlineData->m_pNext;
1675  m_pRedlineData->m_pNext = pNew;
1676  }
1677 }
1678 
1680 {
1681  if( !m_pRedlineData->m_pNext )
1682  return false;
1683  SwRedlineData* pCur = m_pRedlineData;
1684  m_pRedlineData = pCur->m_pNext;
1685  pCur->m_pNext = nullptr;
1686  delete pCur;
1687  return true;
1688 }
1689 
1691 {
1692  sal_uInt16 nRet = 1;
1693  for( SwRedlineData* pCur = m_pRedlineData; pCur->m_pNext; pCur = pCur->m_pNext )
1694  ++nRet;
1695  return nRet;
1696 }
1697 
1698 std::size_t SwRangeRedline::GetAuthor( sal_uInt16 nPos ) const
1699 {
1700  return GetRedlineData(nPos).m_nAuthor;
1701 }
1702 
1703 OUString const & SwRangeRedline::GetAuthorString( sal_uInt16 nPos ) const
1704 {
1705  return SW_MOD()->GetRedlineAuthor(GetRedlineData(nPos).m_nAuthor);
1706 }
1707 
1708 const DateTime& SwRangeRedline::GetTimeStamp( sal_uInt16 nPos ) const
1709 {
1710  return GetRedlineData(nPos).m_aStamp;
1711 }
1712 
1713 RedlineType SwRangeRedline::GetType( sal_uInt16 nPos ) const
1714 {
1715  return GetRedlineData(nPos).m_eType;
1716 }
1717 
1718 const OUString& SwRangeRedline::GetComment( sal_uInt16 nPos ) const
1719 {
1720  return GetRedlineData(nPos).m_sComment;
1721 }
1722 
1724 {
1725  if (*Start() < *rCmp.Start())
1726  return true;
1727 
1728  return *Start() == *rCmp.Start() && *End() < *rCmp.End();
1729 }
1730 
1731 const SwRedlineData & SwRangeRedline::GetRedlineData(const sal_uInt16 nPos) const
1732 {
1733  SwRedlineData * pCur = m_pRedlineData;
1734 
1735  sal_uInt16 nP = nPos;
1736 
1737  while (nP > 0 && nullptr != pCur->m_pNext)
1738  {
1739  pCur = pCur->m_pNext;
1740 
1741  nP--;
1742  }
1743 
1744  SAL_WARN_IF( nP != 0, "sw.core", "Pos " << nPos << " is " << nP << " too big");
1745 
1746  return *pCur;
1747 }
1748 
1750 {
1751  // get description of redline data (e.g.: "insert $1")
1752  OUString aResult = GetRedlineData().GetDescr();
1753 
1754  SwPaM * pPaM = nullptr;
1755  bool bDeletePaM = false;
1756 
1757  // if this redline is visible the content is in this PaM
1758  if (nullptr == m_pContentSect)
1759  {
1760  pPaM = this;
1761  }
1762  else // otherwise it is saved in pContentSect
1763  {
1765  pPaM = new SwPaM(*m_pContentSect, aTmpIdx );
1766  bDeletePaM = true;
1767  }
1768 
1769  OUString sDescr = pPaM->GetText();
1770  if (const SwTextNode *pTextNode = pPaM->GetNode().GetTextNode())
1771  {
1772  if (const SwTextAttr* pTextAttr = pTextNode->GetFieldTextAttrAt(pPaM->GetPoint()->nContent.GetIndex() - 1, true ))
1773  {
1774  sDescr = pTextAttr->GetFormatField().GetField()->GetFieldName();
1775  }
1776  }
1777 
1778  // replace $1 in description by description of the redlines text
1779  const OUString aTmpStr = SwResId(STR_START_QUOTE)
1780  + ShortenString(sDescr, nUndoStringLength, SwResId(STR_LDOTS))
1781  + SwResId(STR_END_QUOTE);
1782 
1783  SwRewriter aRewriter;
1784  aRewriter.AddRule(UndoArg1, aTmpStr);
1785 
1786  aResult = aRewriter.Apply(aResult);
1787 
1788  if (bDeletePaM)
1789  delete pPaM;
1790 
1791  return aResult;
1792 }
1793 
1795 {
1796  xmlTextWriterStartElement(pWriter, BAD_CAST("SwRangeRedline"));
1797 
1798  xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
1799  xmlTextWriterWriteAttribute(pWriter, BAD_CAST("id"), BAD_CAST(OString::number(GetSeqNo()).getStr()));
1800  xmlTextWriterWriteAttribute(pWriter, BAD_CAST("author"), BAD_CAST(SW_MOD()->GetRedlineAuthor(GetAuthor()).toUtf8().getStr()));
1801  xmlTextWriterWriteAttribute(pWriter, BAD_CAST("date"), BAD_CAST(DateTimeToOString(GetTimeStamp()).getStr()));
1802  xmlTextWriterWriteAttribute(pWriter, BAD_CAST("descr"), BAD_CAST(const_cast<SwRangeRedline*>(this)->GetDescr().toUtf8().getStr()));
1803 
1804  OString sRedlineType;
1805  switch (GetType())
1806  {
1807  case RedlineType::Insert:
1808  sRedlineType = "REDLINE_INSERT";
1809  break;
1810  case RedlineType::Delete:
1811  sRedlineType = "REDLINE_DELETE";
1812  break;
1813  case RedlineType::Format:
1814  sRedlineType = "REDLINE_FORMAT";
1815  break;
1816  default:
1817  sRedlineType = "UNKNOWN";
1818  break;
1819  }
1820  xmlTextWriterWriteAttribute(pWriter, BAD_CAST("type"), BAD_CAST(sRedlineType.getStr()));
1821 
1822  SwPaM::dumpAsXml(pWriter);
1823 
1824  xmlTextWriterEndElement(pWriter);
1825 }
1826 
1828 {
1829  m_aExtraRedlines.push_back( p );
1830  //p->CallDisplayFunc();
1831 }
1832 
1833 void SwExtraRedlineTable::DeleteAndDestroy(sal_uInt16 const nPos)
1834 {
1835  /*
1836  SwDoc* pDoc = 0;
1837  if( !nP && nL && nL == size() )
1838  pDoc = front()->GetDoc();
1839  */
1840 
1841  delete m_aExtraRedlines[nPos];
1842  m_aExtraRedlines.erase(m_aExtraRedlines.begin() + nPos);
1843 
1844  /*
1845  SwViewShell* pSh;
1846  if( pDoc && !pDoc->IsInDtor() &&
1847  0 != ( pSh = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell() ) )
1848  pSh->InvalidateWindows( SwRect( 0, 0, SAL_MAX_INT32, SAL_MAX_INT32 ) );
1849  */
1850 }
1851 
1853 {
1854  while (!m_aExtraRedlines.empty())
1855  {
1856  auto const pRedline = m_aExtraRedlines.back();
1857  m_aExtraRedlines.pop_back();
1858  delete pRedline;
1859  }
1860 }
1861 
1863 {
1864 }
1865 
1867  : m_aRedlineData(rData)
1868  , m_rTableLine(rTableLine)
1869 {
1870 }
1871 
1873 {
1874 }
1875 
1877  : m_aRedlineData(rData)
1878  , m_rTableBox(rTableBox)
1879 {
1880 }
1881 
1883 {
1884 }
1885 
1886 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual ~SwRedlineExtraData_FormatColl() override
Definition: docredln.cxx:763
void SetCopyIsMove(bool bFlag)
Definition: doc.hxx:1361
const SwEndNode * EndOfSectionNode() const
Definition: node.hxx:682
Starts a section of nodes in the document model.
Definition: node.hxx:303
Base class of the Writer layout elements.
Definition: frame.hxx:295
virtual sal_Int32 Len() const
Definition: node.cxx:1183
void DeleteMark()
Definition: pam.hxx:177
bool CanCombine(const SwRangeRedline &rRedl) const
Definition: docredln.cxx:1658
sal_uLong GetIndex() const
Definition: node.hxx:282
SwRedlineData(RedlineType eT, std::size_t nAut)
Definition: docredln.cxx:871
SwNode & GetNode(bool bPoint=true) const
Definition: pam.hxx:223
bool InsertWithValidRanges(SwRangeRedline *&p, size_type *pInsPos=nullptr)
Definition: docredln.cxx:560
bool IsFollow() const
Definition: flowfrm.hxx:166
sal_uInt16 GetSeqNo() const
Definition: redline.hxx:220
void Insert(SwExtraRedline *p)
Definition: docredln.cxx:1827
Represents the style of a paragraph.
Definition: fmtcol.hxx:55
Marks a position in the document model.
Definition: pam.hxx:35
void Show(sal_uInt16 nLoop, size_t nMyPos)
Definition: docredln.cxx:1088
bool IsSectionNode() const
Definition: node.hxx:644
SwNodeIndex * m_pContentSect
Definition: redline.hxx:154
void Hide(sal_uInt16 nLoop, size_t nMyPos)
Definition: docredln.cxx:1120
virtual void ModifyNotification(const SfxPoolItem *pOld, const SfxPoolItem *pNew) override
Definition: node.hxx:475
void SetContentIdx(const SwNodeIndex *)
Definition: docredln.cxx:1639
OUString const & GetAuthorString(sal_uInt16 nPos=0) const
Definition: docredln.cxx:1703
virtual ~SwRangeRedline() override
Definition: docredln.cxx:1005
const OUString & GetText() const
Definition: ndtxt.hxx:211
void SetSec(sal_uInt16 nNewSec)
OUString toISO8601(const css::util::DateTime &rDateTime)
SwRedlineData * m_pNext
Definition: redline.hxx:88
SwRect FindLayoutRect(const bool bPrtArea=false, const Point *pPoint=nullptr) const
Definition: node.cxx:1158
virtual void SetRedlineFlags_intern(RedlineFlags eMode)=0
Set a new redline mode.
virtual ~SwExtraRedline()
Definition: docredln.cxx:1862
SwNodeIndex nNode
Definition: pam.hxx:37
virtual void InsertItemSet(const SwPaM &rRg, const SfxItemSet &, const SetAttrMode nFlags=SetAttrMode::DEFAULT, SwRootFrame const *pLayout=nullptr)=0
SwTextFormatColl * FindTextFormatCollByName(const OUString &rName) const
Definition: doc.hxx:794
virtual void SetModified()=0
Must be called manually at changes of format.
sal_uIntPtr sal_uLong
#define FRM_CNTNT
Definition: frame.hxx:101
size_type FindPrevOfSeqNo(size_type nSttPos) const
Definition: docredln.cxx:650
const SwPosition * GetMark() const
Definition: pam.hxx:209
void CallDisplayFunc(size_t nMyPos)
Definition: docredln.cxx:1077
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1150
void Remove(size_type nPos)
Definition: docredln.cxx:609
virtual void SetMark() override
Unless this is called, the getter method of Mark will return Point.
Definition: viscrs.cxx:573
Definition: doc.hxx:185
const SwRedlineData & GetRedlineData() const
Definition: redline.hxx:314
void SetEnd(const SwPosition &rPos, SwPosition *pEndPtr=nullptr)
Definition: docredln.cxx:1053
virtual bool operator==(const SwRedlineExtraData &) const
Definition: docredln.cxx:749
const Point & GetSttPos() const
Definition: viscrs.hxx:144
virtual void DeleteRange(SwPaM &)=0
Delete a range SwFlyFrameFormat.
void ShowOriginal(sal_uInt16 nLoop, size_t nMyPos)
Definition: docredln.cxx:1156
SwTableLine is one table row in the document model.
Definition: swtable.hxx:344
SwNode & GetNode() const
Definition: ndindex.hxx:118
bool IsAtEnd() const
const SwRedlineData & GetRedlineData() const
Definition: redline.hxx:293
virtual bool MoveRange(SwPaM &, SwPosition &, SwMoveFlags)=0
SwTableCellRedline(const SwRedlineData &rData, const SwTableBox &rTableBox)
Definition: docredln.cxx:1876
SwPosition & GetBound(bool bOne=true)
Definition: pam.hxx:245
const SwTableBox & GetTableBox() const
Definition: redline.hxx:312
Dialog to specify the properties of date form field.
Definition: accfrmobj.cxx:40
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:176
OString join(const OString &rSeparator, const std::vector< OString > &rSequence)
bool m_bIsVisible
Definition: redline.hxx:156
static sal_uInt32 m_nLastId
Definition: redline.hxx:167
Of course Writer needs its own rectangles.
Definition: swrect.hxx:34
virtual bool DeleteAndJoin(SwPaM &, const bool bForceJoinNext=false)=0
complete delete of a given PaM
static bool CheckPosition(const SwPosition *pStt, const SwPosition *pEnd)
Definition: docredln.cxx:110
static SwFlowFrame * CastFlowFrame(SwFrame *pFrame)
Definition: flowfrm.cxx:2601
IDocumentContentOperations const & getIDocumentContentOperations() const
Definition: doc.cxx:347
void CalcStartEnd(sal_uLong nNdIdx, sal_Int32 &rStart, sal_Int32 &rEnd) const
Calculates the intersection with text node number nNdIdx.
Definition: docredln.cxx:1250
The root element of a Writer document layout.
Definition: rootfrm.hxx:79
bool CanCombine(const SwRedlineData &rCmp) const
Definition: docredln.cxx:907
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: pam.cxx:1072
const SfxPoolItem * FirstItem()
virtual SwRedlineExtraData * CreateNew() const override
Definition: docredln.cxx:833
bool HasValidRange() const
Do we have a valid selection?
Definition: docredln.cxx:1062
SwWrtShell & GetWrtShell() const
Definition: view.hxx:400
show all inserts
size_type size() const
Definition: docary.hxx:368
SwContentNode * GetContentNode(bool bPoint=true) const
Definition: pam.hxx:229
RedlineType GetType() const
Definition: redline.hxx:123
virtual void Reject(SwPaM &rPam) const
Definition: docredln.cxx:745
new delete redline is created
Definition: hints.hxx:112
void GoEndSection(SwPosition *pPos)
go to the end of the current base section
Definition: pam.cxx:868
SW_DLLPUBLIC bool DeleteAllTableRedlines(SwDoc *pDoc, const SwTable &rTable, bool bSaveInUndo, RedlineType nRedlineTypeToDelete)
Definition: docredln.cxx:137
virtual SwRedlineExtraData * CreateNew() const override
Definition: docredln.cxx:767
SwIndex nContent
Definition: pam.hxx:38
enumrange< T >::Iterator begin(enumrange< T >)
OUString GetDescr() const
Definition: docredln.cxx:952
bool SetTextFormatColl(const SwPaM &rRg, SwTextFormatColl *pFormat, const bool bReset=true, const bool bResetListAttrs=false, SwRootFrame const *pLayout=nullptr)
Add 4th optional parameter .
Definition: docfmt.cxx:1096
IDocumentStylePoolAccess const & getIDocumentStylePoolAccess() const
Definition: doc.cxx:458
const DateTime & GetTimeStamp(sal_uInt16 nPos=0) const
Definition: docredln.cxx:1708
sal_uLong GetIndex() const
Definition: ndindex.hxx:151
static SfxViewShell * GetNext(const SfxViewShell &rPrev, bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
static SfxViewShell * Current()
static void LOKRedlineNotification(RedlineNotification eType, SwRangeRedline *pRedline)
Emits LOK notification about one addition / removal of a redline item.
Definition: docredln.cxx:352
virtual ~SwRedlineExtraData()
Definition: docredln.cxx:741
void libreOfficeKitViewCallback(int nType, const char *pPayload) const override
bool IsStartNode() const
Definition: node.hxx:624
void DeleteAndDestroy(sal_uInt16 nPos)
Definition: docredln.cxx:1833
SwRedlineExtraData_FormatColl(const OUString &rColl, sal_uInt16 nPoolFormatId, const SfxItemSet *pSet=nullptr)
Definition: docredln.cxx:754
void MoveFromSection(size_t nMyPos)
Definition: docredln.cxx:1517
const SwTable & GetTable() const
Definition: node.hxx:497
virtual void DeleteSection(SwNode *pNode)=0
Delete section containing the node.
virtual bool IsRedlineMove() const =0
const SfxPoolItem * GetDfltAttr(sal_uInt16 nWhich)
Get the default attribute from corresponding default attribute table.
Definition: hints.cxx:153
boost::optional< long > m_oLOKLastNodeTop
Definition: redline.hxx:159
RedlineFlags on.
void MaybeNotifyRedlineModification(SwRangeRedline *pRedline, SwDoc *pDoc)
Definition: docredln.cxx:1017
virtual bool DoesUndo() const =0
Is Undo enabled?
sal_uInt16 GetStackCount() const
Definition: docredln.cxx:1690
std::vector< sal_uInt16 > m_aWhichIds
Definition: redline.hxx:73
Redline that holds information about a table-cell that had some change.
Definition: redline.hxx:298
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: docredln.cxx:1794
const SwRedlineData & GetRedlineData(sal_uInt16 nPos=0) const
Definition: docredln.cxx:1731
virtual bool operator==(const SwRedlineExtraData &) const override
Definition: docredln.cxx:793
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
Definition: ndarr.hxx:164
virtual void Reject(SwPaM &rPam) const override
Definition: docredln.cxx:838
SwStartNode * MakeTextSection(const SwNodeIndex &rWhere, SwStartNodeType eSttNdTyp, SwTextFormatColl *pColl)
Definition: nodes.cxx:1900
css::util::DateTime GetUNODateTime() const
void InvalidateRange(Invalidation)
Initiate the layout.
Definition: docredln.cxx:1199
virtual ~SwTableRowRedline() override
Definition: docredln.cxx:1872
void DelCopyOfSection(size_t nMyPos)
Definition: docredln.cxx:1432
bool IsContentNode() const
Definition: node.hxx:628
OUString GetText() const
Definition: pam.cxx:1009
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
size_type FindPrevSeqNo(sal_uInt16 nSeqNo, size_type nSttPos) const
Definition: docredln.cxx:681
struct _xmlTextWriter * xmlTextWriterPtr
void SetExtraData(const SwRedlineExtraData *pData)
ExtraData is copied.
Definition: docredln.cxx:927
size_type GetPos(const SwRangeRedline *p) const
Definition: docredln.cxx:593
delete redline is removed
Definition: hints.hxx:122
SwPaM(SwPaM const &rPaM)=delete
#define SW_MOD()
Definition: swmodule.hxx:255
#define SAL_MAX_INT32
virtual void Reject(SwPaM &rPam) const override
Definition: docredln.cxx:772
const SwCursorShell * GetShell() const
Definition: viscrs.hxx:107
std::size_t const m_nAuthor
Definition: redline.hxx:95
std::vector< SwRangeRedline * > GetAllValidRanges(std::unique_ptr< SwRangeRedline > p)
Definition: docredln.cxx:452
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:131
void DeleteAndDestroy(size_type nPos)
Definition: docredln.cxx:635
const SwPosition * GetPoint() const
Definition: pam.hxx:207
SwTableRowRedline(const SwRedlineData &rData, const SwTableLine &rTableLine)
Definition: docredln.cxx:1866
void SetItemSet(const SfxItemSet &rSet)
Definition: docredln.cxx:801
SwFrameType
Definition: frame.hxx:72
SwIndex & Assign(SwIndexReg *, sal_Int32)
Definition: index.cxx:198
OUString Apply(const OUString &rStr) const
Definition: SwRewriter.cxx:43
OUString SwRedlineTypeToOUString(RedlineType eType)
::sw::DocumentContentOperationsManager const & GetDocumentContentOperationsManager() const
Definition: doc.cxx:357
void DeleteAndDestroyAll()
Definition: docredln.cxx:624
void Exchange()
Definition: pam.cxx:471
virtual ~SwRedlineExtraData_Format() override
Definition: docredln.cxx:829
int i
SwContentNode * GetContentNode()
Definition: node.hxx:615
vector_type::size_type size_type
Definition: docary.hxx:330
void CopyToSection()
Definition: docredln.cxx:1357
sal_uInt16 Count() const
const SfxPoolItem * NextItem()
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:205
bool DeleteTableRowRedline(SwDoc *pDoc, const SwTableLine &rTableLine, bool bSaveInUndo, RedlineType nRedlineTypeToDelete)
Definition: docredln.cxx:213
SwDoc * GetDoc() const
Definition: pam.hxx:243
Marks a character position inside a document model node.
Definition: index.hxx:37
void AddRule(SwUndoArg eWhat, const OUString &rWith)
Definition: SwRewriter.cxx:29
virtual void CallSwClientNotify(const SfxHint &rHint) const
Definition: calbck.cxx:369
const DateTime & GetTimeStamp() const
Definition: redline.hxx:127
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: docredln.cxx:730
static const char * STR_REDLINE_ARY[]
Definition: docredln.cxx:938
IDocumentState const & getIDocumentState() const
Definition: doc.cxx:426
void CopyWithFlyInFly(const SwNodeRange &rRg, const sal_Int32 nEndContentIndex, const SwNodeIndex &rInsPos, const std::pair< const SwPaM &, const SwPosition & > *pCopiedPaM=nullptr, bool bMakeNewFrames=true, bool bDelRedlines=true, bool bCopyFlyAtFly=false) const
const SwRangeRedline * FindAtPosition(const SwPosition &startPosition, size_type &tableIndex, bool next=true) const
Find the redline at the given position.
Definition: docredln.cxx:702
size
Marks a node in the document model.
Definition: ndindex.hxx:31
SwNodes & GetNodes()
Node is in which nodes-array/doc?
Definition: node.hxx:693
OUString SwResId(const char *pId)
Definition: swmodule.cxx:191
virtual SwFormatColl * ChgFormatColl(SwFormatColl *)
Definition: node.cxx:1185
Base object for 'Redlines' that are not of 'Ranged' type (like table row insert)
Definition: redline.hxx:266
static SfxViewShell * GetFirst(bool bOnlyVisible=true, const std::function< bool(const SfxViewShell *)> &isViewShell=nullptr)
#define RES_FMT_CHG
Definition: hintids.hxx:284
sal_uInt32 GetId() const
Definition: redline.hxx:181
Redline that holds information about a table-row that had some change.
Definition: redline.hxx:277
show all deletes
IDocumentLayoutAccess const & getIDocumentLayoutAccess() const
Definition: doc.cxx:437
void InvalidateWindows(const SwRect &rRect)
Definition: viewsh.cxx:551
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
bool IsVisible() const
Definition: redline.hxx:186
virtual void SetRedlineMove(bool bFlag)=0
virtual bool MoveAndJoin(SwPaM &, SwPosition &)=0
Move a range.
const OUString & GetComment(sal_uInt16 nPos=0) const
Definition: docredln.cxx:1718
ignore Redlines
const SwTableLine & GetTableLine() const
Definition: redline.hxx:291
size_type FindNextOfSeqNo(size_type nSttPos) const
Definition: docredln.cxx:643
const OUString & GetComment() const
Definition: redline.hxx:126
sal_uLong EndOfSectionIndex() const
Definition: node.hxx:677
void CopyCollFormat(SwTextNode &rDestNd)
Copy collection with all auto formats to dest-node.
Definition: ndcopy.cxx:327
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
std::unique_ptr< SfxItemSet > m_pSet
Definition: redline.hxx:56
SwTableBoxes & GetTabBoxes()
Definition: swtable.hxx:354
std::vector< SwRect > SwRects
Definition: swregion.hxx:26
OUString m_sComment
Definition: redline.hxx:91
std::vector< SwTableBox * > SwTableBoxes
Definition: swtable.hxx:103
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:367
SwRedlineExtraData * m_pExtraData
Definition: redline.hxx:89
const SwStartNode * GetSttNd() const
Definition: swtable.hxx:439
virtual SwRedlineExtraData * CreateNew() const =0
void sw_DebugRedline(const SwDoc *pDoc)
Definition: docredln.cxx:69
bool operator<(const SwRangeRedline &) const
Definition: docredln.cxx:1723
std::size_t GetAuthor(sal_uInt16 nPos=0) const
Definition: docredln.cxx:1698
#define SAL_WARN_IF(condition, area, stream)
RedlineType m_eType
Definition: redline.hxx:93
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: docredln.cxx:93
virtual const SwViewShell * GetCurrentViewShell() const =0
Returns the layout set at the document.
virtual bool operator==(const SwRedlineExtraData &) const override
Definition: docredln.cxx:855
const SwNodes & GetNodes() const
Definition: ndindex.hxx:155
OUString ShortenString(const OUString &rStr, sal_Int32 nLength, const OUString &rFillStr)
Shortens a string to a maximum length.
Definition: undobj.cxx:1505
void PushData(const SwRangeRedline &rRedl, bool bOwnAsNext=true)
Definition: docredln.cxx:1664
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:261
virtual bool InsertPoolItem(const SwPaM &rRg, const SfxPoolItem &, const SetAttrMode nFlags=SetAttrMode::DEFAULT, SwRootFrame const *pLayout=nullptr, bool bExpandCharToPara=false, SwTextAttr **ppNewTextAttr=nullptr)=0
Insert an attribute.
bool IsCopyIsMove() const
Definition: doc.hxx:1360
virtual bool DelFullPara(SwPaM &)=0
Delete full paragraphs.
sal_Int32 GetIndex() const
Definition: index.hxx:95
OString DateTimeToOString(const DateTime &rDateTime)
SwNodes & GetNodes()
Definition: doc.hxx:403
virtual SwTextFormatColl * GetTextCollFromPool(sal_uInt16 nId, bool bRegardLanguage=true)=0
Return "Auto-Collection with ID.
const SwPosition * End() const
Definition: pam.hxx:217
RedlineType GetType(sal_uInt16 nPos=0) const
Definition: docredln.cxx:1713
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:386
void MoveToSection()
Definition: docredln.cxx:1286
void SetNanoSec(sal_uInt32 nNewNanoSec)
size_type FindNextSeqNo(sal_uInt16 nSeqNo, size_type nSttPos) const
Search next or previous Redline with the same Seq.
Definition: docredln.cxx:658
virtual bool AppendTextNode(SwPosition &rPos)=0
RedlineNotification
Definition: docary.hxx:323
virtual ~SwTableCellRedline() override
Definition: docredln.cxx:1882
SwTableNode * FindTableNode()
Search table node, in which it is.
Definition: node.cxx:351
void DeleteAndDestroyAll()
Definition: docredln.cxx:1852
const Point & GetEndPos() const
Definition: viscrs.hxx:146
bool IsInDtor() const
Definition: doc.hxx:398
virtual RedlineFlags GetRedlineFlags() const =0
Query the currently set redline mode.
SwContentNode * GoPreviousNds(SwNodeIndex *pIdx, bool bChk)
Definition: pam.cxx:299
bool IsTableNode() const
Definition: node.hxx:640
SwFormatColl * GetFormatColl() const
Definition: node.hxx:447
bool DeleteTableCellRedline(SwDoc *pDoc, const SwTableBox &rTableBox, bool bSaveInUndo, RedlineType nRedlineTypeToDelete)
Definition: docredln.cxx:257
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:457
virtual const SwRedlineTable & GetRedlineTable() const =0
bool Insert(SwRangeRedline *&p)
Definition: docredln.cxx:425
SwNode & GetEndOfRedlines() const
Section for all Redlines.
Definition: ndarr.hxx:159
void MaybeNotifyRedlinePositionModification(long nTop)
Definition: docredln.cxx:1033
OUString GetDescr()
Returns textual description of a redline data element of this redline.
Definition: docredln.cxx:1749
SwRootFrame * GetLayout() const
Definition: viewsh.cxx:2072
sal_Int32 nPos
bool IsTextNode() const
Definition: node.hxx:636
SwRedlineData * m_pRedlineData
Definition: redline.hxx:153
SwRangeRedline(RedlineType eType, const SwPaM &rPam)
Definition: docredln.cxx:959
bool m_bDelLastPara
Definition: redline.hxx:155
bool operator()(SwRangeRedline *const &lhs, SwRangeRedline *const &rhs) const
Definition: docredln.cxx:583
SwContentNode * GoNext(SwNodeIndex *) const
Definition: nodes.cxx:1273
SwNodeIndex * GetContentIdx() const
Definition: redline.hxx:182
const sal_Int32 COMPLETE_STRING
Definition: swtypes.hxx:61
sal_uInt16 Which() const
SwRootFrame * getRootFrame()
Definition: frame.hxx:657
Definition: view.hxx:146
const int nUndoStringLength
Definition: UndoCore.hxx:225
void SetStart(const SwPosition &rPos, SwPosition *pSttPtr=nullptr)
Definition: docredln.cxx:1045
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:843
DateTime m_aStamp
Definition: redline.hxx:92
static SwStartNode * MakeEmptySection(const SwNodeIndex &rIdx, SwStartNodeType=SwNormalStartNode)
Create an empty section of Start- and EndNote.
Definition: nodes.cxx:1892
SwRedlineExtraData_Format(const SwRedlineExtraData_Format &rCpy)
Definition: docredln.cxx:822
Base class of the Writer document model elements.
Definition: node.hxx:79
SwTextFormatColl * GetTextColl() const
Definition: ndtxt.hxx:837
std::vector< SwExtraRedline * > m_aExtraRedlines
Definition: docary.hxx:382
virtual bool CopyRange(SwPaM &rPam, SwPosition &rPos, const bool bCopyAll, bool bCheckPos) const =0
Copy a selected content range to a position.