KickJava   Java API By Example, From Geeks To Geeks.

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


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.SheetSettings;
23
24 import jxl.biff.Type;
25 import jxl.biff.IntegerHelper;
26 import jxl.biff.WritableRecordData;
27
28 /**
29  * Contains the window attributes for a worksheet
30  */

31 class Window2Record extends WritableRecordData
32 {
33   /**
34    * The binary data for output to file
35    */

36   private byte[] data;
37
38   /**
39    * Constructor
40    */

41   public Window2Record(SheetSettings settings)
42   {
43     super(Type.WINDOW2);
44
45     int selected = settings.isSelected() ? 0x06 : 0x0;
46
47     int options = 0;
48     
49     options |= 0x0; // display formula values, not formulas
50

51     if (settings.getShowGridLines())
52     {
53       options |= 0x02;
54     }
55
56     options |= 0x04; // display row and column headings
57

58     options |= 0x0; // panes should be not frozen
59

60     if (settings.getDisplayZeroValues())
61     {
62       options |= 0x10;
63     }
64
65     options |= 0x20; // default header
66

67     options |= 0x80; // display outline symbols
68

69     // Handle the freeze panes
70
if (settings.getHorizontalFreeze() != 0 ||
71         settings.getVerticalFreeze() != 0)
72     {
73       options |= 0x08;
74       selected |= 0x01;
75     }
76
77     // hard code the data in for now
78
data = new byte[]
79     {(byte) options,
80      (byte) selected,
81      (byte) 0,
82      (byte) 0,
83      (byte) 0,
84      (byte) 0,
85      (byte) 0x40,
86      (byte) 0,
87      (byte) 0,
88      (byte) 0,
89      (byte) 0,
90      (byte) 0,
91      (byte) 0,
92      (byte) 0,
93      (byte) 0,
94      (byte) 0,
95      (byte) 0,
96      (byte) 0 };
97   }
98
99   /**
100    * Gets the binary data for output to file
101    *
102    * @return the binary data
103    */

104   public byte[] getData()
105   {
106     return data;
107   }
108 }
109
Popular Tags