sw/inc/swtable.hxx               |    2 ++
 sw/source/core/docnode/ndtbl.cxx |   12 +-----------
 sw/source/core/table/swtable.cxx |   17 +++++++++++++++++
 3 files changed, 20 insertions(+), 11 deletions(-)

New commits:
commit 2422e1b0418d057e08ef08251e8638d1478631fe
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Thu Feb 2 20:10:17 2023 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Fri Feb 3 07:11:51 2023 +0000

    sw layout xml dump: extract SwTable::dumpAsXml() from SwTableNode
    
    The idea is that each class only dumps itself & what it owns, otherwise
    the same info is dumped multiple times.
    
    Change-Id: Ib21bd2d31aa0d70d58b2b8aa453e0ede788c7144
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146511
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/inc/swtable.hxx b/sw/inc/swtable.hxx
index 0ad1deffb42e..3858c55217be 100644
--- a/sw/inc/swtable.hxx
+++ b/sw/inc/swtable.hxx
@@ -357,6 +357,8 @@ public:
     // it doesn't contain box content (except single empty nested tables of 
the boxes
     // which could remain after deletion of text content of the selected table)
     bool IsEmpty() const;
+
+    void dumpAsXml(xmlTextWriterPtr pWriter) const;
 };
 
 /// SwTableLine is one table row in the document model.
diff --git a/sw/source/core/docnode/ndtbl.cxx b/sw/source/core/docnode/ndtbl.cxx
index 77f7a4d3e97c..5e2cd8605bdd 100644
--- a/sw/source/core/docnode/ndtbl.cxx
+++ b/sw/source/core/docnode/ndtbl.cxx
@@ -2488,17 +2488,7 @@ void SwTableNode::dumpAsXml(xmlTextWriterPtr pWriter) 
const
 
     if (m_pTable)
     {
-        (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwTable"));
-        (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), 
"%p", m_pTable.get());
-        m_pTable->GetFrameFormat()->dumpAsXml(pWriter);
-        for (const auto& pLine : m_pTable->GetTabLines())
-        {
-            (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwTableLine"));
-            (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), 
"%p", pLine);
-            pLine->GetFrameFormat()->dumpAsXml(pWriter);
-            (void)xmlTextWriterEndElement(pWriter);
-        }
-        (void)xmlTextWriterEndElement(pWriter);
+        m_pTable->dumpAsXml(pWriter);
     }
 
     // (void)xmlTextWriterEndElement(pWriter); - it is a start node, so don't 
end, will make xml better nested
diff --git a/sw/source/core/table/swtable.cxx b/sw/source/core/table/swtable.cxx
index 7fa3c3caea4d..06c76771434d 100644
--- a/sw/source/core/table/swtable.cxx
+++ b/sw/source/core/table/swtable.cxx
@@ -17,6 +17,8 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <libxml/xmlwriter.h>
+
 #include <hintids.hxx>
 #include <hints.hxx>
 #include <editeng/lrspitem.hxx>
@@ -1610,6 +1612,21 @@ bool SwTable::IsDeleted() const
     return true;
 }
 
+void SwTable::dumpAsXml(xmlTextWriterPtr pWriter) const
+{
+    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwTable"));
+    (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", 
this);
+    GetFrameFormat()->dumpAsXml(pWriter);
+    for (const auto& pLine : GetTabLines())
+    {
+        (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwTableLine"));
+        (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), 
"%p", pLine);
+        pLine->GetFrameFormat()->dumpAsXml(pWriter);
+        (void)xmlTextWriterEndElement(pWriter);
+    }
+    (void)xmlTextWriterEndElement(pWriter);
+}
+
 // TODO Set HasTextChangesOnly=true, if needed based on the redlines in the 
cells.
 // At tracked row deletion, return with the newest deletion of the row or
 // at tracked row insertion, return with the oldest insertion in the row, which

Reply via email to