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

Adam Co rattles2013 at gmail.com
Tue Nov 26 05:16:53 PST 2013


 sw/inc/docary.hxx                   |    2 
 sw/source/core/docnode/nodedump.cxx |  131 ++++++++++++++++++++++++++++++++++++
 2 files changed, 133 insertions(+)

New commits:
commit bbcce6e10cf9e46b0a8521e50d3dd69ea44481a0
Author: Adam Co <rattles2013 at gmail.com>
Date:   Tue Nov 26 14:10:36 2013 +0200

    Added dump of 'redline' objects in 'node dump' XML
    
    Change-Id: I531a04fd4747a4b10858f6317b7c08cceb6458eb
    Reviewed-on: https://gerrit.libreoffice.org/6817
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/inc/docary.hxx b/sw/inc/docary.hxx
index 4525763..8927cde 100644
--- a/sw/inc/docary.hxx
+++ b/sw/inc/docary.hxx
@@ -165,6 +165,8 @@ public:
     void DeleteAndDestroy( sal_uInt16 nPos, sal_uInt16 nLen = 1 );
     void DeleteAndDestroyAll();
 
+    void dumpAsXml(xmlTextWriterPtr w);
+
     /** Search next or previous Redline with the same Seq. No.
        Search can be restricted via Lookahaed.
        Using 0 or USHRT_MAX makes search the whole array. */
diff --git a/sw/source/core/docnode/nodedump.cxx b/sw/source/core/docnode/nodedump.cxx
index da8f4b2..5728554 100644
--- a/sw/source/core/docnode/nodedump.cxx
+++ b/sw/source/core/docnode/nodedump.cxx
@@ -18,12 +18,16 @@
 #include "fmtautofmt.hxx"
 #include "charfmt.hxx"
 #include "paratr.hxx"
+#include "redline.hxx"
+#include <swmodule.hxx>
 #include <svl/itemiter.hxx>
 #include <svl/intitem.hxx>
+#include <tools/datetimeutils.hxx>
 
 #include <libxml/encoding.h>
 #include <libxml/xmlwriter.h>
 #include <boost/optional.hpp>
+#include <rtl/strbuf.hxx>
 
 namespace
 {
@@ -112,6 +116,7 @@ void SwDoc::dumpAsXml( xmlTextWriterPtr w )
     mpTxtFmtCollTbl->dumpAsXml( writer );
     mpCharFmtTbl->dumpAsXml( writer );
     mpNumRuleTbl->dumpAsXml( writer );
+    mpRedlineTbl->dumpAsXml( writer );
     writer.endElement();
 }
 
@@ -428,4 +433,130 @@ void SwTxtNode::dumpAsXml( xmlTextWriterPtr w )
     writer.endElement();
 }
 
