22#include "manipulator.h"
23#include "manipulator_data.h"
25namespace Kross {
namespace KSpreadCore {
27Cell::Cell(KSpread::Cell* cell, KSpread::Sheet* sheet, uint col, uint row)
28 : Kross::Api::Class<
Cell>(
"KSpreadCell"), m_cell(cell), m_sheet(sheet), m_col(col), m_row(row)
30 this->addFunction0< Kross::Api::Variant >(
"value",
this, &Cell::value);
31 this->addFunction1< Kross::Api::Variant, Kross::Api::Variant >(
"setValue",
this, &Cell::setValue);
33 this->addFunction0< Kross::Api::Variant >(
"column",
this, &Cell::column);
34 this->addFunction0< Kross::Api::Variant >(
"row",
this, &Cell::row);
36 this->addFunction0< Cell >(
"previousCell",
this, &Cell::previousCell);
37 this->addFunction0< Cell >(
"nextCell",
this, &Cell::nextCell);
38 this->addFunction1< void, Cell >(
"setPreviousCell",
this, &Cell::setPreviousCell);
39 this->addFunction1< void, Cell >(
"setNextCell",
this, &Cell::setNextCell);
41 this->addFunction0< Kross::Api::Variant >(
"name",
this, &Cell::name);
42 this->addFunction0< Kross::Api::Variant >(
"fullName",
this, &Cell::fullName);
44 this->addFunction0< Kross::Api::Variant >(
"comment",
this, &Cell::comment);
45 this->addFunction1< void, Kross::Api::Variant >(
"setComment",
this, &Cell::setComment);
47 this->addFunction0< Kross::Api::Variant >(
"getFormatString",
this, &Cell::getFormatString);
48 this->addFunction1< void, Kross::Api::Variant >(
"setFormatString",
this, &Cell::setFormatString);
50 this->addFunction0< Kross::Api::Variant >(
"text",
this, &Cell::text);
51 this->addFunction1< void, Kross::Api::Variant >(
"setText",
this, &Cell::setText);
53 this->addFunction0< Kross::Api::Variant >(
"textColor",
this, &Cell::textColor);
54 this->addFunction1< void, Kross::Api::Variant >(
"setTextColor",
this, &Cell::setTextColor);
55 this->addFunction0< Kross::Api::Variant >(
"backgroundColor",
this, &Cell::backgroundColor);
56 this->addFunction1< void, Kross::Api::Variant >(
"setBackgroundColor",
this, &Cell::setBackgroundColor);
62const TQString Cell::getClassName()
const {
63 return "Kross::KSpreadCore::KSpreadCell";
71 switch(value.
type()) {
72 case KSpread::Value::Empty:
74 case KSpread::Value::Boolean:
76 case KSpread::Value::Integer:
77 return static_cast<TQ_LLONG
>(value.
asInteger());
78 case KSpread::Value::Float:
80 case KSpread::Value::String:
82 case KSpread::Value::Array: {
83 TQValueList<TQVariant> colarray;
84 for(uint j = 0; j < value.
rows(); j++) {
85 TQValueList<TQVariant> rowarray;
86 for( uint i = 0; i < value.
columns(); i++) {
88 rowarray.append( toVariant(v) );
90 colarray.append(rowarray);
94 case KSpread::Value::CellRange:
97 case KSpread::Value::Error:
103TQVariant Cell::value()
const {
104 return toVariant( m_cell->value() );
107bool Cell::setValue(
const TQVariant& value) {
109 switch(value.type()) {
110 case TQVariant::Bool: v.
setValue( value.toBool() );
break;
111 case TQVariant::ULongLong: v.
setValue( (
long)value.toLongLong() );
break;
112 case TQVariant::Int: v.
setValue( value.toInt() );
break;
113 case TQVariant::Double: v.
setValue( value.toDouble() );
break;
114 case TQVariant::String: v.
setValue( value.toString() );
break;
115 case TQVariant::Date: v.
setValue( value.toDate() );
break;
116 case TQVariant::Time: v.
setValue( value.toTime() );
break;
117 case TQVariant::DateTime: v.
setValue( value.toDateTime() );
break;
118 default:
return false;
123int Cell::column()
const {
124 return m_cell->column();
127int Cell::row()
const {
128 return m_cell->row();
131Cell* Cell::previousCell()
const {
136Cell* Cell::nextCell()
const {
141void Cell::setPreviousCell(Cell* c) {
142 return m_cell->setPreviousCell(c->m_cell);
145void Cell::setNextCell(Cell* c) {
146 return m_cell->setNextCell(c->m_cell);
149const TQString Cell::name()
const {
150 return m_cell->name();
153const TQString Cell::fullName()
const {
154 return m_cell->fullName();
157const TQString Cell::comment()
const {
158 return m_cell->format()->comment(m_col, m_row);
161void Cell::setComment(
const TQString& c) {
162 return m_cell->format()->setComment(c);
165const TQString Cell::getFormatString()
const {
166 return m_cell->format()->getFormatString(m_col, m_row);
169void Cell::setFormatString(
const TQString& format) {
170 m_cell->format()->setFormatString(format);
173const TQString Cell::text()
const {
174 return m_cell->text();
177bool Cell::setText(
const TQString& text) {
179 prot.setSheet (m_sheet);
180 prot.
add (TQPoint (m_col, m_row));
185 dm->setSheet (m_sheet);
187 dm->setParsing (
true);
188 dm->
add (TQPoint (m_col, m_row));
194const TQString Cell::textColor() {
195 return m_cell->format()->textColor(m_col, m_row).name();
198void Cell::setTextColor(
const TQString& textcolor) {
199 m_cell->format()->setTextColor( TQColor(textcolor) );
202const TQString Cell::backgroundColor() {
203 return m_cell->format()->bgColor(m_col, m_row).name();
206void Cell::setBackgroundColor(
const TQString& backgroundcolor) {
207 m_cell->format()->setBgColor( TQColor(backgroundcolor) );
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.
DataManipulator - allows setting values on one range.
void setValue(Value val)
set the values for the range.
class ProtectedCheck can be used to check, whether a particular range is protected or not
Element * add(const TQPoint &point, Sheet *sheet=0)
Adds the point point to this region.
Provides a wrapper for cell value.
unsigned columns() const
If this value is an array, return the number of columns.
Value element(unsigned column, unsigned row) const
Return an element in the array value.
void setValue(const Value &v)
Sets this value to another value.
unsigned rows() const
If this value is an array, return the number of rows.
Type type() const
Returns the type of the value.
double asFloat() const
Returns the floating-point value of this value.
long asInteger() const
Returns the integer value of this value.
TQString asString() const
Returns the string value of this value.
bool asBoolean() const
Returns the boolean value of this value.
For every cell in the spread sheet there is a Cell object.