sw/inc/node.hxx                    |    2 ++
 sw/inc/section.hxx                 |    1 +
 sw/source/core/docnode/ndsect.cxx  |   20 ++++++++++++++++++++
 sw/source/core/docnode/node.cxx    |    3 ---
 sw/source/core/docnode/section.cxx |   10 ++++++++++
 5 files changed, 33 insertions(+), 3 deletions(-)

New commits:
commit 9d3b636466ba113fa769cca786b8f70fe2a70789
Author:     Miklos Vajna <[email protected]>
AuthorDate: Tue Nov 30 20:20:58 2021 +0100
Commit:     Miklos Vajna <[email protected]>
CommitDate: Wed Dec 1 08:32:28 2021 +0100

    sw doc model xml dump: show the format of section nodes
    
    The SwSectionNode has an SwSection, which is registered in an
    SwSectionFormat, which finally tells us if it's a protected one.
    
    Change-Id: Ie46c516f900f1c479c11cbbaf061973400614a2e
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/126151
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <[email protected]>

diff --git a/sw/inc/node.hxx b/sw/inc/node.hxx
index bdcc9c801a49..bc0d874f66cb 100644
--- a/sw/inc/node.hxx
+++ b/sw/inc/node.hxx
@@ -568,6 +568,8 @@ public:
        a hidden sub-area. */
     bool IsContentHidden() const;
 
+    void dumpAsXml(xmlTextWriterPtr pWriter) const override;
+
 };
 
 /** This class is internal, used only during 
DocumentContentOperationsManager::CopyWithFlyInFly(), and for undo.
diff --git a/sw/inc/section.hxx b/sw/inc/section.hxx
index 06a173daec7f..6e32cd41f5e7 100644
--- a/sw/inc/section.hxx
+++ b/sw/inc/section.hxx
@@ -244,6 +244,7 @@ public:
 
     void BreakLink();
 
+    void dumpAsXml(xmlTextWriterPtr pWriter) const;
 };
 
 // #i117863#
diff --git a/sw/source/core/docnode/ndsect.cxx 
b/sw/source/core/docnode/ndsect.cxx
index 48a5b0af4700..6c1afc01070e 100644
--- a/sw/source/core/docnode/ndsect.cxx
+++ b/sw/source/core/docnode/ndsect.cxx
@@ -17,6 +17,8 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <libxml/xmlwriter.h>
+
 #include <hintids.hxx>
 #include <osl/diagnose.h>
 #include <sfx2/linkmgr.hxx>
@@ -1323,6 +1325,24 @@ bool SwSectionNode::IsContentHidden() const
     return true; // Hide everything
 }
 
+void SwSectionNode::dumpAsXml(xmlTextWriterPtr pWriter) const
+{
+    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("section"));
+    (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", 
this);
+    (void)xmlTextWriterWriteAttribute(
+        pWriter, BAD_CAST("type"),
+        
BAD_CAST(OString::number(static_cast<sal_uInt8>(GetNodeType())).getStr()));
+    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("index"),
+                                      
BAD_CAST(OString::number(sal_Int32(GetIndex())).getStr()));
+
+    if (m_pSection)
+    {
+        m_pSection->dumpAsXml(pWriter);
+    }
+
+    // (void)xmlTextWriterEndElement(pWriter); - it is a start node, so don't 
end, will make xml better nested
+}
+
 void SwSectionNode::NodesArrChgd()
 {
     SwSectionFormat *const pFormat = m_pSection->GetFormat();
diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx
index c9b4a41f42fe..f0ee2aad5b6c 100644
--- a/sw/source/core/docnode/node.cxx
+++ b/sw/source/core/docnode/node.cxx
@@ -992,9 +992,6 @@ void SwStartNode::dumpAsXml(xmlTextWriterPtr pWriter) const
     case SwNodeType::Table:
         pName = "table";
         break;
-    case SwNodeType::Section:
-        pName = "section";
-        break;
     default:
         switch(GetStartNodeType())
         {
diff --git a/sw/source/core/docnode/section.cxx 
b/sw/source/core/docnode/section.cxx
index ec77917bd30d..86c1d4546f47 100644
--- a/sw/source/core/docnode/section.cxx
+++ b/sw/source/core/docnode/section.cxx
@@ -1021,6 +1021,7 @@ bool 
SwSectionFormat::supportsFullDrawingLayerFillAttributeSet() const
 void SwSectionFormat::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
     (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwSectionFormat"));
+    (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", 
this);
     (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("name"), 
BAD_CAST(GetName().toUtf8().getStr()));
     GetAttrSet().dumpAsXml(pWriter);
     (void)xmlTextWriterEndElement(pWriter);
@@ -1521,6 +1522,15 @@ void SwSection::BreakLink()
     SetLinkFilePassword( OUString() );
 }
 
+void SwSection::dumpAsXml(xmlTextWriterPtr pWriter) const
+{
+    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwSection"));
+    (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", 
this);
+    (void)xmlTextWriterWriteFormatAttribute(pWriter, 
BAD_CAST("registered-in"), "%p",
+                                            GetRegisteredIn());
+    (void)xmlTextWriterEndElement(pWriter);
+}
+
 const SwNode* SwIntrnlSectRefLink::GetAnchor() const { return 
m_rSectFormat.GetSectionNode(); }
 
 bool SwIntrnlSectRefLink::IsInRange( SwNodeOffset nSttNd, SwNodeOffset nEndNd 
) const

Reply via email to