Kaydet (Commit) e4b0d63c authored tarafından Miklos Vajna's avatar Miklos Vajna

Extract SfxUndoAction::dumpAsXml() from sw

Change-Id: I7ec2071150c03b61f3f681dbd26968ae3c535742
üst d2a6d6a1
...@@ -71,6 +71,7 @@ public: ...@@ -71,6 +71,7 @@ public:
virtual OUString GetComment() const; virtual OUString GetComment() const;
virtual OUString GetRepeatComment(SfxRepeatTarget&) const; virtual OUString GetRepeatComment(SfxRepeatTarget&) const;
virtual sal_uInt16 GetId() const; virtual sal_uInt16 GetId() const;
virtual void dumpAsXml(struct _xmlTextWriter* pWriter) const;
private: private:
SfxUndoAction( const SfxUndoAction& ); // disabled SfxUndoAction( const SfxUndoAction& ); // disabled
...@@ -159,6 +160,7 @@ public: ...@@ -159,6 +160,7 @@ public:
virtual sal_uInt16 GetId() const SAL_OVERRIDE; virtual sal_uInt16 GetId() const SAL_OVERRIDE;
void SetComment(const OUString& rComment); void SetComment(const OUString& rComment);
void dumpAsXml(struct _xmlTextWriter* pWriter) const SAL_OVERRIDE;
}; };
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <osl/mutex.hxx> #include <osl/mutex.hxx>
#include <comphelper/flagguard.hxx> #include <comphelper/flagguard.hxx>
#include <tools/diagnose_ex.h> #include <tools/diagnose_ex.h>
#include <libxml/xmlwriter.h>
#include <vector> #include <vector>
#include <list> #include <list>
...@@ -135,6 +136,14 @@ bool SfxUndoAction::CanRepeat(SfxRepeatTarget&) const ...@@ -135,6 +136,14 @@ bool SfxUndoAction::CanRepeat(SfxRepeatTarget&) const
return true; 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 struct MarkedUndoAction
{ {
SfxUndoAction* pAction; SfxUndoAction* pAction;
...@@ -1372,6 +1381,18 @@ bool SfxListUndoAction::Merge( SfxUndoAction *pNextAction ) ...@@ -1372,6 +1381,18 @@ bool SfxListUndoAction::Merge( SfxUndoAction *pNextAction )
return !aUndoActions.empty() && aUndoActions[aUndoActions.size()-1].pAction->Merge( 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. * Creates a LinkAction which points to another UndoManager.
* Gets that UndoManagers current Action and sets it as that UndoManager's * Gets that UndoManagers current Action and sets it as that UndoManager's
......
...@@ -656,24 +656,6 @@ void SwExtraRedlineTbl::dumpAsXml( xmlTextWriterPtr w ) const ...@@ -656,24 +656,6 @@ void SwExtraRedlineTbl::dumpAsXml( xmlTextWriterPtr w ) const
writer.endElement( ); // swextraredlinetbl 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) void sw::UndoManager::dumpAsXml(xmlTextWriterPtr w)
{ {
WriterHelper writer(w); WriterHelper writer(w);
...@@ -682,7 +664,7 @@ void sw::UndoManager::dumpAsXml(xmlTextWriterPtr w) ...@@ -682,7 +664,7 @@ void sw::UndoManager::dumpAsXml(xmlTextWriterPtr w)
writer.writeFormatAttribute("nUndoActionCount", TMP_FORMAT, GetUndoActionCount()); writer.writeFormatAttribute("nUndoActionCount", TMP_FORMAT, GetUndoActionCount());
for (size_t i = 0; i < GetUndoActionCount(); ++i) for (size_t i = 0; i < GetUndoActionCount(); ++i)
lcl_dumpSfxUndoAction(writer, GetUndoAction(i)); GetUndoAction(i)->dumpAsXml(w);
writer.endElement(); writer.endElement();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment