2 /* ====================================================================
3 Licensed to the Apache Software Foundation (ASF) under one or more
4 contributor license agreements. See the NOTICE file distributed with
5 this work for additional information regarding copyright ownership.
6 The ASF licenses this file to You under the Apache License, Version 2.0
7 (the "License"); you may not use this file except in compliance with
8 the License. You may obtain a copy of the License at
10 http://www.apache.org/licenses/LICENSE-2.0
12 Unless required by applicable law or agreed to in writing, software
13 distributed under the License is distributed on an "AS IS" BASIS,
14 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 See the License for the specific language governing permissions and
16 limitations under the License.
17 ==================================================================== */
23 * Created on December 10, 2001, 12:49 PM
25 package org
.apache
.poi
.hssf
.record
;
28 * Title: Mulitple Blank cell record <P>
29 * Description: Represents a set of columns in a row with no value but with styling.
30 * In this release we have read-only support for this record type.
31 * The RecordFactory converts this to a set of BlankRecord objects.<P>
32 * REFERENCE: PG 329 Microsoft Excel 97 Developer's Kit (ISBN: 1-57231-498-2)<P>
33 * @author Andrew C. Oliver (acoliver at apache dot org)
34 * @author Glen Stampoultzis (glens at apache.org)
36 * @see org.apache.poi.hssf.record.BlankRecord
39 public class MulBlankRecord
42 public final static short sid
= 0xbe;
43 //private short field_1_row;
44 private int field_1_row
;
45 private short field_2_first_col
;
46 private short[] field_3_xfs
;
47 private short field_4_last_col
;
49 /** Creates new MulBlankRecord */
51 public MulBlankRecord()
56 * Constructs a MulBlank record and sets its fields appropriately.
58 * @param in the RecordInputstream to read the record from
61 public MulBlankRecord(RecordInputStream in
)
67 * get the row number of the cells this represents
72 //public short getRow()
79 * starting column (first cell this holds in the row)
80 * @return first column number
83 public short getFirstColumn()
85 return field_2_first_col
;
89 * ending column (last cell this holds in the row)
90 * @return first column number
93 public short getLastColumn()
95 return field_4_last_col
;
99 * get the number of columns this contains (last-first +1)
100 * @return number of columns (last - first +1)
103 public int getNumColumns()
105 return field_4_last_col
- field_2_first_col
+ 1;
109 * returns the xf index for column (coffset = column - field_2_first_col)
110 * @param coffset the column (coffset = column - field_2_first_col)
111 * @return the XF index for the column
114 public short getXFAt(int coffset
)
116 return field_3_xfs
[ coffset
];
120 * @param in the RecordInputstream to read the record from
122 protected void fillFields(RecordInputStream in
)
124 //field_1_row = LittleEndian.getShort(data, 0 + offset);
125 field_1_row
= in
.readUShort();
126 field_2_first_col
= in
.readShort();
127 field_3_xfs
= parseXFs(in
);
128 field_4_last_col
= in
.readShort();
131 private short [] parseXFs(RecordInputStream in
)
133 short[] retval
= new short[ (in
.remaining() - 2) / 2 ];
135 for (int idx
= 0; idx
< retval
.length
;idx
++)
137 retval
[idx
] = in
.readShort();
142 public String
toString()
144 StringBuffer buffer
= new StringBuffer();
146 buffer
.append("[MULBLANK]\n");
147 buffer
.append("row = ")
148 .append(Integer
.toHexString(getRow())).append("\n");
149 buffer
.append("firstcol = ")
150 .append(Integer
.toHexString(getFirstColumn())).append("\n");
151 buffer
.append(" lastcol = ")
152 .append(Integer
.toHexString(getLastColumn())).append("\n");
153 for (int k
= 0; k
< getNumColumns(); k
++)
155 buffer
.append("xf").append(k
).append(" = ")
156 .append(Integer
.toHexString(getXFAt(k
))).append("\n");
158 buffer
.append("[/MULBLANK]\n");
159 return buffer
.toString();
163 * called by constructor, should throw runtime exception in the event of a
164 * record passed with a differing ID.
166 * @param id alleged id for this record
169 protected void validateSid(short id
)
173 throw new RecordFormatException("Not a MulBlankRecord!");
177 public short getSid()
182 public int serialize(int offset
, byte [] data
)
184 throw new RecordFormatException(
185 "Sorry, you can't serialize a MulBlank in this release");