sw/inc/tox.hxx                    |    4 +++-
 sw/source/core/doc/docnew.cxx     |   16 ++++++++--------
 sw/source/core/doc/doctxm.cxx     |    2 +-
 sw/source/core/tox/tox.cxx        |    8 +++++---
 sw/source/core/txtnode/atrtox.cxx |    2 +-
 sw/source/core/undo/rolbck.cxx    |    2 +-
 sw/source/core/unocore/unoidx.cxx |    4 ++--
 sw/source/uibase/index/toxmgr.cxx |    2 +-
 8 files changed, 22 insertions(+), 18 deletions(-)

New commits:
commit 60b1f8f6ef715ee4cb282215375188c1511ad6d6
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Wed Oct 28 10:36:47 2020 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Fri Oct 30 13:30:11 2020 +0100

    Related: tdf#98868 add SwDoc& member to SwTOXType
    
    Change-Id: Ic1dc600e75cb4f6a7a0aa86714a87e3ec5658cb0
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104926
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

diff --git a/sw/inc/tox.hxx b/sw/inc/tox.hxx
index fdec079490e8..c7bcaacf036a 100644
--- a/sw/inc/tox.hxx
+++ b/sw/inc/tox.hxx
@@ -175,13 +175,14 @@ public:
 class SwTOXType final: public sw::BroadcastingModify
 {
 public:
-    SwTOXType(TOXTypes eTyp, const OUString& aName);
+    SwTOXType(SwDoc& rDoc, TOXTypes eTyp, const OUString& rName);
 
     // @@@ public copy ctor, but no copy assignment?
     SwTOXType(const SwTOXType& rCopy);
 
     inline const OUString&  GetTypeName() const;
     inline TOXTypes         GetType() const;
+    SwDoc& GetDoc() const { return m_rDoc; }
     void CollectTextMarks(SwTOXMarks& rMarks) const
             { 
const_cast<SwTOXType*>(this)->GetNotifier().Broadcast(sw::CollectTextMarksHint(rMarks));
 }
     SwContentFrame* FindContentFrame(const SwDoc& rDoc, const SwRootFrame& 
rLayout, const bool isReadOnlyAvailable) const
@@ -195,6 +196,7 @@ public:
 
 
 private:
+    SwDoc&          m_rDoc;
     OUString        m_aName;
     TOXTypes        m_eType;
 
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index 54c576830b15..3380b5e6bc15 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -819,21 +819,21 @@ SwDoc::GetXmlIdRegistry()
 void SwDoc::InitTOXTypes()
 {
     ShellResource* pShellRes = SwViewShell::GetShellRes();
-    SwTOXType * pNew = new SwTOXType(TOX_CONTENT,   pShellRes->aTOXContentName 
       );
+    SwTOXType* pNew = new SwTOXType(*this, TOX_CONTENT, 
pShellRes->aTOXContentName);
     mpTOXTypes->emplace_back( pNew );
-    pNew = new SwTOXType(TOX_INDEX,                 pShellRes->aTOXIndexName  
);
+    pNew = new SwTOXType(*this, TOX_INDEX, pShellRes->aTOXIndexName);
     mpTOXTypes->emplace_back( pNew );
-    pNew = new SwTOXType(TOX_USER,                  pShellRes->aTOXUserName  );
+    pNew = new SwTOXType(*this, TOX_USER, pShellRes->aTOXUserName);
     mpTOXTypes->emplace_back( pNew );
-    pNew = new SwTOXType(TOX_ILLUSTRATIONS,         
pShellRes->aTOXIllustrationsName );
+    pNew = new SwTOXType(*this, TOX_ILLUSTRATIONS, 
pShellRes->aTOXIllustrationsName);
     mpTOXTypes->emplace_back( pNew );
-    pNew = new SwTOXType(TOX_OBJECTS,               pShellRes->aTOXObjectsName 
      );
+    pNew = new SwTOXType(*this, TOX_OBJECTS, pShellRes->aTOXObjectsName);
     mpTOXTypes->emplace_back( pNew );
-    pNew = new SwTOXType(TOX_TABLES,                pShellRes->aTOXTablesName  
      );
+    pNew = new SwTOXType(*this, TOX_TABLES, pShellRes->aTOXTablesName);
     mpTOXTypes->emplace_back( pNew );
-    pNew = new SwTOXType(TOX_AUTHORITIES,           
pShellRes->aTOXAuthoritiesName   );
+    pNew = new SwTOXType(*this, TOX_AUTHORITIES, 
pShellRes->aTOXAuthoritiesName);
     mpTOXTypes->emplace_back( pNew );
-    pNew = new SwTOXType(TOX_CITATION,           pShellRes->aTOXCitationName   
);
+    pNew = new SwTOXType(*this, TOX_CITATION, pShellRes->aTOXCitationName);
     mpTOXTypes->emplace_back( pNew );
 }
 
diff --git a/sw/source/core/doc/doctxm.cxx b/sw/source/core/doc/doctxm.cxx
index f45b7b2be8b5..5642224b083f 100644
--- a/sw/source/core/doc/doctxm.cxx
+++ b/sw/source/core/doc/doctxm.cxx
@@ -628,7 +628,7 @@ const SwTOXType* SwDoc::GetTOXType( TOXTypes eTyp, 
sal_uInt16 nId ) const
 
 const SwTOXType* SwDoc::InsertTOXType( const SwTOXType& rTyp )
 {
-    SwTOXType * pNew = new SwTOXType( rTyp );
+    SwTOXType * pNew = new SwTOXType(rTyp);
     mpTOXTypes->emplace_back( pNew );
     return pNew;
 }
diff --git a/sw/source/core/tox/tox.cxx b/sw/source/core/tox/tox.cxx
index 149a305a348a..0f9526488cb8 100644
--- a/sw/source/core/tox/tox.cxx
+++ b/sw/source/core/tox/tox.cxx
@@ -210,14 +210,16 @@ OUString SwTOXMark::GetText(SwRootFrame const*const 
pLayout) const
 }
 
 // Manage types of TOX