+void SwRedlineTbl::dumpAsXml( xmlTextWriterPtr w )
+{
+    WriterHelper writer( w );
+
+    writer.startElement( "swredlinetbl" );
+    writer.writeFormatAttribute( "ptr", "%p", this );
+
+    for( sal_uInt16 nCurRedlinePos = 0; nCurRedlinePos < size(); ++nCurRedlinePos )
+    {
+        const SwRedlineTbl& redlineTbl = (*this);
+        const SwRedline* pRedline = redlineTbl[ nCurRedlinePos ];
+
+        writer.startElement( "swredline" );
+        writer.writeFormatAttribute( "ptr", "%p", pRedline );
+
+        OString aId( OString::number( pRedline->GetSeqNo() ) );
+        const OUString &rAuthor( SW_MOD()->GetRedlineAuthor( pRedline->GetAuthor() ) );
+        OString aAuthor( OUStringToOString( rAuthor, RTL_TEXTENCODING_UTF8 ) );
+        OString aDate( DateTimeToOString( pRedline->GetTimeStamp() ) );
+        OString sRedlineType;
+        switch( pRedline->GetType() )
+        {
+            case nsRedlineType_t::REDLINE_INSERT:
+                sRedlineType = "REDLINE_INSERT";
+                break;
+            case nsRedlineType_t::REDLINE_DELETE:
+                sRedlineType = "REDLINE_DELETE";
+                break;
+            case nsRedlineType_t::REDLINE_FORMAT:
+                sRedlineType = "REDLINE_FORMAT";
+                break;
+            default:
+                sRedlineType = "UNKNOWN";
+                break;
+        };
+        writer.writeFormatAttribute( "id", "%s", BAD_CAST(aId.getStr()) );
+        writer.writeFormatAttribute( "author", "%s", BAD_CAST(aAuthor.getStr()) );
+        writer.writeFormatAttribute( "date", "%s", BAD_CAST(aDate.getStr()) );
+        writer.writeFormatAttribute( "type", "%s", BAD_CAST(sRedlineType.getStr()) );
+        {
+            const SwPosition* pStart = pRedline->Start();
+
+            writer.startElement( "start_swposition" );
+            //writer.writeFormatAttribute( "ptr", "%p", pStart );
+            {
+                const SwNodeIndex pStartNodeIndex = pStart->nNode;
+                //writer.startElement( "swnodeindex" );
+                //writer.writeFormatAttribute( "ptr", "%p", &pStartNodeIndex );
+                {
+                    const SwNode&     pStartSwNode      = pStartNodeIndex.GetNode();
+                    //writer.startElement( "swnode" );
+                    //writer.writeFormatAttribute( "ptr", "%p", &pStartSwNode );
+                    //writer.writeFormatAttribute( "type", "%d", pStartSwNode.GetNodeType() );
+                    //writer.endElement( );    // swnode
+                    writer.writeFormatAttribute( "swnode_type", "%d", pStartSwNode.GetNodeType() );
+
+                    const SwIndex&    pStartContent   = pStart->nContent;
+                    //writer.startElement( "swindex" );
+                    //writer.writeFormatAttribute( "ptr", "%p", &pStartContent );
+                    //writer.writeFormatAttribute( "content_index", "%d", pStartContent.GetIndex() );
+                    //writer.endElement( );    // swindex
+                    writer.writeFormatAttribute( "swindex_content_index", "%d", pStartContent.GetIndex() );
+                }
+                //writer.endElement( );    // swnodeindex
+            }
+            writer.endElement( );    // start_swposition
+
+
+            const SwPosition* pEnd;
+            bool bEndIsMark = false;
+            if ( pStart == pRedline->GetPoint() )
+            {
+                // End = Mark
+                pEnd = pRedline->GetMark();
+                bEndIsMark = true;
+            }
+            else
+            {
+                // End = Point
+                pEnd = pRedline->GetPoint();
+            }
+
+            writer.startElement( "end___swposition" );
+            //writer.writeFormatAttribute( "ptr", "%p", pStart );
+            {
+                const SwNodeIndex pEndNodeIndex = pEnd->nNode;
+                //writer.startElement( "swnodeindex" );
+                //writer.writeFormatAttribute( "ptr", "%p", &pEndNodeIndex );
+                {
+                    const SwNode&     pEndSwNode      = pEndNodeIndex.GetNode();
+                    //writer.startElement( "swnode" );
+                    //writer.writeFormatAttribute( "ptr", "%p", &pEndSwNode );
+                    //writer.writeFormatAttribute( "type", "%d", pEndSwNode.GetNodeType() );
+                    //writer.endElement( );    // swnode
+                    writer.writeFormatAttribute( "swnode_type", "%d", pEndSwNode.GetNodeType() );
+
+                    const SwIndex&    pEndContent   = pEnd->nContent;
+                    //writer.startElement( "swindex" );
+                    //writer.writeFormatAttribute( "ptr", "%p", &pEndContent );
+                    //writer.writeFormatAttribute( "content_index", "%d", pEndContent.GetIndex() );
+                    //writer.endElement( );    // swindex
+                    writer.writeFormatAttribute( "swindex_content_index", "%d", pEndContent.GetIndex() );
+                }
+                //writer.endElement( );    // swnodeindex
+            }
+            writer.writeFormatAttribute( "end_is", "%s", BAD_CAST(bEndIsMark ? "mark" : "point"));
+            writer.endElement( );    // end_swposition
+
+            //const SwRedlineData& aRedlineData = pRedline->GetRedlineData();
+            const SwRedlineExtraData* pExtraRedlineData = pRedline->GetExtraData();
+            writer.startElement( "extra_redline_data" );
+            {
+                if (pExtraRedlineData == NULL)
+                    writer.writeFormatAttribute( "data", "%s", BAD_CAST( "none" ) );
+                else
+                    writer.writeFormatAttribute( "data", "%s", BAD_CAST( "exists" ) );
+            }
+            writer.endElement( );    // end_swposition
+        }
+
+        writer.endElement( );    // extra_redline_data
+    }
+
+    writer.endElement( );    // swredlinetbl
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */


More information about the Libreoffice-commits mailing list