From: Dominik Stadler Date: Wed, 5 Oct 2016 19:59:56 +0000 (+0000) Subject: Bug 53028: Broken auto fit row height in the cells with word wrap X-Git-Tag: REL_3_16_BETA1~134 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=b66689d2b026280202c04d3a52cb33199abef2ab;p=poi.git Bug 53028: Broken auto fit row height in the cells with word wrap git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1763484 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java b/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java index 31a17e0c0f..7af241c85a 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java @@ -499,6 +499,7 @@ public final class HSSFRow implements Row, Comparable { { if(height == -1){ row.setHeight((short)(0xFF | 0x8000)); + row.setBadFontHeight(false); } else { row.setBadFontHeight(true); row.setHeight((short) (height * 20)); diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRow.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRow.java index ecfe4cf971..bd7ad3d2e8 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRow.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRow.java @@ -17,11 +17,6 @@ package org.apache.poi.hssf.usermodel; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.fail; - import java.io.IOException; import org.apache.poi.hssf.HSSFITestDataProvider; @@ -31,6 +26,8 @@ import org.apache.poi.ss.SpreadsheetVersion; import org.apache.poi.ss.usermodel.BaseTestRow; import org.junit.Test; +import static org.junit.Assert.*; + /** * Test HSSFRow is okay. * @@ -42,10 +39,12 @@ public final class TestHSSFRow extends BaseTestRow { super(HSSFITestDataProvider.instance); } + @Test public void testRowBounds() throws IOException { baseTestRowBounds(SpreadsheetVersion.EXCEL97.getLastRowIndex()); } + @Test public void testCellBounds() throws IOException { baseTestCellBounds(SpreadsheetVersion.EXCEL97.getLastColumnIndex()); } @@ -136,16 +135,28 @@ public final class TestHSSFRow extends BaseTestRow { HSSFRow row = sheet.createRow(0); assertEquals(row.getHeight(), sheet.getDefaultRowHeight()); - assertEquals(row.getRowRecord().getBadFontHeight(), false); + assertFalse(row.getRowRecord().getBadFontHeight()); row.setHeight((short) 123); - assertEquals(row.getHeight(), 123); - assertEquals(row.getRowRecord().getBadFontHeight(), true); + assertEquals(123, row.getHeight()); + assertTrue(row.getRowRecord().getBadFontHeight()); row.setHeight((short) -1); assertEquals(row.getHeight(), sheet.getDefaultRowHeight()); - assertEquals(row.getRowRecord().getBadFontHeight(), false); - + assertFalse(row.getRowRecord().getBadFontHeight()); + + row.setHeight((short) 123); + assertEquals(123, row.getHeight()); + assertTrue(row.getRowRecord().getBadFontHeight()); + + row.setHeightInPoints(-1); + assertEquals(row.getHeight(), sheet.getDefaultRowHeight()); + assertFalse(row.getRowRecord().getBadFontHeight()); + + row.setHeightInPoints(432); + assertEquals(432*20, row.getHeight()); + assertTrue(row.getRowRecord().getBadFontHeight()); + workbook.close(); } }