/* ==================================================================== Licensed To the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for Additional information regarding copyright ownership. The ASF licenses this file To You 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. ==================================================================== */ /* ================================================================ * About NPOI * Author: Tony Qu * Author's email: tonyqus (at) gmail.com * Author's Blog: tonyqus.wordpress.com.cn (wp.tonyqus.cn) * HomePage: http://www.codeplex.com/npoi * Contributors: * * ==============================================================*/ namespace HH.WMS.Utils.NPOI.HPSF { using System; using HH.WMS.Utils.NPOI.HPSF.Wellknown; /// /// Convenience class representing a Summary Information stream in a /// Microsoft Office document. /// @author Rainer Klute /// <klute@rainer-klute.de> /// @see DocumentSummaryInformation /// @since 2002-02-09 /// [Serializable] public class SummaryInformation : SpecialPropertySet { /** * The document name a summary information stream usually has in a POIFS * filesystem. */ public const String DEFAULT_STREAM_NAME = "\x0005SummaryInformation"; public override PropertyIDMap PropertySetIDMap { get { return PropertyIDMap.SummaryInformationProperties; } } /// /// Initializes a new instance of the class. /// /// A property Set which should be Created from a summary /// information stream. public SummaryInformation(PropertySet ps): base(ps) { if (!IsSummaryInformation) throw new UnexpectedPropertySetTypeException("Not a " + GetType().Name); } /// /// Gets or sets the title. /// /// The title. public String Title { get { return (String)GetProperty(PropertyIDMap.PID_TITLE); } set { MutableSection s = (MutableSection)FirstSection; s.SetProperty(PropertyIDMap.PID_TITLE, value); } } /// /// Removes the title. /// public void RemoveTitle() { MutableSection s = (MutableSection)FirstSection; s.RemoveProperty(PropertyIDMap.PID_TITLE); } /// /// Gets or sets the subject. /// /// The subject. public String Subject { get { return (String)GetProperty(PropertyIDMap.PID_SUBJECT); } set { MutableSection s = (MutableSection)FirstSection; s.SetProperty(PropertyIDMap.PID_SUBJECT, value); } } /// /// Removes the subject. /// public void RemoveSubject() { MutableSection s = (MutableSection)FirstSection; s.RemoveProperty(PropertyIDMap.PID_SUBJECT); } /// /// Gets or sets the author. /// /// The author. public String Author { get { return (String)GetProperty(PropertyIDMap.PID_AUTHOR); } set { MutableSection s = (MutableSection)FirstSection; s.SetProperty(PropertyIDMap.PID_AUTHOR, value); } } /// /// Removes the author. /// public void RemoveAuthor() { MutableSection s = (MutableSection)FirstSection; s.RemoveProperty(PropertyIDMap.PID_AUTHOR); } /// /// Gets or sets the keywords. /// /// The keywords. public String Keywords { get { return (String)GetProperty(PropertyIDMap.PID_KEYWORDS); } set { MutableSection s = (MutableSection)FirstSection; s.SetProperty(PropertyIDMap.PID_KEYWORDS, value); } } /// /// Removes the keywords. /// public void RemoveKeywords() { MutableSection s = (MutableSection)FirstSection; s.RemoveProperty(PropertyIDMap.PID_KEYWORDS); } /// /// Gets or sets the comments. /// /// The comments. public String Comments { get { return (String)GetProperty(PropertyIDMap.PID_COMMENTS); } set { MutableSection s = (MutableSection)FirstSection; s.SetProperty(PropertyIDMap.PID_COMMENTS, value); } } /// /// Removes the comments. /// public void RemoveComments() { MutableSection s = (MutableSection)FirstSection; s.RemoveProperty(PropertyIDMap.PID_COMMENTS); } /// /// Gets or sets the template. /// /// The template. public String Template { get { return (String)GetProperty(PropertyIDMap.PID_TEMPLATE); } set { MutableSection s = (MutableSection)FirstSection; s.SetProperty(PropertyIDMap.PID_TEMPLATE, value); } } /// /// Removes the template. /// public void RemoveTemplate() { MutableSection s = (MutableSection)FirstSection; s.RemoveProperty(PropertyIDMap.PID_TEMPLATE); } /// /// Gets or sets the last author. /// /// The last author. public String LastAuthor { get{return (String)GetProperty(PropertyIDMap.PID_LASTAUTHOR);} set { MutableSection s = (MutableSection)FirstSection; s.SetProperty(PropertyIDMap.PID_LASTAUTHOR, value); } } /// /// Removes the last author. /// public void RemoveLastAuthor() { MutableSection s = (MutableSection)FirstSection; s.RemoveProperty(PropertyIDMap.PID_LASTAUTHOR); } /// /// Gets or sets the rev number. /// /// The rev number. public String RevNumber { get { return (String)GetProperty(PropertyIDMap.PID_REVNUMBER); } set { MutableSection s = (MutableSection)FirstSection; s.SetProperty(PropertyIDMap.PID_REVNUMBER, value); } } /// /// Removes the rev number. /// public void RemoveRevNumber() { MutableSection s = (MutableSection)FirstSection; s.RemoveProperty(PropertyIDMap.PID_REVNUMBER); } /// /// Returns the Total time spent in editing the document (or 0). /// /// The Total time spent in editing the document or 0 if the {@link /// SummaryInformation} does not contain this information. public long EditTime { get { if (GetProperty(PropertyIDMap.PID_EDITTIME) == null) return 0; else { DateTime d = (DateTime)GetProperty(PropertyIDMap.PID_EDITTIME); return Util.DateToFileTime(d); } } set { DateTime d = Util.FiletimeToDate(value); MutableSection s = (MutableSection)FirstSection; s.SetProperty(PropertyIDMap.PID_EDITTIME, Variant.VT_FILETIME, d); } } /// /// Removes the edit time. /// public void RemoveEditTime() { MutableSection s = (MutableSection)FirstSection; s.RemoveProperty(PropertyIDMap.PID_EDITTIME); } /// /// Gets or sets the last printed time /// /// The last printed time /// Returns the last printed time (or null). public DateTime? LastPrinted { get { return (DateTime?)GetProperty(PropertyIDMap.PID_LASTPRINTED); } set { MutableSection s = (MutableSection)FirstSection; s.SetProperty(PropertyIDMap.PID_LASTPRINTED, Variant.VT_FILETIME, value); } } /// /// Removes the last printed. /// public void RemoveLastPrinted() { MutableSection s = (MutableSection)FirstSection; s.RemoveProperty(PropertyIDMap.PID_LASTPRINTED); } /// /// Gets or sets the create date time. /// /// The create date time. public DateTime? CreateDateTime { get { return (DateTime?)GetProperty(PropertyIDMap.PID_Create_DTM); } set { MutableSection s = (MutableSection)FirstSection; s.SetProperty(PropertyIDMap.PID_Create_DTM, Variant.VT_FILETIME, value); } } /// /// Removes the create date time. /// public void RemoveCreateDateTime() { MutableSection s = (MutableSection)FirstSection; s.RemoveProperty(PropertyIDMap.PID_Create_DTM); } /// /// Gets or sets the last save date time. /// /// The last save date time. public DateTime? LastSaveDateTime { get { return (DateTime?)GetProperty(PropertyIDMap.PID_LASTSAVE_DTM); } set { MutableSection s = (MutableSection)FirstSection; s.SetProperty(PropertyIDMap.PID_LASTSAVE_DTM, Variant.VT_FILETIME, value); } } /// /// Removes the last save date time. /// public void RemoveLastSaveDateTime() { MutableSection s = (MutableSection)FirstSection; s.RemoveProperty(PropertyIDMap.PID_LASTSAVE_DTM); } /// /// Gets or sets the page count or 0 if the {@link SummaryInformation} does /// not contain a page count. /// /// The page count or 0 if the {@link SummaryInformation} does not /// contain a page count. public int PageCount { get { return GetPropertyIntValue(PropertyIDMap.PID_PAGECOUNT); } set { MutableSection s = (MutableSection)FirstSection; s.SetProperty(PropertyIDMap.PID_PAGECOUNT, value); } } /// /// Removes the page count. /// public void RemovePageCount() { MutableSection s = (MutableSection)FirstSection; s.RemoveProperty(PropertyIDMap.PID_PAGECOUNT); } /// /// Gets or sets the word count or 0 if the {@link SummaryInformation} does /// not contain a word count. /// /// The word count. public int WordCount { get { return GetPropertyIntValue(PropertyIDMap.PID_WORDCOUNT); } set { MutableSection s = (MutableSection)FirstSection; s.SetProperty(PropertyIDMap.PID_WORDCOUNT, value); } } /// /// Removes the word count. /// public void RemoveWordCount() { MutableSection s = (MutableSection)FirstSection; s.RemoveProperty(PropertyIDMap.PID_WORDCOUNT); } /// /// Gets or sets the character count or 0 if the {@link SummaryInformation} /// does not contain a char count. /// /// The character count. public int CharCount { get{return GetPropertyIntValue(PropertyIDMap.PID_CHARCOUNT);} set { MutableSection s = (MutableSection)FirstSection; s.SetProperty(PropertyIDMap.PID_CHARCOUNT, value); } } /// /// Removes the char count. /// public void RemoveCharCount() { MutableSection s = (MutableSection)FirstSection; s.RemoveProperty(PropertyIDMap.PID_CHARCOUNT); } /// /// Gets or sets the thumbnail (or null) when this /// method is implemented. Please note that the return type is likely To /// Change! /// Hint To developers: Drew Varner <Drew.Varner /// -at- sc.edu> said that this is an image in WMF or Clipboard (BMP?) /// format. However, we won't do any conversion into any image type but /// instead just return a byte array. /// /// The thumbnail. public byte[] Thumbnail { get{return (byte[])GetProperty(PropertyIDMap.PID_THUMBNAIL);} set { MutableSection s = (MutableSection)FirstSection; s.SetProperty(PropertyIDMap.PID_THUMBNAIL, /* FIXME: */ Variant.VT_LPSTR, value); } } /// /// Removes the thumbnail. /// public void RemoveThumbnail() { MutableSection s = (MutableSection)FirstSection; s.RemoveProperty(PropertyIDMap.PID_THUMBNAIL); } /// /// Gets or sets the name of the application. /// /// The name of the application. public String ApplicationName { get { return (String)GetProperty(PropertyIDMap.PID_APPNAME); } set { MutableSection s = (MutableSection)FirstSection; s.SetProperty(PropertyIDMap.PID_APPNAME, value); } } /// /// Removes the name of the application. /// public void RemoveApplicationName() { MutableSection s = (MutableSection)FirstSection; s.RemoveProperty(PropertyIDMap.PID_APPNAME); } /// /// Gets or sets a security code which is one of the following values: /// /// /// The security code public int Security { get { return GetPropertyIntValue(PropertyIDMap.PID_SECURITY); } set { MutableSection s = (MutableSection)FirstSection; s.SetProperty(PropertyIDMap.PID_SECURITY, value); } } /// /// Removes the security code. /// public void RemoveSecurity() { MutableSection s = (MutableSection)FirstSection; s.RemoveProperty(PropertyIDMap.PID_SECURITY); } } }