[Libreoffice-commits] core.git: sw/inc sw/source

Miklos Vajna vmiklos at collabora.co.uk
Tue Feb 24 00:05:58 PST 2015


 sw/inc/pam.hxx                  |    2 ++
 sw/source/core/crsr/pam.cxx     |   18 ++++++++++++++++++
 sw/source/core/doc/docredln.cxx |    7 +------
 sw/source/core/text/xmldump.cxx |   12 ++----------
 4 files changed, 23 insertions(+), 16 deletions(-)

New commits:
commit 44009b9a9d09c2574b4740881a848556eea2859d
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Tue Feb 24 09:03:24 2015 +0100

    Add SwPaM::dumpAsXml()
    
    To avoid code duplication in SwRangeRedline::dumpAsXml() and
    SwFrm::dumpAsXml().
    
    Change-Id: Ic473cd77e960041b035b147dd31c16b141cc7cbe

diff --git a/sw/inc/pam.hxx b/sw/inc/pam.hxx
index 616a45a..30a19c3 100644
--- a/sw/inc/pam.hxx
+++ b/sw/inc/pam.hxx
@@ -315,6 +315,8 @@ public:
         { return GetPrevInRing(); }
     bool IsMultiSelection() const
         { return !unique(); }
+
+    void dumpAsXml(struct _xmlTextWriter* pWriter) const;
 };
 
 std::ostream &operator <<(std::ostream& s, const SwPaM& pam);
diff --git a/sw/source/core/crsr/pam.cxx b/sw/source/core/crsr/pam.cxx
index b8dc0a6..16f107c 100644
--- a/sw/source/core/crsr/pam.cxx
+++ b/sw/source/core/crsr/pam.cxx
@@ -1098,6 +1098,24 @@ void SwPaM::InvalidatePaM()
     }
 }
 
+void SwPaM::dumpAsXml(xmlTextWriterPtr pWriter) const
+{
+    xmlTextWriterStartElement(pWriter, BAD_CAST("swPaM"));
+
+    xmlTextWriterStartElement(pWriter, BAD_CAST("point"));
+    GetPoint()->dumpAsXml(pWriter);
+    xmlTextWriterEndElement(pWriter);
+
+    if (HasMark())
+    {
+        xmlTextWriterStartElement(pWriter, BAD_CAST("mark"));
+        GetMark()->dumpAsXml(pWriter);
+        xmlTextWriterEndElement(pWriter);
+    }
+
+    xmlTextWriterEndElement(pWriter);
+}
+
 std::ostream &operator <<(std::ostream& s, const SwPaM& pam)
 {
     if( pam.HasMark())
diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx
index 82ce470..ba755ab 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -1640,12 +1640,7 @@ void SwRangeRedline::dumpAsXml(xmlTextWriterPtr pWriter) const
     }
     xmlTextWriterWriteAttribute(pWriter, BAD_CAST("type"), BAD_CAST(sRedlineType.getStr()));
 
-    xmlTextWriterStartElement(pWriter, BAD_CAST("point"));
-    GetPoint()->dumpAsXml(pWriter);
-    xmlTextWriterEndElement(pWriter);
-    xmlTextWriterStartElement(pWriter, BAD_CAST("mark"));
-    GetMark()->dumpAsXml(pWriter);
-    xmlTextWriterEndElement(pWriter);
+    SwPaM::dumpAsXml(pWriter);
 
     const SwRedlineExtraData* pExtraRedlineData = GetExtraData();
     xmlTextWriterStartElement(pWriter, BAD_CAST("swRedlineExtraData"));
diff --git a/sw/source/core/text/xmldump.cxx b/sw/source/core/text/xmldump.cxx
index a21f56e..d322199 100644
--- a/sw/source/core/text/xmldump.cxx
+++ b/sw/source/core/text/xmldump.cxx
@@ -299,16 +299,8 @@ void SwFrm::dumpAsXml( xmlTextWriterPtr writer ) const
             const SwRootFrm* const pRootFrm = static_cast<const SwRootFrm* const>(this);
             SwEditShell* pEditShell = pRootFrm->GetCurrShell()->GetDoc()->GetEditShell();
             xmlTextWriterStartElement(writer, BAD_CAST("shellCrsr"));
-            for(SwPaM& rPaM : pEditShell->getShellCrsr(false)->GetRingContainer())
-            {
-                xmlTextWriterStartElement(writer, BAD_CAST("swpam"));
-                xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("pointNodeIndex"), "%ld", rPaM.GetPoint()->nNode.GetIndex());
-                xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("pointContentIndex"), "%" SAL_PRIdINT32, rPaM.GetPoint()->nContent.GetIndex());
-
-                xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("markNodeIndex"), "%ld", rPaM.GetMark()->nNode.GetIndex());
-                xmlTextWriterWriteFormatAttribute(writer, BAD_CAST("markContentIndex"), "%" SAL_PRIdINT32, rPaM.GetMark()->nContent.GetIndex());
-                xmlTextWriterEndElement(writer);
-            }
+            for (SwPaM& rPaM : pEditShell->getShellCrsr(false)->GetRingContainer())
+                rPaM.dumpAsXml(writer);
             xmlTextWriterEndElement(writer);
         }
 


More information about the Libreoffice-commits mailing list