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

Miklos Vajna vmiklos at collabora.co.uk
Sun Feb 8 03:15:09 PST 2015


 include/svl/itemset.hxx             |    1 +
 svl/source/items/itemset.cxx        |   10 ++++++++++
 sw/source/core/docnode/nodedump.cxx |   30 +++++++-----------------------
 3 files changed, 18 insertions(+), 23 deletions(-)

New commits:
commit b42d7e4f5d496da81e7e86f437ee275729201907
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Sun Feb 8 11:46:35 2015 +0100

    Extract SfxItemSet::dumpAsXml() from sw
    
    Change-Id: I30cb1a3c99ad5116cc2d014a7bbb1048fe8cb9f8

diff --git a/include/svl/itemset.hxx b/include/svl/itemset.hxx
index 55c2664..af85023 100644
--- a/include/svl/itemset.hxx
+++ b/include/svl/itemset.hxx
@@ -136,6 +136,7 @@ public:
     bool                        operator==(const SfxItemSet &) const;
     sal_Int32                   getHash() const;
     OString                     stringify() const;
+    void dumpAsXml(struct _xmlTextWriter* pWriter) const;
 };
 
 inline void SfxItemSet::SetParent( const SfxItemSet* pNew )
diff --git a/svl/source/items/itemset.cxx b/svl/source/items/itemset.cxx
index 22105af..c69cbb4 100644
--- a/svl/source/items/itemset.cxx
+++ b/svl/source/items/itemset.cxx
@@ -21,6 +21,7 @@
 #include <string.h>
 
 #include <cstdarg>
+#include <libxml/xmlwriter.h>
 
 #include <svl/itemset.hxx>
 #include <svl/itempool.hxx>
@@ -1920,4 +1921,13 @@ OString SfxItemSet::stringify() const
         static_cast<char const *>(aStream.GetData()), aStream.GetEndOfData());
 }
 
+void SfxItemSet::dumpAsXml(xmlTextWriterPtr pWriter) const
+{
+    xmlTextWriterStartElement(pWriter, BAD_CAST("sfxItemSet"));
+    SfxItemIter aIter(*this);
+    for (const SfxPoolItem* pItem = aIter.FirstItem(); pItem; pItem = aIter.NextItem())
+         pItem->dumpAsXml(pWriter);
+    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 ec2eef0..127701b 100644
--- a/sw/source/core/docnode/nodedump.cxx
+++ b/sw/source/core/docnode/nodedump.cxx
@@ -99,8 +99,6 @@ static const char* TMP_FORMAT_I32 = "%" SAL_PRIdINT32;
 
 }
 
-void lcl_dumpSfxItemSet(WriterHelper& writer, const SfxItemSet* pSet);
-
 void SwDoc::dumpAsXml( xmlTextWriterPtr w ) const
 {
     WriterHelper writer( w );
@@ -256,25 +254,13 @@ void SwStartNode::dumpAsXml( xmlTextWriterPtr w ) const
     if (IsTableNode())
     {
         writer.startElement("attrset");
-        const SwAttrSet& rAttrSet = GetTableNode()->GetTable().GetFrmFmt()->GetAttrSet();
-        lcl_dumpSfxItemSet(writer, &rAttrSet);
+        GetTableNode()->GetTable().GetFrmFmt()->GetAttrSet().dumpAsXml(writer);
         writer.endElement();
     }
 
     // writer.endElement(); - it is a start node, so don't end, will make xml better nested
 }
 
-void lcl_dumpSfxItemSet(WriterHelper& writer, const SfxItemSet* pSet)
-{
-    SfxItemIter aIter(*pSet);
-    const SfxPoolItem* pItem = aIter.FirstItem();
-    while (pItem)
-    {
-        pItem->dumpAsXml(writer);
-        pItem = aIter.NextItem();
-    }
-}
-
 void SwFrmFmts::dumpAsXml(xmlTextWriterPtr w, const char* pName) const
 {
     WriterHelper writer(w);
@@ -310,8 +296,7 @@ void SwFrmFmt::dumpAsXml(xmlTextWriterPtr pWriter) const
     if (pWhich)
         xmlTextWriterWriteAttribute(pWriter, BAD_CAST("which"), BAD_CAST(pWhich));
 
-    WriterHelper w(pWriter);
-    lcl_dumpSfxItemSet(w, &GetAttrSet());
+    GetAttrSet().dumpAsXml(pWriter);
 
     xmlTextWriterEndElement(pWriter);
 }
@@ -329,7 +314,7 @@ void SwCharFmts::dumpAsXml(xmlTextWriterPtr w) const
             OString aName = OUStringToOString(pFmt->GetName(), RTL_TEXTENCODING_UTF8);
             writer.writeFormatAttribute("name", "%s", BAD_CAST(aName.getStr()));
 
-            lcl_dumpSfxItemSet(writer, &pFmt->GetAttrSet());
+            pFmt->GetAttrSet().dumpAsXml(w);
             writer.endElement();
         }
         writer.endElement();
@@ -346,7 +331,7 @@ void SwSectionFmts::dumpAsXml(xmlTextWriterPtr w) const
         {
             const SwSectionFmt* pFmt = GetFmt(i);
             writer.startElement("swsectionfmt");
-            lcl_dumpSfxItemSet(writer, &pFmt->GetAttrSet());
+            pFmt->GetAttrSet().dumpAsXml(w);
             writer.endElement();
         }
         writer.endElement();
@@ -366,7 +351,7 @@ void SwTxtFmtColls::dumpAsXml(xmlTextWriterPtr w) const
             OString aName = OUStringToOString(pColl->GetName(), RTL_TEXTENCODING_UTF8);
             writer.writeFormatAttribute("name", "%s", BAD_CAST(aName.getStr()));
 
-            lcl_dumpSfxItemSet(writer, &pColl->GetAttrSet());
+            pColl->GetAttrSet().dumpAsXml(w);
             writer.endElement();
         }
         writer.endElement();
@@ -399,8 +384,7 @@ void SwTxtNode::dumpAsXml( xmlTextWriterPtr w ) const
     if (HasSwAttrSet())
     {
         writer.startElement("attrset");
-        const SwAttrSet& rAttrSet = GetSwAttrSet();
-        lcl_dumpSfxItemSet(writer, &rAttrSet);
+        GetSwAttrSet().dumpAsXml(writer);
         writer.endElement();
     }
 
@@ -451,7 +435,7 @@ void SwTxtNode::dumpAsXml( xmlTextWriterPtr w ) const
             {
                 boost::shared_ptr<SfxItemSet> const pSet(pHint->GetAutoFmt().GetStyleHandle());
                 writer.startElement("autofmt");
-                lcl_dumpSfxItemSet(writer, pSet.get());
+                pSet->dumpAsXml(writer);
                 writer.endElement();
             }
 


More information about the Libreoffice-commits mailing list