From 437062f29360146995ae37ccde79f449d09102c8 Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Thu, 14 Dec 2023 20:16:04 +0100 Subject: sw doc model xml dump: add initial ruby support Fixes this warning when some text portion has ruby on it: warn:sw.core:19310:19310:sw/source/core/txtnode/txatbase.cxx:180: Unhandled TXTATR Change-Id: If741f7201c56f7f19ae51108312f2813e92f45d4 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/160787 Tested-by: Jenkins Reviewed-by: Miklos Vajna --- sw/inc/fmtruby.hxx | 1 + sw/source/core/txtnode/fmtatr2.cxx | 13 +++++++++++++ sw/source/core/txtnode/txatbase.cxx | 5 ++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/sw/inc/fmtruby.hxx b/sw/inc/fmtruby.hxx index e0e756b1db7a..6741102ed489 100644 --- a/sw/inc/fmtruby.hxx +++ b/sw/inc/fmtruby.hxx @@ -74,6 +74,7 @@ public: css::text::RubyAdjust GetAdjustment() const { return m_eAdjustment; } void SetAdjustment( css::text::RubyAdjust nNew ) { m_eAdjustment = nNew; } + void dumpAsXml(xmlTextWriterPtr pWriter) const override; }; #endif diff --git a/sw/source/core/txtnode/fmtatr2.cxx b/sw/source/core/txtnode/fmtatr2.cxx index 3e888b660f6a..d9fe78377de3 100644 --- a/sw/source/core/txtnode/fmtatr2.cxx +++ b/sw/source/core/txtnode/fmtatr2.cxx @@ -426,6 +426,19 @@ SwFormatRuby::~SwFormatRuby() { } +void SwFormatRuby::dumpAsXml(xmlTextWriterPtr pWriter) const +{ + (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwFormatRuby")); + (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this); + (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("m_pTextAttr"), "%p", m_pTextAttr); + (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("ruby-text"), + BAD_CAST(m_sRubyText.toUtf8().getStr())); + SfxPoolItem::dumpAsXml(pWriter); + + + (void)xmlTextWriterEndElement(pWriter); +} + SwFormatRuby& SwFormatRuby::operator=( const SwFormatRuby& rAttr ) { // SwFormatRuby is not shareable, so ptr compare is OK diff --git a/sw/source/core/txtnode/txatbase.cxx b/sw/source/core/txtnode/txatbase.cxx index 1d57f0e0dda5..8e48806901a2 100644 --- a/sw/source/core/txtnode/txatbase.cxx +++ b/sw/source/core/txtnode/txatbase.cxx @@ -176,8 +176,11 @@ void SwTextAttr::dumpAsXml(xmlTextWriterPtr pWriter) const case RES_TXTATR_INETFMT: GetINetFormat().dumpAsXml(pWriter); break; + case RES_TXTATR_CJK_RUBY: + GetRuby().dumpAsXml(pWriter); + break; default: - SAL_WARN("sw.core", "Unhandled TXTATR"); + SAL_WARN("sw.core", "Unhandled TXTATR: " << Which()); break; } -- cgit