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.hssf.model.Workbook;
21: import org.apache.poi.hssf.record.RecordFormatException;
22: import org.apache.poi.hssf.record.RecordInputStream;
23:
24: import org.apache.poi.util.LittleEndian;
25:
26: /**
27: *
28: * @author andy
29: * @author Jason Height (jheight at chariot dot net dot au)
30: * @author dmui (save existing implementation)
31: */
32:
33: public class ExpPtg extends Ptg {
34: private final static int SIZE = 5;
35: public final static short sid = 0x1;
36: private short field_1_first_row;
37: private short field_2_first_col;
38:
39: /** Creates new ExpPtg */
40:
41: public ExpPtg() {
42: }
43:
44: /** Creates new ExpPtg */
45:
46: public ExpPtg(RecordInputStream in) {
47: field_1_first_row = in.readShort();
48: field_2_first_col = in.readShort();
49: }
50:
51: public void writeBytes(byte[] array, int offset) {
52: array[offset + 0] = (byte) (sid);
53: LittleEndian.putShort(array, offset + 1, field_1_first_row);
54: LittleEndian.putShort(array, offset + 3, field_2_first_col);
55: }
56:
57: public int getSize() {
58: return SIZE;
59: }
60:
61: public short getRow() {
62: return field_1_first_row;
63: }
64:
65: public short getColumn() {
66: return field_2_first_col;
67: }
68:
69: public String toFormulaString(Workbook book) {
70: throw new RecordFormatException(
71: "Coding Error: Expected ExpPtg to be converted from Shared to Non-Shared Formula");
72: }
73:
74: public String toString() {
75: StringBuffer buffer = new StringBuffer(
76: "[Array Formula or Shared Formula]\n");
77: buffer.append("row = ").append(getRow()).append("\n");
78: buffer.append("col = ").append(getColumn()).append("\n");
79: return buffer.toString();
80: }
81:
82: public byte getDefaultOperandClass() {
83: return Ptg.CLASS_VALUE;
84: }
85:
86: public Object clone() {
87: ExpPtg result = new ExpPtg();
88: result.field_1_first_row = field_1_first_row;
89: result.field_2_first_col = field_2_first_col;
90: return result;
91: }
92:
93: }
|