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      /**
107       * Constructs a SheetProperties record and sets its fields appropriately.
108       *
109       * @param id    id must be 0x1044 or an exception
110       *              will be throw upon validation
111       * @param size  size the size of the data area of the record
112       * @param data  data of the record (should not contain sid/len)
113       * @param offset of the record's data
114       */
115  
116      public SheetPropertiesRecord(short id, short size, byte [] data, int offset)
117      {
118          super(id, size, data, offset);
119      
120      }
121  
122      /**
123       * Checks the sid matches the expected side for this record
124       *
125       * @param id   the expected sid.
126       */
127      protected void validateSid(short id)
128      {
129          if (id != sid)
130          {
131              throw new RecordFormatException("Not a SheetProperties record");
132          }
133      }
134  
135      protected void fillFields(byte [] data, short size, int offset)
136      {
137  
138          int pos = 0;
139          field_1_flags                  = LittleEndian.getShort(data, pos + 0x0 + offset);
140          field_2_empty                  = data[ pos + 0x2 + offset ];
141  
142      }
143  
144      public String toString()
145      {
146          StringBuffer buffer = new StringBuffer();
147  
148          buffer.append("[SHTPROPS]\n");
149          buffer.append("    .flags                = ")
150              .append("0x").append(HexDump.toHex(  getFlags ()))
151              .append(" (").append( getFlags() ).append(" )");
152          buffer.append(System.getProperty("line.separator")); 
153          buffer.append("         .chartTypeManuallyFormatted     = ").append(isChartTypeManuallyFormatted()).append('\n'); 
154          buffer.append("         .plotVisibleOnly          = ").append(isPlotVisibleOnly()).append('\n'); 
155          buffer.append("         .doNotSizeWithWindow      = ").append(isDoNotSizeWithWindow()).append('\n'); 
156          buffer.append("         .defaultPlotDimensions     = ").append(isDefaultPlotDimensions()).append('\n'); 
157          buffer.append("         .autoPlotArea             = ").append(isAutoPlotArea()).append('\n'); 
158          buffer.append("    .empty                = ")
159              .append("0x").append(HexDump.toHex(  getEmpty ()))
160              .append(" (").append( getEmpty() ).append(" )");
161          buffer.append(System.getProperty("line.separator")); 
162  
163          buffer.append("[/SHTPROPS]\n");
164          return buffer.toString();
165      }
166  
167      public int serialize(int offset, byte[] data)
168      {
169          int pos = 0;
170  
171          LittleEndian.putShort(data, 0 + offset, sid);
172          LittleEndian.putShort(data, 2 + offset, (short)(getRecordSize() - 4));
173  
174          LittleEndian.putShort(data, 4 + offset + pos, field_1_flags);
175          data[ 6 + offset + pos ] = field_2_empty;
176  
177          return getRecordSize();
178      }
179  
180      /**
181       * Size of record (exluding 4 byte header)
182       */
183      public int getRecordSize()
184      {
185          return 4  + 2 + 1;
186      }
187  
188      public short getSid()
189      {
190          return this.sid;
191      }
192  
193      public Object clone() {
194          SheetPropertiesRecord rec = new SheetPropertiesRecord();
195      
196          rec.field_1_flags = field_1_flags;
197          rec.field_2_empty = field_2_empty;
198          return rec;
199      }
200  
201  
202  
203  
204      /**
205       * Get the flags field for the SheetProperties record.
206       */
207      public short getFlags()
208      {
209          return field_1_flags;
210      }
211  
212      /**
213       * Set the flags field for the SheetProperties record.
214       */
215      public void setFlags(short field_1_flags)
216      {
217          this.field_1_flags = field_1_flags;
218      }
219  
220      /**
221       * Get the empty field for the SheetProperties record.
222       *
223       * @return  One of 
224       *        EMPTY_NOT_PLOTTED
225       *        EMPTY_ZERO
226       *        EMPTY_INTERPOLATED
227       */
228      public byte getEmpty()
229      {
230          return field_2_empty;
231      }
232  
233      /**
234       * Set the empty field for the SheetProperties record.
235       *
236       * @param field_2_empty
237       *        One of 
238       *        EMPTY_NOT_PLOTTED
239       *        EMPTY_ZERO
240       *        EMPTY_INTERPOLATED
241       */
242      public void setEmpty(byte field_2_empty)
243      {
244          this.field_2_empty = field_2_empty;
245      }
246  
247      /**
248       * Sets the chart type manually formatted field value.
249       * Has the chart type been manually formatted?
250       */
251      public void setChartTypeManuallyFormatted(boolean value)
252      {
253          field_1_flags = chartTypeManuallyFormatted.setShortBoolean(field_1_flags, value);
254      }
255  
256      /**
257       * Has the chart type been manually formatted?
258       * @return  the chart type manually formatted field value.
259       */
260      public boolean isChartTypeManuallyFormatted()
261      {
262          return chartTypeManuallyFormatted.isSet(field_1_flags);
263      }
264  
265      /**
266       * Sets the plot visible only field value.
267       * Only show visible cells on the chart.
268       */
269      public void setPlotVisibleOnly(boolean value)
270      {
271          field_1_flags = plotVisibleOnly.setShortBoolean(field_1_flags, value);
272      }
273  
274      /**
275       * Only show visible cells on the chart.
276       * @return  the plot visible only field value.
277       */
278      public boolean isPlotVisibleOnly()
279      {
280          return plotVisibleOnly.isSet(field_1_flags);
281      }
282  
283      /**
284       * Sets the do not size with window field value.
285       * Do not size the chart when the window changes size
286       */
287      public void setDoNotSizeWithWindow(boolean value)
288      {
289          field_1_flags = doNotSizeWithWindow.setShortBoolean(field_1_flags, value);
290      }
291  
292      /**
293       * Do not size the chart when the window changes size
294       * @return  the do not size with window field value.
295       */
296      public boolean isDoNotSizeWithWindow()
297      {
298          return doNotSizeWithWindow.isSet(field_1_flags);
299      }
300  
301      /**
302       * Sets the default plot dimensions field value.
303       * Indicates that the default area dimensions should be used.
304       */
305      public void setDefaultPlotDimensions(boolean value)
306      {
307          field_1_flags = defaultPlotDimensions.setShortBoolean(field_1_flags, value);
308      }
309  
310      /**
311       * Indicates that the default area dimensions should be used.
312       * @return  the default plot dimensions field value.
313       */
314      public boolean isDefaultPlotDimensions()
315      {
316          return defaultPlotDimensions.isSet(field_1_flags);
317      }
318  
319      /**
320       * Sets the auto plot area field value.
321       * ??
322       */
323      public void setAutoPlotArea(boolean value)
324      {
325          field_1_flags = autoPlotArea.setShortBoolean(field_1_flags, value);
326      }
327  
328      /**
329       * ??
330       * @return  the auto plot area field value.
331       */
332      public boolean isAutoPlotArea()
333      {
334          return autoPlotArea.isSet(field_1_flags);
335      }
336  
337  
338  }  // END OF CLASS
339  
340  
341  
342  
343