cellRange.merge();
Cell cell = cellRange.getCellByPosition(0, 0);
saveodt("MergeTwoCell");
Assert.assertEquals(cell.getDisplayText(), "cell1\rcell2");
try {
TextDocument saveddoc = (TextDocument) TextDocument.loadDocument(ResourceUtilities
.getTestResourceAsStream(odtfilename + "MergeTwoCell.odt"));
Table savedTable1 = saveddoc.getTableByName("Table1");
// get the cell range which the first cell is the covered cell.
// so the cell range will be enlarged
CellRange savedCellRange = savedTable1.getCellRangeByPosition(1, 0, 2, 0);
savedCellRange.merge();
Assert.assertTrue(savedCellRange.getColumnNumber() == 3);
Cell savedCell = savedCellRange.getCellByPosition(0, 0);
NodeList paraList = savedCell.getOdfElement().getChildNodes();
Assert.assertTrue(paraList.item(2) instanceof OdfTextParagraph);
Assert.assertEquals(TextExtractor.getText((OdfTextParagraph) paraList.item(2)), "0.00");
saveddoc.save(ResourceUtilities.newTestOutputFile(odtfilename + "MergeCoveredCell.odt"));
} catch (Exception e) {
Logger.getLogger(TableCellRangeTest.class.getName()).log(Level.SEVERE, e.getMessage(), e);
Assert.fail("Failed with " + e.getClass().getName() + ": '" + e.getMessage() + "'");
}
try {
TextDocument saveddoc = (TextDocument) TextDocument.loadDocument(ResourceUtilities
.getTestResourceAsStream(odtfilename + "MergeTwoCell.odt"));
Table savedTable1 = saveddoc.getTableByName("Table1");
// get the cell range which the first cell is the covered cell.
// so the cell range will be enlarged
CellRange savedCellRange = savedTable1.getCellRangeByPosition(0, 0, 0, 1);
savedCellRange.merge();
Assert.assertTrue(savedCellRange.getColumnNumber() == 2);
Assert.assertTrue(savedCellRange.getRowNumber() == 2);
Cell savedCell = savedCellRange.getCellByPosition(0, 1);
Assert.assertTrue(savedCell.getOdfElement() instanceof TableCoveredTableCellElement);
saveddoc.save(ResourceUtilities.newTestOutputFile(odtfilename + "MergeCoveredCell2.odt"));
} catch (Exception e) {
Logger.getLogger(TableCellRangeTest.class.getName()).log(Level.SEVERE, e.getMessage(), e);
Assert.fail("Failed with " + e.getClass().getName() + ": '" + e.getMessage() + "'");
}
}