sw/qa/extras/ooxmlexport/data/tdf164176.docx     |binary
 sw/qa/extras/ooxmlexport/ooxmlexport21.cxx       |   14 ++++++++++++++
 sw/source/writerfilter/dmapper/SettingsTable.cxx |    4 +++-
 3 files changed, 17 insertions(+), 1 deletion(-)

New commits:
commit 9647aded124c17e97db1bf7bb071136c7f91cb90
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 16:33:21 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/+/177838
    Tested-by: Jenkins
    Reviewed-by: Gabor Kelemen <gabor.kelemen.ext...@allotropia.de>
    Tested-by: Gabor Kelemen <gabor.kelemen.ext...@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 91bf853c784c..89ba838e10ba 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport21.cxx
@@ -17,6 +17,7 @@
 #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>
@@ -1242,6 +1243,19 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf164474)
     }
 }
 
+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 b4bf82541484..7ec07453d4f6 100644
--- a/sw/source/writerfilter/dmapper/SettingsTable.cxx
+++ b/sw/source/writerfilter/dmapper/SettingsTable.cxx
@@ -215,7 +215,9 @@ void SettingsTable::lcl_attribute(Id nName, const 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;

Reply via email to