From 33903d5df35375d76beb98cddd0f715a8fcfc388 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Mon, 12 Nov 2007 22:12:03 +0000 Subject: [PATCH] Patch for unicode NameRecords (bug #43837) git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@594316 13f79535-47bb-0310-9956-ffa450edef68 --- src/documentation/content/xdocs/changes.xml | 1 + src/documentation/content/xdocs/status.xml | 1 + .../apache/poi/hssf/record/NameRecord.java | 18 +++--- .../poi/hssf/data/unicodeNameRecord.xls | Bin 0 -> 13824 bytes .../hssf/record/TestUnicodeNameRecord.java | 52 ++++++++++++++++++ 5 files changed, 63 insertions(+), 9 deletions(-) create mode 100644 src/testcases/org/apache/poi/hssf/data/unicodeNameRecord.xls create mode 100644 src/testcases/org/apache/poi/hssf/record/TestUnicodeNameRecord.java diff --git a/src/documentation/content/xdocs/changes.xml b/src/documentation/content/xdocs/changes.xml index ca6a475253..c750d3347a 100644 --- a/src/documentation/content/xdocs/changes.xml +++ b/src/documentation/content/xdocs/changes.xml @@ -36,6 +36,7 @@ + 43837 - [PATCH] Support for unicode NameRecords 43721 - [PATCH] Support for Chart Title Format records 42794 - [PATCH] Fix for BOF records from things like Access 43648 - Fix for IntPtg and short vs int diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 2b561f5549..24d49e9384 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -33,6 +33,7 @@ + 43837 - [PATCH] Support for unicode NameRecords 43721 - [PATCH] Support for Chart Title Format records 42794 - [PATCH] Fix for BOF records from things like Access 43648 - Fix for IntPtg and short vs int diff --git a/src/java/org/apache/poi/hssf/record/NameRecord.java b/src/java/org/apache/poi/hssf/record/NameRecord.java index c920a4afc1..4014d7e7ed 100644 --- a/src/java/org/apache/poi/hssf/record/NameRecord.java +++ b/src/java/org/apache/poi/hssf/record/NameRecord.java @@ -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 index 0000000000000000000000000000000000000000..d1d246062c1475cca49e8682c66a8de630ae9497 GIT binary patch literal 13824 zcmeHOU2IfE6h5=P+ipv3w*{dVS+85r(jT(WsKg3g2_QTG1q2al%2En#_^E-CU^Kd= zkQf6I(f}{0!SEm<0aPLn5-s8bCK8PaF%ln&i7#m4Vl;{Y*6*9Uw|jTXLj4P1W^U&1 zoHH|LzL`67&)j>z{Gx2&;JcLSkyi zVv0KSW8zIy`JzC}lLH7#Fb~No*WpMV9@Da?bT|#1goNZweb4x*kQ0<$=8I~%T{;Zw zumqu!le)|WO_?mVd<*&HE4w+}^WqXv^~r{$Es^Aj$jQi=$g#+sD6{pJI#r=&}|r9(QUO+r?M_+_L>xFuXwS5*~hM53i$CqvdatO>Z&2YD+NwXc58 zD-egXav`fq0vMbOiL6?**ke*7Q$$*AR8?c^=3DK?R5qngnh>rJ>rAxO z4q20AA}$p5maDP7g=*}K5=~Mkk7qUpCDPTWie}JIK~qz@(MP3LCVLunWe3|$6S7KH z${4v9H`;iolM@?Ts#EEfi6QF&;9cqEYOpdyY#=^%P=xJx>Ohv&Oh6@emP}?%T5v!{ zVV;Qmn#9U5==yEac}r;eFD~Qebl#&klFvnFtv8bYKhu>A#n~@~4i3Mw=X4Ivet9Sd zy*dXyKLOd;j)2oI%Ur&zKO*HL9*MOW4sEC`%ibQSU-qXJ!kDUn$l*Upb^Xm8{) z4sl!+oXJ?8(?aU|_PVuizLt_9^Rx=Ui#)wc$q%xeTUcTd8IqsC0w!SVC7+X#jniB3 z4KgB8j`(9J6_6hFq)4D&MG;0NbeV&757Nc(W8i-i30{>$kVFPviA9l^l43ye2$GIN z?WoM z0Mwg!e28xK6|&ddEQ=AY29`{hY5any^XlQtU(H+9+|;V+HJVWC`BJC<`|b^!*p}x(UHgcOEC}J9C@UX$977w zSGqa!Nc$QX_alBn?$_6k(#%qcIiLaSgfq)9`JoO`=%%LcBiEqm#WO^=>m{~UT33eqG;%yyo**E z`r*P5!)<;0V4(JH_ucqkhrt7xNg4zU0{;+!>o~#j>nFL)ins_3?0DDo?90AQFv~N+?cp2t%T=;6KzpGVC;s+qY^B3p*1P*z;jDDgk28ipMLJm zI#jqNeO_nVrmoFhYr5@OTie>#YaQZmEIoW7cveMGXT0FkITONX6*p4j3<3rLgMdN6 zAYc$M2p9wm0tNwtfI+|@U=VN+xS9R$JAdx{fk|V7efwem*IhYE`#%W7AMXOR{ojn3 zN8QWd@hSwb1w{BlW<7imz8ju)|4Z0hZCuHNSfUD$G#VLUXo&zXPZ2WpkBSN_pIoh-@6py zTCD^Xahdy0?OCw5d)tv$FYVv2nbh1kgMdN6AYc$M2p9wm0tNwtfI+|@U=T0}+#Lw; zJw7d2n!2=wX;1UJFxu4ouYuA4+b=WGLYvm1U5~(D(`V}6=)dlIs{eliZcflE literal 0 HcmV?d00001 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 index 0000000000..2677c4c42e --- /dev/null +++ b/src/testcases/org/apache/poi/hssf/record/TestUnicodeNameRecord.java @@ -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); + } +} -- 2.39.5