Fix for bug 46385 (by patch 46362 from Matsuyama Tomohiro) fixed serialization of StyleRecord with unicode name
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@726969 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
13860fc475
commit
60afb94fdb
@ -37,6 +37,7 @@
|
|||||||
|
|
||||||
<!-- Don't forget to update status.xml too! -->
|
<!-- Don't forget to update status.xml too! -->
|
||||||
<release version="3.5-beta5" date="2008-??-??">
|
<release version="3.5-beta5" date="2008-??-??">
|
||||||
|
<action dev="POI-DEVELOPERS" type="fix">46385 - (also patch 46362) fix serialization of StyleRecord with unicode name</action>
|
||||||
<action dev="POI-DEVELOPERS" type="fix">46368 - Fix HSSFRichTextRun and strings longer than 32768 characters</action>
|
<action dev="POI-DEVELOPERS" type="fix">46368 - Fix HSSFRichTextRun and strings longer than 32768 characters</action>
|
||||||
<action dev="POI-DEVELOPERS" type="add">Support sheet-level names</action>
|
<action dev="POI-DEVELOPERS" type="add">Support sheet-level names</action>
|
||||||
<action dev="POI-DEVELOPERS" type="fix">Fixed XSSFCell to properly handle cell references with column numbers up to XFD</action>
|
<action dev="POI-DEVELOPERS" type="fix">Fixed XSSFCell to properly handle cell references with column numbers up to XFD</action>
|
||||||
|
@ -34,6 +34,7 @@
|
|||||||
<!-- Don't forget to update changes.xml too! -->
|
<!-- Don't forget to update changes.xml too! -->
|
||||||
<changes>
|
<changes>
|
||||||
<release version="3.5-beta5" date="2008-??-??">
|
<release version="3.5-beta5" date="2008-??-??">
|
||||||
|
<action dev="POI-DEVELOPERS" type="fix">46385 - (also patch 46362) fix serialization of StyleRecord with unicode name</action>
|
||||||
<action dev="POI-DEVELOPERS" type="fix">46368 - Fix HSSFRichTextRun and strings longer than 32768 characters</action>
|
<action dev="POI-DEVELOPERS" type="fix">46368 - Fix HSSFRichTextRun and strings longer than 32768 characters</action>
|
||||||
<action dev="POI-DEVELOPERS" type="add">Support sheet-level names</action>
|
<action dev="POI-DEVELOPERS" type="add">Support sheet-level names</action>
|
||||||
<action dev="POI-DEVELOPERS" type="fix">Fixed XSSFCell to properly handle cell references with column numbers up to XFD</action>
|
<action dev="POI-DEVELOPERS" type="fix">Fixed XSSFCell to properly handle cell references with column numbers up to XFD</action>
|
||||||
|
@ -40,7 +40,8 @@ public abstract class StandardRecord extends Record {
|
|||||||
out.writeShort(dataSize);
|
out.writeShort(dataSize);
|
||||||
serialize(out);
|
serialize(out);
|
||||||
if (out.getWriteIndex() - offset != recSize) {
|
if (out.getWriteIndex() - offset != recSize) {
|
||||||
throw new IllegalStateException("Incorrect number of bytes written - expected "
|
throw new IllegalStateException("Error in serialization of (" + getClass().getName() + "): "
|
||||||
|
+ "Incorrect number of bytes written - expected "
|
||||||
+ recSize + " but got " + (out.getWriteIndex() - offset));
|
+ recSize + " but got " + (out.getWriteIndex() - offset));
|
||||||
}
|
}
|
||||||
return recSize;
|
return recSize;
|
||||||
|
@ -173,9 +173,13 @@ public final class StyleRecord extends StandardRecord {
|
|||||||
} else {
|
} else {
|
||||||
out.writeShort(field_4_name.length());
|
out.writeShort(field_4_name.length());
|
||||||
out.writeByte(field_3_stringHasMultibyte ? 0x01 : 0x00);
|
out.writeByte(field_3_stringHasMultibyte ? 0x01 : 0x00);
|
||||||
|
if (field_3_stringHasMultibyte) {
|
||||||
|
StringUtil.putUnicodeLE(getName(), out);
|
||||||
|
} else {
|
||||||
StringUtil.putCompressedUnicode(getName(), out);
|
StringUtil.putCompressedUnicode(getName(), out);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public short getSid() {
|
public short getSid() {
|
||||||
return sid;
|
return sid;
|
||||||
|
@ -17,17 +17,30 @@
|
|||||||
|
|
||||||
package org.apache.poi.hssf.record;
|
package org.apache.poi.hssf.record;
|
||||||
|
|
||||||
|
import junit.framework.AssertionFailedError;
|
||||||
import junit.framework.TestCase;
|
import junit.framework.TestCase;
|
||||||
|
|
||||||
|
import org.apache.poi.util.HexRead;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* Tests for {@link StyleRecord}
|
||||||
*/
|
*/
|
||||||
public final class TestStyleRecord extends TestCase {
|
public final class TestStyleRecord extends TestCase {
|
||||||
public void testUnicodeReadName() {
|
public void testUnicodeReadName() {
|
||||||
byte[] data = {
|
byte[] data = HexRead.readFromString(
|
||||||
17, 0, 9, 0, 1, 56, 94, -60, -119, 95, 0, 83, 0, 104, 0, 101, 0, 101, 0, 116, 0, 49, 0, 92, 40, //92, 36
|
"11 00 09 00 01 38 5E C4 89 5F 00 53 00 68 00 65 00 65 00 74 00 31 00");
|
||||||
};
|
|
||||||
RecordInputStream in = TestcaseRecordInputStream.create(StyleRecord.sid, data);
|
RecordInputStream in = TestcaseRecordInputStream.create(StyleRecord.sid, data);
|
||||||
StyleRecord sr = new StyleRecord(in);
|
StyleRecord sr = new StyleRecord(in);
|
||||||
assertEquals("\u5E38\u89C4_Sheet1", sr.getName()); // "<Conventional>_Sheet1"
|
assertEquals("\u5E38\u89C4_Sheet1", sr.getName()); // "<Conventional>_Sheet1"
|
||||||
|
byte[] ser;
|
||||||
|
try {
|
||||||
|
ser = sr.serialize();
|
||||||
|
} catch (IllegalStateException e) {
|
||||||
|
if (e.getMessage().equals("Incorrect number of bytes written - expected 27 but got 18")) {
|
||||||
|
throw new AssertionFailedError("Identified bug 46385");
|
||||||
|
}
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
TestcaseRecordInputStream.confirmRecordEncoding(StyleRecord.sid, data, ser);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user