From b1536368b94fc280c8357d2333efd74997f9c2b4 Mon Sep 17 00:00:00 2001 From: Jason Height Date: Fri, 13 Jan 2006 02:19:36 +0000 Subject: [PATCH] BUG 37056 & BUG 37058 fixed git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@368554 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/poi/hssf/model/Sheet.java | 20 +++++++++++++++++++ .../apache/poi/hssf/record/UnicodeString.java | 1 - 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/java/org/apache/poi/hssf/model/Sheet.java b/src/java/org/apache/poi/hssf/model/Sheet.java index 1c55ab50f5..d173ec4350 100644 --- a/src/java/org/apache/poi/hssf/model/Sheet.java +++ b/src/java/org/apache/poi/hssf/model/Sheet.java @@ -228,6 +228,10 @@ public class Sheet implements Model { retval.printGridlines = (PrintGridlinesRecord) rec; } + else if ( rec.getSid() == GridsetRecord.sid ) + { + retval.gridset = (GridsetRecord) rec; + } else if ( rec.getSid() == HeaderRecord.sid && bofEofNestingLevel == 1) { retval.header = (HeaderRecord) rec; @@ -1709,6 +1713,12 @@ public class Sheet implements Model public boolean isGridsPrinted() { + if (gridset == null) { + gridset = (GridsetRecord)createGridset(); + //Insert the newlycreated Gridset record at the end of the record (just before the EOF) + int loc = findFirstRecordLocBySid(EOFRecord.sid); + records.add(loc, gridset); + } return !gridset.getGridset(); } @@ -2416,8 +2426,18 @@ public class Sheet implements Model return retval; } + /** Returns the ProtectRecord. + * If one is not contained in the sheet, then one is created. + * @return + */ public ProtectRecord getProtect() { + if (protect == null) { + protect = (ProtectRecord)createProtect(); + //Insert the newlycreated protect record at the end of the record (just before the EOF) + int loc = findFirstRecordLocBySid(EOFRecord.sid); + records.add(loc, protect); + } return protect; } diff --git a/src/java/org/apache/poi/hssf/record/UnicodeString.java b/src/java/org/apache/poi/hssf/record/UnicodeString.java index 9a40687398..e9e0afd7a2 100644 --- a/src/java/org/apache/poi/hssf/record/UnicodeString.java +++ b/src/java/org/apache/poi/hssf/record/UnicodeString.java @@ -672,7 +672,6 @@ public class UnicodeString } return pos - offset; - //jmh return getRecordSize(); } -- 2.39.5