diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-02-21 11:16:07 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-02-21 19:03:00 +0100 |
commit | 76e974e078d8ad77eb316cfbe5a3e2323cac390a (patch) | |
tree | f2a7214d6b5aff5b2726f7d8278f7a9487509a12 /sw/source | |
parent | af986d2be777e7dd31ce94a70e60af754bac7131 (diff) |
Extract SwRedlineTbl::dumpAsXml() from docnode
Change-Id: I336d7875bbd88dd1993993e0e049c264b87f2318
Diffstat (limited to 'sw/source')
-rw-r--r-- | sw/source/core/doc/docredln.cxx | 50 | ||||
-rw-r--r-- | sw/source/core/docnode/nodedump.cxx | 138 |
2 files changed, 50 insertions, 138 deletions
diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx index 8d9cf0883bd2..20dcda5dfc18 100644 --- a/sw/source/core/doc/docredln.cxx +++ b/sw/source/core/doc/docredln.cxx @@ -17,6 +17,8 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <libxml/xmlwriter.h> +#include <tools/datetimeutils.hxx> #include <hintids.hxx> #include <svl/itemiter.hxx> #include <sfx2/app.hxx> @@ -564,6 +566,54 @@ const SwRangeRedline* SwRedlineTbl::FindAtPosition( const SwPosition& rSttPos, return pFnd; } +void SwRedlineTbl::dumpAsXml(xmlTextWriterPtr pWriter) const +{ + xmlTextWriterStartElement(pWriter, BAD_CAST("swRedlineTbl")); + xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this); + + for (sal_uInt16 nCurRedlinePos = 0; nCurRedlinePos < size(); ++nCurRedlinePos) + { + const SwRangeRedline* pRedline = operator[](nCurRedlinePos); + xmlTextWriterStartElement(pWriter, BAD_CAST("swRangeRedline")); + + xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", pRedline); + xmlTextWriterWriteAttribute(pWriter, BAD_CAST("id"), BAD_CAST(OString::number(pRedline->GetSeqNo()).getStr())); + xmlTextWriterWriteAttribute(pWriter, BAD_CAST("author"), BAD_CAST(SW_MOD()->GetRedlineAuthor(pRedline->GetAuthor()).toUtf8().getStr())); + xmlTextWriterWriteAttribute(pWriter, BAD_CAST("date"), BAD_CAST(DateTimeToOString(pRedline->GetTimeStamp()).getStr())); + + 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; + } + xmlTextWriterWriteAttribute(pWriter, BAD_CAST("type"), BAD_CAST(sRedlineType.getStr())); + + xmlTextWriterStartElement(pWriter, BAD_CAST("point")); + pRedline->GetPoint()->dumpAsXml(pWriter); + xmlTextWriterEndElement(pWriter); + xmlTextWriterStartElement(pWriter, BAD_CAST("mark")); + pRedline->GetMark()->dumpAsXml(pWriter); + xmlTextWriterEndElement(pWriter); + + const SwRedlineExtraData* pExtraRedlineData = pRedline->GetExtraData(); + xmlTextWriterStartElement(pWriter, BAD_CAST("swRedlineExtraData")); + xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("symbol"), "%s", BAD_CAST(typeid(pExtraRedlineData).name())); + xmlTextWriterEndElement(pWriter); // swRadlineExtraData + xmlTextWriterEndElement(pWriter); // swRangeRedline + } + xmlTextWriterEndElement(pWriter); // swRedlineTbl +} SwRedlineExtraData::~SwRedlineExtraData() { diff --git a/sw/source/core/docnode/nodedump.cxx b/sw/source/core/docnode/nodedump.cxx index 7ab7fe8e3ec6..e485e3380483 100644 --- a/sw/source/core/docnode/nodedump.cxx +++ b/sw/source/core/docnode/nodedump.cxx @@ -95,7 +95,6 @@ void WriterHelper::writeFormatAttribute( const char* attribute, const char* form // Hack: somehow conversion from "..." to va_list does // bomb on two string litterals in the format. static const char* TMP_FORMAT = "%" SAL_PRIuUINTPTR; -static const char* TMP_FORMAT_I32 = "%" SAL_PRIdINT32; } @@ -340,143 +339,6 @@ void SwTxtNode::dumpAsXml( xmlTextWriterPtr w ) const writer.endElement(); } -void SwRedlineTbl::dumpAsXml( xmlTextWriterPtr w ) const -{ - WriterHelper writer( w ); - - writer.startElement( "swredlinetbl" ); - writer.writeFormatAttribute( "ptr", "%p", this ); - - const SwRedlineTbl& redlineTbl = (*this); - - for( sal_uInt16 nCurRedlinePos = 0; nCurRedlinePos < size(); ++nCurRedlinePos ) - { - const SwRangeRedline* 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( "swposition_start" ); - //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", TMP_FORMAT, pStartSwNode.GetNodeType() ); - - writer.writeFormatAttribute( "paragraph_index", "%d", (int)pStartNodeIndex.GetIndex() ); - - 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( "character_index", TMP_FORMAT_I32, pStartContent.GetIndex() ); - } - //writer.endElement( ); // swnodeindex - } - writer.endElement( ); // swposition_start - - 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( "swposition_end" ); - //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", TMP_FORMAT, pEndSwNode.GetNodeType() ); - - writer.writeFormatAttribute( "paragraph_index", "%d", (int)pEndNodeIndex.GetIndex() ); - - 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( "character_index", TMP_FORMAT_I32, pEndContent.GetIndex() ); - } - //writer.endElement( ); // swnodeindex - } - writer.writeFormatAttribute( "end_is", "%s", BAD_CAST(bEndIsMark ? "mark" : "point")); - writer.endElement( ); // swposition_end - - //const SwRedlineData& aRedlineData = pRedline->GetRedlineData(); - const SwRedlineExtraData* pExtraRedlineData = pRedline->GetExtraData(); - writer.startElement( "extra_redline_data" ); - { - const SwRedlineExtraData_FmtColl* pExtraData_FmtColl = dynamic_cast<const SwRedlineExtraData_FmtColl*>(pExtraRedlineData); - const SwRedlineExtraData_Format* pExtraData_Format = dynamic_cast<const SwRedlineExtraData_Format*>(pExtraRedlineData); - const SwRedlineExtraData_FormattingChanges* pExtraData_FormattingChanges = dynamic_cast<const SwRedlineExtraData_FormattingChanges*>(pExtraRedlineData); - if (pExtraData_FmtColl) - writer.writeFormatAttribute( "extra_data_type", "%s", BAD_CAST( "fmt coll" ) ); - else if (pExtraData_Format) - writer.writeFormatAttribute( "extra_data_type", "%s", BAD_CAST( "format" ) ); - else if (pExtraData_FormattingChanges) - writer.writeFormatAttribute( "extra_data_type", "%s", BAD_CAST( "formatting changes" ) ); - else - writer.writeFormatAttribute( "extra_data_type", "%s", BAD_CAST( "UNKNOWN" ) ); - } - writer.endElement( ); // extra_redline_data - } - - writer.endElement( ); // extra_redline_data - } - - writer.endElement( ); // swredlinetbl -} - void SwExtraRedlineTbl::dumpAsXml( xmlTextWriterPtr w ) const { WriterHelper writer( w ); |