-SwTOXType::SwTOXType(TOXTypes eTyp, const OUString& rName)
-    : m_aName(rName)
+SwTOXType::SwTOXType(SwDoc& rDoc, TOXTypes eTyp, const OUString& rName)
+    : m_rDoc(rDoc)
+    , m_aName(rName)
     , m_eType(eTyp)
 {
 }
 
 SwTOXType::SwTOXType(const SwTOXType& rCopy)
-    : m_aName(rCopy.m_aName)
+    : m_rDoc(rCopy.m_rDoc)
+    , m_aName(rCopy.m_aName)
     , m_eType(rCopy.m_eType)
 {
     if (auto pRegisteredIn = const_cast<SwTOXType&>(rCopy).GetRegisteredIn())
diff --git a/sw/source/core/txtnode/atrtox.cxx 
b/sw/source/core/txtnode/atrtox.cxx
index d5c862b38d1e..664ce55968ad 100644
--- a/sw/source/core/txtnode/atrtox.cxx
+++ b/sw/source/core/txtnode/atrtox.cxx
@@ -79,7 +79,7 @@ void SwTextTOXMark::CopyTOXMark( SwDoc& rDoc )
     // if the requested tox type does not exist, create it
     if(!pType)
     {
-        rDoc.InsertTOXType( SwTOXType( eType, rNm ) );
+        rDoc.InsertTOXType( SwTOXType( rDoc, eType, rNm ) );
         pType = rDoc.GetTOXType(eType, 0);
     }
 
diff --git a/sw/source/core/undo/rolbck.cxx b/sw/source/core/undo/rolbck.cxx
index dd04451c0d84..f7e8a968a6ef 100644
--- a/sw/source/core/undo/rolbck.cxx
+++ b/sw/source/core/undo/rolbck.cxx
@@ -392,7 +392,7 @@ SwTOXType* SwHistorySetTOXMark::GetSwTOXType(SwDoc& rDoc, 
TOXTypes eTOXTypes, co
     if ( !pToxType )  // TOX type not found, create new
     {
         pToxType = const_cast<SwTOXType*>(
-                rDoc.InsertTOXType(SwTOXType(eTOXTypes, rTOXName)));
+                rDoc.InsertTOXType(SwTOXType(rDoc, eTOXTypes, rTOXName)));
     }
 
     return pToxType;
diff --git a/sw/source/core/unocore/unoidx.cxx 
b/sw/source/core/unocore/unoidx.cxx
index 442527ef454b..bb0782e07cfc 100644
--- a/sw/source/core/unocore/unoidx.cxx
+++ b/sw/source/core/unocore/unoidx.cxx
@@ -113,7 +113,7 @@ lcl_ReAssignTOXType(SwDoc& rDoc, SwTOXBase& rTOXBase, const 
OUString& rNewName)
     }
     if(!pNewType)
     {
-        SwTOXType aNewType(TOX_USER, rNewName);
+        SwTOXType aNewType(rDoc, TOX_USER, rNewName);
         pNewType = rDoc.InsertTOXType( aNewType );
     }
 
@@ -1814,7 +1814,7 @@ SwXDocumentIndexMark::attach(
                 }
                 if (!pTOXType)
                 {
-                    SwTOXType aUserType(TOX_USER, m_pImpl->m_sUserIndexName);
+                    SwTOXType aUserType(*pDoc, TOX_USER, 
m_pImpl->m_sUserIndexName);
                     pTOXType = pDoc->InsertTOXType(aUserType);
                 }
             }
diff --git a/sw/source/uibase/index/toxmgr.cxx 
b/sw/source/uibase/index/toxmgr.cxx
index 53223fc91ff1..4e7e65f9c4d0 100644
--- a/sw/source/uibase/index/toxmgr.cxx
+++ b/sw/source/uibase/index/toxmgr.cxx
@@ -227,7 +227,7 @@ sal_uInt16 SwTOXMgr::GetUserTypeID(const OUString& rStr)
         if(pTmp && pTmp->GetTypeName() == rStr)
             return i;
     }
-    SwTOXType aUserType(TOX_USER, rStr);
+    SwTOXType aUserType(*pSh->GetDoc(), TOX_USER, rStr);
     pSh->InsertTOXType(aUserType);
     return nSize;
 }
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to