diff options
author | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-01-31 18:09:05 +0100 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.co.uk> | 2015-01-31 18:09:25 +0100 |
commit | e4b0d63c134e7833db562f4eef93bbf828ea1b9d (patch) | |
tree | acdd48c6a14d27b299a3c067f73b6091e285661a | |
parent | d2a6d6a1a05337dbb733a9a3d4926a5c6d6cd8cd (diff) |
Extract SfxUndoAction::dumpAsXml() from sw
Change-Id: I7ec2071150c03b61f3f681dbd26968ae3c535742
-rw-r--r-- | include/svl/undo.hxx | 2 | ||||
-rw-r--r-- | svl/source/undo/undo.cxx | 21 | ||||
-rw-r--r-- | sw/source/core/docnode/nodedump.cxx | 20 |
3 files changed, 24 insertions, 19 deletions
diff --git a/include/svl/undo.hxx b/include/svl/undo.hxx index 92a9907db0f2..2c1923876ab6 100644 --- a/include/svl/undo.hxx +++ b/include/svl/undo.hxx @@ -71,6 +71,7 @@ public: virtual OUString GetComment() const; virtual OUString GetRepeatComment(SfxRepeatTarget&) const; virtual sal_uInt16 GetId() const; + virtual void dumpAsXml(struct _xmlTextWriter* pWriter) const; private: SfxUndoAction( const SfxUndoAction& ); // disabled @@ -159,6 +160,7 @@ public: virtual sal_uInt16 GetId() const SAL_OVERRIDE; void SetComment(const OUString& rComment); + void dumpAsXml(struct _xmlTextWriter* pWriter) const SAL_OVERRIDE; }; diff --git a/svl/source/undo/undo.cxx b/svl/source/undo/undo.cxx index 772dd43af580..1fcc6497ff5f 100644 --- a/svl/source/undo/undo.cxx +++ b/svl/source/undo/undo.cxx @@ -24,6 +24,7 @@ #include <osl/mutex.hxx> #include <comphelper/flagguard.hxx> #include <tools/diagnose_ex.h> +#include <libxml/xmlwriter.h> #include <vector> #include <list> @@ -135,6 +136,14 @@ bool SfxUndoAction::CanRepeat(SfxRepeatTarget&) const return true; } +void SfxUndoAction::dumpAsXml(xmlTextWriterPtr pWriter) const +{ + xmlTextWriterStartElement(pWriter, BAD_CAST("sfxUndoAction")); + xmlTextWriterWriteAttribute(pWriter, BAD_CAST("symbol"), BAD_CAST(typeid(*this).name())); + xmlTextWriterWriteAttribute(pWriter, BAD_CAST("comment"), BAD_CAST(GetComment().toUtf8().getStr())); + xmlTextWriterEndElement(pWriter); +} + struct MarkedUndoAction { SfxUndoAction* pAction; @@ -1372,6 +1381,18 @@ bool SfxListUndoAction::Merge( SfxUndoAction *pNextAction ) return !aUndoActions.empty() && aUndoActions[aUndoActions.size()-1].pAction->Merge( pNextAction ); } +void SfxListUndoAction::dumpAsXml(xmlTextWriterPtr pWriter) const +{ + xmlTextWriterStartElement(pWriter, BAD_CAST("sfxListUndoAction")); + xmlTextWriterWriteAttribute(pWriter, BAD_CAST("size"), BAD_CAST(OString::number(aUndoActions.size()).getStr())); + SfxUndoAction::dumpAsXml(pWriter); + + for (size_t i = 0; i < aUndoActions.size(); ++i) + aUndoActions.GetUndoAction(i)->dumpAsXml(pWriter); + + xmlTextWriterEndElement(pWriter); +} + /** * Creates a LinkAction which points to another UndoManager. * Gets that UndoManagers current Action and sets it as that UndoManager's diff --git a/sw/source/core/docnode/nodedump.cxx b/sw/source/core/docnode/nodedump.cxx index 67ea050d8310..902c49469911 100644 --- a/sw/source/core/docnode/nodedump.cxx +++ b/sw/source/core/docnode/nodedump.cxx @@ -656,24 +656,6 @@ void SwExtraRedlineTbl::dumpAsXml( xmlTextWriterPtr w ) const writer.endElement( ); // swextraredlinetbl } -void lcl_dumpSfxUndoAction(WriterHelper& writer, SfxUndoAction* pAction) -{ - writer.startElement("undoAction"); - writer.writeFormatAttribute("symbol", "%s", BAD_CAST(typeid(*pAction).name())); - writer.writeFormatAttribute("comment", "%s", BAD_CAST(OUStringToOString(pAction->GetComment(), RTL_TEXTENCODING_UTF8).getStr())); - - if (SfxListUndoAction* pList = dynamic_cast<SfxListUndoAction*>(pAction)) - { - writer.startElement("list"); - writer.writeFormatAttribute("size", TMP_FORMAT, pList->aUndoActions.size()); - for (size_t i = 0; i < pList->aUndoActions.size(); ++i) - lcl_dumpSfxUndoAction(writer, pList->aUndoActions.GetUndoAction(i)); - writer.endElement(); - } - - writer.endElement(); -} - void sw::UndoManager::dumpAsXml(xmlTextWriterPtr w) { WriterHelper writer(w); @@ -682,7 +664,7 @@ void sw::UndoManager::dumpAsXml(xmlTextWriterPtr w) writer.writeFormatAttribute("nUndoActionCount", TMP_FORMAT, GetUndoActionCount()); for (size_t i = 0; i < GetUndoActionCount(); ++i) - lcl_dumpSfxUndoAction(writer, GetUndoAction(i)); + GetUndoAction(i)->dumpAsXml(w); writer.endElement(); } |