aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorYegor Kozlov <yegor@apache.org>2012-02-12 11:14:23 +0000
committerYegor Kozlov <yegor@apache.org>2012-02-12 11:14:23 +0000
commitbc48e85daacb6a52e8c2376f56d23d95c8a5f74a (patch)
tree00fc249b60bfe36c9a34acc44c93ce11b45ed008 /src
parent7e7bde2595efc8b52531708c03326455a126ce80 (diff)
downloadpoi-bc48e85daacb6a52e8c2376f56d23d95c8a5f74a.tar.gz
poi-bc48e85daacb6a52e8c2376f56d23d95c8a5f74a.zip
Bugzilla 52626: fixed setting default row height in HSSF and XSSF
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1243240 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/poi/hssf/model/InternalSheet.java2
-rw-r--r--src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java2
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java8
-rw-r--r--src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFRow.java10
-rw-r--r--src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java1
-rw-r--r--src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java4
6 files changed, 23 insertions, 4 deletions
diff --git a/src/java/org/apache/poi/hssf/model/InternalSheet.java b/src/java/org/apache/poi/hssf/model/InternalSheet.java
index c3db773929..0f03bbc457 100644
--- a/src/java/org/apache/poi/hssf/model/InternalSheet.java
+++ b/src/java/org/apache/poi/hssf/model/InternalSheet.java
@@ -1002,6 +1002,8 @@ public final class InternalSheet {
*/
public void setDefaultRowHeight(short dch) {
defaultrowheight.setRowHeight(dch);
+ // set the bit that specifies that the default settings for the row height have been changed.
+ defaultrowheight.setOptionFlags((short)1);
}
/**
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
index 7a821b7886..a1bc0f36b7 100644
--- a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
+++ b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
@@ -197,6 +197,8 @@ public final class HSSFSheet implements org.apache.poi.ss.usermodel.Sheet {
public HSSFRow createRow(int rownum)
{
HSSFRow row = new HSSFRow(_workbook, this, rownum);
+ // new rows inherit default height from the sheet
+ row.setHeight(getDefaultRowHeight());
addRow(row, true);
return row;
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
index b1d532427b..fa7ce429d8 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFSheet.java
@@ -2060,8 +2060,7 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
* @param height default row height in twips (1/20 of a point)
*/
public void setDefaultRowHeight(short height) {
- getSheetTypeSheetFormatPr().setDefaultRowHeight((double)height / 20);
-
+ setDefaultRowHeightInPoints((float)height / 20);
}
/**
@@ -2070,8 +2069,9 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
* @param height default row height measured in point size.
*/
public void setDefaultRowHeightInPoints(float height) {
- getSheetTypeSheetFormatPr().setDefaultRowHeight(height);
-
+ CTSheetFormatPr pr = getSheetTypeSheetFormatPr();
+ pr.setDefaultRowHeight(height);
+ pr.setCustomHeight(true);
}
/**
diff --git a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFRow.java b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFRow.java
index 2a3e06991c..1a0ff3bfa2 100644
--- a/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFRow.java
+++ b/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFRow.java
@@ -19,6 +19,7 @@
package org.apache.poi.xssf.streaming;
+import org.apache.poi.ss.SpreadsheetVersion;
import org.apache.poi.ss.usermodel.BaseTestRow;
import org.apache.poi.xssf.SXSSFITestDataProvider;
@@ -30,4 +31,13 @@ public final class TestSXSSFRow extends BaseTestRow {
public TestSXSSFRow() {
super(SXSSFITestDataProvider.instance);
}
+
+ public void testRowBounds() {
+ baseTestRowBounds(SpreadsheetVersion.EXCEL2007.getLastRowIndex());
+ }
+
+ public void testCellBounds() {
+ baseTestCellBounds(SpreadsheetVersion.EXCEL2007.getLastColumnIndex());
+ }
+
}
diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java
index da40cd076b..eb185471f4 100644
--- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java
+++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestRow.java
@@ -292,6 +292,7 @@ public abstract class BaseTestRow extends TestCase {
assertEquals(20*20, row1.getHeight());
Row row2 = sheet.createRow(1);
+ assertEquals(sheet.getDefaultRowHeight(), row2.getHeight());
row2.setHeight((short)310);
assertEquals(310, row2.getHeight());
assertEquals(310F/20, row2.getHeightInPoints(), 0F);
diff --git a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java
index b7f7a783c5..bd2b8f3771 100644
--- a/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java
+++ b/src/testcases/org/apache/poi/ss/usermodel/BaseTestSheet.java
@@ -401,6 +401,10 @@ public abstract class BaseTestSheet extends TestCase {
assertEquals((short) 300, sheet.getDefaultRowHeight());
assertEquals(15.0F, sheet.getDefaultRowHeightInPoints(), 0F);
+ Row row = sheet.createRow(1);
+ // new row inherits default height from the sheet
+ assertEquals(sheet.getDefaultRowHeight(), row.getHeight());
+
// Set a new default row height in twips and test getting the value in points
sheet.setDefaultRowHeight((short) 360);
assertEquals(18.0f, sheet.getDefaultRowHeightInPoints(), 0F);