diff --git a/odfdom/src/test/java/org/odftoolkit/odfdom/doc/table/TableTest.java b/odfdom/src/test/java/org/odftoolkit/odfdom/doc/table/TableTest.java index 340784379..9053306a8 100644 --- a/odfdom/src/test/java/org/odftoolkit/odfdom/doc/table/TableTest.java +++ b/odfdom/src/test/java/org/odftoolkit/odfdom/doc/table/TableTest.java @@ -23,6 +23,7 @@ import java.util.Calendar; import java.util.HashMap; import java.util.List; +import java.util.Locale; import java.util.Map; import java.util.logging.Level; import java.util.logging.Logger; @@ -47,8 +48,10 @@ import org.odftoolkit.odfdom.dom.element.table.TableTableColumnElement; import org.odftoolkit.odfdom.dom.element.table.TableTableElement; import org.odftoolkit.odfdom.dom.element.table.TableTableHeaderColumnsElement; +import org.odftoolkit.odfdom.dom.style.props.OdfTableColumnProperties; import org.odftoolkit.odfdom.pkg.OdfElement; import org.odftoolkit.odfdom.pkg.OdfFileDom; +import org.odftoolkit.odfdom.type.PositiveLength; import org.odftoolkit.odfdom.utils.ResourceUtilities; import org.w3c.dom.NamedNodeMap; import org.w3c.dom.Node; @@ -201,6 +204,28 @@ public void testNewTableWithoutHeaderColumn() { } } + /** + * Issue #332 + */ + @Test + public void testNewTableGermanLocaleColumnWidth() { + Locale previousDefault = Locale.getDefault(); + try { + Locale.setDefault(Locale.GERMANY); + OdfSpreadsheetDocument spreadsheet = OdfSpreadsheetDocument.newSpreadsheetDocument(); + OdfTable sheet = OdfTable.newTable(spreadsheet, 3, 5); + Locale.setDefault(previousDefault); + + Assert.assertTrue(PositiveLength.isValid(sheet.getColumnElementByIndex(0).getProperty(OdfTableColumnProperties.ColumnWidth))); + sheet.getColumnByIndex(0).setWidth(10L); + Assert.assertEquals((sheet.getColumnByIndex(0).getWidth()), 10); + } catch (Exception e) { + Locale.setDefault(previousDefault); + Logger.getLogger(TableTest.class.getName()).log(Level.SEVERE, null, e); + Assert.fail(e.getMessage()); + } + } + private OdfTable createEmptyTable(OdfTextDocument document) { String tablename = "Table1"; int rownumber = 5; @@ -1114,11 +1139,11 @@ public void testGetCellAt() { @Test public void writeCellDataAndCloneSheet() { try { - OdfSpreadsheetDocument ods = + OdfSpreadsheetDocument ods = (OdfSpreadsheetDocument) OdfSpreadsheetDocument.loadDocument( ResourceUtilities.getAbsoluteInputPath("template.ots")); - + ods.getSpreadsheetTables().get(0).appendRow(); ods.getSpreadsheetTables().get(0).getRowByIndex(5).getCellByIndex(0).setStringValue("Row3"); ods.getSpreadsheetTables().get(0).getRowByIndex(5).getCellByIndex(1).setDateValue(Calendar.getInstance());