editeng/source/items/numitem.cxx | 15 +++++++++++++++ include/editeng/numitem.hxx | 4 +++- sw/inc/numrule.hxx | 2 ++ sw/source/core/doc/docfmt.cxx | 2 +- sw/source/core/doc/number.cxx | 15 +++++++++++++++ 5 files changed, 36 insertions(+), 2 deletions(-)
New commits: commit acc2258eab90ab5a7f062567dfb090fc81f601e7 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Mon May 12 14:45:31 2025 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Tue May 13 11:26:32 2025 +0200 sw doc model xml dump: show bullet types of an SwNumRule This helped to write the tdf#166229 testcase, because it shows where the actual bullet character is. Also declare the encoding in SwDoc::dumpAsXml() explicitly, since these bullet characters are typically not ASCII, so they didn't show up correctly in the output. Change-Id: I5a6f58d0971c2542e4cd79209589259fa5e9e5b7 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/185243 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/editeng/source/items/numitem.cxx b/editeng/source/items/numitem.cxx index 60d9b43a1047..bf9dbf47466e 100644 --- a/editeng/source/items/numitem.cxx +++ b/editeng/source/items/numitem.cxx @@ -568,6 +568,21 @@ OUString SvxNumberFormat::CreateRomanString( sal_Int32 nNo, bool bUpper ) : sRet.makeStringAndClear().toAsciiLowerCase(); } +void SvxNumberFormat::dumpAsXml(xmlTextWriterPtr pWriter) const +{ + (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SvxNumberFormat")); + (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this); + + SvxNumberType::dumpAsXml(pWriter); + + (void)xmlTextWriterStartElement(pWriter, BAD_CAST("bullet")); + (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), + BAD_CAST(OUString(&cBullet, 1).toUtf8().getStr())); + (void)xmlTextWriterEndElement(pWriter); + + (void)xmlTextWriterEndElement(pWriter); +} + void SvxNumberFormat::SetPrefix(const OUString& rSet) { // ListFormat manages the prefix. If badly changed via this function, sListFormat is invalidated diff --git a/include/editeng/numitem.hxx b/include/editeng/numitem.hxx index 9226e1a3b867..b859c0e68150 100644 --- a/include/editeng/numitem.hxx +++ b/include/editeng/numitem.hxx @@ -83,7 +83,7 @@ public: css::style::NumberingType::BITMAP != nNumType; } - void dumpAsXml(xmlTextWriterPtr w) const; + virtual void dumpAsXml(xmlTextWriterPtr w) const; }; class EDITENG_DLLPUBLIC SvxNumberFormat : public SvxNumberType @@ -233,6 +233,8 @@ public: bool GetIsLegal() const { return mbIsLegal; } void SetIsLegal(bool val) { mbIsLegal = val; } + + void dumpAsXml(xmlTextWriterPtr w) const override; }; //Feature-Flags (only sal_uInt16!) diff --git a/sw/inc/numrule.hxx b/sw/inc/numrule.hxx index 9363d769f986..f315acbd4769 100644 --- a/sw/inc/numrule.hxx +++ b/sw/inc/numrule.hxx @@ -88,6 +88,8 @@ public: bool IsEnumeration() const; // #i22362# bool IsItemize() const; // #i29560# + + void dumpAsXml(xmlTextWriterPtr w) const override; }; enum SwNumRuleType { OUTLINE_RULE = 0, NUM_RULE = 1, RULE_END = 2 }; diff --git a/sw/source/core/doc/docfmt.cxx b/sw/source/core/doc/docfmt.cxx index ecacdc15d38b..7c0aa1f5c4cd 100644 --- a/sw/source/core/doc/docfmt.cxx +++ b/sw/source/core/doc/docfmt.cxx @@ -2002,7 +2002,7 @@ void SwDoc::dumpAsXml(xmlTextWriterPtr pWriter) const pWriter = xmlNewTextWriterFilename("nodes.xml", 0); xmlTextWriterSetIndent(pWriter,1); (void)xmlTextWriterSetIndentString(pWriter, BAD_CAST(" ")); - (void)xmlTextWriterStartDocument(pWriter, nullptr, nullptr, nullptr); + (void)xmlTextWriterStartDocument(pWriter, nullptr, "UTF-8", nullptr); bOwns = true; } (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwDoc")); diff --git a/sw/source/core/doc/number.cxx b/sw/source/core/doc/number.cxx index 5883cbd90c5b..bf78ee7b6ab1 100644 --- a/sw/source/core/doc/number.cxx +++ b/sw/source/core/doc/number.cxx @@ -273,6 +273,21 @@ bool SwNumFormat::IsItemize() const } +void SwNumFormat::dumpAsXml(xmlTextWriterPtr pWriter) const +{ + (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwNumFormat")); + (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this); + + SvxNumberFormat::dumpAsXml(pWriter); + + (void)xmlTextWriterStartElement(pWriter, BAD_CAST("grf-bullet-cp")); + (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("value"), + BAD_CAST(OUString(&m_cGrfBulletCP, 1).toUtf8().getStr())); + (void)xmlTextWriterEndElement(pWriter); + + (void)xmlTextWriterEndElement(pWriter); +} + SwNumFormat& SwNumFormat::operator=( const SwNumFormat& rNumFormat) { SvxNumberFormat::operator=(rNumFormat);