sw/qa/extras/rtfimport/data/tdf167254.rtf       |   22 ++++++++++++++++++++++
 sw/qa/extras/rtfimport/rtfimport2.cxx           |    6 ++++++
 sw/source/writerfilter/dmapper/TableManager.cxx |    2 +-
 3 files changed, 29 insertions(+), 1 deletion(-)

New commits:
commit 780e865517bc8ae798edde9d24cecb4a8254e516
Author:     Mike Kaganski <[email protected]>
AuthorDate: Fri Jun 27 02:04:53 2025 +0500
Commit:     Xisco Fauli <[email protected]>
CommitDate: Fri Jun 27 14:14:14 2025 +0200

    tdf#167254: check if getCellCount gives zero
    
    Regression since commit 038473595ed266d15a788d8f97781cbaf066cfe7
    (tdf#152839 add fill cells to tables imported wrongly from RTF, 2024-10-11).
    
    Change-Id: Ie2da84eb358d291bcc584a86ae69843f13186c3d
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187073
    Tested-by: Jenkins
    Reviewed-by: Mike Kaganski <[email protected]>
    Signed-off-by: Xisco Fauli <[email protected]>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187089

diff --git a/sw/qa/extras/rtfimport/data/tdf167254.rtf 
b/sw/qa/extras/rtfimport/data/tdf167254.rtf
new file mode 100644
index 000000000000..5ad617f72fb1
--- /dev/null
+++ b/sw/qa/extras/rtfimport/data/tdf167254.rtf
@@ -0,0 +1,22 @@
+{ tf1
+       rowd
+++\intbl A1+\intbl B1+\intbl ow\pard
+       rowd
+++\intbl A2+\intbl B2+\intbl ow\pard
+       rowd
+++\intbl A3+\intbl B3+\intbl ow\pard
+       rowd
+\intbl ow\pard
+}
\ No newline at end of file
diff --git a/sw/qa/extras/rtfimport/rtfimport2.cxx 
b/sw/qa/extras/rtfimport/rtfimport2.cxx
index b4981eda3a7f..04a41ed271ca 100644
--- a/sw/qa/extras/rtfimport/rtfimport2.cxx
+++ b/sw/qa/extras/rtfimport/rtfimport2.cxx
@@ -1087,6 +1087,12 @@ CPPUNIT_TEST_FIXTURE(Test, tdf165923Tdf)
     CPPUNIT_ASSERT_EQUAL(sal_Int32(0), getProperty<sal_Int32>(xPara, 
u"ParaTopMargin"_ustr));
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf167254)
+{
+    createSwDoc("tdf167254.rtf");
+    // It must not crash on import
+}
+
 // tests should only be added to rtfIMPORT *if* they fail round-tripping in 
rtfEXPORT
 } // end of anonymous namespace
 CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/writerfilter/dmapper/TableManager.cxx 
b/sw/source/writerfilter/dmapper/TableManager.cxx
index 2c814d1f6134..2baace56973b 100644
--- a/sw/source/writerfilter/dmapper/TableManager.cxx
+++ b/sw/source/writerfilter/dmapper/TableManager.cxx
@@ -410,7 +410,7 @@ void TableManager::HandleSmallerRows()
             RowData::Pointer_t pRowData = pTableData->getRow(nRow);
             sal_Int32 nRowWidth = 0;
             pRowData->getProperties()->getValue(TablePropertyMap::TABLE_WIDTH, 
nRowWidth);
-            if (nRowWidth < nMaxRowWidth)
+            if (nRowWidth < nMaxRowWidth && pRowData->getCellCount() > 0)
             {
                 uno::Reference<text::XTextRange> xTextRange
                     = pRowData->getCellEnd(pRowData->getCellCount() - 1);

Reply via email to