01: /* ====================================================================
02: Licensed to the Apache Software Foundation (ASF) under one or more
03: contributor license agreements. See the NOTICE file distributed with
04: this work for additional information regarding copyright ownership.
05: The ASF licenses this file to You under the Apache License, Version 2.0
06: (the "License"); you may not use this file except in compliance with
07: the License. You may obtain a copy of the License at
08:
09: http://www.apache.org/licenses/LICENSE-2.0
10:
11: Unless required by applicable law or agreed to in writing, software
12: distributed under the License is distributed on an "AS IS" BASIS,
13: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: See the License for the specific language governing permissions and
15: limitations under the License.
16: ==================================================================== */
17:
18: package org.apache.poi.hssf.record.formula;
19:
20: import org.apache.poi.util.LittleEndian;
21: import org.apache.poi.util.BitField;
22:
23: import org.apache.poi.hssf.util.CellReference;
24: import org.apache.poi.hssf.model.Workbook;
25: import org.apache.poi.hssf.record.RecordInputStream;
26:
27: /**
28: * RefError - handles deleted cell reference
29: * @author Jason Height (jheight at chariot dot net dot au)
30: */
31:
32: public class RefErrorPtg extends Ptg {
33: private final static int SIZE = 5;
34: public final static byte sid = 0x2a;
35: private int field_1_reserved;
36:
37: private RefErrorPtg() {
38: //Required for clone methods
39: }
40:
41: public RefErrorPtg(RecordInputStream in) {
42: field_1_reserved = in.readInt();
43:
44: }
45:
46: public String toString() {
47: StringBuffer buffer = new StringBuffer("[RefError]\n");
48:
49: buffer.append("reserved = ").append(getReserved()).append("\n");
50: return buffer.toString();
51: }
52:
53: public void writeBytes(byte[] array, int offset) {
54: array[offset] = (byte) (sid + ptgClass);
55: LittleEndian.putInt(array, offset + 1, field_1_reserved);
56: }
57:
58: public void setReserved(int reserved) {
59: field_1_reserved = reserved;
60: }
61:
62: public int getReserved() {
63: return field_1_reserved;
64: }
65:
66: public int getSize() {
67: return SIZE;
68: }
69:
70: public String toFormulaString(Workbook book) {
71: //TODO -- should we store a cellreference instance in this ptg?? but .. memory is an issue, i believe!
72: return "#REF!";
73: }
74:
75: public byte getDefaultOperandClass() {
76: return Ptg.CLASS_REF;
77: }
78:
79: public Object clone() {
80: RefErrorPtg ptg = new RefErrorPtg();
81: ptg.field_1_reserved = field_1_reserved;
82: ptg.setClass(ptgClass);
83: return ptg;
84: }
85: }
|