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