diff options
author | Jason Height <jheight@apache.org> | 2006-09-08 21:09:48 +0000 |
---|---|---|
committer | Jason Height <jheight@apache.org> | 2006-09-08 21:09:48 +0000 |
commit | 233ebaf41c8f93b0cb7c965947324ff85991f85d (patch) | |
tree | e5705329eb655098675d9b8dd80af14e06b1ee2c /src/java/org/apache/poi/hssf/usermodel | |
parent | a3b31fe54f0e91cfb04614601ead48116303d5bf (diff) | |
download | poi-233ebaf41c8f93b0cb7c965947324ff85991f85d.tar.gz poi-233ebaf41c8f93b0cb7c965947324ff85991f85d.zip |
BUG 27496: get/setPageBreak and get/getColumnBreak now work correctly if a template excel file is loaded which does not contain PaneRecords is loaded.
git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@441652 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/poi/hssf/usermodel')
-rw-r--r-- | src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java | 34 |
1 files changed, 21 insertions, 13 deletions
diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java index 99a2b5fef3..006d096d05 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFSheet.java @@ -1204,34 +1204,42 @@ public class HSSFSheet /** * Retrieves all the horizontal page breaks - * @return all the horizontal page breaks + * @return all the horizontal page breaks, or null if there are no row page breaks */ public int[] getRowBreaks(){ - //we can probably cache this information, but this should be a sparsely used function - int[] returnValue = new int[sheet.getNumRowBreaks()]; - Iterator iterator = sheet.getRowBreaks(); - int i = 0; - while (iterator.hasNext()) { + //we can probably cache this information, but this should be a sparsely used function + int count = sheet.getNumRowBreaks(); + if (count > 0) { + int[] returnValue = new int[count]; + Iterator iterator = sheet.getRowBreaks(); + int i = 0; + while (iterator.hasNext()) { PageBreakRecord.Break breakItem = (PageBreakRecord.Break)iterator.next(); returnValue[i++] = (int)breakItem.main; + } + return returnValue; } - return returnValue; + return null; } /** * Retrieves all the vertical page breaks - * @return all the vertical page breaks + * @return all the vertical page breaks, or null if there are no column page breaks */ public short[] getColumnBreaks(){ //we can probably cache this information, but this should be a sparsely used function - short[] returnValue = new short[sheet.getNumColumnBreaks()]; - Iterator iterator = sheet.getColumnBreaks(); - int i = 0; - while (iterator.hasNext()) { + int count = sheet.getNumColumnBreaks(); + if (count > 0) { + short[] returnValue = new short[count]; + Iterator iterator = sheet.getColumnBreaks(); + int i = 0; + while (iterator.hasNext()) { PageBreakRecord.Break breakItem = (PageBreakRecord.Break)iterator.next(); returnValue[i++] = breakItem.main; + } + return returnValue; } - return returnValue; + return null; } |