diff options
author | Adam Co <rattles2013@gmail.com> | 2013-11-26 14:10:36 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2013-11-26 07:16:32 -0600 |
commit | bbcce6e10cf9e46b0a8521e50d3dd69ea44481a0 (patch) | |
tree | 985c72c0f677df16363c580c6da5ede76826b2d6 | |
parent | aaf5658a2f0e1a371dc5257feeda7f3c4e304651 (diff) |
Added dump of 'redline' objects in 'node dump' XML
Change-Id: I531a04fd4747a4b10858f6317b7c08cceb6458eb
Reviewed-on: https://gerrit.libreoffice.org/6817
Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
Tested-by: Miklos Vajna <vmiklos@collabora.co.uk>
-rw-r--r-- | sw/inc/docary.hxx | 2 | ||||
-rw-r--r-- | sw/source/core/docnode/nodedump.cxx | 131 |
2 files changed, 133 insertions, 0 deletions
diff --git a/sw/inc/docary.hxx b/sw/inc/docary.hxx index 4525763749a3..8927cdea2eeb 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 da8f4b2a338a..57285548561c 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: */ |