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

Miklos Vajna vmiklos at collabora.co.uk
Thu Jan 22 00:19:00 PST 2015


 include/svl/stritem.hxx             |    2 ++
 svl/source/items/stritem.cxx        |   10 +++++++++-
 sw/source/core/docnode/nodedump.cxx |   29 +++++------------------------
 3 files changed, 16 insertions(+), 25 deletions(-)

New commits:
commit e17847e0ce5602b0cdf312ba2c72bd99aa7b72b2
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Thu Jan 22 09:16:39 2015 +0100

    Factor out SfxStringItem::dumpAsXml() from sw
    
    Change-Id: If218d83297bfdd39471d5502c0639248c96af9c6

diff --git a/include/svl/stritem.hxx b/include/svl/stritem.hxx
index 8d6da4f..eb0fea3 100644
--- a/include/svl/stritem.hxx
+++ b/include/svl/stritem.hxx
@@ -41,6 +41,8 @@ public:
     virtual SvStream & Store(SvStream & rStream, sal_uInt16) const SAL_OVERRIDE;
 
     virtual SfxPoolItem * Clone(SfxItemPool * = 0) const SAL_OVERRIDE;
+
+    void dumpAsXml(struct _xmlTextWriter* pWriter) const;
 };
 
 #endif // INCLUDED_SVL_STRITEM_HXX
diff --git a/svl/source/items/stritem.cxx b/svl/source/items/stritem.cxx
index dd94154..dea5550 100644
--- a/svl/source/items/stritem.cxx
+++ b/svl/source/items/stritem.cxx
@@ -19,7 +19,7 @@
 
 #include <svl/stritem.hxx>
 #include <stringio.hxx>
-
+#include <libxml/xmlwriter.h>
 
 //  class SfxStringItem
 
@@ -53,4 +53,12 @@ SfxPoolItem * SfxStringItem::Clone(SfxItemPool *) const
     return new SfxStringItem(*this);
 }
 
+void SfxStringItem::dumpAsXml(xmlTextWriterPtr pWriter) const
+{
+    xmlTextWriterStartElement(pWriter, BAD_CAST("sfxStringItem"));
+    xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
+    xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), BAD_CAST(GetValue().toUtf8().getStr()));
+    xmlTextWriterEndElement(pWriter);
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/docnode/nodedump.cxx b/sw/source/core/docnode/nodedump.cxx
index 6717299..eb7af26 100644
--- a/sw/source/core/docnode/nodedump.cxx
+++ b/sw/source/core/docnode/nodedump.cxx
@@ -502,6 +502,10 @@ void lcl_dumpSfxItemSet(WriterHelper& writer, const SfxItemSet* pSet)
             case RES_PAGEDESC:
                 static_cast<const SwFmtPageDesc*>(pItem)->dumpAsXml(writer);
                 break;
+            case RES_FRMATR_CONDITIONAL_STYLE_NAME:
+            case RES_FRMATR_STYLE_NAME:
+                static_cast<const SfxStringItem*>(pItem)->dumpAsXml(writer);
+                break;
             default: bDone = false; break;
         }
         if (bDone)
@@ -512,31 +516,8 @@ void lcl_dumpSfxItemSet(WriterHelper& writer, const SfxItemSet* pSet)
 
         writer.startElement("item");
         writer.writeFormatAttribute("whichId", TMP_FORMAT, pItem->Which());
-        const char* pWhich = 0;
-        boost::optional<OString> oValue;
-        switch (pItem->Which())
-        {
-            case RES_FRMATR_STYLE_NAME:
-            {
-                pWhich = "frame style name";
-                const SfxStringItem* pStringItem = static_cast<const SfxStringItem*>(pItem);
-                oValue = "name: " + OUStringToOString(pStringItem->GetValue(), RTL_TEXTENCODING_UTF8);
-                break;
-            }
-            case RES_FRMATR_CONDITIONAL_STYLE_NAME:
-            {
-                pWhich = "frame conditional style name";
-                const SfxStringItem* pStringItem = static_cast<const SfxStringItem*>(pItem);
-                oValue = "name: " + OUStringToOString(pStringItem->GetValue(), RTL_TEXTENCODING_UTF8);
-                break;
-            }
-        }
-        if (pWhich)
-            writer.writeFormatAttribute("which", "%s", BAD_CAST(pWhich));
-        if (oValue)
-            writer.writeFormatAttribute("value", "%s", BAD_CAST(oValue->getStr()));
-        pItem = aIter.NextItem();
         writer.endElement();
+        pItem = aIter.NextItem();
     }
 }
 


More information about the Libreoffice-commits mailing list