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

Miklos Vajna vmiklos at collabora.co.uk
Sun Mar 1 22:54:49 PST 2015


 sw/Library_sw.mk                    |    1 
 sw/inc/docary.hxx                   |   16 ++--
 sw/source/core/docnode/nodedump.cxx |  136 ------------------------------------
 sw/source/core/fields/fldbas.cxx    |   40 +++++++++-
 4 files changed, 45 insertions(+), 148 deletions(-)

New commits:
commit 6aeaa9634e87f5df2fd90f01900a487982068160
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Mon Mar 2 07:51:53 2015 +0100

    sw: remove now unused WriterHelper
    
    This concludes the ongoing various dumpXml() cleanups of mine since
    2014-11-24 in the sw doc model xml dumper.
    
    Change-Id: I8e9f7c8d9443df3763b7d3073541dbe03b662f4c

diff --git a/sw/Library_sw.mk b/sw/Library_sw.mk
index 2af35f2..5254e3a 100644
--- a/sw/Library_sw.mk
+++ b/sw/Library_sw.mk
@@ -230,7 +230,6 @@ $(eval $(call gb_Library_add_exception_objects,sw,\
     sw/source/core/docnode/ndtbl \
     sw/source/core/docnode/ndtbl1 \
     sw/source/core/docnode/node \
-    sw/source/core/docnode/nodedump \
     sw/source/core/docnode/node2lay \
     sw/source/core/docnode/nodes \
     sw/source/core/docnode/observablethread \
diff --git a/sw/inc/docary.hxx b/sw/inc/docary.hxx
index abe1480..115a86c 100644
--- a/sw/inc/docary.hxx
+++ b/sw/inc/docary.hxx
@@ -108,7 +108,7 @@ public:
     bool Contains(Value const& p) const
         { return std::find(begin(), end(), p) != end(); }
 
-    void dumpAsXml(xmlTextWriterPtr) const {};
+    void dumpAsXml(struct _xmlTextWriter* /*pWriter*/) const {};
 };
 
 template<typename Value>
@@ -142,39 +142,39 @@ public:
 class SW_DLLPUBLIC SwFrmFmts : public SwFmtsModifyBase<SwFrmFmt*>
 {
 public:
-    void dumpAsXml(xmlTextWriterPtr w, const char* pName) const;
+    void dumpAsXml(struct _xmlTextWriter* pWriter, const char* pName) const;
 };
 
 class SwCharFmts : public SwFmtsModifyBase<SwCharFmt*>
 {
 public:
-    void dumpAsXml(xmlTextWriterPtr w) const;
+    void dumpAsXml(struct _xmlTextWriter* pWriter) const;
 };
 
 class SwTxtFmtColls : public SwFmtsModifyBase<SwTxtFmtColl*>
 {
 public:
     SwTxtFmtColls() : SwFmtsModifyBase( DestructorPolicy::KeepElements ) {}
-    void dumpAsXml(xmlTextWriterPtr w) const;
+    void dumpAsXml(struct _xmlTextWriter* pWriter) const;
 };
 
 /// Array of Undo-history.
 class SW_DLLPUBLIC SwSectionFmts : public SwFmtsModifyBase<SwSectionFmt*>
 {
 public:
-    void dumpAsXml(xmlTextWriterPtr w) const;
+    void dumpAsXml(struct _xmlTextWriter* pWriter) const;
 };
 
 class SwFldTypes : public SwVectorModifyBase<SwFieldType*> {
 public:
-    void dumpAsXml(xmlTextWriterPtr w) const;
+    void dumpAsXml(struct _xmlTextWriter* pWriter) const;
 };
 
 class SwTOXTypes : public SwVectorModifyBase<SwTOXType*> {};
 
 class SW_DLLPUBLIC SwNumRuleTbl : public SwVectorModifyBase<SwNumRule*> {
 public:
-    void dumpAsXml(xmlTextWriterPtr w) const;
+    void dumpAsXml(struct _xmlTextWriter* pWriter) const;
 };
 
 struct CompareSwRedlineTbl
@@ -249,7 +249,7 @@ public:
     void DeleteAndDestroy( sal_uInt16 nPos, sal_uInt16 nLen = 1 );
     void DeleteAndDestroyAll();
 
-    void dumpAsXml(xmlTextWriterPtr w) const;
+    void dumpAsXml(struct _xmlTextWriter* pWriter) const;
 
     sal_uInt16 GetSize() const                              {     return m_aExtraRedlines.size();                }
     SwExtraRedline* GetRedline( sal_uInt16 uIndex ) const   {     return m_aExtraRedlines.operator[]( uIndex );  }
diff --git a/sw/source/core/docnode/nodedump.cxx b/sw/source/core/docnode/nodedump.cxx
deleted file mode 100644
index 01d76ca..0000000
--- a/sw/source/core/docnode/nodedump.cxx
+++ /dev/null
@@ -1,136 +0,0 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/*
- * This file is part of the LibreOffice project.
- *
- * This Source Code Form is subject to the terms of the Mozilla Public
- * License, v. 2.0. If a copy of the MPL was not distributed with this
- * file, You can obtain one at http://mozilla.org/MPL/2.0/.
- */
-
-#include "doc.hxx"
-#include "drawdoc.hxx"
-#include <IDocumentDrawModelAccess.hxx>
-#include <IDocumentFieldsAccess.hxx>
-#include <IDocumentState.hxx>
-#include <UndoManager.hxx>
-#include "ndtxt.hxx"
-#include "MarkManager.hxx"
-#include "switerator.hxx"
-#include "docufld.hxx"
-#include "txatbase.hxx"
-#include "redline.hxx"
-#include <swmodule.hxx>
-#include <svl/itemiter.hxx>
-#include <tools/datetimeutils.hxx>
-
-#include <libxml/xmlwriter.h>
-
-using namespace com::sun::star;
-
-namespace
-{
-
-// Small helper class to ensure that we write to nodes.xml if nothing
-// has been explicitly specified.
-// Always use at the beginning of dumpAsXml().
-// Also, there are some functions to save typing.
-class WriterHelper
-{
-public:
-    WriterHelper( xmlTextWriterPtr );
-    ~WriterHelper();
-    void startElement( const char* element );
-    void endElement();
-    void writeFormatAttribute( const char* attribute, const char* format, ... )
-#ifdef LIBXML_ATTR_FORMAT
-        LIBXML_ATTR_FORMAT(3,4)
-#endif
-        ;
-private:
-    xmlTextWriterPtr writer;
-    bool owns;
-};
-
-WriterHelper::WriterHelper( xmlTextWriterPtr w )
-    : writer( w )
-    , owns( false )
-{
-    if( writer == NULL )
-    {
-        writer = xmlNewTextWriterFilename( "nodes.xml", 0 );
-        xmlTextWriterStartDocument( writer, NULL, NULL, NULL );
-        owns = true;
-    }
-}
-
-WriterHelper::~WriterHelper()
-{
-    if( owns )
-    {
-        xmlTextWriterEndDocument( writer );
-        xmlFreeTextWriter( writer );
-    }
-}
-
-
-void WriterHelper::startElement( const char* element )
-{
-    xmlTextWriterStartElement( writer, BAD_CAST( element ));
-}
-
-void WriterHelper::endElement()
-{
-    xmlTextWriterEndElement( writer );
-}
-
-void WriterHelper::writeFormatAttribute( const char* attribute, const char* format, ... )
-{
-    va_list va;
-    va_start( va, format );
-    xmlTextWriterWriteVFormatAttribute( writer, BAD_CAST( attribute ), format, va );
-    va_end( va );
-}
-}
-
-void SwFldTypes::dumpAsXml( xmlTextWriterPtr w ) const
-{
-    WriterHelper writer(w);
-    writer.startElement("swfldtypes");
-    sal_uInt16 nCount = size();
-    for (sal_uInt16 nType = 0; nType < nCount; ++nType)
-    {
-        const SwFieldType *pCurType = (*this)[nType];
-        SwIterator<SwFmtFld, SwFieldType> aIter(*pCurType);
-        for (const SwFmtFld* pCurFldFmt = aIter.First(); pCurFldFmt; pCurFldFmt = aIter.Next())
-        {
-            writer.startElement("swfmtfld");
-            writer.writeFormatAttribute("ptr", "%p", pCurFldFmt);
-            writer.writeFormatAttribute("pTxtAttr", "%p", pCurFldFmt->GetTxtFld());
-            const char* name = "FIXME_unhandledfield";
-            switch(pCurFldFmt->GetField()->GetTyp()->Which())
-            {
-                case RES_PAGENUMBERFLD: name = "swpagenumberfield"; break;
-                case RES_POSTITFLD: name = "swpostitfield"; break;
-                case RES_DATETIMEFLD: name = "swdatetimefield"; break;
-                default:
-                    SAL_INFO("sw.core", "unhandled field type " << pCurFldFmt->GetField()->GetTyp()->Which());
-                    break;
-            }
-            writer.startElement(name);
-            writer.writeFormatAttribute("ptr", "%p", pCurFldFmt->GetField());
-            const SwPostItField* pField = NULL;
-            if (pCurFldFmt->GetField()->GetTyp()->Which() == RES_POSTITFLD)
-                pField = dynamic_cast<const SwPostItField*>(pCurFldFmt->GetField());
-            if (pField)
-            {
-                OString txt8 = OUStringToOString(pField->GetName(), RTL_TEXTENCODING_UTF8);
-                writer.writeFormatAttribute("name", "%s", BAD_CAST( txt8.getStr()));
-            }
-            writer.endElement();
-            writer.endElement();
-        }
-    }
-    writer.endElement();
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/sw/source/core/fields/fldbas.cxx b/sw/source/core/fields/fldbas.cxx
index 0cf94f3..8333ad8 100644
--- a/sw/source/core/fields/fldbas.cxx
+++ b/sw/source/core/fields/fldbas.cxx
@@ -17,7 +17,13 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include <fldbas.hxx>
+
 #include <float.h>
+#include <math.h>
+
+#include <libxml/xmlwriter.h>
+
 #include <rtl/math.hxx>
 #include <svl/zforlist.hxx>
 #include <svl/zformat.hxx>
@@ -26,7 +32,6 @@
 #include <doc.hxx>
 #include <editsh.hxx>
 #include <frame.hxx>
-#include <fldbas.hxx>
 #include <flddat.hxx>
 #include <ndtxt.hxx>
 #include <fmtfld.hxx>
@@ -41,8 +46,7 @@
 #include <comcore.hrc>
 #include <docary.hxx>
 #include <authfld.hxx>
-
-#include <math.h>
+#include <switerator.hxx>
 
 using namespace ::com::sun::star;
 using namespace nsSwDocInfoSubType;
@@ -150,6 +154,36 @@ bool SwFieldType::PutValue( const uno::Any& , sal_uInt16 )
     return false;
 }
 
+void SwFldTypes::dumpAsXml(xmlTextWriterPtr pWriter) const
+{
+    xmlTextWriterStartElement(pWriter, BAD_CAST("swFldTypes"));
+    sal_uInt16 nCount = size();
+    for (sal_uInt16 nType = 0; nType < nCount; ++nType)
+    {
+        const SwFieldType *pCurType = (*this)[nType];
+        SwIterator<SwFmtFld, SwFieldType> aIter(*pCurType);
+        for (const SwFmtFld* pCurFldFmt = aIter.First(); pCurFldFmt; pCurFldFmt = aIter.Next())
+        {
+            xmlTextWriterStartElement(pWriter, BAD_CAST("swFmtFld"));
+            xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", pCurFldFmt);
+            xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("txtFld"), "%p", pCurFldFmt->GetTxtFld());
+
+            xmlTextWriterStartElement(pWriter, BAD_CAST("swField"));
+            xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("symbol"), "%s", BAD_CAST(typeid(*pCurFldFmt->GetField()).name()));
+            xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", pCurFldFmt->GetField());
+            if (pCurFldFmt->GetField()->GetTyp()->Which() == RES_POSTITFLD)
+            {
+                const SwPostItField* pField = static_cast<const SwPostItField*>(pCurFldFmt->GetField());
+                xmlTextWriterWriteAttribute(pWriter, BAD_CAST("name"), BAD_CAST(pField->GetName().toUtf8().getStr()));
+            }
+            xmlTextWriterEndElement(pWriter);
+
+            xmlTextWriterEndElement(pWriter);
+        }
+    }
+    xmlTextWriterEndElement(pWriter);
+}
+
 // Base class for all fields.
 // A field (multiple can exist) references a field type (can exists only once)
 SwField::SwField(


More information about the Libreoffice-commits mailing list