sw/qa/extras/ooxmlexport/data/tdf128460.odt |binary sw/qa/extras/ooxmlexport/ooxmlexport21.cxx | 29 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+)
New commits: commit 03b31a8ad48e3b8a9e54203ff3856702557757b5 Author: Adam Seskunas <adamsesku...@gmail.com> AuthorDate: Wed Aug 14 11:52:45 2024 -0700 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue Aug 27 08:58:42 2024 +0200 tdf#128460 Add Unit Test Change-Id: Ia83b87db09256aedf8f6e8c04986d4476099b4aa Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171877 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org> diff --git a/sw/qa/extras/ooxmlexport/data/tdf128460.odt b/sw/qa/extras/ooxmlexport/data/tdf128460.odt new file mode 100644 index 000000000000..9d55b6c68c9c Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf128460.odt differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx index 32892540e734..ce7e68bf3341 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx @@ -17,6 +17,7 @@ #include <com/sun/star/text/WrapTextMode.hpp> #include <com/sun/star/text/XDocumentIndex.hpp> #include <com/sun/star/text/XTextTable.hpp> +#include <com/sun/star/text/XTextField.hpp> #include <com/sun/star/style/LineSpacing.hpp> #include <com/sun/star/style/LineSpacingMode.hpp> @@ -1097,6 +1098,34 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf162370) loadAndSave("too_many_styles.odt"); } +CPPUNIT_TEST_FIXTURE(Test, testTdf128460) +{ + 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()); + uno::Reference<text::XTextField> xField(xFields->nextElement(), uno::UNO_QUERY); + + CPPUNIT_ASSERT_EQUAL(u""_ustr, xField->getPresentation(false)); + CPPUNIT_ASSERT_EQUAL(u"Input field"_ustr, xField->getPresentation(true)); + + xField.set(xFields->nextElement(), uno::UNO_QUERY); + + CPPUNIT_ASSERT_EQUAL(u"text"_ustr, xField->getPresentation(false)); + CPPUNIT_ASSERT_EQUAL(u"Input field"_ustr, xField->getPresentation(true)); + }; + createSwDoc("tdf128460.odt"); + verify(); + + saveAndReload(u"Office Open XML Text"_ustr); + // Without the fix in place, the third ASSERT fails with + // Expected: text + // Actual: + // i.e. The second Field is blank when it should have the content of `text` + verify(); +} + } // end of anonymous namespace CPPUNIT_PLUGIN_IMPLEMENT();