summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2016-09-27 13:51:40 +0200
committerNoel Grandin <noel@peralex.com>2016-09-28 08:44:36 +0200
commit678bdd064af207a7b90e3e44d652eb59be7db61f (patch)
treea1c14ac6777995ed9866abc83b6ff4bcbbbb5a9f /editeng
parent62b2d8ff356e7ac74dc0a66f1630e704af270356 (diff)
extend dumpAsXml to EditDoc
Change-Id: I71464b20c5897a2af3b4069f7f0963ef55dcd8c4
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/editeng/editattr.cxx10
-rw-r--r--editeng/source/editeng/editattr.hxx2
-rw-r--r--editeng/source/editeng/editdoc.cxx51
-rw-r--r--editeng/source/editeng/editdoc.hxx9
-rw-r--r--editeng/source/editeng/editobj.cxx14
5 files changed, 85 insertions, 1 deletions
diff --git a/editeng/source/editeng/editattr.cxx b/editeng/source/editeng/editattr.cxx
index a274d8b3ffcf..dbd428bb8cd3 100644
--- a/editeng/source/editeng/editattr.cxx
+++ b/editeng/source/editeng/editattr.cxx
@@ -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
diff --git a/editeng/source/editeng/editattr.hxx b/editeng/source/editeng/editattr.hxx
index 3dffbe2197d7..f49898b50952 100644
--- a/editeng/source/editeng/editattr.hxx
+++ b/editeng/source/editeng/editattr.hxx
@@ -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; }
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx
index 2f04b7181412..b67c97ca4c4f 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -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,
diff --git a/editeng/source/editeng/editdoc.hxx b/editeng/source/editeng/editdoc.hxx
index cd3fd86a0c2b..182d09f775b5 100644
--- a/editeng/source/editeng/editdoc.hxx
+++ b/editeng/source/editeng/editdoc.hxx
@@ -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 );
diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx
index 6df0e418ea91..8e53e3d646fc 100644
--- a/editeng/source/editeng/editobj.cxx
+++ b/editeng/source/editeng/editobj.cxx
@@ -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