summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAron Budea <aron.budea@collabora.com>2021-02-28 22:04:24 +0100
committerCaolán McNamara <caolanm@redhat.com>2021-03-01 10:18:06 +0100
commit67d41607ad3b97abbb939a989e491af932e985a7 (patch)
tree73b1816a19b6f8d9f76d461798a3cd5325f99ddb
parent17e253a5de94ccce31300247fa53e05d9d499ff5 (diff)
tdf#140137 Don't throw exception when w:gridCol is missing "w" attr
2149e924cbc32c370128c5f87a4f55c50c99e6bd added a division-by-zero check, which caused Writer to throw an error on the bugdoc. Since the file could be loaded fine before, let's return to a working version, with the check included. The cause is the following in document.xml (originating from a non-MS generator): <w:tblGrid> <w:gridCol/> <w:gridCol/> </w:tblGrid> Word still splits such tables differently, but that difference was always there in Writer. Change-Id: I6d91a736f460394a76f035298a238c41da201cb3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111723 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--sw/qa/extras/ooxmlexport/data/tdf140137.docxbin0 -> 28792 bytes
-rw-r--r--sw/qa/extras/ooxmlexport/ooxmlexport16.cxx5
-rw-r--r--writerfilter/source/dmapper/DomainMapperTableManager.cxx18
3 files changed, 18 insertions, 5 deletions
diff --git a/sw/qa/extras/ooxmlexport/data/tdf140137.docx b/sw/qa/extras/ooxmlexport/data/tdf140137.docx
new file mode 100644
index 000000000000..d03925e75e2c
--- /dev/null
+++ b/sw/qa/extras/ooxmlexport/data/tdf140137.docx
Binary files differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
index 046721c53f59..29798dcabdec 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
@@ -147,6 +147,11 @@ DECLARE_OOXMLEXPORT_TEST(testTdf133473_shadowSize, "tdf133473.docx")
CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int32>(200000), nSize1);
}
+DECLARE_OOXMLEXPORT_TEST(testTdf140137, "tdf140137.docx")
+{
+ // Don't throw exception during load
+}
+
CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
index da78cb682e5c..a3a76dccbf82 100644
--- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
@@ -693,17 +693,25 @@ void DomainMapperTableManager::endOfRowAction()
size_t nWidthsBound = getCurrentGridBefore() + m_nCell.back() - 1;
if (nWidthsBound)
{
- if (nFullWidthRelative == 0)
- throw o3tl::divide_by_zero();
-
::std::vector< sal_uInt32 >::const_iterator aSpansIter = rCurrentSpans.begin();
for( size_t nBorder = 0; nBorder < nWidthsBound; ++nBorder )
{
- double fGridWidth = 0.;
+ double nRelPos, fGridWidth = 0.;
for ( sal_Int32 nGridCount = *aSpansIter; nGridCount > 0; --nGridCount )
fGridWidth += (*pTableGrid)[nBorderGridIndex++];
- double nRelPos = (fGridWidth * 10000) / nFullWidthRelative;
+ if (fGridWidth == 0.)
+ {
+ // allow nFullWidthRelative here, with a sane 0.0 result
+ nRelPos = 0.;
+ }
+ else
+ {
+ if (nFullWidthRelative == 0)
+ throw o3tl::divide_by_zero();
+
+ nRelPos = (fGridWidth * 10000) / nFullWidthRelative;
+ }
pSeparators[nBorder].Position = rtl::math::round(nRelPos + nLastRelPos);
pSeparators[nBorder].IsVisible = true;