KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jxl > read > biff > MulBlankCell


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.read.biff;
21
22 import common.Logger;
23
24 import jxl.Cell;
25 import jxl.CellType;
26 import jxl.CellFeatures;
27 import jxl.format.CellFormat;
28 import jxl.biff.FormattingRecords;
29
30 /**
31  * A blank cell value, initialized indirectly from a multiple biff record
32  * rather than directly from the binary data
33  */

34 class MulBlankCell implements Cell, CellFeaturesAccessor
35 {
36   /**
37    * The logger
38    */

39   private static Logger logger = Logger.getLogger(MulBlankCell.class);
40
41   /**
42    * The row containing this blank
43    */

44   private int row;
45   /**
46    * The column containing this blank
47    */

48   private int column;
49   /**
50    * The raw cell format
51    */

52   private CellFormat cellFormat;
53
54   /**
55    * The index to the XF Record
56    */

57   private int xfIndex;
58
59   /**
60    * A handle to the formatting records
61    */

62   private FormattingRecords formattingRecords;
63
64   /**
65    * A flag to indicate whether this object's formatting things have
66    * been initialized
67    */

68   private boolean initialized;
69
70   /**
71    * A handle to the sheet
72    */

73   private SheetImpl sheet;
74
75   /**
76    * The cell features
77    */

78   private CellFeatures features;
79
80
81   /**
82    * Constructs this cell
83    *
84    * @param r the zero based row
85    * @param c the zero base column
86    * @param xfi the xf index
87    * @param fr the formatting records
88    * @param si the sheet
89    */

90   public MulBlankCell(int r, int c,
91                       int xfi,
92                       FormattingRecords fr,
93                       SheetImpl si)
94   {
95     row = r;
96     column = c;
97     xfIndex = xfi;
98     formattingRecords = fr;
99     sheet = si;
100     initialized = false;
101   }
102
103   /**
104    * Accessor for the row
105    *
106    * @return the zero based row
107    */

108   public final int getRow()
109   {
110     return row;
111   }
112
113   /**
114    * Accessor for the column
115    *
116    * @return the zero based column
117    */

118   public final int getColumn()
119   {
120     return column;
121   }
122
123   /**
124    * Accessor for the contents as a string
125    *
126    * @return the value as a string
127    */

128   public String JavaDoc getContents()
129   {
130     return "";
131   }
132
133   /**
134    * Accessor for the cell type
135    *
136    * @return the cell type
137    */

138   public CellType getType()
139   {
140     return CellType.EMPTY;
141   }
142
143   /**
144    * Gets the cell format for this cell
145    *
146    * @return the cell format for these cells
147    */

148   public CellFormat getCellFormat()
149   {
150     if (!initialized)
151     {
152       cellFormat = formattingRecords.getXFRecord(xfIndex);
153       initialized = true;
154     }
155
156     return cellFormat;
157   }
158
159   /**
160    * Determines whether or not this cell has been hidden
161    *
162    * @return TRUE if this cell has been hidden, FALSE otherwise
163    */

164   public boolean isHidden()
165   {
166     ColumnInfoRecord cir = sheet.getColumnInfo(column);
167
168     if (cir != null && cir.getWidth() == 0)
169     {
170       return true;
171     }
172
173     RowRecord rr = sheet.getRowInfo(row);
174
175     if (rr != null && (rr.getRowHeight() == 0 || rr.isCollapsed()))
176     {
177       return true;
178     }
179
180     return false;
181   }
182
183   /**
184    * Accessor for the cell features
185    *
186    * @return the cell features or NULL if this cell doesn't have any
187    */

188   public CellFeatures getCellFeatures()
189   {
190     return features;
191   }
192
193   /**
194    * Sets the cell features during the reading process
195    *
196    * @param cf the cell features
197    */

198   public void setCellFeatures(CellFeatures cf)
199   {
200     if (features != null)
201     {
202       logger.warn("current cell features not null - overwriting");
203     }
204
205     features = cf;
206   }
207 }
208
Popular Tags