Enhancements from Drew for boolean properties. Plus doc change for DWord.

git-svn-id: https://svn.apache.org/repos/asf/jakarta/poi/trunk@352594 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Rainer Klute 2002-05-03 07:29:09 +00:00
parent 14dada7c69
commit 2ac503512a
5 changed files with 86 additions and 22 deletions

View File

@ -65,6 +65,8 @@ import org.apache.poi.hpsf.wellknown.*;
* @see SummaryInformation
*
* @author Rainer Klute (klute@rainer-klute.de)
* @author Drew Varner (Drew.Varner closeTo sc.edu)
*
* @version $Id$
* @since 2002-02-09
*/
@ -191,16 +193,12 @@ public class DocumentSummaryInformation extends SpecialPropertySet
/**
* <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 @@ public class DocumentSummaryInformation extends SpecialPropertySet
/**
* <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);
}
}

View File

@ -90,6 +90,7 @@ import org.apache.poi.hpsf.littleendian.*;
*
* @author Rainer Klute (klute@rainer-klute.de)
* @author Drew Varner (Drew.Varner InAndAround sc.edu)
*
* @version $Id$
* @since 2002-02-09
*/
@ -207,21 +208,45 @@ public class Property
}
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:
{
final byte[] v = new byte[length];

View File

@ -91,6 +91,8 @@ import org.apache.poi.poifs.filesystem.*;
* Section}).
*
* @author Rainer Klute (klute@rainer-klute.de)
* @author Drew Varner (Drew.Varner hanginIn sc.edu)
*
* @version $Id$
* @since 2002-02-09
*/
@ -465,6 +467,25 @@ public class PropertySet
/**
* <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);
}
/**
* <p>Convenience method returning the value of the numeric
* property with the specified ID. If the property is not

View File

@ -62,6 +62,8 @@ import org.apache.poi.hpsf.wellknown.*;
* <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$
* @since 2002-02-09
*/
@ -231,6 +233,24 @@ public class Section
/**
* <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;
}
private boolean wasNull;
/**

View File

@ -63,7 +63,7 @@
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 (klute@rainer-klute.de)
* @version $Id$
@ -97,7 +97,7 @@ public class DWord extends LittleEndian
/**
* <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>