From fcb41adacd3a95c25e3d4008b40d53f698b91ef1 Mon Sep 17 00:00:00 2001 From: Maxim Valyanskiy Date: Mon, 19 Sep 2011 12:06:58 +0000 Subject: [PATCH] HSLF: support for uncompressed OLE embeddings git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1172583 13f79535-47bb-0310-9956-ffa450edef68 --- src/documentation/content/xdocs/status.xml | 1 + .../apache/poi/hslf/record/ExOleObjStg.java | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 69291355a9..bfcdf5aa45 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -47,6 +47,7 @@ XSLFPowerPointExtractor support for including comment authors with comment text Converted XSLFPowerPointExtractor to use UserModel for all text extraction XSLF initial UserModel support for Notes and Comments for Slides + HSLF: support for uncompressed OLE embeddings 51678 - Extracting text from Bug51524.zip is slow diff --git a/src/scratchpad/src/org/apache/poi/hslf/record/ExOleObjStg.java b/src/scratchpad/src/org/apache/poi/hslf/record/ExOleObjStg.java index 4fee85ead1..7e6a7593ba 100644 --- a/src/scratchpad/src/org/apache/poi/hslf/record/ExOleObjStg.java +++ b/src/scratchpad/src/org/apache/poi/hslf/record/ExOleObjStg.java @@ -73,13 +73,21 @@ public class ExOleObjStg extends RecordAtom implements PositionDependentRecord, System.arraycopy(source,start+8,_data,0,len-8); } + public boolean isCompressed() { + return LittleEndian.getShort(_header, 0)!=0; + } + /** * Gets the uncompressed length of the data. * * @return the uncompressed length of the data. */ public int getDataLength() { - return LittleEndian.getInt(_data, 0); + if (isCompressed()) { + return LittleEndian.getInt(_data, 0); + } else { + return _data.length; + } } /** @@ -88,8 +96,12 @@ public class ExOleObjStg extends RecordAtom implements PositionDependentRecord, * @return the data input stream. */ public InputStream getData() { - InputStream compressedStream = new ByteArrayInputStream(_data, 4, _data.length); - return new InflaterInputStream(compressedStream); + if (isCompressed()) { + InputStream compressedStream = new ByteArrayInputStream(_data, 4, _data.length); + return new InflaterInputStream(compressedStream); + } else { + return new ByteArrayInputStream(_data, 0, _data.length); + } } public byte[] getRawData() {