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

Caolán McNamara (via logerrit) logerrit at kemper.freedesktop.org
Wed Oct 28 15:55:13 UTC 2020


 sw/source/core/inc/rolbck.hxx  |    1 +
 sw/source/core/undo/rolbck.cxx |   27 +++++++++++++++++----------
 2 files changed, 18 insertions(+), 10 deletions(-)

New commits:
commit 496771a6466d6a48f0bcbd8976df24308e052f38
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Oct 28 10:22:58 2020 +0000
Commit:     Caolán McNamara <caolanm at redhat.com>
CommitDate: Wed Oct 28 16:54:19 2020 +0100

    Related: tdf#98868 split out reusable hunk as function
    
    Change-Id: I7e410ba55f94e87c007acbe1887a022948ef354f
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104925
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/sw/source/core/inc/rolbck.hxx b/sw/source/core/inc/rolbck.hxx
index 295279fd9396..c0506fdf91e6 100644
--- a/sw/source/core/inc/rolbck.hxx
+++ b/sw/source/core/inc/rolbck.hxx
@@ -177,6 +177,7 @@ public:
     virtual void SetInDoc( SwDoc* pDoc, bool bTmpSet ) override;
     bool IsEqual( const SwTOXMark& rCmp ) const;
 
+    static SwTOXType* GetSwTOXType(SwDoc& rDoc, TOXTypes eTOXTypes, const OUString& rTOXName);
 };
 
 class SwHistoryResetText : public SwHistoryHint
diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx
index 54fcd33b6815..dd04451c0d84 100644
--- a/sw/source/core/undo/rolbck.cxx
+++ b/sw/source/core/undo/rolbck.cxx
@@ -376,20 +376,15 @@ SwHistorySetTOXMark::SwHistorySetTOXMark( const SwTextTOXMark* pTextHt, sal_uLon
     static_cast<SvtListener*>(&m_TOXMark)->EndListeningAll();
 }
 
-void SwHistorySetTOXMark::SetInDoc( SwDoc* pDoc, bool )
+SwTOXType* SwHistorySetTOXMark::GetSwTOXType(SwDoc& rDoc, TOXTypes eTOXTypes, const OUString& rTOXName)
 {
-    SwTextNode * pTextNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetTextNode();
-    OSL_ENSURE( pTextNd, "SwHistorySetTOXMark: no TextNode" );
-    if ( !pTextNd )
-        return;
-
     // search for respective TOX type
-    const sal_uInt16 nCnt = pDoc->GetTOXTypeCount( m_eTOXTypes );
+    const sal_uInt16 nCnt = rDoc.GetTOXTypeCount(eTOXTypes);
     SwTOXType* pToxType = nullptr;
     for ( sal_uInt16 n = 0; n < nCnt; ++n )
     {
-        pToxType = const_cast<SwTOXType*>(pDoc->GetTOXType( m_eTOXTypes, n ));
-        if ( pToxType->GetTypeName() == m_TOXName )
+        pToxType = const_cast<SwTOXType*>(rDoc.GetTOXType(eTOXTypes, n));
+        if (pToxType->GetTypeName() == rTOXName)
             break;
         pToxType = nullptr;
     }
@@ -397,9 +392,21 @@ void SwHistorySetTOXMark::SetInDoc( SwDoc* pDoc, bool )
     if ( !pToxType )  // TOX type not found, create new
     {
         pToxType = const_cast<SwTOXType*>(
-                pDoc->InsertTOXType( SwTOXType( m_eTOXTypes, m_TOXName )));
+                rDoc.InsertTOXType(SwTOXType(eTOXTypes, rTOXName)));
     }
 
+    return pToxType;
+}
+
+void SwHistorySetTOXMark::SetInDoc( SwDoc* pDoc, bool )
+{
+    SwTextNode * pTextNd = pDoc->GetNodes()[ m_nNodeIndex ]->GetTextNode();
+    OSL_ENSURE( pTextNd, "SwHistorySetTOXMark: no TextNode" );
+    if ( !pTextNd )
+        return;
+
+    SwTOXType* pToxType = GetSwTOXType(*pDoc, m_eTOXTypes, m_TOXName);
+
     SwTOXMark aNew( m_TOXMark );
     aNew.RegisterToTOXType( *pToxType );
 


More information about the Libreoffice-commits mailing list