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