LibreOffice Module sw (master)  1
docundo.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 <UndoManager.hxx>
21 
22 #include <svx/svdmodel.hxx>
23 #include <swmodule.hxx>
24 #include <doc.hxx>
25 #include <docsh.hxx>
26 #include <view.hxx>
27 #include <drawdoc.hxx>
28 #include <ndarr.hxx>
29 #include <pam.hxx>
30 #include <ndtxt.hxx>
31 #include <swundo.hxx>
32 #include <UndoCore.hxx>
33 #include <rolbck.hxx>
34 #include <editsh.hxx>
35 #include <unobaseclass.hxx>
36 #include <limits>
39 #include <IDocumentState.hxx>
40 #include <comphelper/lok.hxx>
41 #include <assert.h>
42 
43 #include <sfx2/viewfrm.hxx>
44 #include <sfx2/bindings.hxx>
45 
46 using namespace ::com::sun::star;
47 
48 // the undo array should never grow beyond this limit:
49 #define UNDO_ACTION_LIMIT (USHRT_MAX - 1000)
50 
51 namespace sw {
52 
53 UndoManager::UndoManager(std::shared_ptr<SwNodes> const & xUndoNodes,
54  IDocumentDrawModelAccess & rDrawModelAccess,
55  IDocumentRedlineAccess & rRedlineAccess,
56  IDocumentState & rState)
57  : m_rDrawModelAccess(rDrawModelAccess)
58  , m_rRedlineAccess(rRedlineAccess)
59  , m_rState(rState)
60  , m_xUndoNodes(xUndoNodes)
61  , m_bGroupUndo(true)
62  , m_bDrawUndo(true)
63  , m_bRepair(false)
64  , m_bLockUndoNoModifiedPosition(false)
65  , m_isAddWithIgnoreRepeat(false)
66  , m_UndoSaveMark(MARK_INVALID)
67  , m_pDocShell(nullptr)
68  , m_pView(nullptr)
69 {
70  assert(m_xUndoNodes.get());
71  // writer expects it to be disabled initially
72  // Undo is enabled by SwEditShell constructor
73  SdrUndoManager::EnableUndo(false);
74 }
75 
77 {
78  return *m_xUndoNodes;
79 }
80 
82 {
83  return *m_xUndoNodes;
84 }
85 
86 bool UndoManager::IsUndoNodes(SwNodes const& rNodes) const
87 {
88  return & rNodes == m_xUndoNodes.get();
89 }
90 
92 {
93  m_pDocShell = pDocShell;
94 }
95 
97 {
98  m_pView = pView;
99 }
100 
101 size_t UndoManager::GetUndoActionCount(const bool bCurrentLevel) const
102 {
103  size_t nRet = SdrUndoManager::GetUndoActionCount(bCurrentLevel);
105  return nRet;
106 
107  if (!nRet || !SdrUndoManager::GetUndoActionCount())
108  return nRet;
109 
110  const SfxUndoAction* pAction = SdrUndoManager::GetUndoAction();
111  if (!pAction)
112  return nRet;
113 
114  if (!m_bRepair)
115  {
116  // If another view created the last undo action, prevent undoing it from this view.
117  ViewShellId nViewShellId = m_pView->GetViewShellId();
118  if (pAction->GetViewShellId() != nViewShellId)
119  nRet = 0;
120  }
121 
122  return nRet;
123 }
124 
125 size_t UndoManager::GetRedoActionCount(const bool bCurrentLevel) const
126 {
127  size_t nRet = SdrUndoManager::GetRedoActionCount(bCurrentLevel);
129  return nRet;
130 
131  if (!nRet || !SdrUndoManager::GetRedoActionCount())
132  return nRet;
133 
134  const SfxUndoAction* pAction = SdrUndoManager::GetRedoAction();
135  if (!pAction)
136  return nRet;
137 
138  if (!m_bRepair)
139  {
140  // If another view created the first redo action, prevent redoing it from this view.
141  ViewShellId nViewShellId = m_pView->GetViewShellId();
142  if (pAction->GetViewShellId() != nViewShellId)
143  nRet = 0;
144  }
145 
146  return nRet;
147 }
148 
149 void UndoManager::DoUndo(bool const bDoUndo)
150 {
151  if(!isTextEditActive())
152  {
153  EnableUndo(bDoUndo);
154 
155  SwDrawModel*const pSdrModel = m_rDrawModelAccess.GetDrawModel();
156  if( pSdrModel )
157  {
158  pSdrModel->EnableUndo(bDoUndo);
159  }
160  }
161 }
162 
164 {
165  if(isTextEditActive())
166  {
167  return false;
168  }
169  else
170  {
171  return IsUndoEnabled();
172  }
173 }
174 
175 void UndoManager::DoGroupUndo(bool const bDoUndo)
176 {
177  m_bGroupUndo = bDoUndo;
178 }
179 
181 {
182  return m_bGroupUndo;
183 }
184 
185 void UndoManager::DoDrawUndo(bool const bDoUndo)
186 {
187  m_bDrawUndo = bDoUndo;
188 }
189 
191 {
192  return m_bDrawUndo;
193 }
194 
195 void UndoManager::DoRepair(bool bRepair)
196 {
197  m_bRepair = bRepair;
198 }
199 
201 {
202  return m_bRepair;
203 }
204 
206 {
207  return MARK_INVALID == m_UndoSaveMark;
208 }
209 
211 {
213  {
214  RemoveMark(m_UndoSaveMark);
216  }
217 }
218 
220 {
222  {
223  m_UndoSaveMark = MarkTopUndoAction();
224  }
225 }
226 
228 {
230 }
231 
233 {
235 }
236 
238 {
239  if (!SdrUndoManager::GetUndoActionCount())
240  {
241  return nullptr;
242  }
243  SfxUndoAction *const pAction( SdrUndoManager::GetUndoAction() );
244  return dynamic_cast<SwUndo*>(pAction);
245 }
246 
247 void UndoManager::AppendUndo(std::unique_ptr<SwUndo> pUndo)
248 {
249  AddUndoAction(std::move(pUndo));
250 }
251 
253 {
254  return SdrUndoManager::ImplClearRedo_NoLock(TopLevel);
255 }
256 
258 {
259  ::sw::UndoGuard const undoGuard(*this);
260 
261  SdrUndoManager::ClearAllLevels();
262 
264 }
265 
266 SwUndoId
268  SwRewriter const*const pRewriter)
269 {
270  if (!IsUndoEnabled())
271  {
272  return SwUndoId::EMPTY;
273  }
274 
275  SwUndoId const eUndoId( (i_eUndoId == SwUndoId::EMPTY) ? SwUndoId::START : i_eUndoId );
276 
277  assert(SwUndoId::END != eUndoId);
278  OUString comment( (SwUndoId::START == eUndoId)
279  ? OUString("??")
280  : GetUndoComment(eUndoId) );
281  if (pRewriter)
282  {
283  assert(SwUndoId::START != eUndoId);
284  comment = pRewriter->Apply(comment);
285  }
286 
287  ViewShellId nViewShellId(-1);
288  if (m_pDocShell)
289  {
290  if (const SwView* pView = m_pDocShell->GetView())
291  nViewShellId = pView->GetViewShellId();
292  }
293  SdrUndoManager::EnterListAction(comment, comment, static_cast<sal_uInt16>(eUndoId), nViewShellId);
294 
295  return eUndoId;
296 }
297 
298 SwUndoId
299 UndoManager::EndUndo(SwUndoId eUndoId, SwRewriter const*const pRewriter)
300 {
301  if (!IsUndoEnabled())
302  {
303  return SwUndoId::EMPTY;
304  }
305 
306  if ((eUndoId == SwUndoId::EMPTY) || (SwUndoId::START == eUndoId))
307  eUndoId = SwUndoId::END;
308  OSL_ENSURE(!((SwUndoId::END == eUndoId) && pRewriter),
309  "EndUndo(): no Undo ID, but rewriter given?");
310 
311  SfxUndoAction *const pLastUndo(
312  (0 == SdrUndoManager::GetUndoActionCount())
313  ? nullptr : SdrUndoManager::GetUndoAction() );
314 
315  int const nCount = LeaveListAction();
316 
317  if (nCount) // otherwise: empty list action not inserted!
318  {
319  assert(pLastUndo);
320  assert(SwUndoId::START != eUndoId);
321  auto pListAction = dynamic_cast<SfxListUndoAction*>(SdrUndoManager::GetUndoAction());
322  assert(pListAction);
323  if (SwUndoId::END != eUndoId)
324  {
325  OSL_ENSURE(static_cast<SwUndoId>(pListAction->GetId()) == eUndoId,
326  "EndUndo(): given ID different from StartUndo()");
327  // comment set by caller of EndUndo
328  OUString comment = GetUndoComment(eUndoId);
329  if (pRewriter)
330  {
331  comment = pRewriter->Apply(comment);
332  }
333  pListAction->SetComment(comment);
334  }
335  else if (SwUndoId::START != static_cast<SwUndoId>(pListAction->GetId()))
336  {
337  // comment set by caller of StartUndo: nothing to do here
338  }
339  else if (pLastUndo)
340  {
341  // comment was not set at StartUndo or EndUndo:
342  // take comment of last contained action
343  // (note that this works recursively, i.e. the last contained
344  // action may be a list action created by StartUndo/EndUndo)
345  OUString const comment(pLastUndo->GetComment());
346  pListAction->SetComment(comment);
347  }
348  else
349  {
350  OSL_ENSURE(false, "EndUndo(): no comment?");
351  }
352  }
353 
354  return eUndoId;
355 }
356 
357 bool
359  OUString *const o_pStr, SwUndoId *const o_pId, const SwView* pView) const
360 {
361  // this is actually expected to work on the current level,
362  // but that was really not obvious from the previous implementation...
363  if (!SdrUndoManager::GetUndoActionCount())
364  {
365  return false;
366  }
367 
368  SfxUndoAction *const pAction( SdrUndoManager::GetUndoAction() );
369 
371  {
372  // If another view created the undo action, prevent undoing it from this view.
373  ViewShellId nViewShellId = pView ? pView->GetViewShellId() : m_pDocShell->GetView()->GetViewShellId();
374  if (pAction->GetViewShellId() != nViewShellId)
375  {
376  if (o_pId)
377  {
378  *o_pId = SwUndoId::CONFLICT;
379  }
380  return false;
381  }
382  }
383 
384  if (o_pStr)
385  {
386  *o_pStr = pAction->GetComment();
387  }
388  if (o_pId)
389  {
390  if (auto pListAction = dynamic_cast<const SfxListUndoAction*>(pAction))
391  *o_pId = static_cast<SwUndoId>(pListAction->GetId());
392  else if (auto pSwAction = dynamic_cast<const SwUndo*>(pAction))
393  *o_pId = pSwAction->GetId();
394  else
395  *o_pId = SwUndoId::EMPTY;
396  }
397 
398  return true;
399 }
400 
402 {
403  OSL_ENSURE(!SdrUndoManager::IsInListAction(),
404  "GetUndoComments() called while in list action?");
405 
406  SwUndoComments_t ret;
407  const size_t nUndoCount(SdrUndoManager::GetUndoActionCount(TopLevel));
408  for (size_t n = 0; n < nUndoCount; ++n)
409  {
410  OUString const comment(
411  SdrUndoManager::GetUndoActionComment(n, TopLevel));
412  ret.push_back(comment);
413  }
414 
415  return ret;
416 }
417 
418 bool UndoManager::GetFirstRedoInfo(OUString *const o_pStr,
419  SwUndoId *const o_pId,
420  const SwView* pView) const
421 {
422  if (!SdrUndoManager::GetRedoActionCount())
423  {
424  return false;
425  }
426 
427  SfxUndoAction *const pAction( SdrUndoManager::GetRedoAction() );
428  if ( pAction == nullptr )
429  {
430  return false;
431  }
432 
434  {
435  // If another view created the undo action, prevent redoing it from this view.
436  ViewShellId nViewShellId = pView ? pView->GetViewShellId() : m_pDocShell->GetView()->GetViewShellId();
437  if (pAction->GetViewShellId() != nViewShellId)
438  {
439  if (o_pId)
440  {
441  *o_pId = SwUndoId::CONFLICT;
442  }
443  return false;
444  }
445  }
446 
447  if (o_pStr)
448  {
449  *o_pStr = pAction->GetComment();
450  }
451  if (o_pId)
452  {
453  if (auto pListAction = dynamic_cast<const SfxListUndoAction*>(pAction))
454  *o_pId = static_cast<SwUndoId>(pListAction->GetId());
455  else if (auto pSwAction = dynamic_cast<const SwUndo*>(pAction))
456  *o_pId = pSwAction->GetId();
457  else
458  *o_pId = SwUndoId::EMPTY;
459  }
460 
461  return true;
462 }
463 
465 {
466  OSL_ENSURE(!SdrUndoManager::IsInListAction(),
467  "GetRedoComments() called while in list action?");
468 
469  SwUndoComments_t ret;
470  const size_t nRedoCount(SdrUndoManager::GetRedoActionCount(TopLevel));
471  for (size_t n = 0; n < nRedoCount; ++n)
472  {
473  OUString const comment(
474  SdrUndoManager::GetRedoActionComment(n, TopLevel));
475  ret.push_back(comment);
476  }
477 
478  return ret;
479 }
480 
481 SwUndoId UndoManager::GetRepeatInfo(OUString *const o_pStr) const
482 {
483  SwUndoId nRepeatId(SwUndoId::EMPTY);
484  GetLastUndoInfo(o_pStr, & nRepeatId);
485  if( SwUndoId::REPEAT_START <= nRepeatId && SwUndoId::REPEAT_END > nRepeatId )
486  {
487  return nRepeatId;
488  }
489  if (o_pStr) // not repeatable -> clear comment
490  {
491  o_pStr->clear();
492  }
493  return SwUndoId::EMPTY;
494 }
495 
497 {
498  if (SdrUndoManager::GetRedoActionCount() ||
499  SdrUndoManager::GetRedoActionCount(TopLevel))
500  {
501  OSL_ENSURE(false, "RemoveLastUndoAction(): there are Redo actions?");
502  return nullptr;
503  }
504  if (!SdrUndoManager::GetUndoActionCount())
505  {
506  OSL_ENSURE(false, "RemoveLastUndoAction(): no Undo actions");
507  return nullptr;
508  }
509  SfxUndoAction *const pLastUndo(GetUndoAction());
510  SdrUndoManager::RemoveLastUndoAction();
511  return dynamic_cast<SwUndo *>(pLastUndo);
512 }
513 
514 // SfxUndoManager
515 
516 void UndoManager::AddUndoAction(std::unique_ptr<SfxUndoAction> pAction, bool bTryMerge)
517 {
518  SwUndo *const pUndo( dynamic_cast<SwUndo *>(pAction.get()) );
519  if (pUndo)
520  {
521  if (RedlineFlags::NONE == pUndo->GetRedlineFlags())
522  {
524  }
526  {
527  pUndo->IgnoreRepeat();
528  }
529  }
530  SdrUndoManager::AddUndoAction(std::move(pAction), bTryMerge);
531  if (m_pDocShell)
532  {
534  while ( pViewFrame )
535  {
536  pViewFrame->GetBindings().Invalidate( SID_UNDO );
537  pViewFrame->GetBindings().Invalidate( SID_REDO );
538  pViewFrame = SfxViewFrame::GetNext( *pViewFrame, m_pDocShell );
539  }
540  }
541 
542  // if the undo nodes array is too large, delete some actions
543  while (UNDO_ACTION_LIMIT < GetUndoNodes().Count())
544  {
545  RemoveOldestUndoAction();
546  }
547 }
548 
550 {
551 public:
552  CursorGuard(SwEditShell & rShell, bool const bSave)
553  : m_rShell(rShell)
554  , m_bSaveCursor(bSave)
555  {
556  if (m_bSaveCursor)
557  {
558  m_rShell.Push(); // prevent modification of current cursor
559  }
560  }
561  ~CursorGuard() COVERITY_NOEXCEPT_FALSE
562  {
563  if (m_bSaveCursor)
564  {
566  }
567  }
568 private:
570  bool const m_bSaveCursor;
571 };
572 
574 {
575  SwDoc & rDoc(*GetUndoNodes().GetDoc());
576 
577  UnoActionContext c(& rDoc); // exception-safe StartAllAction/EndAllAction
578 
579  SwEditShell *const pEditShell( rDoc.GetEditShell() );
580 
581  OSL_ENSURE(pEditShell, "sw::UndoManager needs a SwEditShell!");
582  if (!pEditShell)
583  {
584  throw uno::RuntimeException();
585  }
586 
587  // in case the model has controllers locked, the Undo should not
588  // change the view cursors!
589  bool const bSaveCursors(pEditShell->CursorsLocked());
590  CursorGuard aCursorGuard(*pEditShell, bSaveCursors);
591  if (!bSaveCursors)
592  {
593  // (in case Undo was called via API) clear the cursors:
594  pEditShell->KillPams();
595  pEditShell->SetMark();
596  pEditShell->ClearMark();
597  }
598 
599  bool bRet(false);
600 
601  ::sw::UndoRedoContext context(rDoc, *pEditShell);
602 
603  // N.B. these may throw!
604  if (UndoOrRedoType::Undo == undoOrRedo)
605  {
606  bRet = SdrUndoManager::UndoWithContext(context);
607  }
608  else
609  {
610  bRet = SdrUndoManager::RedoWithContext(context);
611  }
612 
613  if (bRet)
614  {
615  // if we are at the "last save" position, the document is not modified
616  if (SdrUndoManager::HasTopUndoActionMark(m_UndoSaveMark))
617  {
619  }
620  else
621  {
623  }
624  }
625 
626  pEditShell->HandleUndoRedoContext(context);
627 
628  return bRet;
629 }
630 
632 {
633  if(isTextEditActive())
634  {
635  return SdrUndoManager::Undo();
636  }
637  else
638  {
640  }
641 }
642 
644 {
645  if(isTextEditActive())
646  {
647  return SdrUndoManager::Redo();
648  }
649  else
650  {
652  }
653 }
654 
656 {
657  if (m_pDocShell)
658  {
659  m_pDocShell->Broadcast(SfxHint(SfxHintId::DocumentRepair));
660  }
661 }
662 
669  sal_uInt16 const nRepeatCount)
670 {
671  if (SdrUndoManager::IsInListAction())
672  {
673  OSL_ENSURE(false, "repeat in open list action???");
674  return false;
675  }
676  if (!SdrUndoManager::GetUndoActionCount(TopLevel))
677  {
678  return false;
679  }
680  SfxUndoAction *const pRepeatAction(GetUndoAction());
681  assert(pRepeatAction);
682  if (!pRepeatAction->CanRepeat(rContext))
683  {
684  return false;
685  }
686 
687  OUString const comment(pRepeatAction->GetComment());
688  OUString const rcomment(pRepeatAction->GetRepeatComment(rContext));
689  SwUndoId nId;
690  if (auto const* const pSwAction = dynamic_cast<SwUndo*>(pRepeatAction))
691  nId = pSwAction->GetId();
692  else if (auto const* const pListAction = dynamic_cast<SfxListUndoAction*>(pRepeatAction))
693  nId = static_cast<SwUndoId>(pListAction->GetId());
694  else
695  return false;
696  if (DoesUndo())
697  {
698  ViewShellId nViewShellId(-1);
699  if (m_pDocShell)
700  {
701  if (const SwView* pView = m_pDocShell->GetView())
702  nViewShellId = pView->GetViewShellId();
703  }
704  EnterListAction(comment, rcomment, static_cast<sal_uInt16>(nId), nViewShellId);
705  }
706 
707  SwPaM* pTmp = rContext.m_pCurrentPaM;
708  for(SwPaM& rPaM : rContext.GetRepeatPaM().GetRingContainer())
709  { // iterate over ring
710  rContext.m_pCurrentPaM = &rPaM;
711  if (DoesUndo() && & rPaM != pTmp)
712  {
714  }
715  for (sal_uInt16 nRptCnt = nRepeatCount; nRptCnt > 0; --nRptCnt)
716  {
717  pRepeatAction->Repeat(rContext);
718  }
719  if (DoesUndo() && & rPaM != pTmp)
720  {
721  m_isAddWithIgnoreRepeat = false;
722  }
723  rContext.m_bDeleteRepeated = false; // reset for next PaM
724  }
725  rContext.m_pCurrentPaM = pTmp;
726 
727  if (DoesUndo())
728  {
729  LeaveListAction();
730  }
731  return true;
732 }
733 
734 } // namespace sw
735 
736 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual bool DoesGroupUndo() const override
Is Group Undo enabled?
Definition: docundo.cxx:180
SwNodes const & GetUndoNodes() const
Definition: docundo.cxx:76
std::shared_ptr< SwNodes > m_xUndoNodes
Undo nodes array: content not currently in document.
SwUndoId
Definition: swundo.hxx:29
bool m_isAddWithIgnoreRepeat
set the IgnoreRepeat flag on every added action
virtual void SetModified()=0
Must be called manually at changes of format.
SwPaM & GetRepeatPaM()
Definition: UndoCore.hxx:128
virtual bool Undo() override
Definition: doc.hxx:185
sal_Int16 nId
virtual bool DoesDrawUndo() const override
Is Undo for Drawing objects enabled? for Draw-Undo: writer wants to handle actions on Flys on its own...
Definition: docundo.cxx:190
void SetDocShell(SwDocShell *pDocShell)
Definition: docundo.cxx:91
void SetRedlineFlags(RedlineFlags eMode)
Definition: undobj.hxx:119
virtual void SetUndoNoResetModified() override
Disable (re)setting the document modified flag on Undo/Redo.
Definition: docundo.cxx:210
bool impl_DoUndoRedo(UndoOrRedoType undoOrRedo)
Definition: docundo.cxx:573
size_t GetRedoActionCount(const bool bCurrentLevel=true) const override
Definition: docundo.cxx:125
Dialog to specify the properties of date form field.
void Invalidate(sal_uInt16 nId)
virtual bool GetLastUndoInfo(OUString *const o_pStr, SwUndoId *const o_pId, const SwView *pView=nullptr) const override
Get Id and comment of last Undo action.
Definition: docundo.cxx:358
virtual bool Redo() override
void SetView(SwView *pView) override
Return undo/redo info for this view.
Definition: docundo.cxx:96
IDocumentState & m_rState
virtual void DelAllUndoObj() override
Delete all Undo actions.
Definition: docundo.cxx:257
void EnableUndo(bool bEnable)
virtual bool IsUndoNoResetModified() const override
Is setting the document modified flag on Undo/Redo disabled?
Definition: docundo.cxx:205
virtual SwUndoComments_t GetRedoComments() const override
Get comments of Redo actions.
Definition: docundo.cxx:464
virtual bool Undo() override
Definition: docundo.cxx:631
std::vector< OUString > SwUndoComments_t
Definition: swundo.hxx:26
RedlineFlags GetRedlineFlags() const
Definition: undobj.hxx:118
bool isTextEditActive() const
void DoRepair(bool bRepair) override
Enable repair mode.
Definition: docundo.cxx:195
PaM is Point and Mark: a selection of the document model.
Definition: pam.hxx:136
SwDocShell * m_pDocShell
IDocumentRedlineAccess & m_rRedlineAccess
OUString Apply(const OUString &rStr) const
Definition: SwRewriter.cxx:43
SwEditShell const * GetEditShell() const
Definition: doccorr.cxx:317
bool m_bRepair
If true, then repair mode is enabled.
void Push()
store a copy of the current cursor on the cursor stack
Definition: crsrsh.cxx:2221
Count
SfxBindings & GetBindings()
virtual void LockUndoNoModifiedPosition() override
Prevent updates to the "unmodified" state position via SetUndoNoResetModified().
Definition: docundo.cxx:227
#define MARK_INVALID
static SfxViewFrame * GetNext(const SfxViewFrame &rPrev, const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
virtual const SwDrawModel * GetDrawModel() const =0
Draw Model and id accessors.
virtual size_t GetUndoActionCount(const bool bCurrentLevel=true) const override
Get the number of Undo actions.
Definition: docundo.cxx:101
UndoManager(std::shared_ptr< SwNodes > const &pUndoNodes, IDocumentDrawModelAccess &rDrawModelAccess, IDocumentRedlineAccess &rRedlineAccess, IDocumentState &rState)
Definition: docundo.cxx:53
virtual void SetUndoNoModifiedPosition() override
Set the position at which the document is in the "unmodified" state to the current position in the Un...
Definition: docundo.cxx:219
virtual SwUndoId GetRepeatInfo(OUString *const o_pStr) const override
Get Id and comment of last Undo action, if it is Repeat capable.
Definition: docundo.cxx:481
ring_container GetRingContainer()
Definition: ring.hxx:240
UndoStackMark m_UndoSaveMark
position in Undo-Array at which Doc was saved (and is not modified)
virtual bool IsUndoNodes(SwNodes const &rNodes) const override
Definition: docundo.cxx:86
virtual void DoDrawUndo(bool const bDoUndo) override
Enable/Disable Undo for Drawing objects.
Definition: docundo.cxx:185
virtual OUString GetRepeatComment(SfxRepeatTarget &) const
virtual SwUndoId EndUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter) override
Closes undo block.
Definition: docundo.cxx:299
virtual void UnLockUndoNoModifiedPosition() override
Allow updates to the "unmodified" state position via SetUndoNoResetModified().
Definition: docundo.cxx:232
CursorGuard(SwEditShell &rShell, bool const bSave)
Definition: docundo.cxx:552
SwUndo * GetLastUndo()
Definition: docundo.cxx:237
virtual ViewShellId GetViewShellId() const
bool DoesRepair() const override
Is repair mode active?
Definition: docundo.cxx:200
virtual OUString GetComment() const
#define UNDO_ACTION_LIMIT
Definition: docundo.cxx:49
bool m_bLockUndoNoModifiedPosition
SwEditShell & m_rShell
Definition: docundo.cxx:569
virtual void Repeat(SfxRepeatTarget &)
Get information about the current document state.
void IgnoreRepeat()
Definition: undobj.hxx:129
IDocumentDrawModelAccess & m_rDrawModelAccess
virtual SwUndoComments_t GetUndoComments() const override
Get comments of Undo actions.
Definition: docundo.cxx:401
virtual bool Redo() override
Definition: docundo.cxx:643
virtual void DoUndo(bool const bDoUndo) override
IDocumentUndoRedo.
Definition: docundo.cxx:149
virtual void AddUndoAction(std::unique_ptr< SfxUndoAction > pAction, bool bTryMerg=false) override
Definition: docundo.cxx:516
virtual SwUndoId StartUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter) override
Opens undo block.
Definition: docundo.cxx:267
virtual void EmptyActionsChanged() override
Definition: docundo.cxx:655
bool const m_bSaveCursor
Definition: docundo.cxx:570
OUString GetUndoComment(SwUndoId eId)
Definition: undobj.cxx:265
static SfxViewFrame * GetFirst(const SfxObjectShell *pDoc=nullptr, bool bOnlyVisible=true)
virtual bool CanRepeat(SfxRepeatTarget &) const
virtual void DoGroupUndo(bool const bDoUndo) override
Enable/Disable Group Undo.
Definition: docundo.cxx:175
virtual RedlineFlags GetRedlineFlags() const =0
Query the currently set redline mode.
SwPaM * m_pCurrentPaM
Definition: UndoCore.hxx:138
const SwView * GetView() const
Definition: docsh.hxx:220
SwUndo * RemoveLastUndo()
Definition: docundo.cxx:496
virtual void ClearRedo() override
Delete all Redo actions.
Definition: docundo.cxx:252
virtual bool Repeat(::sw::RepeatContext &rContext, sal_uInt16 const nRepeatCnt) override
N.B.
Definition: docundo.cxx:668
bool Pop(PopMode)
delete cursor
Definition: crsrsh.cxx:2243
virtual bool DoesUndo() const override
Is Undo enabled?
Definition: docundo.cxx:163
virtual bool GetFirstRedoInfo(OUString *const o_pStr, SwUndoId *const o_pId, const SwView *pView=nullptr) const override
Get Id and comment of first Redo action.
Definition: docundo.cxx:418
~CursorGuard() COVERITY_NOEXCEPT_FALSE
Definition: docundo.cxx:561
no RedlineFlags
Definition: view.hxx:146
ViewShellId GetViewShellId() const override
virtual void AppendUndo(std::unique_ptr< SwUndo > pUndo) override
Add new Undo action.
Definition: docundo.cxx:247
virtual void ResetModified()=0