sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx | 6 +++++ sw/source/writerfilter/dmapper/DomainMapperTableHandler.cxx | 13 +++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-)
New commits: commit a63534ef77c620c06d41be9ad29c283fe636bf7f Author: Justin Luth <[email protected]> AuthorDate: Sat Jan 3 17:02:37 2026 -0500 Commit: Justin Luth <[email protected]> CommitDate: Tue Jan 6 03:26:59 2026 +0100 tdf#170208 docx import: shift table by cell margin, not style margin This has always been wrong, but some documents have accidentally 'looked right' at various times, most recently before 25.8.3 commit a80d7ba9c01c8c5c95bf01960d969b82dc7edffc Author: Aron Budea on Mon Sep 29 14:59:18 2025 +0930 tdf#168598 Fix for tdf#148578 should only apply to RTF Reviewed-on: https://gerrit.libreoffice.org/c/core/+/191587 make CppunitTest_sw_ooxmlfieldexport \ CPPUNIT_TEST_NAME=testTdf158661_blockSDT Another nice example was nested-floating-table.docx Change-Id: Ie4e256dc0651ade8d302bf78646b2a5215414bc6 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/196462 Tested-by: Jenkins Reviewed-by: Justin Luth <[email protected]> diff --git a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx index 7ed052daf2c3..a8f92ffdb5f5 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlfieldexport.cxx @@ -564,6 +564,12 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf158661_blockSDT) xContentControlEnum = xContentControlEnumAccess->createEnumeration(); xTextPortionRange.set(xContentControlEnum->nextElement(), uno::UNO_QUERY); CPPUNIT_ASSERT_EQUAL(u"Test"_ustr, xTextPortionRange->getString()); + + // tdf#170208: compatibilityMode14 document - emulate table placement + // TODO: the first table is also not correctly positioned + + // table2's cell margin (in the first row) is zero, so compat14 table shifts by zero, not .19cm + CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(0), getProperty<sal_Int32>(xTable, "LeftMargin")); } CPPUNIT_TEST_FIXTURE(Test, testSdt2Run) diff --git a/sw/source/writerfilter/dmapper/DomainMapperTableHandler.cxx b/sw/source/writerfilter/dmapper/DomainMapperTableHandler.cxx index b4e2174f52dc..6c282aed8935 100644 --- a/sw/source/writerfilter/dmapper/DomainMapperTableHandler.cxx +++ b/sw/source/writerfilter/dmapper/DomainMapperTableHandler.cxx @@ -603,7 +603,18 @@ TableStyleSheetEntry * DomainMapperTableHandler::endTableGetTableStyle(TableInfo if (m_rDMapper_Impl.IsOOXMLImport() && (nMode < 0 || (0 < nMode && nMode <= 14)) && rInfo.nNestLevel == 1) { - const sal_Int32 nAdjustedMargin = nLeftMargin - rInfo.nLeftBorderDistance; + const sal_Int32 nMinLeftBorderDistance = aLeftBorder.LineWidth / 2; + sal_Int32 nLeftBorderDistance = rInfo.nLeftBorderDistance; + if (!m_aCellProperties.empty() && !m_aCellProperties[0].empty()) + { + // only the border spacing of the first row affects the placement of the table + std::optional<PropertyMap::Property> aCellLeftBorderDistance + = m_aCellProperties[0][0]->getProperty(PROP_LEFT_BORDER_DISTANCE); + if (aCellLeftBorderDistance) + aCellLeftBorderDistance->second >>= nLeftBorderDistance; + } + nLeftBorderDistance = std::max(nMinLeftBorderDistance, nLeftBorderDistance); + const sal_Int32 nAdjustedMargin = nLeftMargin - nLeftBorderDistance; m_aTableProperties->Insert( PROP_LEFT_MARGIN, uno::Any( nAdjustedMargin ) ); } else
