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