String Continue records support (with test), from bug #41064
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@600995 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
44741d2ce1
commit
941bba0e15
@ -36,6 +36,7 @@
|
|||||||
|
|
||||||
<!-- Don't forget to update status.xml too! -->
|
<!-- Don't forget to update status.xml too! -->
|
||||||
<release version="3.0.2-FINAL" date="2007-??-??">
|
<release version="3.0.2-FINAL" date="2007-??-??">
|
||||||
|
<action dev="POI-DEVELOPERS" type="add">41064 - [PATCH] Support for String continue records</action>
|
||||||
<action dev="POI-DEVELOPERS" type="add">27511 - [PATCH] Support for data validation, via DVRecord and DVALRecord</action>
|
<action dev="POI-DEVELOPERS" type="add">27511 - [PATCH] Support for data validation, via DVRecord and DVALRecord</action>
|
||||||
<action dev="POI-DEVELOPERS" type="fix">43877 and 39512 - Fix for handling mixed OBJ and CONTINUE records.</action>
|
<action dev="POI-DEVELOPERS" type="fix">43877 and 39512 - Fix for handling mixed OBJ and CONTINUE records.</action>
|
||||||
<action dev="POI-DEVELOPERS" type="fix">43807 - Throw an IllegalArgumentException if asked to create a merged region with invalid columns or rows, rather than writing out a corrupt file</action>
|
<action dev="POI-DEVELOPERS" type="fix">43807 - Throw an IllegalArgumentException if asked to create a merged region with invalid columns or rows, rather than writing out a corrupt file</action>
|
||||||
|
@ -33,6 +33,7 @@
|
|||||||
<!-- Don't forget to update changes.xml too! -->
|
<!-- Don't forget to update changes.xml too! -->
|
||||||
<changes>
|
<changes>
|
||||||
<release version="3.0.2-FINAL" date="2007-??-??">
|
<release version="3.0.2-FINAL" date="2007-??-??">
|
||||||
|
<action dev="POI-DEVELOPERS" type="add">41064 - [PATCH] Support for String continue records</action>
|
||||||
<action dev="POI-DEVELOPERS" type="add">27511 - [PATCH] Support for data validation, via DVRecord and DVALRecord</action>
|
<action dev="POI-DEVELOPERS" type="add">27511 - [PATCH] Support for data validation, via DVRecord and DVALRecord</action>
|
||||||
<action dev="POI-DEVELOPERS" type="fix">43877 - Fix for handling mixed OBJ and CONTINUE records</action>
|
<action dev="POI-DEVELOPERS" type="fix">43877 - Fix for handling mixed OBJ and CONTINUE records</action>
|
||||||
<action dev="POI-DEVELOPERS" type="fix">39512 - Fix for handling mixed OBJ and CONTINUE records</action>
|
<action dev="POI-DEVELOPERS" type="fix">39512 - Fix for handling mixed OBJ and CONTINUE records</action>
|
||||||
|
@ -147,6 +147,9 @@ public class RecordFactory
|
|||||||
} else if (record.getSid() == ContinueRecord.sid &&
|
} else if (record.getSid() == ContinueRecord.sid &&
|
||||||
(lastRecord instanceof DrawingGroupRecord)) {
|
(lastRecord instanceof DrawingGroupRecord)) {
|
||||||
((DrawingGroupRecord)lastRecord).processContinueRecord(((ContinueRecord)record).getData());
|
((DrawingGroupRecord)lastRecord).processContinueRecord(((ContinueRecord)record).getData());
|
||||||
|
} else if (record.getSid() == ContinueRecord.sid &&
|
||||||
|
(lastRecord instanceof StringRecord)) {
|
||||||
|
((StringRecord)lastRecord).processContinueRecord(((ContinueRecord)record).getData());
|
||||||
} else if (record.getSid() == ContinueRecord.sid) {
|
} else if (record.getSid() == ContinueRecord.sid) {
|
||||||
if (lastRecord instanceof UnknownRecord) {
|
if (lastRecord instanceof UnknownRecord) {
|
||||||
//Gracefully handle records that we dont know about,
|
//Gracefully handle records that we dont know about,
|
||||||
|
@ -84,6 +84,14 @@ public class StringRecord
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void processContinueRecord(byte[] data) {
|
||||||
|
if(isUnCompressedUnicode()) {
|
||||||
|
field_3_string += StringUtil.getFromUnicodeLE(data, 0, field_1_string_length - field_3_string.length());
|
||||||
|
} else {
|
||||||
|
field_3_string += StringUtil.getFromCompressedUnicode(data, 0, field_1_string_length - field_3_string.length());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isInValueSection()
|
public boolean isInValueSection()
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
|
@ -161,7 +161,8 @@ public class StringUtil {
|
|||||||
final int offset,
|
final int offset,
|
||||||
final int len) {
|
final int len) {
|
||||||
try {
|
try {
|
||||||
return new String(string, offset, len, "ISO-8859-1");
|
int len_to_use = Math.min(len, string.length - offset);
|
||||||
|
return new String(string, offset, len_to_use, "ISO-8859-1");
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
throw new InternalError(); /* unreachable */
|
throw new InternalError(); /* unreachable */
|
||||||
}
|
}
|
||||||
|
BIN
src/testcases/org/apache/poi/hssf/data/StringContinueRecords.xls
Normal file
BIN
src/testcases/org/apache/poi/hssf/data/StringContinueRecords.xls
Normal file
Binary file not shown.
@ -68,6 +68,19 @@ public class TestExcelExtractor extends TestCase {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void testwithContinueRecords() throws Exception {
|
||||||
|
String path = System.getProperty("HSSF.testdata.path");
|
||||||
|
FileInputStream fin = new FileInputStream(path + File.separator + "StringContinueRecords.xls");
|
||||||
|
|
||||||
|
ExcelExtractor extractor = new ExcelExtractor(new POIFSFileSystem(fin));
|
||||||
|
|
||||||
|
extractor.getText();
|
||||||
|
|
||||||
|
// Has masses of text
|
||||||
|
// Until we fixed bug #41064, this would've
|
||||||
|
// failed by now
|
||||||
|
assertTrue(extractor.getText().length() > 40960);
|
||||||
|
}
|
||||||
|
|
||||||
public void testStringConcat() throws Exception {
|
public void testStringConcat() throws Exception {
|
||||||
String path = System.getProperty("HSSF.testdata.path");
|
String path = System.getProperty("HSSF.testdata.path");
|
||||||
|
Loading…
Reference in New Issue
Block a user