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.rows;
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  
29  /**
30   * 
31   */
32  public class RowCellRefImpl extends Deferred implements CellRef {
33  
34      private Cell cell;
35  
36      private int indexToColumn;
37  
38      private RowRef rowRef;
39  
40      /**
41       * 
42       */
43      public RowCellRefImpl( final RowRef row, final int col, final Cell c ) {
44          this.cell = c;
45          this.indexToColumn = col;
46          this.rowRef = row;
47      }
48  
49      /**
50       * @see org.millscript.office.spreadsheet.CellRef#getCalculatedCellContents()
51       */
52      public Object getCalculatedCellContents() {
53          return this.cell.getCalculatedContents( this );
54      }
55  
56      /**
57       * @see org.millscript.millscript.datatypes.Deferred#get()
58       */
59      @Override
60      public Object get() {
61          return this.cell == null ? null : this.getCalculatedCellContents();
62      }
63  
64      /**
65       * @see org.millscript.office.spreadsheet.CellRef#getCell()
66       */
67      public Cell getCell() {
68          return this.cell;
69      }
70  
71      /**
72       * @see org.millscript.office.spreadsheet.CellRef#getColumnIndex()
73       */
74      public int getColumnIndex() {
75          return this.indexToColumn;
76      }
77  
78      /**
79       * @see org.millscript.office.spreadsheet.CellRef#getColumnRef()
80       */
81      public ColumnRef getColumnRef() {
82          return this.rowRef.getWorksheetRef().getColumnRef( this.indexToColumn );
83      }
84  
85      /**
86       * @see org.millscript.office.spreadsheet.CellRef#getRowIndex()
87       */
88      public int getRowIndex() {
89          return this.getRowRef().getRowIndex();
90      }
91  
92      /**
93       * @see org.millscript.office.spreadsheet.CellRef#getRowRef()
94       */
95      public RowRef getRowRef() {
96          return this.rowRef;
97      }
98  
99  }