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