sw/qa/extras/layout/data/tdf134685.docx |binary sw/qa/extras/layout/layout.cxx | 10 ++++++++++ writerfilter/source/dmapper/TableData.hxx | 9 +++++++-- writerfilter/source/dmapper/TableManager.cxx | 6 ++++-- writerfilter/source/dmapper/TableManager.hxx | 2 +- 5 files changed, 22 insertions(+), 5 deletions(-)
New commits: commit abea0d6647c7f1f7e76c73c26cb80e6a67dc5111 Author: László Németh <nem...@numbertext.org> AuthorDate: Fri Jul 17 14:39:45 2020 +0200 Commit: László Németh <nem...@numbertext.org> CommitDate: Mon Jul 20 09:36:26 2020 +0200 tdf#134685 DOCX table import: fix gridBefore + cell width Improve workaround to handle nested tables started at cell start in a row with gridBefore. Omitted gridBefore cells from commit 5483d4e10aad27889b961b9cb94d7ba6c86aed0b (tdf#134606 DOCX table import: fix gridBefore + nesting) resulted less cells in the row than defined by the grid, and the different code path could lead to narrow cell width with partially invisible nested table. Fix this by adding gridBefore cell count to the cell span in the first cell. Regression from commit 70274f86cdc1c023ffdd0130c262c1479262d76b (tdf#116194 DOCX import: fix missing tables with w:gridBefore) Change-Id: If332305d54ff2b34b258270a607fb31ff7380149 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/98973 Tested-by: Jenkins Reviewed-by: László Németh <nem...@numbertext.org> diff --git a/sw/qa/extras/layout/data/tdf134685.docx b/sw/qa/extras/layout/data/tdf134685.docx new file mode 100644 index 000000000000..86b59fa982f3 Binary files /dev/null and b/sw/qa/extras/layout/data/tdf134685.docx differ diff --git a/sw/qa/extras/layout/layout.cxx b/sw/qa/extras/layout/layout.cxx index eee85f5b9b72..5d70eec259b2 100644 --- a/sw/qa/extras/layout/layout.cxx +++ b/sw/qa/extras/layout/layout.cxx @@ -3121,6 +3121,16 @@ CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf127606) assertXPath(pXmlDoc, "/root/page/body/tab/row/cell/txt[3]/Special", "nHeight", "260"); } +CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf134685) +{ + createDoc("tdf134685.docx"); + xmlDocUniquePtr pXmlDoc = parseLayoutDump(); + sal_Int32 nWidth + = getXPath(pXmlDoc, "/root/page/body/tab/row[6]/cell[1]/infos/bounds", "width").toInt32(); + // This was 2223: the content was only partially visible according to the lost cell width + CPPUNIT_ASSERT_GREATER(static_cast<sal_Int32>(14000), nWidth); +} + CPPUNIT_TEST_FIXTURE(SwLayoutWriter, testTdf109077) { createDoc("tdf109077.docx"); diff --git a/writerfilter/source/dmapper/TableData.hxx b/writerfilter/source/dmapper/TableData.hxx index 9da80a620481..a88c6a477430 100644 --- a/writerfilter/source/dmapper/TableData.hxx +++ b/writerfilter/source/dmapper/TableData.hxx @@ -248,10 +248,15 @@ public: nRet.push_back(aCell->getGridSpan()); return nRet; } - void setCurrentGridSpan(sal_uInt32 nSpan) + void setCurrentGridSpan(sal_uInt32 nSpan, bool bFirstCell = false) { if ( mCells.size() ) - mCells.back()->setGridSpan(nSpan); + { + if ( bFirstCell ) + mCells.front()->setGridSpan(nSpan); + else + mCells.back()->setGridSpan(nSpan); + } } }; diff --git a/writerfilter/source/dmapper/TableManager.cxx b/writerfilter/source/dmapper/TableManager.cxx index 9f29b2b437bf..8b49fbe509e0 100644 --- a/writerfilter/source/dmapper/TableManager.cxx +++ b/writerfilter/source/dmapper/TableManager.cxx @@ -72,9 +72,9 @@ std::vector<sal_uInt32> TableManager::getCurrentGridSpans() return mTableDataStack.top()->getCurrentRow()->getGridSpans(); } -void TableManager::setCurrentGridSpan(sal_uInt32 nGridSpan) +void TableManager::setCurrentGridSpan(sal_uInt32 nGridSpan, bool bFirstCell) { - mTableDataStack.top()->getCurrentRow()->setCurrentGridSpan(nGridSpan); + mTableDataStack.top()->getCurrentRow()->setCurrentGridSpan(nGridSpan, bFirstCell); } sal_uInt32 TableManager::findColumn(const sal_uInt32 nRow, const sal_uInt32 nCell) @@ -514,6 +514,8 @@ void TableManager::endRow() { // don't add gridBefore cells in not valid TextRange setCurrentGridBefore(0); + setCurrentGridSpan(getCurrentGridSpans().front() + nGridBefore, + /*bFirstCell=*/true); } } } diff --git a/writerfilter/source/dmapper/TableManager.hxx b/writerfilter/source/dmapper/TableManager.hxx index ba1b225b0cd9..234ba63f86bd 100644 --- a/writerfilter/source/dmapper/TableManager.hxx +++ b/writerfilter/source/dmapper/TableManager.hxx @@ -502,7 +502,7 @@ public: sal_uInt32 getCurrentGridBefore(); void setCurrentGridBefore( sal_uInt32 nSkipGrids ); std::vector<sal_uInt32> getCurrentGridSpans(); - void setCurrentGridSpan( sal_uInt32 nGridSpan ); + void setCurrentGridSpan( sal_uInt32 nGridSpan, bool bFirstCell = false ); /// Given a zero-based row/cell, return the zero-based grid it belongs to, or SAL_MAX_UINT16 for invalid. sal_uInt32 findColumn( const sal_uInt32 nRow, const sal_uInt32 nCell ); /// Given a zero-based row/col, return the zero-based cell describing that grid, or SAL_MAX_UINT16 for invalid. _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits