00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #include "krs_cell.h"
00021 #include "krs_sheet.h"
00022 #include "krs_doc.h"
00023
00024 #include <kspread_doc.h>
00025 #include <kspread_sheet.h>
00026 #include <kspread_cell.h>
00027 #include <kspread_value.h>
00028
00029 namespace Kross { namespace KSpreadCore {
00030
00031 Sheet::Sheet(KSpread::Sheet* sheet, KSpread::Doc *doc) : Kross::Api::Class<Sheet>("KSpreadSheet"), m_sheet(sheet), m_doc(doc) {
00032
00033 this->addFunction0< Kross::Api::Variant >("name", this, &Sheet::name);
00034 this->addFunction1< void, Kross::Api::Variant >("setName", this, &Sheet::setName);
00035
00036 this->addFunction0< Kross::Api::Variant >("maxColumn", this, &Sheet::maxColumn);
00037 this->addFunction0< Kross::Api::Variant >("maxRow", this, &Sheet::maxRow);
00038
00039 this->addFunction0< Cell >("firstCell", this, &Sheet::firstCell);
00040
00041 this->addFunction2< Cell, Kross::Api::Variant, Kross::Api::Variant >("cell", this, &Sheet::cell);
00042
00043 this->addFunction1< Kross::Api::Variant, Kross::Api::Variant >("insertRow", this, &Sheet::insertRow);
00044 this->addFunction1< Kross::Api::Variant, Kross::Api::Variant >("insertColumn", this, &Sheet::insertColumn);
00045
00046 this->addFunction1< void, Kross::Api::Variant >("removeRow", this, &Sheet::removeRow);
00047 this->addFunction1< void, Kross::Api::Variant >("removeColumn", this, &Sheet::removeColumn);
00048 }
00049
00050 Sheet::~Sheet() {
00051 }
00052
00053 const QString Sheet::getClassName() const {
00054 return "Kross::KSpreadCore::Sheet";
00055 }
00056
00057 const QString Sheet::name() const
00058 {
00059 return m_sheet->sheetName();
00060 }
00061
00062 void Sheet::setName(const QString& name)
00063 {
00064 m_sheet->setSheetName(name);
00065 }
00066
00067 int Sheet::maxColumn() const {
00068 return m_sheet->maxColumn();
00069 }
00070
00071 int Sheet::maxRow() const {
00072 return m_sheet->maxRow();
00073 }
00074
00075 Cell* Sheet::firstCell() const {
00076 KSpread::Cell* c = m_sheet->firstCell();
00077 return c ? new Cell(c,c->sheet(),c->column(),c->row()) : 0;
00078 }
00079
00080 Cell* Sheet::cell(uint col, uint row) {
00081 uint c = QMAX(uint(1), col);
00082 uint r = QMAX(uint(1), row);
00083 return new Cell(m_sheet->cellAt(c,r),m_sheet,c,r);
00084 }
00085
00086 bool Sheet::insertRow(uint row) {
00087 return m_sheet->insertRow(row);
00088 }
00089
00090 bool Sheet::insertColumn(uint col) {
00091 return m_sheet->insertColumn(col);
00092 }
00093
00094 void Sheet::removeRow(uint row) {
00095 m_sheet->removeRow( QMAX(uint(1), row) );
00096 }
00097
00098 void Sheet::removeColumn(uint col) {
00099 m_sheet->removeColumn( QMAX(uint(1), col) );
00100 }
00101
00102 }
00103 }