diff options
author | Yegor Kozlov <yegor@apache.org> | 2010-08-19 18:08:54 +0000 |
---|---|---|
committer | Yegor Kozlov <yegor@apache.org> | 2010-08-19 18:08:54 +0000 |
commit | b98b01b29b0168b09bab225e8b93067ae3e89ebd (patch) | |
tree | 89a30ce3427f7bfcb1ed0fac988a59a05409ca40 | |
parent | faa64fa1f42d6204a841a6e4b6e172dfc4a892b4 (diff) | |
download | poi-b98b01b29b0168b09bab225e8b93067ae3e89ebd.tar.gz poi-b98b01b29b0168b09bab225e8b93067ae3e89ebd.zip |
fixed fetching names of user defined styles, see Bugzila 49751
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@987256 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | src/documentation/content/xdocs/status.xml | 1 | ||||
-rw-r--r-- | src/java/org/apache/poi/hssf/model/InternalWorkbook.java | 2 | ||||
-rw-r--r-- | src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java | 28 | ||||
-rw-r--r-- | test-data/spreadsheet/49751.xls | bin | 0 -> 19456 bytes |
4 files changed, 27 insertions, 4 deletions
diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index ad5baeebdd..67f61e1615 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,7 @@ <changes> <release version="3.7-beta3" date="2010-??-??"> + <action dev="POI-DEVELOPERS" type="fix">49751 - fixed fetching names of user defined styles in HSSFCellStyle.getUserStyleName()</action> <action dev="POI-DEVELOPERS" type="add">48900 - support for protecting a XSSF workbook</action> <action dev="POI-DEVELOPERS" type="fix">49725 - fixed FormulaParser to correctly process defined names with underscore</action> <action dev="POI-DEVELOPERS" type="add">48526 - added implementation for RANDBETWEEN()</action> diff --git a/src/java/org/apache/poi/hssf/model/InternalWorkbook.java b/src/java/org/apache/poi/hssf/model/InternalWorkbook.java index f2719bba5e..1ac6a2a375 100644 --- a/src/java/org/apache/poi/hssf/model/InternalWorkbook.java +++ b/src/java/org/apache/poi/hssf/model/InternalWorkbook.java @@ -871,7 +871,7 @@ public final class InternalWorkbook { continue; } if(!(r instanceof StyleRecord)) { - return null; + continue; } StyleRecord sr = (StyleRecord)r; if(sr.getXFIndex() == xfIndex) { diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java index 7d8c27a6f4..293e237b0e 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java @@ -22,9 +22,7 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; +import java.util.*; import junit.framework.AssertionFailedError; @@ -1837,4 +1835,28 @@ if(1==2) { assertEquals("Testing 2", wb.getCellStyleAt((short)22).getUserStyleName()); assertEquals("Testing 3", wb.getCellStyleAt((short)23).getUserStyleName()); } + + public void test49751() { + HSSFWorkbook wb = openSample("49751.xls"); + short numCellStyles = wb.getNumCellStyles(); + List<String> namedStyles = Arrays.asList( + "20% - Accent1", "20% - Accent2", "20% - Accent3", "20% - Accent4", "20% - Accent5", + "20% - Accent6", "40% - Accent1", "40% - Accent2", "40% - Accent3", "40% - Accent4", + "40% - Accent5", "40% - Accent6", "60% - Accent1", "60% - Accent2", "60% - Accent3", + "60% - Accent4", "60% - Accent5", "60% - Accent6", "Accent1", "Accent2", "Accent3", + "Accent4", "Accent5", "Accent6", "Bad", "Calculation", "Check Cell", "Explanatory Text", + "Good", "Heading 1", "Heading 2", "Heading 3", "Heading 4", "Input", "Linked Cell", + "Neutral", "Note", "Output", "Title", "Total", "Warning Text"); + + List<String> collecteddStyles = new ArrayList<String>(); + for (short i = 0; i < numCellStyles; i++) { + HSSFCellStyle cellStyle = wb.getCellStyleAt(i); + String styleName = cellStyle.getUserStyleName(); + if (styleName != null) { + collecteddStyles.add(styleName); + } + } + assertTrue(namedStyles.containsAll(collecteddStyles)); + + } } diff --git a/test-data/spreadsheet/49751.xls b/test-data/spreadsheet/49751.xls Binary files differnew file mode 100644 index 0000000000..09eaede140 --- /dev/null +++ b/test-data/spreadsheet/49751.xls |