sw/qa/extras/ww8export/data/tdf56738.doc |binary
 sw/qa/extras/ww8export/ww8export4.cxx    |   43 +++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+)

New commits:
commit c387604cc58f3214f4fda9d9c32969115bda7b2e
Author:     Adam Seskunas <[email protected]>
AuthorDate: Mon Aug 19 15:33:56 2024 -0700
Commit:     Xisco Fauli <[email protected]>
CommitDate: Tue Aug 27 08:48:49 2024 +0200

    tdf#56738 Add Unit test
    
    Change-Id: Ie0292472833c3f62f42f67877c1c4896deee0d65
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/172089
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <[email protected]>

diff --git a/sw/qa/extras/ww8export/data/tdf56738.doc 
b/sw/qa/extras/ww8export/data/tdf56738.doc
new file mode 100644
index 000000000000..20c5a9b9727d
Binary files /dev/null and b/sw/qa/extras/ww8export/data/tdf56738.doc differ
diff --git a/sw/qa/extras/ww8export/ww8export4.cxx 
b/sw/qa/extras/ww8export/ww8export4.cxx
index 084eb178af6a..9eed7ea9b0bf 100644
--- a/sw/qa/extras/ww8export/ww8export4.cxx
+++ b/sw/qa/extras/ww8export/ww8export4.cxx
@@ -560,6 +560,49 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf135710)
     CPPUNIT_ASSERT_DOUBLES_EQUAL(static_cast<double>(nFlyLeft), 
static_cast<double>(nFlyLeftAfter), 2.0);
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf56738)
+{
+    auto verify = [this]() {
+        uno::Reference<text::XTextFieldsSupplier> 
xTextFieldsSupplier(mxComponent, uno::UNO_QUERY);
+        uno::Reference<container::XEnumerationAccess> 
xFieldsAccess(xTextFieldsSupplier->getTextFields());
+        uno::Reference<container::XEnumeration> 
xFields(xFieldsAccess->createEnumeration());
+
+        // make sure we get to the correct field to test
+        CPPUNIT_ASSERT(xFields->hasMoreElements());
+        uno::Reference<text::XTextField> xField;
+        xField.set(xFields->nextElement(), uno::UNO_QUERY);
+        CPPUNIT_ASSERT_EQUAL(u"2"_ustr, xField->getPresentation(false));
+
+        CPPUNIT_ASSERT(xFields->hasMoreElements());
+        xField.set(xFields->nextElement(), uno::UNO_QUERY_THROW);
+        CPPUNIT_ASSERT_EQUAL(u"3"_ustr, xField->getPresentation(false));
+
+        CPPUNIT_ASSERT(xFields->hasMoreElements());
+        xField.set(xFields->nextElement(), uno::UNO_QUERY_THROW);
+        OUString sExpComment1(u"Como eu vou saber se é a USG é anterior a 
20s????"_ustr);
+        CPPUNIT_ASSERT_EQUAL(sExpComment1, getProperty<OUString>(xField, 
u"Content"_ustr));
+
+        CPPUNIT_ASSERT(xFields->hasMoreElements());
+        xField.set(xFields->nextElement(), uno::UNO_QUERY_THROW);
+
+        OUString sExpComment(u"Não sei se é relevante esta pergunta. O que eu 
queria saber é se o médico ate\
+nde muito parto na água. Tb posso fazer porcentagem de atendimento..."_ustr);
+
+        // Without the fix in place this fails with
+        // Expected: Não sei se é relevante esta pergunta. O que eu queria 
saber é
+        //           se o médico atende muito parto na água. Tb posso fazer 
porcentagem de atendimento...
+        // Actual:   N縊 sei se �relevante esta pergunta. O que eu queria saber 
�
+        //           se o m馘ico atende muito parto na 疊ua. Tb posso fazer 
porcentagem de atendimento...
+        // i.e. the display characters of the second comment were getting 
re-intrepeted from Latin-1 to Shift-Js
+        CPPUNIT_ASSERT_EQUAL(sExpComment, getProperty<OUString>(xField, 
u"Content"_ustr));
+    };
+
+    // make sure everything survives roundtrip
+    createSwDoc("tdf56738.doc");
+    verify();
+    saveAndReload(mpFilter);
+    verify();
+}
 } // end of anonymous namespace
 CPPUNIT_PLUGIN_IMPLEMENT();
 

Reply via email to