From: Rainer Klute Date: Wed, 2 Apr 2008 00:50:45 +0000 (+0000) Subject: 44694 - HPSF: Support for property sets without sections X-Git-Tag: REL_3_0_3_BETA1~49 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=af1ef87ac708cfda5463842a78821430eef2066f;p=poi.git 44694 - HPSF: Support for property sets without sections git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@643670 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/documentation/content/xdocs/changes.xml b/src/documentation/content/xdocs/changes.xml index 5722a7be45..256538dabb 100644 --- a/src/documentation/content/xdocs/changes.xml +++ b/src/documentation/content/xdocs/changes.xml @@ -37,7 +37,7 @@ - Implement Sheet.removeShape(Shape shape) in HSLF + 44694 - HPSF: Support for property sets without sections Various fixes: Recognising var-arg built-in functions #44675, ExternalNameRecord serialisation bug #44695, PMT() bug #44691 30311 - More work on Conditional Formatting Move the Formula Evaluator code out of scratchpad diff --git a/src/documentation/content/xdocs/status.xml b/src/documentation/content/xdocs/status.xml index 9d35cb7fd1..5e963e484c 100644 --- a/src/documentation/content/xdocs/status.xml +++ b/src/documentation/content/xdocs/status.xml @@ -34,6 +34,7 @@ + 44694 - HPSF: Support for property sets without sections Implement Sheet.removeShape(Shape shape) in HSLF Various fixes: Recognising var-arg built-in functions #44675, ExternalNameRecord serialisation bug #44695, PMT() bug #44691 30311 - More work on Conditional Formatting diff --git a/src/java/org/apache/poi/hpsf/MutablePropertySet.java b/src/java/org/apache/poi/hpsf/MutablePropertySet.java index 34281b90c1..5ecbfeee3d 100644 --- a/src/java/org/apache/poi/hpsf/MutablePropertySet.java +++ b/src/java/org/apache/poi/hpsf/MutablePropertySet.java @@ -92,6 +92,8 @@ public class MutablePropertySet extends PropertySet osVersion = ps.getOSVersion(); setClassID(ps.getClassID()); clearSections(); + if (sections == null) + sections = new LinkedList(); for (final Iterator i = ps.getSections().iterator(); i.hasNext();) { final MutableSection s = new MutableSection((Section) (i.next())); diff --git a/src/java/org/apache/poi/hpsf/PropertySet.java b/src/java/org/apache/poi/hpsf/PropertySet.java index 0bfbb8f32f..b39ba08bfa 100644 --- a/src/java/org/apache/poi/hpsf/PropertySet.java +++ b/src/java/org/apache/poi/hpsf/PropertySet.java @@ -387,7 +387,7 @@ public class PropertySet o += ClassID.LENGTH; final long sectionCount = LittleEndian.getUInt(src, o); o += LittleEndian.INT_SIZE; - if (sectionCount < 1) + if (sectionCount < 0) return false; return true; } @@ -426,9 +426,9 @@ public class PropertySet o += ClassID.LENGTH; final int sectionCount = LittleEndian.getInt(src, o); o += LittleEndian.INT_SIZE; - if (sectionCount <= 0) + if (sectionCount < 0) throw new HPSFRuntimeException("Section count " + sectionCount + - " must be greater than 0."); + " is negative."); /* * Read the sections, which are following the header. They @@ -468,6 +468,8 @@ public class PropertySet */ public boolean isSummaryInformation() { + if (sections.size() <= 0) + return false; return Util.equal(((Section) sections.get(0)).getFormatID().getBytes(), SectionIDMap.SUMMARY_INFORMATION_ID); } @@ -483,6 +485,8 @@ public class PropertySet */ public boolean isDocumentSummaryInformation() { + if (sections.size() <= 0) + return false; return Util.equal(((Section) sections.get(0)).getFormatID().getBytes(), SectionIDMap.DOCUMENT_SUMMARY_INFORMATION_ID[0]); } diff --git a/src/testcases/org/apache/poi/hpsf/data/Test_Humor-Generation.ppt b/src/testcases/org/apache/poi/hpsf/data/Test_Humor-Generation.ppt new file mode 100644 index 0000000000..e5763ccca1 Binary files /dev/null and b/src/testcases/org/apache/poi/hpsf/data/Test_Humor-Generation.ppt differ