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  pViewShell->libreOfficeKitViewCallback(nType == RedlineNotification::Modify ? LOK_CALLBACK_REDLINE_TABLE_ENTRY_MODIFIED : LOK_CALLBACK_REDLINE_TABLE_SIZE_CHANGED, aPayload.c_str());
415  pViewShell = SfxViewShell::GetNext(*pViewShell);
416  }
417 }
418 
420 {
421  if( p->HasValidRange() )
422  {
423  std::pair<vector_type::const_iterator, bool> rv = maVector.insert( p );
424  size_type nP = rv.first - begin();
425  LOKRedlineNotification(RedlineNotification::Add, p);
426  p->CallDisplayFunc(nP);
427  return rv.second;
428  }
429  return InsertWithValidRanges( p );
430 }
431 
433 {
434  if( p->HasValidRange() )
435  {
436  std::pair<vector_type::const_iterator, bool> rv = maVector.insert( p );
437  rP = rv.first - begin();
438  p->CallDisplayFunc(rP);
439  return rv.second;
440  }
441  return InsertWithValidRanges( p, &rP );
442 }
443 
444 namespace sw {
445 
446 std::vector<SwRangeRedline*> GetAllValidRanges(std::unique_ptr<SwRangeRedline> p)
447 {
448  std::vector<SwRangeRedline*> ret;
449  // Create valid "sub-ranges" from the Selection
450  SwPosition* pStt = p->Start(),
451  * pEnd = pStt == p->GetPoint() ? p->GetMark() : p->GetPoint();
452  SwPosition aNewStt( *pStt );
453  SwNodes& rNds = aNewStt.nNode.GetNodes();
454  SwContentNode* pC;
455 
456  if( !aNewStt.nNode.GetNode().IsContentNode() )
457  {
458  pC = rNds.GoNext( &aNewStt.nNode );
459  if( pC )
460  aNewStt.nContent.Assign( pC, 0 );
461  else
462  aNewStt.nNode = rNds.GetEndOfContent();
463  }
464 
465  SwRangeRedline* pNew = nullptr;
466 
467  if( aNewStt < *pEnd )
468  do {
469  if( !pNew )
470  pNew = new SwRangeRedline( p->GetRedlineData(), aNewStt );
471  else
472  {
473  pNew->DeleteMark();
474  *pNew->GetPoint() = aNewStt;
475  }
476 
477  pNew->SetMark();
478  GoEndSection( pNew->GetPoint() );
479  // i60396: If the redlines starts before a table but the table is the last member
480  // of the section, the GoEndSection will end inside the table.
481  // This will result in an incorrect redline, so we've to go back
483  // We end in a table when pTab != 0
484  if( pTab && !pNew->GetMark()->nNode.GetNode().StartOfSectionNode()->FindTableNode() )
485  { // but our Mark was outside the table => Correction
486  do
487  {
488  // We want to be before the table
489  *pNew->GetPoint() = SwPosition(*pTab);
490  pC = GoPreviousNds( &pNew->GetPoint()->nNode, false ); // here we are.
491  if( pC )
492  pNew->GetPoint()->nContent.Assign( pC, 0 );
493  pTab = pNew->GetPoint()->nNode.GetNode().StartOfSectionNode()->FindTableNode();
494  } while( pTab ); // If there is another table we have to repeat our step backwards
495  }
496 
497  if( *pNew->GetPoint() > *pEnd )
498  {
499  pC = nullptr;
500  if( aNewStt.nNode != pEnd->nNode )
501  do {
502  SwNode& rCurNd = aNewStt.nNode.GetNode();
503  if( rCurNd.IsStartNode() )
504  {
505  if( rCurNd.EndOfSectionIndex() < pEnd->nNode.GetIndex() )
506  aNewStt.nNode = *rCurNd.EndOfSectionNode();
507  else
508  break;
509  }
510  else if( rCurNd.IsContentNode() )
511  pC = rCurNd.GetContentNode();
512  ++aNewStt.nNode;
513  } while( aNewStt.nNode.GetIndex() < pEnd->nNode.GetIndex() );
514 
515  if( aNewStt.nNode == pEnd->nNode )
516  aNewStt.nContent = pEnd->nContent;
517  else if( pC )
518  {
519  aNewStt.nNode = *pC;
520  aNewStt.nContent.Assign( pC, pC->Len() );
521  }
522 
523  if( aNewStt <= *pEnd )
524  *pNew->GetPoint() = aNewStt;
525  }
526  else
527  aNewStt = *pNew->GetPoint();
528 #if OSL_DEBUG_LEVEL > 0
529  CheckPosition( pNew->GetPoint(), pNew->GetMark() );
530 #endif
531 
532  if( *pNew->GetPoint() != *pNew->GetMark() &&
533  pNew->HasValidRange())
534  {
535  ret.push_back(pNew);
536  pNew = nullptr;
537  }
538 
539  if( aNewStt >= *pEnd )
540  break;
541  pC = rNds.GoNext( &aNewStt.nNode );
542  if( !pC )
543  break;
544 
545  aNewStt.nContent.Assign( pC, 0 );
546 
547  } while( aNewStt < *pEnd );
548 
549  delete pNew;
550  p.reset();
551  return ret;
552 }
553 
554 } // namespace sw
555 
557 {
558  bool bAnyIns = false;
559  std::vector<SwRangeRedline*> const redlines(
560  GetAllValidRanges(std::unique_ptr<SwRangeRedline>(p)));
561  for (SwRangeRedline * pRedline : redlines)
562  {
563  assert(pRedline->HasValidRange());
564  size_type nInsPos;
565  if (Insert(pRedline, nInsPos))
566  {
567  pRedline->CallDisplayFunc(nInsPos);
568  bAnyIns = true;
569  if (pInsPos && *pInsPos < nInsPos)
570  {
571  *pInsPos = nInsPos;
572  }
573  }
574  }
575  p = nullptr;
576  return bAnyIns;
577 }
578 
580 {
581  return *lhs < *rhs;
582 }
583 
585 {
586  maVector.DeleteAndDestroyAll();
587 }
588 
590 {
591  vector_type::const_iterator it = maVector.find(const_cast<SwRangeRedline*>(p));
592  if( it == maVector.end() )
593  return npos;
594  return it - maVector.begin();
595 }
596 
598 {
599  const size_type nPos = GetPos(p);
600  if (nPos == npos)
601  return;
602  Remove(nPos);
603 }
604 
606 {
607  LOKRedlineNotification(RedlineNotification::Remove, maVector[nP]);
608  SwDoc* pDoc = nullptr;
609  if( !nP && 1 == size() )
610  pDoc = maVector.front()->GetDoc();
611 
612  maVector.erase( maVector.begin() + nP );
613 
614  if( pDoc && !pDoc->IsInDtor() )
615  {
617  if( pSh )
619  }
620 }
621 
623 {
624  while (!maVector.empty())
625  {
626  auto const pRedline = maVector.back();
627  maVector.erase(maVector.size() - 1);
628  LOKRedlineNotification(RedlineNotification::Remove, pRedline);
629  delete pRedline;
630  }
631 }
632 
634 {
635  auto const pRedline = maVector[nP];
636  maVector.erase(maVector.begin() + nP);
637  LOKRedlineNotification(RedlineNotification::Remove, pRedline);
638  delete pRedline;
639 }
640 
642 {
643  return nSttPos + 1 < size()
644  ? FindNextSeqNo( operator[]( nSttPos )->GetSeqNo(), nSttPos+1 )
645  : npos;
646 }
647 
649 {
650  return nSttPos ? FindPrevSeqNo( operator[]( nSttPos )->GetSeqNo(), nSttPos-1 )
651  : npos;
652 }
653 
657 {
658  auto const nLookahead = 20;
659  size_type nRet = npos;
660  if( nSeqNo && nSttPos < size() )
661  {
662  size_type nEnd = size();
663  const size_type nTmp = nSttPos + nLookahead;
664  if (nTmp < nEnd)
665  {
666  nEnd = nTmp;
667  }
668 
669  for( ; nSttPos < nEnd; ++nSttPos )
670  if( nSeqNo == operator[]( nSttPos )->GetSeqNo() )
671  {
672  nRet = nSttPos;
673  break;
674  }
675  }
676  return nRet;
677 }
678 
680 {
681  auto const nLookahead = 20;
682  size_type nRet = npos;
683  if( nSeqNo && nSttPos < size() )
684  {
685  size_type nEnd = 0;
686  if( nSttPos > nLookahead )
687  nEnd = nSttPos - nLookahead;
688 
689  ++nSttPos;
690  while( nSttPos > nEnd )
691  if( nSeqNo == operator[]( --nSttPos )->GetSeqNo() )
692  {
693  nRet = nSttPos;
694  break;
695  }
696  }
697  return nRet;
698 }
699 
701  size_type& rPos,
702  bool bNext ) const
703 {
704  const SwRangeRedline* pFnd = nullptr;
705  for( ; rPos < maVector.size() ; ++rPos )
706  {
707  const SwRangeRedline* pTmp = (*this)[ rPos ];
708  if( pTmp->HasMark() && pTmp->IsVisible() )
709  {
710  const SwPosition* pRStt = pTmp->Start(),
711  * pREnd = pRStt == pTmp->GetPoint() ? pTmp->GetMark()
712  : pTmp->GetPoint();
713  if( bNext ? *pRStt <= rSttPos : *pRStt < rSttPos )
714  {
715  if( bNext ? *pREnd > rSttPos : *pREnd >= rSttPos )
716  {
717  pFnd = pTmp;
718  break;
719  }
720  }
721  else
722  break;
723  }
724  }
725  return pFnd;
726 }
727 
729 {
730  xmlTextWriterStartElement(pWriter, BAD_CAST("SwRedlineTable"));
731  xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
732 
733  for (SwRedlineTable::size_type nCurRedlinePos = 0; nCurRedlinePos < size(); ++nCurRedlinePos)
734  operator[](nCurRedlinePos)->dumpAsXml(pWriter);
735 
736  xmlTextWriterEndElement(pWriter);
737 }
738 
740 {
741 }
742 
744 {
745 }
746 
748 {
749  return false;
750 }
751 
753  sal_uInt16 nPoolFormatId,
754  const SfxItemSet* pItemSet,
755  bool bFormatAll )
756  : m_sFormatNm(rColl), m_nPoolId(nPoolFormatId), m_bFormatAll(bFormatAll)
757 {
758  if( pItemSet && pItemSet->Count() )
759  m_pSet.reset( new SfxItemSet( *pItemSet ) );
760 }
761 
763 {
764 }
765 
767 {
769 }
770 
772 {
773  SwDoc* pDoc = rPam.GetDoc();
774 
775  // What about Undo? Is it turned off?
779 
782 
783  SwPaM aPam( *rPam.GetMark(), *rPam.GetPoint() );
784 
785  const SwPosition* pStt = rPam.Start(),
786  * pEnd = pStt == rPam.GetPoint() ? rPam.GetMark()
787  : rPam.GetPoint();
788 
789  if ( !m_bFormatAll || pEnd->nContent == 0 )
790  {
791  // don't reject the format of the next paragraph (that is handled by the next redline)
792  if (aPam.GetPoint()->nNode > aPam.GetMark()->nNode)
793  {
794  aPam.GetPoint()->nNode--;
795  SwContentNode* pNode = aPam.GetPoint()->nNode.GetNode().GetContentNode();
796  aPam.GetPoint()->nContent.Assign( pNode, pNode->Len() );
797  }
798  else if (aPam.GetPoint()->nNode < aPam.GetMark()->nNode)
799  {
800  aPam.GetMark()->nNode--;
801  SwContentNode* pNode = aPam.GetMark()->nNode.GetNode().GetContentNode();
802  aPam.GetMark()->nContent.Assign( pNode, pNode->Len() );
803  }
804  }
805 
806  if( pColl )
807  pDoc->SetTextFormatColl( aPam, pColl, false );
808 
809  if( m_pSet )
811 
813 }
814 
816 {
817  const SwRedlineExtraData_FormatColl& rCmp = static_cast<const SwRedlineExtraData_FormatColl&>(r);
818  return m_sFormatNm == rCmp.m_sFormatNm && m_nPoolId == rCmp.m_nPoolId &&
819  m_bFormatAll == rCmp.m_bFormatAll &&
820  ( ( !m_pSet && !rCmp.m_pSet ) ||
821  ( m_pSet && rCmp.m_pSet && *m_pSet == *rCmp.m_pSet ) );
822 }
823 
825 {
826  if( rSet.Count() )
827  m_pSet.reset( new SfxItemSet( rSet ) );
828  else
829  m_pSet.reset();
830 }
831 
833 {
834  SfxItemIter aIter( rSet );
835  for (const SfxPoolItem* pItem = aIter.GetCurItem(); pItem; pItem = aIter.NextItem())
836  {
837  m_aWhichIds.push_back( pItem->Which() );
838  }
839 }
840 
842  const SwRedlineExtraData_Format& rCpy )
844 {
845  m_aWhichIds.insert( m_aWhichIds.begin(), rCpy.m_aWhichIds.begin(), rCpy.m_aWhichIds.end() );
846 }
847 
849 {
850 }
851 
853 {
854  return new SwRedlineExtraData_Format( *this );
855 }
856 
858 {
859  SwDoc* pDoc = rPam.GetDoc();
860 
863 
864  // Actually we need to reset the Attribute here!
865  for( const auto& rWhichId : m_aWhichIds )
866  {
867  pDoc->getIDocumentContentOperations().InsertPoolItem( rPam, *GetDfltAttr( rWhichId ),
869  }
870 
872 }
873 
875 {
876  const size_t nEnd = m_aWhichIds.size();
877  if( nEnd != static_cast<const SwRedlineExtraData_Format&>(rCmp).m_aWhichIds.size() )
878  return false;
879 
880  for( size_t n = 0; n < nEnd; ++n )
881  {
882  if( static_cast<const SwRedlineExtraData_Format&>(rCmp).m_aWhichIds[n] != m_aWhichIds[n])
883  {
884  return false;
885  }
886  }
887  return true;
888 }
889 
891  : m_pNext( nullptr ), m_pExtraData( nullptr ),
892  m_aStamp( DateTime::SYSTEM ),
893  m_eType( eT ), m_bAutoFormat(false), m_nAuthor( nAut ), m_nSeqNo( 0 )
894 {
895  m_aStamp.SetNanoSec( 0 );
896 }
897 
899  const SwRedlineData& rCpy,
900  bool bCpyNext )
901  : m_pNext( ( bCpyNext && rCpy.m_pNext ) ? new SwRedlineData( *rCpy.m_pNext ) : nullptr )
902  , m_pExtraData( rCpy.m_pExtraData ? rCpy.m_pExtraData->CreateNew() : nullptr )
903  , m_sComment( rCpy.m_sComment )
904  , m_aStamp( rCpy.m_aStamp )
905  , m_eType( rCpy.m_eType )
906  , m_bAutoFormat(false)
907  , m_nAuthor( rCpy.m_nAuthor )
908  , m_nSeqNo( rCpy.m_nSeqNo )
909 {
910 }
911 
912 // For sw3io: We now own pNext!
913 SwRedlineData::SwRedlineData(RedlineType eT, std::size_t nAut, const DateTime& rDT,
914  const OUString& rCmnt, SwRedlineData *pNxt)
915  : m_pNext(pNxt), m_pExtraData(nullptr), m_sComment(rCmnt), m_aStamp(rDT),
916  m_eType(eT), m_bAutoFormat(false), m_nAuthor(nAut), m_nSeqNo(0)
917 {
918 }
919 
921 {
922  delete m_pExtraData;
923  delete m_pNext;
924 }
925 
927 {
928  DateTime aTime = GetTimeStamp();
929  aTime.SetSec(0);
930  DateTime aCompareTime = rCmp.GetTimeStamp();
931  aCompareTime.SetSec(0);
932  return m_nAuthor == rCmp.m_nAuthor &&
933  m_eType == rCmp.m_eType &&
934  m_sComment == rCmp.m_sComment &&
935  aTime == aCompareTime &&
936  (( !m_pNext && !rCmp.m_pNext ) ||
937  ( m_pNext && rCmp.m_pNext &&
938  m_pNext->CanCombine( *rCmp.m_pNext ))) &&
939  (( !m_pExtraData && !rCmp.m_pExtraData ) ||
940  ( m_pExtraData && rCmp.m_pExtraData &&
941  *m_pExtraData == *rCmp.m_pExtraData ));
942 }
943 
947 {
948  delete m_pExtraData;
949 
950  // Check if there is data - and if so - delete it
951  if( pData )
952  m_pExtraData = pData->CreateNew();
953  else
954  m_pExtraData = nullptr;
955 }
956 
957 static const char* STR_REDLINE_ARY[] =
958 {
959  STR_UNDO_REDLINE_INSERT,
960  STR_UNDO_REDLINE_DELETE,
961  STR_UNDO_REDLINE_FORMAT,
962  STR_UNDO_REDLINE_TABLE,
963  STR_UNDO_REDLINE_FMTCOLL,
964  STR_UNDO_REDLINE_PARAGRAPH_FORMAT,
965  STR_UNDO_REDLINE_TABLE_ROW_INSERT,
966  STR_UNDO_REDLINE_TABLE_ROW_DELETE,
967  STR_UNDO_REDLINE_TABLE_CELL_INSERT,
968  STR_UNDO_REDLINE_TABLE_CELL_DELETE
969 };
970 
971 OUString SwRedlineData::GetDescr() const
972 {
973  return SwResId(STR_REDLINE_ARY[static_cast<int>(GetType())]);
974 }
975 
976 sal_uInt32 SwRangeRedline::m_nLastId = 1;
977 
979  : SwPaM( *rPam.GetMark(), *rPam.GetPoint() ),
980  m_pRedlineData( new SwRedlineData( eTyp, GetDoc()->getIDocumentRedlineAccess().GetRedlineAuthor() ) ),
981  m_pContentSect( nullptr ),
982  m_nId( m_nLastId++ )
983 {
984  m_bDelLastPara = false;
985  m_bIsVisible = true;
986  if( !rPam.HasMark() )
987  DeleteMark();
988 }
989 
991  : SwPaM( *rPam.GetMark(), *rPam.GetPoint() ),
992  m_pRedlineData( new SwRedlineData( rData )),
993  m_pContentSect( nullptr ),
994  m_nId( m_nLastId++ )
995 {
996  m_bDelLastPara = false;
997  m_bIsVisible = true;
998  if( !rPam.HasMark() )
999  DeleteMark();
1000 }
1001 
1003  : SwPaM( rPos ),
1004  m_pRedlineData( new SwRedlineData( rData )),
1005  m_pContentSect( nullptr ),
1006  m_nId( m_nLastId++ )
1007 {
1008  m_bDelLastPara = false;
1009  m_bIsVisible = true;
1010 }
1011 
1013  : SwPaM( *rCpy.GetMark(), *rCpy.GetPoint() ),
1014  m_pRedlineData( new SwRedlineData( *rCpy.m_pRedlineData )),
1015  m_pContentSect( nullptr ),
1016  m_nId( m_nLastId++ )
1017 {
1018  m_bDelLastPara = false;
1019  m_bIsVisible = true;
1020  if( !rCpy.HasMark() )
1021  DeleteMark();
1022 }
1023 
1025 {
1026  if( m_pContentSect )
1027  {
1028  // delete the ContentSection
1029  if( !GetDoc()->IsInDtor() )
1031  delete m_pContentSect;
1032  }
1033  delete m_pRedlineData;
1034 }
1035 
1037 {
1039  return;
1040 
1041  const SwRedlineTable& rRedTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable();
1042  for (SwRedlineTable::size_type i = 0; i < rRedTable.size(); ++i)
1043  {
1044  if (rRedTable[i] == pRedline)
1045  {
1047  break;
1048  }
1049  }
1050 }
1051 
1053 {
1055  return;
1056 
1057  if(!m_oLOKLastNodeTop || *m_oLOKLastNodeTop != nTop)
1058  {
1059  m_oLOKLastNodeTop = nTop;
1061  }
1062 }
1063 
1064 void SwRangeRedline::SetStart( const SwPosition& rPos, SwPosition* pSttPtr )
1065 {
1066  if( !pSttPtr ) pSttPtr = Start();
1067  *pSttPtr = rPos;
1068 
1070 }
1071 
1072 void SwRangeRedline::SetEnd( const SwPosition& rPos, SwPosition* pEndPtr )
1073 {
1074  if( !pEndPtr ) pEndPtr = End();
1075  *pEndPtr = rPos;
1076 
1078 }
1079 
1082 {
1083  const SwNode* pPtNd = &GetPoint()->nNode.GetNode(),
1084  * pMkNd = &GetMark()->nNode.GetNode();
1085  if( pPtNd->StartOfSectionNode() == pMkNd->StartOfSectionNode() &&
1086  !pPtNd->StartOfSectionNode()->IsTableNode() &&
1087  // invalid if points on the end of content
1088  // end-of-content only invalid if no content index exists
1089  ( pPtNd != pMkNd || GetContentIdx() != nullptr ||
1090  pPtNd != &pPtNd->GetNodes().GetEndOfContent() )
1091  )
1092  return true;
1093  return false;
1094 }
1095 
1097 {
1100  Show(0, nMyPos);
1101  else if (eShow == RedlineFlags::ShowInsert)
1102  Hide(0, nMyPos);
1103  else if (eShow == RedlineFlags::ShowDelete)
1104  ShowOriginal(0, nMyPos);
1105 }
1106 
1107 void SwRangeRedline::Show(sal_uInt16 nLoop, size_t nMyPos)
1108 {
1109  if( 1 <= nLoop )
1110  {
1111  SwDoc* pDoc = GetDoc();
1114  ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
1115 
1116  switch( GetType() )
1117  {
1118  case RedlineType::Insert: // Content has been inserted
1119  m_bIsVisible = true;
1120  MoveFromSection(nMyPos);
1121  break;
1122 
1123  case RedlineType::Delete: // Content has been deleted
1124  m_bIsVisible = true;
1125  MoveFromSection(nMyPos);
1126  break;
1127 
1128  case RedlineType::Format: // Attributes have been applied
1129  case RedlineType::Table: // Table structure has been modified
1131  break;
1132  default:
1133  break;
1134  }
1136  }
1137 }
1138 
1139 void SwRangeRedline::Hide(sal_uInt16 nLoop, size_t nMyPos)
1140 {
1141  SwDoc* pDoc = GetDoc();
1144  ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
1145 
1146  switch( GetType() )
1147  {
1148  case RedlineType::Insert: // Content has been inserted
1149  m_bIsVisible = true;
1150  if( 1 <= nLoop )
1151  MoveFromSection(nMyPos);
1152  break;
1153 
1154  case RedlineType::Delete: // Content has been deleted
1155  m_bIsVisible = false;
1156  switch( nLoop )
1157  {
1158  case 0: MoveToSection(); break;
1159  case 1: CopyToSection(); break;
1160  case 2: DelCopyOfSection(nMyPos); break;
1161  }
1162  break;
1163 
1164  case RedlineType::Format: // Attributes have been applied
1165  case RedlineType::Table: // Table structure has been modified
1166  if( 1 <= nLoop )
1168  break;
1169  default:
1170  break;
1171  }
1173 }
1174 
1175 void SwRangeRedline::ShowOriginal(sal_uInt16 nLoop, size_t nMyPos)
1176 {
1177  SwDoc* pDoc = GetDoc();
1179  SwRedlineData* pCur;
1180 
1182  ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
1183 
1184  // Determine the Type, it's the first on Stack
1185  for( pCur = m_pRedlineData; pCur->m_pNext; )
1186  pCur = pCur->m_pNext;
1187 
1188  switch( pCur->m_eType )
1189  {
1190  case RedlineType::Insert: // Content has been inserted
1191  m_bIsVisible = false;
1192  switch( nLoop )
1193  {
1194  case 0: MoveToSection(); break;
1195  case 1: CopyToSection(); break;
1196  case 2: DelCopyOfSection(nMyPos); break;
1197  }
1198  break;
1199 
1200  case RedlineType::Delete: // Content has been deleted
1201  m_bIsVisible = true;
1202  if( 1 <= nLoop )
1203  MoveFromSection(nMyPos);
1204  break;
1205 
1206  case RedlineType::Format: // Attributes have been applied
1207  case RedlineType::Table: // Table structure has been modified
1208  if( 1 <= nLoop )
1210  break;
1211  default:
1212  break;
1213  }
1215 }
1216 
1217 // trigger the Layout
1219 {
1220  sal_uLong nSttNd = GetMark()->nNode.GetIndex(),
1221  nEndNd = GetPoint()->nNode.GetIndex();
1222  sal_Int32 nSttCnt = GetMark()->nContent.GetIndex();
1223  sal_Int32 nEndCnt = GetPoint()->nContent.GetIndex();
1224 
1225  if( nSttNd > nEndNd || ( nSttNd == nEndNd && nSttCnt > nEndCnt ))
1226  {
1227  sal_uLong nTmp = nSttNd; nSttNd = nEndNd; nEndNd = nTmp;
1228  sal_Int32 nTmp2 = nSttCnt; nSttCnt = nEndCnt; nEndCnt = nTmp2;
1229  }
1230 
1231  SwNodes& rNds = GetDoc()->GetNodes();
1232  for (sal_uLong n(nSttNd); n <= nEndNd; ++n)
1233  {
1234  SwNode* pNode = rNds[n];
1235 
1236  if (pNode && pNode->IsTextNode())
1237  {
1238  SwTextNode* pNd = pNode->GetTextNode();
1239 
1240  SwUpdateAttr aHt(
1241  n == nSttNd ? nSttCnt : 0,
1242  n == nEndNd ? nEndCnt : pNd->GetText().getLength(),
1243  RES_FMT_CHG);
1244 
1245  pNd->ModifyNotification(&aHt, &aHt);
1246 
1247  // SwUpdateAttr must be handled first, otherwise indexes are off
1248  if (GetType() == RedlineType::Delete)
1249  {
1250  sal_Int32 const nStart(n == nSttNd ? nSttCnt : 0);
1251  sal_Int32 const nLen((n == nEndNd ? nEndCnt : pNd->GetText().getLength()) - nStart);
1252  if (eWhy == Invalidation::Add)
1253  {
1254  sw::RedlineDelText const hint(nStart, nLen);
1255  pNd->CallSwClientNotify(hint);
1256  }
1257  else
1258  {
1259  sw::RedlineUnDelText const hint(nStart, nLen);
1260  pNd->CallSwClientNotify(hint);
1261  }
1262  }
1263  }
1264  }
1265 }
1266 
1269 void SwRangeRedline::CalcStartEnd( sal_uLong nNdIdx, sal_Int32& rStart, sal_Int32& rEnd ) const
1270 {
1271  const SwPosition *pRStt = Start(), *pREnd = End();
1272  if( pRStt->nNode < nNdIdx )
1273  {
1274  if( pREnd->nNode > nNdIdx )
1275  {
1276  rStart = 0; // Paragraph is completely enclosed
1277  rEnd = COMPLETE_STRING;
1278  }
1279  else if (pREnd->nNode == nNdIdx)
1280  {
1281  rStart = 0; // Paragraph is overlapped in the beginning
1282  rEnd = pREnd->nContent.GetIndex();
1283  }
1284  else // redline ends before paragraph
1285  {
1286  rStart = COMPLETE_STRING;
1287  rEnd = COMPLETE_STRING;
1288  }
1289  }
1290  else if( pRStt->nNode == nNdIdx )
1291  {
1292  rStart = pRStt->nContent.GetIndex();
1293  if( pREnd->nNode == nNdIdx )
1294  rEnd = pREnd->nContent.GetIndex(); // Within the Paragraph
1295  else
1296  rEnd = COMPLETE_STRING; // Paragraph is overlapped in the end
1297  }
1298  else
1299  {
1300  rStart = COMPLETE_STRING;
1301  rEnd = COMPLETE_STRING;
1302  }
1303 }
1304 
1306 {
1307  if( !m_pContentSect )
1308  {
1309  const SwPosition* pStt = Start(),
1310  * pEnd = pStt == GetPoint() ? GetMark() : GetPoint();
1311 
1312  SwDoc* pDoc = GetDoc();
1313  SwPaM aPam( *pStt, *pEnd );
1314  SwContentNode* pCSttNd = pStt->nNode.GetNode().GetContentNode();
1315  SwContentNode* pCEndNd = pEnd->nNode.GetNode().GetContentNode();
1316 
1317  if( !pCSttNd )
1318  {
1319  // In order to not move other Redlines' indices, we set them
1320  // to the end (is exclusive)
1321  const SwRedlineTable& rTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable();
1322  for(SwRangeRedline* pRedl : rTable)
1323  {
1324  if( pRedl->GetBound() == *pStt )
1325  pRedl->GetBound() = *pEnd;
1326  if( pRedl->GetBound(false) == *pStt )
1327  pRedl->GetBound(false) = *pEnd;
1328  }
1329  }
1330 
1331  SwStartNode* pSttNd;
1332  SwNodes& rNds = pDoc->GetNodes();
1333  if( pCSttNd || pCEndNd )
1334  {
1335  SwTextFormatColl* pColl = (pCSttNd && pCSttNd->IsTextNode() )
1336  ? pCSttNd->GetTextNode()->GetTextColl()
1337  : (pCEndNd && pCEndNd->IsTextNode() )
1338  ? pCEndNd->GetTextNode()->GetTextColl()
1340 
1341  pSttNd = rNds.MakeTextSection( SwNodeIndex( rNds.GetEndOfRedlines() ),
1342  SwNormalStartNode, pColl );
1343  SwTextNode* pTextNd = rNds[ pSttNd->GetIndex() + 1 ]->GetTextNode();
1344 
1345  SwNodeIndex aNdIdx( *pTextNd );
1346  SwPosition aPos( aNdIdx, SwIndex( pTextNd ));
1347  if( pCSttNd && pCEndNd )
1348  pDoc->getIDocumentContentOperations().MoveAndJoin( aPam, aPos );
1349  else
1350  {
1351  if( pCSttNd && !pCEndNd )
1352  m_bDelLastPara = true;
1353  pDoc->getIDocumentContentOperations().MoveRange( aPam, aPos,
1355  }
1356  }
1357  else
1358  {
1360 
1361  SwPosition aPos( *pSttNd->EndOfSectionNode() );
1362  pDoc->getIDocumentContentOperations().MoveRange( aPam, aPos,
1364  }
1365  m_pContentSect = new SwNodeIndex( *pSttNd );
1366 
1367  if( pStt == GetPoint() )
1368  Exchange();
1369 
1370  DeleteMark();
1371  }
1372  else
1374 }
1375 
1377 {
1378  if( m_pContentSect )
1379  return;
1380 
1381  const SwPosition* pStt = Start(),
1382  * pEnd = pStt == GetPoint() ? GetMark() : GetPoint();
1383 
1384  SwContentNode* pCSttNd = pStt->nNode.GetNode().GetContentNode();
1385  SwContentNode* pCEndNd = pEnd->nNode.GetNode().GetContentNode();
1386 
1387  SwStartNode* pSttNd;
1388  SwDoc* pDoc = GetDoc();
1389  SwNodes& rNds = pDoc->GetNodes();
1390 
1391  bool bSaveCopyFlag = pDoc->IsCopyIsMove(),
1392  bSaveRdlMoveFlg = pDoc->getIDocumentRedlineAccess().IsRedlineMove();
1393  pDoc->SetCopyIsMove( true );
1394 
1395  // The IsRedlineMove() flag causes the behaviour of the
1396  // DocumentContentOperationsManager::CopyFlyInFlyImpl() method to change,
1397  // which will eventually be called by the CopyRange() below.
1399 
1400  if( pCSttNd )
1401  {
1402  SwTextFormatColl* pColl = pCSttNd->IsTextNode()
1403  ? pCSttNd->GetTextNode()->GetTextColl()
1405 
1406  pSttNd = rNds.MakeTextSection( SwNodeIndex( rNds.GetEndOfRedlines() ),
1407  SwNormalStartNode, pColl );
1408 
1409  SwNodeIndex aNdIdx( *pSttNd, 1 );
1410  SwTextNode* pTextNd = aNdIdx.GetNode().GetTextNode();
1411  SwPosition aPos( aNdIdx, SwIndex( pTextNd ));
1413 
1414  // Take over the style from the EndNode if needed
1415  // We don't want this in Doc::Copy
1416  if( pCEndNd && pCEndNd != pCSttNd )
1417  {
1418  SwContentNode* pDestNd = aPos.nNode.GetNode().GetContentNode();
1419  if( pDestNd )
1420  {
1421  if( pDestNd->IsTextNode() && pCEndNd->IsTextNode() )
1422  pCEndNd->GetTextNode()->CopyCollFormat(*pDestNd->GetTextNode());
1423  else
1424  pDestNd->ChgFormatColl( pCEndNd->GetFormatColl() );
1425  }
1426  }
1427  }
1428  else
1429  {
1431 
1432  if( pCEndNd )
1433  {
1434  SwPosition aPos( *pSttNd->EndOfSectionNode() );
1436  }
1437  else
1438  {
1439  SwNodeIndex aInsPos( *pSttNd->EndOfSectionNode() );
1440  SwNodeRange aRg( pStt->nNode, 0, pEnd->nNode, 1 );
1442  }
1443  }
1444  m_pContentSect = new SwNodeIndex( *pSttNd );
1445 
1446  pDoc->SetCopyIsMove( bSaveCopyFlag );
1447  pDoc->getIDocumentRedlineAccess().SetRedlineMove( bSaveRdlMoveFlg );
1448 
1449 }
1450 
1452 {
1453  if( m_pContentSect )
1454  {
1455  const SwPosition* pStt = Start(),
1456  * pEnd = pStt == GetPoint() ? GetMark() : GetPoint();
1457 
1458  SwDoc* pDoc = GetDoc();
1459  SwPaM aPam( *pStt, *pEnd );
1460  SwContentNode* pCSttNd = pStt->nNode.GetNode().GetContentNode();
1461  SwContentNode* pCEndNd = pEnd->nNode.GetNode().GetContentNode();
1462 
1463  if( !pCSttNd )
1464  {
1465  // In order to not move other Redlines' indices, we set them
1466  // to the end (is exclusive)
1467  const SwRedlineTable& rTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable();
1468  for(SwRangeRedline* pRedl : rTable)
1469  {
1470  if( pRedl->GetBound() == *pStt )
1471  pRedl->GetBound() = *pEnd;
1472  if( pRedl->GetBound(false) == *pStt )
1473  pRedl->GetBound(false) = *pEnd;
1474  }
1475  }
1476 
1477  if( pCSttNd && pCEndNd )
1478  {
1479  // #i100466# - force a <join next> on <delete and join> operation
1480  // tdf#125319 - rather not?
1481  pDoc->getIDocumentContentOperations().DeleteAndJoin(aPam/*, true*/);
1482  }
1483  else if( pCSttNd || pCEndNd )
1484  {
1485  if( pCSttNd && !pCEndNd )
1486  m_bDelLastPara = true;
1488 
1489  if( m_bDelLastPara )
1490  {
1491  // To prevent dangling references to the paragraph to
1492  // be deleted, redline that point into this paragraph should be
1493  // moved to the new end position. Since redlines in the redline
1494  // table are sorted and the pEnd position is an endnode (see
1495  // bDelLastPara condition above), only redlines before the
1496  // current ones can be affected.
1497  const SwRedlineTable& rTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable();
1498  size_t n = nMyPos;
1499  for( bool bBreak = false; !bBreak && n > 0; )
1500  {
1501  --n;
1502  bBreak = true;
1503  if( rTable[ n ]->GetBound() == *aPam.GetPoint() )
1504  {
1505  rTable[ n ]->GetBound() = *pEnd;
1506  bBreak = false;
1507  }
1508  if( rTable[ n ]->GetBound(false) == *aPam.GetPoint() )
1509  {
1510  rTable[ n ]->GetBound(false) = *pEnd;
1511  bBreak = false;
1512  }
1513  }
1514 
1515  *GetPoint() = *pEnd;
1516  *GetMark() = *pEnd;
1517  DeleteMark();
1518 
1519  aPam.GetBound().nContent.Assign( nullptr, 0 );
1520  aPam.GetBound( false ).nContent.Assign( nullptr, 0 );
1521  aPam.DeleteMark();
1523  }
1524  }
1525  else
1526  {
1528  }
1529 
1530  if( pStt == GetPoint() )
1531  Exchange();
1532 
1533  DeleteMark();
1534  }
1535 }
1536 
1538 {
1539  if( m_pContentSect )
1540  {
1541  SwDoc* pDoc = GetDoc();
1542  const SwRedlineTable& rTable = pDoc->getIDocumentRedlineAccess().GetRedlineTable();
1543  std::vector<SwPosition*> aBeforeArr, aBehindArr;
1544  bool bBreak = false;
1546 
1547  for( n = nMyPos+1; !bBreak && n < rTable.size(); ++n )
1548  {
1549  bBreak = true;
1550  if( rTable[ n ]->GetBound() == *GetPoint() )
1551  {
1552  SwRangeRedline* pRedl = rTable[n];
1553  aBehindArr.push_back(&pRedl->GetBound());
1554  bBreak = false;
1555  }
1556  if( rTable[ n ]->GetBound(false) == *GetPoint() )
1557  {
1558  SwRangeRedline* pRedl = rTable[n];
1559  aBehindArr.push_back(&pRedl->GetBound(false));
1560  bBreak = false;
1561  }
1562  }
1563  for( bBreak = false, n = nMyPos; !bBreak && n ; )
1564  {
1565  --n;
1566  bBreak = true;
1567  if( rTable[ n ]->GetBound() == *GetPoint() )
1568  {
1569  SwRangeRedline* pRedl = rTable[n];
1570  aBeforeArr.push_back(&pRedl->GetBound());
1571  bBreak = false;
1572  }
1573  if( rTable[ n ]->GetBound(false) == *GetPoint() )
1574  {
1575  SwRangeRedline* pRedl = rTable[n];
1576  aBeforeArr.push_back(&pRedl->GetBound(false));
1577  bBreak = false;
1578  }
1579  }
1580 
1581  const SwNode* pKeptContentSectNode( &m_pContentSect->GetNode() ); // #i95711#
1582  {
1583  SwPaM aPam( m_pContentSect->GetNode(),
1585  ( m_bDelLastPara ? -2 : -1 ) );
1586  SwContentNode* pCNd = aPam.GetContentNode();
1587  if( pCNd )
1588  aPam.GetPoint()->nContent.Assign( pCNd, pCNd->Len() );
1589  else
1590  ++aPam.GetPoint()->nNode;
1591 
1592  SwFormatColl* pColl = pCNd && pCNd->Len() && aPam.GetPoint()->nNode !=
1593  aPam.GetMark()->nNode
1594  ? pCNd->GetFormatColl() : nullptr;
1595 
1596  SwNodeIndex aNdIdx( GetPoint()->nNode, -1 );
1597  const sal_Int32 nPos = GetPoint()->nContent.GetIndex();
1598 
1599  SwPosition aPos( *GetPoint() );
1600  if( m_bDelLastPara && *aPam.GetPoint() == *aPam.GetMark() )
1601  {
1602  --aPos.nNode;
1603 
1605  }
1606  else
1607  {
1608  pDoc->getIDocumentContentOperations().MoveRange( aPam, aPos,
1610  }
1611 
1612  SetMark();
1613  *GetPoint() = aPos;
1614  GetMark()->nNode = aNdIdx.GetIndex() + 1;
1615  pCNd = GetMark()->nNode.GetNode().GetContentNode();
1616  GetMark()->nContent.Assign( pCNd, nPos );
1617 
1618  if( m_bDelLastPara )
1619  {
1620  ++GetPoint()->nNode;
1621  pCNd = GetContentNode();
1622  GetPoint()->nContent.Assign( pCNd, 0 );
1623  m_bDelLastPara = false;
1624  }
1625  else if( pColl )
1626  pCNd = GetContentNode();
1627 
1628  if( pColl && pCNd )
1629  pCNd->ChgFormatColl( pColl );
1630  }
1631 
1632  // #i95771#
1633  // Under certain conditions the previous <SwDoc::Move(..)> has already
1634  // removed the change tracking section of this <SwRangeRedline> instance from
1635  // the change tracking nodes area.
1636  // Thus, check if <pContentSect> still points to the change tracking section
1637  // by comparing it with the "indexed" <SwNode> instance copied before
1638  // perform the intrinsic move.
1639  // Note: Such condition is e.g. a "delete" change tracking only containing a table.
1640  if ( &m_pContentSect->GetNode() == pKeptContentSectNode )
1641  {
1643  }
1644  delete m_pContentSect;
1645  m_pContentSect = nullptr;
1646 
1647  // adjustment of redline table positions must take start and
1648  // end into account, not point and mark.
1649  for( auto& pItem : aBeforeArr )
1650  *pItem = *Start();
1651  for( auto& pItem : aBehindArr )
1652  *pItem = *End();
1653  }
1654  else
1656 }
1657 
1658 // for Undo
1660 {
1661  if( pIdx && !m_pContentSect )
1662  {
1663  m_pContentSect = new SwNodeIndex( *pIdx );
1664  m_bIsVisible = false;
1665  }
1666  else if( !pIdx && m_pContentSect )
1667  {
1668  delete m_pContentSect;
1669  m_pContentSect = nullptr;
1670  m_bIsVisible = false;
1671  }
1672  else
1673  {
1674  OSL_FAIL("SwRangeRedline::SetContentIdx: invalid state");
1675  }
1676 }
1677 
1678 bool SwRangeRedline::CanCombine( const SwRangeRedline& rRedl ) const
1679 {
1680  return IsVisible() && rRedl.IsVisible() &&
1682 }
1683 
1684 void SwRangeRedline::PushData( const SwRangeRedline& rRedl, bool bOwnAsNext )
1685 {
1686  SwRedlineData* pNew = new SwRedlineData( *rRedl.m_pRedlineData, false );
1687  if( bOwnAsNext )
1688  {
1689  pNew->m_pNext = m_pRedlineData;
1690  m_pRedlineData = pNew;
1691  }
1692  else
1693  {
1694  pNew->m_pNext = m_pRedlineData->m_pNext;
1695  m_pRedlineData->m_pNext = pNew;
1696  }
1697 }
1698 
1700 {
1701  if( !m_pRedlineData->m_pNext )
1702  return false;
1703  SwRedlineData* pCur = m_pRedlineData;
1704  m_pRedlineData = pCur->m_pNext;
1705  pCur->m_pNext = nullptr;
1706  delete pCur;
1707  return true;
1708 }
1709 
1711 {
1712  sal_uInt16 nRet = 1;
1713  for( SwRedlineData* pCur = m_pRedlineData; pCur->m_pNext; pCur = pCur->m_pNext )
1714  ++nRet;
1715  return nRet;
1716 }
1717 
1718 std::size_t SwRangeRedline::GetAuthor( sal_uInt16 nPos ) const
1719 {
1720  return GetRedlineData(nPos).m_nAuthor;
1721 }
1722 
1723 OUString const & SwRangeRedline::GetAuthorString( sal_uInt16 nPos ) const
1724 {
1725  return SW_MOD()->GetRedlineAuthor(GetRedlineData(nPos).m_nAuthor);
1726 }
1727 
1728 const DateTime& SwRangeRedline::GetTimeStamp( sal_uInt16 nPos ) const
1729 {
1730  return GetRedlineData(nPos).m_aStamp;
1731 }
1732 
1733 RedlineType SwRangeRedline::GetType( sal_uInt16 nPos ) const
1734 {
1735  return GetRedlineData(nPos).m_eType;
1736 }
1737 
1738 const OUString& SwRangeRedline::GetComment( sal_uInt16 nPos ) const
1739 {
1740  return GetRedlineData(nPos).m_sComment;
1741 }
1742 
1744 {
1745  if (*Start() < *rCmp.Start())
1746  return true;
1747 
1748  return *Start() == *rCmp.Start() && *End() < *rCmp.End();
1749 }
1750 
1751 const SwRedlineData & SwRangeRedline::GetRedlineData(const sal_uInt16 nPos) const
1752 {
1753  SwRedlineData * pCur = m_pRedlineData;
1754 
1755  sal_uInt16 nP = nPos;
1756 
1757  while (nP > 0 && nullptr != pCur->m_pNext)
1758  {
1759  pCur = pCur->m_pNext;
1760 
1761  nP--;
1762  }
1763 
1764  SAL_WARN_IF( nP != 0, "sw.core", "Pos " << nPos << " is " << nP << " too big");
1765 
1766  return *pCur;
1767 }
1768 
1770 {
1771  // get description of redline data (e.g.: "insert $1")
1772  OUString aResult = GetRedlineData().GetDescr();
1773 
1774  SwPaM * pPaM = nullptr;
1775  bool bDeletePaM = false;
1776 
1777  // if this redline is visible the content is in this PaM
1778  if (nullptr == m_pContentSect)
1779  {
1780  pPaM = this;
1781  }
1782  else // otherwise it is saved in pContentSect
1783  {
1785  pPaM = new SwPaM(*m_pContentSect, aTmpIdx );
1786  bDeletePaM = true;
1787  }
1788 
1789  OUString sDescr = DenoteSpecialCharacters(pPaM->GetText());
1790  if (const SwTextNode *pTextNode = pPaM->GetNode().GetTextNode())
1791  {
1792  if (const SwTextAttr* pTextAttr = pTextNode->GetFieldTextAttrAt(pPaM->GetPoint()->nContent.GetIndex() - 1, true ))
1793  {
1794  sDescr = SwResId(STR_START_QUOTE)
1795  + pTextAttr->GetFormatField().GetField()->GetFieldName()
1796  + SwResId(STR_END_QUOTE);
1797  }
1798  }
1799 
1800  // replace $1 in description by description of the redlines text
1801  const OUString aTmpStr = ShortenString(sDescr, nUndoStringLength, SwResId(STR_LDOTS));
1802 
1803  SwRewriter aRewriter;
1804  aRewriter.AddRule(UndoArg1, aTmpStr);
1805 
1806  aResult = aRewriter.Apply(aResult);
1807 
1808  if (bDeletePaM)
1809  delete pPaM;
1810 
1811  return aResult;
1812 }
1813 
1815 {
1816  xmlTextWriterStartElement(pWriter, BAD_CAST("SwRangeRedline"));
1817 
1818  xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
1819  xmlTextWriterWriteAttribute(pWriter, BAD_CAST("id"), BAD_CAST(OString::number(GetSeqNo()).getStr()));
1820  xmlTextWriterWriteAttribute(pWriter, BAD_CAST("author"), BAD_CAST(SW_MOD()->GetRedlineAuthor(GetAuthor()).toUtf8().getStr()));
1821  xmlTextWriterWriteAttribute(pWriter, BAD_CAST("date"), BAD_CAST(DateTimeToOString(GetTimeStamp()).getStr()));
1822  xmlTextWriterWriteAttribute(pWriter, BAD_CAST("descr"), BAD_CAST(const_cast<SwRangeRedline*>(this)->GetDescr().toUtf8().getStr()));
1823 
1824  OString sRedlineType;
1825  switch (GetType())
1826  {
1827  case RedlineType::Insert:
1828  sRedlineType = "REDLINE_INSERT";
1829  break;
1830  case RedlineType::Delete:
1831  sRedlineType = "REDLINE_DELETE";
1832  break;
1833  case RedlineType::Format:
1834  sRedlineType = "REDLINE_FORMAT";
1835  break;
1836  default:
1837  sRedlineType = "UNKNOWN";
1838  break;
1839  }
1840  xmlTextWriterWriteAttribute(pWriter, BAD_CAST("type"), BAD_CAST(sRedlineType.getStr()));
1841 
1842  SwPaM::dumpAsXml(pWriter);
1843 
1844  xmlTextWriterEndElement(pWriter);
1845 }
1846 
1848 {
1849  m_aExtraRedlines.push_back( p );
1850  //p->CallDisplayFunc();
1851 }
1852 
1853 void SwExtraRedlineTable::DeleteAndDestroy(sal_uInt16 const nPos)
1854 {
1855  /*
1856  SwDoc* pDoc = 0;
1857  if( !nP && nL && nL == size() )
1858  pDoc = front()->GetDoc();
1859  */
1860 
1861  delete m_aExtraRedlines[nPos];
1862  m_aExtraRedlines.erase(m_aExtraRedlines.begin() + nPos);
1863 
1864  /*
1865  SwViewShell* pSh;
1866  if( pDoc && !pDoc->IsInDtor() &&
1867  0 != ( pSh = pDoc->getIDocumentLayoutAccess().GetCurrentViewShell() ) )
1868  pSh->InvalidateWindows( SwRect( 0, 0, SAL_MAX_INT32, SAL_MAX_INT32 ) );
1869  */
1870 }
1871 
1873 {
1874  while (!m_aExtraRedlines.empty())
1875  {
1876  auto const pRedline = m_aExtraRedlines.back();
1877  m_aExtraRedlines.pop_back();
1878  delete pRedline;
1879  }
1880 }
1881 
1883 {
1884 }
1885 
1887  : m_aRedlineData(rData)
1888  , m_rTableLine(rTableLine)
1889 {
1890 }
1891 
1893 {
1894 }
1895 
1897  : m_aRedlineData(rData)
1898  , m_rTableBox(rTableBox)
1899 {
1900 }
1901 
1903 {
1904 }
1905 
1906 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual ~SwRedlineExtraData_FormatColl() override
Definition: docredln.cxx:762
void SetCopyIsMove(bool bFlag)
Definition: doc.hxx:1371
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:1181
void DeleteMark()
Definition: pam.hxx:177
bool CanCombine(const SwRangeRedline &rRedl) const
Definition: docredln.cxx:1678
sal_uLong GetIndex() const
Definition: node.hxx:282
SwRedlineData(RedlineType eT, std::size_t nAut)
Definition: docredln.cxx:890
SwNode & GetNode(bool bPoint=true) const
Definition: pam.hxx:223
bool InsertWithValidRanges(SwRangeRedline *&p, size_type *pInsPos=nullptr)
Definition: docredln.cxx:556
bool IsFollow() const
Definition: flowfrm.hxx:166
sal_uInt16 GetSeqNo() const
Definition: redline.hxx:222
void Insert(SwExtraRedline *p)
Definition: docredln.cxx:1847
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:1107
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:1139
virtual void ModifyNotification(const SfxPoolItem *pOld, const SfxPoolItem *pNew) override
Definition: node.hxx:475
void SetContentIdx(const SwNodeIndex *)
Definition: docredln.cxx:1659
OUString const & GetAuthorString(sal_uInt16 nPos=0) const
Definition: docredln.cxx:1723
virtual ~SwRangeRedline() override
Definition: docredln.cxx:1024
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:1156
virtual void SetRedlineFlags_intern(RedlineFlags eMode)=0
Set a new redline mode.
virtual ~SwExtraRedline()
Definition: docredln.cxx:1882
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:798
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:648
const SwPosition * GetMark() const
Definition: pam.hxx:209
void CallDisplayFunc(size_t nMyPos)
Definition: docredln.cxx:1096
SwContentFrame * getLayoutFrame(const SwRootFrame *, const SwPosition *pPos=nullptr, std::pair< Point, bool > const *pViewPosAndCalcFrame=nullptr) const
Definition: node.cxx:1148
sal_Int64 n
void Remove(size_type nPos)
Definition: docredln.cxx:605
virtual void SetMark() override
Unless this is called, the getter method of Mark will return Point.
Definition: viscrs.cxx:651
Definition: doc.hxx:186
const SwRedlineData & GetRedlineData() const
Definition: redline.hxx:316
void SetEnd(const SwPosition &rPos, SwPosition *pEndPtr=nullptr)
Definition: docredln.cxx:1072
virtual bool operator==(const SwRedlineExtraData &) const
Definition: docredln.cxx:747
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:1175
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:1896
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
static sal_uInt32 m_nLastId
Definition: redline.hxx:169
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:2609
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:1269
The root element of a Writer document layout.
Definition: rootfrm.hxx:79
bool CanCombine(const SwRedlineData &rCmp) const
Definition: docredln.cxx:926
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: pam.cxx:1136
virtual SwRedlineExtraData * CreateNew() const override
Definition: docredln.cxx:852
bool HasValidRange() const
Do we have a valid selection?
Definition: docredln.cxx:1081
SwWrtShell & GetWrtShell() const
Definition: view.hxx:400
show all inserts
size_type size() const
Definition: docary.hxx:266
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:743
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:766
SwIndex nContent
Definition: pam.hxx:38
enumrange< T >::Iterator begin(enumrange< T >)
OUString GetDescr() const
Definition: docredln.cxx:971
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:1728
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:739
void libreOfficeKitViewCallback(int nType, const char *pPayload) const override
bool IsStartNode() const
Definition: node.hxx:624
void DeleteAndDestroy(sal_uInt16 nPos)
Definition: docredln.cxx:1853
constexpr TypedWhichId< SwFormatChg > RES_FMT_CHG(160)
void MoveFromSection(size_t nMyPos)
Definition: docredln.cxx:1537
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:1036
virtual bool DoesUndo() const =0
Is Undo enabled?
sal_uInt16 GetStackCount() const
Definition: docredln.cxx:1710
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:1814
const SwRedlineData & GetRedlineData(sal_uInt16 nPos=0) const
Definition: docredln.cxx:1751
virtual bool operator==(const SwRedlineExtraData &) const override
Definition: docredln.cxx:815
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
Definition: ndarr.hxx:163
virtual void Reject(SwPaM &rPam) const override
Definition: docredln.cxx:857
SwStartNode * MakeTextSection(const SwNodeIndex &rWhere, SwStartNodeType eSttNdTyp, SwTextFormatColl *pColl)
Definition: nodes.cxx:1877
css::util::DateTime GetUNODateTime() const
void InvalidateRange(Invalidation)
Initiate the layout.
Definition: docredln.cxx:1218
virtual ~SwTableRowRedline() override
Definition: docredln.cxx:1892
void DelCopyOfSection(size_t nMyPos)
Definition: docredln.cxx:1451
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:679
struct _xmlTextWriter * xmlTextWriterPtr
void SetExtraData(const SwRedlineExtraData *pData)
ExtraData is copied.
Definition: docredln.cxx:946
size_type GetPos(const SwRangeRedline *p) const
Definition: docredln.cxx:589
delete redline is removed
Definition: hints.hxx:122
SwPaM(SwPaM const &rPaM)=delete
#define SW_MOD()
Definition: swmodule.hxx:256
#define SAL_MAX_INT32
virtual void Reject(SwPaM &rPam) const override
Definition: docredln.cxx:771
const SwCursorShell * GetShell() const
Definition: viscrs.hxx:109
std::vector< SwRangeRedline * > GetAllValidRanges(std::unique_ptr< SwRangeRedline > p)
Definition: docredln.cxx:446
int i
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:131
void DeleteAndDestroy(size_type nPos)
Definition: docredln.cxx:633
const SwPosition * GetPoint() const
Definition: pam.hxx:207
SwTableRowRedline(const SwRedlineData &rData, const SwTableLine &rTableLine)
Definition: docredln.cxx:1886
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:824
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:622
void Exchange()
Definition: pam.cxx:489
virtual ~SwRedlineExtraData_Format() override
Definition: docredln.cxx:848
SwContentNode * GetContentNode()
Definition: node.hxx:615
vector_type::size_type size_type
Definition: docary.hxx:228
void CopyToSection()
Definition: docredln.cxx:1376
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:37
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:728
static const char * STR_REDLINE_ARY[]
Definition: docredln.cxx:957
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:700
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:178
virtual SwFormatColl * ChgFormatColl(SwFormatColl *)
Definition: node.cxx:1183
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:1738
ignore Redlines
SwRedlineExtraData_FormatColl(const OUString &rColl, sal_uInt16 nPoolFormatId, const SfxItemSet *pSet=nullptr, bool bFormatAll=true)
Definition: docredln.cxx:752
const SwTableLine & GetTableLine() const
Definition: redline.hxx:293
size_type FindNextOfSeqNo(size_type nSttPos) const
Definition: docredln.cxx:641
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:1743
std::size_t GetAuthor(sal_uInt16 nPos=0) const
Definition: docredln.cxx:1718
#define SAL_WARN_IF(condition, area, stream)
RedlineType m_eType
Definition: redline.hxx:95
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:874
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:1499
void PushData(const SwRangeRedline &rRedl, bool bOwnAsNext=true)
Definition: docredln.cxx:1684
const o3tl::enumarray< SvxAdjust, unsigned short > aSvxToUnoAdjust USHRT_MAX
Definition: unosett.cxx:253
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:1370
virtual bool DelFullPara(SwPaM &)=0
Delete full paragraphs.
sal_Int32 GetIndex() const
Definition: index.hxx:95
OString DateTimeToOString(const DateTime &rDateTime)
SwNodes & GetNodes()
Definition: doc.hxx:405
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:1733
SwTableBox is one table cell in the document model.
Definition: swtable.hxx:386
void MoveToSection()
Definition: docredln.cxx:1305
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:656
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:1902
SwTableNode * FindTableNode()
Search table node, in which it is.
Definition: node.cxx:350
OUString DenoteSpecialCharacters(const OUString &rStr)
Denotes special characters in a string.
Definition: undel.cxx:704
void DeleteAndDestroyAll()
Definition: docredln.cxx:1872
const Point & GetEndPos() const
Definition: viscrs.hxx:148
bool IsInDtor() const
Definition: doc.hxx:400
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:419
SwNode & GetEndOfRedlines() const
Section for all Redlines.
Definition: ndarr.hxx:158
void MaybeNotifyRedlinePositionModification(long nTop)
Definition: docredln.cxx:1052
OUString GetDescr()
Returns textual description of a redline data element of this redline.
Definition: docredln.cxx:1769
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:978
sal_uInt32 m_nId
bool m_bDelLastPara
Definition: redline.hxx:157
bool operator()(SwRangeRedline *const &lhs, SwRangeRedline *const &rhs) const
Definition: docredln.cxx:579
SwContentNode * GoNext(SwNodeIndex *) const
Definition: nodes.cxx:1277
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:146
const int nUndoStringLength
Definition: UndoCore.hxx:224
void SetStart(const SwPosition &rPos, SwPosition *pSttPtr=nullptr)
Definition: docredln.cxx:1064
sal_uInt16 nPos
const SfxPoolItem * GetCurItem() const
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:836
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:1869
SwRedlineExtraData_Format(const SwRedlineExtraData_Format &rCpy)
Definition: docredln.cxx:841
Base class of the Writer document model elements.
Definition: node.hxx:79
SwTextFormatColl * GetTextColl() const
Definition: ndtxt.hxx:830
std::size_t m_nAuthor
Definition: redline.hxx:97
std::vector< SwExtraRedline * > m_aExtraRedlines
Definition: docary.hxx:280