KickJava   Java API By Example, From Geeks To Geeks.

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


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  * Record which stores the sheet name, the sheet type and the stream
29  * position
30  */

31 class BoundsheetRecord extends WritableRecordData
32 {
33   /**
34    * Hidden flag
35    */

36   private boolean hidden;
37
38   /**
39    * Chart only flag
40    */

41   private boolean chartOnly;
42
43   /**
44    * The name of the sheet
45    */

46   private String JavaDoc name;
47
48   /**
49    * The data to write to the output file
50    */

51   private byte[] data;
52
53   /**
54    * Constructor
55    *
56    * @param n the sheet name
57    */

58   public BoundsheetRecord(String JavaDoc n)
59   {
60     super(Type.BOUNDSHEET);
61     name = n;
62     hidden = false;
63     chartOnly = false;
64   }
65
66   /**
67    * Sets the hidden flag
68    */

69   void setHidden()
70   {
71     hidden = true;
72   }
73
74   /**
75    * Sets the chart only flag
76    */

77   void setChartOnly()
78   {
79     chartOnly = true;
80   }
81
82   /**
83    * Gets the data to write out to the binary file
84    *
85    * @return the data to write out
86    */

87   public byte[] getData()
88   {
89     data = new byte[name.length() * 2 + 8];
90
91     if (chartOnly)
92     {
93       data[5] = 0x02;
94     }
95     else
96     {
97       data[5] = 0; // set stream type to worksheet
98
}
99
100     if (hidden)
101     {
102       data[4] = 0x1;
103       data[5] = 0x0;
104     }
105     
106     data[6] = (byte) name.length();
107     data[7] = 1;
108     StringHelper.getUnicodeBytes(name, data, 8);
109
110     return data;
111   }
112 }
113
114
115
116
117
118
119
120
121
Popular Tags