Inspired by bug #44958 - Record level support for Data Tables. (No formula parser...
[poi.git] / src / java / org / apache / poi / hssf / record / MulBlankRecord.java
blobdffdb2fe80673f010b40c648a8efe47c1aa9bae3
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 ==================================================================== */
21 * MulBlankRecord.java
23 * Created on December 10, 2001, 12:49 PM
25 package org.apache.poi.hssf.record;
27 /**
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)
35 * @version 2.0-pre
36 * @see org.apache.poi.hssf.record.BlankRecord
39 public class MulBlankRecord
40 extends Record
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()
55 /**
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)
63 super(in);
66 /**
67 * get the row number of the cells this represents
69 * @return row number
72 //public short getRow()
73 public int getRow()
75 return field_1_row;
78 /**
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;
88 /**
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;
98 /**
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();
139 return retval;
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)
171 if (id != sid)
173 throw new RecordFormatException("Not a MulBlankRecord!");
177 public short getSid()
179 return sid;
182 public int serialize(int offset, byte [] data)
184 throw new RecordFormatException(
185 "Sorry, you can't serialize a MulBlank in this release");