klute 02/05/03 00:29:09
Modified: src/java/org/apache/poi/hpsf DocumentSummaryInformation.java
Property.java PropertySet.java Section.java
src/java/org/apache/poi/hpsf/littleendian DWord.java
Log:
Enhancements from Drew for boolean properties. Plus doc change for DWord.
Revision Changes Path
1.6 +12 -14
jakarta-poi/src/java/org/apache/poi/hpsf/DocumentSummaryInformation.java
Index: DocumentSummaryInformation.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/java/org/apache/poi/hpsf/DocumentSummaryInformation.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- DocumentSummaryInformation.java 2 May 2002 16:03:41 -0000 1.5
+++ DocumentSummaryInformation.java 3 May 2002 07:29:09 -0000 1.6
@@ -65,7 +65,9 @@
* @see SummaryInformation
*
* @author Rainer Klute ([EMAIL PROTECTED])
- * @version $Id: DocumentSummaryInformation.java,v 1.5 2002/05/02 16:03:41 klute
Exp $
+ * @author Drew Varner (Drew.Varner closeTo sc.edu)
+ *
+ * @version $Id: DocumentSummaryInformation.java,v 1.6 2002/05/03 07:29:09 klute
Exp $
* @since 2002-02-09
*/
public class DocumentSummaryInformation extends SpecialPropertySet
@@ -191,16 +193,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>Returns <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 +252,15 @@
/**
- * <p>Returns the stream's links dirty information <strong>when
- * this method is implemented.</strong>
+ * <p>Returns <code>true</code> if the custom links are hampered
+ * by excessive noise, for all applications.</p>
+ *
+ * <p><strong>FIXME:</strong> Explain this some more! I (Rainer)
+ * don't understand it.</p>
*/
public boolean getLinksDirty()
{
- if (true)
- throw new UnsupportedOperationException("FIXME");
- // return (byte[]) getProperty(PropertyIDMap.PID_LINKSDIRTY);
- return false;
+ return getPropertyBooleanValue(PropertyIDMap.PID_LINKSDIRTY);
}
}
1.4 +33 -8 jakarta-poi/src/java/org/apache/poi/hpsf/Property.java
Index: Property.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hpsf/Property.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Property.java 1 May 2002 09:31:52 -0000 1.3
+++ Property.java 3 May 2002 07:29:09 -0000 1.4
@@ -90,7 +90,8 @@
*
* @author Rainer Klute ([EMAIL PROTECTED])
* @author Drew Varner (Drew.Varner InAndAround sc.edu)
- * @version $Id: Property.java,v 1.3 2002/05/01 09:31:52 klute Exp $
+ *
+ * @version $Id: Property.java,v 1.4 2002/05/03 07:29:09 klute Exp $
* @since 2002-02-09
*/
public class Property
@@ -207,19 +208,43 @@
}
case Variant.VT_CF:
{
- // the first four bytes in src, from
- // src[offset] to src[offset + 3] contain
- // the DWord for VT_CF, so skip it, we don't
- // need it
+ /* The first four bytes in src, from rc[offset] to
+ * src[offset + 3] contain the DWord for VT_CF, so
+ * skip it, we don't need it. */
- // truncate the length of the return array by
- // a DWord length (4 bytes)
+ /* Truncate the length of the return array by a DWord
+ * length (4 bytes). */
length = length - DWord.LENGTH;
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: Someone might invent a new
+ * HPSFRuntimeException subclass
+ * IllegalPropertySetDataException for this and
+ * similar cases. */
+ throw new HPSFRuntimeException
+ ("Illegal property set data: A boolean must be " +
+ "either -1 (true) or 0 (false).");
break;
}
default:
1.4 +22 -1 jakarta-poi/src/java/org/apache/poi/hpsf/PropertySet.java
Index: PropertySet.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hpsf/PropertySet.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- PropertySet.java 1 May 2002 09:31:52 -0000 1.3
+++ PropertySet.java 3 May 2002 07:29:09 -0000 1.4
@@ -91,7 +91,9 @@
* Section}).
*
* @author Rainer Klute ([EMAIL PROTECTED])
- * @version $Id: PropertySet.java,v 1.3 2002/05/01 09:31:52 klute Exp $
+ * @author Drew Varner (Drew.Varner hanginIn sc.edu)
+ *
+ * @version $Id: PropertySet.java,v 1.4 2002/05/03 07:29:09 klute Exp $
* @since 2002-02-09
*/
public class PropertySet
@@ -461,6 +463,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);
}
1.4 +21 -1 jakarta-poi/src/java/org/apache/poi/hpsf/Section.java
Index: Section.java
===================================================================
RCS file: /home/cvs/jakarta-poi/src/java/org/apache/poi/hpsf/Section.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Section.java 1 May 2002 09:31:52 -0000 1.3
+++ Section.java 3 May 2002 07:29:09 -0000 1.4
@@ -62,7 +62,9 @@
* <p>Represents a section in a {@link PropertySet}.</p>
*
* @author Rainer Klute ([EMAIL PROTECTED])
- * @version $Id: Section.java,v 1.3 2002/05/01 09:31:52 klute Exp $
+ * @author Drew Varner (Drew.Varner allUpIn sc.edu)
+ *
+ * @version $Id: Section.java,v 1.4 2002/05/03 07:29:09 klute Exp $
* @since 2002-02-09
*/
public class Section
@@ -227,6 +229,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;
}
1.3 +3 -3 jakarta-poi/src/java/org/apache/poi/hpsf/littleendian/DWord.java
Index: DWord.java
===================================================================
RCS file:
/home/cvs/jakarta-poi/src/java/org/apache/poi/hpsf/littleendian/DWord.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DWord.java 30 Apr 2002 03:51:02 -0000 1.2
+++ DWord.java 3 May 2002 07:29:09 -0000 1.3
@@ -63,10 +63,10 @@
package org.apache.poi.hpsf.littleendian;
/**
- * <p>Represents a double word (4 bytes).</p>
+ * <p>Represents an unsigned double word (4 bytes).</p>
*
* @author Rainer Klute ([EMAIL PROTECTED])
- * @version $Id: DWord.java,v 1.2 2002/04/30 03:51:02 acoliver Exp $
+ * @version $Id: DWord.java,v 1.3 2002/05/03 07:29:09 klute Exp $
* @since 2002-02-09
*/
public class DWord extends LittleEndian
@@ -97,7 +97,7 @@
/**
- * <p>Return the integral value of this {@link DWord}.</p>
+ * <p>Returns the integral value of this {@link DWord}.</p>
*
* <p><strong>FIXME:</strong> Introduce a superclass for the
* numeric types and make this a method of the superclass!</p>