001/* 002 * Copyright (c) 2005 Einar Pehrson <einar@pehrson.nu>. 003 * 004 * This file is part of 005 * CleanSheets - a spreadsheet application for the Java platform. 006 * 007 * CleanSheets is free software; you can redistribute it and/or modify 008 * it under the terms of the GNU General Public License as published by 009 * the Free Software Foundation; either version 2 of the License, or 010 * (at your option) any later version. 011 * 012 * CleanSheets is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 015 * GNU General Public License for more details. 016 * 017 * You should have received a copy of the GNU General Public License 018 * along with CleanSheets; if not, write to the Free Software 019 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 020 */ 021package csheets.core; 022 023import java.io.Serializable; 024import java.util.SortedSet; 025 026import csheets.ext.Extensible; 027 028/** 029 * A spreadsheet which provides cell data and dependencies. 030 * @author Einar Pehrson 031 */ 032public interface Spreadsheet extends Iterable<Cell>, Extensible<Spreadsheet>, 033 Serializable { 034 035/* 036 * LOCATION 037 */ 038 039 /** 040 * Returns the workbook to which the spreadsheet belongs. 041 * @return the workbook to which the spreadsheet belongs 042 */ 043 public Workbook getWorkbook(); 044 045 /** 046 * Returns the title of the spreadsheet. 047 * @return the title of the spreadsheet. 048 */ 049 public String getTitle(); 050 051 /** 052 * Sets the title of the spreadsheet. 053 * @param title the title of the spreadsheet. 054 */ 055 public void setTitle(String title); 056 057/* 058 * DIMENSIONS 059 */ 060 061 /** 062 * Returns the number of columns in the spreadsheet. 063 * @return the number of columns in the spreadsheet. 064 */ 065 public int getColumnCount(); 066 067 /** 068 * Returns the number of rows in the spreadsheet. 069 * @return the number of rows in the spreadsheet. 070 */ 071 public int getRowCount(); 072 073/* 074 * CELLS 075 */ 076 077 /** 078 * Returns the cell at the given address. 079 * @param address the address of the cell 080 * @return the cell at the given address 081 */ 082 public Cell getCell(Address address); 083 084 /** 085 * Returns the cell at the given column and row in the spreadsheet. 086 * @param column the column index of the cell's location 087 * @param row the row index of the cell's location 088 * @return the cell at the given column and row in the spreadsheet 089 */ 090 public Cell getCell(int column, int row); 091 092 /** 093 * Returns the cells in the range between the given addresses. 094 * @param address1 the address of the cell in one end of the range 095 * @param address2 the address of the cell in the other end of the range 096 * @return a sorted set of the cells in the range 097 */ 098 public SortedSet<Cell> getCells(Address address1, Address address2); 099 100 /** 101 * Returns the cells in the given column. 102 * @param index the index of the column 103 * @return an array of the cells in the column 104 */ 105 public Cell[] getColumn(int index); 106 107 /** 108 * Returns the cells in the given row. 109 * @param index the index of the row 110 * @return an array of the cells in the row 111 */ 112 public Cell[] getRow(int index); 113 114/* 115 * EVENT HANDLING 116 */ 117 118 /** 119 * Registers the given listener to receive events from all cells in the 120 * spreadsheet. 121 * @param listener the listener to be added 122 */ 123 public void addCellListener(CellListener listener); 124 125 /** 126 * Deregisters the given listener from receiving events from all cells in 127 * the spreadsheet. 128 * @param listener the listener to be removed 129 */ 130 public void removeCellListener(CellListener listener); 131 132 /** 133 * Returns the cell listeners that have been registered on the spreadsheet. 134 * @return the cell listeners that have been registered on the spreadsheet 135 */ 136 public CellListener[] getCellListeners(); 137}