From 9b504ad3ae9f71ea02df2ab6f2c2fbd59d38ae9a Mon Sep 17 00:00:00 2001
From: Miklos Vajna <vmiklos@collabora.co.uk>
Date: Tue, 10 Nov 2015 11:33:03 +0100
Subject: sw doc model xml dump: show comment text

Change-Id: If15ca89f2b7c54441f076eb233c4e1414dac25c0
---
 sw/inc/docufld.hxx                |  1 +
 sw/inc/fldbas.hxx                 |  1 +
 sw/inc/fmtfld.hxx                 |  1 +
 sw/source/core/fields/docufld.cxx | 15 +++++++++++++++
 sw/source/core/fields/fldbas.cxx  | 29 +++++++++++------------------
 sw/source/core/txtnode/atrfld.cxx | 17 ++++++++++++++++-
 6 files changed, 45 insertions(+), 19 deletions(-)

(limited to 'sw')

diff --git a/sw/inc/docufld.hxx b/sw/inc/docufld.hxx
index 34b083efeb77..2e8c9152fd24 100644
--- a/sw/inc/docufld.hxx
+++ b/sw/inc/docufld.hxx
@@ -487,6 +487,7 @@ public:
     virtual bool        QueryValue( css::uno::Any& rVal, sal_uInt16 nWhich ) const override;
     virtual bool        PutValue( const css::uno::Any& rVal, sal_uInt16 nWhich ) override;
     virtual OUString    GetDescription() const override;
+    virtual void dumpAsXml(struct _xmlTextWriter* pWriter) const override;
 };
 
 class SwDocInfoFieldType : public SwValueFieldType
diff --git a/sw/inc/fldbas.hxx b/sw/inc/fldbas.hxx
index 603e7587b8ee..6a49b5e82493 100644
--- a/sw/inc/fldbas.hxx
+++ b/sw/inc/fldbas.hxx
@@ -360,6 +360,7 @@ public:
     virtual OUString    GetDescription() const;
     /// Is this field clickable?
     bool IsClickable() const;
+    virtual void dumpAsXml(struct _xmlTextWriter* pWriter) const;
 };
 
 inline SwFieldType* SwField::GetTyp() const
diff --git a/sw/inc/fmtfld.hxx b/sw/inc/fmtfld.hxx
index 0f83415293e8..4aba5ee50cab 100644
--- a/sw/inc/fmtfld.hxx
+++ b/sw/inc/fmtfld.hxx
@@ -112,6 +112,7 @@ public:
             { return m_wXTextField; }
     SAL_DLLPRIVATE void SetXTextField(css::uno::Reference<css::text::XTextField> const& xTextField)
             { m_wXTextField = xTextField; }
+    void dumpAsXml(struct _xmlTextWriter* pWriter) const override;
 };
 
 enum class SwFormatFieldHintWhich
diff --git a/sw/source/core/fields/docufld.cxx b/sw/source/core/fields/docufld.cxx
index 8227ccb5e92f..29b646cc9769 100644
--- a/sw/source/core/fields/docufld.cxx
+++ b/sw/source/core/fields/docufld.cxx
@@ -1833,6 +1833,21 @@ bool SwPostItField::PutValue( const uno::Any& rAny, sal_uInt16 nWhichId )
     return true;
 }
 
+void SwPostItField::dumpAsXml(xmlTextWriterPtr pWriter) const
+{
+    xmlTextWriterStartElement(pWriter, BAD_CAST("swPostItField"));
+    xmlTextWriterWriteAttribute(pWriter, BAD_CAST("name"), BAD_CAST(GetName().toUtf8().getStr()));
+
+    SwField::dumpAsXml(pWriter);
+
+    xmlTextWriterStartElement(pWriter, BAD_CAST("mpText"));
+    OutlinerParaObject aParaObject(*mpText);
+    aParaObject.dumpAsXml(pWriter);
+    xmlTextWriterEndElement(pWriter);
+
+    xmlTextWriterEndElement(pWriter);
+}
+
 // extended user information field type
 
 SwExtUserFieldType::SwExtUserFieldType()
diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx
index 28a3034713ae..f0608d24db5d 100644
--- a/sw/source/core/fields/fldbas.cxx
+++ b/sw/source/core/fields/fldbas.cxx
@@ -162,24 +162,8 @@ void SwFieldTypes::dumpAsXml(xmlTextWriterPtr pWriter) const
     {
         const SwFieldType *pCurType = (*this)[nType];
         SwIterator<SwFormatField, SwFieldType> aIter(*pCurType);
-        for (const SwFormatField* pCurFieldFormat = aIter.First(); pCurFieldFormat; pCurFieldFormat = aIter.Next())
-        {
-            xmlTextWriterStartElement(pWriter, BAD_CAST("swFormatField"));
-            xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", pCurFieldFormat);
-            xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("txtField"), "%p", pCurFieldFormat->GetTextField());
-
-            xmlTextWriterStartElement(pWriter, BAD_CAST("swField"));
-            xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("symbol"), "%s", BAD_CAST(typeid(*pCurFieldFormat->GetField()).name()));
-            xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", pCurFieldFormat->GetField());
-            if (pCurFieldFormat->GetField()->GetTyp()->Which() == RES_POSTITFLD)
-            {
-                const SwPostItField* pField = static_cast<const SwPostItField*>(pCurFieldFormat->GetField());
-                xmlTextWriterWriteAttribute(pWriter, BAD_CAST("name"), BAD_CAST(pField->GetName().toUtf8().getStr()));
-            }
-            xmlTextWriterEndElement(pWriter);
-
-            xmlTextWriterEndElement(pWriter);
-        }
+        for (const SwFormatField* pFormatField = aIter.First(); pFormatField; pFormatField = aIter.Next())
+            pFormatField->dumpAsXml(pWriter);
     }
     xmlTextWriterEndElement(pWriter);
 }
@@ -774,4 +758,13 @@ bool SwField::IsClickable() const
     return false;
 }
 
+void SwField::dumpAsXml(xmlTextWriterPtr pWriter) const
+{
+    xmlTextWriterStartElement(pWriter, BAD_CAST("swField"));
+    xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("symbol"), "%s", BAD_CAST(typeid(*this).name()));
+    xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
+
+    xmlTextWriterEndElement(pWriter);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/txtnode/atrfld.cxx b/sw/source/core/txtnode/atrfld.cxx
index 43f12917d220..89649a0cb06c 100644
--- a/sw/source/core/txtnode/atrfld.cxx
+++ b/sw/source/core/txtnode/atrfld.cxx
@@ -17,8 +17,11 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
-#include "fldbas.hxx"
 #include <fmtfld.hxx>
+
+#include <libxml/xmlwriter.h>
+
+#include "fldbas.hxx"
 #include <txtfld.hxx>
 #include <txtannotationfld.hxx>
 #include <docfld.hxx>
@@ -329,6 +332,18 @@ bool SwFormatField::IsProtect() const
            && mpTextField->GetpTextNode()->IsProtect();
 }
 
+void SwFormatField::dumpAsXml(xmlTextWriterPtr pWriter) const
+{
+    xmlTextWriterStartElement(pWriter, BAD_CAST("swFormatField"));
+    xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
+    xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("mpTextField"), "%p", mpTextField);
+
+    SfxPoolItem::dumpAsXml(pWriter);
+    GetField()->dumpAsXml(pWriter);
+
+    xmlTextWriterEndElement(pWriter);
+}
+
 // class SwTextField ////////////////////////////////////////////////////
 
 SwTextField::SwTextField(
-- 
cgit