add more dumpAsXml()

and make it format the output nicely, so I don't have to use 'xmllint
--format' before I can read it.

Change-Id: I065ee93193f3c6c7bab87212ab96021fb0d7c5ed
Reviewed-on: https://gerrit.libreoffice.org/29407
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2016-09-30 16:49:56 +02:00 committed by Noel Grandin
parent bc4715ddac
commit ba3521f288
16 changed files with 95 additions and 13 deletions

View File

@ -1651,7 +1651,7 @@ void ContentNode::SetStyleSheet( SfxStyleSheet* pS, const SvxFont& rFontFromStyl
GetCharAttribs().GetDefFont() = rFontFromStyle;
// ... then iron out the hard paragraph formatting...
CreateFont( GetCharAttribs().GetDefFont(),
GetContentAttribs().GetItems(), pS == nullptr );
GetContentAttribs().GetItems(), pS == nullptr );
}
void ContentNode::SetStyleSheet( SfxStyleSheet* pS, bool bRecalcFont )
@ -1944,6 +1944,7 @@ bool ContentAttribs::HasItem( sal_uInt16 nWhich ) const
void ContentAttribs::dumpAsXml(struct _xmlTextWriter* pWriter) const
{
xmlTextWriterStartElement(pWriter, BAD_CAST("contentAttribs"));
xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("style"), "%s", pStyle->GetName().toUtf8().getStr());
aAttribSet.dumpAsXml(pWriter);
xmlTextWriterEndElement(pWriter);
}
@ -2742,6 +2743,8 @@ void EditDoc::dumpAsXml(struct _xmlTextWriter* pWriter) const
if (!pWriter)
{
pWriter = xmlNewTextWriterFilename("editdoc.xml", 0);
xmlTextWriterSetIndent(pWriter,1);
xmlTextWriterSetIndentString(pWriter, BAD_CAST(" "));
xmlTextWriterStartDocument(pWriter, nullptr, nullptr, nullptr);
bOwns = true;
}

View File

@ -462,6 +462,8 @@ void EditTextObject::dumpAsXml(xmlTextWriterPtr pWriter) const
if (!pWriter)
{
pWriter = xmlNewTextWriterFilename("editTextObject.xml", 0);
xmlTextWriterSetIndent(pWriter,1);
xmlTextWriterSetIndentString(pWriter, BAD_CAST(" "));
xmlTextWriterStartDocument(pWriter, nullptr, nullptr, nullptr);
bOwns = true;
}
@ -470,9 +472,7 @@ void EditTextObject::dumpAsXml(xmlTextWriterPtr pWriter) const
sal_Int32 nCount = GetParagraphCount();
for (sal_Int32 i = 0; i < nCount; ++i)
{
xmlTextWriterStartElement(pWriter, BAD_CAST("paragraph"));
mpImpl->aContents[i]->dumpAsXml(pWriter);
xmlTextWriterEndElement(pWriter);
}
xmlTextWriterEndElement(pWriter);

View File

