From 5cbd261957177ca9403d0292e704a0e72f5b2a19 Mon Sep 17 00:00:00 2001 From: Nick Burch Date: Thu, 11 Aug 2011 11:13:03 +0000 Subject: [PATCH] Patch from Antoni Mylka from bug #51535 - correct signed vs unsigned short reading in NDocumentInputStream git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1156573 13f79535-47bb-0310-9956-ffa450edef68 --- src/documentation/content/xdocs/status.xml | 1 + .../apache/poi/poifs/filesystem/NDocumentInputStream.java | 7 +++++-- src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index b1790bf74c..96acff77ec 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,7 @@ + 51535 - correct signed vs unsigned short reading in NDocumentInputStream 51634 - support SXSSF streaming from templates initial support for XSLF usermodel API 51187 - fixed OPCPackage to correctly handle self references diff --git a/src/java/org/apache/poi/poifs/filesystem/NDocumentInputStream.java b/src/java/org/apache/poi/poifs/filesystem/NDocumentInputStream.java index cb4f7ffe75..1db8975d2b 100644 --- a/src/java/org/apache/poi/poifs/filesystem/NDocumentInputStream.java +++ b/src/java/org/apache/poi/poifs/filesystem/NDocumentInputStream.java @@ -275,7 +275,10 @@ public final class NDocumentInputStream extends DocumentInputStream { @Override public short readShort() { - return (short) readUShort(); + checkAvaliable(SIZE_SHORT); + byte[] data = new byte[SIZE_SHORT]; + readFully(data, 0, SIZE_SHORT); + return LittleEndian.getShort(data); } @Override @@ -291,7 +294,7 @@ public final class NDocumentInputStream extends DocumentInputStream { checkAvaliable(SIZE_SHORT); byte[] data = new byte[SIZE_SHORT]; readFully(data, 0, SIZE_SHORT); - return LittleEndian.getShort(data); + return LittleEndian.getUShort(data); } @Override diff --git a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java index 25ad94e352..d53e50783e 100644 --- a/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java +++ b/src/testcases/org/apache/poi/hssf/usermodel/TestBugs.java @@ -2144,9 +2144,9 @@ if(1==2) { } /** - * Large row numbers + * Large row numbers and NPOIFS vs POIFS */ - public void DISABLEDtest51535() throws Exception { + public void test51535() throws Exception { byte[] data = HSSFITestDataProvider.instance.getTestDataFileContent("51535.xls"); HSSFWorkbook wbPOIFS = new HSSFWorkbook(new POIFSFileSystem( -- 2.39.5