Hi,
we have an issue while deleting some lines in an odt document containing tables. The issue: if the table has merged cells (see attachment sample), the deletion of lines containing this merged cells is not possible. If the merged cells are removed, everything works fine.
Error is located here:
java.lang.NullPointerException: Cannot invoke "org.odftoolkit.odfdom.doc.table.OdfTableCell.isCoveredElement()" because "cell" is null
at org.odftoolkit.odfdom.doc.table.OdfTableRow.removeAllCellsRelationship(OdfTableRow.java:868)
at org.odftoolkit.odfdom.doc.table.OdfTable.removeRowsByIndex(OdfTable.java:1816)
at de.rekn.odftest.DeleteLineTest.testDeleteLine(DeleteLineTest.java:20)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
Sample code for reproducing this error:
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Path;
import org.junit.jupiter.api.Test;
import org.odftoolkit.odfdom.doc.OdfTextDocument;
import org.odftoolkit.odfdom.doc.table.OdfTable;
public class DeleteLineTest {
@Test
public void testDeleteLineText() throws URISyntaxException, Exception {
URL resURL = this.getClass().getResource("/odfWriterTest.odt");
OdfTextDocument document = OdfTextDocument.loadDocument(Path.of(resURL.toURI()).toFile());
OdfTable pTable = document.getTableList(true).get(0);
assertDoesNotThrow(() -> pTable.removeRowsByIndex(2, 1));
}
}
Testfile odfWriterTest.odt
Can you confirm this is a bug? Are there other ways to solve this problem?
Thanks in advance
Boarschti
Hi,
we have an issue while deleting some lines in an odt document containing tables. The issue: if the table has merged cells (see attachment sample), the deletion of lines containing this merged cells is not possible. If the merged cells are removed, everything works fine.
Error is located here:
Sample code for reproducing this error:
Testfile odfWriterTest.odt
Can you confirm this is a bug? Are there other ways to solve this problem?
Thanks in advance
Boarschti