extend dumpAsXml to EditDoc

Change-Id: I71464b20c5897a2af3b4069f7f0963ef55dcd8c4
This commit is contained in:
Noel Grandin 2016-09-27 13:51:40 +02:00
parent 62b2d8ff35
commit 678bdd064a
5 changed files with 85 additions and 1 deletions

View File

@ -24,6 +24,7 @@
#include <vcl/svapp.hxx>
#include <svl/grabbagitem.hxx>
#include <libxml/xmlwriter.h>
#include <editeng/svxfont.hxx>
#include <editeng/flditem.hxx>
#include <editeng/fontitem.hxx>
@ -68,6 +69,15 @@ void EditCharAttrib::SetFont( SvxFont&, OutputDevice* )
{
}
void EditCharAttrib::dumpAsXml(xmlTextWriterPtr pWriter) const
{
xmlTextWriterStartElement(pWriter, BAD_CAST("editCharAttrib"));
xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("nStart"), "%d", nStart);
xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("nEnd"), "%d", nEnd);
pItem->dumpAsXml(pWriter);
xmlTextWriterEndElement(pWriter);
}
// class EditCharAttribFont

View File

@ -80,6 +80,8 @@ public:
EditCharAttrib(const EditCharAttrib&) = delete;
EditCharAttrib& operator=(const EditCharAttrib&) = delete;
void dumpAsXml(struct _xmlTextWriter* pWriter) const;
sal_uInt16 Which() const { return pItem->Which(); }
const SfxPoolItem* GetItem() const { return pItem; }

View File

@ -63,6 +63,7 @@
#include <tools/stream.hxx>
#include <tools/debug.hxx>
#include <com/sun/star/i18n/ScriptType.hpp>
#include <libxml/xmlwriter.h>
#include <cassert>
#include <limits>
@ -1856,6 +1857,16 @@ void ContentNode::DestroyWrongList()
mpWrongList.reset();
}
void ContentNode::dumpAsXml(struct _xmlTextWriter* pWriter) const
{
xmlTextWriterStartElement(pWriter, BAD_CAST("contentNode"));
xmlTextWriterWriteAttribute(pWriter, BAD_CAST("maString"), BAD_CAST(maString.toUtf8().getStr()));
aContentAttribs.dumpAsXml(pWriter);
aCharAttribList.dumpAsXml(pWriter);
xmlTextWriterEndElement(pWriter);
}
ContentAttribs::ContentAttribs( SfxItemPool& rPool )
: pStyle(nullptr)
, aAttribSet( rPool, EE_PARA_START, EE_CHAR_END )
@ -1930,6 +1941,13 @@ bool ContentAttribs::HasItem( sal_uInt16 nWhich ) const
return bHasItem;
}
void ContentAttribs::dumpAsXml(struct _xmlTextWriter* pWriter) const
{
xmlTextWriterStartElement(pWriter, BAD_CAST("contentAttribs"));
aAttribSet.dumpAsXml(pWriter);
xmlTextWriterEndElement(pWriter);
}
ItemList::ItemList() : CurrentItem( 0 )
{
@ -2718,6 +2736,31 @@ void EditDoc::FindAttribs( ContentNode* pNode, sal_Int32 nStartPos, sal_Int32 nE
}
}
void EditDoc::dumpAsXml(struct _xmlTextWriter* pWriter) const
{
bool bOwns = false;
if (!pWriter)
{
pWriter = xmlNewTextWriterFilename("editdoc.xml", 0);
xmlTextWriterStartDocument(pWriter, nullptr, nullptr, nullptr);
bOwns = true;
}
xmlTextWriterStartElement(pWriter, BAD_CAST("editDoc"));
for (auto const & i : maContents)
{
i->dumpAsXml(pWriter);
}
xmlTextWriterEndElement(pWriter);
if (bOwns)
{
xmlTextWriterEndDocument(pWriter);
xmlFreeTextWriter(pWriter);
}
}
namespace {
struct LessByStart : std::binary_function<std::unique_ptr<EditCharAttrib>, std::unique_ptr<EditCharAttrib>, bool>
@ -3017,6 +3060,14 @@ void CharAttribList::DbgCheckAttribs(CharAttribList const& rAttribs)
}
#endif
void CharAttribList::dumpAsXml(struct _xmlTextWriter* pWriter) const
{
xmlTextWriterStartElement(pWriter, BAD_CAST("charAttribList"));
for (auto const & i : aAttribs) {
i->dumpAsXml(pWriter);
}
xmlTextWriterEndElement(pWriter);
}
EditEngineItemPool::EditEngineItemPool( bool bPersistenRefCounts )
: SfxItemPool( "EditEngineItemPool", EE_ITEMS_START, EE_ITEMS_END,

View File

@ -164,6 +164,8 @@ public:
ContentAttribs( const ContentAttribs& );
~ContentAttribs(); // only for larger Tabs
void dumpAsXml(struct _xmlTextWriter* pWriter) const;
SvxTabStop FindTabStop( sal_Int32 nCurPos, sal_uInt16 nDefTab );
SfxItemSet& GetItems() { return aAttribSet; }
const SfxItemSet& GetItems() const { return aAttribSet; }
@ -194,6 +196,8 @@ public:
CharAttribList();
~CharAttribList();
void dumpAsXml(struct _xmlTextWriter* pWriter = nullptr) const;
void DeleteEmptyAttribs( SfxItemPool& rItemPool );
const EditCharAttrib* FindAttrib( sal_uInt16 nWhich, sal_Int32 nPos ) const;
@ -248,6 +252,8 @@ public:
ContentNode(const ContentNode&) = delete;
ContentNode& operator=(const ContentNode&) = delete;
void dumpAsXml(struct _xmlTextWriter* pWriter) const;
ContentAttribs& GetContentAttribs() { return aContentAttribs; }
const ContentAttribs& GetContentAttribs() const { return aContentAttribs; }
CharAttribList& GetCharAttribs() { return aCharAttribList; }
@ -747,7 +753,8 @@ public:
EditDoc( SfxItemPool* pItemPool );
~EditDoc();
void ClearSpellErrors();
void dumpAsXml(struct _xmlTextWriter* pWriter) const;
void ClearSpellErrors();
bool IsModified() const { return bModified; }
void SetModified( bool b );

View File

@ -458,6 +458,14 @@ void EditTextObject::Dump() const
void EditTextObject::dumpAsXml(xmlTextWriterPtr pWriter) const
{
bool bOwns = false;
if (!pWriter)
{
pWriter = xmlNewTextWriterFilename("editTextObject.xml", 0);
xmlTextWriterStartDocument(pWriter, nullptr, nullptr, nullptr);
bOwns = true;
}
xmlTextWriterStartElement(pWriter, BAD_CAST("editTextObject"));
sal_Int32 nCount = GetParagraphCount();
for (sal_Int32 i = 0; i < nCount; ++i)
@ -467,6 +475,12 @@ void EditTextObject::dumpAsXml(xmlTextWriterPtr pWriter) const
xmlTextWriterEndElement(pWriter);
}
xmlTextWriterEndElement(pWriter);
if (bOwns)
{
xmlTextWriterEndDocument(pWriter);
xmlFreeTextWriter(pWriter);
}
}
// from SfxItemPoolUser