summaryrefslogtreecommitdiff
path: root/editeng
diff options
context:
space:
mode:
authorNoel Grandin <noel@peralex.com>2016-09-30 16:49:56 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2016-10-03 06:08:14 +0000
commitba3521f28831f41c92aa863ba6ba6da7c91c56f7 (patch)
tree23cd127507e7b6f0268de65716c8ed559874cd25 /editeng
parentbc4715ddac99ca104e1ba6b313f089cfe4039381 (diff)
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>
Diffstat (limited to 'editeng')
-rw-r--r--editeng/source/editeng/editdoc.cxx5
-rw-r--r--editeng/source/editeng/editobj.cxx4
-rw-r--r--editeng/source/outliner/outliner.cxx40
-rw-r--r--editeng/source/outliner/outlobj.cxx4
-rw-r--r--editeng/source/outliner/paralist.cxx18
-rw-r--r--editeng/source/outliner/paralist.hxx2
6 files changed, 61 insertions, 12 deletions
diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx
index b67c97ca4c4f..cdc06a8c9e41 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -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;
}
diff --git a/editeng/source/editeng/editobj.cxx b/editeng/source/editeng/editobj.cxx
index 8e53e3d646fc..5fcc8c790a24 100644
--- a/editeng/source/editeng/editobj.cxx
+++ b/editeng/source/editeng/editobj.cxx
@@ -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);
diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx
index 4876df86961d..1a2861054105 100644
--- a/editeng/source/outliner/outliner.cxx
+++ b/editeng/source/outliner/outliner.cxx
@@ -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: */
diff --git a/editeng/source/outliner/outlobj.cxx b/editeng/source/outliner/outlobj.cxx
index 9e67af1dee54..209d6d0842ef 100644
--- a/editeng/source/outliner/outlobj.cxx
+++ b/editeng/source/outliner/outlobj.cxx
@@ -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);
}
diff --git a/editeng/source/outliner/paralist.cxx b/editeng/source/outliner/paralist.cxx
index c50e576d6096..544da1e5c71d 100644
--- a/editeng/source/outliner/paralist.cxx
+++ b/editeng/source/outliner/paralist.cxx
@@ -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: */
diff --git a/editeng/source/outliner/paralist.hxx b/editeng/source/outliner/paralist.hxx
index a4e6ebb7be6b..abadc15b365e 100644
--- a/editeng/source/outliner/paralist.hxx
+++ b/editeng/source/outliner/paralist.hxx
@@ -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;