sw/qa/extras/ooxmlexport/data/tdf164176.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport21.cxx | 15 +++++++++++++++ sw/source/writerfilter/dmapper/SettingsTable.cxx | 4 +++- 3 files changed, 18 insertions(+), 1 deletion(-)
New commits: commit fc5f6664668c3b07234f8b0c42170ae125c26712 Author: Oliver Specht <oliver.spe...@cib.de> AuthorDate: Thu Dec 5 07:48:10 2024 +0100 Commit: Gabor Kelemen <gabor.kelemen.ext...@allotropia.de> CommitDate: Tue Feb 11 17:26:17 2025 +0100 tdf#164176 Import multiline document variable with break Converts the '_x000d_' or '_x000d__x000a_' to a paragraph break in docx import. Change-Id: Ib8b5203338e987028279711928d3aecb9cedd836 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/178731 Reviewed-by: Gabor Kelemen <gabor.kelemen.ext...@allotropia.de> Tested-by: allotropia jenkins <jenk...@allotropia.de> diff --git a/sw/qa/extras/ooxmlexport/data/tdf164176.docx b/sw/qa/extras/ooxmlexport/data/tdf164176.docx new file mode 100644 index 000000000000..2d93cfd3765d Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf164176.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx index f846a248022d..1107173e0ad8 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx @@ -16,6 +16,8 @@ #include <com/sun/star/text/RelOrientation.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/text/XTextFieldsSupplier.hpp> #include <com/sun/star/table/XCellRange.hpp> #include <com/sun/star/style/LineSpacing.hpp> #include <com/sun/star/style/LineSpacingMode.hpp> @@ -890,6 +892,19 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf164065) CPPUNIT_ASSERT_EQUAL(u"a"_ustr, xCell->getString()); } +DECLARE_OOXMLEXPORT_TEST(testTdf164176, "tdf164176.docx") +{ + 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> xEnumerationAccess1(xFields->nextElement(), uno::UNO_QUERY); + rtl::OUString sPresentation = xEnumerationAccess1->getPresentation(true).trim(); + CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), sPresentation.indexOf("_x000d_")); + CPPUNIT_ASSERT_EQUAL(sal_Int32(-1), sPresentation.indexOf("_x000a_")); +} + } // end of anonymous namespace CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/source/writerfilter/dmapper/SettingsTable.cxx b/sw/source/writerfilter/dmapper/SettingsTable.cxx index da276ca67d92..6e2da1061525 100644 --- a/sw/source/writerfilter/dmapper/SettingsTable.cxx +++ b/sw/source/writerfilter/dmapper/SettingsTable.cxx @@ -212,7 +212,9 @@ void SettingsTable::lcl_attribute(Id nName, Value & val) m_pImpl->m_aDocVars.back().first = sStringValue; break; case NS_ooxml::LN_CT_DocVar_val: - m_pImpl->m_aDocVars.back().second = sStringValue; + m_pImpl->m_aDocVars.back().second = + sStringValue.replaceAll("_x000d__x000a_", " ") + .replaceAll("_x000d_", " "); break; case NS_ooxml::LN_CT_CompatSetting_name: m_pImpl->m_aCurrentCompatSettingName = sStringValue;