sw/qa/extras/ooxmlexport/data/tdf131203.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport5.cxx | 8 +++++++ writerfilter/source/dmapper/DomainMapperTableManager.cxx | 17 +++++++-------- 3 files changed, 17 insertions(+), 8 deletions(-)
New commits: commit 02de07ffd65d40d26bfc15783ec25030117d5761 Author: László Németh <nem...@numbertext.org> AuthorDate: Thu Jan 5 10:21:10 2023 +0100 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Tue Jan 10 11:54:19 2023 +0000 tdf#131203 DOCX import: fix lost table when w:tblGrid is missing Load tables in case of incomplete text table definition, i.e. missing w:tblGrid and its w:gridCol elements, like MSO does. Note: Apache POI, and maybe old MSO versions generated such DOCX documents. divide_by_zero() was thrown from 975884fbbc3f80a634258ee562037688a42027a9 "ofz#7110 ensure join is called on std::exceptions as well as uno::Exception". See also commit 9279b0bb5397d0520b727ab0d271f328807c8749 "writerfilter: avoid divide by zero" and commit 116cadb5d2582532c69677a2f8499e8e9b7b9b80 "tdf#59274 DOCX import: fix tables with incomplete grid". Change-Id: I991807da13e22e551f81c3fb60580be7a9c0fb50 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145069 Tested-by: Jenkins Reviewed-by: László Németh <nem...@numbertext.org> (cherry picked from commit e17b4df3fe5441ca66e4203c725a578eb1797eb2) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145008 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> Tested-by: László Németh <nem...@numbertext.org> (cherry picked from commit e9a3755182db2a0e06278977e9d8af376ac4eefa) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145221 diff --git a/sw/qa/extras/ooxmlexport/data/tdf131203.docx b/sw/qa/extras/ooxmlexport/data/tdf131203.docx new file mode 100644 index 000000000000..2fd0dcabded4 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf131203.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx index cd405b196cba..c735d018a180 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport5.cxx @@ -248,6 +248,14 @@ CPPUNIT_TEST_FIXTURE(Test, testTdf131959) assertXPath(pXmlDoc, "/w:document/w:body/w:tbl/w:tr[1]/w:tc[1]/w:tbl/w:tblPr/w:tblInd", "w", "360"); } +CPPUNIT_TEST_FIXTURE(Test, testTdf131203) +{ + loadAndSave("tdf131203.docx"); + xmlDocUniquePtr pXmlDoc = parseExport("word/document.xml"); + // loading thrown divide_by_zero() + assertXPath(pXmlDoc, "//w:tbl", 2); +} + CPPUNIT_TEST_FIXTURE(Test, testFDO76597) { loadAndSave("fdo76597.docx"); diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx b/writerfilter/source/dmapper/DomainMapperTableManager.cxx index bc8b59642714..004f34971b6a 100644 --- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx @@ -807,15 +807,16 @@ void DomainMapperTableManager::endOfRowAction() nFullWidthRelative += nFixLastCellWidth - (*pCellWidths)[nWidthsBound]; } - if (nFullWidthRelative == 0) - throw o3tl::divide_by_zero(); - - for (size_t i = 0; i < nWidthsBound; ++i) + // tdf#131203 handle missing w:tblGrid + if (nFullWidthRelative > 0) { - nSum += (*pCellWidths)[i]; - pSeparators[nPos].Position = (nSum * 10000) / nFullWidthRelative; // Relative position - pSeparators[nPos].IsVisible = true; - nPos++; + for (size_t i = 0; i < nWidthsBound; ++i) + { + nSum += (*pCellWidths)[i]; + pSeparators[nPos].Position = (nSum * 10000) / nFullWidthRelative; // Relative position + pSeparators[nPos].IsVisible = true; + nPos++; + } } }