Fix bug #46368 - HSSFRichTextRun and strings longer than 32768 characters
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@724848 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
31f67965d0
commit
015af7c141
@ -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">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>
|
||||||
<action dev="POI-DEVELOPERS" type="fix">44914 - Fixed warning message "WARN. Unread n bytes of record 0xNN"</action>
|
<action dev="POI-DEVELOPERS" type="fix">44914 - Fixed warning message "WARN. Unread n bytes of record 0xNN"</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">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>
|
||||||
<action dev="POI-DEVELOPERS" type="fix">44914 - Fixed warning message "WARN. Unread n bytes of record 0xNN"</action>
|
<action dev="POI-DEVELOPERS" type="fix">44914 - Fixed warning message "WARN. Unread n bytes of record 0xNN"</action>
|
||||||
|
@ -202,9 +202,9 @@ public final class UnicodeString implements Comparable {
|
|||||||
|
|
||||||
boolean isCompressed = ((field_2_optionflags & 1) == 0);
|
boolean isCompressed = ((field_2_optionflags & 1) == 0);
|
||||||
if (isCompressed) {
|
if (isCompressed) {
|
||||||
field_3_string = in.readCompressedUnicode(field_1_charCount);
|
field_3_string = in.readCompressedUnicode(getCharCount());
|
||||||
} else {
|
} else {
|
||||||
field_3_string = in.readUnicodeLEString(field_1_charCount);
|
field_3_string = in.readUnicodeLEString(getCharCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -226,15 +226,25 @@ public final class UnicodeString implements Comparable {
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get the number of characters in the string
|
* get the number of characters in the string,
|
||||||
*
|
* as an un-wrapped int
|
||||||
*
|
*
|
||||||
* @return number of characters
|
* @return number of characters
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
public int getCharCount() {
|
||||||
|
if(field_1_charCount < 0) {
|
||||||
|
return field_1_charCount + 65536;
|
||||||
|
}
|
||||||
|
return field_1_charCount;
|
||||||
|
}
|
||||||
|
|
||||||
public short getCharCount()
|
/**
|
||||||
{
|
* get the number of characters in the string,
|
||||||
|
* wrapped as needed to fit within a short
|
||||||
|
*
|
||||||
|
* @return number of characters
|
||||||
|
*/
|
||||||
|
public short getCharCountShort() {
|
||||||
return field_1_charCount;
|
return field_1_charCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -198,8 +198,7 @@ public class HSSFRichTextString
|
|||||||
/**
|
/**
|
||||||
* @return the number of characters in the text.
|
* @return the number of characters in the text.
|
||||||
*/
|
*/
|
||||||
public int length()
|
public int length() {
|
||||||
{
|
|
||||||
return string.getCharCount();
|
return string.getCharCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,9 @@ import org.apache.poi.hssf.record.NameRecord;
|
|||||||
import org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate;
|
import org.apache.poi.hssf.record.aggregates.FormulaRecordAggregate;
|
||||||
import org.apache.poi.hssf.record.formula.DeletedArea3DPtg;
|
import org.apache.poi.hssf.record.formula.DeletedArea3DPtg;
|
||||||
import org.apache.poi.hssf.record.formula.Ptg;
|
import org.apache.poi.hssf.record.formula.Ptg;
|
||||||
|
import org.apache.poi.ss.usermodel.Cell;
|
||||||
|
import org.apache.poi.ss.usermodel.RichTextString;
|
||||||
|
import org.apache.poi.ss.usermodel.Row;
|
||||||
import org.apache.poi.ss.util.CellRangeAddress;
|
import org.apache.poi.ss.util.CellRangeAddress;
|
||||||
import org.apache.poi.util.TempFile;
|
import org.apache.poi.util.TempFile;
|
||||||
|
|
||||||
@ -1540,4 +1543,36 @@ public final class TestBugs extends TestCase {
|
|||||||
HSSFWorkbook wb = openSample("45290.xls");
|
HSSFWorkbook wb = openSample("45290.xls");
|
||||||
assertEquals(1, wb.getNumberOfSheets());
|
assertEquals(1, wb.getNumberOfSheets());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* HSSFRichTextString.length() returns negative for really
|
||||||
|
* long strings
|
||||||
|
*/
|
||||||
|
public void test46368() {
|
||||||
|
HSSFWorkbook wb = new HSSFWorkbook();
|
||||||
|
HSSFSheet s = wb.createSheet();
|
||||||
|
HSSFRow r = s.createRow(0);
|
||||||
|
for(int i=0; i<15; i++) {
|
||||||
|
int len = 32760 + i;
|
||||||
|
HSSFCell c = r.createCell(i);
|
||||||
|
|
||||||
|
StringBuffer sb = new StringBuffer();
|
||||||
|
for(int j=0; j<len; j++) {
|
||||||
|
sb.append("x");
|
||||||
|
}
|
||||||
|
HSSFRichTextString rtr = new HSSFRichTextString(sb.toString());
|
||||||
|
assertEquals(len, rtr.length());
|
||||||
|
c.setCellValue(rtr);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save and reload
|
||||||
|
wb = writeOutAndReadBack(wb);
|
||||||
|
s = wb.getSheetAt(0);
|
||||||
|
r = s.getRow(0);
|
||||||
|
for(int i=0; i<15; i++) {
|
||||||
|
int len = 32760 + i;
|
||||||
|
HSSFCell c = r.getCell(i);
|
||||||
|
assertEquals(len, c.getRichStringCellValue().length());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user