Kaydet (Commit) d8d0914b authored tarafından Miklos Vajna's avatar Miklos Vajna

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/43319Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
üst 33f126b4
......@@ -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);
......
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment