diff options
author | Andreas Beeker <kiwiwings@apache.org> | 2018-05-21 23:17:57 +0000 |
---|---|---|
committer | Andreas Beeker <kiwiwings@apache.org> | 2018-05-21 23:17:57 +0000 |
commit | d136eaa77889159fb88f9761aaeb469f45398735 (patch) | |
tree | e38fdacaad77cdeff6429952df80bee23d97c3d9 /src/examples | |
parent | d3fbc56fd0eca832545e4dc923d40a85aa97937b (diff) | |
download | poi-d136eaa77889159fb88f9761aaeb469f45398735.tar.gz poi-d136eaa77889159fb88f9761aaeb469f45398735.zip |
sonar fixes - null dereference
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1831992 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/examples')
-rw-r--r-- | src/examples/src/org/apache/poi/hssf/usermodel/examples/AddDimensionedImage.java | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/AddDimensionedImage.java b/src/examples/src/org/apache/poi/hssf/usermodel/examples/AddDimensionedImage.java index 61629d5c44..bee33a250d 100644 --- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/AddDimensionedImage.java +++ b/src/examples/src/org/apache/poi/hssf/usermodel/examples/AddDimensionedImage.java @@ -279,14 +279,19 @@ public class AddDimensionedImage { // The first two parameters are not used currently but could be if the // need arose to extend the functionality of this code by adding the // ability to specify that a clear 'border' be placed around the image. - anchor = new HSSFClientAnchor(0, - 0, - colClientAnchorDetail.getInset(), - rowClientAnchorDetail.getInset(), - (short)colClientAnchorDetail.getFromIndex(), - rowClientAnchorDetail.getFromIndex(), - (short)colClientAnchorDetail.getToIndex(), - rowClientAnchorDetail.getToIndex()); + int dx1 = 0, dy1 = 0, dx2 = 0, dy2 = 0; + short col1 = 0, col2 = 0, row1 = 0, row2 = 0; + if (colClientAnchorDetail != null) { + dx2 = colClientAnchorDetail.getInset(); + col1 = (short)colClientAnchorDetail.getFromIndex(); + col2 = (short)colClientAnchorDetail.getToIndex(); + } + if (rowClientAnchorDetail != null) { + dy2 = rowClientAnchorDetail.getInset(); + row1 = (short)rowClientAnchorDetail.getFromIndex(); + row2 = (short)rowClientAnchorDetail.getToIndex(); + } + anchor = new HSSFClientAnchor(dx1, dy1, dx2, dy2, col1, row1, col2, row2); // For now, set the anchor type to do not move or resize the // image as the size of the row/column is adjusted. This could easilly |