You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ye...@apache.org on 2008/01/19 15:28:10 UTC
svn commit: r613396 -
/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
Author: yegor
Date: Sat Jan 19 06:28:10 2008
New Revision: 613396
URL: http://svn.apache.org/viewvc?rev=613396&view=rev
Log:
add a check to prevent NPE in HSSFSheet.autoSizeColumn(). See Bug 44246
Modified:
poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
Modified: poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java?rev=613396&r1=613395&r2=613396&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java (original)
+++ poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java Sat Jan 19 06:28:10 2008
@@ -1748,27 +1748,28 @@
} else if (cell.getCellType() == HSSFCell.CELL_TYPE_BOOLEAN) {
sval = String.valueOf(cell.getBooleanCellValue());
}
+ if(sval != null) {
+ String txt = sval + defaultChar;
+ str = new AttributedString(txt);
+ copyAttributes(font, str, 0, txt.length());
- String txt = sval + defaultChar;
- str = new AttributedString(txt);
- copyAttributes(font, str, 0, txt.length());
-
- layout = new TextLayout(str.getIterator(), frc);
- if(style.getRotation() != 0){
- /*
- * Transform the text using a scale so that it's height is increased by a multiple of the leading,
- * and then rotate the text before computing the bounds. The scale results in some whitespace around
- * the unrotated top and bottom of the text that normally wouldn't be present if unscaled, but
- * is added by the standard Excel autosize.
- */
- AffineTransform trans = new AffineTransform();
- trans.concatenate(AffineTransform.getRotateInstance(style.getRotation()*2.0*Math.PI/360.0));
- trans.concatenate(
- AffineTransform.getScaleInstance(1, fontHeightMultiple)
- );
- width = Math.max(width, layout.getOutline(trans).getBounds().getWidth() / defaultCharWidth);
- } else {
- width = Math.max(width, layout.getBounds().getWidth() / defaultCharWidth);
+ layout = new TextLayout(str.getIterator(), frc);
+ if(style.getRotation() != 0){
+ /*
+ * Transform the text using a scale so that it's height is increased by a multiple of the leading,
+ * and then rotate the text before computing the bounds. The scale results in some whitespace around
+ * the unrotated top and bottom of the text that normally wouldn't be present if unscaled, but
+ * is added by the standard Excel autosize.
+ */
+ AffineTransform trans = new AffineTransform();
+ trans.concatenate(AffineTransform.getRotateInstance(style.getRotation()*2.0*Math.PI/360.0));
+ trans.concatenate(
+ AffineTransform.getScaleInstance(1, fontHeightMultiple)
+ );
+ width = Math.max(width, layout.getOutline(trans).getBounds().getWidth() / defaultCharWidth);
+ } else {
+ width = Math.max(width, layout.getBounds().getWidth() / defaultCharWidth);
+ }
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org