sw/qa/extras/ooxmlexport/data/tdf140137.docx             |binary
 sw/qa/extras/ooxmlexport/ooxmlexport16.cxx               |    5 ++++
 writerfilter/source/dmapper/DomainMapperTableManager.cxx |   18 ++++++++++-----
 3 files changed, 18 insertions(+), 5 deletions(-)

New commits:
commit 31c1f9dd56184307db0743b0b4bef9510e601c1a
Author:     Aron Budea <aron.bu...@collabora.com>
AuthorDate: Sun Feb 28 22:04:24 2021 +0100
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Mon Mar 1 15:36:18 2021 +0100

    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 <caol...@redhat.com>
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111736
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111741
    (cherry picked from commit 102ddaa04193a3303e4d3d3e2193048aad3dc16a)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111707
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

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
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf140137.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
index c300f7068110..5e966efd5999 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport16.cxx
@@ -67,6 +67,11 @@ DECLARE_OOXMLEXPORT_TEST(testTdf138953, 
"croppedAndRotated.odt")
     CPPUNIT_ASSERT_EQUAL(sal_Int32(8664), frameRect.Width);
 }
 
+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 a19b9395e192..84b959e4e6ba 100644
--- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx
+++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx
@@ -726,17 +726,25 @@ void DomainMapperTableManager::endOfRowAction()
         size_t nWidthsBound = m_aGridBefore.back() + m_nCell.back() - 1;
         if (nWidthsBound)
         {
-            if (nFullWidthRelative == 0)
-                throw o3tl::divide_by_zero();
-
             ::std::vector< sal_Int32 >::const_iterator aSpansIter = 
pCurrentSpans->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;
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to