]> source.dussan.org Git - poi.git/commitdiff
Patch for unicode NameRecords (bug #43837)
authorNick Burch <nick@apache.org>
Mon, 12 Nov 2007 22:12:03 +0000 (22:12 +0000)
committerNick Burch <nick@apache.org>
Mon, 12 Nov 2007 22:12:03 +0000 (22:12 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@594316 13f79535-47bb-0310-9956-ffa450edef68

src/documentation/content/xdocs/changes.xml
src/documentation/content/xdocs/status.xml
src/java/org/apache/poi/hssf/record/NameRecord.java
src/testcases/org/apache/poi/hssf/data/unicodeNameRecord.xls [new file with mode: 0644]
src/testcases/org/apache/poi/hssf/record/TestUnicodeNameRecord.java [new file with mode: 0644]

index ca6a4752539803b6e1799daa99bbde5c29d21f50..c750d3347ab38ef47a7f2dfd528dc1ef5a0bfb43 100644 (file)
@@ -36,6 +36,7 @@
 
                <!-- Don't forget to update status.xml too! -->
         <release version="3.0.2-FINAL" date="2007-??-??">
+            <action dev="POI-DEVELOPERS" type="fix">43837 - [PATCH] Support for unicode NameRecords</action>
             <action dev="POI-DEVELOPERS" type="add">43721 - [PATCH] Support for Chart Title Format records</action>
             <action dev="POI-DEVELOPERS" type="fix">42794 - [PATCH] Fix for BOF records from things like Access</action>
             <action dev="POI-DEVELOPERS" type="fix">43648 - Fix for IntPtg and short vs int</action>
index 2b561f554934a8c353eae376be06ac5d57c2d83f..24d49e9384837db52c2f828e5ab9fc5ccadd3ee2 100644 (file)
@@ -33,6 +33,7 @@
        <!-- Don't forget to update changes.xml too! -->
     <changes>
         <release version="3.0.2-FINAL" date="2007-??-??">
+            <action dev="POI-DEVELOPERS" type="fix">43837 - [PATCH] Support for unicode NameRecords</action>
             <action dev="POI-DEVELOPERS" type="add">43721 - [PATCH] Support for Chart Title Format records</action>
             <action dev="POI-DEVELOPERS" type="fix">42794 - [PATCH] Fix for BOF records from things like Access</action>
             <action dev="POI-DEVELOPERS" type="fix">43648 - Fix for IntPtg and short vs int</action>
index c920a4afc192bf24814e1c27eb38c3a934b5a6fb..4014d7e7ed41082316a1c3afaf9a688f97e99ef0 100644 (file)
@@ -719,17 +719,17 @@ public class NameRecord extends Record {
         field_9_length_help_topic_text  = in.readByte();
         field_10_length_status_bar_text = in.readByte();
             
-                       //store the name in byte form if it's a builtin name
+        //store the name in byte form if it's a builtin name
         field_11_compressed_unicode_flag= in.readByte();        
-                       if (this.isBuiltInName()) {
-                field_12_builtIn_name = in.readByte();
+        if (this.isBuiltInName()) {
+           field_12_builtIn_name = in.readByte();
         } else {                
-          if (field_11_compressed_unicode_flag == 1) {
-            field_12_name_text = in.readCompressedUnicode(field_3_length_name_text);
-          } else {
-            field_12_name_text = in.readCompressedUnicode(field_3_length_name_text);
-          }
-                       }
+           if (field_11_compressed_unicode_flag == 1) {
+             field_12_name_text = in.readUnicodeLEString(field_3_length_name_text);
+           } else {
+             field_12_name_text = in.readCompressedUnicode(field_3_length_name_text);
+           }
+        }
             
         field_13_name_definition = Ptg.createParsedExpressionTokens(field_4_length_name_definition, in);
     
diff --git a/src/testcases/org/apache/poi/hssf/data/unicodeNameRecord.xls b/src/testcases/org/apache/poi/hssf/data/unicodeNameRecord.xls
new file mode 100644 (file)
index 0000000..d1d2460
Binary files /dev/null and b/src/testcases/org/apache/poi/hssf/data/unicodeNameRecord.xls differ
diff --git a/src/testcases/org/apache/poi/hssf/record/TestUnicodeNameRecord.java b/src/testcases/org/apache/poi/hssf/record/TestUnicodeNameRecord.java
new file mode 100644 (file)
index 0000000..2677c4c
--- /dev/null
@@ -0,0 +1,52 @@
+/* ====================================================================
+   Licensed to the Apache Software Foundation (ASF) under one or more
+   contributor license agreements.  See the NOTICE file distributed with
+   this work for additional information regarding copyright ownership.
+   The ASF licenses this file to You under the Apache License, Version 2.0
+   (the "License"); you may not use this file except in compliance with
+   the License.  You may obtain a copy of the License at
+
+       http://www.apache.org/licenses/LICENSE-2.0
+
+   Unless required by applicable law or agreed to in writing, software
+   distributed under the License is distributed on an "AS IS" BASIS,
+   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+   See the License for the specific language governing permissions and
+   limitations under the License.
+==================================================================== */
+        
+
+package org.apache.poi.hssf.record;
+
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.poifs.filesystem.POIFSFileSystem;
+
+public class TestUnicodeNameRecord extends TestCase {
+    private String _test_file_path;
+    private static final String _test_file_path_property = "HSSF.testdata.path";
+
+    public TestUnicodeNameRecord()
+    {
+        super();
+        _test_file_path = System.getProperty( _test_file_path_property ) +
+               File.separator + "unicodeNameRecord.xls";
+    }
+
+       public void testReadBook() throws IOException {
+       POIFSFileSystem fs = new POIFSFileSystem(
+                       new FileInputStream(_test_file_path)
+       );
+
+               // This bit used to crash
+       HSSFWorkbook book = new HSSFWorkbook(fs);
+       HSSFSheet sheet = book.getSheetAt(0);
+       }
+}