LibreOffice Module sw (master)  1
undobj.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 
22 #include <IShellCursorSupplier.hxx>
23 #include <txtftn.hxx>
24 #include <fmtanchr.hxx>
25 #include <ftnidx.hxx>
26 #include <frmfmt.hxx>
27 #include <doc.hxx>
28 #include <UndoManager.hxx>
30 #include <docary.hxx>
31 #include <swcrsr.hxx>
32 #include <swundo.hxx>
33 #include <pam.hxx>
34 #include <ndtxt.hxx>
35 #include <UndoCore.hxx>
36 #include <rolbck.hxx>
37 #include <ndnotxt.hxx>
38 #include <IMark.hxx>
39 #include <mvsave.hxx>
40 #include <redline.hxx>
41 #include <crossrefbookmark.hxx>
42 #include <strings.hrc>
43 #include <docsh.hxx>
44 #include <view.hxx>
45 #include <frameformats.hxx>
46 #include <o3tl/deleter.hxx>
47 #include <sal/log.hxx>
48 
49 // This class saves the Pam as integers and can recompose those into a PaM
51  : m_nSttNode( 0 ), m_nEndNode( 0 ), m_nSttContent( 0 ), m_nEndContent( 0 )
52 {
53 }
54 
55 SwUndRng::SwUndRng( const SwPaM& rPam )
56 {
57  SetValues( rPam );
58 }
59 
60 void SwUndRng::SetValues( const SwPaM& rPam )
61 {
62  const SwPosition *pStt = rPam.Start();
63  if( rPam.HasMark() )
64  {
65  const SwPosition *pEnd = rPam.GetPoint() == pStt
66  ? rPam.GetMark()
67  : rPam.GetPoint();
68  m_nEndNode = pEnd->nNode.GetIndex();
70  }
71  else
72  {
73  // no selection !!
74  m_nEndNode = 0;
76  }
77 
78  m_nSttNode = pStt->nNode.GetIndex();
80 }
81 
82 void SwUndRng::SetPaM( SwPaM & rPam, bool bCorrToContent ) const
83 {
84  rPam.DeleteMark();
85  rPam.GetPoint()->nNode = m_nSttNode;
86  SwNode& rNd = rPam.GetNode();
87  if( rNd.IsContentNode() )
89  else if( bCorrToContent )
91  else
92  rPam.GetPoint()->nContent.Assign( nullptr, 0 );
93 
94  if( !m_nEndNode && COMPLETE_STRING == m_nEndContent ) // no selection
95  return ;
96 
97  rPam.SetMark();
99  return; // nothing left to do
100 
101  rPam.GetPoint()->nNode = m_nEndNode;
102  if( rPam.GetNode().IsContentNode() )
104  else if( bCorrToContent )
106  else
107  rPam.GetPoint()->nContent.Assign( nullptr, 0 );
108 }
109 
111  ::sw::UndoRedoContext & rContext, bool const bCorrToContent) const
112 {
113  SwCursor & rPaM( rContext.GetCursorSupplier().CreateNewShellCursor() );
114  SetPaM( rPaM, bCorrToContent );
115  return rPaM;
116 }
117 
119  const sal_uLong* pEndIdx )
120 {
121  SwNodeIndex aIdx( rDoc.GetNodes(), nSttIdx );
122  SwNodeIndex aEndIdx( rDoc.GetNodes(), pEndIdx ? *pEndIdx
123  : aIdx.GetNode().EndOfSectionIndex() );
124  SwPosition aPos( rDoc.GetNodes().GetEndOfPostIts() );
125  SwDoc::CorrAbs( aIdx, aEndIdx, aPos, true );
126 }
127 
128 void SwUndo::RemoveIdxFromRange( SwPaM& rPam, bool bMoveNext )
129 {
130  const SwPosition* pEnd = rPam.End();
131  if( bMoveNext )
132  {
133  if( pEnd != rPam.GetPoint() )
134  rPam.Exchange();
135 
136  SwNodeIndex aStt( rPam.GetMark()->nNode );
137  SwNodeIndex aEnd( rPam.GetPoint()->nNode );
138 
139  if( !rPam.Move( fnMoveForward ) )
140  {
141  rPam.Exchange();
142  if( !rPam.Move( fnMoveBackward ) )
143  {
144  rPam.GetPoint()->nNode = rPam.GetDoc().GetNodes().GetEndOfPostIts();
145  rPam.GetPoint()->nContent.Assign( nullptr, 0 );
146  }
147  }
148 
149  SwDoc::CorrAbs( aStt, aEnd, *rPam.GetPoint(), true );
150  }
151  else
152  SwDoc::CorrAbs( rPam, *pEnd, true );
153 }
154 
155 void SwUndo::RemoveIdxRel( sal_uLong nIdx, const SwPosition& rPos )
156 {
157  // Move only the Cursor. Bookmarks/TOXMarks/etc. are done by the corresponding
158  // JoinNext/JoinPrev
159  SwNodeIndex aIdx( rPos.nNode.GetNode().GetNodes(), nIdx );
160  ::PaMCorrRel( aIdx, rPos );
161 }
162 
163 SwUndo::SwUndo(SwUndoId const nId, const SwDoc* pDoc)
164  : m_nId(nId), m_nOrigRedlineFlags(RedlineFlags::NONE)
165  , m_nViewShellId(CreateViewShellId(pDoc))
166  , m_isRepeatIgnored(false)
167  , m_bCacheComment(true)
168 {
169 }
170 
172 {
173  ViewShellId nRet(-1);
174 
175  if (const SwDocShell* pDocShell = pDoc->GetDocShell())
176  {
177  if (const SwView* pView = pDocShell->GetView())
178  nRet = pView->GetViewShellId();
179  }
180 
181  return nRet;
182 }
183 
184 bool SwUndo::IsDelBox() const
185 {
188 }
189 
191 {
192 }
193 
194 namespace {
195 
196 class UndoRedoRedlineGuard
197 {
198 public:
199  UndoRedoRedlineGuard(::sw::UndoRedoContext const & rContext, SwUndo const & rUndo)
200  : m_rRedlineAccess(rContext.GetDoc().getIDocumentRedlineAccess())
201  , m_eMode(m_rRedlineAccess.GetRedlineFlags())
202  {
203  RedlineFlags const eTmpMode = rUndo.GetRedlineFlags();
204  if ((RedlineFlags::ShowMask & eTmpMode) != (RedlineFlags::ShowMask & m_eMode))
205  {
206  m_rRedlineAccess.SetRedlineFlags( eTmpMode );
207  }
208  m_rRedlineAccess.SetRedlineFlags_intern( eTmpMode | RedlineFlags::Ignore );
209  }
210  ~UndoRedoRedlineGuard()
211  {
212  m_rRedlineAccess.SetRedlineFlags(m_eMode);
213  }
214 private:
215  IDocumentRedlineAccess & m_rRedlineAccess;
216  RedlineFlags const m_eMode;
217 };
218 
219 }
220 
222 {
223  assert(false); // SwUndo::Undo(): ERROR: must call UndoWithContext instead
224 }
225 
227 {
228  assert(false); // SwUndo::Redo(): ERROR: must call RedoWithContext instead
229 }
230 
232 {
233  ::sw::UndoRedoContext *const pContext(
234  dynamic_cast< ::sw::UndoRedoContext * >(& rContext));
235  assert(pContext);
236  const UndoRedoRedlineGuard aUndoRedoRedlineGuard(*pContext, *this);
237  UndoImpl(*pContext);
238 }
239 
241 {
242  ::sw::UndoRedoContext *const pContext(
243  dynamic_cast< ::sw::UndoRedoContext * >(& rContext));
244  assert(pContext);
245  const UndoRedoRedlineGuard aUndoRedoRedlineGuard(*pContext, *this);
246  RedoImpl(*pContext);
247 }
248 
250 {
251  if (m_isRepeatIgnored)
252  {
253  return; // ignore Repeat for multi-selections
254  }
255  ::sw::RepeatContext *const pRepeatContext(
256  dynamic_cast< ::sw::RepeatContext * >(& rContext));
257  assert(pRepeatContext);
258  RepeatImpl(*pRepeatContext);
259 }
260 
261 bool SwUndo::CanRepeat(SfxRepeatTarget & rContext) const
262 {
263  assert(dynamic_cast< ::sw::RepeatContext * >(& rContext));
264  (void)rContext;
265  // a MultiSelection action that doesn't do anything must still return true
267 }
268 
270 {
271 }
272 
274 {
275  TranslateId pId;
276  switch (eId)
277  {
278  case SwUndoId::EMPTY:
279  pId = STR_CANT_UNDO;
280  break;
281  case SwUndoId::START:
282  case SwUndoId::END:
283  break;
284  case SwUndoId::DELETE:
285  pId = STR_DELETE_UNDO;
286  break;
287  case SwUndoId::INSERT:
288  pId = STR_INSERT_UNDO;
289  break;
290  case SwUndoId::OVERWRITE:
291  pId = STR_OVR_UNDO;
292  break;
293  case SwUndoId::SPLITNODE:
294  pId = STR_SPLITNODE_UNDO;
295  break;
296  case SwUndoId::INSATTR:
297  pId = STR_INSATTR_UNDO;
298  break;
300  pId = STR_SETFMTCOLL_UNDO;
301  break;
302  case SwUndoId::RESETATTR:
303  pId = STR_RESET_ATTR_UNDO;
304  break;
306  pId = STR_INSFMT_ATTR_UNDO;
307  break;
309  pId = STR_INSERT_DOC_UNDO;
310  break;
311  case SwUndoId::COPY:
312  pId = STR_COPY_UNDO;
313  break;
314  case SwUndoId::INSTABLE:
315  pId = STR_INSTABLE_UNDO;
316  break;
318  pId = STR_TABLETOTEXT_UNDO;
319  break;
321  pId = STR_TEXTTOTABLE_UNDO;
322  break;
323  case SwUndoId::SORT_TXT:
324  pId = STR_SORT_TXT;
325  break;
326  case SwUndoId::INSLAYFMT:
327  pId = STR_INSERTFLY;
328  break;
330  pId = STR_TABLEHEADLINE;
331  break;
333  pId = STR_INSERTSECTION;
334  break;
336  pId = STR_OUTLINE_LR;
337  break;
339  pId = STR_OUTLINE_UD;
340  break;
342  pId = STR_OUTLINE_EDIT;
343  break;
344  case SwUndoId::INSNUM:
345  pId = STR_INSNUM;
346  break;
347  case SwUndoId::NUMUP:
348  pId = STR_NUMUP;
349  break;
350  case SwUndoId::MOVENUM:
351  pId = STR_MOVENUM;
352  break;
354  pId = STR_INSERTDRAW;
355  break;
357  pId = STR_NUMORNONUM;
358  break;
360  pId = STR_INC_LEFTMARGIN;
361  break;
363  pId = STR_DEC_LEFTMARGIN;
364  break;
366  pId = STR_INSERTLABEL;
367  break;
369  pId = STR_SETNUMRULESTART;
370  break;
371  case SwUndoId::CHGFTN:
372  pId = STR_CHANGEFTN;
373  break;
374  case SwUndoId::REDLINE:
375  SAL_INFO("sw.core", "Should NEVER be used/translated");
376  return "$1";
378  pId = STR_ACCEPT_REDLINE;
379  break;
381  pId = STR_REJECT_REDLINE;
382  break;
384  pId = STR_SPLIT_TABLE;
385  break;
387  pId = STR_DONTEXPAND;
388  break;
390  pId = STR_AUTOCORRECT;
391  break;
393  pId = STR_MERGE_TABLE;
394  break;
396  pId = STR_TRANSLITERATE;
397  break;
399  pId = STR_PASTE_CLIPBOARD_UNDO;
400  break;
401  case SwUndoId::TYPING:
402  pId = STR_TYPING_UNDO;
403  break;
404  case SwUndoId::MOVE:
405  pId = STR_MOVE_UNDO;
406  break;
408  pId = STR_INSERT_GLOSSARY;
409  break;
411  pId = STR_DELBOOKMARK;
412  break;
414  pId = STR_INSBOOKMARK;
415  break;
416  case SwUndoId::SORT_TBL:
417  pId = STR_SORT_TBL;
418  break;
419  case SwUndoId::DELLAYFMT:
420  pId = STR_DELETEFLY;
421  break;
423  pId = STR_AUTOFORMAT;
424  break;
425  case SwUndoId::REPLACE:
426  pId = STR_REPLACE;
427  break;
429  pId = STR_DELETESECTION;
430  break;
432  pId = STR_CHANGESECTION;
433  break;
435  pId = STR_CHANGEDEFATTR;
436  break;
437  case SwUndoId::DELNUM:
438  pId = STR_DELNUM;
439  break;
440  case SwUndoId::DRAWUNDO:
441  pId = STR_DRAWUNDO;
442  break;
443  case SwUndoId::DRAWGROUP:
444  pId = STR_DRAWGROUP;
445  break;
447  pId = STR_DRAWUNGROUP;
448  break;
450  pId = STR_DRAWDELETE;
451  break;
452  case SwUndoId::REREAD:
453  pId = STR_REREAD;
454  break;
455  case SwUndoId::DELGRF:
456  pId = STR_DELGRF;
457  break;
459  pId = STR_TABLE_ATTR;
460  break;
462  pId = STR_UNDO_TABLE_AUTOFMT;
463  break;
465  pId = STR_UNDO_TABLE_INSCOL;
466  break;
468  pId = STR_UNDO_TABLE_INSROW;
469  break;
471  pId = STR_UNDO_TABLE_DELBOX;
472  break;
474  pId = STR_UNDO_TABLE_SPLIT;
475  break;
477  pId = STR_UNDO_TABLE_MERGE;
478  break;
479  case SwUndoId::TBLNUMFMT:
480  pId = STR_TABLE_NUMFORMAT;
481  break;
482  case SwUndoId::INSTOX:
483  pId = STR_INSERT_TOX;
484  break;
486  pId = STR_CLEAR_TOX_RANGE;
487  break;
488  case SwUndoId::TBLCPYTBL:
489  pId = STR_TABLE_TBLCPYTBL;
490  break;
491  case SwUndoId::CPYTBL:
492  pId = STR_TABLE_CPYTBL;
493  break;
495  pId = STR_INS_FROM_SHADOWCRSR;
496  break;
497  case SwUndoId::CHAINE:
498  pId = STR_UNDO_CHAIN;
499  break;
500  case SwUndoId::UNCHAIN:
501  pId = STR_UNDO_UNCHAIN;
502  break;
503  case SwUndoId::FTNINFO:
504  pId = STR_UNDO_FTNINFO;
505  break;
507  pId = STR_UNDO_COMPAREDOC;
508  break;
510  pId = STR_UNDO_SETFLYFRMFMT;
511  break;
513  pId = STR_UNDO_SETRUBYATTR;
514  break;
515  case SwUndoId::TOXCHANGE:
516  pId = STR_TOXCHANGE;
517  break;
519  pId = STR_UNDO_PAGEDESC_CREATE;
520  break;
522  pId = STR_UNDO_PAGEDESC;
523  break;
525  pId = STR_UNDO_PAGEDESC_DELETE;
526  break;
528  pId = STR_UNDO_HEADER_FOOTER;
529  break;
530  case SwUndoId::FIELD:
531  pId = STR_UNDO_FIELD;
532  break;
534  pId = STR_UNDO_TXTFMTCOL_CREATE;
535  break;
537  pId = STR_UNDO_TXTFMTCOL_DELETE;
538  break;
540  pId = STR_UNDO_TXTFMTCOL_RENAME;
541  break;
543  pId = STR_UNDO_CHARFMT_CREATE;
544  break;
546  pId = STR_UNDO_CHARFMT_DELETE;
547  break;
549  pId = STR_UNDO_CHARFMT_RENAME;
550  break;
552  pId = STR_UNDO_FRMFMT_CREATE;
553  break;
555  pId = STR_UNDO_FRMFMT_DELETE;
556  break;
558  pId = STR_UNDO_FRMFMT_RENAME;
559  break;
561  pId = STR_UNDO_NUMRULE_CREATE;
562  break;
564  pId = STR_UNDO_NUMRULE_DELETE;
565  break;
567  pId = STR_UNDO_NUMRULE_RENAME;
568  break;
570  pId = STR_UNDO_BOOKMARK_RENAME;
571  break;
573  pId = STR_UNDO_INDEX_ENTRY_INSERT;
574  break;
576  pId = STR_UNDO_INDEX_ENTRY_DELETE;
577  break;
579  pId = STR_UNDO_COL_DELETE;
580  break;
582  pId = STR_UNDO_ROW_DELETE;
583  break;
585  pId = STR_UNDO_PAGEDESC_RENAME;
586  break;
587  case SwUndoId::NUMDOWN:
588  pId = STR_NUMDOWN;
589  break;
591  pId = STR_UNDO_FLYFRMFMT_TITLE;
592  break;
594  pId = STR_UNDO_FLYFRMFMT_DESCRIPTION;
595  break;
597  pId = STR_UNDO_TBLSTYLE_CREATE;
598  break;
600  pId = STR_UNDO_TBLSTYLE_DELETE;
601  break;
603  pId = STR_UNDO_TBLSTYLE_UPDATE;
604  break;
606  pId = STR_REPLACE_UNDO;
607  break;
609  pId = STR_INSERT_PAGE_BREAK_UNDO;
610  break;
612  pId = STR_INSERT_COLUMN_BREAK_UNDO;
613  break;
615  pId = STR_INSERT_ENV_UNDO;
616  break;
618  pId = STR_DRAG_AND_COPY;
619  break;
621  pId = STR_DRAG_AND_MOVE;
622  break;
624  pId = STR_INSERT_CHART;
625  break;
627  pId = STR_INSERT_FOOTNOTE;
628  break;
630  pId = STR_INSERT_URLBTN;
631  break;
633  pId = STR_INSERT_URLTXT;
634  break;
636  pId = STR_DELETE_INVISIBLECNTNT;
637  break;
639  pId = STR_REPLACE_STYLE;
640  break;
642  pId = STR_DELETE_PAGE_BREAK;
643  break;
645  pId = STR_TEXT_CORRECTION;
646  break;
648  pId = STR_UNDO_TABLE_DELETE;
649  break;
650  case SwUndoId::CONFLICT:
651  break;
653  pId = STR_PARAGRAPH_SIGN_UNDO;
654  break;
656  pId = STR_UNDO_INSERT_FORM_FIELD;
657  break;
658  }
659 
660  assert(pId);
661  return SwResId(pId);
662 }
663 
664 OUString SwUndo::GetComment() const
665 {
666  OUString aResult;
667 
668  if (m_bCacheComment)
669  {
670  if (! maComment)
671  {
673 
674  SwRewriter aRewriter = GetRewriter();
675 
676  maComment = aRewriter.Apply(*maComment);
677  }
678 
679  aResult = *maComment;
680  }
681  else
682  {
683  aResult = GetUndoComment(GetId());
684 
685  SwRewriter aRewriter = GetRewriter();
686 
687  aResult = aRewriter.Apply(aResult);
688  }
689 
690  return aResult;
691 }
692 
694 {
695  return m_nViewShellId;
696 }
697 
699 {
700  SwRewriter aResult;
701 
702  return aResult;
703 }
704 
706 {}
707 
708 SwUndoSaveContent::~SwUndoSaveContent() COVERITY_NOEXCEPT_FALSE
709 {
710 }
711 
713 {
714  (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwUndoSaveContent"));
715  (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
716 
717  if (m_pHistory)
718  {
719  m_pHistory->dumpAsXml(pWriter);
720  }
721 
722  (void)xmlTextWriterEndElement(pWriter);
723 }
724 
725 // This is needed when deleting content. For REDO all contents will be moved
726 // into the UndoNodesArray. These methods always create a new node to insert
727 // content. As a result, the attributes will not be expanded.
728 // - MoveTo moves from NodesArray into UndoNodesArray
729 // - MoveFrom moves from UndoNodesArray into NodesArray
730 
731 // If pEndNdIdx is given, Undo/Redo calls -Ins/DelFly. In that case the whole
732 // section should be moved.
734  sal_uLong* pEndNdIdx )
735 {
736  SwDoc& rDoc = rPaM.GetDoc();
737  ::sw::UndoGuard const undoGuard(rDoc.GetIDocumentUndoRedo());
738 
739  SwNoTextNode* pCpyNd = rPaM.GetNode().GetNoTextNode();
740 
741  // here comes the actual delete (move)
742  SwNodes & rNds = rDoc.GetUndoManager().GetUndoNodes();
743  SwPosition aPos( pEndNdIdx ? rNds.GetEndOfPostIts()
744  : rNds.GetEndOfExtras() );
745 
746  const SwPosition* pStt = rPaM.Start(), *pEnd = rPaM.End();
747 
748  sal_uLong nTmpMvNode = aPos.nNode.GetIndex();
749 
750  if( pCpyNd || pEndNdIdx )
751  {
752  SwNodeRange aRg( pStt->nNode, 0, pEnd->nNode, 1 );
753  rDoc.GetNodes().MoveNodes( aRg, rNds, aPos.nNode, true );
754  aPos.nContent = 0;
755  --aPos.nNode;
756  }
757  else
758  {
759  rDoc.GetNodes().MoveRange( rPaM, aPos, rNds );
760  }
761  if( pEndNdIdx )
762  *pEndNdIdx = aPos.nNode.GetIndex();
763 
764  // old position
765  aPos.nNode = nTmpMvNode;
766  if( pNodeIdx )
767  *pNodeIdx = aPos.nNode;
768 }
769 
771  SwPosition& rInsPos,
772  const sal_uLong* pEndNdIdx, bool const bForceCreateFrames)
773 {
774  // here comes the recovery
775  SwNodes & rNds = rDoc.GetUndoManager().GetUndoNodes();
776  if( nNodeIdx == rNds.GetEndOfPostIts().GetIndex() )
777  return; // nothing saved
778 
779  ::sw::UndoGuard const undoGuard(rDoc.GetIDocumentUndoRedo());
780 
781  SwPaM aPaM( rInsPos );
782  if( pEndNdIdx ) // than get the section from it
783  aPaM.GetPoint()->nNode.Assign( rNds, *pEndNdIdx );
784  else
785  {
786  aPaM.GetPoint()->nNode = rNds.GetEndOfExtras();
787  GoInContent( aPaM, fnMoveBackward );
788  }
789 
790  SwTextNode* pTextNd = aPaM.GetNode().GetTextNode();
791  if (!pEndNdIdx && pTextNd)
792  {
793  aPaM.SetMark();
794  aPaM.GetPoint()->nNode = nNodeIdx;
795  aPaM.GetPoint()->nContent.Assign(aPaM.GetContentNode(), 0);
796 
797  SaveRedlEndPosForRestore aRedlRest( rInsPos.nNode, rInsPos.nContent.GetIndex() );
798 
799  rNds.MoveRange( aPaM, rInsPos, rDoc.GetNodes() );
800 
801  // delete the last Node as well
802  if( !aPaM.GetPoint()->nContent.GetIndex() ||
803  ( aPaM.GetPoint()->nNode++ && // still empty Nodes at the end?
804  &rNds.GetEndOfExtras() != &aPaM.GetPoint()->nNode.GetNode() ))
805  {
806  aPaM.GetPoint()->nContent.Assign( nullptr, 0 );
807  aPaM.SetMark();
808  rNds.Delete( aPaM.GetPoint()->nNode,
809  rNds.GetEndOfExtras().GetIndex() -
810  aPaM.GetPoint()->nNode.GetIndex() );
811  }
812 
813  aRedlRest.Restore();
814  }
815  else
816  {
817  SwNodeRange aRg( rNds, nNodeIdx, rNds, (pEndNdIdx
818  ? ((*pEndNdIdx) + 1)
819  : rNds.GetEndOfExtras().GetIndex() ) );
820  rNds.MoveNodes(aRg, rDoc.GetNodes(), rInsPos.nNode, nullptr == pEndNdIdx || bForceCreateFrames);
821 
822  }
823 }
824 
825 // These two methods move the Point of Pam backwards/forwards. With that, one
826 // can span an area for a Undo/Redo. (The Point is then positioned in front of
827 // the area to manipulate!)
828 // The flag indicates if there is still content in front of Point.
830 {
831  rPam.SetMark();
832  if( rPam.Move( fnMoveBackward ))
833  return true;
834 
835  // If there is no content onwards, set Point simply to the previous position
836  // (Node and Content, so that Content will be detached!)
837  --rPam.GetPoint()->nNode;
838  rPam.GetPoint()->nContent.Assign( nullptr, 0 );
839  return false;
840 }
841 
842 void SwUndoSaveContent::MovePtForward( SwPaM& rPam, bool bMvBkwrd )
843 {
844  // Was there content before this position?
845  if( bMvBkwrd )
846  rPam.Move( fnMoveForward );
847  else
848  {
849  ++rPam.GetPoint()->nNode;
850  SwContentNode* pCNd = rPam.GetContentNode();
851  if( pCNd )
852  pCNd->MakeStartIndex( &rPam.GetPoint()->nContent );
853  else
854  rPam.Move( fnMoveForward );
855  }
856 }
857 
858 // Delete all objects that have ContentIndices to the given area.
859 // Currently (1994) these exist:
860 // - Footnotes
861 // - Flys
862 // - Bookmarks
863 
864 // #i81002# - extending method
865 // delete certain (not all) cross-reference bookmarks at text node of <rMark>
866 // and at text node of <rPoint>, if these text nodes aren't the same.
868  const SwPosition& rPoint,
869  DelContentType nDelContentType )
870 {
871  const SwPosition *pStt = rMark < rPoint ? &rMark : &rPoint,
872  *pEnd = &rMark == pStt ? &rPoint : &rMark;
873 
874  SwDoc& rDoc = rMark.nNode.GetNode().GetDoc();
875 
876  // if it's not in the doc array, probably missing some invalidation somewhere
877  assert(&rPoint.nNode.GetNodes() == &rDoc.GetNodes());
878  assert(&rMark.nNode.GetNodes() == &rDoc.GetNodes());
879 
880  ::sw::UndoGuard const undoGuard(rDoc.GetIDocumentUndoRedo());
881 
882  // 1. Footnotes
883  if( DelContentType::Ftn & nDelContentType )
884  {
885  SwFootnoteIdxs& rFootnoteArr = rDoc.GetFootnoteIdxs();
886  if( !rFootnoteArr.empty() )
887  {
888  const SwNode* pFootnoteNd;
889  size_t nPos = 0;
890  rFootnoteArr.SeekEntry( pStt->nNode, &nPos );
891  SwTextFootnote* pSrch;
892 
893  // for now delete all that come afterwards
894  while( nPos < rFootnoteArr.size() && ( pFootnoteNd =
895  &( pSrch = rFootnoteArr[ nPos ] )->GetTextNode())->GetIndex()
896  <= pEnd->nNode.GetIndex() )
897  {
898  const sal_Int32 nFootnoteSttIdx = pSrch->GetStart();
899  if( (DelContentType::CheckNoCntnt & nDelContentType )
900  ? (&pEnd->nNode.GetNode() == pFootnoteNd )
901  : (( &pStt->nNode.GetNode() == pFootnoteNd &&
902  pStt->nContent.GetIndex() > nFootnoteSttIdx) ||
903  ( &pEnd->nNode.GetNode() == pFootnoteNd &&
904  nFootnoteSttIdx >= pEnd->nContent.GetIndex() )) )
905  {
906  ++nPos; // continue searching
907  continue;
908  }
909 
910 // FIXME: duplicated code here and below -> refactor?
911  // Unfortunately an index needs to be created. Otherwise there
912  // will be problems with TextNode because the index will be
913  // deleted in the DTOR of SwFootnote!
914  SwTextNode* pTextNd = const_cast<SwTextNode*>(static_cast<const SwTextNode*>(pFootnoteNd));
915  if( !m_pHistory )
916  m_pHistory.reset( new SwHistory );
917  SwTextAttr* const pFootnoteHint =
918  pTextNd->GetTextAttrForCharAt( nFootnoteSttIdx );
919  assert(pFootnoteHint);
920  SwIndex aIdx( pTextNd, nFootnoteSttIdx );
921  m_pHistory->Add( pFootnoteHint, pTextNd->GetIndex(), false );
922  pTextNd->EraseText( aIdx, 1 );
923  }
924 
925  while( nPos-- && ( pFootnoteNd = &( pSrch = rFootnoteArr[ nPos ] )->
926  GetTextNode())->GetIndex() >= pStt->nNode.GetIndex() )
927  {
928  const sal_Int32 nFootnoteSttIdx = pSrch->GetStart();
929  if( !(DelContentType::CheckNoCntnt & nDelContentType) && (
930  ( &pStt->nNode.GetNode() == pFootnoteNd &&
931  pStt->nContent.GetIndex() > nFootnoteSttIdx ) ||
932  ( &pEnd->nNode.GetNode() == pFootnoteNd &&
933  nFootnoteSttIdx >= pEnd->nContent.GetIndex() )))
934  continue; // continue searching
935 
936  // Unfortunately an index needs to be created. Otherwise there
937  // will be problems with TextNode because the index will be
938  // deleted in the DTOR of SwFootnote!
939  SwTextNode* pTextNd = const_cast<SwTextNode*>(static_cast<const SwTextNode*>(pFootnoteNd));
940  if( !m_pHistory )
941  m_pHistory.reset( new SwHistory );
942  SwTextAttr* const pFootnoteHint =
943  pTextNd->GetTextAttrForCharAt( nFootnoteSttIdx );
944  assert(pFootnoteHint);
945  SwIndex aIdx( pTextNd, nFootnoteSttIdx );
946  m_pHistory->Add( pFootnoteHint, pTextNd->GetIndex(), false );
947  pTextNd->EraseText( aIdx, 1 );
948  }
949  }
950  }
951 
952  // 2. Flys
953  if( DelContentType::Fly & nDelContentType )
954  {
955  sal_uInt16 nChainInsPos = m_pHistory ? m_pHistory->Count() : 0;
956  const SwFrameFormats& rSpzArr = *rDoc.GetSpzFrameFormats();
957  if( !rSpzArr.empty() )
958  {
959  SwFrameFormat* pFormat;
960  const SwFormatAnchor* pAnchor;
961  size_t n = rSpzArr.size();
962  const SwPosition* pAPos;
963 
964  while( n && !rSpzArr.empty() )
965  {
966  pFormat = rSpzArr[--n];
967  pAnchor = &pFormat->GetAnchor();
968  switch( pAnchor->GetAnchorId() )
969  {
970  case RndStdIds::FLY_AS_CHAR:
971  if( nullptr != (pAPos = pAnchor->GetContentAnchor() ) &&
972  (( DelContentType::CheckNoCntnt & nDelContentType )
973  ? ( pStt->nNode <= pAPos->nNode &&
974  pAPos->nNode < pEnd->nNode )
975  : ( *pStt <= *pAPos && *pAPos < *pEnd )) )
976  {
977  if( !m_pHistory )
978  m_pHistory.reset( new SwHistory );
979  SwTextNode *const pTextNd =
980  pAPos->nNode.GetNode().GetTextNode();
981  SwTextAttr* const pFlyHint = pTextNd->GetTextAttrForCharAt(
982  pAPos->nContent.GetIndex());
983  assert(pFlyHint);
984  m_pHistory->Add( pFlyHint, 0, false );
985  // reset n so that no Format is skipped
986  n = n >= rSpzArr.size() ? rSpzArr.size() : n+1;
987  }
988  break;
989  case RndStdIds::FLY_AT_PARA:
990  {
991  pAPos = pAnchor->GetContentAnchor();
992  if (pAPos &&
993  pStt->nNode <= pAPos->nNode && pAPos->nNode <= pEnd->nNode)
994  {
995  if (!m_pHistory)
996  m_pHistory.reset( new SwHistory );
997 
998  if (!(DelContentType::Replace & nDelContentType)
999  && IsSelectFrameAnchoredAtPara(*pAPos, *pStt, *pEnd, nDelContentType))
1000  {
1001  m_pHistory->AddDeleteFly(*pFormat, nChainInsPos);
1002  // reset n so that no Format is skipped
1003  n = n >= rSpzArr.size() ? rSpzArr.size() : n+1;
1004  }
1005  // Moving the anchor?
1007  & nDelContentType) &&
1008  // at least for calls from SwUndoDelete,
1009  // this should work - other Undos don't
1010  // remember the order of the cursor
1011  (rPoint.nNode.GetIndex() == pAPos->nNode.GetIndex())
1012  // Do not try to move the anchor to a table!
1013  && rMark.nNode.GetNode().IsTextNode())
1014  {
1015  m_pHistory->AddChangeFlyAnchor(*pFormat);
1016  SwFormatAnchor aAnch( *pAnchor );
1017  SwPosition aPos( rMark.nNode );
1018  aAnch.SetAnchor( &aPos );
1019  pFormat->SetFormatAttr( aAnch );
1020  }
1021  }
1022  }
1023  break;
1024  case RndStdIds::FLY_AT_CHAR:
1025  if( nullptr != (pAPos = pAnchor->GetContentAnchor() ) &&
1026  ( pStt->nNode <= pAPos->nNode && pAPos->nNode <= pEnd->nNode ) )
1027  {
1028  if( !m_pHistory )
1029  m_pHistory.reset( new SwHistory );
1030  if (!(DelContentType::Replace & nDelContentType)
1032  *pAPos, *pStt, *pEnd, nDelContentType))
1033  {
1034  m_pHistory->AddDeleteFly(*pFormat, nChainInsPos);
1035  n = n >= rSpzArr.size() ? rSpzArr.size() : n+1;
1036  }
1037  else if (!((DelContentType::CheckNoCntnt |
1039  & nDelContentType))
1040  {
1041  if( *pStt <= *pAPos && *pAPos < *pEnd )
1042  {
1043  // These are the objects anchored
1044  // between section start and end position
1045  // Do not try to move the anchor to a table!
1046  if( rMark.nNode.GetNode().GetTextNode() )
1047  {
1048  m_pHistory->AddChangeFlyAnchor(*pFormat);
1049  SwFormatAnchor aAnch( *pAnchor );
1050  aAnch.SetAnchor( &rMark );
1051  pFormat->SetFormatAttr( aAnch );
1052  }
1053  }
1054  }
1055  }
1056  break;
1057  case RndStdIds::FLY_AT_FLY:
1058 
1059  if( nullptr != (pAPos = pAnchor->GetContentAnchor() ) &&
1060  pStt->nNode == pAPos->nNode )
1061  {
1062  if( !m_pHistory )
1063  m_pHistory.reset( new SwHistory );
1064 
1065  m_pHistory->AddDeleteFly(*pFormat, nChainInsPos);
1066 
1067  // reset n so that no Format is skipped
1068  n = n >= rSpzArr.size() ? rSpzArr.size() : n+1;
1069  }
1070  break;
1071  default: break;
1072  }
1073  }
1074  }
1075  }
1076 
1077  // 3. Bookmarks
1078  if( !(DelContentType::Bkm & nDelContentType) )
1079  return;
1080 
1081  IDocumentMarkAccess* const pMarkAccess = rDoc.getIDocumentMarkAccess();
1082  if( !pMarkAccess->getAllMarksCount() )
1083  return;
1084 
1085  for( sal_Int32 n = 0; n < pMarkAccess->getAllMarksCount(); ++n )
1086  {
1087  // #i81002#
1088  bool bSavePos = false;
1089  bool bSaveOtherPos = false;
1090  const ::sw::mark::IMark *const pBkmk = pMarkAccess->getAllMarksBegin()[n];
1091  auto const type(IDocumentMarkAccess::GetType(*pBkmk));
1092 
1093  if( DelContentType::CheckNoCntnt & nDelContentType )
1094  {
1095  if ( pStt->nNode <= pBkmk->GetMarkPos().nNode
1096  && pBkmk->GetMarkPos().nNode < pEnd->nNode )
1097  {
1098  bSavePos = true;
1099  }
1100  if ( pBkmk->IsExpanded()
1101  && pStt->nNode <= pBkmk->GetOtherMarkPos().nNode
1102  && pBkmk->GetOtherMarkPos().nNode < pEnd->nNode )
1103  {
1104  bSaveOtherPos = true;
1105  }
1106  }
1107  else
1108  {
1109  // #i92125#
1110  // keep cross-reference bookmarks, if content inside one paragraph is deleted.
1111  if ( rMark.nNode == rPoint.nNode
1114  {
1115  continue;
1116  }
1117 
1118  bool bMaybe = false;
1119  if ( *pStt <= pBkmk->GetMarkPos() && pBkmk->GetMarkPos() <= *pEnd )
1120  {
1121  if ( pBkmk->GetMarkPos() == *pEnd
1122  || ( *pStt == pBkmk->GetMarkPos() && pBkmk->IsExpanded() ) )
1123  bMaybe = true;
1124  else
1125  bSavePos = true;
1126  }
1127  if( pBkmk->IsExpanded() &&
1128  *pStt <= pBkmk->GetOtherMarkPos() && pBkmk->GetOtherMarkPos() <= *pEnd )
1129  {
1130  assert(!bSaveOtherPos);
1131  if ( bSavePos
1132  || (*pStt < pBkmk->GetOtherMarkPos() && pBkmk->GetOtherMarkPos() < *pEnd)
1133  || (bMaybe
1138  {
1139  if( bMaybe )
1140  bSavePos = true;
1141  bSaveOtherPos = true;
1142  }
1143  }
1144 
1145  if ( !bSavePos && !bSaveOtherPos
1146  && dynamic_cast< const ::sw::mark::CrossRefBookmark* >(pBkmk) )
1147  {
1148  // certain special handling for cross-reference bookmarks
1149  const bool bDifferentTextNodesAtMarkAndPoint =
1150  rMark.nNode != rPoint.nNode
1151  && rMark.nNode.GetNode().GetTextNode()
1152  && rPoint.nNode.GetNode().GetTextNode();
1153  if ( bDifferentTextNodesAtMarkAndPoint )
1154  {
1155  // delete cross-reference bookmark at <pStt>, if only part of
1156  // <pEnd> text node content is deleted.
1157  if( pStt->nNode == pBkmk->GetMarkPos().nNode
1158  && pEnd->nContent.GetIndex() != pEnd->nNode.GetNode().GetTextNode()->Len() )
1159  {
1160  bSavePos = true;
1161  bSaveOtherPos = false; // cross-reference bookmarks are not expanded
1162  }
1163  // delete cross-reference bookmark at <pEnd>, if only part of
1164  // <pStt> text node content is deleted.
1165  else if( pEnd->nNode == pBkmk->GetMarkPos().nNode &&
1166  pStt->nContent.GetIndex() != 0 )
1167  {
1168  bSavePos = true;
1169  bSaveOtherPos = false; // cross-reference bookmarks are not expanded
1170  }
1171  }
1172  }
1174  {
1175  // delete annotation marks, if its end position is covered by the deletion
1176  const SwPosition& rAnnotationEndPos = pBkmk->GetMarkEnd();
1177  if ( *pStt < rAnnotationEndPos && rAnnotationEndPos <= *pEnd )
1178  {
1179  bSavePos = true;
1180  bSaveOtherPos = pBkmk->IsExpanded(); //tdf#90138, only save the other pos if there is one
1181  }
1182  }
1183  }
1184 
1185  if ( bSavePos || bSaveOtherPos )
1186  {
1188  {
1189  if( !m_pHistory )
1190  m_pHistory.reset( new SwHistory );
1191  m_pHistory->Add( *pBkmk, bSavePos, bSaveOtherPos );
1192  }
1193  if ( bSavePos
1194  && ( bSaveOtherPos
1195  || !pBkmk->IsExpanded() ) )
1196  {
1197  pMarkAccess->deleteMark(pMarkAccess->getAllMarksBegin()+n);
1198  n--;
1199  }
1200  }
1201  }
1202 }
1203 
1204 // save a complete section into UndoNodes array
1206  : m_nMoveLen( 0 ), m_nStartPos( ULONG_MAX )
1207 {
1208 }
1209 
1211 {
1212  if (m_pMovedStart) // delete also the section from UndoNodes array
1213  {
1214  // SaveSection saves the content in the PostIt section.
1215  SwNodes& rUNds = m_pMovedStart->GetNode().GetNodes();
1216  // cid#1486004 Uncaught exception
1218 
1219  m_pMovedStart.reset();
1220  }
1221  m_pRedlineSaveData.reset();
1222 }
1223 
1225 {
1226  SwNodeRange aRg( rSttIdx.GetNode(), *rSttIdx.GetNode().EndOfSectionNode() );
1227  SaveSection( aRg );
1228 }
1229 
1231  const SwNodeRange& rRange, bool const bExpandNodes)
1232 {
1233  SwPaM aPam( rRange.aStart, rRange.aEnd );
1234 
1235  // delete all footnotes, fly frames, bookmarks
1236  DelContentIndex( *aPam.GetMark(), *aPam.GetPoint() );
1237 
1238  // redlines *before* CorrAbs, because DelBookmarks will make them 0-length
1239  // but *after* DelContentIndex because that also may use FillSaveData (in
1240  // flys) and that will be restored *after* this one...
1243  {
1244  m_pRedlineSaveData.reset();
1245  }
1246 
1247  {
1248  // move certain indexes out of deleted range
1249  SwNodeIndex aSttIdx( aPam.Start()->nNode.GetNode() );
1250  SwNodeIndex aEndIdx( aPam.End()->nNode.GetNode() );
1251  SwNodeIndex aMvStt( aEndIdx, 1 );
1252  SwDoc::CorrAbs( aSttIdx, aEndIdx, SwPosition( aMvStt ), true );
1253  }
1254 
1255  m_nStartPos = rRange.aStart.GetIndex();
1256 
1257  if (bExpandNodes)
1258  {
1259  --aPam.GetPoint()->nNode;
1260  ++aPam.GetMark()->nNode;
1261  }
1262 
1263  SwContentNode* pCNd = aPam.GetContentNode( false );
1264  if( pCNd )
1265  aPam.GetMark()->nContent.Assign( pCNd, 0 );
1266  pCNd = aPam.GetContentNode();
1267  if( nullptr != pCNd )
1268  aPam.GetPoint()->nContent.Assign( pCNd, pCNd->Len() );
1269 
1270  // Keep positions as SwIndex so that this section can be deleted in DTOR
1271  sal_uLong nEnd;
1272  m_pMovedStart.reset(new SwNodeIndex(rRange.aStart));
1273  MoveToUndoNds(aPam, m_pMovedStart.get(), &nEnd);
1274  m_nMoveLen = nEnd - m_pMovedStart->GetIndex() + 1;
1275 }
1276 
1278  sal_uInt16 nSectType )
1279 {
1280  if( ULONG_MAX == m_nStartPos ) // was there any content?
1281  return;
1282 
1283  // check if the content is at the old position
1284  SwNodeIndex aSttIdx( pDoc->GetNodes(), m_nStartPos );
1285 
1286  // move the content from UndoNodes array into Fly
1287  SwStartNode* pSttNd = SwNodes::MakeEmptySection( aSttIdx,
1288  static_cast<SwStartNodeType>(nSectType) );
1289 
1290  RestoreSection( pDoc, SwNodeIndex( *pSttNd->EndOfSectionNode() ));
1291 
1292  if( pIdx )
1293  *pIdx = *pSttNd;
1294 }
1295 
1297  SwDoc *const pDoc, const SwNodeIndex& rInsPos, bool bForceCreateFrames)
1298 {
1299  if( ULONG_MAX == m_nStartPos ) // was there any content?
1300  return;
1301 
1302  SwPosition aInsPos( rInsPos );
1303  sal_uLong nEnd = m_pMovedStart->GetIndex() + m_nMoveLen - 1;
1304  MoveFromUndoNds(*pDoc, m_pMovedStart->GetIndex(), aInsPos, &nEnd, bForceCreateFrames);
1305 
1306  // destroy indices again, content was deleted from UndoNodes array
1307  m_pMovedStart.reset();
1308  m_nMoveLen = 0;
1309 
1310  if( m_pRedlineSaveData )
1311  {
1313  m_pRedlineSaveData.reset();
1314  }
1315 }
1316 
1318 {
1320 }
1321 
1322 // save and set the RedlineData
1324  SwComparePosition eCmpPos,
1325  const SwPosition& rSttPos,
1326  const SwPosition& rEndPos,
1327  SwRangeRedline& rRedl,
1328  bool bCopyNext )
1329  : SwUndRng( rRedl )
1330  , SwRedlineData( rRedl.GetRedlineData(), bCopyNext )
1331 {
1332  assert( SwComparePosition::Outside == eCmpPos ||
1333  !rRedl.GetContentIdx() ); // "Redline with Content"
1334 
1335  switch (eCmpPos)
1336  {
1337  case SwComparePosition::OverlapBefore: // Pos1 overlaps Pos2 at the beginning
1338  m_nEndNode = rEndPos.nNode.GetIndex();
1339  m_nEndContent = rEndPos.nContent.GetIndex();
1340  break;
1341 
1342  case SwComparePosition::OverlapBehind: // Pos1 overlaps Pos2 at the end
1343  m_nSttNode = rSttPos.nNode.GetIndex();
1344  m_nSttContent = rSttPos.nContent.GetIndex();
1345  break;
1346 
1347  case SwComparePosition::Inside: // Pos1 lays completely in Pos2
1348  m_nSttNode = rSttPos.nNode.GetIndex();
1349  m_nSttContent = rSttPos.nContent.GetIndex();
1350  m_nEndNode = rEndPos.nNode.GetIndex();
1351  m_nEndContent = rEndPos.nContent.GetIndex();
1352  break;
1353 
1354  case SwComparePosition::Outside: // Pos2 lays completely in Pos1
1355  if ( rRedl.GetContentIdx() )
1356  {
1357  // than move section into UndoArray and memorize it
1358  SaveSection( *rRedl.GetContentIdx() );
1359  rRedl.SetContentIdx( nullptr );
1360  }
1361  break;
1362 
1363  case SwComparePosition::Equal: // Pos1 is exactly as big as Pos2
1364  break;
1365 
1366  default:
1367  assert(false);
1368  }
1369 
1370 #if OSL_DEBUG_LEVEL > 0
1372 #endif
1373 }
1374 
1376 {
1377 }
1378 
1380 {
1381  SwDoc& rDoc = rPam.GetDoc();
1382  SwRangeRedline* pRedl = new SwRangeRedline( *this, rPam );
1383 
1384  if( GetMvSttIdx() )
1385  {
1386  SwNodeIndex aIdx( rDoc.GetNodes() );
1387  RestoreSection( &rDoc, &aIdx, SwNormalStartNode );
1388  if( GetHistory() )
1389  GetHistory()->Rollback( &rDoc );
1390  pRedl->SetContentIdx( &aIdx );
1391  }
1392  SetPaM( *pRedl );
1393  // First, delete the "old" so that in an Append no unexpected things will
1394  // happen, e.g. a delete in an insert. In the latter case the just restored
1395  // content will be deleted and not the one you originally wanted.
1396  rDoc.getIDocumentRedlineAccess().DeleteRedline( *pRedl, false, RedlineType::Any );
1397 
1400  //#i92154# let UI know about a new redline with comment
1401  if (rDoc.GetDocShell() && (!pRedl->GetComment().isEmpty()) )
1402  rDoc.GetDocShell()->Broadcast(SwRedlineHint());
1403 
1404  auto const result(rDoc.getIDocumentRedlineAccess().AppendRedline(pRedl, true));
1405  assert(result != IDocumentRedlineAccess::AppendResult::IGNORED); // SwRedlineSaveData::RedlineToDoc: insert redline failed
1406  (void) result; // unused in non-debug
1408 }
1409 
1411  const SwPaM& rRange,
1412  SwRedlineSaveDatas& rSData,
1413  bool bDelRange,
1414  bool bCopyNext )
1415 {
1416  rSData.clear();
1417 
1418  const SwPosition* pStt = rRange.Start();
1419  const SwPosition* pEnd = rRange.End();
1420  const SwRedlineTable& rTable = rRange.GetDoc().getIDocumentRedlineAccess().GetRedlineTable();
1422  rRange.GetDoc().getIDocumentRedlineAccess().GetRedline( *pStt, &n );
1423  for ( ; n < rTable.size(); ++n )
1424  {
1425  SwRangeRedline* pRedl = rTable[n];
1426 
1427  const SwComparePosition eCmpPos =
1428  ComparePosition( *pStt, *pEnd, *pRedl->Start(), *pRedl->End() );
1429  if ( eCmpPos != SwComparePosition::Before
1430  && eCmpPos != SwComparePosition::Behind
1431  && eCmpPos != SwComparePosition::CollideEnd
1432  && eCmpPos != SwComparePosition::CollideStart )
1433  {
1434 
1435  rSData.push_back(std::unique_ptr<SwRedlineSaveData, o3tl::default_delete<SwRedlineSaveData>>(new SwRedlineSaveData(eCmpPos, *pStt, *pEnd, *pRedl, bCopyNext)));
1436  }
1437  }
1438  if( !rSData.empty() && bDelRange )
1439  {
1440  rRange.GetDoc().getIDocumentRedlineAccess().DeleteRedline( rRange, false, RedlineType::Any );
1441  }
1442  return !rSData.empty();
1443 }
1444 
1446  const SwPaM& rRange,
1447  SwRedlineSaveDatas& rSData )
1448 {
1449  rSData.clear();
1450 
1451  const SwPosition *pStt = rRange.Start(), *pEnd = rRange.End();
1452  const SwRedlineTable& rTable = rRange.GetDoc().getIDocumentRedlineAccess().GetRedlineTable();
1454  rRange.GetDoc().getIDocumentRedlineAccess().GetRedline( *pStt, &n );
1455  for ( ; n < rTable.size(); ++n )
1456  {
1457  SwRangeRedline* pRedl = rTable[n];
1458  if ( RedlineType::Format == pRedl->GetType() )
1459  {
1460  const SwComparePosition eCmpPos = ComparePosition( *pStt, *pEnd, *pRedl->Start(), *pRedl->End() );
1461  if ( eCmpPos != SwComparePosition::Before
1462  && eCmpPos != SwComparePosition::Behind
1463  && eCmpPos != SwComparePosition::CollideEnd
1464  && eCmpPos != SwComparePosition::CollideStart )
1465  {
1466  rSData.push_back(std::unique_ptr<SwRedlineSaveData, o3tl::default_delete<SwRedlineSaveData>>(new SwRedlineSaveData(eCmpPos, *pStt, *pEnd, *pRedl, true)));
1467  }
1468 
1469  }
1470  }
1471  return !rSData.empty();
1472 }
1473 
1474 
1476 {
1479  SwPaM aPam( rDoc.GetNodes().GetEndOfContent() );
1480 
1481  for( size_t n = rSData.size(); n; )
1482  rSData[ --n ].RedlineToDoc( aPam );
1483 
1484 #if OSL_DEBUG_LEVEL > 0
1485  // check redline count against count saved in RedlineSaveData object
1486  assert(rSData.empty() ||
1487  (rSData[0].m_nRedlineCount == rDoc.getIDocumentRedlineAccess().GetRedlineTable().size()));
1488  // "redline count not restored properly"
1489 #endif
1490 
1492 }
1493 
1495 {
1496  for( size_t n = rSData.size(); n; )
1497  if( rSData[ --n ].GetMvSttIdx() )
1498  return true;
1499  return false;
1500 }
1501 
1503  const SwRedlineSaveDatas& rCheck, bool bCurrIsEnd )
1504 {
1505  if( rCurr.size() != rCheck.size() )
1506  return false;
1507 
1508  for( size_t n = 0; n < rCurr.size(); ++n )
1509  {
1510  const SwRedlineSaveData& rSet = rCurr[ n ];
1511  const SwRedlineSaveData& rGet = rCheck[ n ];
1512  if( rSet.m_nSttNode != rGet.m_nSttNode ||
1513  rSet.GetMvSttIdx() || rGet.GetMvSttIdx() ||
1514  ( bCurrIsEnd ? rSet.m_nSttContent != rGet.m_nEndContent
1515  : rSet.m_nEndContent != rGet.m_nSttContent ) ||
1516  !rGet.CanCombine( rSet ) )
1517  {
1518  return false;
1519  }
1520  }
1521 
1522  for( size_t n = 0; n < rCurr.size(); ++n )
1523  {
1524  SwRedlineSaveData& rSet = rCurr[ n ];
1525  const SwRedlineSaveData& rGet = rCheck[ n ];
1526  if( bCurrIsEnd )
1527  rSet.m_nSttContent = rGet.m_nSttContent;
1528  else
1529  rSet.m_nEndContent = rGet.m_nEndContent;
1530  }
1531  return true;
1532 }
1533 
1534 OUString ShortenString(const OUString & rStr, sal_Int32 nLength, const OUString & rFillStr)
1535 {
1536  assert(nLength - rFillStr.getLength() >= 2);
1537 
1538  if (rStr.getLength() <= nLength)
1539  return rStr;
1540 
1541  nLength -= rFillStr.getLength();
1542  if ( nLength < 2 )
1543  nLength = 2;
1544 
1545  const sal_Int32 nFrontLen = nLength - nLength / 2;
1546  const sal_Int32 nBackLen = nLength - nFrontLen;
1547 
1548  return rStr.subView(0, nFrontLen)
1549  + rFillStr
1550  + rStr.subView(rStr.getLength() - nBackLen);
1551 }
1552 
1553 static bool IsAtEndOfSection(SwPosition const& rAnchorPos)
1554 {
1555  SwNodeIndex node(*rAnchorPos.nNode.GetNode().EndOfSectionNode());
1556  SwContentNode *const pNode(SwNodes::GoPrevious(&node));
1557  assert(pNode);
1558  assert(rAnchorPos.nNode <= node); // last valid anchor pos is last content
1559  return node == rAnchorPos.nNode
1560  // at-para fly has no SwIndex!
1561  && (rAnchorPos.nContent == pNode->Len() || rAnchorPos.nContent.GetIdxReg() == nullptr);
1562 }
1563 
1564 static bool IsAtStartOfSection(SwPosition const& rAnchorPos)
1565 {
1566  SwNodes const& rNodes(rAnchorPos.nNode.GetNodes());
1567  SwNodeIndex node(*rAnchorPos.nNode.GetNode().StartOfSectionNode());
1568  SwContentNode *const pNode(rNodes.GoNext(&node));
1569  assert(pNode);
1570  (void) pNode;
1571  assert(node <= rAnchorPos.nNode);
1572  return node == rAnchorPos.nNode && rAnchorPos.nContent == 0;
1573 }
1574 
1576 static bool IsAtEndOfSection2(SwPosition const& rPos)
1577 {
1578  return rPos.nNode.GetNode().IsEndNode()
1579  || IsAtEndOfSection(rPos);
1580 }
1581 
1582 static bool IsAtStartOfSection2(SwPosition const& rPos)
1583 {
1584  return rPos.nNode.GetNode().IsStartNode()
1585  || IsAtStartOfSection(rPos);
1586 }
1587 
1589  SwPosition const& rStart, SwPosition const& rEnd)
1590 {
1591  // check if the selection is backspace/delete created by DelLeft/DelRight
1592  if (rStart.nNode.GetIndex() + 1 != rEnd.nNode.GetIndex())
1593  return true;
1594  if (rEnd.nContent != 0)
1595  return true;
1596  const SwTextNode* pTextNode = rStart.nNode.GetNode().GetTextNode();
1597  if (!pTextNode || rStart.nContent != pTextNode->Len())
1598  return true;
1599  return false;
1600 }
1601 
1603  SwPosition const & rStart, SwPosition const & rEnd,
1604  DelContentType const nDelContentType)
1605 {
1606  assert(rStart <= rEnd);
1607 
1608  // CheckNoCntnt means DelFullPara which is obvious to handle
1609  if (DelContentType::CheckNoCntnt & nDelContentType)
1610  { // exclude selection end node because it won't be deleted
1611  return (rAnchorPos.nNode < rEnd.nNode)
1612  && (rStart.nNode <= rAnchorPos.nNode);
1613  }
1614 
1615  if ((nDelContentType & DelContentType::WriterfilterHack)
1616  && rAnchorPos.GetDoc().IsInWriterfilterImport())
1617  { // FIXME hack for writerfilter RemoveLastParagraph() and MakeFlyAndMove(); can't test file format more specific?
1618  return (rStart < rAnchorPos) && (rAnchorPos < rEnd);
1619  }
1620 
1621  if (nDelContentType & DelContentType::ExcludeFlyAtStartEnd)
1622  { // exclude selection start and end node
1623  return (rAnchorPos.nNode < rEnd.nNode)
1624  && (rStart.nNode < rAnchorPos.nNode);
1625  }
1626 
1627  // in general, exclude the start and end position
1628  return ((rStart < rAnchorPos)
1629  || (rStart == rAnchorPos
1630  // special case: fully deleted node
1631  && ((rStart.nNode != rEnd.nNode && rStart.nContent == 0
1632  // but not if the selection is backspace/delete!
1633  && IsNotBackspaceHeuristic(rStart, rEnd))
1634  || (IsAtStartOfSection(rAnchorPos) && IsAtEndOfSection2(rEnd)))))
1635  && ((rAnchorPos < rEnd)
1636  || (rAnchorPos == rEnd
1637  // special case: fully deleted node
1638  && ((rEnd.nNode != rStart.nNode && rEnd.nContent == rEnd.nNode.GetNode().GetTextNode()->Len()
1639  && IsNotBackspaceHeuristic(rStart, rEnd))
1640  || (IsAtEndOfSection(rAnchorPos) && IsAtStartOfSection2(rStart)))));
1641 }
1642 
1643 bool IsSelectFrameAnchoredAtPara(SwPosition const & rAnchorPos,
1644  SwPosition const & rStart, SwPosition const & rEnd,
1645  DelContentType const nDelContentType)
1646 {
1647  assert(rStart <= rEnd);
1648 
1649  // CheckNoCntnt means DelFullPara which is obvious to handle
1650  if (DelContentType::CheckNoCntnt & nDelContentType)
1651  { // exclude selection end node because it won't be deleted
1652  return (rAnchorPos.nNode < rEnd.nNode)
1653  && (rStart.nNode <= rAnchorPos.nNode);
1654  }
1655 
1656  if ((nDelContentType & DelContentType::WriterfilterHack)
1657  && rAnchorPos.GetDoc().IsInWriterfilterImport())
1658  { // FIXME hack for writerfilter RemoveLastParagraph() and MakeFlyAndMove(); can't test file format more specific?
1659  // but it MUST NOT be done during the SetRedlineFlags at the end of ODF
1660  // import, where the IsInXMLImport() cannot be checked because the
1661  // stupid code temp. overrides it - instead rely on setting the ALLFLYS
1662  // flag in MoveFromSection() and converting that to CheckNoCntnt with
1663  // adjusted cursor!
1664  return (rStart.nNode < rAnchorPos.nNode) && (rAnchorPos.nNode < rEnd.nNode);
1665  }
1666 
1667  // in general, exclude the start and end position
1668  return ((rStart.nNode < rAnchorPos.nNode)
1669  || (rStart.nNode == rAnchorPos.nNode
1670  && !(nDelContentType & DelContentType::ExcludeFlyAtStartEnd)
1671  // special case: fully deleted node
1672  && ((rStart.nNode != rEnd.nNode && rStart.nContent == 0
1673  // but not if the selection is backspace/delete!
1674  && IsNotBackspaceHeuristic(rStart, rEnd))
1675  || (IsAtStartOfSection2(rStart) && IsAtEndOfSection2(rEnd)))))
1676  && ((rAnchorPos.nNode < rEnd.nNode)
1677  || (rAnchorPos.nNode == rEnd.nNode
1678  && !(nDelContentType & DelContentType::ExcludeFlyAtStartEnd)
1679  // special case: fully deleted node
1680  && ((rEnd.nNode != rStart.nNode && rEnd.nContent == rEnd.nNode.GetNode().GetTextNode()->Len()
1681  && IsNotBackspaceHeuristic(rStart, rEnd))
1682  || (IsAtEndOfSection2(rEnd) && IsAtStartOfSection2(rStart)))));
1683 }
1684 
1685 bool IsFlySelectedByCursor(SwDoc const & rDoc,
1686  SwPosition const & rStart, SwPosition const & rEnd)
1687 {
1688  for (SwFrameFormat const*const pFly : *rDoc.GetSpzFrameFormats())
1689  {
1690  SwFormatAnchor const& rAnchor(pFly->GetAnchor());
1691  switch (rAnchor.GetAnchorId())
1692  {
1693  case RndStdIds::FLY_AT_CHAR:
1694  case RndStdIds::FLY_AT_PARA:
1695  {
1696  SwPosition const*const pAnchorPos(rAnchor.GetContentAnchor());
1697  // can this really be null?
1698  if (pAnchorPos != nullptr
1699  && ((rAnchor.GetAnchorId() == RndStdIds::FLY_AT_CHAR)
1700  ? IsDestroyFrameAnchoredAtChar(*pAnchorPos, rStart, rEnd)
1701  : IsSelectFrameAnchoredAtPara(*pAnchorPos, rStart, rEnd)))
1702  {
1703  return true;
1704  }
1705  }
1706  break;
1707  default: // other types not relevant
1708  break;
1709  }
1710  }
1711  return false;
1712 }
1713 
1714 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static bool IsAtEndOfSection(SwPosition const &rAnchorPos)
Definition: undobj.cxx:1553
const SwEndNode * EndOfSectionNode() const
Definition: node.hxx:683
Starts a section of nodes in the document model.
Definition: node.hxx:312
virtual SwCursor & CreateNewShellCursor()=0
SwPaM & AddUndoRedoPaM(::sw::UndoRedoContext &, bool const bCorrToContent=false) const
Definition: undobj.cxx:110
virtual sal_Int32 Len() const
Definition: node.cxx:1246
void DeleteMark()
Definition: pam.hxx:177
sal_uLong m_nStartPos
Definition: undobj.hxx:205
sal_uLong GetIndex() const
Definition: node.hxx:291
SwNode & GetNode(bool bPoint=true) const
Definition: pam.hxx:223
bool GoInContent(SwPaM &rPam, SwMoveFnCollection const &fnMove)
Definition: pam.cxx:970
std::unique_ptr< SwRedlineSaveDatas > m_pRedlineSaveData
Definition: undobj.hxx:203
Marks a position in the document model.
Definition: pam.hxx:35
std::unique_ptr< SwHistory > m_pHistory
Definition: undobj.hxx:166
SwNodes const & GetUndoNodes() const
Definition: docundo.cxx:74
void SetContentIdx(const SwNodeIndex *)
Definition: docredln.cxx:1766
SwComparePosition ComparePosition(const T &rStt1, const T &rEnd1, const T &rStt2, const T &rEnd2)
Definition: pam.hxx:77
static bool IsAtStartOfSection(SwPosition const &rAnchorPos)
Definition: undobj.cxx:1564
SwUndoId
Definition: swundo.hxx:29
SwDocShell * GetDocShell()
Definition: doc.hxx:1352
virtual AppendResult AppendRedline(SwRangeRedline *pNewRedl, bool bCallDelete)=0
Append a new redline.
size_t size() const
Definition: UndoCore.hxx:77
bool Rollback(SwDoc *pDoc, sal_uInt16 nStart=0)
Definition: rolbck.cxx:1209
virtual void SetRedlineFlags_intern(RedlineFlags eMode)=0
Set a new redline mode.
static bool FillSaveDataForFormat(const SwPaM &, SwRedlineSaveDatas &)
Definition: undobj.cxx:1445
SwNodeIndex nNode
Definition: pam.hxx:37
virtual void Repeat(SfxRepeatTarget &) override
Definition: undobj.cxx:249
virtual sal_Int32 Len() const override
Definition: ndtxt.cxx:278
sal_uIntPtr sal_uLong
Pos1 is as large as Pos2.
static SW_DLLPUBLIC MarkType GetType(const ::sw::mark::IMark &rMark)
Returns the MarkType used to create the mark.
Definition: docbm.cxx:478
const SwPosition * GetMark() const
Definition: pam.hxx:209
sal_uLong m_nEndNode
Definition: undobj.hxx:230
Pos1 completely contained in Pos2.
sal_Int64 n
static ViewShellId CreateViewShellId(const SwDoc *pDoc)
Try to obtain the view shell ID of the current view.
Definition: undobj.cxx:171
Provides access to the marks of a document.
Definition: doc.hxx:188
virtual ~SwUndoSaveContent() COVERITY_NOEXCEPT_FALSE
Definition: undobj.cxx:708
SwRedlineSaveData(SwComparePosition eCmpPos, const SwPosition &rSttPos, const SwPosition &rEndPos, SwRangeRedline &rRedl, bool bCopyNext)
Definition: undobj.cxx:1323
static SwContentNode * GoPrevious(SwNodeIndex *)
Definition: nodes.cxx:1310
static bool IsAtStartOfSection2(SwPosition const &rPos)
Definition: undobj.cxx:1582
SwNode & GetNode() const
Definition: ndindex.hxx:119
bool IsSelectFrameAnchoredAtPara(SwPosition const &rAnchorPos, SwPosition const &rStart, SwPosition const &rEnd, DelContentType const nDelContentType)
is a fly anchored at paragraph at rAnchorPos selected?
Definition: undobj.cxx:1643
const SwHistory * GetHistory() const
Definition: undobj.hxx:220
IDocumentMarkAccess * getIDocumentMarkAccess()
Definition: docbm.cxx:1790
IDocumentUndoRedo & GetIDocumentUndoRedo()
Definition: doc.cxx:144
SwNode & GetEndOfPostIts() const
A still empty section.
Definition: ndarr.hxx:149
static void RemoveIdxFromSection(SwDoc &, sal_uLong nSttIdx, const sal_uLong *pEndIdx=nullptr)
Definition: undobj.cxx:118
bool IsDestroyFrameAnchoredAtChar(SwPosition const &rAnchorPos, SwPosition const &rStart, SwPosition const &rEnd, DelContentType const nDelContentType)
will DelContentIndex destroy a frame anchored at character at rAnchorPos?
Definition: undobj.cxx:1602
virtual void RepeatImpl(::sw::RepeatContext &)
Definition: undobj.cxx:269
SwUndoId GetId() const
Definition: undobj.hxx:101
bool CanCombine(const SwRedlineData &rCmp) const
Definition: docredln.cxx:968
const SwFrameFormats * GetSpzFrameFormats() const
Definition: doc.hxx:744
IShellCursorSupplier & GetCursorSupplier()
Definition: UndoCore.hxx:97
SwUndRng()
Definition: undobj.cxx:50
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: undobj.cxx:712
size_type size() const
Definition: docary.hxx:265
void push_back(std::unique_ptr< SwRedlineSaveData, o3tl::default_delete< SwRedlineSaveData >> pNew)
Definition: UndoCore.hxx:78
SwContentNode * GetContentNode(bool bPoint=true) const
Definition: pam.hxx:229
void SetValues(const SwPaM &rPam)
Definition: undobj.cxx:60
SwTextAttr * GetTextAttrForCharAt(const sal_Int32 nIndex, const sal_uInt16 nWhich=RES_TXTATR_END) const
get the text attribute at position nIndex which owns the dummy character CH_TXTATR_* at that position...
Definition: ndtxt.cxx:3012
OUString SwResId(TranslateId aId)
Definition: swmodule.cxx:165
Pos1 end touches at Pos2 start.
sal_uLong m_nMoveLen
Definition: undobj.hxx:204
void Delete(const SwNodeIndex &rPos, sal_uLong nNodes=1)
delete nodes
Definition: nodes.cxx:1078
sal_uInt16 m_nRedlineCount
Definition: UndoCore.hxx:64
SwNodeIndex * GetMvSttIdx() const
Definition: UndoCore.hxx:58
SwIndex nContent
Definition: pam.hxx:38
SwNodeIndex aStart
Definition: ndindex.hxx:132
A wrapper around SfxPoolItem to store the start position of (usually) a text portion, with an optional end.
Definition: txatbase.hxx:41
sal_uLong GetIndex() const
Definition: ndindex.hxx:152
sal_Int32 GetStart() const
Definition: txatbase.hxx:86
virtual SwRewriter GetRewriter() const
Returns the rewriter for this object.
Definition: undobj.cxx:698
bool IsStartNode() const
Definition: node.hxx:625
Pos2 completely contained in Pos1.
static bool CanRedlineGroup(SwRedlineSaveDatas &rCurr, const SwRedlineSaveDatas &rCheck, bool bCurrIsEnd)
Definition: undobj.cxx:1502
#define suppress_fun_call_w_exception(expr)
bool empty() const
Pos1 before Pos2.
RedlineFlags on.
static void MoveToUndoNds(SwPaM &rPam, SwNodeIndex *pNodeIdx, sal_uLong *pEndNdIdx=nullptr)
Definition: undobj.cxx:733
size_type size() const
static void RemoveIdxFromRange(SwPaM &rPam, bool bMoveNext)
Definition: undobj.cxx:128
virtual bool CanRepeat(SfxRepeatTarget &) const override
Definition: undobj.cxx:261
RedlineFlags GetRedlineFlags() const
Definition: undobj.hxx:119
Specific frame formats (frames, DrawObjects).
SwNode & GetEndOfContent() const
Regular ContentSection (i.e. the BodyText).
Definition: ndarr.hxx:160
virtual std::unique_ptr< ILazyDeleter > deleteMark(const IDocumentMarkAccess::const_iterator_t &ppMark)=0
Deletes a mark.
virtual const_iterator_t getAllMarksBegin() const =0
returns a STL-like random access iterator to the begin of the sequence of marks.
bool IsContentNode() const
Definition: node.hxx:629
static void MovePtForward(SwPaM &rPam, bool bMvBkwrd)
Definition: undobj.cxx:842
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
struct _xmlTextWriter * xmlTextWriterPtr
virtual void UndoImpl(::sw::UndoRedoContext &)=0
bool Move(SwMoveFnCollection const &fnMove=fnMoveForward, SwGoInDoc fnGo=GoInContent)
Movement of cursor.
Definition: pam.cxx:504
static bool IsNotBackspaceHeuristic(SwPosition const &rStart, SwPosition const &rEnd)
Definition: undobj.cxx:1588
SwTextFootnote * SeekEntry(const SwNodeIndex &rIdx, size_t *pPos=nullptr) const
Definition: ftnidx.cxx:409
Style of a layout element.
Definition: frmfmt.hxx:59
::sw::UndoManager & GetUndoManager()
Definition: doc.cxx:133
static bool HasHiddenRedlines(const SwRedlineSaveDatas &rSData)
Definition: undobj.cxx:1494
const SwFormatAnchor & GetAnchor(bool=true) const
Definition: fmtanchr.hxx:81
const SwStartNode * StartOfSectionNode() const
Definition: node.hxx:132
SwDoc & GetDoc()
Definition: node.hxx:212
const SwPosition * GetPoint() const
Definition: pam.hxx:207
Pos1 start touches at Pos2 end.
virtual void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: undobj.cxx:1317
void DelContentIndex(const SwPosition &pMark, const SwPosition &pPoint, DelContentType nDelContentType=DelContentType::AllMask)
Definition: undobj.cxx:867
SwIndex & Assign(SwIndexReg *, sal_Int32)
Definition: index.cxx:206
RndStdIds GetAnchorId() const
Definition: fmtanchr.hxx:65
OUString Apply(const OUString &rStr) const
Definition: SwRewriter.cxx:39
const SwPosition * GetContentAnchor() const
Definition: fmtanchr.hxx:67
OUString ShortenString(const OUString &rStr, sal_Int32 nLength, const OUString &rFillStr)
Shortens a string to a maximum length.
Definition: undobj.cxx:1534
static void SetSaveData(SwDoc &rDoc, SwRedlineSaveDatas &rSData)
Definition: undobj.cxx:1475
void Exchange()
Definition: pam.cxx:492
virtual bool DeleteRedline(const SwPaM &rPam, bool bSaveInUndo, RedlineType nDelType)=0
SwContentNode * GetContentNode()
Definition: node.hxx:616
vector_type::size_type size_type
Definition: docary.hxx:223
FlyAnchors.
Definition: fmtanchr.hxx:34
void MakeStartIndex(SwIndex *pIdx)
Definition: node.hxx:398
bool HasMark() const
A PaM marks a selection if Point and Mark are distinct positions.
Definition: pam.hxx:205
SwNoTextNode * GetNoTextNode()
Definition: ndnotxt.hxx:96
ViewShellId m_nViewShellId
Definition: undobj.hxx:57
sal_Int32 m_nEndContent
Definition: undobj.hxx:231
virtual void UndoWithContext(SfxUndoContext &) override
Definition: undobj.cxx:231
Marks a character position inside a document model node.
Definition: index.hxx:33
void PaMCorrRel(const SwNodeIndex &rOldNode, const SwPosition &rNewPos, const sal_Int32 nOffset)
Sets all PaMs in OldNode to relative Pos.
Definition: doccorr.cxx:241
std::optional< OUString > maComment
Definition: undobj.hxx:62
Marks a node in the document model.
Definition: ndindex.hxx:31
bool m_bCacheComment
Definition: undobj.hxx:61
bool IsEndNode() const
Definition: node.hxx:633
SwNodes & GetNodes()
Node is in which nodes-array/doc?
Definition: node.hxx:694
static bool MovePtBackward(SwPaM &rPam)
Definition: undobj.cxx:829
bool empty() const
virtual OUString GetComment() const override
Returns textual comment for this undo object.
Definition: undobj.cxx:664
std::unique_ptr< SwNodeIndex > m_pMovedStart
Definition: undobj.hxx:202
const SwPosition * Start() const
Definition: pam.hxx:212
void RedlineToDoc(SwPaM const &rPam)
Definition: undobj.cxx:1379
virtual const SwRangeRedline * GetRedline(const SwPosition &rPos, SwRedlineTable::size_type *pFndPos) const =0
sal_uLong m_nSttNode
Definition: undobj.hxx:230
virtual bool SetFormatAttr(const SfxPoolItem &rAttr)
Definition: format.cxx:450
const OUString & GetComment(sal_uInt16 nPos=0) const
Definition: docredln.cxx:1845
ignore Redlines
void EraseText(const SwIndex &rIdx, const sal_Int32 nCount=SAL_MAX_INT32, const SwInsertFlags nMode=SwInsertFlags::DEFAULT)
delete text content ATTENTION: must not be called with a range that overlaps the start of an attribut...
Definition: ndtxt.cxx:2632
SwTextNode is a paragraph in the document model.
Definition: ndtxt.hxx:79
void RestoreSection(SwDoc *pDoc, SwNodeIndex *pIdx, sal_uInt16 nSectType)
Definition: undobj.cxx:1277
IDocumentRedlineAccess const & getIDocumentRedlineAccess() const
Definition: doc.cxx:335
void SetPaM(SwPaM &, bool bCorrToContent=false) const
Definition: undobj.cxx:82
static void MoveFromUndoNds(SwDoc &rDoc, sal_uLong nNodeIdx, SwPosition &rInsPos, const sal_uLong *pEndNdIdx=nullptr, bool bForceCreateFrames=false)
Definition: undobj.cxx:770
DelContentType
Definition: undobj.hxx:133
virtual sal_Int32 getAllMarksCount() const =0
returns the number of marks.
void CorrAbs(const SwNodeIndex &rOldNode, const SwPosition &rNewPos, const sal_Int32 nOffset=0, bool bMoveCursor=false)
Definition: doccorr.cxx:168
Pos1 overlaps Pos2 at the end.
const SwNodes & GetNodes() const
Definition: ndindex.hxx:156
virtual ~SwUndo() override
Definition: undobj.cxx:190
SwMoveFnCollection const & fnMoveForward
SwPam::Move()/Find() default argument.
Definition: paminit.cxx:59
#define SAL_INFO(area, stream)
sal_Int32 GetIndex() const
Definition: index.hxx:91
SwNodes & GetNodes()
Definition: doc.hxx:409
SwUndo(SwUndoId const nId, const SwDoc *pDoc)
Definition: undobj.cxx:163
const SwPosition * End() const
Definition: pam.hxx:217
SwNodeIndex aEnd
Definition: ndindex.hxx:133
SwDoc & GetDoc() const
Returns the document this position is in.
Definition: pam.cxx:181
bool m_isRepeatIgnored
for multi-selection, only repeat 1st selection
Definition: undobj.hxx:58
RedlineType GetType(sal_uInt16 nPos=0) const
Definition: docredln.cxx:1840
virtual void Redo() override
Definition: undobj.cxx:226
virtual void RedoWithContext(SfxUndoContext &) override
Definition: undobj.cxx:240
static void RemoveIdxRel(sal_uLong, const SwPosition &)
Definition: undobj.cxx:155
bool empty() const
Definition: UndoCore.hxx:76
SwMoveFnCollection const & fnMoveBackward
Definition: paminit.cxx:58
constexpr sal_Int32 COMPLETE_STRING
Definition: swtypes.hxx:58
friend class SwRangeRedline
Definition: redline.hxx:88
virtual void RedoImpl(::sw::UndoRedoContext &)=0
OUString GetUndoComment(SwUndoId eId)
Definition: undobj.cxx:273
virtual void Undo() override
Definition: undobj.cxx:221
Any result
SwFootnoteIdxs & GetFootnoteIdxs()
Definition: doc.hxx:634
ResultType type
virtual RedlineFlags GetRedlineFlags() const =0
Query the currently set redline mode.
size_t size() const
SwDoc & GetDoc() const
Definition: pam.hxx:243
bool IsFlySelectedByCursor(SwDoc const &rDoc, SwPosition const &rStart, SwPosition const &rEnd)
check at-char and at-para flys in rDoc
Definition: undobj.cxx:1685
virtual void SetMark()
Unless this is called, the getter method of Mark will return Point.
Definition: pam.cxx:478
Pos1 behind Pos2.
static bool FillSaveData(const SwPaM &rRange, SwRedlineSaveDatas &rSData, bool bDelRange=true, bool bCopyNext=true)
Definition: undobj.cxx:1410
virtual const SwRedlineTable & GetRedlineTable() const =0
ViewShellId GetViewShellId() const override
See SfxUndoAction::GetViewShellId().
Definition: undobj.cxx:693
const SwIndexReg * GetIdxReg() const
Definition: index.hxx:97
SwNode & GetEndOfExtras() const
This is the last EndNode of a special section.
Definition: ndarr.hxx:158
bool IsTextNode() const
Definition: node.hxx:637
void SaveSection(const SwNodeIndex &rSttIdx)
Definition: undobj.cxx:1224
SwNodeIndex * GetContentIdx() const
Definition: redline.hxx:183
bool IsDelBox() const
Definition: undobj.cxx:184
Pos1 overlaps Pos2 at the beginning.
sal_Int32 m_nSttContent
Definition: undobj.hxx:231
Definition: view.hxx:144
sal_uInt16 nPos
bool IsInWriterfilterImport() const
Definition: doc.hxx:972
SwComparePosition
Definition: pam.hxx:64
SwTextNode * GetTextNode()
Inline methods from Node.hxx.
Definition: ndtxt.hxx:856
static bool IsAtEndOfSection2(SwPosition const &rPos)
passed start / end position could be on section start / end node
Definition: undobj.cxx:1576
void SetAnchor(const SwPosition *pPos)
Definition: atrfrm.cxx:1584
bool MoveNodes(const SwNodeRange &, SwNodes &rNodes, const SwNodeIndex &, bool bNewFrames=true)
move the node pointer
Definition: nodes.cxx:400
static SwStartNode * MakeEmptySection(const SwNodeIndex &rIdx, SwStartNodeType=SwNormalStartNode)
Create an empty section of Start- and EndNote.
Definition: nodes.cxx:1885
Base class of the Writer document model elements.
Definition: node.hxx:80
void MoveRange(SwPaM &, SwPosition &, SwNodes &rNodes)
move a range
Definition: nodes.cxx:1432
typedef void(CALLTYPE *GetFuncDataPtr)(sal_uInt16 &nNo