From 6b57997977e23897131d1d8d13a2129dd447fe1c Mon Sep 17 00:00:00 2001 From: Glen Stampoultzis Date: Tue, 23 Apr 2002 12:22:24 +0000 Subject: [PATCH] Bug fix for cell delete git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/branches/REL_1_5_BRANCH@352469 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/poi/hssf/record/RowRecord.java | 4 ++-- src/java/org/apache/poi/hssf/usermodel/HSSFRow.java | 6 +++--- .../org/apache/poi/hssf/usermodel/TestHSSFRow.java | 6 ++++++ .../org/apache/poi/hssf/usermodel/TestHSSFSheet.java | 2 ++ 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/java/org/apache/poi/hssf/record/RowRecord.java b/src/java/org/apache/poi/hssf/record/RowRecord.java index 65b627ea55..fc29fcbd26 100644 --- a/src/java/org/apache/poi/hssf/record/RowRecord.java +++ b/src/java/org/apache/poi/hssf/record/RowRecord.java @@ -452,8 +452,8 @@ public class RowRecord LittleEndian.putShort(data, 0 + offset, sid); LittleEndian.putShort(data, 2 + offset, ( short ) 16); LittleEndian.putShort(data, 4 + offset, getRowNumber()); - LittleEndian.putShort(data, 6 + offset, getFirstCol()); - LittleEndian.putShort(data, 8 + offset, getLastCol()); + LittleEndian.putShort(data, 6 + offset, getFirstCol() == -1 ? (short)0 : getFirstCol()); + LittleEndian.putShort(data, 8 + offset, getLastCol() == -1 ? (short)0 : getLastCol()); LittleEndian.putShort(data, 10 + offset, getHeight()); LittleEndian.putShort(data, 12 + offset, getOptimize()); LittleEndian.putShort(data, 14 + offset, field_6_reserved); diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java b/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java index 39da13e42c..e2e77dc947 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFRow.java @@ -292,8 +292,8 @@ public class HSSFRow * get the hssfcell representing a given column (logical cell) 0-based. If you * ask for a cell that is not defined....you get a null. * - * @param cellnum - 0 based column number - * @returns HSSFCell representing that column or null if undefined. + * @param cellnum 0 based column number + * @return HSSFCell representing that column or null if undefined. */ public HSSFCell getCell(short cellnum) @@ -441,7 +441,7 @@ public class HSSFRow } /** - * @returns cell iterator of the physically defined cells. Note element 4 may + * @return cell iterator of the physically defined cells. Note element 4 may * actually be row cell depending on how many are defined! */ diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRow.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRow.java index f8c584839a..fe3414d1f7 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRow.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFRow.java @@ -115,5 +115,11 @@ public class TestHSSFRow assertEquals(-1, row.getLastCellNum()); assertEquals(-1, row.getFirstCellNum()); + // check the row record actually writes it out as 0's + byte[] data = new byte[100]; + row.getRowRecord().serialize(0, data); + assertEquals(0, data[6]); + assertEquals(0, data[8]); + } } diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java index 4868aee042..7484b58024 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFSheet.java @@ -58,6 +58,7 @@ import junit.framework.TestCase; import org.apache.poi.hssf.model.Sheet; import org.apache.poi.hssf.record.VCenterRecord; import org.apache.poi.hssf.record.WSBoolRecord; +import org.apache.poi.hssf.record.RowRecord; import org.apache.poi.hssf.dev.BiffViewer; import java.io.File; @@ -193,4 +194,5 @@ public class TestHSSFSheet } + } -- 2.39.5