1    
2    /* ====================================================================
3     * The Apache Software License, Version 1.1
4     *
5     * Copyright (c) 2002 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" and
28    *    "Apache POI" must not be used to endorse or promote products
29    *    derived from this software without prior written permission. For
30    *    written permission, please contact apache@apache.org.
31    *
32    * 5. Products derived from this software may not be called "Apache",
33    *    "Apache POI", nor may "Apache" appear in their name, without
34    *    prior written 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   
56   
57   package org.apache.poi.hssf.record;
58   
59   
60   
61   import org.apache.poi.util.*;
62   
63   /**
64    * Describes a chart sheet properties record.
65    * NOTE: This source is automatically generated please do not modify this file.  Either subclass or
66    *       remove the record in src/records/definitions.
67   
68    * @author Glen Stampoultzis (glens at apache.org)
69    */
70   public class SheetPropertiesRecord
71       extends Record
72   {
73       public final static short      sid                             = 0x1044;
74       private  short      field_1_flags;
75       private  BitField   chartTypeManuallyFormatted                  = new BitField(0x1);
76       private  BitField   plotVisibleOnly                             = new BitField(0x2);
77       private  BitField   doNotSizeWithWindow                         = new BitField(0x4);
78       private  BitField   defaultPlotDimensions                       = new BitField(0x8);
79       private  BitField   autoPlotArea                                = new BitField(0x10);
80       private  byte       field_2_empty;
81       public final static byte        EMPTY_NOT_PLOTTED              = 0;
82       public final static byte        EMPTY_ZERO                     = 1;
83       public final static byte        EMPTY_INTERPOLATED             = 2;
84   
85   
86       public SheetPropertiesRecord()
87       {
88   
89       }
90   
91       /**
92        * Constructs a SheetProperties record and sets its fields appropriately.
93        *
94        * @param id    id must be 0x1044 or an exception
95        *              will be throw upon validation
96        * @param size  size the size of the data area of the record
97        * @param data  data of the record (should not contain sid/len)
98        */
99   
100      public SheetPropertiesRecord(short id, short size, byte [] data)
101      {
102          super(id, size, data);
103      }
104  
105      /**
106       * Constructs a SheetProperties record and sets its fields appropriately.
107       *
108       * @param id    id must be 0x1044 or an exception
109       *              will be throw upon validation
110       * @param size  size the size of the data area of the record
111       * @param data  data of the record (should not contain sid/len)
112       * @param offset of the record's data
113       */
114  
115      public SheetPropertiesRecord(short id, short size, byte [] data, int offset)
116      {
117          super(id, size, data, offset);
118      }
119  
120      /**
121       * Checks the sid matches the expected side for this record
122       *
123       * @param id   the expected sid.
124       */
125      protected void validateSid(short id)
126      {
127          if (id != sid)
128          {
129              throw new RecordFormatException("Not a SheetProperties record");
130          }
131      }
132  
133      protected void fillFields(byte [] data, short size, int offset)
134      {
135          field_1_flags                   = LittleEndian.getShort(data, 0x0 + offset);
136          field_2_empty                   = data[ 0x2 + offset ];
137  
138      }
139  
140      public String toString()
141      {
142          StringBuffer buffer = new StringBuffer();
143  
144          buffer.append("[SheetProperties]\n");
145  
146          buffer.append("    .flags                = ")
147              .append("0x")
148              .append(HexDump.toHex((short)getFlags()))
149              .append(" (").append(getFlags()).append(" )\n");
150          buffer.append("         .chartTypeManuallyFormatted     = ").append(isChartTypeManuallyFormatted()).append('\n');
151          buffer.append("         .plotVisibleOnly          = ").append(isPlotVisibleOnly     ()).append('\n');
152          buffer.append("         .doNotSizeWithWindow      = ").append(isDoNotSizeWithWindow ()).append('\n');
153          buffer.append("         .defaultPlotDimensions     = ").append(isDefaultPlotDimensions()).append('\n');
154          buffer.append("         .autoPlotArea             = ").append(isAutoPlotArea        ()).append('\n');
155  
156          buffer.append("    .empty                = ")
157              .append("0x")
158              .append(HexDump.toHex((byte)getEmpty()))
159              .append(" (").append(getEmpty()).append(" )\n");
160  
161          buffer.append("[/SheetProperties]\n");
162          return buffer.toString();
163      }
164  
165      public int serialize(int offset, byte[] data)
166      {
167          LittleEndian.putShort(data, 0 + offset, sid);
168          LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
169  
170          LittleEndian.putShort(data, 4 + offset, field_1_flags);
171          data[ 6 + offset ] = field_2_empty;
172  
173          return getRecordSize();
174      }
175  
176      /**
177       * Size of record (exluding 4 byte header)
178       */
179      public int getRecordSize()
180      {
181          return 4 + 2 + 1;
182      }
183  
184      public short getSid()
185      {
186          return this.sid;
187      }
188  
189      public Object clone() {
190        SheetPropertiesRecord rec = new SheetPropertiesRecord();
191        
192        rec.field_1_flags = field_1_flags;
193        rec.field_2_empty = field_2_empty;
194  
195        return rec;
196      }
197  
198  
199      /**
200       * Get the flags field for the SheetProperties record.
201       */
202      public short getFlags()
203      {
204          return field_1_flags;
205      }
206  
207      /**
208       * Set the flags field for the SheetProperties record.
209       */
210      public void setFlags(short field_1_flags)
211      {
212          this.field_1_flags = field_1_flags;
213      }
214  
215      /**
216       * Get the empty field for the SheetProperties record.
217       *
218       * @return  One of 
219       *        EMPTY_NOT_PLOTTED
220       *        EMPTY_ZERO
221       *        EMPTY_INTERPOLATED
222       */
223      public byte getEmpty()
224      {
225          return field_2_empty;
226      }
227  
228      /**
229       * Set the empty field for the SheetProperties record.
230       *
231       * @param field_2_empty
232       *        One of 
233       *        EMPTY_NOT_PLOTTED
234       *        EMPTY_ZERO
235       *        EMPTY_INTERPOLATED
236       */
237      public void setEmpty(byte field_2_empty)
238      {
239          this.field_2_empty = field_2_empty;
240      }
241  
242      /**
243       * Sets the chart type manually formatted field value.
244       * Has the chart type been manually formatted?
245       */
246      public void setChartTypeManuallyFormatted(boolean value)
247      {
248          field_1_flags = chartTypeManuallyFormatted.setShortBoolean(field_1_flags, value);
249      }
250  
251      /**
252       * Has the chart type been manually formatted?
253       * @return  the chart type manually formatted field value.
254       */
255      public boolean isChartTypeManuallyFormatted()
256      {
257          return chartTypeManuallyFormatted.isSet(field_1_flags);
258      }
259  
260      /**
261       * Sets the plot visible only field value.
262       * Only show visible cells on the chart.
263       */
264      public void setPlotVisibleOnly(boolean value)
265      {
266          field_1_flags = plotVisibleOnly.setShortBoolean(field_1_flags, value);
267      }
268  
269      /**
270       * Only show visible cells on the chart.
271       * @return  the plot visible only field value.
272       */
273      public boolean isPlotVisibleOnly()
274      {
275          return plotVisibleOnly.isSet(field_1_flags);
276      }
277  
278      /**
279       * Sets the do not size with window field value.
280       * Do not size the chart when the window changes size
281       */
282      public void setDoNotSizeWithWindow(boolean value)
283      {
284          field_1_flags = doNotSizeWithWindow.setShortBoolean(field_1_flags, value);
285      }
286  
287      /**
288       * Do not size the chart when the window changes size
289       * @return  the do not size with window field value.
290       */
291      public boolean isDoNotSizeWithWindow()
292      {
293          return doNotSizeWithWindow.isSet(field_1_flags);
294      }
295  
296      /**
297       * Sets the default plot dimensions field value.
298       * Indicates that the default area dimensions should be used.
299       */
300      public void setDefaultPlotDimensions(boolean value)
301      {
302          field_1_flags = defaultPlotDimensions.setShortBoolean(field_1_flags, value);
303      }
304  
305      /**
306       * Indicates that the default area dimensions should be used.
307       * @return  the default plot dimensions field value.
308       */
309      public boolean isDefaultPlotDimensions()
310      {
311          return defaultPlotDimensions.isSet(field_1_flags);
312      }
313  
314      /**
315       * Sets the auto plot area field value.
316       * ??
317       */
318      public void setAutoPlotArea(boolean value)
319      {
320          field_1_flags = autoPlotArea.setShortBoolean(field_1_flags, value);
321      }
322  
323      /**
324       * ??
325       * @return  the auto plot area field value.
326       */
327      public boolean isAutoPlotArea()
328      {
329          return autoPlotArea.isSet(field_1_flags);
330      }
331  
332  
333  }  // END OF CLASS
334  
335  
336  
337  
338