[Libreoffice-commits] core.git: connectivity/source sw/qa

Miklos Vajna vmiklos at collabora.co.uk
Wed Oct 11 06:20:18 UTC 2017


 connectivity/source/drivers/writer/WTable.cxx                      |   13 +++++++-
 sw/qa/extras/mailmerge/data/10-testing-addresses-writer-merged.odt |binary
 sw/qa/extras/mailmerge/data/writer-merged-mail-merge.odt           |binary
 sw/qa/extras/mailmerge/mailmerge.cxx                               |   16 ++++++++++
 4 files changed, 28 insertions(+), 1 deletion(-)

New commits:
commit d8d0914be7b5fee3e21ec088f518b09281ed34ee
Author: Miklos Vajna <vmiklos at collabora.co.uk>
Date:   Wed Oct 11 00:31:44 2017 +0200

    connectivity writer driver: survive merged cells
    
    Fow now just don't crash on them, instead give empty result for those
    cells.
    
    Change-Id: I9edd231b00fa00af95408a550484da74c98275da
    Reviewed-on: https://gerrit.libreoffice.org/43319
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Jenkins <ci at libreoffice.org>

diff --git a/connectivity/source/drivers/writer/WTable.cxx b/connectivity/source/drivers/writer/WTable.cxx
index fd759cc88ad9..9f08b05ca48a 100644
--- a/connectivity/source/drivers/writer/WTable.cxx
+++ b/connectivity/source/drivers/writer/WTable.cxx
@@ -28,6 +28,7 @@
 #include <com/sun/star/util/NumberFormat.hpp>
 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
 #include <com/sun/star/text/XText.hpp>
+#include <com/sun/star/lang/IndexOutOfBoundsException.hpp>
 #include <svl/converter.hxx>
 #include "writer/WConnection.hxx"
 #include "component/CColumns.hxx"
@@ -87,7 +88,17 @@ static void lcl_SetValue(connectivity::ORowSetValue& rValue, const uno::Referenc
         ++nDocRow;
 
     uno::Reference<table::XCellRange> xCellRange(xTable, uno::UNO_QUERY);
-    const uno::Reference<table::XCell> xCell = xCellRange->getCellByPosition(nDocColumn, nDocRow);
+    uno::Reference<table::XCell> xCell;
+    try
+    {
+        xCell = xCellRange->getCellByPosition(nDocColumn, nDocRow);
+    }
+    catch (const lang::IndexOutOfBoundsException& /*rException*/)
+    {
+        SAL_WARN("connectivity.writer", "getCellByPosition(" << nDocColumn << ", " << nDocRow << ") failed");
+        rValue = OUString();
+    }
+
     if (xCell.is())
     {
         const uno::Reference<text::XText> xText(xCell, uno::UNO_QUERY);
diff --git a/sw/qa/extras/mailmerge/data/10-testing-addresses-writer-merged.odt b/sw/qa/extras/mailmerge/data/10-testing-addresses-writer-merged.odt
new file mode 100644
index 000000000000..e61d9fc04635
Binary files /dev/null and b/sw/qa/extras/mailmerge/data/10-testing-addresses-writer-merged.odt differ
diff --git a/sw/qa/extras/mailmerge/data/writer-merged-mail-merge.odt b/sw/qa/extras/mailmerge/data/writer-merged-mail-merge.odt
new file mode 100644
index 000000000000..8ec76852a34a
Binary files /dev/null and b/sw/qa/extras/mailmerge/data/writer-merged-mail-merge.odt differ
diff --git a/sw/qa/extras/mailmerge/mailmerge.cxx b/sw/qa/extras/mailmerge/mailmerge.cxx
index d7413f33a68a..3e29b7a9b01e 100644
--- a/sw/qa/extras/mailmerge/mailmerge.cxx
+++ b/sw/qa/extras/mailmerge/mailmerge.cxx
@@ -440,6 +440,22 @@ DECLARE_FILE_MAILMERGE_TEST(testWriterDataSource, "writer-mail-merge.odt", "10-t
     }
 }
 
+DECLARE_FILE_MAILMERGE_TEST(testWriterMergedDataSource, "writer-merged-mail-merge.odt", "10-testing-addresses-writer-merged.odt", "testing-addresses-writer-merged")
+{
+    // This failed with com.sun.star.lang.IndexOutOfBoundsException, leading to
+    // a crash, as the last row had merged cells in
+    // 10-testing-addresses-writer-merged.odt.
+    executeMailMerge();
+    for (int doc = 0; doc < 10; ++doc)
+    {
+        loadMailMergeDocument(doc);
+        CPPUNIT_ASSERT_EQUAL(1, getPages());
+        CPPUNIT_ASSERT_EQUAL(OUString("Fixed text."), getRun(getParagraph(1), 1)->getString());
+        CPPUNIT_ASSERT_EQUAL(OUString("lastname" + OUString::number(doc + 1)), getRun(getParagraph(2), 1)->getString());
+        CPPUNIT_ASSERT_EQUAL(OUString("Another fixed text."), getRun(getParagraph(3), 1)->getString());
+    }
+}
+
 DECLARE_FILE_MAILMERGE_TEST(test2Pages, "simple-mail-merge-2pages.odt", "10-testing-addresses.ods", "testing-addresses")
 {
     executeMailMerge();


More information about the Libreoffice-commits mailing list