kspread

krs_sheet.cpp
1/*
2 * Copyright (c) 2005 Cyrille Berger <cberger@cberger.net>
3 * Copyright (c) 2006 Isaac Clerencia <isaac@warp.es>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU Library General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 */
19
20#include "krs_cell.h"
21#include "krs_sheet.h"
22#include "krs_doc.h"
23
24#include <kspread_doc.h>
25#include <kspread_sheet.h>
26#include <kspread_cell.h>
27#include <kspread_value.h>
28
29namespace Kross { namespace KSpreadCore {
30
31Sheet::Sheet(KSpread::Sheet* sheet, KSpread::Doc *doc) : Kross::Api::Class<Sheet>("KSpreadSheet"), m_sheet(sheet), m_doc(doc) {
32
33 this->addFunction0< Kross::Api::Variant >("name", this, &Sheet::name);
34 this->addFunction1< void, Kross::Api::Variant >("setName", this, &Sheet::setName);
35
36 this->addFunction0< Kross::Api::Variant >("maxColumn", this, &Sheet::maxColumn);
37 this->addFunction0< Kross::Api::Variant >("maxRow", this, &Sheet::maxRow);
38
39 this->addFunction0< Cell >("firstCell", this, &Sheet::firstCell);
40
41 this->addFunction2< Cell, Kross::Api::Variant, Kross::Api::Variant >("cell", this, &Sheet::cell);
42
43 this->addFunction1< Kross::Api::Variant, Kross::Api::Variant >("insertRow", this, &Sheet::insertRow);
44 this->addFunction1< Kross::Api::Variant, Kross::Api::Variant >("insertColumn", this, &Sheet::insertColumn);
45
46 this->addFunction1< void, Kross::Api::Variant >("removeRow", this, &Sheet::removeRow);
47 this->addFunction1< void, Kross::Api::Variant >("removeColumn", this, &Sheet::removeColumn);
48}
49
50Sheet::~Sheet() {
51}
52
53const TQString Sheet::getClassName() const {
54 return "Kross::KSpreadCore::Sheet";
55}
56
57const TQString Sheet::name() const
58{
59 return m_sheet->sheetName();
60}
61
62void Sheet::setName(const TQString& name)
63{
64 m_sheet->setSheetName(name);
65}
66
67int Sheet::maxColumn() const {
68 return m_sheet->maxColumn();
69}
70
71int Sheet::maxRow() const {
72 return m_sheet->maxRow();
73}
74
75Cell* Sheet::firstCell() const {
76 KSpread::Cell* c = m_sheet->firstCell();
77 return c ? new Cell(c,c->sheet(),c->column(),c->row()) : 0;
78}
79
80Cell* Sheet::cell(uint col, uint row) {
81 uint c = TQMAX(uint(1), col);
82 uint r = TQMAX(uint(1), row);
83 return new Cell(m_sheet->cellAt(c,r),m_sheet,c,r);
84}
85
86bool Sheet::insertRow(uint row) {
87 return m_sheet->insertRow(row);
88}
89
90bool Sheet::insertColumn(uint col) {
91 return m_sheet->insertColumn(col);
92}
93
94void Sheet::removeRow(uint row) {
95 m_sheet->removeRow( TQMAX(uint(1), row) );
96}
97
98void Sheet::removeColumn(uint col) {
99 m_sheet->removeColumn( TQMAX(uint(1), col) );
100}
101
102}
103}
For every cell in the spread sheet there is a Cell object.
int row() const
Returns the cell's row.
Sheet * sheet() const
Returns the worksheet which owns this cell.
int column() const
Returns the cell's column.
A sheet in a document.
Definition krs_sheet.h:51