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