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