KickJava   Java API By Example, From Geeks To Geeks.

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


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 PaneRecord extends WritableRecordData
32 {
33   /**
34    * The number of rows visible in the top left pane
35    */

36   private int rowsVisible;
37   /**
38    * The number of columns visible in the top left pane
39    */

40   private int columnsVisible;
41
42   /**
43    * The pane codes
44    */

45   private final static int topLeftPane = 0x3;
46   private final static int bottomLeftPane = 0x2;
47   private final static int topRightPane = 0x1;
48   private final static int bottomRightPane = 0x0;
49
50   /**
51    * Code
52
53   /**
54    * Constructor
55    */

56   public PaneRecord(int cols, int rows)
57   {
58     super(Type.PANE);
59
60     rowsVisible = rows;
61     columnsVisible = cols;
62   }
63
64   /**
65    * Gets the binary data for output to file
66    *
67    * @return the binary data
68    */

69   public byte[] getData()
70   {
71     byte[] data = new byte[10];
72
73     // The x position
74
IntegerHelper.getTwoBytes(columnsVisible, data, 0);
75
76     // The y position
77
IntegerHelper.getTwoBytes(rowsVisible, data, 2);
78
79     // The top row visible in the bottom pane
80
if (rowsVisible > 0)
81     {
82       IntegerHelper.getTwoBytes(rowsVisible, data, 4);
83     }
84
85     // The left most column visible in the right pane
86
if (columnsVisible > 0)
87     {
88       IntegerHelper.getTwoBytes(columnsVisible, data, 6);
89     }
90
91     // The active pane
92
int activePane = topLeftPane;
93
94     if (rowsVisible > 0 && columnsVisible == 0)
95     {
96       activePane = bottomLeftPane;
97     }
98     else if (rowsVisible == 0 && columnsVisible > 0)
99     {
100       activePane = topRightPane;
101     }
102     else if (rowsVisible > 0 && columnsVisible > 0)
103     {
104       activePane = bottomRightPane;
105     }
106     // always present
107
IntegerHelper.getTwoBytes(activePane, data, 8);
108
109     return data;
110   }
111 }
112
Popular Tags