2004-04-09 09:05:39 -04:00
|
|
|
|
|
|
|
/* ====================================================================
|
|
|
|
Copyright 2002-2004 Apache Software Foundation
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
==================================================================== */
|
|
|
|
|
2002-02-13 23:00:59 -05:00
|
|
|
package org.apache.poi.hpsf;
|
|
|
|
|
2003-10-23 16:44:24 -04:00
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.Map;
|
|
|
|
|
2003-08-02 15:02:28 -04:00
|
|
|
import org.apache.poi.hpsf.wellknown.PropertyIDMap;
|
2002-02-13 23:00:59 -05:00
|
|
|
|
|
|
|
/**
|
2002-12-10 01:15:20 -05:00
|
|
|
* <p>Convenience class representing a DocumentSummary Information stream in a
|
|
|
|
* Microsoft Office document.</p>
|
2002-02-13 23:00:59 -05:00
|
|
|
*
|
2003-08-30 05:13:53 -04:00
|
|
|
* @author Rainer Klute <a
|
|
|
|
* href="mailto:klute@rainer-klute.de"><klute@rainer-klute.de></a>
|
2002-12-10 01:15:20 -05:00
|
|
|
* @author Drew Varner (Drew.Varner closeTo sc.edu)
|
2003-10-23 16:44:24 -04:00
|
|
|
* @author robert_flaherty@hyperion.com
|
2002-12-10 01:15:20 -05:00
|
|
|
* @see SummaryInformation
|
|
|
|
* @version $Id$
|
|
|
|
* @since 2002-02-09
|
2002-02-13 23:00:59 -05:00
|
|
|
*/
|
2002-12-10 01:15:20 -05:00
|
|
|
public class DocumentSummaryInformation extends SpecialPropertySet
|
|
|
|
{
|
2002-02-13 23:00:59 -05:00
|
|
|
|
2003-02-22 09:27:16 -05:00
|
|
|
/**
|
|
|
|
* <p>The document name a document summary information stream
|
|
|
|
* usually has in a POIFS filesystem.</p>
|
|
|
|
*/
|
|
|
|
public static final String DEFAULT_STREAM_NAME =
|
|
|
|
"\005DocumentSummaryInformation";
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-02-13 23:00:59 -05:00
|
|
|
/**
|
2002-12-10 01:15:20 -05:00
|
|
|
* <p>Creates a {@link DocumentSummaryInformation} from a given
|
|
|
|
* {@link PropertySet}.</p>
|
2002-02-13 23:00:59 -05:00
|
|
|
*
|
2002-12-10 01:15:20 -05:00
|
|
|
* @param ps A property set which should be created from a
|
|
|
|
* document summary information stream.
|
|
|
|
* @throws UnexpectedPropertySetTypeException if <var>ps</var>
|
|
|
|
* does not contain a document summary information stream.
|
2002-02-13 23:00:59 -05:00
|
|
|
*/
|
|
|
|
public DocumentSummaryInformation(final PropertySet ps)
|
2003-08-02 15:02:28 -04:00
|
|
|
throws UnexpectedPropertySetTypeException
|
2002-12-10 01:15:20 -05:00
|
|
|
{
|
2002-02-13 23:00:59 -05:00
|
|
|
super(ps);
|
2002-12-10 01:15:20 -05:00
|
|
|
if (!isDocumentSummaryInformation())
|
2002-02-13 23:00:59 -05:00
|
|
|
throw new UnexpectedPropertySetTypeException
|
2003-08-02 15:02:28 -04:00
|
|
|
("Not a " + getClass().getName());
|
2002-02-13 23:00:59 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2002-12-10 01:15:20 -05:00
|
|
|
* <p>Returns the stream's category (or <code>null</code>).</p>
|
2002-05-11 10:47:24 -04:00
|
|
|
*
|
2002-12-10 01:15:20 -05:00
|
|
|
* @return The category value
|
2002-02-13 23:00:59 -05:00
|
|
|
*/
|
2002-12-10 01:15:20 -05:00
|
|
|
public String getCategory()
|
|
|
|
{
|
2002-02-13 23:00:59 -05:00
|
|
|
return (String) getProperty(PropertyIDMap.PID_CATEGORY);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2002-12-10 01:15:20 -05:00
|
|
|
* <p>Returns the stream's presentation format (or
|
|
|
|
* <code>null</code>).</p>
|
2002-05-11 10:47:24 -04:00
|
|
|
*
|
2002-12-10 01:15:20 -05:00
|
|
|
* @return The presentationFormat value
|
2002-02-13 23:00:59 -05:00
|
|
|
*/
|
2002-12-10 01:15:20 -05:00
|
|
|
public String getPresentationFormat()
|
|
|
|
{
|
2002-02-13 23:00:59 -05:00
|
|
|
return (String) getProperty(PropertyIDMap.PID_PRESFORMAT);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2002-12-10 01:15:20 -05:00
|
|
|
* <p>Returns the stream's byte count or 0 if the {@link
|
|
|
|
* DocumentSummaryInformation} does not contain a byte count.</p>
|
2002-05-11 10:47:24 -04:00
|
|
|
*
|
2002-12-10 01:15:20 -05:00
|
|
|
* @return The byteCount value
|
2002-02-13 23:00:59 -05:00
|
|
|
*/
|
2002-12-10 01:15:20 -05:00
|
|
|
public int getByteCount()
|
|
|
|
{
|
2002-02-13 23:00:59 -05:00
|
|
|
return getPropertyIntValue(PropertyIDMap.PID_BYTECOUNT);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2002-12-10 01:15:20 -05:00
|
|
|
* <p>Returns the stream's line count or 0 if the {@link
|
|
|
|
* DocumentSummaryInformation} does not contain a line count.</p>
|
2002-05-11 10:47:24 -04:00
|
|
|
*
|
2002-12-10 01:15:20 -05:00
|
|
|
* @return The lineCount value
|
2002-02-13 23:00:59 -05:00
|
|
|
*/
|
2002-12-10 01:15:20 -05:00
|
|
|
public int getLineCount()
|
|
|
|
{
|
2002-02-13 23:00:59 -05:00
|
|
|
return getPropertyIntValue(PropertyIDMap.PID_LINECOUNT);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2002-12-10 01:15:20 -05:00
|
|
|
* <p>Returns the stream's par count or 0 if the {@link
|
|
|
|
* DocumentSummaryInformation} does not contain a par count.</p>
|
2002-05-11 10:47:24 -04:00
|
|
|
*
|
2002-12-10 01:15:20 -05:00
|
|
|
* @return The parCount value
|
2002-02-13 23:00:59 -05:00
|
|
|
*/
|
2002-12-10 01:15:20 -05:00
|
|
|
public int getParCount()
|
|
|
|
{
|
2002-02-13 23:00:59 -05:00
|
|
|
return getPropertyIntValue(PropertyIDMap.PID_PARCOUNT);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2002-12-10 01:15:20 -05:00
|
|
|
* <p>Returns the stream's slide count or 0 if the {@link
|
|
|
|
* DocumentSummaryInformation} does not contain a slide count.</p>
|
2002-05-11 10:47:24 -04:00
|
|
|
*
|
2002-12-10 01:15:20 -05:00
|
|
|
* @return The slideCount value
|
2002-02-13 23:00:59 -05:00
|
|
|
*/
|
2002-12-10 01:15:20 -05:00
|
|
|
public int getSlideCount()
|
|
|
|
{
|
2002-02-13 23:00:59 -05:00
|
|
|
return getPropertyIntValue(PropertyIDMap.PID_SLIDECOUNT);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2002-12-10 01:15:20 -05:00
|
|
|
* <p>Returns the stream's note count or 0 if the {@link
|
|
|
|
* DocumentSummaryInformation} does not contain a note count.</p>
|
2002-05-11 10:47:24 -04:00
|
|
|
*
|
2002-12-10 01:15:20 -05:00
|
|
|
* @return The noteCount value
|
2002-02-13 23:00:59 -05:00
|
|
|
*/
|
2002-12-10 01:15:20 -05:00
|
|
|
public int getNoteCount()
|
|
|
|
{
|
2002-02-13 23:00:59 -05:00
|
|
|
return getPropertyIntValue(PropertyIDMap.PID_NOTECOUNT);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2002-12-10 01:15:20 -05:00
|
|
|
* <p>Returns the stream's hidden count or 0 if the {@link
|
|
|
|
* DocumentSummaryInformation} does not contain a hidden
|
|
|
|
* count.</p>
|
2002-05-11 10:47:24 -04:00
|
|
|
*
|
2002-12-10 01:15:20 -05:00
|
|
|
* @return The hiddenCount value
|
2002-02-13 23:00:59 -05:00
|
|
|
*/
|
2002-12-10 01:15:20 -05:00
|
|
|
public int getHiddenCount()
|
|
|
|
{
|
2002-02-13 23:00:59 -05:00
|
|
|
return getPropertyIntValue(PropertyIDMap.PID_HIDDENCOUNT);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2002-12-10 01:15:20 -05:00
|
|
|
* <p>Returns the stream's mmclip count or 0 if the {@link
|
|
|
|
* DocumentSummaryInformation} does not contain a mmclip
|
|
|
|
* count.</p>
|
2002-05-11 10:47:24 -04:00
|
|
|
*
|
2002-12-10 01:15:20 -05:00
|
|
|
* @return The mMClipCount value
|
2002-02-13 23:00:59 -05:00
|
|
|
*/
|
2002-12-10 01:15:20 -05:00
|
|
|
public int getMMClipCount()
|
|
|
|
{
|
2002-02-13 23:00:59 -05:00
|
|
|
return getPropertyIntValue(PropertyIDMap.PID_MMCLIPCOUNT);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2002-12-10 01:15:20 -05:00
|
|
|
* <p>Returns <code>true</code> when scaling of the thumbnail is
|
|
|
|
* desired, <code>false</code> if cropping is desired.</p>
|
2002-05-11 10:47:24 -04:00
|
|
|
*
|
2002-12-10 01:15:20 -05:00
|
|
|
* @return The scale value
|
2002-02-13 23:00:59 -05:00
|
|
|
*/
|
2002-12-10 01:15:20 -05:00
|
|
|
public boolean getScale()
|
|
|
|
{
|
2002-05-03 03:29:09 -04:00
|
|
|
return getPropertyBooleanValue(PropertyIDMap.PID_SCALE);
|
2002-02-13 23:00:59 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2002-12-10 01:15:20 -05:00
|
|
|
* <p>Returns the stream's heading pair (or <code>null</code>)
|
|
|
|
* <strong>when this method is implemented. Please note that the
|
|
|
|
* return type is likely to change!</strong>
|
2002-05-11 10:47:24 -04:00
|
|
|
*
|
2002-12-10 01:15:20 -05:00
|
|
|
* @return The headingPair value
|
2002-02-13 23:00:59 -05:00
|
|
|
*/
|
2002-12-10 01:15:20 -05:00
|
|
|
public byte[] getHeadingPair()
|
|
|
|
{
|
|
|
|
if (true)
|
2002-02-13 23:00:59 -05:00
|
|
|
throw new UnsupportedOperationException("FIXME");
|
|
|
|
return (byte[]) getProperty(PropertyIDMap.PID_HEADINGPAIR);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2002-12-10 01:15:20 -05:00
|
|
|
* <p>Returns the stream's doc parts (or <code>null</code>)
|
|
|
|
* <strong>when this method is implemented. Please note that the
|
|
|
|
* return type is likely to change!</strong>
|
2002-05-11 10:47:24 -04:00
|
|
|
*
|
2002-12-10 01:15:20 -05:00
|
|
|
* @return The docparts value
|
2002-02-13 23:00:59 -05:00
|
|
|
*/
|
2002-12-10 01:15:20 -05:00
|
|
|
public byte[] getDocparts()
|
|
|
|
{
|
|
|
|
if (true)
|
2002-02-13 23:00:59 -05:00
|
|
|
throw new UnsupportedOperationException("FIXME");
|
|
|
|
return (byte[]) getProperty(PropertyIDMap.PID_DOCPARTS);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2002-12-10 01:15:20 -05:00
|
|
|
* <p>Returns the stream's manager (or <code>null</code>).</p>
|
2002-05-11 10:47:24 -04:00
|
|
|
*
|
2002-12-10 01:15:20 -05:00
|
|
|
* @return The manager value
|
2002-02-13 23:00:59 -05:00
|
|
|
*/
|
2002-12-10 01:15:20 -05:00
|
|
|
public String getManager()
|
|
|
|
{
|
2002-02-13 23:00:59 -05:00
|
|
|
return (String) getProperty(PropertyIDMap.PID_MANAGER);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2002-12-10 01:15:20 -05:00
|
|
|
* <p>Returns the stream's company (or <code>null</code>).</p>
|
2002-05-11 10:47:24 -04:00
|
|
|
*
|
2002-12-10 01:15:20 -05:00
|
|
|
* @return The company value
|
2002-02-13 23:00:59 -05:00
|
|
|
*/
|
2002-12-10 01:15:20 -05:00
|
|
|
public String getCompany()
|
|
|
|
{
|
2002-02-13 23:00:59 -05:00
|
|
|
return (String) getProperty(PropertyIDMap.PID_COMPANY);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2004-08-15 11:20:08 -04:00
|
|
|
* <p>Returns <code>true</code> if the custom links are dirty.</p> <p>
|
2002-05-03 03:29:09 -04:00
|
|
|
*
|
2002-12-10 01:15:20 -05:00
|
|
|
* @return The linksDirty value
|
2002-02-13 23:00:59 -05:00
|
|
|
*/
|
2002-12-10 01:15:20 -05:00
|
|
|
public boolean getLinksDirty()
|
|
|
|
{
|
2002-05-03 03:29:09 -04:00
|
|
|
return getPropertyBooleanValue(PropertyIDMap.PID_LINKSDIRTY);
|
2002-02-13 23:00:59 -05:00
|
|
|
}
|
|
|
|
|
2003-10-23 16:44:24 -04:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* <p>Gets the custom properties as a map from the property name to
|
|
|
|
* value.</p>
|
|
|
|
*
|
|
|
|
* @return The custom properties if any exist, <code>null</code> otherwise.
|
|
|
|
* @since 2003-10-22
|
|
|
|
*/
|
|
|
|
public Map getCustomProperties()
|
|
|
|
{
|
|
|
|
Map nameToValue = null;
|
|
|
|
if (getSectionCount() >= 2)
|
|
|
|
{
|
|
|
|
final Section section = (Section) getSections().get(1);
|
|
|
|
final Map pidToName =
|
|
|
|
(Map) section.getProperty(PropertyIDMap.PID_DICTIONARY);
|
|
|
|
if (pidToName != null)
|
|
|
|
{
|
|
|
|
nameToValue = new HashMap(pidToName.size());
|
|
|
|
for (Iterator i = pidToName.entrySet().iterator(); i.hasNext();)
|
|
|
|
{
|
|
|
|
final Map.Entry e = (Map.Entry) i.next();
|
|
|
|
final long pid = ((Number) e.getKey()).longValue();
|
|
|
|
nameToValue.put(e.getValue(), section.getProperty(pid));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return nameToValue;
|
|
|
|
}
|
|
|
|
|
2002-02-13 23:00:59 -05:00
|
|
|
}
|