From 5ceb0327e5dd533a7cf9125f374e7391f9f3229e Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Sun, 21 Sep 2008 17:49:20 +0000 Subject: [PATCH] Fix bug #45784 - Support long chart titles in SeriesTextRecords git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@697562 13f79535-47bb-0310-9956-ffa450edef68 --- src/documentation/content/xdocs/changes.xml | 1 + src/documentation/content/xdocs/status.xml | 1 + .../poi/hssf/record/SeriesTextRecord.java | 23 +++++++++++++++--- .../org/apache/poi/hssf/data/45784.xls | Bin 0 -> 13824 bytes .../apache/poi/hssf/usermodel/TestBugs.java | 10 ++++++++ 5 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 src/testcases/org/apache/poi/hssf/data/45784.xls diff --git a/src/documentation/content/xdocs/changes.xml b/src/documentation/content/xdocs/changes.xml index eb5ae733f..815bbb095 100644 --- a/src/documentation/content/xdocs/changes.xml +++ b/src/documentation/content/xdocs/changes.xml @@ -37,6 +37,7 @@ + 45784 - Support long chart titles in SeriesTextRecords 45777 - Throw an exception if HSSF Footer or Header is attemped to be set too long, rather than having it break during writing out 45844 - Addtional diagnostics for HSLF SlideShowRecordDumper 45829 - HSSFPicture.getImageDimension() failed when DPI of image is zero diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 1718ff841..338849914 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,7 @@ + 45784 - Support long chart titles in SeriesTextRecords 45777 - Throw an exception if HSSF Footer or Header is attemped to be set too long, rather than having it break during writing out 45844 - Addtional diagnostics for HSLF SlideShowRecordDumper 45829 - HSSFPicture.getImageDimension() failed when DPI of image is zero diff --git a/src/java/org/apache/poi/hssf/record/SeriesTextRecord.java b/src/java/org/apache/poi/hssf/record/SeriesTextRecord.java index 1271ef876..66c26b321 100644 --- a/src/java/org/apache/poi/hssf/record/SeriesTextRecord.java +++ b/src/java/org/apache/poi/hssf/record/SeriesTextRecord.java @@ -75,7 +75,8 @@ public class SeriesTextRecord field_1_id = in.readShort(); field_2_textLength = in.readByte(); field_3_undocumented = in.readByte(); - field_4_text = in.readUnicodeLEString(field_2_textLength); + field_4_text = in.readUnicodeLEString( + LittleEndian.ubyteToInt(field_2_textLength)); } public String toString() @@ -163,18 +164,34 @@ public class SeriesTextRecord /** * Get the text length field for the SeriesText record. */ - public byte getTextLength() + public int getTextLength() { - return field_2_textLength; + return LittleEndian.ubyteToInt(field_2_textLength); } /** * Set the text length field for the SeriesText record. + * Needs to be wrapped. */ public void setTextLength(byte field_2_textLength) { this.field_2_textLength = field_2_textLength; } + /** + * Set the text length field for the SeriesText record. + */ + public void setTextLength(int field_2_textLength) + { + if(field_2_textLength > 255) { + throw new IllegalArgumentException("Length must be 0-255"); + } + if(field_2_textLength > 127) { + this.field_2_textLength = (byte) + (field_2_textLength-256); + } else { + this.field_2_textLength = (byte)field_2_textLength; + } + } /** * Get the undocumented field for the SeriesText record. diff --git a/src/testcases/org/apache/poi/hssf/data/45784.xls b/src/testcases/org/apache/poi/hssf/data/45784.xls new file mode 100644 index 0000000000000000000000000000000000000000..f0d25fddfbd9570fd2b38c64f82da7ed724c869a GIT binary patch literal 13824 zcmeHOYiv|S6h8OvqucW6EtDb@+RL^;U(}X&Y@mx$l!QV75uzn6w2NSYnr$VJn6TyX z4-*v={Xr0n{xBvyVxnSD3h@Ud5)F|UOf+EpC&tBSlmuA6@7%rYZlQ=q62v<<^Ez|p z%$aY_ow+kR`{fq}7Y`mCdr1bkx#E)>$y^C$&<&)=xOq!Zo=h_9#t$J4lIQ+I2;_z^ zkimeQD?OWYrXNY4$R#o5i2o!)k?-MK<#_?uqBR?0o%Xz1`^ngbO=~ws?R)7SRUOtC z)S(}SHwP(0_JKMaHc09S4M%EtSow}?I0q%;jRvE*ZbjK_@CoXzG9$|Ol7?Xoha)uP zL#^|TQtD-_oCbe#`^z+Sk<|fXp2TE>tdWg!Z%YrLxqH)Y0=-ObKTgO7^r*x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