[Libreoffice-commits] core.git: sw/qa sw/source

Miklos Vajna (via logerrit) logerrit at kemper.freedesktop.org
Tue Oct 5 06:25:49 UTC 2021


 sw/qa/extras/uiwriter/uiwriter4.cxx |   18 +++++++-----------
 sw/source/core/text/porlin.cxx      |    9 +++++++++
 2 files changed, 16 insertions(+), 11 deletions(-)

New commits:
commit 2d9eddbb23625aad7a9accedbf69209a04169f00
Author:     Miklos Vajna <vmiklos at collabora.com>
AuthorDate: Mon Oct 4 19:55:58 2021 +0200
Commit:     Miklos Vajna <vmiklos at collabora.com>
CommitDate: Tue Oct 5 08:25:16 2021 +0200

    sw layout xml dump: show width/height/length even for multi-portions
    
    The old SwPortionHandler-based approach doesn't handle multi-portions.
    
    Change-Id: I6702e7af3b9fe7e4c25692c22e8f35d9ab98f67a
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123061
    Tested-by: Jenkins
    Reviewed-by: Miklos Vajna <vmiklos at collabora.com>

diff --git a/sw/qa/extras/uiwriter/uiwriter4.cxx b/sw/qa/extras/uiwriter/uiwriter4.cxx
index acafb12e4cc5..03c0d3857a73 100644
--- a/sw/qa/extras/uiwriter/uiwriter4.cxx
+++ b/sw/qa/extras/uiwriter/uiwriter4.cxx
@@ -1580,24 +1580,20 @@ void SwUiWriterTest4::testTdf107025()
     createSwDoc(DATA_DIRECTORY, "tdf107025.odt");
     xmlDocUniquePtr pXmlDoc = parseLayoutDump();
     // Verify the number of characters in each line.
-    CPPUNIT_ASSERT_EQUAL(
-        sal_Int32(1),
-        getXPath(pXmlDoc, "(//Text[@nType='PortionType::Text'])[1]", "nLength").toInt32());
-    CPPUNIT_ASSERT_EQUAL(
-        sal_Int32(9),
-        getXPath(pXmlDoc, "(//Text[@nType='PortionType::Text'])[2]", "nLength").toInt32());
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(1),
+                         getXPath(pXmlDoc, "(//SwLinePortion)[1]", "length").toInt32());
+    CPPUNIT_ASSERT_EQUAL(sal_Int32(9),
+                         getXPath(pXmlDoc, "(//SwLinePortion)[2]", "length").toInt32());
 
     // Do the subsequent test only if the first line can be displayed,
     // in case that the required font does not exist.
-    sal_Int32 nWidth1
-        = getXPath(pXmlDoc, "(//Text[@nType='PortionType::Text'])[1]", "nWidth").toInt32();
+    sal_Int32 nWidth1 = getXPath(pXmlDoc, "(//SwLinePortion)[1]", "width").toInt32();
     if (!nWidth1)
         return;
 
-    CPPUNIT_ASSERT(!parseDump("(//Text[@nType='PortionType::Text'])[2]", "nWidth").isEmpty());
+    CPPUNIT_ASSERT(!parseDump("(//SwLinePortion)[2]", "width").isEmpty());
     // Width of the second line is expected to be 9 times of the first.
-    sal_Int32 nWidth2
-        = getXPath(pXmlDoc, "(//Text[@nType='PortionType::Text'])[2]", "nWidth").toInt32();
+    sal_Int32 nWidth2 = getXPath(pXmlDoc, "(//SwLinePortion)[2]", "width").toInt32();
 
     CPPUNIT_ASSERT_EQUAL(sal_Int32(9), nWidth2 / nWidth1);
 }
diff --git a/sw/source/core/text/porlin.cxx b/sw/source/core/text/porlin.cxx
index d7268fd5f6e6..439382a92b63 100644
--- a/sw/source/core/text/porlin.cxx
+++ b/sw/source/core/text/porlin.cxx
@@ -322,6 +322,15 @@ void SwLinePortion::dumpAsXml(xmlTextWriterPtr pWriter) const
     (void)xmlTextWriterStartElement(pWriter, BAD_CAST("SwLinePortion"));
     (void)xmlTextWriterWriteFormatAttribute(pWriter, BAD_CAST("ptr"), "%p", this);
     (void)xmlTextWriterWriteAttribute(pWriter, BAD_CAST("symbol"), BAD_CAST(typeid(*this).name()));
+    (void)xmlTextWriterWriteAttribute(
+        pWriter, BAD_CAST("width"),
+        BAD_CAST(OString::number(Width()).getStr()));
+    (void)xmlTextWriterWriteAttribute(
+        pWriter, BAD_CAST("height"),
+        BAD_CAST(OString::number(Height()).getStr()));
+    (void)xmlTextWriterWriteAttribute(
+        pWriter, BAD_CAST("length"),
+        BAD_CAST(OString::number(static_cast<sal_Int32>(mnLineLength)).getStr()));
     (void)xmlTextWriterEndElement(pWriter);
 }
 


More information about the Libreoffice-commits mailing list