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

New commits:
commit fe7b39884ccb5e540e10f3294d8f7b35bf3e6ebb
Author:     Adam Seskunas <adamsesku...@gmail.com>
AuthorDate: Tue Aug 13 13:49:04 2024 -0700
Commit:     Hossein <hoss...@libreoffice.org>
CommitDate: Wed Aug 14 23:50:52 2024 +0200

    tdf#160301 - Add Unit test
    
    Change-Id: Icfd8aa7066ea837103a332c3b61950574b7799fa
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171840
    Tested-by: Jenkins
    Reviewed-by: Hossein <hoss...@libreoffice.org>

diff --git a/sw/qa/extras/ww8export/data/tdf160301.doc 
b/sw/qa/extras/ww8export/data/tdf160301.doc
new file mode 100644
index 000000000000..c087566183b9
Binary files /dev/null and b/sw/qa/extras/ww8export/data/tdf160301.doc differ
diff --git a/sw/qa/extras/ww8export/ww8export4.cxx 
b/sw/qa/extras/ww8export/ww8export4.cxx
index 798e3e52da75..7055e0eab76c 100644
--- a/sw/qa/extras/ww8export/ww8export4.cxx
+++ b/sw/qa/extras/ww8export/ww8export4.cxx
@@ -19,6 +19,7 @@
 #include <com/sun/star/text/XTextFrame.hpp>
 #include <com/sun/star/text/XTextTable.hpp>
 #include <com/sun/star/text/WrapTextMode.hpp>
+#include <com/sun/star/text/XTextField.hpp>
 
 #include <comphelper/sequenceashashmap.hxx>
 #include <o3tl/string_view.hxx>
@@ -440,6 +441,26 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf135710)
     // i.e. the picture has moved from the second column to the first column
     CPPUNIT_ASSERT_DOUBLES_EQUAL(static_cast<double>(nFlyLeft), 
static_cast<double>(nFlyLeftAfter), 2.0);
 }
+
+CPPUNIT_TEST_FIXTURE(Test, testTdf160301)
+{
+    // Without the fix in place, fields in the test doc are imported as 
DocInformation
+    // with the content set to the variable name
+    createSwDoc("tdf160301.doc");
+    uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, 
uno::UNO_QUERY);
+    uno::Reference<container::XEnumerationAccess> 
xFieldsAccess(xTextFieldsSupplier->getTextFields());
+    uno::Reference<container::XEnumeration> 
xFields(xFieldsAccess->createEnumeration());
+    uno::Reference<text::XTextField> xField(xFields->nextElement(), 
uno::UNO_QUERY);
+    // Without the fix in place this fails with
+    // Expected: Jeff Smith
+    // Actual:   FullName
+    CPPUNIT_ASSERT_EQUAL(u"Jeff Smith"_ustr, xField->getPresentation(false));
+    // Without the fix in place this fails with
+    // Expected: User Field FullName = Jeff Smith
+    // Actual:   DocInformation:FullName
+    CPPUNIT_ASSERT_EQUAL(u"User Field FullName = Jeff Smith"_ustr, 
xField->getPresentation(true));
+}
+
 } // end of anonymous namespace
 CPPUNIT_PLUGIN_IMPLEMENT();
 

Reply via email to