KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jxl > write > biff > CalcModeRecord


1 /*********************************************************************
2 *
3 * Copyright (C) 2002 Andrew Khan
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 ***************************************************************************/

19
20 package jxl.write.biff;
21
22 import jxl.biff.Type;
23 import jxl.biff.IntegerHelper;
24 import jxl.biff.StringHelper;
25 import jxl.biff.WritableRecordData;
26
27 /**
28  * The calculation mode for the workbook, as set from the Options
29  * dialog box
30  */

31 class CalcModeRecord extends WritableRecordData
32 {
33   /**
34    * The calculation mode (manual, automatic)
35    */

36   private CalcMode calculationMode;
37
38   private static class CalcMode
39   {
40     /**
41      * The indicator as written to the output file
42      */

43     int value;
44
45     /**
46      * Constructor
47      *
48      * @param m
49      */

50     public CalcMode(int m)
51     {
52       value = m;
53     }
54   }
55
56   /**
57    * Manual calculation
58    */

59   static CalcMode manual = new CalcMode(0);
60   /**
61    * Automatic calculation
62    */

63   static CalcMode automatic = new CalcMode(1);
64   /**
65    * Automatic calculation, except tables
66    */

67   static CalcMode automaticNoTables = new CalcMode(-1);
68   
69   /**
70    * Constructor
71    *
72    * @param cm the calculation mode
73    */

74   public CalcModeRecord(CalcMode cm)
75   {
76     super(Type.CALCMODE);
77     calculationMode = cm;
78   }
79
80
81   /**
82    * Gets the binary to data to write to the output file
83    *
84    * @return the binary data
85    */

86   public byte[] getData()
87   {
88     byte[] data = new byte[2];
89     
90     IntegerHelper.getTwoBytes(calculationMode.value, data, 0);
91
92     return data;
93   }
94 }
95
96
97
Popular Tags