sw/qa/extras/uiwriter/uiwriter4.cxx | 10 - sw/source/core/inc/txttypes.hxx | 5 sw/source/core/text/porlin.cxx | 3 sw/source/core/text/xmldump.cxx | 252 ++++++++++++++++++------------------ 4 files changed, 140 insertions(+), 130 deletions(-)
New commits: commit 4da10f6931166ddef04aa2731c52e9b401303bb3 Author: Miklos Vajna <vmik...@collabora.com> AuthorDate: Mon Oct 11 20:08:56 2021 +0200 Commit: Miklos Vajna <vmik...@collabora.com> CommitDate: Tue Oct 12 08:18:43 2021 +0200 sw layout xml dump: show type even for multi-portions The old SwPortionHandler-based approach doesn't handle multi-portions. Change-Id: I2473e61c19cd7aa134614f96505e10bebf1d0017 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123428 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmik...@collabora.com> diff --git a/sw/qa/extras/uiwriter/uiwriter4.cxx b/sw/qa/extras/uiwriter/uiwriter4.cxx index 03c0d3857a73..94e12529847d 100644 --- a/sw/qa/extras/uiwriter/uiwriter4.cxx +++ b/sw/qa/extras/uiwriter/uiwriter4.cxx @@ -1536,16 +1536,18 @@ void SwUiWriterTest4::testTdf35021_tabOverMarginDemo() sal_Int32 nMargin = getXPath(pXmlDoc, "//body/txt[1]/infos/prtBounds", "width").toInt32(); // left tab was 3381 because it got its own full line sal_Int32 nWidth - = getXPath(pXmlDoc, "//Text[@nType='PortionType::TabLeft']", "nWidth").toInt32(); + = getXPath(pXmlDoc, "//SwLinePortion[@type='PortionType::TabLeft']", "width").toInt32(); CPPUNIT_ASSERT_MESSAGE("Left Tab width is ~4479", nMargin < nWidth); // center tab was 842 - nWidth = getXPath(pXmlDoc, "//Text[@nType='PortionType::TabCenter']", "nWidth").toInt32(); + nWidth + = getXPath(pXmlDoc, "//SwLinePortion[@type='PortionType::TabCenter']", "width").toInt32(); CPPUNIT_ASSERT_MESSAGE("Center Tab width is ~3521", nMargin < nWidth); // right tab was probably the same as center tab. - nWidth = getXPath(pXmlDoc, "//Text[@nType='PortionType::TabRight']", "nWidth").toInt32(); + nWidth = getXPath(pXmlDoc, "//SwLinePortion[@type='PortionType::TabRight']", "width").toInt32(); CPPUNIT_ASSERT_MESSAGE("Right Tab width is ~2907", sal_Int32(2500) < nWidth); // decimal tab was 266 - nWidth = getXPath(pXmlDoc, "//Text[@nType='PortionType::TabDecimal']", "nWidth").toInt32(); + nWidth + = getXPath(pXmlDoc, "//SwLinePortion[@type='PortionType::TabDecimal']", "width").toInt32(); CPPUNIT_ASSERT_MESSAGE("Decimal Tab width is ~4096", nMargin < nWidth); #endif } diff --git a/sw/source/core/inc/txttypes.hxx b/sw/source/core/inc/txttypes.hxx index 96972212c02e..e65ed26dc128 100644 --- a/sw/source/core/inc/txttypes.hxx +++ b/sw/source/core/inc/txttypes.hxx @@ -88,4 +88,9 @@ enum class PortionType TabLeft = 0x0740, }; +namespace sw +{ +const char* PortionTypeToString(PortionType nType); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/core/text/porlin.cxx b/sw/source/core/text/porlin.cxx index 61db8135f33b..82e5255def9e 100644 --- a/sw/source/core/text/porlin.cxx +++ b/sw/source/core/text/porlin.cxx @@ -331,6 +331,9 @@ void SwLinePortion::dumpAsXml(xmlTextWriterPtr pWriter) const (void)xmlTextWriterWriteAttribute( pWriter, BAD_CAST("length"), BAD_CAST(OString::number(static_cast<sal_Int32>(mnLineLength)).getStr())); + (void)xmlTextWriterWriteAttribute( + pWriter, BAD_CAST("type"), + BAD_CAST(sw::PortionTypeToString(GetWhichPor()))); (void)xmlTextWriterEndElement(pWriter); } diff --git a/sw/source/core/text/xmldump.cxx b/sw/source/core/text/xmldump.cxx index d188a0698373..621a1093107a 100644 --- a/sw/source/core/text/xmldump.cxx +++ b/sw/source/core/text/xmldump.cxx @@ -30,6 +30,130 @@ #include "porlay.hxx" +const char* sw::PortionTypeToString(PortionType nType) +{ + switch (nType) + { + case PortionType::NONE: + return "PortionType::NONE"; + case PortionType::FlyCnt: + return "PortionType::FlyCnt"; + + case PortionType::Hole: + return "PortionType::Hole"; + case PortionType::TempEnd: + return "PortionType::TempEnd"; + case PortionType::Break: + return "PortionType::Break"; + case PortionType::Kern: + return "PortionType::Kern"; + case PortionType::Arrow: + return "PortionType::Arrow"; + case PortionType::Multi: + return "PortionType::Multi"; + case PortionType::HiddenText: + return "PortionType::HiddenText"; + case PortionType::ControlChar: + return "PortionType::ControlChar"; + case PortionType::Bookmark: + return "PortionType::Bookmark"; + + case PortionType::Text: + return "PortionType::Text"; + case PortionType::Lay: + return "PortionType::Lay"; + case PortionType::Para: + return "PortionType::Para"; + case PortionType::Hanging: + return "PortionType::Hanging"; + + case PortionType::Drop: + return "PortionType::Drop"; + case PortionType::Tox: + return "PortionType::Tox"; + case PortionType::IsoTox: + return "PortionType::IsoTox"; + case PortionType::Ref: + return "PortionType::Ref"; + case PortionType::IsoRef: + return "PortionType::IsoRef"; + case PortionType::Meta: + return "PortionType::Meta"; + case PortionType::FieldMark: + return "PortionType::FieldMark"; + case PortionType::FieldFormCheckbox: + return "PortionType::FieldFormCheckbox"; + case PortionType::InputField: + return "PortionType::InputField"; + + case PortionType::Expand: + return "PortionType::Expand"; + case PortionType::Blank: + return "PortionType::Blank"; + case PortionType::PostIts: + return "PortionType::PostIts"; + + case PortionType::Hyphen: + return "PortionType::Hyphen"; + case PortionType::HyphenStr: + return "PortionType::HyphenStr"; + case PortionType::SoftHyphen: + return "PortionType::SoftHyphen"; + case PortionType::SoftHyphenStr: + return "PortionType::SoftHyphenStr"; + case PortionType::SoftHyphenComp: + return "PortionType::SoftHyphenComp"; + + case PortionType::Field: + return "PortionType::Field"; + case PortionType::Hidden: + return "PortionType::Hidden"; + case PortionType::QuoVadis: + return "PortionType::QuoVadis"; + case PortionType::ErgoSum: + return "PortionType::ErgoSum"; + case PortionType::Combined: + return "PortionType::Combined"; + case PortionType::Footnote: + return "PortionType::Footnote"; + + case PortionType::FootnoteNum: + return "PortionType::FootnoteNum"; + case PortionType::Number: + return "PortionType::Number"; + case PortionType::Bullet: + return "PortionType::Bullet"; + case PortionType::GrfNum: + return "PortionType::GrfNum"; + + case PortionType::Glue: + return "PortionType::Glue"; + + case PortionType::Margin: + return "PortionType::Margin"; + + case PortionType::Fix: + return "PortionType::Fix"; + case PortionType::Fly: + return "PortionType::Fly"; + + case PortionType::Table: + return "PortionType::Table"; + + case PortionType::TabRight: + return "PortionType::TabRight"; + case PortionType::TabCenter: + return "PortionType::TabCenter"; + case PortionType::TabDecimal: + return "PortionType::TabDecimal"; + + case PortionType::TabLeft: + return "PortionType::TabLeft"; + default: + return "Unknown"; + } +} + namespace { class XmlPortionDumper:public SwPortionHandler @@ -40,130 +164,6 @@ class XmlPortionDumper:public SwPortionHandler const OUString& m_rText; OUString m_aLine; - static const char* getTypeName(PortionType nType) - { - switch (nType) - { - case PortionType::NONE: - return "PortionType::NONE"; - case PortionType::FlyCnt: - return "PortionType::FlyCnt"; - - case PortionType::Hole: - return "PortionType::Hole"; - case PortionType::TempEnd: - return "PortionType::TempEnd"; - case PortionType::Break: - return "PortionType::Break"; - case PortionType::Kern: - return "PortionType::Kern"; - case PortionType::Arrow: - return "PortionType::Arrow"; - case PortionType::Multi: - return "PortionType::Multi"; - case PortionType::HiddenText: - return "PortionType::HiddenText"; - case PortionType::ControlChar: - return "PortionType::ControlChar"; - case PortionType::Bookmark: - return "PortionType::Bookmark"; - - case PortionType::Text: - return "PortionType::Text"; - case PortionType::Lay: - return "PortionType::Lay"; - case PortionType::Para: - return "PortionType::Para"; - case PortionType::Hanging: - return "PortionType::Hanging"; - - case PortionType::Drop: - return "PortionType::Drop"; - case PortionType::Tox: - return "PortionType::Tox"; - case PortionType::IsoTox: - return "PortionType::IsoTox"; - case PortionType::Ref: - return "PortionType::Ref"; - case PortionType::IsoRef: - return "PortionType::IsoRef"; - case PortionType::Meta: - return "PortionType::Meta"; - case PortionType::FieldMark: - return "PortionType::FieldMark"; - case PortionType::FieldFormCheckbox: - return "PortionType::FieldFormCheckbox"; - case PortionType::InputField: - return "PortionType::InputField"; - - case PortionType::Expand: - return "PortionType::Expand"; - case PortionType::Blank: - return "PortionType::Blank"; - case PortionType::PostIts: - return "PortionType::PostIts"; - - case PortionType::Hyphen: - return "PortionType::Hyphen"; - case PortionType::HyphenStr: - return "PortionType::HyphenStr"; - case PortionType::SoftHyphen: - return "PortionType::SoftHyphen"; - case PortionType::SoftHyphenStr: - return "PortionType::SoftHyphenStr"; - case PortionType::SoftHyphenComp: - return "PortionType::SoftHyphenComp"; - - case PortionType::Field: - return "PortionType::Field"; - case PortionType::Hidden: - return "PortionType::Hidden"; - case PortionType::QuoVadis: - return "PortionType::QuoVadis"; - case PortionType::ErgoSum: - return "PortionType::ErgoSum"; - case PortionType::Combined: - return "PortionType::Combined"; - case PortionType::Footnote: - return "PortionType::Footnote"; - - case PortionType::FootnoteNum: - return "PortionType::FootnoteNum"; - case PortionType::Number: - return "PortionType::Number"; - case PortionType::Bullet: - return "PortionType::Bullet"; - case PortionType::GrfNum: - return "PortionType::GrfNum"; - - case PortionType::Glue: - return "PortionType::Glue"; - - case PortionType::Margin: - return "PortionType::Margin"; - - case PortionType::Fix: - return "PortionType::Fix"; - case PortionType::Fly: - return "PortionType::Fly"; - - case PortionType::Table: - return "PortionType::Table"; - - case PortionType::TabRight: - return "PortionType::TabRight"; - case PortionType::TabCenter: - return "PortionType::TabCenter"; - case PortionType::TabDecimal: - return "PortionType::TabDecimal"; - - case PortionType::TabLeft: - return "PortionType::TabLeft"; - default: - return "Unknown"; - } - } - public: explicit XmlPortionDumper(xmlTextWriterPtr some_writer, const OUString& rText) : m_Writer(some_writer) @@ -187,7 +187,7 @@ class XmlPortionDumper:public SwPortionHandler (void)xmlTextWriterWriteFormatAttribute(m_Writer, BAD_CAST("nLength"), "%i", static_cast<int>(static_cast<sal_Int32>(nLength))); (void)xmlTextWriterWriteFormatAttribute(m_Writer, BAD_CAST("nType"), "%s", - getTypeName(nType)); + sw::PortionTypeToString(nType)); if (nHeight > 0) (void)xmlTextWriterWriteFormatAttribute(m_Writer, BAD_CAST("nHeight"), "%i", static_cast<int>(nHeight)); @@ -225,7 +225,7 @@ class XmlPortionDumper:public SwPortionHandler (void)xmlTextWriterWriteFormatAttribute(m_Writer, BAD_CAST("nLength"), "%i", static_cast<int>(static_cast<sal_Int32>(nLength))); (void)xmlTextWriterWriteFormatAttribute(m_Writer, BAD_CAST("nType"), "%s", - getTypeName(nType)); + sw::PortionTypeToString(nType)); OString sText8 = OUStringToOString( rText, RTL_TEXTENCODING_UTF8 ); (void)xmlTextWriterWriteFormatAttribute(m_Writer, BAD_CAST("rText"), "%s", sText8.getStr());