]> source.dussan.org Git - poi.git/commitdiff
Bug 53028: Broken auto fit row height in the cells with word wrap
authorDominik Stadler <centic@apache.org>
Wed, 5 Oct 2016 19:59:56 +0000 (19:59 +0000)
committerDominik Stadler <centic@apache.org>
Wed, 5 Oct 2016 19:59:56 +0000 (19:59 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1763484 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/poi/hssf/usermodel/HSSFRow.java
src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRow.java

index 31a17e0c0fe727b5eab39fd21a2a12d982ff5833..7af241c85a04839f9583acd885ab126e098fd288 100644 (file)
@@ -499,6 +499,7 @@ public final class HSSFRow implements Row, Comparable<HSSFRow> {
     {
         if(height == -1){
             row.setHeight((short)(0xFF | 0x8000));
+            row.setBadFontHeight(false);
         } else {
             row.setBadFontHeight(true);
             row.setHeight((short) (height * 20));
index ecfe4cf971367e924c1d4cdf7df2a0bb078c2706..bd7ad3d2e8232dcdd42bee07f048c2c21b5a9652 100644 (file)
 
 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();
     }
 }