From 2014f3b06a5027126a9c1307620fee5425398567 Mon Sep 17 00:00:00 2001 From: Glen Stampoultzis Date: Sun, 27 Jun 2004 11:08:02 +0000 Subject: [PATCH] Fix for bug 29747 git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/branches/REL_2_BRANCH@353564 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/poi/hssf/record/NameRecord.java | 3 ++- .../poi/hssf/usermodel/HSSFWorkbook.java | 2 +- .../apache/poi/hssf/usermodel/TestBugs.java | 7 ++----- .../poi/hssf/usermodel/TestHSSFWorkbook.java | 21 +++++++++++++++++++ 4 files changed, 26 insertions(+), 7 deletions(-) create mode 100644 src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java diff --git a/src/java/org/apache/poi/hssf/record/NameRecord.java b/src/java/org/apache/poi/hssf/record/NameRecord.java index 5494362aec..a1b9adf437 100644 --- a/src/java/org/apache/poi/hssf/record/NameRecord.java +++ b/src/java/org/apache/poi/hssf/record/NameRecord.java @@ -924,7 +924,8 @@ public class NameRecord extends Record { .append("\n"); buffer.append(" .Status bar text (Unicode string without length field) = ").append( field_17_status_bar_text ) .append("\n"); - buffer.append(org.apache.poi.util.HexDump.dump(this.field_13_raw_name_definition,0,0)); + if (field_13_raw_name_definition != null) + buffer.append(org.apache.poi.util.HexDump.dump(this.field_13_raw_name_definition,0,0)); buffer.append("[/NAME]\n"); return buffer.toString(); diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java b/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java index 372058ebde..3a40962f0d 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java @@ -515,7 +515,7 @@ public class HSSFWorkbook } if ( nameRecord == null ) { - nameRecord = workbook.createBuiltInName(NameRecord.BUILTIN_PRINT_TITLE, externSheetIndex+1); + nameRecord = workbook.createBuiltInName(NameRecord.BUILTIN_PRINT_TITLE, sheetIndex+1); //does a lot of the house keeping for builtin records, like setting lengths to zero etc isNewRecord = true; } diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java index 2f354c1be6..493721190b 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java @@ -18,11 +18,7 @@ package org.apache.poi.hssf.usermodel; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; +import java.io.*; import junit.framework.TestCase; @@ -458,6 +454,7 @@ extends TestCase { assertEquals("Re-Written Formula String Cell value", d1.getStringCellValue(), rd2.getStringCellValue()); } + } diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java new file mode 100644 index 0000000000..232916f8d5 --- /dev/null +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestHSSFWorkbook.java @@ -0,0 +1,21 @@ +package org.apache.poi.hssf.usermodel; + +import junit.framework.*; +import org.apache.poi.hssf.record.NameRecord; + +public class TestHSSFWorkbook extends TestCase +{ + HSSFWorkbook hssfWorkbook; + + public void testSetRepeatingRowsAndColumns() throws Exception + { + // Test bug 29747 + HSSFWorkbook b = new HSSFWorkbook( ); + b.createSheet(); + b.createSheet(); + b.createSheet(); + b.setRepeatingRowsAndColumns( 2, 0,1,-1,-1 ); + NameRecord nameRecord = b.getWorkbook().getNameRecord( 0 ); + assertEquals( 3, nameRecord.getIndexToSheet() ); + } +} \ No newline at end of file -- 2.39.5