You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2010/08/03 17:29:56 UTC
svn commit: r981930 - in /poi/trunk/src:
documentation/content/xdocs/status.xml
java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java
testcases/org/apache/poi/hssf/usermodel/TestBugs.java
Author: nick
Date: Tue Aug 3 15:29:56 2010
New Revision: 981930
URL: http://svn.apache.org/viewvc?rev=981930&view=rev
Log:
Fix bug #49689 - Allow the setting of user style names on newly created HSSF cell styles
Modified:
poi/trunk/src/documentation/content/xdocs/status.xml
poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java
poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=981930&r1=981929&r2=981930&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Tue Aug 3 15:29:56 2010
@@ -34,6 +34,7 @@
<changes>
<release version="3.7-beta2" date="2010-??-??">
+ <action dev="POI-DEVELOPERS" type="fix">49689 - Allow the setting of user style names on newly created HSSF cell styles</action>
<action dev="POI-DEVELOPERS" type="add">Make it easier to tell which content types each POIXMLTextExtractor handles</action>
<action dev="POI-DEVELOPERS" type="fix">49649 - Added clone support for UserSView* and Feat* families of records</action>
<action dev="POI-DEVELOPERS" type="fix">49653 - Support for escaped unicode characters in Shared String Table</action>
Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java?rev=981930&r1=981929&r2=981930&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java Tue Aug 3 15:29:56 2010
@@ -778,7 +778,9 @@ public final class HSSFCellStyle impleme
if(sr == null) {
sr = _workbook.createStyleRecord(_index);
}
- if(sr.isBuiltin()) {
+ // All Style records start as "builtin", but generally
+ // only 20 and below really need to be
+ if(sr.isBuiltin() && _index <= 20) {
throw new IllegalArgumentException("Unable to set user specified style names for built in styles!");
}
sr.setName(styleName);
Modified: poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java?rev=981930&r1=981929&r2=981930&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java Tue Aug 3 15:29:56 2010
@@ -1803,4 +1803,38 @@ if(1==2) {
assertEquals(0xff, rotated.getCellStyle().getRotation());
assertEquals(0xff, nc.getCellStyle().getRotation());
}
+
+ /**
+ * Setting the user style name on custom styles
+ */
+ public void test49689() throws Exception {
+ HSSFWorkbook wb = new HSSFWorkbook();
+ HSSFSheet s = wb.createSheet("Test");
+ HSSFRow r = s.createRow(0);
+ HSSFCell c = r.createCell(0);
+
+ HSSFCellStyle cs1 = wb.createCellStyle();
+ HSSFCellStyle cs2 = wb.createCellStyle();
+ HSSFCellStyle cs3 = wb.createCellStyle();
+
+ assertEquals(21, cs1.getIndex());
+ cs1.setUserStyleName("Testing");
+
+ assertEquals(22, cs2.getIndex());
+ cs2.setUserStyleName("Testing 2");
+
+ assertEquals(23, cs3.getIndex());
+ cs3.setUserStyleName("Testing 3");
+
+ // Set one
+ c.setCellStyle(cs1);
+
+ // Write out and read back
+ wb = writeOutAndReadBack(wb);
+
+ // Re-check
+ assertEquals("Testing", wb.getCellStyleAt((short)21).getUserStyleName());
+ assertEquals("Testing 2", wb.getCellStyleAt((short)22).getUserStyleName());
+ assertEquals("Testing 3", wb.getCellStyleAt((short)23).getUserStyleName());
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org