aboutsummaryrefslogtreecommitdiffstats
path: root/src/testcases/org
diff options
context:
space:
mode:
Diffstat (limited to 'src/testcases/org')
-rw-r--r--src/testcases/org/apache/poi/hssf/usermodel/TestHSSFOptimiser.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFOptimiser.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFOptimiser.java
index 6dc5f98e5e..d230185f73 100644
--- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFOptimiser.java
+++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFOptimiser.java
@@ -224,6 +224,7 @@ public final class TestHSSFOptimiser extends TestCase {
assertEquals(21, r.getCell(0).getCellValueRecord().getXFIndex());
// cs2 -> 22
assertEquals(22, r.getCell(1).getCellValueRecord().getXFIndex());
+ assertEquals(22, r.getCell(1).getCellStyle().getFont(wb).getFontHeight());
// cs3 = cs1 -> 21
assertEquals(21, r.getCell(2).getCellValueRecord().getXFIndex());
// cs4 --> 24 -> 23
@@ -269,4 +270,44 @@ public final class TestHSSFOptimiser extends TestCase {
// csD -> cs1 -> 21
assertEquals(21, r.getCell(8).getCellValueRecord().getXFIndex());
}
+
+ public void testOptimiseStylesCheckActualStyles() {
+ HSSFWorkbook wb = new HSSFWorkbook();
+
+ // Several styles
+ assertEquals(21, wb.getNumCellStyles());
+
+ HSSFCellStyle cs1 = wb.createCellStyle();
+ cs1.setBorderBottom(HSSFCellStyle.BORDER_THICK);
+
+ HSSFCellStyle cs2 = wb.createCellStyle();
+ cs2.setBorderBottom(HSSFCellStyle.BORDER_DASH_DOT);
+
+ HSSFCellStyle cs3 = wb.createCellStyle(); // = cs1
+ cs3.setBorderBottom(HSSFCellStyle.BORDER_THICK);
+
+ assertEquals(24, wb.getNumCellStyles());
+
+ // Use them
+ HSSFSheet s = wb.createSheet();
+ HSSFRow r = s.createRow(0);
+
+ r.createCell(0).setCellStyle(cs1);
+ r.createCell(1).setCellStyle(cs2);
+ r.createCell(2).setCellStyle(cs3);
+
+ assertEquals(21, r.getCell(0).getCellValueRecord().getXFIndex());
+ assertEquals(22, r.getCell(1).getCellValueRecord().getXFIndex());
+ assertEquals(23, r.getCell(2).getCellValueRecord().getXFIndex());
+
+ // Optimise
+ HSSFOptimiser.optimiseCellStyles(wb);
+
+ // Check
+ assertEquals(23, wb.getNumCellStyles());
+
+ assertEquals(HSSFCellStyle.BORDER_THICK, r.getCell(0).getCellStyle().getBorderBottom());
+ assertEquals(HSSFCellStyle.BORDER_DASH_DOT, r.getCell(1).getCellStyle().getBorderBottom());
+ assertEquals(HSSFCellStyle.BORDER_THICK, r.getCell(2).getCellStyle().getBorderBottom());
+ }
}