1 | /* ====================================================================
|
---|
2 | Licensed to the Apache Software Foundation (ASF) under one or more
|
---|
3 | contributor license agreements. See the NOTICE file distributed with
|
---|
4 | this work for additional information regarding copyright ownership.
|
---|
5 | The ASF licenses this file to You under the Apache License, Version 2.0
|
---|
6 | (the "License"); you may not use this file except in compliance with
|
---|
7 | the License. You may obtain a copy of the License at
|
---|
8 |
|
---|
9 | 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.ss.formula.ExternSheetReferenceToken;
|
---|
21 | import org.apache.poi.ss.formula.FormulaRenderingWorkbook;
|
---|
22 | import org.apache.poi.ss.formula.WorkbookDependentFormula;
|
---|
23 | import org.apache.poi.util.LittleEndianInput;
|
---|
24 | import org.apache.poi.util.LittleEndianOutput;
|
---|
25 |
|
---|
26 | /**
|
---|
27 | * Title: Reference 3D Ptg <P>
|
---|
28 | * Description: Defined a cell in extern sheet. <P>
|
---|
29 | * REFERENCE: <P>
|
---|
30 | * @author Libin Roman (Vista Portal LDT. Developer)
|
---|
31 | * @author Jason Height (jheight at chariot dot net dot au)
|
---|
32 | */
|
---|
33 | public final class Ref3DPtg extends RefPtgBase implements WorkbookDependentFormula, ExternSheetReferenceToken {
|
---|
34 | public final static byte sid = 0x3a;
|
---|
35 |
|
---|
36 | private final static int SIZE = 7; // 6 + 1 for Ptg
|
---|
37 | private int field_1_index_extern_sheet;
|
---|
38 |
|
---|
39 |
|
---|
40 | public Ref3DPtg(LittleEndianInput in) {
|
---|
41 | field_1_index_extern_sheet = in.readShort();
|
---|
42 | readCoordinates(in);
|
---|
43 | }
|
---|
44 |
|
---|
45 |
|
---|
46 | public String toString() {
|
---|
47 | StringBuffer sb = new StringBuffer();
|
---|
48 | sb.append(getClass().getName());
|
---|
49 | sb.append(" [");
|
---|
50 | sb.append("sheetIx=").append(getExternSheetIndex());
|
---|
51 | sb.append(" ! ");
|
---|
52 | sb.append(formatReferenceAsString());
|
---|
53 | sb.append("]");
|
---|
54 | return sb.toString();
|
---|
55 | }
|
---|
56 |
|
---|
57 | public void write(LittleEndianOutput out) {
|
---|
58 | out.writeByte(sid + getPtgClass());
|
---|
59 | out.writeShort(getExternSheetIndex());
|
---|
60 | writeCoordinates(out);
|
---|
61 | }
|
---|
62 |
|
---|
63 | public int getSize() {
|
---|
64 | return SIZE;
|
---|
65 | }
|
---|
66 |
|
---|
67 | public int getExternSheetIndex() {
|
---|
68 | return field_1_index_extern_sheet;
|
---|
69 | }
|
---|
70 |
|
---|
71 | /**
|
---|
72 | * @return text representation of this cell reference that can be used in text
|
---|
73 | * formulas. The sheet name will get properly delimited if required.
|
---|
74 | */
|
---|
75 | public String toFormulaString(FormulaRenderingWorkbook book) {
|
---|
76 | return ExternSheetNameResolver.prependSheetName(book, field_1_index_extern_sheet, formatReferenceAsString());
|
---|
77 | }
|
---|
78 | public String toFormulaString() {
|
---|
79 | throw new RuntimeException("3D references need a workbook to determine formula text");
|
---|
80 | }
|
---|
81 | }
|
---|