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