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

Miklos Vajna vmiklos at collabora.co.uk
Fri Jan 30 09:34:36 PST 2015


 sw/source/core/doc/docbm.cxx |   36 +++++++++++++++++-------------------
 1 file changed, 17 insertions(+), 19 deletions(-)

New commits:
commit a0107abd7e379a94edc75957ff173a64e843574d
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Fri Jan 30 18:06:25 2015 +0100

    Get rid of copy&paste in MarkManager
    
    Change-Id: I4d0ec50ee2e2099630e88b0fd086abddafc5873d

diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index e78b2f4..0a3d27f 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -1135,29 +1135,27 @@ namespace sw { namespace mark
 
 void MarkManager::dumpAsXml(xmlTextWriterPtr pWriter) const
 {
-    xmlTextWriterStartElement(pWriter, BAD_CAST("markManager"));
-    if (!m_vBookmarks.empty())
+    struct
     {
-        xmlTextWriterStartElement(pWriter, BAD_CAST("bookmarks"));
-        for (const_iterator_t it = m_vBookmarks.begin(); it != m_vBookmarks.end(); ++it)
-            (*it)->dumpAsXml(pWriter);
-        xmlTextWriterEndElement(pWriter);
-    }
-
-    if (!m_vFieldmarks.empty())
+        const char* pName;
+        const container_t& rContainer;
+    } aContainers[] =
     {
-        xmlTextWriterStartElement(pWriter, BAD_CAST("fieldmarks"));
-        for (const_iterator_t it = m_vFieldmarks.begin(); it != m_vFieldmarks.end(); ++it)
-            (*it)->dumpAsXml(pWriter);
-        xmlTextWriterEndElement(pWriter);
-    }
+        {"bookmarks", m_vBookmarks},
+        {"fieldmarks", m_vFieldmarks},
+        {"annotationmarks", m_vAnnotationMarks}
+    };
 
-    if (!m_vAnnotationMarks.empty())
+    xmlTextWriterStartElement(pWriter, BAD_CAST("markManager"));
+    for (size_t i = 0; i < SAL_N_ELEMENTS(aContainers); ++i)
     {
-        xmlTextWriterStartElement(pWriter, BAD_CAST("annotationmarks"));
-        for (const_iterator_t it = m_vAnnotationMarks.begin(); it != m_vAnnotationMarks.end(); ++it)
-            (*it)->dumpAsXml(pWriter);
-        xmlTextWriterEndElement(pWriter);
+        if (!aContainers[i].rContainer.empty())
+        {
+            xmlTextWriterStartElement(pWriter, BAD_CAST(aContainers[i].pName));
+            for (const_iterator_t it = aContainers[i].rContainer.begin(); it != aContainers[i].rContainer.end(); ++it)
+                (*it)->dumpAsXml(pWriter);
+            xmlTextWriterEndElement(pWriter);
+        }
     }
     xmlTextWriterEndElement(pWriter);
 }


More information about the Libreoffice-commits mailing list