[Libreoffice-commits] core.git: sw/inc sw/source

Miklos Vajna vmiklos at collabora.co.uk
Fri Jul 29 17:03:00 UTC 2016


 sw/inc/undobj.hxx                       |    8 +++++++-
 sw/source/core/doc/doc.cxx              |    4 ++--
 sw/source/core/doc/docbm.cxx            |    2 +-
 sw/source/core/doc/docdraw.cxx          |    8 ++++----
 sw/source/core/doc/docfmt.cxx           |    2 +-
 sw/source/core/doc/docftn.cxx           |    4 ++--
 sw/source/core/doc/doclay.cxx           |    4 ++--
 sw/source/core/doc/docnum.cxx           |    2 +-
 sw/source/core/docnode/ndtbl.cxx        |    4 ++--
 sw/source/core/inc/SwUndoTOXChange.hxx  |    4 +++-
 sw/source/core/inc/UndoAttribute.hxx    |    7 ++++---
 sw/source/core/inc/UndoBookmark.hxx     |    4 +++-
 sw/source/core/inc/UndoDraw.hxx         |   11 ++++++-----
 sw/source/core/inc/UndoInsert.hxx       |    4 +++-
 sw/source/core/inc/UndoNumbering.hxx    |    2 +-
 sw/source/core/inc/UndoTable.hxx        |    4 ++--
 sw/source/core/undo/SwUndoField.cxx     |    2 +-
 sw/source/core/undo/SwUndoFmt.cxx       |   12 ++++++------
 sw/source/core/undo/SwUndoPageDesc.cxx  |    7 ++++---
 sw/source/core/undo/SwUndoTOXChange.cxx |    4 ++--
 sw/source/core/undo/unattr.cxx          |   32 ++++++++++++++++----------------
 sw/source/core/undo/unbkmk.cxx          |    6 +++---
 sw/source/core/undo/undel.cxx           |    2 +-
 sw/source/core/undo/undobj.cxx          |   22 +++++++++++++++++++++-
 sw/source/core/undo/undobj1.cxx         |    4 ++--
 sw/source/core/undo/undoflystrattr.cxx  |    2 +-
 sw/source/core/undo/undraw.cxx          |   22 +++++++++++-----------
 sw/source/core/undo/unfmco.cxx          |    2 +-
 sw/source/core/undo/unins.cxx           |   13 +++++++------
 sw/source/core/undo/unmove.cxx          |    4 ++--
 sw/source/core/undo/unnum.cxx           |   23 +++++++++++++----------
 sw/source/core/undo/unoutl.cxx          |    2 +-
 sw/source/core/undo/unovwr.cxx          |    4 ++--
 sw/source/core/undo/unredln.cxx         |    6 +++---
 sw/source/core/undo/unsect.cxx          |    6 +++---
 sw/source/core/undo/unsort.cxx          |    4 ++--
 sw/source/core/undo/unspnd.cxx          |    2 +-
 sw/source/core/undo/untbl.cxx           |   32 ++++++++++++++++----------------
 sw/source/core/undo/untblk.cxx          |    2 +-
 39 files changed, 164 insertions(+), 125 deletions(-)

New commits:
commit d60708c5116b4c48b30b94095aafd3e77de46f6a
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Jul 29 17:58:19 2016 +0200

    sw undo: implement SfxUndoAction::GetViewShellId() interface
    
    With this, it's possible to tell which view shell created which undo
    actions. It's visible only in the doc model xml dump only, though.
    
    Change-Id: Ia76d218a1d8b578aaad00ab733c772b10dda39f0
    Reviewed-on: https://gerrit.libreoffice.org/27693
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/sw/inc/undobj.hxx b/sw/inc/undobj.hxx
index 79d890c..14e099f 100644
--- a/sw/inc/undobj.hxx
+++ b/sw/inc/undobj.hxx
@@ -49,6 +49,7 @@ class SwUndo
 {
     SwUndoId const m_nId;
     sal_uInt16 nOrigRedlineMode;
+    sal_Int32 m_nViewShellId;
 
 protected:
     bool bCacheComment;
@@ -81,6 +82,8 @@ public: // should not be public, but ran into trouble in untbl.cxx
     virtual void RedoImpl( ::sw::UndoRedoContext & ) = 0;
 
 private:
+    /// Try to obtain the view shell ID of the current view.
+    static sal_Int32 CreateViewShellId(const SwDoc* pDoc);
     // SfxUndoAction
     virtual void Undo() override;
     virtual void Redo() override;
@@ -90,7 +93,7 @@ private:
     virtual bool CanRepeat(SfxRepeatTarget &) const override;
 
 public:
-    SwUndo(SwUndoId const nId);
+    SwUndo(SwUndoId const nId, const SwDoc* pDoc);
     virtual ~SwUndo();
 
     /**
@@ -104,6 +107,9 @@ public:
     */
     virtual OUString GetComment() const override;
 
+    /// See SfxUndoAction::GetViewShellId().
+    sal_Int32 GetViewShellId() const override;
+
     // UndoObject remembers which mode was turned on.
     // In Undo/Redo/Repeat this remembered mode is switched on.
     sal_uInt16 GetRedlineMode() const { return nOrigRedlineMode; }
diff --git a/sw/source/core/doc/doc.cxx b/sw/source/core/doc/doc.cxx
index 63075b8..9d7c40d 100644
--- a/sw/source/core/doc/doc.cxx
+++ b/sw/source/core/doc/doc.cxx
@@ -1651,7 +1651,7 @@ void SwDoc::AppendUndoForInsertFromDB( const SwPaM& rPam, bool bIsTable )
         const SwTableNode* pTableNd = rPam.GetPoint()->nNode.GetNode().FindTableNode();
         if( pTableNd )
         {
-            SwUndoCpyTable* pUndo = new SwUndoCpyTable;
+            SwUndoCpyTable* pUndo = new SwUndoCpyTable(this);
             pUndo->SetTableSttIdx( pTableNd->GetIndex() );
             GetIDocumentUndoRedo().AppendUndo( pUndo );
         }
@@ -1670,7 +1670,7 @@ void SwDoc::ChgTOX(SwTOXBase & rTOX, const SwTOXBase & rNew)
     {
         GetIDocumentUndoRedo().DelAllUndoObj();
 
-        SwUndo * pUndo = new SwUndoTOXChange(&rTOX, rNew);
+        SwUndo * pUndo = new SwUndoTOXChange(this, &rTOX, rNew);
 
         GetIDocumentUndoRedo().AppendUndo(pUndo);
     }
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index 3e7919f..c910663 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -558,7 +558,7 @@ namespace sw { namespace mark
                 if (m_pDoc->GetIDocumentUndoRedo().DoesUndo())
                 {
                     m_pDoc->GetIDocumentUndoRedo().AppendUndo(
-                            new SwUndoRenameBookmark(sOldName, rNewName));
+                            new SwUndoRenameBookmark(sOldName, rNewName, m_pDoc));
                 }
                 m_pDoc->getIDocumentState().SetModified();
             }
diff --git a/sw/source/core/doc/docdraw.cxx b/sw/source/core/doc/docdraw.cxx
index 3edbe8b..403b46b 100644
--- a/sw/source/core/doc/docdraw.cxx
+++ b/sw/source/core/doc/docdraw.cxx
@@ -212,7 +212,7 @@ SwDrawContact* SwDoc::GroupSelection( SdrView& rDrawView )
 
         SwUndoDrawGroup *const pUndo = (!GetIDocumentUndoRedo().DoesUndo())
                                  ? nullptr
-                                 : new SwUndoDrawGroup( (sal_uInt16)rMrkList.GetMarkCount() );
+                                 : new SwUndoDrawGroup( (sal_uInt16)rMrkList.GetMarkCount() , this);
 
         // #i53320#
         bool bGroupMembersNotPositioned( false );
@@ -330,7 +330,7 @@ void SwDoc::UnGroupSelection( SdrView& rDrawView )
                     SwUndoDrawUnGroup* pUndo = nullptr;
                     if( bUndo )
                     {
-                        pUndo = new SwUndoDrawUnGroup( static_cast<SdrObjGroup*>(pObj) );
+                        pUndo = new SwUndoDrawUnGroup( static_cast<SdrObjGroup*>(pObj), this );
                         GetIDocumentUndoRedo().AppendUndo(pUndo);
                     }
 
@@ -360,7 +360,7 @@ void SwDoc::UnGroupSelection( SdrView& rDrawView )
         SwUndoDrawUnGroupConnectToLayout* pUndo = nullptr;
         if( bUndo )
         {
-            pUndo = new SwUndoDrawUnGroupConnectToLayout();
+            pUndo = new SwUndoDrawUnGroupConnectToLayout(this);
             GetIDocumentUndoRedo().AppendUndo(pUndo);
         }
 
@@ -433,7 +433,7 @@ bool SwDoc::DeleteSelection( SwDrawView& rDrawView )
                 SwUndoDrawDelete *const pUndo =
                     (!GetIDocumentUndoRedo().DoesUndo())
                         ? nullptr
-                            : new SwUndoDrawDelete( (sal_uInt16)rMrkList.GetMarkCount() );
+                            : new SwUndoDrawDelete( (sal_uInt16)rMrkList.GetMarkCount(), this );
 
                 // Destroy ContactObjects, save formats.
                 for( size_t i = 0; i < rMrkList.GetMarkCount(); ++i )
diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx
index 332cb3d..6410970 100644
--- a/sw/source/core/doc/docfmt.cxx
+++ b/sw/source/core/doc/docfmt.cxx
@@ -617,7 +617,7 @@ void SwDoc::SetDefault( const SfxItemSet& rSet )
     {
         if (GetIDocumentUndoRedo().DoesUndo())
         {
-            GetIDocumentUndoRedo().AppendUndo( new SwUndoDefaultAttr( aOld ) );
+            GetIDocumentUndoRedo().AppendUndo( new SwUndoDefaultAttr( aOld, this ) );
         }
 
         const SfxPoolItem* pTmpItem;
diff --git a/sw/source/core/doc/docftn.cxx b/sw/source/core/doc/docftn.cxx
index da581f9..807a972 100644
--- a/sw/source/core/doc/docftn.cxx
+++ b/sw/source/core/doc/docftn.cxx
@@ -257,7 +257,7 @@ void SwDoc::SetFootnoteInfo(const SwFootnoteInfo& rInfo)
 
         if (GetIDocumentUndoRedo().DoesUndo())
         {
-            GetIDocumentUndoRedo().AppendUndo( new SwUndoFootNoteInfo(rOld) );
+            GetIDocumentUndoRedo().AppendUndo( new SwUndoFootNoteInfo(rOld, this) );
         }
 
         bool bFootnotePos  = rInfo.ePos != rOld.ePos;
@@ -327,7 +327,7 @@ void SwDoc::SetEndNoteInfo(const SwEndNoteInfo& rInfo)
     {
         if(GetIDocumentUndoRedo().DoesUndo())
         {
-            SwUndo *const pUndo( new SwUndoEndNoteInfo( GetEndNoteInfo() ) );
+            SwUndo *const pUndo( new SwUndoEndNoteInfo( GetEndNoteInfo(), this ) );
             GetIDocumentUndoRedo().AppendUndo(pUndo);
         }
 
diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx
index 226af731..134243f 100644
--- a/sw/source/core/doc/doclay.cxx
+++ b/sw/source/core/doc/doclay.cxx
@@ -971,7 +971,7 @@ SwDoc::InsertLabel(
     {
         pUndo = new SwUndoInsertLabel(
                         eType, rText, rSeparator, rNumberingSeparator,
-                        bBefore, nId, rCharacterStyle, bCpyBrd );
+                        bBefore, nId, rCharacterStyle, bCpyBrd, this );
     }
 
     SwFlyFrameFormat *const pNewFormat = lcl_InsertLabel(*this, mpTextFormatCollTable, pUndo,
@@ -1255,7 +1255,7 @@ SwFlyFrameFormat* SwDoc::InsertDrawLabel(
         GetIDocumentUndoRedo().ClearRedo();
         pUndo = new SwUndoInsertLabel(
             LTYPE_DRAW, rText, rSeparator, rNumberSeparator, false,
-            nId, rCharacterStyle, false );
+            nId, rCharacterStyle, false, this );
     }
 
     SwFlyFrameFormat *const pNewFormat = lcl_InsertDrawLabel(
diff --git a/sw/source/core/doc/docnum.cxx b/sw/source/core/doc/docnum.cxx
index 1b55385..71e2b82 100644
--- a/sw/source/core/doc/docnum.cxx
+++ b/sw/source/core/doc/docnum.cxx
@@ -1049,7 +1049,7 @@ void SwDoc::ChgNumRuleFormats( const SwNumRule& rRule )
         SwUndoInsNum* pUndo = nullptr;
         if (GetIDocumentUndoRedo().DoesUndo())
         {
-            pUndo = new SwUndoInsNum( *pRule, rRule );
+            pUndo = new SwUndoInsNum( *pRule, rRule, this );
             pUndo->GetHistory();
             GetIDocumentUndoRedo().AppendUndo( pUndo );
         }
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 1fabfa9..074f160 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -4305,7 +4305,7 @@ bool SwDoc::InsCopyOfTable( SwPosition& rInsPos, const SwSelBoxes& rBoxes,
         if (bUndo)
         {
             GetIDocumentUndoRedo().ClearRedo();
-            pUndo = new SwUndoCpyTable;
+            pUndo = new SwUndoCpyTable(this);
         }
 
         {
@@ -4342,7 +4342,7 @@ bool SwDoc::InsCopyOfTable( SwPosition& rInsPos, const SwSelBoxes& rBoxes,
         if (bUndo)
         {
             GetIDocumentUndoRedo().ClearRedo();
-            pUndo = new SwUndoTableCpyTable;
+            pUndo = new SwUndoTableCpyTable(this);
             GetIDocumentUndoRedo().DoUndo(false);
         }
 
diff --git a/sw/source/core/inc/SwUndoTOXChange.hxx b/sw/source/core/inc/SwUndoTOXChange.hxx
index c3964a8..c97b948 100644
--- a/sw/source/core/inc/SwUndoTOXChange.hxx
+++ b/sw/source/core/inc/SwUndoTOXChange.hxx
@@ -23,6 +23,8 @@
 #include <undobj.hxx>
 #include <tox.hxx>
 
+class SwDoc;
+
 class SwUndoTOXChange : public SwUndo
 {
     SwTOXBase * pTOX, aOld, aNew;
@@ -31,7 +33,7 @@ class SwUndoTOXChange : public SwUndo
     void DoImpl();
 
 public:
-    SwUndoTOXChange(SwTOXBase * pTOX, const SwTOXBase & rNew);
+    SwUndoTOXChange(const SwDoc* pDoc, SwTOXBase * pTOX, const SwTOXBase & rNew);
     virtual ~SwUndoTOXChange();
 
     virtual void UndoImpl( ::sw::UndoRedoContext & ) override;
diff --git a/sw/source/core/inc/UndoAttribute.hxx b/sw/source/core/inc/UndoAttribute.hxx
index c68a4bc..69820b1 100644
--- a/sw/source/core/inc/UndoAttribute.hxx
+++ b/sw/source/core/inc/UndoAttribute.hxx
@@ -32,6 +32,7 @@ class SvxTabStopItem;
 class SwFormat;
 class SwFootnoteInfo;
 class SwEndNoteInfo;
+class SwDoc;
 
 class SwUndoAttr : public SwUndo, private SwUndRng
 {
@@ -199,7 +200,7 @@ class SwUndoDefaultAttr : public SwUndo
 
 public:
     // registers at the format and saves old attributes
-    SwUndoDefaultAttr( const SfxItemSet& rOldSet );
+    SwUndoDefaultAttr( const SfxItemSet& rOldSet, const SwDoc* pDoc );
 
     virtual ~SwUndoDefaultAttr();
 
@@ -231,7 +232,7 @@ class SwUndoFootNoteInfo : public SwUndo
     std::unique_ptr<SwFootnoteInfo> m_pFootNoteInfo;
 
 public:
-    SwUndoFootNoteInfo( const SwFootnoteInfo &rInfo );
+    SwUndoFootNoteInfo( const SwFootnoteInfo &rInfo, const SwDoc* pDoc );
 
     virtual ~SwUndoFootNoteInfo();
 
@@ -244,7 +245,7 @@ class SwUndoEndNoteInfo : public SwUndo
     std::unique_ptr<SwEndNoteInfo> m_pEndNoteInfo;
 
 public:
-    SwUndoEndNoteInfo( const SwEndNoteInfo &rInfo );
+    SwUndoEndNoteInfo( const SwEndNoteInfo &rInfo, const SwDoc* pDoc );
 
     virtual ~SwUndoEndNoteInfo();
 
diff --git a/sw/source/core/inc/UndoBookmark.hxx b/sw/source/core/inc/UndoBookmark.hxx
index 401c15e..6fd6363 100644
--- a/sw/source/core/inc/UndoBookmark.hxx
+++ b/sw/source/core/inc/UndoBookmark.hxx
@@ -30,6 +30,8 @@ namespace sw {
     }
 }
 
+class SwDoc;
+
 class SwUndoBookmark : public SwUndo
 {
     const std::unique_ptr<SwHistoryBookmark> m_pHistoryBookmark;
@@ -82,7 +84,7 @@ class SwUndoRenameBookmark : public SwUndo
     const OUString m_sNewName;
 
 public:
-    SwUndoRenameBookmark( const OUString& rOldName, const OUString& rNewName );
+    SwUndoRenameBookmark( const OUString& rOldName, const OUString& rNewName, const SwDoc* pDoc );
     virtual ~SwUndoRenameBookmark();
 
 private:
diff --git a/sw/source/core/inc/UndoDraw.hxx b/sw/source/core/inc/UndoDraw.hxx
index b603c26..a57340d 100644
--- a/sw/source/core/inc/UndoDraw.hxx
+++ b/sw/source/core/inc/UndoDraw.hxx
@@ -30,6 +30,7 @@ class SdrObject;
 class SdrObjGroup;
 class SdrUndoAction;
 class SwDrawFrameFormat;
+class SwDoc;
 
 // Undo for Draw Objects
 class SwSdrUndo : public SwUndo
@@ -38,7 +39,7 @@ class SwSdrUndo : public SwUndo
     SdrMarkList* pMarkList; // MarkList for all selected SdrObjects
 
 public:
-    SwSdrUndo( SdrUndoAction* , const SdrMarkList* pMarkList );
+    SwSdrUndo( SdrUndoAction* , const SdrMarkList* pMarkList, const SwDoc* pDoc );
 
     virtual ~SwSdrUndo();
 
@@ -55,7 +56,7 @@ class SwUndoDrawGroup : public SwUndo
     bool bDelFormat;
 
 public:
-    SwUndoDrawGroup( sal_uInt16 nCnt );
+    SwUndoDrawGroup( sal_uInt16 nCnt, const SwDoc* pDoc );
 
     virtual ~SwUndoDrawGroup();
 
@@ -84,7 +85,7 @@ class SwUndoDrawUnGroup : public SwUndo
     bool bDelFormat;
 
 public:
-    SwUndoDrawUnGroup( SdrObjGroup* );
+    SwUndoDrawUnGroup( SdrObjGroup*, const SwDoc* pDoc );
 
     virtual ~SwUndoDrawUnGroup();
 
@@ -100,7 +101,7 @@ private:
     std::vector< std::pair< SwDrawFrameFormat*, SdrObject* > > aDrawFormatsAndObjs;
 
 public:
-    SwUndoDrawUnGroupConnectToLayout();
+    SwUndoDrawUnGroupConnectToLayout(const SwDoc* pDoc);
 
     virtual ~SwUndoDrawUnGroupConnectToLayout();
 
@@ -119,7 +120,7 @@ class SwUndoDrawDelete : public SwUndo
     bool bDelFormat;
 
 public:
-    SwUndoDrawDelete( sal_uInt16 nCnt );
+    SwUndoDrawDelete( sal_uInt16 nCnt, const SwDoc* pDoc );
 
     virtual ~SwUndoDrawDelete();
 
diff --git a/sw/source/core/inc/UndoInsert.hxx b/sw/source/core/inc/UndoInsert.hxx
index b72f9d0..32b9b94 100644
--- a/sw/source/core/inc/UndoInsert.hxx
+++ b/sw/source/core/inc/UndoInsert.hxx
@@ -32,6 +32,7 @@ class Graphic;
 class SwGrfNode;
 class SwUndoDelete;
 class SwUndoFormatAttr;
+class SwDoc;
 namespace sw { class DocumentContentOperationsManager; }
 
 class SwUndoInsert: public SwUndo, private SwUndoSaveContent
@@ -185,7 +186,8 @@ public:
                         const OUString& rNumberSeparator, //#i61007# order of captions
                         const bool bBefore, const sal_uInt16 nId,
                         const OUString& rCharacterStyle,
-                        const bool bCpyBrd );
+                        const bool bCpyBrd,
+                        const SwDoc* pDoc );
     virtual ~SwUndoInsertLabel();
 
     virtual void UndoImpl( ::sw::UndoRedoContext & ) override;
diff --git a/sw/source/core/inc/UndoNumbering.hxx b/sw/source/core/inc/UndoNumbering.hxx
index 1d0a1fc..1adad5c 100644
--- a/sw/source/core/inc/UndoNumbering.hxx
+++ b/sw/source/core/inc/UndoNumbering.hxx
@@ -37,7 +37,7 @@ class SwUndoInsNum : public SwUndo, private SwUndRng
 public:
     SwUndoInsNum( const SwPaM& rPam, const SwNumRule& rRule );
     SwUndoInsNum( const SwNumRule& rOldRule, const SwNumRule& rNewRule,
-                  SwUndoId nUndoId = UNDO_INSFMTATTR );
+                  const SwDoc* pDoc, SwUndoId nUndoId = UNDO_INSFMTATTR );
     SwUndoInsNum( const SwPosition& rPos, const SwNumRule& rRule,
                             const OUString& rReplaceRule );
 
diff --git a/sw/source/core/inc/UndoTable.hxx b/sw/source/core/inc/UndoTable.hxx
index 7266ca9..670c8c9 100644
--- a/sw/source/core/inc/UndoTable.hxx
+++ b/sw/source/core/inc/UndoTable.hxx
@@ -285,7 +285,7 @@ class SwUndoTableCpyTable : public SwUndo
                 const SwPosition& rPos, bool& rJoin, bool bRedo );
 
 public:
-    SwUndoTableCpyTable();
+    SwUndoTableCpyTable(const SwDoc* pDoc);
 
     virtual ~SwUndoTableCpyTable();
 
@@ -306,7 +306,7 @@ class SwUndoCpyTable : public SwUndo
     sal_uLong nTableNode;
 
 public:
-    SwUndoCpyTable();
+    SwUndoCpyTable(const SwDoc* pDoc);
 
     virtual ~SwUndoCpyTable();
 
diff --git a/sw/source/core/undo/SwUndoField.cxx b/sw/source/core/undo/SwUndoField.cxx
index e983c6b..fc370c8 100644
--- a/sw/source/core/undo/SwUndoField.cxx
+++ b/sw/source/core/undo/SwUndoField.cxx
@@ -33,7 +33,7 @@
 using namespace ::com::sun::star::uno;
 
 SwUndoField::SwUndoField(const SwPosition & rPos, SwUndoId _nId )
-    : SwUndo(_nId)
+    : SwUndo(_nId, rPos.GetDoc())
 {
     nNodeIndex = rPos.nNode.GetIndex();
     nOffset = rPos.nContent.GetIndex();
diff --git a/sw/source/core/undo/SwUndoFmt.cxx b/sw/source/core/undo/SwUndoFmt.cxx
index ff117c6..ffa0531 100644
--- a/sw/source/core/undo/SwUndoFmt.cxx
+++ b/sw/source/core/undo/SwUndoFmt.cxx
@@ -33,7 +33,7 @@
 
 SwUndoFormatCreate::SwUndoFormatCreate
 (SwUndoId nUndoId, SwFormat * _pNew, SwFormat * _pDerivedFrom, SwDoc * _pDoc)
-    : SwUndo(nUndoId), pNew(_pNew),
+    : SwUndo(nUndoId, _pDoc), pNew(_pNew),
       pDoc(_pDoc), pNewSet(nullptr), nId(0), bAuto(false)
 {
     if (_pDerivedFrom)
@@ -98,7 +98,7 @@ SwRewriter SwUndoFormatCreate::GetRewriter() const
 
 SwUndoFormatDelete::SwUndoFormatDelete
 (SwUndoId nUndoId, SwFormat * _pOld, SwDoc * _pDoc)
-    : SwUndo(nUndoId),
+    : SwUndo(nUndoId, _pDoc),
       pDoc(_pDoc), sOldName(_pOld->GetName()),
       aOldSet(_pOld->GetAttrSet())
 {
@@ -150,7 +150,7 @@ SwUndoRenameFormat::SwUndoRenameFormat(SwUndoId nUndoId,
                                  const OUString & _sOldName,
                                  const OUString & _sNewName,
                                  SwDoc * _pDoc)
-    : SwUndo(nUndoId), sOldName(_sOldName),
+    : SwUndo(nUndoId, _pDoc), sOldName(_sOldName),
       sNewName(_sNewName), pDoc(_pDoc)
 {
 }
@@ -377,7 +377,7 @@ SwFormat * SwUndoRenameFrameFormat::Find(const OUString & rName) const
 
 SwUndoNumruleCreate::SwUndoNumruleCreate(const SwNumRule * _pNew,
                                          SwDoc * _pDoc)
-    : SwUndo(UNDO_NUMRULE_CREATE), pNew(_pNew), aNew(*_pNew), pDoc(_pDoc),
+    : SwUndo(UNDO_NUMRULE_CREATE, _pDoc), pNew(_pNew), aNew(*_pNew), pDoc(_pDoc),
       bInitialized(false)
 {
 }
@@ -415,7 +415,7 @@ SwRewriter SwUndoNumruleCreate::GetRewriter() const
 
 SwUndoNumruleDelete::SwUndoNumruleDelete(const SwNumRule & rRule,
                                          SwDoc * _pDoc)
-    : SwUndo(UNDO_NUMRULE_DELETE), aOld(rRule), pDoc(_pDoc)
+    : SwUndo(UNDO_NUMRULE_DELETE, _pDoc), aOld(rRule), pDoc(_pDoc)
 {
 }
 
@@ -441,7 +441,7 @@ SwRewriter SwUndoNumruleDelete::GetRewriter() const
 SwUndoNumruleRename::SwUndoNumruleRename(const OUString & _aOldName,
                                          const OUString & _aNewName,
                                          SwDoc * _pDoc)
-    : SwUndo(UNDO_NUMRULE_RENAME), aOldName(_aOldName), aNewName(_aNewName),
+    : SwUndo(UNDO_NUMRULE_RENAME, _pDoc), aOldName(_aOldName), aNewName(_aNewName),
       pDoc(_pDoc)
 {
 }
diff --git a/sw/source/core/undo/SwUndoPageDesc.cxx b/sw/source/core/undo/SwUndoPageDesc.cxx
index 9aadad4..e8bdf8b 100644
--- a/sw/source/core/undo/SwUndoPageDesc.cxx
+++ b/sw/source/core/undo/SwUndoPageDesc.cxx
@@ -101,7 +101,8 @@ SwUndoPageDesc::SwUndoPageDesc(const SwPageDesc & _aOld,
                                SwDoc * _pDoc)
     : SwUndo( _aOld.GetName() != _aNew.GetName() ?
               UNDO_RENAME_PAGEDESC :
-              UNDO_CHANGE_PAGEDESC ),
+              UNDO_CHANGE_PAGEDESC,
+              _pDoc ),
       aOld(_aOld, _pDoc), aNew(_aNew, _pDoc), pDoc(_pDoc), bExchange( false )
 {
     OSL_ENSURE(nullptr != pDoc, "no document?");
@@ -365,7 +366,7 @@ SwRewriter SwUndoPageDesc::GetRewriter() const
 
 SwUndoPageDescCreate::SwUndoPageDescCreate(const SwPageDesc * pNew,
                                            SwDoc * _pDoc)
-    : SwUndo(UNDO_CREATE_PAGEDESC), pDesc(pNew), aNew(*pNew, _pDoc),
+    : SwUndo(UNDO_CREATE_PAGEDESC, _pDoc), pDesc(pNew), aNew(*pNew, _pDoc),
       pDoc(_pDoc)
 {
     OSL_ENSURE(nullptr != pDoc, "no document?");
@@ -417,7 +418,7 @@ SwRewriter SwUndoPageDescCreate::GetRewriter() const
 
 SwUndoPageDescDelete::SwUndoPageDescDelete(const SwPageDesc & _aOld,
                                            SwDoc * _pDoc)
-    : SwUndo(UNDO_DELETE_PAGEDESC), aOld(_aOld, _pDoc), pDoc(_pDoc)
+    : SwUndo(UNDO_DELETE_PAGEDESC, _pDoc), aOld(_aOld, _pDoc), pDoc(_pDoc)
 {
     OSL_ENSURE(nullptr != pDoc, "no document?");
 }
diff --git a/sw/source/core/undo/SwUndoTOXChange.cxx b/sw/source/core/undo/SwUndoTOXChange.cxx
index 1deb5c1..5305fb2 100644
--- a/sw/source/core/undo/SwUndoTOXChange.cxx
+++ b/sw/source/core/undo/SwUndoTOXChange.cxx
@@ -21,8 +21,8 @@
 #include <swundo.hxx>
 #include <doctxm.hxx>
 
-SwUndoTOXChange::SwUndoTOXChange(SwTOXBase * _pTOX, const SwTOXBase & rNew)
-    : SwUndo(UNDO_TOXCHANGE), pTOX(_pTOX), aOld(*_pTOX), aNew(rNew)
+SwUndoTOXChange::SwUndoTOXChange(const SwDoc *pDoc, SwTOXBase * _pTOX, const SwTOXBase & rNew)
+    : SwUndo(UNDO_TOXCHANGE, pDoc), pTOX(_pTOX), aOld(*_pTOX), aNew(rNew)
 {
 }
 
diff --git a/sw/source/core/undo/unattr.cxx b/sw/source/core/undo/unattr.cxx
index d7e6cb7..6e8958c 100644
--- a/sw/source/core/undo/unattr.cxx
+++ b/sw/source/core/undo/unattr.cxx
@@ -102,7 +102,7 @@ void SwUndoFormatAttrHelper::Modify( const SfxPoolItem* pOld, const SfxPoolItem*
 SwUndoFormatAttr::SwUndoFormatAttr( const SfxItemSet& rOldSet,
                               SwFormat& rChgFormat,
                               bool bSaveDrawPt )
-    : SwUndo( UNDO_INSFMTATTR )
+    : SwUndo( UNDO_INSFMTATTR, rChgFormat.GetDoc() )
     , m_pFormat( &rChgFormat )
     // #i56253#
     , m_pOldSet( new SfxItemSet( rOldSet ) )
@@ -115,7 +115,7 @@ SwUndoFormatAttr::SwUndoFormatAttr( const SfxItemSet& rOldSet,
 
 SwUndoFormatAttr::SwUndoFormatAttr( const SfxPoolItem& rItem, SwFormat& rChgFormat,
                               bool bSaveDrawPt )
-    : SwUndo( UNDO_INSFMTATTR )
+    : SwUndo( UNDO_INSFMTATTR, rChgFormat.GetDoc() )
     , m_pFormat( &rChgFormat )
     , m_pOldSet( m_pFormat->GetAttrSet().Clone( false ) )
     , m_nNodeIndex( 0 )
@@ -527,7 +527,7 @@ bool SwUndoFormatAttr::RestoreFlyAnchor(::sw::UndoRedoContext & rContext)
 
 SwUndoFormatResetAttr::SwUndoFormatResetAttr( SwFormat& rChangedFormat,
                                         const sal_uInt16 nWhichId )
-    : SwUndo( UNDO_RESETATTR )
+    : SwUndo( UNDO_RESETATTR, rChangedFormat.GetDoc() )
     , m_pChangedFormat( &rChangedFormat )
     , m_nWhichId( nWhichId )
 {
@@ -556,14 +556,14 @@ void SwUndoFormatResetAttr::RedoImpl(::sw::UndoRedoContext &)
 }
 
 SwUndoResetAttr::SwUndoResetAttr( const SwPaM& rRange, sal_uInt16 nFormatId )
-    : SwUndo( UNDO_RESETATTR ), SwUndRng( rRange )
+    : SwUndo( UNDO_RESETATTR, rRange.GetDoc() ), SwUndRng( rRange )
     , m_pHistory( new SwHistory )
     , m_nFormatId( nFormatId )
 {
 }
 
 SwUndoResetAttr::SwUndoResetAttr( const SwPosition& rPos, sal_uInt16 nFormatId )
-    : SwUndo( UNDO_RESETATTR )
+    : SwUndo( UNDO_RESETATTR, rPos.GetDoc() )
     , m_pHistory( new SwHistory )
     , m_nFormatId( nFormatId )
 {
@@ -671,7 +671,7 @@ void SwUndoResetAttr::SetAttrs( const std::set<sal_uInt16> &rAttrs )
 
 SwUndoAttr::SwUndoAttr( const SwPaM& rRange, const SfxPoolItem& rAttr,
                         const SetAttrMode nFlags )
-    : SwUndo( UNDO_INSATTR ), SwUndRng( rRange )
+    : SwUndo( UNDO_INSATTR, rRange.GetDoc() ), SwUndRng( rRange )
     , m_AttrSet( rRange.GetDoc()->GetAttrPool(), rAttr.Which(), rAttr.Which() )
     , m_pHistory( new SwHistory )
     , m_nNodeIndex( ULONG_MAX )
@@ -682,7 +682,7 @@ SwUndoAttr::SwUndoAttr( const SwPaM& rRange, const SfxPoolItem& rAttr,
 
 SwUndoAttr::SwUndoAttr( const SwPaM& rRange, const SfxItemSet& rSet,
                         const SetAttrMode nFlags )
-    : SwUndo( UNDO_INSATTR ), SwUndRng( rRange )
+    : SwUndo( UNDO_INSATTR, rRange.GetDoc() ), SwUndRng( rRange )
     , m_AttrSet( rSet )
     , m_pHistory( new SwHistory )
     , m_nNodeIndex( ULONG_MAX )
@@ -836,8 +836,8 @@ void SwUndoAttr::RemoveIdx( SwDoc& rDoc )
     }
 }
 
-SwUndoDefaultAttr::SwUndoDefaultAttr( const SfxItemSet& rSet )
-    : SwUndo( UNDO_SETDEFTATTR )
+SwUndoDefaultAttr::SwUndoDefaultAttr( const SfxItemSet& rSet, const SwDoc* pDoc )
+    : SwUndo( UNDO_SETDEFTATTR, pDoc )
 {
     const SfxPoolItem* pItem;
     if( SfxItemState::SET == rSet.GetItemState( RES_PARATR_TABSTOP, false, &pItem ) ) {
@@ -883,7 +883,7 @@ void SwUndoDefaultAttr::RedoImpl(::sw::UndoRedoContext & rContext)
 
 SwUndoMoveLeftMargin::SwUndoMoveLeftMargin(
     const SwPaM& rPam, bool bFlag, bool bMod )
-    : SwUndo( bFlag ? UNDO_INC_LEFTMARGIN : UNDO_DEC_LEFTMARGIN )
+    : SwUndo( bFlag ? UNDO_INC_LEFTMARGIN : UNDO_DEC_LEFTMARGIN, rPam.GetDoc() )
     , SwUndRng( rPam )
     , m_pHistory( new SwHistory )
     , m_bModulus( bMod )
@@ -924,7 +924,7 @@ void SwUndoMoveLeftMargin::RepeatImpl(::sw::RepeatContext & rContext)
 SwUndoChangeFootNote::SwUndoChangeFootNote(
     const SwPaM& rRange, const OUString& rText,
     sal_uInt16 nNum, bool bIsEndNote )
-    : SwUndo( UNDO_CHGFTN ), SwUndRng( rRange )
+    : SwUndo( UNDO_CHGFTN, rRange.GetDoc() ), SwUndRng( rRange )
     , m_pHistory( new SwHistory() )
     , m_Text( rText )
     , m_nNumber( nNum )
@@ -962,8 +962,8 @@ void SwUndoChangeFootNote::RepeatImpl(::sw::RepeatContext & rContext)
     rDoc.SetCurFootnote( rContext.GetRepeatPaM(), m_Text, m_nNumber, m_bEndNote );
 }
 
-SwUndoFootNoteInfo::SwUndoFootNoteInfo( const SwFootnoteInfo &rInfo )
-    : SwUndo( UNDO_FTNINFO )
+SwUndoFootNoteInfo::SwUndoFootNoteInfo( const SwFootnoteInfo &rInfo, const SwDoc* pDoc )
+    : SwUndo( UNDO_FTNINFO, pDoc )
     , m_pFootNoteInfo( new SwFootnoteInfo( rInfo ) )
 {
 }
@@ -988,8 +988,8 @@ void SwUndoFootNoteInfo::RedoImpl(::sw::UndoRedoContext & rContext)
     m_pFootNoteInfo.reset( pInf );
 }
 
-SwUndoEndNoteInfo::SwUndoEndNoteInfo( const SwEndNoteInfo &rInfo )
-    : SwUndo( UNDO_FTNINFO )
+SwUndoEndNoteInfo::SwUndoEndNoteInfo( const SwEndNoteInfo &rInfo, const SwDoc* pDoc )
+    : SwUndo( UNDO_FTNINFO, pDoc )
     , m_pEndNoteInfo( new SwEndNoteInfo( rInfo ) )
 {
 }
@@ -1015,7 +1015,7 @@ void SwUndoEndNoteInfo::RedoImpl(::sw::UndoRedoContext & rContext)
 }
 
 SwUndoDontExpandFormat::SwUndoDontExpandFormat( const SwPosition& rPos )
-    : SwUndo( UNDO_DONTEXPAND )
+    : SwUndo( UNDO_DONTEXPAND, rPos.GetDoc() )
     , m_nNodeIndex( rPos.nNode.GetIndex() )
     , m_nContentIndex( rPos.nContent.GetIndex() )
 {
diff --git a/sw/source/core/undo/unbkmk.cxx b/sw/source/core/undo/unbkmk.cxx
index ef0ad13..ae96d7c 100644
--- a/sw/source/core/undo/unbkmk.cxx
+++ b/sw/source/core/undo/unbkmk.cxx
@@ -33,7 +33,7 @@
 
 SwUndoBookmark::SwUndoBookmark( SwUndoId nUndoId,
             const ::sw::mark::IMark& rBkmk )
-    : SwUndo( nUndoId )
+    : SwUndo( nUndoId, rBkmk.GetMarkPos().GetDoc() )
     , m_pHistoryBookmark(new SwHistoryBookmark(rBkmk, true, rBkmk.IsExpanded()))
 {
 }
@@ -101,8 +101,8 @@ void SwUndoDeleteBookmark::RedoImpl(::sw::UndoRedoContext & rContext)
     ResetInDoc( &rContext.GetDoc() );
 }
 
-SwUndoRenameBookmark::SwUndoRenameBookmark( const OUString& rOldName, const OUString& rNewName )
-    : SwUndo( UNDO_BOOKMARK_RENAME )
+SwUndoRenameBookmark::SwUndoRenameBookmark( const OUString& rOldName, const OUString& rNewName, const SwDoc* pDoc )
+    : SwUndo( UNDO_BOOKMARK_RENAME, pDoc )
     , m_sOldName( rOldName )
     , m_sNewName( rNewName )
 {
diff --git a/sw/source/core/undo/undel.cxx b/sw/source/core/undo/undel.cxx
index cfc19be..c78901a 100644
--- a/sw/source/core/undo/undel.cxx
+++ b/sw/source/core/undo/undel.cxx
@@ -97,7 +97,7 @@ SwUndoDelete::SwUndoDelete(
     SwPaM& rPam,
     bool bFullPara,
     bool bCalledByTableCpy )
-    : SwUndo(UNDO_DELETE),
+    : SwUndo(UNDO_DELETE, rPam.GetDoc()),
     SwUndRng( rPam ),
     m_pMvStt( nullptr ),
     m_pSttStr(nullptr),
diff --git a/sw/source/core/undo/undobj.cxx b/sw/source/core/undo/undobj.cxx
index 03e439e..227d3fe 100644
--- a/sw/source/core/undo/undobj.cxx
+++ b/sw/source/core/undo/undobj.cxx
@@ -40,6 +40,7 @@
 #include <undo.hrc>
 #include <comcore.hrc>
 #include <docsh.hxx>
+#include <view.hxx>
 #include <o3tl/make_unique.hxx>
 
 // This class saves the Pam as integers and can recompose those into a PaM
@@ -156,12 +157,26 @@ void SwUndo::RemoveIdxRel( sal_uLong nIdx, const SwPosition& rPos )
     ::PaMCorrRel( aIdx, rPos );
 }
 
-SwUndo::SwUndo(SwUndoId const nId)
+SwUndo::SwUndo(SwUndoId const nId, const SwDoc* pDoc)
     : m_nId(nId), nOrigRedlineMode(nsRedlineMode_t::REDLINE_NONE),
+      m_nViewShellId(CreateViewShellId(pDoc)),
       bCacheComment(true), pComment(nullptr)
 {
 }
 
+sal_Int32 SwUndo::CreateViewShellId(const SwDoc* pDoc)
+{
+    sal_Int32 nRet = -1;
+
+    if (const SwDocShell* pDocShell = pDoc->GetDocShell())
+    {
+        if (const SwView* pView = pDocShell->GetView())
+            nRet = pView->GetViewShellId();
+    }
+
+    return nRet;
+}
+
 bool SwUndo::IsDelBox() const
 {
     return GetId() == UNDO_COL_DELETE || GetId() == UNDO_ROW_DELETE ||
@@ -281,6 +296,11 @@ OUString SwUndo::GetComment() const
     return aResult;
 }
 
+sal_Int32 SwUndo::GetViewShellId() const
+{
+    return m_nViewShellId;
+}
+
 SwRewriter SwUndo::GetRewriter() const
 {
     SwRewriter aResult;
diff --git a/sw/source/core/undo/undobj1.cxx b/sw/source/core/undo/undobj1.cxx
index 5197045..659bf87 100644
--- a/sw/source/core/undo/undobj1.cxx
+++ b/sw/source/core/undo/undobj1.cxx
@@ -40,7 +40,7 @@
 #include <ndole.hxx>
 
 SwUndoFlyBase::SwUndoFlyBase( SwFrameFormat* pFormat, SwUndoId nUndoId )
-    : SwUndo(nUndoId)
+    : SwUndo(nUndoId, pFormat->GetDoc())
     , pFrameFormat(pFormat)
     , nNdPgPos(0)
     , nCntPos(0)
@@ -454,7 +454,7 @@ void SwUndoDelLayFormat::RedoForRollback()
 }
 
 SwUndoSetFlyFormat::SwUndoSetFlyFormat( SwFrameFormat& rFlyFormat, SwFrameFormat& rNewFrameFormat )
-    : SwUndo( UNDO_SETFLYFRMFMT ), SwClient( &rFlyFormat ), pFrameFormat( &rFlyFormat ),
+    : SwUndo( UNDO_SETFLYFRMFMT, rFlyFormat.GetDoc() ), SwClient( &rFlyFormat ), pFrameFormat( &rFlyFormat ),
     pOldFormat( static_cast<SwFrameFormat*>(rFlyFormat.DerivedFrom()) ), pNewFormat( &rNewFrameFormat ),
     pItemSet( new SfxItemSet( *rFlyFormat.GetAttrSet().GetPool(),
                                 rFlyFormat.GetAttrSet().GetRanges() )),
diff --git a/sw/source/core/undo/undoflystrattr.cxx b/sw/source/core/undo/undoflystrattr.cxx
index 76bff54..a15b3c6 100644
--- a/sw/source/core/undo/undoflystrattr.cxx
+++ b/sw/source/core/undo/undoflystrattr.cxx
@@ -25,7 +25,7 @@ SwUndoFlyStrAttr::SwUndoFlyStrAttr( SwFlyFrameFormat& rFlyFrameFormat,
                                     const SwUndoId eUndoId,
                                     const OUString& sOldStr,
                                     const OUString& sNewStr )
-    : SwUndo( eUndoId ),
+    : SwUndo( eUndoId, rFlyFrameFormat.GetDoc() ),
       mrFlyFrameFormat( rFlyFrameFormat ),
       msOldStr( sOldStr ),
       msNewStr( sNewStr )
diff --git a/sw/source/core/undo/undraw.cxx b/sw/source/core/undo/undraw.cxx
index ba52ed4..22a9642 100644
--- a/sw/source/core/undo/undraw.cxx
+++ b/sw/source/core/undo/undraw.cxx
@@ -69,14 +69,14 @@ IMPL_LINK_TYPED( SwDoc, AddDrawUndo, SdrUndoAction *, pUndo, void )
         if( pSh && pSh->HasDrawView() )
             pMarkList = &pSh->GetDrawView()->GetMarkedObjectList();
 
-        GetIDocumentUndoRedo().AppendUndo( new SwSdrUndo(pUndo, pMarkList) );
+        GetIDocumentUndoRedo().AppendUndo( new SwSdrUndo(pUndo, pMarkList, this) );
     }
     else
         delete pUndo;
 }
 
-SwSdrUndo::SwSdrUndo( SdrUndoAction* pUndo, const SdrMarkList* pMrkLst )
-    : SwUndo( UNDO_DRAWUNDO ), pSdrUndo( pUndo )
+SwSdrUndo::SwSdrUndo( SdrUndoAction* pUndo, const SdrMarkList* pMrkLst, const SwDoc* pDoc )
+    : SwUndo( UNDO_DRAWUNDO, pDoc ), pSdrUndo( pUndo )
 {
     if( pMrkLst && pMrkLst->GetMarkCount() )
         pMarkList = new SdrMarkList( *pMrkLst );
@@ -184,8 +184,8 @@ static void lcl_RestoreAnchor( SwFrameFormat* pFormat, sal_uLong& rNodePos )
     }
 }
 
-SwUndoDrawGroup::SwUndoDrawGroup( sal_uInt16 nCnt )
-    : SwUndo( UNDO_DRAWGROUP ), nSize( nCnt + 1 ), bDelFormat( true )
+SwUndoDrawGroup::SwUndoDrawGroup( sal_uInt16 nCnt, const SwDoc* pDoc )
+    : SwUndo( UNDO_DRAWGROUP, pDoc ), nSize( nCnt + 1 ), bDelFormat( true )
 {
     pObjArr = new SwUndoGroupObjImpl[ nSize ];
 }
@@ -320,8 +320,8 @@ void SwUndoDrawGroup::SetGroupFormat( SwDrawFrameFormat* pFormat )
     pObjArr->pFormat = pFormat;
 }
 
-SwUndoDrawUnGroup::SwUndoDrawUnGroup( SdrObjGroup* pObj )
-    : SwUndo( UNDO_DRAWUNGROUP ), bDelFormat( false )
+SwUndoDrawUnGroup::SwUndoDrawUnGroup( SdrObjGroup* pObj, const SwDoc* pDoc )
+    : SwUndo( UNDO_DRAWUNGROUP, pDoc ), bDelFormat( false )
 {
     nSize = (sal_uInt16)pObj->GetSubList()->GetObjCount() + 1;
     pObjArr = new SwUndoGroupObjImpl[ nSize ];
@@ -445,8 +445,8 @@ void SwUndoDrawUnGroup::AddObj( sal_uInt16 nPos, SwDrawFrameFormat* pFormat )
     rSave.pObj = nullptr;
 }
 
-SwUndoDrawUnGroupConnectToLayout::SwUndoDrawUnGroupConnectToLayout()
-    : SwUndo( UNDO_DRAWUNGROUP )
+SwUndoDrawUnGroupConnectToLayout::SwUndoDrawUnGroupConnectToLayout(const SwDoc* pDoc)
+    : SwUndo( UNDO_DRAWUNGROUP, pDoc )
 {
 }
 
@@ -493,8 +493,8 @@ void SwUndoDrawUnGroupConnectToLayout::AddFormatAndObj( SwDrawFrameFormat* pDraw
             std::pair< SwDrawFrameFormat*, SdrObject* >( pDrawFrameFormat, pDrawObject ) );
 }
 
-SwUndoDrawDelete::SwUndoDrawDelete( sal_uInt16 nCnt )
-    : SwUndo( UNDO_DRAWDELETE ), nSize( nCnt ), bDelFormat( true )
+SwUndoDrawDelete::SwUndoDrawDelete( sal_uInt16 nCnt, const SwDoc* pDoc )
+    : SwUndo( UNDO_DRAWDELETE, pDoc ), nSize( nCnt ), bDelFormat( true )
 {
     pObjArr = new SwUndoGroupObjImpl[ nSize ];
     pMarkLst = new SdrMarkList();
diff --git a/sw/source/core/undo/unfmco.cxx b/sw/source/core/undo/unfmco.cxx
index c69f50b..5aeaf87 100644
--- a/sw/source/core/undo/unfmco.cxx
+++ b/sw/source/core/undo/unfmco.cxx
@@ -29,7 +29,7 @@ SwUndoFormatColl::SwUndoFormatColl( const SwPaM& rRange,
                               SwFormatColl* pColl,
                               const bool bReset,
                               const bool bResetListAttrs )
-    : SwUndo( UNDO_SETFMTCOLL ),
+    : SwUndo( UNDO_SETFMTCOLL, rRange.GetDoc() ),
       SwUndRng( rRange ),
       pHistory( new SwHistory ),
       pFormatColl( pColl ),
diff --git a/sw/source/core/undo/unins.cxx b/sw/source/core/undo/unins.cxx
index f105bbc..02bb04d 100644
--- a/sw/source/core/undo/unins.cxx
+++ b/sw/source/core/undo/unins.cxx
@@ -110,7 +110,7 @@ SwUndoInsert::SwUndoInsert( const SwNodeIndex& rNd, sal_Int32 nCnt,
             sal_Int32 nL,
             const SwInsertFlags nInsertFlags,
             bool bWDelim )
-    : SwUndo(UNDO_TYPING), pText( nullptr ), pRedlData( nullptr ),
+    : SwUndo(UNDO_TYPING, rNd.GetNode().GetDoc()), pText( nullptr ), pRedlData( nullptr ),
         nNode( rNd.GetIndex() ), nContent(nCnt), nLen(nL),
         bIsWordDelim( bWDelim ), bIsAppend( false )
     , m_bWithRsid(false)
@@ -120,7 +120,7 @@ SwUndoInsert::SwUndoInsert( const SwNodeIndex& rNd, sal_Int32 nCnt,
 }
 
 SwUndoInsert::SwUndoInsert( const SwNodeIndex& rNd )
-    : SwUndo(UNDO_SPLITNODE), pText( nullptr ),
+    : SwUndo(UNDO_SPLITNODE, rNd.GetNode().GetDoc()), pText( nullptr ),
         pRedlData( nullptr ), nNode( rNd.GetIndex() ), nContent(0), nLen(1),
         bIsWordDelim( false ), bIsAppend( true )
     , m_bWithRsid(false)
@@ -509,7 +509,7 @@ public:
 
 SwUndoReplace::SwUndoReplace(SwPaM const& rPam,
         OUString const& rIns, bool const bRegExp)
-    : SwUndo( UNDO_REPLACE )
+    : SwUndo( UNDO_REPLACE, rPam.GetDoc() )
     , m_pImpl(o3tl::make_unique<Impl>(rPam, rIns, bRegExp))
 {
 }
@@ -786,7 +786,7 @@ void SwUndoReplace::Impl::SetEnd(SwPaM const& rPam)
 }
 
 SwUndoReRead::SwUndoReRead( const SwPaM& rPam, const SwGrfNode& rGrfNd )
-    : SwUndo( UNDO_REREAD ), nPos( rPam.GetPoint()->nNode.GetIndex() )
+    : SwUndo( UNDO_REREAD, rPam.GetDoc() ), nPos( rPam.GetPoint()->nNode.GetIndex() )
 {
     SaveGraphicData( rGrfNd );
 }
@@ -866,8 +866,9 @@ SwUndoInsertLabel::SwUndoInsertLabel( const SwLabelType eTyp,
                                       const bool bBef,
                                       const sal_uInt16 nInitId,
                                       const OUString& rCharacterStyle,
-                                      const bool bCpyBorder )
-    : SwUndo( UNDO_INSERTLABEL ),
+                                      const bool bCpyBorder,
+                                      const SwDoc* pDoc )
+    : SwUndo( UNDO_INSERTLABEL, pDoc ),
       sText( rText ),
       sSeparator( rSeparator ),
       sNumberSeparator( rNumberSeparator ),//#i61007# order of captions
diff --git a/sw/source/core/undo/unmove.cxx b/sw/source/core/undo/unmove.cxx
index 5d6f7c6..439e61c 100644
--- a/sw/source/core/undo/unmove.cxx
+++ b/sw/source/core/undo/unmove.cxx
@@ -28,7 +28,7 @@
 
 // MOVE
 SwUndoMove::SwUndoMove( const SwPaM& rRange, const SwPosition& rMvPos )
-    : SwUndo( UNDO_MOVE )
+    : SwUndo( UNDO_MOVE, rRange.GetDoc() )
     , SwUndRng( rRange )
     , nDestSttNode(0)
     , nDestEndNode(0)
@@ -95,7 +95,7 @@ SwUndoMove::SwUndoMove( const SwPaM& rRange, const SwPosition& rMvPos )
 
 SwUndoMove::SwUndoMove( SwDoc* pDoc, const SwNodeRange& rRg,
                         const SwNodeIndex& rMvPos )
-    : SwUndo(UNDO_MOVE)
+    : SwUndo(UNDO_MOVE, pDoc)
     , nDestSttNode(0)
     , nDestEndNode(0)
     , nInsPosNode(0)
diff --git a/sw/source/core/undo/unnum.cxx b/sw/source/core/undo/unnum.cxx
index fc9ede2..7a69b29 100644
--- a/sw/source/core/undo/unnum.cxx
+++ b/sw/source/core/undo/unnum.cxx
@@ -30,15 +30,16 @@
 
 SwUndoInsNum::SwUndoInsNum( const SwNumRule& rOldRule,
                             const SwNumRule& rNewRule,
-                            SwUndoId nUndoId )
-    : SwUndo( nUndoId ),
+                            const SwDoc* pDoc,
+                            SwUndoId nUndoId)
+    : SwUndo( nUndoId, pDoc ),
     aNumRule( rNewRule ), pHistory( nullptr ), nSttSet( ULONG_MAX ),
     pOldNumRule( new SwNumRule( rOldRule )), nLRSavePos( 0 )
 {
 }
 
 SwUndoInsNum::SwUndoInsNum( const SwPaM& rPam, const SwNumRule& rRule )
-    : SwUndo( UNDO_INSNUM ), SwUndRng( rPam ),
+    : SwUndo( UNDO_INSNUM, rPam.GetDoc() ), SwUndRng( rPam ),
     aNumRule( rRule ), pHistory( nullptr ),
     nSttSet( ULONG_MAX ), pOldNumRule( nullptr ), nLRSavePos( 0 )
 {
@@ -46,7 +47,7 @@ SwUndoInsNum::SwUndoInsNum( const SwPaM& rPam, const SwNumRule& rRule )
 
 SwUndoInsNum::SwUndoInsNum( const SwPosition& rPos, const SwNumRule& rRule,
                             const OUString& rReplaceRule )
-    : SwUndo( UNDO_INSNUM ),
+    : SwUndo( UNDO_INSNUM, rPos.nNode.GetNode().GetDoc() ),
     aNumRule( rRule ), pHistory( nullptr ),
     nSttSet( ULONG_MAX ), pOldNumRule( nullptr ),
     sReplaceRule( rReplaceRule ), nLRSavePos( 0 )
@@ -162,7 +163,7 @@ void SwUndoInsNum::SaveOldNumRule( const SwNumRule& rOld )
 }
 
 SwUndoDelNum::SwUndoDelNum( const SwPaM& rPam )
-    : SwUndo( UNDO_DELNUM ), SwUndRng( rPam )
+    : SwUndo( UNDO_DELNUM, rPam.GetDoc() ), SwUndRng( rPam )
 {
     aNodes.reserve( nEndNode - nSttNode > 255 ? 255 : nEndNode - nSttNode );
     pHistory = new SwHistory;
@@ -213,7 +214,7 @@ void SwUndoDelNum::AddNode( const SwTextNode& rNd )
 }
 
 SwUndoMoveNum::SwUndoMoveNum( const SwPaM& rPam, long nOff, bool bIsOutlMv )
-    : SwUndo( bIsOutlMv ? UNDO_OUTLINE_UD : UNDO_MOVENUM ),
+    : SwUndo( bIsOutlMv ? UNDO_OUTLINE_UD : UNDO_MOVENUM, rPam.GetDoc() ),
     SwUndRng( rPam ),
     nNewStt( 0 ), nOffset( nOff )
 {
@@ -262,7 +263,8 @@ void SwUndoMoveNum::RepeatImpl(::sw::RepeatContext & rContext)
 }
 
 SwUndoNumUpDown::SwUndoNumUpDown( const SwPaM& rPam, short nOff )
-    : SwUndo( nOff > 0 ? UNDO_NUMUP : UNDO_NUMDOWN ), SwUndRng( rPam ),
+    : SwUndo( nOff > 0 ? UNDO_NUMUP : UNDO_NUMDOWN, rPam.GetDoc() ),
+      SwUndRng( rPam ),
       nOffset( nOff )
 {
     // nOffset: Down    =>  1
@@ -288,7 +290,8 @@ void SwUndoNumUpDown::RepeatImpl(::sw::RepeatContext & rContext)
 
 SwUndoNumOrNoNum::SwUndoNumOrNoNum( const SwNodeIndex& rIdx, bool bOldNum,
                                     bool bNewNum)
-    : SwUndo( UNDO_NUMORNONUM ), nIdx( rIdx.GetIndex() ), mbNewNum(bNewNum),
+    : SwUndo( UNDO_NUMORNONUM, rIdx.GetNode().GetDoc() ),
+      nIdx( rIdx.GetIndex() ), mbNewNum(bNewNum),
       mbOldNum(bOldNum)
 {
 }
@@ -331,14 +334,14 @@ void SwUndoNumOrNoNum::RepeatImpl(::sw::RepeatContext & rContext)
 }
 
 SwUndoNumRuleStart::SwUndoNumRuleStart( const SwPosition& rPos, bool bFlg )
-    : SwUndo( UNDO_SETNUMRULESTART ),
+    : SwUndo( UNDO_SETNUMRULESTART, rPos.GetDoc() ),
     nIdx( rPos.nNode.GetIndex() ), nOldStt( USHRT_MAX ),
     nNewStt( USHRT_MAX ), bSetSttValue( false ), bFlag( bFlg )
 {
 }
 
 SwUndoNumRuleStart::SwUndoNumRuleStart( const SwPosition& rPos, sal_uInt16 nStt )
-    : SwUndo(UNDO_SETNUMRULESTART)
+    : SwUndo(UNDO_SETNUMRULESTART, rPos.GetDoc())
     , nIdx(rPos.nNode.GetIndex())
     , nOldStt(USHRT_MAX)
     , nNewStt(nStt)
diff --git a/sw/source/core/undo/unoutl.cxx b/sw/source/core/undo/unoutl.cxx
index d01baaa..d457328 100644
--- a/sw/source/core/undo/unoutl.cxx
+++ b/sw/source/core/undo/unoutl.cxx
@@ -26,7 +26,7 @@
 
 SwUndoOutlineLeftRight::SwUndoOutlineLeftRight( const SwPaM& rPam,
                                                 short nOff )
-    : SwUndo( UNDO_OUTLINE_LR ), SwUndRng( rPam ), nOffset( nOff )
+    : SwUndo( UNDO_OUTLINE_LR, rPam.GetDoc() ), SwUndRng( rPam ), nOffset( nOff )
 {
 }
 
diff --git a/sw/source/core/undo/unovwr.cxx b/sw/source/core/undo/unovwr.cxx
index 25c178b..a64586a 100644
--- a/sw/source/core/undo/unovwr.cxx
+++ b/sw/source/core/undo/unovwr.cxx
@@ -42,7 +42,7 @@ using namespace ::com::sun::star::uno;
 
 SwUndoOverwrite::SwUndoOverwrite( SwDoc* pDoc, SwPosition& rPos,
                                     sal_Unicode cIns )
-    : SwUndo(UNDO_OVERWRITE),
+    : SwUndo(UNDO_OVERWRITE, pDoc),
       pRedlSaveData( nullptr ), bGroup( false )
 {
     if( !pDoc->getIDocumentRedlineAccess().IsIgnoreRedline() && !pDoc->getIDocumentRedlineAccess().GetRedlineTable().empty() )
@@ -343,7 +343,7 @@ struct UndoTransliterate_Data
 SwUndoTransliterate::SwUndoTransliterate(
     const SwPaM& rPam,
     const utl::TransliterationWrapper& rTrans )
-    : SwUndo( UNDO_TRANSLITERATE ), SwUndRng( rPam ), nType( rTrans.getType() )
+    : SwUndo( UNDO_TRANSLITERATE, rPam.GetDoc() ), SwUndRng( rPam ), nType( rTrans.getType() )
 {
 }
 
diff --git a/sw/source/core/undo/unredln.cxx b/sw/source/core/undo/unredln.cxx
index 9e4c7e7..3448130 100644
--- a/sw/source/core/undo/unredln.cxx
+++ b/sw/source/core/undo/unredln.cxx
@@ -34,7 +34,7 @@
 #include <docedt.hxx>
 
 SwUndoRedline::SwUndoRedline( SwUndoId nUsrId, const SwPaM& rRange )
-    : SwUndo( UNDO_REDLINE ), SwUndRng( rRange ),
+    : SwUndo( UNDO_REDLINE, rRange.GetDoc() ), SwUndRng( rRange ),
     mpRedlData( nullptr ), mpRedlSaveData( nullptr ), mnUserId( nUsrId ),
     mbHiddenRedlines( false )
 {
@@ -355,7 +355,7 @@ void SwUndoRejectRedline::RepeatImpl(::sw::RepeatContext & rContext)
 }
 
 SwUndoCompDoc::SwUndoCompDoc( const SwPaM& rRg, bool bIns )
-    : SwUndo( UNDO_COMPAREDOC ), SwUndRng( rRg ), pRedlData( nullptr ),
+    : SwUndo( UNDO_COMPAREDOC, rRg.GetDoc() ), SwUndRng( rRg ), pRedlData( nullptr ),
     pUnDel( nullptr ), pUnDel2( nullptr ), pRedlSaveData( nullptr ), bInsert( bIns )
 {
     SwDoc* pDoc = rRg.GetDoc();
@@ -368,7 +368,7 @@ SwUndoCompDoc::SwUndoCompDoc( const SwPaM& rRg, bool bIns )
 }
 
 SwUndoCompDoc::SwUndoCompDoc( const SwRangeRedline& rRedl )
-    : SwUndo( UNDO_COMPAREDOC ), SwUndRng( rRedl ), pRedlData( nullptr ),
+    : SwUndo( UNDO_COMPAREDOC, rRedl.GetDoc() ), SwUndRng( rRedl ), pRedlData( nullptr ),
     pUnDel( nullptr ), pUnDel2( nullptr ), pRedlSaveData( nullptr ),
     // for MergeDoc the corresponding inverse is needed
     bInsert( nsRedlineType_t::REDLINE_DELETE == rRedl.GetType() )
diff --git a/sw/source/core/undo/unsect.cxx b/sw/source/core/undo/unsect.cxx
index 06097f7..c010369 100644
--- a/sw/source/core/undo/unsect.cxx
+++ b/sw/source/core/undo/unsect.cxx
@@ -70,7 +70,7 @@ static SfxItemSet* lcl_GetAttrSet( const SwSection& rSect )
 SwUndoInsSection::SwUndoInsSection(
         SwPaM const& rPam, SwSectionData const& rNewData,
         SfxItemSet const*const pSet, SwTOXBase const*const pTOXBase)
-    : SwUndo( UNDO_INSSECTION ), SwUndRng( rPam )
+    : SwUndo( UNDO_INSSECTION, rPam.GetDoc() ), SwUndRng( rPam )
     , m_pSectionData(new SwSectionData(rNewData))
     , m_pTOXBase( (pTOXBase) ? new SwTOXBase(*pTOXBase) : nullptr )
     , m_pAttrSet( (pSet && pSet->Count()) ? new SfxItemSet( *pSet ) : nullptr )
@@ -303,7 +303,7 @@ SwUndo * MakeUndoDelSection(SwSectionFormat const& rFormat)
 SwUndoDelSection::SwUndoDelSection(
             SwSectionFormat const& rSectionFormat, SwSection const& rSection,
             SwNodeIndex const*const pIndex)
-    : SwUndo( UNDO_DELSECTION )
+    : SwUndo( UNDO_DELSECTION, rSectionFormat.GetDoc() )
     , m_pSectionData( new SwSectionData(rSection) )
     , m_pTOXBase( dynamic_cast<const SwTOXBaseSection*>( &rSection) !=  nullptr
             ? new SwTOXBase(static_cast<SwTOXBaseSection const&>(rSection))
@@ -412,7 +412,7 @@ MakeUndoUpdateSection(SwSectionFormat const& rFormat, bool const bOnlyAttr)
 SwUndoUpdateSection::SwUndoUpdateSection(
         SwSection const& rSection, SwNodeIndex const*const pIndex,
         bool const bOnlyAttr)
-    : SwUndo( UNDO_CHGSECTION )
+    : SwUndo( UNDO_CHGSECTION, pIndex->GetNode().GetDoc() )
     , m_pSectionData( new SwSectionData(rSection) )
     , m_pAttrSet( ::lcl_GetAttrSet(rSection) )
     , m_nStartNode( pIndex->GetIndex() )
diff --git a/sw/source/core/undo/unsort.cxx b/sw/source/core/undo/unsort.cxx
index 1f62d42..903c42b 100644
--- a/sw/source/core/undo/unsort.cxx
+++ b/sw/source/core/undo/unsort.cxx
@@ -42,7 +42,7 @@ SwSortUndoElement::~SwSortUndoElement()
 }
 
 SwUndoSort::SwUndoSort(const SwPaM& rRg, const SwSortOptions& rOpt)
-    : SwUndo(UNDO_SORT_TXT)
+    : SwUndo(UNDO_SORT_TXT, rRg.GetDoc())
     , SwUndRng(rRg)
     , pUndoTableAttr(nullptr)
     , nTableNd(0)
@@ -52,7 +52,7 @@ SwUndoSort::SwUndoSort(const SwPaM& rRg, const SwSortOptions& rOpt)
 
 SwUndoSort::SwUndoSort( sal_uLong nStt, sal_uLong nEnd, const SwTableNode& rTableNd,
                         const SwSortOptions& rOpt, bool bSaveTable )
-    : SwUndo(UNDO_SORT_TBL), pUndoTableAttr( nullptr )
+    : SwUndo(UNDO_SORT_TBL, rTableNd.GetDoc()), pUndoTableAttr( nullptr )
 {
     nSttNode = nStt;
     nEndNode = nEnd;
diff --git a/sw/source/core/undo/unspnd.cxx b/sw/source/core/undo/unspnd.cxx
index 7f6e3a7..3cdd941 100644
--- a/sw/source/core/undo/unspnd.cxx
+++ b/sw/source/core/undo/unspnd.cxx
@@ -37,7 +37,7 @@
 
 SwUndoSplitNode::SwUndoSplitNode( SwDoc* pDoc, const SwPosition& rPos,
                                     bool bChkTable )
-    : SwUndo( UNDO_SPLITNODE ), pHistory( nullptr ), pRedlData( nullptr ), nNode( rPos.nNode.GetIndex() ),
+    : SwUndo( UNDO_SPLITNODE, pDoc ), pHistory( nullptr ), pRedlData( nullptr ), nNode( rPos.nNode.GetIndex() ),
         nContent( rPos.nContent.GetIndex() ),
         bTableFlag( false ), bChkTableStt( bChkTable )
 {
diff --git a/sw/source/core/undo/untbl.cxx b/sw/source/core/undo/untbl.cxx
index e270b8c4..ffabd81 100644
--- a/sw/source/core/undo/untbl.cxx
+++ b/sw/source/core/undo/untbl.cxx
@@ -219,7 +219,7 @@ SwUndoInsTable::SwUndoInsTable( const SwPosition& rPos, sal_uInt16 nCl, sal_uInt
                             const SwTableAutoFormat* pTAFormat,
                             const std::vector<sal_uInt16> *pColArr,
                             const OUString & rName)
-    : SwUndo( UNDO_INSTABLE ),
+    : SwUndo( UNDO_INSTABLE, rPos.GetDoc() ),
     aInsTableOpts( rInsTableOpts ), pDDEFieldType( nullptr ), pColWidth( nullptr ), pRedlData( nullptr ), pAutoFormat( nullptr ),
     nSttNode( rPos.nNode.GetIndex() ), nRows( nRw ), nCols( nCl ), nAdjust( nAdj )
 {
@@ -396,7 +396,7 @@ SwTableToTextSave::SwTableToTextSave( SwDoc& rDoc, sal_uLong nNd, sal_uLong nEnd
 }
 
 SwUndoTableToText::SwUndoTableToText( const SwTable& rTable, sal_Unicode cCh )
-    : SwUndo( UNDO_TABLETOTEXT ),
+    : SwUndo( UNDO_TABLETOTEXT, rTable.GetFrameFormat()->GetDoc() ),
     sTableNm( rTable.GetFrameFormat()->GetName() ), pDDEFieldType( nullptr ), pHistory( nullptr ),
     nSttNd( 0 ), nEndNd( 0 ),
     cTrenner( cCh ), nHdlnRpt( rTable.GetRowsToRepeat() )
@@ -690,7 +690,7 @@ SwUndoTextToTable::SwUndoTextToTable( const SwPaM& rRg,
                                 const SwInsertTableOptions& rInsTableOpts,
                                 sal_Unicode cCh, sal_uInt16 nAdj,
                                 const SwTableAutoFormat* pAFormat )
-    : SwUndo( UNDO_TEXTTOTABLE ), SwUndRng( rRg ), aInsTableOpts( rInsTableOpts ),
+    : SwUndo( UNDO_TEXTTOTABLE, rRg.GetDoc() ), SwUndRng( rRg ), aInsTableOpts( rInsTableOpts ),
       pDelBoxes( nullptr ), pAutoFormat( nullptr ),
       pHistory( nullptr ), cTrenner( cCh ), nAdjust( nAdj )
 {
@@ -827,7 +827,7 @@ SwHistory& SwUndoTextToTable::GetHistory()
 
 SwUndoTableHeadline::SwUndoTableHeadline( const SwTable& rTable, sal_uInt16 nOldHdl,
                                       sal_uInt16 nNewHdl )
-    : SwUndo( UNDO_TABLEHEADLINE ),
+    : SwUndo( UNDO_TABLEHEADLINE, rTable.GetFrameFormat()->GetDoc() ),
     nOldHeadline( nOldHdl ),
     nNewHeadline( nNewHdl )
 {
@@ -1371,7 +1371,7 @@ void SaveBox::CreateNew( SwTable& rTable, SwTableLine& rParent, SaveTable& rSTab
 
 // UndoObject for attribute changes on table
 SwUndoAttrTable::SwUndoAttrTable( const SwTableNode& rTableNd, bool bClearTabCols )
-    : SwUndo( UNDO_TABLE_ATTR ),
+    : SwUndo( UNDO_TABLE_ATTR, rTableNd.GetDoc() ),
     nSttNode( rTableNd.GetIndex() )
 {
     bClearTabCol = bClearTabCols;
@@ -1409,7 +1409,7 @@ void SwUndoAttrTable::RedoImpl(::sw::UndoRedoContext & rContext)
 // UndoObject for AutoFormat on Table
 SwUndoTableAutoFormat::SwUndoTableAutoFormat( const SwTableNode& rTableNd,
                                     const SwTableAutoFormat& rAFormat )
-    : SwUndo( UNDO_TABLE_AUTOFMT )
+    : SwUndo( UNDO_TABLE_AUTOFMT, rTableNd.GetDoc() )
     , m_TableStyleName(rTableNd.GetTable().GetTableStyleName())
     , nSttNode( rTableNd.GetIndex() )
     , bSaveContentAttr( false )
@@ -1487,7 +1487,7 @@ SwUndoTableNdsChg::SwUndoTableNdsChg( SwUndoId nAction,
                                     const SwTableNode& rTableNd,
                                     long nMn, long nMx,
                                     sal_uInt16 nCnt, bool bFlg, bool bSmHght )
-    : SwUndo( nAction ),
+    : SwUndo( nAction, rTableNd.GetDoc() ),
     nMin( nMn ), nMax( nMx ),
     nSttNode( rTableNd.GetIndex() ), nCurrBox( 0 ),
     nCount( nCnt ), nRelDiff( 0 ), nAbsDiff( 0 ),
@@ -1505,7 +1505,7 @@ SwUndoTableNdsChg::SwUndoTableNdsChg( SwUndoId nAction,
 SwUndoTableNdsChg::SwUndoTableNdsChg( SwUndoId nAction,
                                     const SwSelBoxes& rBoxes,
                                     const SwTableNode& rTableNd )
-    : SwUndo( nAction ),
+    : SwUndo( nAction, rTableNd.GetDoc() ),
     nMin( 0 ), nMax( 0 ),
     nSttNode( rTableNd.GetIndex() ), nCurrBox( 0 ),
     nCount( 0 ), nRelDiff( 0 ), nAbsDiff( 0 ),
@@ -1940,7 +1940,7 @@ void SwUndoTableNdsChg::RedoImpl(::sw::UndoRedoContext & rContext)
 }
 
 SwUndoTableMerge::SwUndoTableMerge( const SwPaM& rTableSel )
-    : SwUndo( UNDO_TABLE_MERGE ), SwUndRng( rTableSel )
+    : SwUndo( UNDO_TABLE_MERGE, rTableSel.GetDoc() ), SwUndRng( rTableSel )
     , m_pMoves(new SwUndoMoves)
     , pHistory(nullptr)
 {
@@ -2157,7 +2157,7 @@ void SwUndoTableMerge::SaveCollection( const SwTableBox& rBox )
 
 SwUndoTableNumFormat::SwUndoTableNumFormat( const SwTableBox& rBox,
                                     const SfxItemSet* pNewSet )
-    : SwUndo(UNDO_TBLNUMFMT)
+    : SwUndo(UNDO_TBLNUMFMT, rBox.GetFrameFormat()->GetDoc())
     , pBoxSet(nullptr)
     , pHistory(nullptr)
     , nFormatIdx(css::util::NumberFormat::TEXT)
@@ -2429,8 +2429,8 @@ UndoTableCpyTable_Entry::~UndoTableCpyTable_Entry()
     delete pBoxNumAttr;
 }
 
-SwUndoTableCpyTable::SwUndoTableCpyTable()
-    : SwUndo( UNDO_TBLCPYTBL )
+SwUndoTableCpyTable::SwUndoTableCpyTable(const SwDoc* pDoc)
+    : SwUndo( UNDO_TBLCPYTBL, pDoc )
     , m_pArr(new SwUndoTableCpyTable_Entries)
     , pInsRowUndo(nullptr)
 {
@@ -2835,8 +2835,8 @@ bool SwUndoTableCpyTable::IsEmpty() const
     return !pInsRowUndo && m_pArr->empty();
 }
 
-SwUndoCpyTable::SwUndoCpyTable()
-    : SwUndo( UNDO_CPYTBL ), pDel( nullptr ), nTableNode( 0 )
+SwUndoCpyTable::SwUndoCpyTable(const SwDoc* pDoc)
+    : SwUndo( UNDO_CPYTBL, pDoc ), pDel( nullptr ), nTableNode( 0 )
 {
 }
 
@@ -2879,7 +2879,7 @@ void SwUndoCpyTable::RedoImpl(::sw::UndoRedoContext & rContext)
 
 SwUndoSplitTable::SwUndoSplitTable( const SwTableNode& rTableNd,
     SwSaveRowSpan* pRowSp, sal_uInt16 eMode, bool bNewSize )
-    : SwUndo( UNDO_SPLIT_TABLE ),
+    : SwUndo( UNDO_SPLIT_TABLE, rTableNd.GetDoc() ),
     nTableNode( rTableNd.GetIndex() ), nOffset( 0 ), mpSaveRowSpan( pRowSp ), pSavTable( nullptr ),
     pHistory( nullptr ), nMode( eMode ), nFormulaEnd( 0 ), bCalcNewSize( bNewSize )
 {
@@ -3010,7 +3010,7 @@ void SwUndoSplitTable::SaveFormula( SwHistory& rHistory )
 SwUndoMergeTable::SwUndoMergeTable( const SwTableNode& rTableNd,
                                 const SwTableNode& rDelTableNd,
                                 bool bWithPrv, sal_uInt16 nMd )
-    : SwUndo( UNDO_MERGE_TABLE ), pSavTable( nullptr ),
+    : SwUndo( UNDO_MERGE_TABLE, rTableNd.GetDoc() ), pSavTable( nullptr ),
     pHistory( nullptr ), nMode( nMd ), bWithPrev( bWithPrv )
 {
     // memorize end node of the last table cell that'll stay in position
diff --git a/sw/source/core/undo/untblk.cxx b/sw/source/core/undo/untblk.cxx
index 762e3d6..50674f8 100644
--- a/sw/source/core/undo/untblk.cxx
+++ b/sw/source/core/undo/untblk.cxx
@@ -33,7 +33,7 @@
 #include <redline.hxx>
 
 SwUndoInserts::SwUndoInserts( SwUndoId nUndoId, const SwPaM& rPam )
-    : SwUndo( nUndoId ), SwUndRng( rPam ),
+    : SwUndo( nUndoId, rPam.GetDoc() ), SwUndRng( rPam ),
     pTextFormatColl( nullptr ), pLastNdColl(nullptr), pFrameFormats( nullptr ), pRedlData( nullptr ),
     bSttWasTextNd( true ), nNdDiff( 0 ), nSetPos( 0 )
 {


More information about the Libreoffice-commits mailing list