1    /*
2     *  ====================================================================
3     *  The Apache Software License, Version 1.1
4     *
5     *  Copyright (c) 2000 The Apache Software Foundation.  All rights
6     *  reserved.
7     *
8     *  Redistribution and use in source and binary forms, with or without
9     *  modification, are permitted provided that the following conditions
10    *  are met:
11    *
12    *  1. Redistributions of source code must retain the above copyright
13    *  notice, this list of conditions and the following disclaimer.
14    *
15    *  2. Redistributions in binary form must reproduce the above copyright
16    *  notice, this list of conditions and the following disclaimer in
17    *  the documentation and/or other materials provided with the
18    *  distribution.
19    *
20    *  3. The end-user documentation included with the redistribution,
21    *  if any, must include the following acknowledgment:
22    *  "This product includes software developed by the
23    *  Apache Software Foundation (http://www.apache.org/)."
24    *  Alternately, this acknowledgment may appear in the software itself,
25    *  if and wherever such third-party acknowledgments normally appear.
26    *
27    *  4. The names "Apache" and "Apache Software Foundation" must
28    *  not be used to endorse or promote products derived from this
29    *  software without prior written permission. For written
30    *  permission, please contact apache@apache.org.
31    *
32    *  5. Products derived from this software may not be called "Apache",
33    *  nor may "Apache" appear in their name, without prior written
34    *  permission of the Apache Software Foundation.
35    *
36    *  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
37    *  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
38    *  OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
39    *  DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
40    *  ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
41    *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
42    *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
43    *  USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
44    *  ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
45    *  OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
46    *  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
47    *  SUCH DAMAGE.
48    *  ====================================================================
49    *
50    *  This software consists of voluntary contributions made by many
51    *  individuals on behalf of the Apache Software Foundation.  For more
52    *  information on the Apache Software Foundation, please see
53    *  <http://www.apache.org/>.
54    *
55    *  Portions of this software are based upon public domain software
56    *  originally written at the National Center for Supercomputing Applications,
57    *  University of Illinois, Urbana-Champaign.
58    */
59   package org.apache.poi.hpsf;
60   
61   import java.io.*;
62   import java.util.*;
63   import org.apache.poi.hpsf.wellknown.*;
64   
65   /**
66    *  <p>
67    *
68    *  Convenience class representing a Summary Information stream in a Microsoft
69    *  Office document.</p> <p>
70    *
71    *  See <a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/stgu_8910.asp">
72    *  http://msdn.microsoft.com/library/default.asp?url=/library/en-us/com/stgu_8910.asp
73    *  </a> for documentation from That Redmond Company.
74    *
75    *@author     Rainer Klute (klute@rainer-klute.de)
76    *@created    May 10, 2002
77    *@see        DocumentSummaryInformation
78    *@version    $Id: SummaryInformation.java,v 1.7 2002/05/11 14:47:23 acoliver Exp $
79    *@since      2002-02-09
80    */
81   public class SummaryInformation extends SpecialPropertySet {
82   
83       /**
84        *  <p>
85        *
86        *  Creates a {@link SummaryInformation} from a given {@link PropertySet}.
87        *  </p>
88        *
89        *@param  ps                                      A property set which
90        *      should be created from a summary information stream.
91        *@exception  UnexpectedPropertySetTypeException  Description of the
92        *      Exception
93        *@throws  UnexpectedPropertySetTypeException     if <var>ps</var> does not
94        *      contain a summary information stream.
95        */
96       public SummaryInformation(final PropertySet ps)
97                throws UnexpectedPropertySetTypeException {
98           super(ps);
99           if (!isSummaryInformation()) {
100              throw new UnexpectedPropertySetTypeException
101                      ("Not a " + getClass().getName());
102          }
103      }
104  
105  
106  
107      /**
108       *  <p>
109       *
110       *  Returns the stream's title (or <code>null</code>).</p>
111       *
112       *@return    The title value
113       */
114      public String getTitle() {
115          return (String) getProperty(PropertyIDMap.PID_TITLE);
116      }
117  
118  
119  
120      /**
121       *  <p>
122       *
123       *  Returns the stream's subject (or <code>null</code>).</p>
124       *
125       *@return    The subject value
126       */
127      public String getSubject() {
128          return (String) getProperty(PropertyIDMap.PID_SUBJECT);
129      }
130  
131  
132  
133      /**
134       *  <p>
135       *
136       *  Returns the stream's author (or <code>null</code>).</p>
137       *
138       *@return    The author value
139       */
140      public String getAuthor() {
141          return (String) getProperty(PropertyIDMap.PID_AUTHOR);
142      }
143  
144  
145  
146      /**
147       *  <p>
148       *
149       *  Returns the stream's keywords (or <code>null</code>).</p>
150       *
151       *@return    The keywords value
152       */
153      public String getKeywords() {
154          return (String) getProperty(PropertyIDMap.PID_KEYWORDS);
155      }
156  
157  
158  
159      /**
160       *  <p>
161       *
162       *  Returns the stream's comments (or <code>null</code>).</p>
163       *
164       *@return    The comments value
165       */
166      public String getComments() {
167          return (String) getProperty(PropertyIDMap.PID_COMMENTS);
168      }
169  
170  
171  
172      /**
173       *  <p>
174       *
175       *  Returns the stream's template (or <code>null</code>).</p>
176       *
177       *@return    The template value
178       */
179      public String getTemplate() {
180          return (String) getProperty(PropertyIDMap.PID_TEMPLATE);
181      }
182  
183  
184  
185      /**
186       *  <p>
187       *
188       *  Returns the stream's last author (or <code>null</code>).</p>
189       *
190       *@return    The lastAuthor value
191       */
192      public String getLastAuthor() {
193          return (String) getProperty(PropertyIDMap.PID_LASTAUTHOR);
194      }
195  
196  
197  
198      /**
199       *  <p>
200       *
201       *  Returns the stream's revision number (or <code>null</code>). </p>
202       *
203       *@return    The revNumber value
204       */
205      public String getRevNumber() {
206          return (String) getProperty(PropertyIDMap.PID_REVNUMBER);
207      }
208  
209  
210  
211      /**
212       *  <p>
213       *
214       *  Returns the stream's edit time (or <code>null</code>).</p>
215       *
216       *@return    The editTime value
217       */
218      public Date getEditTime() {
219          return (Date) getProperty(PropertyIDMap.PID_EDITTIME);
220      }
221  
222  
223  
224      /**
225       *  <p>
226       *
227       *  Returns the stream's last printed time (or <code>null</code>).</p>
228       *
229       *@return    The lastPrinted value
230       */
231      public Date getLastPrinted() {
232          return (Date) getProperty(PropertyIDMap.PID_LASTPRINTED);
233      }
234  
235  
236  
237      /**
238       *  <p>
239       *
240       *  Returns the stream's creation time (or <code>null</code>).</p>
241       *
242       *@return    The createDateTime value
243       */
244      public Date getCreateDateTime() {
245          return (Date) getProperty(PropertyIDMap.PID_CREATE_DTM);
246      }
247  
248  
249  
250      /**
251       *  <p>
252       *
253       *  Returns the stream's last save time (or <code>null</code>).</p>
254       *
255       *@return    The lastSaveDateTime value
256       */
257      public Date getLastSaveDateTime() {
258          return (Date) getProperty(PropertyIDMap.PID_LASTSAVE_DTM);
259      }
260  
261  
262  
263      /**
264       *  <p>
265       *
266       *  Returns the stream's page count or 0 if the {@link SummaryInformation}
267       *  does not contain a page count.</p>
268       *
269       *@return    The pageCount value
270       */
271      public int getPageCount() {
272          return getPropertyIntValue(PropertyIDMap.PID_PAGECOUNT);
273      }
274  
275  
276  
277      /**
278       *  <p>
279       *
280       *  Returns the stream's word count or 0 if the {@link SummaryInformation}
281       *  does not contain a word count.</p>
282       *
283       *@return    The wordCount value
284       */
285      public int getWordCount() {
286          return getPropertyIntValue(PropertyIDMap.PID_WORDCOUNT);
287      }
288  
289  
290  
291      /**
292       *  <p>
293       *
294       *  Returns the stream's char count or 0 if the {@link SummaryInformation}
295       *  does not contain a char count.</p>
296       *
297       *@return    The charCount value
298       */
299      public int getCharCount() {
300          return getPropertyIntValue(PropertyIDMap.PID_CHARCOUNT);
301      }
302  
303  
304  
305      /**
306       *  <p>
307       *
308       *  Returns the stream's thumbnail (or <code>null</code>) <strong>when this
309       *  method is implemented. Please note that the return type is likely to
310       *  change!</strong> <p>
311       *
312       *  <strong>FIXME / Hint to developers:</strong> Drew Varner <Drew.Varner
313       *  -at- sc.edu> said that this is an image in WMF or Clipboard (BMP?)
314       *  format. He also provided two links that might be helpful: <a
315       *  href="http://www.csn.ul.ie/~caolan/publink/file/OLE2SummaryAgainst_file-3.27.patch"
316       *  target="_blank">http://www.csn.ul.ie/~caolan/publink/file/OLE2SummaryAgainst_file-3.27.patch
317       *  </a> and <a href="http://msdn.microsoft.com/library/en-us/dno97ta/html/msdn_docprop.asp"
318       *  target="_blank">http://msdn.microsoft.com/library/en-us/dno97ta/html/msdn_docprop.asp
319       *  </a>. However, we won't do any conversion into any image type but
320       *  instead just return a byte array.</p>
321       *
322       *@return    The thumbnail value
323       */
324      public byte[] getThumbnail() {
325          return (byte[]) getProperty(PropertyIDMap.PID_THUMBNAIL);
326      }
327  
328  
329  
330      /**
331       *  <p>
332       *
333       *  Returns the stream's application name (or <code>null</code>).</p>
334       *
335       *@return    The applicationName value
336       */
337      public String getApplicationName() {
338          return (String) getProperty(PropertyIDMap.PID_APPNAME);
339      }
340  
341  
342  
343      /**
344       *  <p>
345       *
346       *  Returns one of the following values:</p>
347       *  <ul>
348       *    <li> <p>
349       *
350       *    0 if the {@link SummaryInformation} does not contain a security field
351       *    or if there is no security on the document. Use {@link #wasNull} to
352       *    distinguish between the two cases!</p> </li>
353       *    <li> <p>
354       *
355       *    1 if the document is password protected</p> </li>
356       *    <li> <p>
357       *
358       *    2 if the document is read-only recommended</p> </li>
359       *    <li> <p>
360       *
361       *    4 if the document is read-only enforced</p> </li>
362       *    <li> <p>
363       *
364       *    8 if the document is locked for annotations</p> </li>
365       *  </ul>
366       *
367       *
368       *@return    The security value
369       */
370      public int getSecurity() {
371          return getPropertyIntValue(PropertyIDMap.PID_SECURITY);
372      }
373  
374  }
375