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 || pRedoAction->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 OSL_ENSURE(pEditShell, "sw::UndoManager needs a SwEditShell!");
671 if (!pEditShell)
672 {
673 throw uno::RuntimeException();
674 }
675
676 // in case the model has controllers locked, the Undo should not
677 // change the view cursors!
678 bool const bSaveCursors(pEditShell->CursorsLocked());
679 CursorGuard aCursorGuard(*pEditShell, bSaveCursors);
680 if (!bSaveCursors)
681 {
682 // (in case Undo was called via API) clear the cursors:
683 pEditShell->KillPams();
684 pEditShell->SetMark();
685 pEditShell->ClearMark();
686 }
687
688 bool bRet(false);
689
690 ::sw::UndoRedoContext context(rDoc, *pEditShell);
691 context.SetUndoOffset(nUndoOffset);
692
693 // N.B. these may throw!
694 if (UndoOrRedoType::Undo == undoOrRedo)
695 {
696 bRet = SdrUndoManager::UndoWithContext(context);
697 }
698 else
699 {
700 bRet = SdrUndoManager::RedoWithContext(context);
701 }
702
703 if (bRet)
704 {
705 // if we are at the "last save" position, the document is not modified
706 if (SdrUndoManager::HasTopUndoActionMark(m_UndoSaveMark))
707 {
709 }
710 else
711 {
713 }
714 }
715
716 pEditShell->HandleUndoRedoContext(context);
717
718 return bRet;
719}
720
722
723bool UndoManager::UndoWithOffset(size_t nUndoOffset)
724{
725 if(isTextEditActive())
726 {
727 return SdrUndoManager::Undo();
728 }
729 else
730 {
731 return impl_DoUndoRedo(UndoOrRedoType::Undo, nUndoOffset);
732 }
733}
734
736{
737 if(isTextEditActive())
738 {
739 return SdrUndoManager::Redo();
740 }
741 else
742 {
743 return impl_DoUndoRedo(UndoOrRedoType::Redo, /*nUndoOffset=*/0);
744 }
745}
746
748{
749 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("swUndoManager"));
750 SdrUndoManager::dumpAsXml(pWriter);
751
752 (void)xmlTextWriterStartElement(pWriter, BAD_CAST("m_xUndoNodes"));
753 m_xUndoNodes->dumpAsXml(pWriter);
754 (void)xmlTextWriterEndElement(pWriter);
755
756 (void)xmlTextWriterEndElement(pWriter);
757}
758
760{
761 if (m_pDocShell)
762 {
763 m_pDocShell->Broadcast(SfxHint(SfxHintId::DocumentRepair));
764 }
765}
766
773 sal_uInt16 const nRepeatCount)
774{
775 if (SdrUndoManager::IsInListAction())
776 {
777 OSL_ENSURE(false, "repeat in open list action???");
778 return false;
779 }
780 if (!SdrUndoManager::GetUndoActionCount(TopLevel))
781 {
782 return false;
783 }
784 SfxUndoAction *const pRepeatAction(GetUndoAction());
785 assert(pRepeatAction);
786 if (!pRepeatAction->CanRepeat(rContext))
787 {
788 return false;
789 }
790
791 OUString const comment(pRepeatAction->GetComment());
792 OUString const rcomment(pRepeatAction->GetRepeatComment(rContext));
794 if (auto const* const pSwAction = dynamic_cast<SwUndo*>(pRepeatAction))
795 nId = pSwAction->GetId();
796 else if (auto const* const pListAction = dynamic_cast<SfxListUndoAction*>(pRepeatAction))
797 nId = static_cast<SwUndoId>(pListAction->GetId());
798 else
799 return false;
800 if (DoesUndo())
801 {
802 ViewShellId nViewShellId(-1);
803 if (m_pDocShell)
804 {
805 if (const SwView* pView = m_pDocShell->GetView())
806 nViewShellId = pView->GetViewShellId();
807 }
808 EnterListAction(comment, rcomment, static_cast<sal_uInt16>(nId), nViewShellId);
809 }
810
811 SwPaM* pTmp = rContext.m_pCurrentPaM;
812 for(SwPaM& rPaM : rContext.GetRepeatPaM().GetRingContainer())
813 { // iterate over ring
814 rContext.m_pCurrentPaM = &rPaM;
815 if (DoesUndo() && & rPaM != pTmp)
816 {
818 }
819 for (sal_uInt16 nRptCnt = nRepeatCount; nRptCnt > 0; --nRptCnt)
820 {
821 pRepeatAction->Repeat(rContext);
822 }
823 if (DoesUndo() && & rPaM != pTmp)
824 {
826 }
827 rContext.m_bDeleteRepeated = false; // reset for next PaM
828 }
829 rContext.m_pCurrentPaM = pTmp;
830
831 if (DoesUndo())
832 {
833 LeaveListAction();
834 }
835 return true;
836}
837
838} // namespace sw
839
840/* 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
void ClearMark()
Definition: crsrsh.cxx:1193
void SetMark()
Definition: crsrsh.hxx:905
void KillPams()
Definition: crsrsh.cxx:1276
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
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:177
void DoRepair(bool bRepair) override
Definition: docundo.cxx:197
virtual void LockUndoNoModifiedPosition() override
Definition: docundo.cxx:229
bool DoesRepair() const override
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
Definition: docundo.cxx:504
virtual void ClearRedo() override
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
Definition: docundo.cxx:221
virtual bool Repeat(::sw::RepeatContext &rContext, sal_uInt16 const nRepeatCnt) override
N.B.
Definition: docundo.cxx:772
virtual bool DoesGroupUndo() const override
Definition: docundo.cxx:182
virtual void DoDrawUndo(bool const bDoUndo) override
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:721
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
Definition: docundo.cxx:442
virtual bool Redo() override
Definition: docundo.cxx:735
bool m_bRepair
If true, then repair mode is enabled.
virtual bool DoesUndo() const override
Definition: docundo.cxx:165
virtual SwUndoId StartUndo(SwUndoId const eUndoId, SwRewriter const *const pRewriter) override
Definition: docundo.cxx:269
virtual SwUndoComments_t GetRedoComments() const override
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
Definition: docundo.cxx:103
void SetDocShell(SwDocShell *pDocShell)
Definition: docundo.cxx:93
void SetView(SwView *pView) override
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
Definition: docundo.cxx:301
virtual SwUndoId GetRepeatInfo(OUString *const o_pStr) const override
Definition: docundo.cxx:567
bool impl_DoUndoRedo(UndoOrRedoType undoOrRedo, size_t nUndoOffset)
Definition: docundo.cxx:663
virtual void DelAllUndoObj() override
Definition: docundo.cxx:259
virtual bool IsUndoNoResetModified() const override
Definition: docundo.cxx:207
IDocumentDrawModelAccess & m_rDrawModelAccess
virtual SwUndoComments_t GetUndoComments() const override
Definition: docundo.cxx:487
virtual bool DoesDrawUndo() const override
Definition: docundo.cxx:192
virtual void SetUndoNoResetModified() override
Definition: docundo.cxx:212
virtual void UnLockUndoNoModifiedPosition() override
Definition: docundo.cxx:234
bool UndoWithOffset(size_t nUndoOffset) override
Definition: docundo.cxx:723
void dumpAsXml(xmlTextWriterPtr pWriter) const
Definition: docundo.cxx:747
SwDocShell * m_pDocShell
size_t GetRedoActionCount(const bool bCurrentLevel=true) const override
Definition: docundo.cxx:127
virtual void EmptyActionsChanged() override
Definition: docundo.cxx:759
virtual void AppendUndo(std::unique_ptr< SwUndo > pUndo) override
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
struct _xmlTextWriter * xmlTextWriterPtr
#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