sw/inc/redline.hxx              |    2 +
 sw/source/core/doc/docredln.cxx |   54 +++++++++++++++++++++++++---------------
 2 files changed, 37 insertions(+), 19 deletions(-)

New commits:
commit edd121dd668e141cd61f0992340fa07eb6df8e76
Author:     Miklos Vajna <vmik...@collabora.com>
AuthorDate: Thu Sep 7 20:09:15 2023 +0200
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Fri Sep 8 08:15:13 2023 +0200

    sw doc model xml dump: show all redline data of a range redline
    
    E.g. Alice does an insert, then Bob does a delete in the middle, then
    the deletion redline will have 2 redline data, the first will be the
    delete, the second will be the original insert, show this in the xml
    dump.
    
    Change-Id: Ide9777cdbc8a5460fe28c646104901c968a33382
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156680
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/inc/redline.hxx b/sw/inc/redline.hxx
index 1fccb405e192..7ef6b9cad20f 100644
--- a/sw/inc/redline.hxx
+++ b/sw/inc/redline.hxx
@@ -157,6 +157,8 @@ public:
     void SetSeqNo( sal_uInt16 nNo )                 { m_nSeqNo = nNo; }
 
     OUString GetDescr() const;
+
+    void dumpAsXml(xmlTextWriterPtr pWriter) const;
 };
 
 class SW_DLLPUBLIC SwRangeRedline final : public SwPaM
diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx
index 54d853065629..752de518accb 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -1141,6 +1141,37 @@ OUString SwRedlineData::GetDescr() const
     return SwResId(STR_REDLINE_ARY[static_cast<int>(GetType())]);
 }
 
+void SwRedlineData::dumpAsXml(xmlTextWriterPtr pWriter) const
+{
+    (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwRedlineData"));
+
+    (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", 
this);
+    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("id"), 
BAD_CAST(OString::number(GetSeqNo()).getStr()));
+    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("author"), 
BAD_CAST(SW_MOD()->GetRedlineAuthor(GetAuthor()).toUtf8().getStr()));
+    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("date"), 
BAD_CAST(DateTimeToOString(GetTimeStamp()).getStr()));
+    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("descr"), 
BAD_CAST(GetDescr().toUtf8().getStr()));
+
+    OString sRedlineType;
+    switch (GetType())
+    {
+        case RedlineType::Insert:
+            sRedlineType = "REDLINE_INSERT";
+            break;
+        case RedlineType::Delete:
+            sRedlineType = "REDLINE_DELETE";
+            break;
+        case RedlineType::Format:
+            sRedlineType = "REDLINE_FORMAT";
+            break;
+        default:
+            sRedlineType = "UNKNOWN";
+            break;
+    }
+    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("type"), 
BAD_CAST(sRedlineType.getStr()));
+
+    (void)xmlTextWriterEndElement(pWriter);
+}
+
 sal_uInt32 SwRangeRedline::s_nLastId = 1;
 
 SwRangeRedline::SwRangeRedline(RedlineType eTyp, const SwPaM& rPam )
@@ -2073,28 +2104,13 @@ void SwRangeRedline::dumpAsXml(xmlTextWriterPtr 
pWriter) const
     (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwRangeRedline"));
 
     (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", 
this);
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("id"), 
BAD_CAST(OString::number(GetSeqNo()).getStr()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("author"), 
BAD_CAST(SW_MOD()->GetRedlineAuthor(GetAuthor()).toUtf8().getStr()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("date"), 
BAD_CAST(DateTimeToOString(GetTimeStamp()).getStr()));
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("descr"), 
BAD_CAST(const_cast<SwRangeRedline*>(this)->GetDescr().toUtf8().getStr()));
 
-    OString sRedlineType;
-    switch (GetType())
+    const SwRedlineData* pRedlineData = m_pRedlineData;
+    while (pRedlineData)
     {
-        case RedlineType::Insert:
-            sRedlineType = "REDLINE_INSERT";
-            break;
-        case RedlineType::Delete:
-            sRedlineType = "REDLINE_DELETE";
-            break;
-        case RedlineType::Format:
-            sRedlineType = "REDLINE_FORMAT";
-            break;
-        default:
-            sRedlineType = "UNKNOWN";
-            break;
+        pRedlineData->dumpAsXml(pWriter);
+        pRedlineData = pRedlineData->Next();
     }
-    (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("type"), 
BAD_CAST(sRedlineType.getStr()));
 
     SwPaM::dumpAsXml(pWriter);
 

Reply via email to