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