View Javadoc

1   ////////////////////////////////////////////////////////////////////////////////
2   // MillScript-Excel: an Open Spice interpreter and batch website creation tool
3   // Copyright (C) 2006 Open World Ltd, Kevin Rogers
4   //
5   // This file is part of MillScript-Excel.
6   //
7   // MillScript-Excel is free software; you can redistribute it and/or modify it under
8   // the terms of the GNU General Public License as published by the Free
9   // Software Foundation; either version 2 of the License, or (at your option)
10  // any later version.
11  //
12  // MillScript-Excel is distributed in the hope that it will be useful, but WITHOUT
13  // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14  // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
15  // more details.
16  //
17  // You should have received a copy of the GNU General Public License along with
18  // MillScript-Excel; if not, write to the Free Software Foundation, Inc., 59 Temple
19  // Place, Suite 330, Boston, MA  02111-1307  USA
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 }