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