@ -51,6 +51,7 @@
#include <editeng/svxfont.hxx>
#include <editeng/brushitem.hxx>
#include <svl/itempool.hxx>
#include <libxml/xmlwriter.h>
// calculate if it's RTL or not
#include <unicode/ubidi.h>
@ -675,19 +676,19 @@ OUString Outliner::CalcFieldValue( const SvxFieldItem& rField, sal_Int32 nPara,
void Outliner::SetStyleSheet( sal_Int32 nPara, SfxStyleSheet* pStyle )
{
Paragraph* pPara = pParaList->GetParagraph( nPara );
if (pPara)
{
pEditEngine->SetStyleSheet( nPara, pStyle );
pPara->nFlags |= ParaFlag::SETBULLETTEXT;
ImplCheckNumBulletItem( nPara );
}
if (pPara)
{
pEditEngine->SetStyleSheet( nPara, pStyle );
pPara->nFlags |= ParaFlag::SETBULLETTEXT;
ImplCheckNumBulletItem( nPara );
}
}
void Outliner::ImplCheckNumBulletItem( sal_Int32 nPara )
{
Paragraph* pPara = pParaList->GetParagraph( nPara );
if (pPara)
pPara->aBulSize.Width() = -1;
if (pPara)
pPara->aBulSize.Width() = -1;
}
void Outliner::ImplSetLevelDependendStyleSheet( sal_Int32 nPara )
@ -2193,4 +2194,27 @@ void Outliner::ClearOverflowingParaNum()
pEditEngine->ClearOverflowingParaNum();
}
void Outliner::dumpAsXml(struct _xmlTextWriter* pWriter) const
{
bool bOwns = false;
if (!pWriter)
{
pWriter = xmlNewTextWriterFilename("outliner.xml", 0);
xmlTextWriterSetIndent(pWriter,1);
xmlTextWriterSetIndentString(pWriter, BAD_CAST(" "));
xmlTextWriterStartDocument(pWriter, nullptr, nullptr, nullptr);
bOwns = true;
}
xmlTextWriterStartElement(pWriter, BAD_CAST("outliner"));
pParaList->dumpAsXml(pWriter);
xmlTextWriterEndElement(pWriter);
if (bOwns)
{
xmlTextWriterEndDocument(pWriter);
xmlFreeTextWriter(pWriter);
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -227,7 +227,9 @@ void OutlinerParaObject::dumpAsXml(xmlTextWriterPtr pWriter) const
{
xmlTextWriterStartElement(pWriter, BAD_CAST("outlinerParaObject"));
xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
GetTextObject().dumpAsXml(pWriter);
mpImpl->mpEditTextObject->dumpAsXml(pWriter);
for (Paragraph const & p : mpImpl->maParagraphDataVector)
p.dumpAsXml(pWriter);
xmlTextWriterEndElement(pWriter);
}

View File

@ -25,6 +25,7 @@
#include <osl/diagnose.h>
#include <tools/debug.hxx>
#include <libxml/xmlwriter.h>
#include <iterator>
@ -96,6 +97,15 @@ void Paragraph::SetParaIsNumberingRestart( bool bParaIsNumberingRestart )
mnNumberingStartValue = -1;
}
void Paragraph::dumpAsXml(struct _xmlTextWriter* pWriter) const
{
xmlTextWriterStartElement(pWriter, BAD_CAST("paragraph"));
xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("nDepth"), "%" SAL_PRIdINT32, (sal_Int32)nDepth);
xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("mnNumberingStartValue"), "%" SAL_PRIdINT32, (sal_Int32)mnNumberingStartValue);
xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("mbParaIsNumberingRestart"), "%" SAL_PRIdINT32, (sal_Int32)mbParaIsNumberingRestart);
xmlTextWriterEndElement(pWriter);
}
void ParagraphList::Clear()
{
std::vector<Paragraph*>::iterator iter;
@ -254,4 +264,12 @@ sal_Int32 ParagraphList::GetAbsPos( Paragraph* pParent ) const
return EE_PARA_NOT_FOUND;
}
void ParagraphList::dumpAsXml(struct _xmlTextWriter* pWriter) const
{
xmlTextWriterStartElement(pWriter, BAD_CAST("paragraphList"));
for (const Paragraph* pParagraph : maEntries)
pParagraph->dumpAsXml(pWriter);
xmlTextWriterEndElement(pWriter);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -68,6 +68,8 @@ public:
void SetVisibleStateChangedHdl( const Link<Paragraph&,void>& rLink ) { aVisibleStateChangedHdl = rLink; }
void dumpAsXml(struct _xmlTextWriter* pWriter) const;
private:
Link<Paragraph&,void> aVisibleStateChangedHdl;

View File

@ -148,7 +148,7 @@ private:
void SetText( const OUString& rText ) { aBulText = rText; aBulSize.Width() = -1; }
void Invalidate() { aBulSize.Width() = -1; }
void SetDepth( sal_Int16 nNewDepth ) { nDepth = nNewDepth; aBulSize.Width() = -1; }
const OUString& GetText() const { return aBulText; }
const OUString& GetText() const { return aBulText; }
Paragraph( sal_Int16 nDepth );
Paragraph( const Paragraph& ) = delete;
@ -166,6 +166,8 @@ private:
void SetFlag( ParaFlag nFlag ) { nFlags |= nFlag; }
void RemoveFlag( ParaFlag nFlag ) { nFlags &= ~nFlag; }
bool HasFlag( ParaFlag nFlag ) const { return bool(nFlags & nFlag); }
public:
void dumpAsXml(struct _xmlTextWriter* pWriter) const;
};
struct ParaRange
@ -679,6 +681,8 @@ public:
Outliner( SfxItemPool* pPool, OutlinerMode nOutlinerMode );
virtual ~Outliner() override;
void dumpAsXml(struct _xmlTextWriter* pWriter) const;
void Init( OutlinerMode nOutlinerMode );
OutlinerMode GetMode() const { return nOutlinerMode; }

View File

@ -206,6 +206,8 @@ public:
static const SfxItemPool* GetStoringPool();
void dumpAsXml(struct _xmlTextWriter* pWriter) const;
private:
const SfxItemPool& operator=(const SfxItemPool &) = delete;

View File

