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