1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.millscript.office.spreadsheet.cells;
22
23 import org.millscript.millscript.datatypes.Deferred;
24 import org.millscript.office.spreadsheet.Cell;
25 import org.millscript.office.spreadsheet.CellRef;
26 import org.millscript.office.spreadsheet.ColumnRef;
27 import org.millscript.office.spreadsheet.RowRef;
28 import org.millscript.office.spreadsheet.WorksheetRef;
29
30 /**
31 *
32 */
33 public class CellRefImpl extends Deferred implements CellRef {
34
35 private int indexToColumn;
36
37 private int indexToRow;
38
39 private WorksheetRef worksheetRef;
40
41 /**
42 *
43 */
44 public CellRefImpl( final WorksheetRef sheetRef, final int row, final int col ) {
45 this.indexToColumn = col;
46 this.indexToRow = row;
47 this.worksheetRef = sheetRef;
48 }
49
50 /**
51 * @see org.millscript.office.spreadsheet.CellRef#getCalculatedCellContents()
52 */
53 public Object getCalculatedCellContents() {
54 return this.getCell().getCalculatedContents( this );
55 }
56
57 /**
58 * @see org.millscript.millscript.datatypes.Deferred#get()
59 */
60 @Override
61 public Object get() {
62 return this.getCell().getContents();
63 }
64
65 /**
66 * @see org.millscript.office.spreadsheet.CellRef#getCell()
67 */
68 public Cell getCell() {
69 return this.worksheetRef.getWorksheet().getCell( this.indexToRow, this.indexToColumn );
70 }
71
72 /**
73 * @see org.millscript.office.spreadsheet.CellRef#getColumnIndex()
74 */
75 public int getColumnIndex() {
76 return this.indexToColumn;
77 }
78
79 /**
80 * @see org.millscript.office.spreadsheet.CellRef#getColumnRef()
81 */
82 public ColumnRef getColumnRef() {
83 return this.worksheetRef.getColumnRef( this.indexToColumn );
84 }
85
86 /**
87 * @see org.millscript.office.spreadsheet.CellRef#getRowIndex()
88 */
89 public int getRowIndex() {
90 return this.indexToRow;
91 }
92
93 /**
94 * @see org.millscript.office.spreadsheet.CellRef#getRowRef()
95 */
96 public RowRef getRowRef() {
97 return this.worksheetRef.get( this.indexToRow );
98 }
99
100 }