sw/inc/charfmt.hxx                 |    2 +-
 sw/inc/fmtcol.hxx                  |    2 +-
 sw/inc/format.hxx                  |    2 ++
 sw/inc/frmfmt.hxx                  |    2 +-
 sw/inc/section.hxx                 |    2 +-
 sw/source/core/attr/format.cxx     |   16 ++++++++++++++++
 sw/source/core/doc/fmtcol.cxx      |   12 +++---------
 sw/source/core/docnode/section.cxx |    4 +---
 sw/source/core/layout/atrfrm.cxx   |    7 +------
 sw/source/core/txtnode/chrfmt.cxx  |   11 ++---------
 10 files changed, 29 insertions(+), 31 deletions(-)

New commits:
commit c7bc52f8e69f772edad9c4f695155281e19b1952
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Fri Aug 2 08:16:34 2024 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Fri Aug 2 09:56:57 2024 +0200

    sw doc model xml dump: add SwFormat::dumpAsXml()
    
    SwFormat's name was dumped at 4 different places, extract that to a
    single function.
    
    Change-Id: I64026a267676ca5b0a5920b1a3ee0efa323defc7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171389
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>
    Tested-by: Jenkins

diff --git a/sw/inc/charfmt.hxx b/sw/inc/charfmt.hxx
index 84571d26263a..ac29a29aa84e 100644
--- a/sw/inc/charfmt.hxx
+++ b/sw/inc/charfmt.hxx
@@ -38,7 +38,7 @@ class SW_DLLPUBLIC SwCharFormat final : public SwFormat
 public:
     ~SwCharFormat();
 
-    void dumpAsXml(xmlTextWriterPtr pWriter) const;
+    void dumpAsXml(xmlTextWriterPtr pWriter) const override;
 
     void SetLinkedParaFormat(SwTextFormatColl* pLink);
 
diff --git a/sw/inc/fmtcol.hxx b/sw/inc/fmtcol.hxx
index 1f66f3e1ed36..3c32c6517a33 100644
--- a/sw/inc/fmtcol.hxx
+++ b/sw/inc/fmtcol.hxx
@@ -129,7 +129,7 @@ public:
     ::sw::ListLevelIndents AreListLevelIndentsApplicable() const;
     bool AreListLevelIndentsApplicableImpl(sal_uInt16 nWhich) const;
 
-    void dumpAsXml(xmlTextWriterPtr pWriter) const;
+    void dumpAsXml(xmlTextWriterPtr pWriter) const override;
     virtual void FormatDropNotify(const SwFormatDrop& rDrop) override
     {
         if(HasWriterListeners() && !IsModifyLocked())
diff --git a/sw/inc/format.hxx b/sw/inc/format.hxx
index 09a005dfa965..1646f37a10cd 100644
--- a/sw/inc/format.hxx
+++ b/sw/inc/format.hxx
@@ -281,6 +281,8 @@ public:
     virtual bool supportsFullDrawingLayerFillAttributeSet() const;
     void RemoveAllUnos();
     bool IsUsed() const;
+    virtual void dumpAsXml(xmlTextWriterPtr pWriter) const;
+
 };
 
 #endif // INCLUDED_SW_INC_FORMAT_HXX
diff --git a/sw/inc/frmfmt.hxx b/sw/inc/frmfmt.hxx
index ed2a419e7750..d2a4ad6e6090 100644
--- a/sw/inc/frmfmt.hxx
+++ b/sw/inc/frmfmt.hxx
@@ -184,7 +184,7 @@ public:
     virtual drawinglayer::attribute::SdrAllFillAttributesHelperPtr 
getSdrAllFillAttributesHelper() const override;
     virtual bool supportsFullDrawingLayerFillAttributeSet() const override;
 
-    void dumpAsXml(xmlTextWriterPtr pWriter) const;
+    void dumpAsXml(xmlTextWriterPtr pWriter) const override;
 
     virtual void SetFormatName( const OUString& rNewName, bool 
bBroadcast=false ) override;
     void MoveTableBox(SwTableBox& rTableBox, const SwFrameFormat* pOldFormat);
diff --git a/sw/inc/section.hxx b/sw/inc/section.hxx
index f75c68b13f80..b5c6442eb5fe 100644
--- a/sw/inc/section.hxx
+++ b/sw/inc/section.hxx
@@ -334,7 +334,7 @@ public:
     virtual bool IsInContent() const override;
     virtual css::uno::Reference< css::rdf::XMetadatable > MakeUnoObject() 
override;
     virtual bool supportsFullDrawingLayerFillAttributeSet() const override;
-    void dumpAsXml(xmlTextWriterPtr pWriter) const;
+    void dumpAsXml(xmlTextWriterPtr pWriter) const override;
 
 };
 
diff --git a/sw/source/core/attr/format.cxx b/sw/source/core/attr/format.cxx
index 8f38f7fc8ba8..68ec83a6178d 100644
--- a/sw/source/core/attr/format.cxx
+++ b/sw/source/core/attr/format.cxx
@@ -757,6 +757,22 @@ bool SwFormat::IsUsed() const
     return isUsed;
 }
 
