Dear ODF-Devs, I have observed a problem with the setHeight() method of the Row class of the Simple API. When I use this method to set the height of a row, the row height does not change. This is because the associated <table:table-row> element does not have a table:style-name attribute that points to the desired style.
Looking in the code for the setHeight method (in Row.java), I see that this attribute is removed before the property is set: maRowElement.removeAttributeNS(OdfDocumentNamespace.TABLE.getUri(), "style-name"); maRowElement.setProperty(rowHeightProp, sHeightIN); I have run a test (attached), and if I set the property without removing the style-name attribute then everything works as expected. Is there a reason this attribute is being removed? Comparing with the similar setColumnWidth method of the Column class, this removal of the attribute does not happen there. Should this call to removeAttributeNS be removed? Thanks, Nick
package com.nick;
import junit.framework.TestCase;
import org.odftoolkit.simple.SpreadsheetDocument;
import org.junit.Test;
import java.io.File;
import org.odftoolkit.simple.table.Table;
import org.odftoolkit.simple.table.Row;
import org.odftoolkit.odfdom.dom.style.props.OdfTableRowProperties;
public class RowHeightTest extends TestCase{
@Test
public void testAdjustHeight() throws Exception {
File input = new File(getClass().getResource("/test.ods").toURI());
File output = new File(input.getParentFile(), "/row-height-test.ods");
SpreadsheetDocument spreadsheet = SpreadsheetDocument.loadDocument(new File(getClass().getResource("/test.ods").toURI()));
Table table = spreadsheet.getSheetByIndex(0);
Row row = table.getRowByIndex(0);
//This method doesn't work
row.setHeight(25.0, false);
//This method does work.
//row.getOdfElement().setProperty(OdfTableRowProperties.RowHeight, "1in");
spreadsheet.save(output);
}
}
test.ods
Description: application/vnd.oasis.opendocument.spreadsheet
