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

Miklos Vajna vmiklos at collabora.co.uk
Thu Jan 29 12:55:25 PST 2015


 sw/source/core/crsr/bookmrk.cxx |   19 +++++++++++++++++++
 sw/source/core/doc/docbm.cxx    |   24 +-----------------------
 sw/source/core/inc/bookmrk.hxx  |    1 +
 3 files changed, 21 insertions(+), 23 deletions(-)

New commits:
commit 0dcadc274ba81be6f233e559059b7e3f6cc3c0de
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Jan 29 14:35:06 2015 +0100

    Extract Fieldmark::dumpAsXml() from MarkManager
    
    Change-Id: I1e3b1d4b7d596630ea9b804ded911a2e48b970c9

diff --git a/sw/source/core/crsr/bookmrk.cxx b/sw/source/core/crsr/bookmrk.cxx
index 994aefc..055cee8 100644
--- a/sw/source/core/crsr/bookmrk.cxx
+++ b/sw/source/core/crsr/bookmrk.cxx
@@ -33,6 +33,7 @@
 #include <rtl/random.h>
 #include <xmloff/odffields.hxx>
 #include <libxml/xmlwriter.h>
+#include <comphelper/anytostring.hxx>
 
 using namespace ::sw::mark;
 using namespace ::com::sun::star;
@@ -373,6 +374,24 @@ namespace sw { namespace mark
         aPaM.InvalidatePaM();
     }
 
+    void Fieldmark::dumpAsXml(xmlTextWriterPtr pWriter) const
+    {
+        xmlTextWriterStartElement(pWriter, BAD_CAST("fieldmark"));
+        xmlTextWriterWriteAttribute(pWriter, BAD_CAST("fieldname"), BAD_CAST(m_aFieldname.toUtf8().getStr()));
+        xmlTextWriterWriteAttribute(pWriter, BAD_CAST("fieldHelptext"), BAD_CAST(m_aFieldHelptext.toUtf8().getStr()));
+        MarkBase::dumpAsXml(pWriter);
+        xmlTextWriterStartElement(pWriter, BAD_CAST("parameters"));
+        for (auto& rParam : m_vParams)
+        {
+            xmlTextWriterStartElement(pWriter, BAD_CAST("parameter"));
+            xmlTextWriterWriteAttribute(pWriter, BAD_CAST("name"), BAD_CAST(rParam.first.toUtf8().getStr()));
+            xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(comphelper::anyToString(rParam.second).toUtf8().getStr()));
+            xmlTextWriterEndElement(pWriter);
+        }
+        xmlTextWriterEndElement(pWriter);
+        xmlTextWriterEndElement(pWriter);
+    }
+
     TextFieldmark::TextFieldmark(const SwPaM& rPaM)
         : Fieldmark(rPaM)
     { }
diff --git a/sw/source/core/doc/docbm.cxx b/sw/source/core/doc/docbm.cxx
index d0f71e9..e4e8138 100644
--- a/sw/source/core/doc/docbm.cxx
+++ b/sw/source/core/doc/docbm.cxx
@@ -55,7 +55,6 @@
 #include <edimp.hxx>
 #include <stdio.h>
 #include <tools/datetimeutils.hxx>
-#include <comphelper/anytostring.hxx>
 
 using namespace ::boost;
 using namespace ::sw::mark;
@@ -1154,28 +1153,7 @@ void MarkManager::dumpAsXml(xmlTextWriterPtr pWriter) const
     {
         xmlTextWriterStartElement(pWriter, BAD_CAST("fieldmarks"));
         for (const_iterator_t it = m_vFieldmarks.begin(); it != m_vFieldmarks.end(); ++it)
-        {
-            pMark_t pMark = *it;
-            xmlTextWriterStartElement(pWriter, BAD_CAST("fieldmark"));
-            pMark->dumpAsXml(pWriter);
-            if (sw::mark::IFieldmark* pFieldmark = dynamic_cast<sw::mark::IFieldmark*>(pMark.get()))
-            {
-                sw::mark::IFieldmark::parameter_map_t* pParameters = pFieldmark->GetParameters();
-                if (pParameters)
-                {
-                    xmlTextWriterStartElement(pWriter, BAD_CAST("parameters"));
-                    for (sw::mark::IFieldmark::parameter_map_t::iterator parameter = pParameters->begin(); parameter != pParameters->end(); ++parameter)
-                    {
-                        xmlTextWriterStartElement(pWriter, BAD_CAST("parameter"));
-                        xmlTextWriterWriteAttribute(pWriter, BAD_CAST("name"), BAD_CAST(parameter->first.toUtf8().getStr()));
-                        xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(comphelper::anyToString(parameter->second).toUtf8().getStr()));
-                        xmlTextWriterEndElement(pWriter);
-                    }
-                    xmlTextWriterEndElement(pWriter);
-                }
-            }
-            xmlTextWriterEndElement(pWriter);
-        }
+            (*it)->dumpAsXml(pWriter);
         xmlTextWriterEndElement(pWriter);
     }
 
diff --git a/sw/source/core/inc/bookmrk.hxx b/sw/source/core/inc/bookmrk.hxx
index 676bf81..ebdfbdf 100644
--- a/sw/source/core/inc/bookmrk.hxx
+++ b/sw/source/core/inc/bookmrk.hxx
@@ -226,6 +226,7 @@ namespace sw {
 
             virtual void Invalidate() SAL_OVERRIDE;
             virtual OUString ToString() const SAL_OVERRIDE;
+            virtual void dumpAsXml(struct _xmlTextWriter* pWriter) const SAL_OVERRIDE;
 
         private:
             OUString m_aFieldname;


More information about the Libreoffice-commits mailing list