This patch: 1) Allows proper handling of VT_BOOL in Property.java 2) Enables getLinksDirty() in DocumentSummaryInformation.java 3) Enables getScale() in DocumentSummaryInformation.java 4) Documents the methods correctly 5) Adds getPropertyBooleanValue() where needed Patch follows and is an attachment as well... - Drew cvs diff -u *****CVS exited normally with code 1***** cvs server: Diffing . Index: DocumentSummaryInformation.java =================================================================== RCS file: /home/cvspublic/jakarta- poi/src/java/org/apache/poi/hpsf/DocumentSummaryInformation.java,v retrieving revision 1.5 diff -u -r1.5 DocumentSummaryInformation.java --- DocumentSummaryInformation.java 2 May 2002 16:03:41 -0000 1.5 +++ DocumentSummaryInformation.java 3 May 2002 06:05:02 -0000 @@ -65,6 +65,7 @@ * @see SummaryInformation * * @author Rainer Klute (klute@rainer-klute.de) + * @author Drew Varner (Drew.Varner closeTo sc.edu) * @version $Id: DocumentSummaryInformation.java,v 1.5 2002/05/02 16:03:41 klute Exp $ * @since 2002-02-09 */ @@ -191,16 +192,12 @@ /** - * <p>Returns the stream's scale (or <code>null</code>) - * <strong>when this method is implemented. Please note that the - * return type is likely to change!</strong> + * <p><code>true</code> when scaling of the thumbnail is + * desired. <code>false</code> if cropping is desired.</p> */ public boolean getScale() { - if (true) - throw new UnsupportedOperationException("FIXME"); - // return (byte[]) getProperty(PropertyIDMap.PID_SCALE); - return false; + return getPropertyBooleanValue(PropertyIDMap.PID_SCALE); } @@ -254,15 +251,12 @@ /** - * <p>Returns the stream's links dirty information <strong>when - * this method is implemented.</strong> + * <p>Returns whether the custom links are hampered by + * excessive noise, for all applications</p> */ public boolean getLinksDirty() { - if (true) - throw new UnsupportedOperationException("FIXME"); - // return (byte[]) getProperty(PropertyIDMap.PID_LINKSDIRTY); - return false; + return getPropertyBooleanValue(PropertyIDMap.PID_LINKSDIRTY); } } Index: Property.java =================================================================== RCS file: /home/cvspublic/jakarta- poi/src/java/org/apache/poi/hpsf/Property.java,v retrieving revision 1.3 diff -u -r1.3 Property.java --- Property.java 1 May 2002 09:31:52 -0000 1.3 +++ Property.java 3 May 2002 06:05:03 -0000 @@ -218,8 +218,35 @@ final byte[] v = new byte[length]; for (int i = 0; i < length; i++) - v[i] = src[offset + i + DWord.LENGTH]; + v[i] = src[o + i]; value = v; + break; + } + case Variant.VT_BOOL: + { + // the first four bytes in src, from + // src[offset] to src[offset + 3] contain + // the DWord for VT_BOOL, so skip it, we don't + // need it + final int first = o + DWord.LENGTH; + DWord bool = new DWord(src,o); + if (bool.intValue() == -1) + { + value = new Boolean(true); + } + else if (bool.intValue() == 0) + { + value = new Boolean(false); + } + else + { + //FIXME: What do we do here? + //VT_BOOL must be + // -1 for false + // 0 for true + // this is undefined! + } + break; } default: Index: PropertySet.java =================================================================== RCS file: /home/cvspublic/jakarta- poi/src/java/org/apache/poi/hpsf/PropertySet.java,v retrieving revision 1.3 diff -u -r1.3 PropertySet.java --- PropertySet.java 1 May 2002 09:31:52 -0000 1.3 +++ PropertySet.java 3 May 2002 06:05:05 -0000 @@ -91,6 +91,7 @@ * Section}). * * @author Rainer Klute (klute@rainer-klute.de) + * @author Drew Varner (Drew.Varner hanginIn sc.edu) * @version $Id: PropertySet.java,v 1.3 2002/05/01 09:31:52 klute Exp $ * @since 2002-02-09 */ @@ -461,6 +462,25 @@ throws NoSingleSectionException { return getSingleSection().getProperty(id); + } + + + + /** + * <p>Convenience method returning the value of a boolean + * property with the specified ID. If the property is not + * available, <code>false</code> is returned. A subsequent call to + * {@link #wasNull} will return <code>true</code> to let the caller + * distinguish that case from a real property value of <code>false</code>. + * </p> + * + * @throws NoSingleSectionException if the {@link PropertySet} has + * more or less than one {@link Section}. + */ + protected boolean getPropertyBooleanValue(final int id) + throws NoSingleSectionException + { + return getSingleSection().getPropertyBooleanValue(id); } Index: Section.java =================================================================== RCS file: /home/cvspublic/jakarta- poi/src/java/org/apache/poi/hpsf/Section.java,v retrieving revision 1.3 diff -u -r1.3 Section.java --- Section.java 1 May 2002 09:31:52 -0000 1.3 +++ Section.java 3 May 2002 06:05:05 -0000 @@ -62,6 +62,7 @@ * <p>Represents a section in a {@link PropertySet}.</p> * * @author Rainer Klute (klute@rainer-klute.de) + * @author Drew Varner (Drew.Varner allUpIn sc.edu) * @version $Id: Section.java,v 1.3 2002/05/01 09:31:52 klute Exp $ * @since 2002-02-09 */ @@ -227,6 +228,24 @@ return i.intValue(); else return 0; + } + + + + /** + * <p>Returns the value of the boolean property with the specified + * ID. If the property is not available, <code>false</code> is returned. A + * subsequent call to {@link #wasNull} will return + * <code>true</code> to let the caller distinguish that case from + * a real property value of <code>false</code>.</p> + */ + protected boolean getPropertyBooleanValue(final int id) + { + final Boolean b = (Boolean) getProperty(id); + if (b != null) + return b.booleanValue(); + else + return false; }
Created attachment 1768 [details] A patch to add VT_BOOL functionality in HPSF
Changes added to CVS repository. Thanks, Drew, for your work!