@ -74,6 +74,8 @@ void ScGridWindow::dumpCellProperties()
OString aOutputFile("dump.xml");
xmlTextWriterPtr writer = xmlNewTextWriterFilename( aOutputFile.getStr(), 0 );
xmlTextWriterSetIndent(writer,1);
xmlTextWriterSetIndentString(writer, BAD_CAST(" "));
xmlTextWriterStartDocument( writer, nullptr, nullptr, nullptr );

View File

@ -1096,12 +1096,16 @@ void SdDrawDocument::dumpAsXml(xmlTextWriterPtr pWriter) const
if (!pWriter)
{
pWriter = xmlNewTextWriterFilename("model.xml", 0);
xmlTextWriterSetIndent(pWriter,1);
xmlTextWriterSetIndentString(pWriter, BAD_CAST(" "));
xmlTextWriterStartDocument(pWriter, nullptr, nullptr, nullptr);
bOwns = true;
}
xmlTextWriterStartElement(pWriter, BAD_CAST("sdDrawDocument"));
xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
if (mpOutliner)
mpOutliner->dumpAsXml(pWriter);
FmFormModel::dumpAsXml(pWriter);
if (GetUndoManager())
GetUndoManager()->dumpAsXml(pWriter);

View File

@ -20,6 +20,7 @@
#include <svl/itempool.hxx>
#include <string.h>
#include <libxml/xmlwriter.h>
#include <osl/diagnose.h>
#include <sal/log.hxx>
@ -993,4 +994,15 @@ void SfxItemPool::SetFileFormatVersion( sal_uInt16 nFileFormatVersion )
const SfxItemPool* SfxItemPool::pStoringPool_ = nullptr;
void SfxItemPool::dumpAsXml(xmlTextWriterPtr pWriter) const
{
xmlTextWriterStartElement(pWriter, BAD_CAST("sfxItemPool"));
for (auto const & rArrayPtr : pImpl->maPoolItems)
if (rArrayPtr)
for (auto const & rItem : *rArrayPtr)
if (rItem)
rItem->dumpAsXml(pWriter);
xmlTextWriterEndElement(pWriter);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@ -1269,6 +1269,8 @@ void SfxUndoManager::dumpAsXml(xmlTextWriterPtr pWriter) const
if (!pWriter)
{
pWriter = xmlNewTextWriterFilename("undo.xml", 0);
xmlTextWriterSetIndent(pWriter,1);
xmlTextWriterSetIndentString(pWriter, BAD_CAST(" "));
xmlTextWriterStartDocument(pWriter, nullptr, nullptr, nullptr);
bOwns = true;
}

View File

@ -261,6 +261,7 @@ OUString NameOrIndex::CheckNamedItem( const NameOrIndex* pCheckItem, const sal_u
void NameOrIndex::dumpAsXml(xmlTextWriterPtr pWriter) const
{
xmlTextWriterStartElement(pWriter, BAD_CAST("nameOrIndex"));
xmlTextWriterWriteAttribute(pWriter, BAD_CAST("whichId"), BAD_CAST(OString::number(Which()).getStr()));
xmlTextWriterWriteAttribute(pWriter, BAD_CAST("isIndex"), BAD_CAST(OString::boolean(IsIndex()).getStr()));
xmlTextWriterWriteAttribute(pWriter, BAD_CAST("name"), BAD_CAST(GetName().toUtf8().getStr()));
xmlTextWriterWriteAttribute(pWriter, BAD_CAST("index"), BAD_CAST(OString::number(GetIndex()).getStr()));

View File

@ -1920,6 +1920,8 @@ void SwDoc::dumpAsXml(xmlTextWriterPtr pWriter) const
if (!pWriter)
{
pWriter = xmlNewTextWriterFilename("nodes.xml", 0);
xmlTextWriterSetIndent(pWriter,1);
xmlTextWriterSetIndentString(pWriter, BAD_CAST(" "));
xmlTextWriterStartDocument(pWriter, nullptr, nullptr, nullptr);
bOwns = true;
}

View File

@ -216,6 +216,8 @@ namespace
xmlTextWriterPtr lcl_createDefaultWriter()
{
xmlTextWriterPtr writer = xmlNewTextWriterFilename( "layout.xml", 0 );
xmlTextWriterSetIndent(writer,1);
xmlTextWriterSetIndentString(writer, BAD_CAST(" "));
xmlTextWriterStartDocument( writer, nullptr, nullptr, nullptr );
return writer;
}

View File

@ -67,6 +67,8 @@ namespace writerfilter
fileName += ".xml";
pWriter = xmlNewTextWriterFilename( fileName.c_str(), 0 );
xmlTextWriterSetIndent(pWriter,1);
xmlTextWriterSetIndentString(pWriter, BAD_CAST(" "));
xmlTextWriterSetIndent( pWriter, 4 );
}