+void SwFormat::dumpAsXml(xmlTextWriterPtr pWriter) const
+{
+    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwFormat"));
+    (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", 
this);
+    (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("symbol"), "%s", 
BAD_CAST(typeid(*this).name()));
+    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("name"),
+                                      
BAD_CAST(m_aFormatName.toUtf8().getStr()));
+    if (SwFormat* pDerivedFrom = DerivedFrom())
+    {
+        (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("derived-from"),
+                                          
BAD_CAST(pDerivedFrom->GetName().toUtf8().getStr()));
+    }
+    m_aSet.dumpAsXml(pWriter);
+    (void)xmlTextWriterEndElement(pWriter);
+}
+
 SwFormatsBase::~SwFormatsBase()
 {}
 
diff --git a/sw/source/core/doc/fmtcol.cxx b/sw/source/core/doc/fmtcol.cxx
index 315139ef2a5e..1fa2ceca4831 100644
--- a/sw/source/core/doc/fmtcol.cxx
+++ b/sw/source/core/doc/fmtcol.cxx
@@ -545,14 +545,6 @@ bool 
SwTextFormatColl::AreListLevelIndentsApplicableImpl(sal_uInt16 const nWhich
 void SwTextFormatColl::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
     (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwTextFormatColl"));
-    (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", 
this);
-    (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("symbol"), "%s", 
BAD_CAST(typeid(*this).name()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("name"), 
BAD_CAST(GetName().toUtf8().getStr()));
-    if (SwFormat* pDerivedFrom = DerivedFrom())
-    {
-        (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("derived-from"),
-                                          
BAD_CAST(pDerivedFrom->GetName().toUtf8().getStr()));
-    }
     if (mpNextTextFormatColl)
     {
         (void)xmlTextWriterWriteAttribute(
@@ -563,7 +555,9 @@ void SwTextFormatColl::dumpAsXml(xmlTextWriterPtr pWriter) 
const
         (void)xmlTextWriterWriteAttribute(
             pWriter, BAD_CAST("linked"), 
BAD_CAST(mpLinkedCharFormat->GetName().toUtf8().getStr()));
     }
-    GetAttrSet().dumpAsXml(pWriter);
+
+    SwFormat::dumpAsXml(pWriter);
+
     (void)xmlTextWriterEndElement(pWriter);
 }
 
diff --git a/sw/source/core/docnode/section.cxx 
b/sw/source/core/docnode/section.cxx
index e37aba5463a9..c2f166ec9e9f 100644
--- a/sw/source/core/docnode/section.cxx
+++ b/sw/source/core/docnode/section.cxx
@@ -986,9 +986,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);
+    SwFormat::dumpAsXml(pWriter);
     (void)xmlTextWriterEndElement(pWriter);
 }
 
diff --git a/sw/source/core/layout/atrfrm.cxx b/sw/source/core/layout/atrfrm.cxx
index 47411a6b230f..84e9a59d6e6e 100644
--- a/sw/source/core/layout/atrfrm.cxx
+++ b/sw/source/core/layout/atrfrm.cxx
@@ -2976,10 +2976,7 @@ OUString SwFrameFormat::GetDescription() const
 void SwFrameFormat::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
     (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwFrameFormat"));
-    (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", 
this);
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("name"), 
BAD_CAST(GetName().toUtf8().getStr()));
     (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("whichId"), 
"%d", Which());
-
     const char* pWhich = nullptr;
     switch (Which())
     {
@@ -2992,17 +2989,15 @@ void SwFrameFormat::dumpAsXml(xmlTextWriterPtr pWriter) 
const
     }
     if (pWhich)
         (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("which"), 
BAD_CAST(pWhich));
-
     if (m_pOtherTextBoxFormats)
     {
         (void)xmlTextWriterWriteFormatAttribute(pWriter, 
BAD_CAST("OtherTextBoxFormat"), "%p", m_pOtherTextBoxFormats.get());
     }
 
-    GetAttrSet().dumpAsXml(pWriter);
+    SwFormat::dumpAsXml(pWriter);
 
     if (const SdrObject* pSdrObject = FindSdrObject())
         pSdrObject->dumpAsXml(pWriter);
-
     (void)xmlTextWriterEndElement(pWriter);
 }
 
diff --git a/sw/source/core/txtnode/chrfmt.cxx 
b/sw/source/core/txtnode/chrfmt.cxx
index 78735a353716..8083d5ddb291 100644
--- a/sw/source/core/txtnode/chrfmt.cxx
+++ b/sw/source/core/txtnode/chrfmt.cxx
@@ -26,22 +26,15 @@
 void SwCharFormat::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
     (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwCharFormat"));
-    (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", 
this);
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("name"),
-                                      BAD_CAST(GetName().toUtf8().getStr()));
 
-    if (SwFormat* pDerivedFrom = DerivedFrom())
-    {
-        (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("derived-from"),
-                                          
BAD_CAST(pDerivedFrom->GetName().toUtf8().getStr()));
-    }
+    SwFormat::dumpAsXml(pWriter);
+
     if (mpLinkedParaFormat)
     {
         (void)xmlTextWriterWriteAttribute(
             pWriter, BAD_CAST("linked"), 
BAD_CAST(mpLinkedParaFormat->GetName().toUtf8().getStr()));
     }
 
-    GetAttrSet().dumpAsXml(pWriter);
     (void)xmlTextWriterEndElement(pWriter);
 }
 

Reply via email to