001package com.hfg.xml.msofficexml.xlsx.spreadsheetml;
002
003
004
005import com.hfg.util.BooleanUtil;
006import com.hfg.xml.XMLTag;
007import com.hfg.xml.msofficexml.xlsx.Xlsx;
008
009//------------------------------------------------------------------------------
010/**
011 Represents an Office Open XML workbook properties (<ssml:workbookPr>) tag.
012 <div>
013 @author J. Alex Taylor, hairyfatguy.com
014 </div>
015 */
016//------------------------------------------------------------------------------
017// com.hfg XML/HTML Coding Library
018//
019// This library is free software; you can redistribute it and/or
020// modify it under the terms of the GNU Lesser General Public
021// License as published by the Free Software Foundation; either
022// version 2.1 of the License, or (at your option) any later version.
023//
024// This library is distributed in the hope that it will be useful,
025// but WITHOUT ANY WARRANTY; without even the implied warranty of
026// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
027// Lesser General Public License for more details.
028//
029// You should have received a copy of the GNU Lesser General Public
030// License along with this library; if not, write to the Free Software
031// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
032//
033// J. Alex Taylor, President, Founder, CEO, COO, CFO, OOPS hairyfatguy.com
034// jataylor@hairyfatguy.com
035//------------------------------------------------------------------------------
036
037public class SsmlWorkbookProperties extends SsmlXMLTag
038{
039   //##########################################################################
040   // CONSTRUCTORS
041   //##########################################################################
042
043   //---------------------------------------------------------------------------
044   public SsmlWorkbookProperties(Xlsx inXlsx)
045   {
046      super(SsmlXML.WORKBOOK_PROPS, inXlsx);
047
048      setDefaults();
049   }
050
051   //---------------------------------------------------------------------------
052   public SsmlWorkbookProperties(Xlsx inXlsx, XMLTag inPropertiesTag)
053   {
054      this(inXlsx);
055
056      if (inPropertiesTag.hasAttribute(SsmlXML.DATE1904_ATT))
057      {
058         set1904BasedDates(BooleanUtil.valueOf(inPropertiesTag.getAttributeValue(SsmlXML.DATE1904_ATT)));
059      }
060
061      if (inPropertiesTag.hasAttribute(SsmlXML.SHOW_INK_ANNOTATION_ATT))
062      {
063         setShowInkAnnotation(BooleanUtil.valueOf(inPropertiesTag.getAttributeValue(SsmlXML.SHOW_INK_ANNOTATION_ATT)));
064      }
065
066      if (inPropertiesTag.hasAttribute(SsmlXML.AUTO_COMPRESS_PICS_ATT))
067      {
068         setAutoCompressPictures(BooleanUtil.valueOf(inPropertiesTag.getAttributeValue(SsmlXML.AUTO_COMPRESS_PICS_ATT)));
069      }
070
071   }
072
073   //---------------------------------------------------------------------------
074   private void setDefaults()
075   {
076      set1904BasedDates(false);
077      setShowInkAnnotation(false);
078      setAutoCompressPictures(false);
079   }
080
081   //##########################################################################
082   // PUBLIC METHODS
083   //##########################################################################
084
085   //---------------------------------------------------------------------------
086   /**
087    Indicate that our dates are based on 01 Jan 1904 and not 01 Jan 1900.
088    * @param inValue whether or not dates are based on 01 Jan 1904
089    * @return this workbook properties object to enable method chaining
090    */
091   public SsmlWorkbookProperties set1904BasedDates(boolean inValue)
092   {
093      setAttribute(SsmlXML.DATE1904_ATT, inValue ? "1" : "0");
094
095      return this;
096   }
097
098   //---------------------------------------------------------------------------
099   public boolean get1904BasedDates()
100   {
101      return BooleanUtil.valueOf(getAttributeValue(SsmlXML.DATE1904_ATT));
102   }
103
104
105   //---------------------------------------------------------------------------
106   public SsmlWorkbookProperties setShowInkAnnotation(boolean inValue)
107   {
108      setAttribute(SsmlXML.SHOW_INK_ANNOTATION_ATT, inValue ? "1" : "0");
109
110      return this;
111   }
112
113   //---------------------------------------------------------------------------
114   public boolean getShowInkAnnotation()
115   {
116      return BooleanUtil.valueOf(getAttributeValue(SsmlXML.SHOW_INK_ANNOTATION_ATT));
117   }
118
119
120   //---------------------------------------------------------------------------
121   public SsmlWorkbookProperties setAutoCompressPictures(boolean inValue)
122   {
123      setAttribute(SsmlXML.AUTO_COMPRESS_PICS_ATT, inValue ? "1" : "0");
124
125      return this;
126   }
127
128   //---------------------------------------------------------------------------
129   public boolean getAutoCompressPictures()
130   {
131      return BooleanUtil.valueOf(getAttributeValue(SsmlXML.AUTO_COMPRESS_PICS_ATT));
132   }
133}