2004-04-09 13:05:39 +00: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-14 04:00:59 +00:00
|
|
|
package org.apache.poi.hpsf;
|
|
|
|
|
|
2003-08-02 19:02:28 +00:00
|
|
|
import java.util.Date;
|
|
|
|
|
import org.apache.poi.hpsf.wellknown.PropertyIDMap;
|
2002-02-14 04:00:59 +00:00
|
|
|
|
|
|
|
|
/**
|
2003-02-01 13:28:28 +00:00
|
|
|
* <p>Convenience class representing a Summary Information stream in a
|
|
|
|
|
* Microsoft Office document.</p>
|
2002-02-14 04:00:59 +00:00
|
|
|
*
|
2003-08-30 09:13:53 +00:00
|
|
|
* @author Rainer Klute <a
|
|
|
|
|
* href="mailto:klute@rainer-klute.de"><klute@rainer-klute.de></a>
|
2003-02-01 13:28:28 +00:00
|
|
|
* @see DocumentSummaryInformation
|
|
|
|
|
* @version $Id$
|
|
|
|
|
* @since 2002-02-09
|
2002-02-14 04:00:59 +00:00
|
|
|
*/
|
2003-02-01 13:28:28 +00:00
|
|
|
public class SummaryInformation extends SpecialPropertySet
|
|
|
|
|
{
|
2002-02-14 04:00:59 +00:00
|
|
|
|
2003-02-22 14:27:16 +00:00
|
|
|
/**
|
|
|
|
|
* <p>The document name a summary information stream usually has
|
|
|
|
|
* in a POIFS filesystem.</p>
|
|
|
|
|
*/
|
|
|
|
|
public static final String DEFAULT_STREAM_NAME = "\005SummaryInformation";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2002-02-14 04:00:59 +00:00
|
|
|
/**
|
2003-02-01 13:28:28 +00:00
|
|
|
* <p>Creates a {@link SummaryInformation} from a given {@link
|
|
|
|
|
* PropertySet}.</p>
|
2002-02-14 04:00:59 +00:00
|
|
|
*
|
2003-02-01 13:28:28 +00:00
|
|
|
* @param ps A property set which should be created from a summary
|
|
|
|
|
* information stream.
|
|
|
|
|
* @throws UnexpectedPropertySetTypeException if <var>ps</var>
|
|
|
|
|
* does not contain a summary information stream.
|
2002-02-14 04:00:59 +00:00
|
|
|
*/
|
|
|
|
|
public SummaryInformation(final PropertySet ps)
|
2003-08-02 19:02:28 +00:00
|
|
|
throws UnexpectedPropertySetTypeException
|
2003-02-01 13:28:28 +00:00
|
|
|
{
|
2002-02-14 04:00:59 +00:00
|
|
|
super(ps);
|
2003-02-01 13:28:28 +00:00
|
|
|
if (!isSummaryInformation())
|
2002-02-14 04:00:59 +00:00
|
|
|
throw new UnexpectedPropertySetTypeException
|
2003-08-02 19:02:28 +00:00
|
|
|
("Not a " + getClass().getName());
|
2002-02-14 04:00:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2003-02-01 13:28:28 +00:00
|
|
|
* <p>Returns the stream's title (or <code>null</code>).</p>
|
2002-05-11 14:47:24 +00:00
|
|
|
*
|
2003-02-01 13:28:28 +00:00
|
|
|
* @return The title or <code>null</code>
|
2002-02-14 04:00:59 +00:00
|
|
|
*/
|
2003-02-01 13:28:28 +00:00
|
|
|
public String getTitle()
|
|
|
|
|
{
|
2002-02-14 04:00:59 +00:00
|
|
|
return (String) getProperty(PropertyIDMap.PID_TITLE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2003-02-01 13:28:28 +00:00
|
|
|
* <p>Returns the stream's subject (or <code>null</code>).</p>
|
2002-05-11 14:47:24 +00:00
|
|
|
*
|
2003-02-01 13:28:28 +00:00
|
|
|
* @return The subject or <code>null</code>
|
2002-02-14 04:00:59 +00:00
|
|
|
*/
|
2003-02-01 13:28:28 +00:00
|
|
|
public String getSubject()
|
|
|
|
|
{
|
2002-02-14 04:00:59 +00:00
|
|
|
return (String) getProperty(PropertyIDMap.PID_SUBJECT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2003-02-01 13:28:28 +00:00
|
|
|
* <p>Returns the stream's author (or <code>null</code>).</p>
|
2002-05-11 14:47:24 +00:00
|
|
|
*
|
2003-02-01 13:28:28 +00:00
|
|
|
* @return The author or <code>null</code>
|
2002-02-14 04:00:59 +00:00
|
|
|
*/
|
2003-02-01 13:28:28 +00:00
|
|
|
public String getAuthor()
|
|
|
|
|
{
|
2002-02-14 04:00:59 +00:00
|
|
|
return (String) getProperty(PropertyIDMap.PID_AUTHOR);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2003-02-01 13:28:28 +00:00
|
|
|
* <p>Returns the stream's keywords (or <code>null</code>).</p>
|
2002-05-11 14:47:24 +00:00
|
|
|
*
|
2003-02-01 13:28:28 +00:00
|
|
|
* @return The keywords or <code>null</code>
|
2002-02-14 04:00:59 +00:00
|
|
|
*/
|
2003-02-01 13:28:28 +00:00
|
|
|
public String getKeywords()
|
|
|
|
|
{
|
2002-02-14 04:00:59 +00:00
|
|
|
return (String) getProperty(PropertyIDMap.PID_KEYWORDS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2003-02-01 13:28:28 +00:00
|
|
|
* <p>Returns the stream's comments (or <code>null</code>).</p>
|
2002-05-11 14:47:24 +00:00
|
|
|
*
|
2003-02-01 13:28:28 +00:00
|
|
|
* @return The comments or <code>null</code>
|
2002-02-14 04:00:59 +00:00
|
|
|
*/
|
2003-02-01 13:28:28 +00:00
|
|
|
public String getComments()
|
|
|
|
|
{
|
2002-02-14 04:00:59 +00:00
|
|
|
return (String) getProperty(PropertyIDMap.PID_COMMENTS);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2003-02-01 13:28:28 +00:00
|
|
|
* <p>Returns the stream's template (or <code>null</code>).</p>
|
2002-05-11 14:47:24 +00:00
|
|
|
*
|
2003-02-01 13:28:28 +00:00
|
|
|
* @return The template or <code>null</code>
|
2002-02-14 04:00:59 +00:00
|
|
|
*/
|
2003-02-01 13:28:28 +00:00
|
|
|
public String getTemplate()
|
|
|
|
|
{
|
2002-02-14 04:00:59 +00:00
|
|
|
return (String) getProperty(PropertyIDMap.PID_TEMPLATE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2003-02-01 13:28:28 +00:00
|
|
|
* <p>Returns the stream's last author (or <code>null</code>).</p>
|
2002-05-11 14:47:24 +00:00
|
|
|
*
|
2003-02-01 13:28:28 +00:00
|
|
|
* @return The last author or <code>null</code>
|
2002-02-14 04:00:59 +00:00
|
|
|
*/
|
2003-02-01 13:28:28 +00:00
|
|
|
public String getLastAuthor()
|
|
|
|
|
{
|
2002-02-14 04:00:59 +00:00
|
|
|
return (String) getProperty(PropertyIDMap.PID_LASTAUTHOR);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2003-02-01 13:28:28 +00:00
|
|
|
* <p>Returns the stream's revision number (or
|
|
|
|
|
* <code>null</code>). </p>
|
2002-05-11 14:47:24 +00:00
|
|
|
*
|
2003-02-01 13:28:28 +00:00
|
|
|
* @return The revision number or <code>null</code>
|
2002-05-11 14:47:24 +00:00
|
|
|
*/
|
2003-02-01 13:28:28 +00:00
|
|
|
public String getRevNumber()
|
|
|
|
|
{
|
2002-02-14 04:00:59 +00:00
|
|
|
return (String) getProperty(PropertyIDMap.PID_REVNUMBER);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2003-09-13 12:31:28 +00:00
|
|
|
* <p>Returns the total time spent in editing the document
|
|
|
|
|
* (or <code>0</code>).</p>
|
2002-05-11 14:47:24 +00:00
|
|
|
*
|
2003-09-13 12:31:28 +00:00
|
|
|
* @return The total time spent in editing the document or 0 if the {@link
|
|
|
|
|
* SummaryInformation} does not contain this information.
|
2002-02-14 04:00:59 +00:00
|
|
|
*/
|
2003-09-13 12:31:28 +00:00
|
|
|
public long getEditTime()
|
2003-02-01 13:28:28 +00:00
|
|
|
{
|
2003-09-13 12:31:28 +00:00
|
|
|
final Date d = (Date) getProperty(PropertyIDMap.PID_EDITTIME);
|
|
|
|
|
if (d == null)
|
|
|
|
|
return 0;
|
|
|
|
|
else
|
|
|
|
|
return Util.dateToFileTime(d);
|
2002-02-14 04:00:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2003-02-01 13:28:28 +00:00
|
|
|
* <p>Returns the stream's last printed time (or
|
|
|
|
|
* <code>null</code>).</p>
|
2002-05-11 14:47:24 +00:00
|
|
|
*
|
2003-02-01 13:28:28 +00:00
|
|
|
* @return The last printed time or <code>null</code>
|
2002-02-14 04:00:59 +00:00
|
|
|
*/
|
2003-02-01 13:28:28 +00:00
|
|
|
public Date getLastPrinted()
|
|
|
|
|
{
|
2002-02-14 04:00:59 +00:00
|
|
|
return (Date) getProperty(PropertyIDMap.PID_LASTPRINTED);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2003-02-01 13:28:28 +00:00
|
|
|
* <p>Returns the stream's creation time (or
|
|
|
|
|
* <code>null</code>).</p>
|
2002-05-11 14:47:24 +00:00
|
|
|
*
|
2003-02-01 13:28:28 +00:00
|
|
|
* @return The creation time or <code>null</code>
|
2002-02-14 04:00:59 +00:00
|
|
|
*/
|
2003-02-01 13:28:28 +00:00
|
|
|
public Date getCreateDateTime()
|
|
|
|
|
{
|
2002-02-14 04:00:59 +00:00
|
|
|
return (Date) getProperty(PropertyIDMap.PID_CREATE_DTM);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2003-02-01 13:28:28 +00:00
|
|
|
* <p>Returns the stream's last save time (or
|
|
|
|
|
* <code>null</code>).</p>
|
2002-05-11 14:47:24 +00:00
|
|
|
*
|
2003-02-01 13:28:28 +00:00
|
|
|
* @return The last save time or <code>null</code>
|
2002-02-14 04:00:59 +00:00
|
|
|
*/
|
2003-02-01 13:28:28 +00:00
|
|
|
public Date getLastSaveDateTime()
|
|
|
|
|
{
|
2002-02-14 04:00:59 +00:00
|
|
|
return (Date) getProperty(PropertyIDMap.PID_LASTSAVE_DTM);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2003-02-01 13:28:28 +00:00
|
|
|
* <p>Returns the stream's page count or 0 if the {@link
|
|
|
|
|
* SummaryInformation} does not contain a page count.</p>
|
2002-05-11 14:47:24 +00:00
|
|
|
*
|
2003-09-13 12:31:28 +00:00
|
|
|
* @return The page count or 0 if the {@link SummaryInformation} does not
|
|
|
|
|
* contain a page count.
|
2002-02-14 04:00:59 +00:00
|
|
|
*/
|
2003-02-01 13:28:28 +00:00
|
|
|
public int getPageCount()
|
|
|
|
|
{
|
2002-02-14 04:00:59 +00:00
|
|
|
return getPropertyIntValue(PropertyIDMap.PID_PAGECOUNT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2003-02-01 13:28:28 +00:00
|
|
|
* <p>Returns the stream's word count or 0 if the {@link
|
|
|
|
|
* SummaryInformation} does not contain a word count.</p>
|
2002-05-11 14:47:24 +00:00
|
|
|
*
|
2003-02-01 13:28:28 +00:00
|
|
|
* @return The word count or <code>null</code>
|
2002-02-14 04:00:59 +00:00
|
|
|
*/
|
2003-02-01 13:28:28 +00:00
|
|
|
public int getWordCount()
|
|
|
|
|
{
|
2002-02-14 04:00:59 +00:00
|
|
|
return getPropertyIntValue(PropertyIDMap.PID_WORDCOUNT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2003-02-01 13:28:28 +00:00
|
|
|
* <p>Returns the stream's character count or 0 if the {@link
|
|
|
|
|
* SummaryInformation} does not contain a char count.</p>
|
2002-05-11 14:47:24 +00:00
|
|
|
*
|
2003-02-01 13:28:28 +00:00
|
|
|
* @return The character count or <code>null</code>
|
2002-02-14 04:00:59 +00:00
|
|
|
*/
|
2003-02-01 13:28:28 +00:00
|
|
|
public int getCharCount()
|
|
|
|
|
{
|
2002-02-14 04:00:59 +00:00
|
|
|
return getPropertyIntValue(PropertyIDMap.PID_CHARCOUNT);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2003-02-01 13:28:28 +00:00
|
|
|
* <p>Returns the stream's thumbnail (or <code>null</code>)
|
|
|
|
|
* <strong>when this method is implemented. Please note that the
|
|
|
|
|
* return type is likely to change!</strong></p>
|
|
|
|
|
*
|
2004-08-15 15:20:08 +00:00
|
|
|
* <p><strong>Hint to developers:</strong> Drew Varner <Drew.Varner -at-
|
|
|
|
|
* sc.edu> said that this is an image in WMF or Clipboard (BMP?) format.
|
2003-12-03 20:00:14 +00:00
|
|
|
* However, we won't do any conversion into any image type but instead just
|
|
|
|
|
* return a byte array.</p>
|
2003-02-01 13:28:28 +00:00
|
|
|
*
|
|
|
|
|
* @return The thumbnail or <code>null</code>
|
2002-02-14 04:00:59 +00:00
|
|
|
*/
|
2003-02-01 13:28:28 +00:00
|
|
|
public byte[] getThumbnail()
|
|
|
|
|
{
|
2002-02-14 04:00:59 +00:00
|
|
|
return (byte[]) getProperty(PropertyIDMap.PID_THUMBNAIL);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2003-02-01 13:28:28 +00:00
|
|
|
* <p>Returns the stream's application name (or
|
|
|
|
|
* <code>null</code>).</p>
|
2002-05-11 14:47:24 +00:00
|
|
|
*
|
2003-02-01 13:28:28 +00:00
|
|
|
* @return The application name or <code>null</code>
|
2002-02-14 04:00:59 +00:00
|
|
|
*/
|
2003-02-01 13:28:28 +00:00
|
|
|
public String getApplicationName()
|
|
|
|
|
{
|
2002-02-14 04:00:59 +00:00
|
|
|
return (String) getProperty(PropertyIDMap.PID_APPNAME);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2003-02-01 13:28:28 +00:00
|
|
|
* <p>Returns a security code which is one of the following
|
|
|
|
|
* values:</p>
|
2002-04-26 05:58:00 +00:00
|
|
|
*
|
2003-02-01 13:28:28 +00:00
|
|
|
* <ul>
|
|
|
|
|
* <li>
|
|
|
|
|
* <p>0 if the {@link SummaryInformation} does not contain a
|
|
|
|
|
* security field or if there is no security on the
|
|
|
|
|
* document. Use {@link #wasNull} to distinguish between the
|
|
|
|
|
* two cases!</p>
|
|
|
|
|
* </li>
|
2002-04-26 05:58:00 +00:00
|
|
|
*
|
2003-02-01 13:28:28 +00:00
|
|
|
* <li>
|
|
|
|
|
* <p>1 if the document is password protected</p>
|
|
|
|
|
* </li>
|
2002-04-26 05:58:00 +00:00
|
|
|
*
|
2003-02-01 13:28:28 +00:00
|
|
|
* <li>
|
|
|
|
|
* <p>2 if the document is read-only recommended</p>
|
|
|
|
|
* </li>
|
2002-04-26 05:58:00 +00:00
|
|
|
*
|
2003-02-01 13:28:28 +00:00
|
|
|
* <li>
|
|
|
|
|
* <p>4 if the document is read-only enforced</p>
|
|
|
|
|
* </li>
|
2002-04-26 05:58:00 +00:00
|
|
|
*
|
2003-02-01 13:28:28 +00:00
|
|
|
* <li>
|
|
|
|
|
* <p>8 if the document is locked for annotations</p>
|
|
|
|
|
* </li>
|
2002-04-26 05:58:00 +00:00
|
|
|
*
|
2003-02-01 13:28:28 +00:00
|
|
|
* </ul>
|
2002-04-26 05:58:00 +00:00
|
|
|
*
|
2003-02-01 13:28:28 +00:00
|
|
|
* @return The security code or <code>null</code>
|
2002-02-14 04:00:59 +00:00
|
|
|
*/
|
2003-02-01 13:28:28 +00:00
|
|
|
public int getSecurity()
|
|
|
|
|
{
|
2002-02-14 04:00:59 +00:00
|
|
|
return getPropertyIntValue(PropertyIDMap.PID_SECURITY);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|