add a check to prevent NPE in HSSFSheet.autoSizeColumn(). See Bug 44246
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@613396 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
47f369643a
commit
f6cd038ce3
@ -1748,27 +1748,28 @@ public class HSSFSheet
|
|||||||
} else if (cell.getCellType() == HSSFCell.CELL_TYPE_BOOLEAN) {
|
} else if (cell.getCellType() == HSSFCell.CELL_TYPE_BOOLEAN) {
|
||||||
sval = String.valueOf(cell.getBooleanCellValue());
|
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;
|
layout = new TextLayout(str.getIterator(), frc);
|
||||||
str = new AttributedString(txt);
|
if(style.getRotation() != 0){
|
||||||
copyAttributes(font, str, 0, txt.length());
|
/*
|
||||||
|
* Transform the text using a scale so that it's height is increased by a multiple of the leading,
|
||||||
layout = new TextLayout(str.getIterator(), frc);
|
* and then rotate the text before computing the bounds. The scale results in some whitespace around
|
||||||
if(style.getRotation() != 0){
|
* the unrotated top and bottom of the text that normally wouldn't be present if unscaled, but
|
||||||
/*
|
* is added by the standard Excel autosize.
|
||||||
* 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
|
AffineTransform trans = new AffineTransform();
|
||||||
* the unrotated top and bottom of the text that normally wouldn't be present if unscaled, but
|
trans.concatenate(AffineTransform.getRotateInstance(style.getRotation()*2.0*Math.PI/360.0));
|
||||||
* is added by the standard Excel autosize.
|
trans.concatenate(
|
||||||
*/
|
AffineTransform.getScaleInstance(1, fontHeightMultiple)
|
||||||
AffineTransform trans = new AffineTransform();
|
);
|
||||||
trans.concatenate(AffineTransform.getRotateInstance(style.getRotation()*2.0*Math.PI/360.0));
|
width = Math.max(width, layout.getOutline(trans).getBounds().getWidth() / defaultCharWidth);
|
||||||
trans.concatenate(
|
} else {
|
||||||
AffineTransform.getScaleInstance(1, fontHeightMultiple)
|
width = Math.max(width, layout.getBounds().getWidth() / defaultCharWidth);
|
||||||
);
|
}
|
||||||
width = Math.max(width, layout.getOutline(trans).getBounds().getWidth() / defaultCharWidth);
|
|
||||||
} else {
|
|
||||||
width = Math.max(width, layout.getBounds().getWidth() / defaultCharWidth);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user