kspread

KSpread::Formula Class Reference

#include <formula.h>

List of all members.


Detailed Description

Class Formula encapsulates a formula for a cell.

A Formula is a equations which perform calculations on values in the cells and sheets. Every formula must start with an equal sign (=).

Definition at line 238 of file formula.h.


Public Member Functions

 Formula (Sheet *sheet, Cell *cell=0)
 Formula ()
 ~Formula ()
Sheetsheet () const
Cellcell () const
void setExpression (const QString &expr)
QString expression () const
void clear ()
bool isValid () const
Tokens tokens () const
Value eval () const
Tokens scan (const QString &expr, KLocale *locale=0) const
QString dump () const

Protected Member Functions

void compile (const Tokens &tokens) const

Constructor & Destructor Documentation

Formula::Formula Sheet sheet,
Cell cell = 0
 

Creates a formula.

It must be owned by a sheet, and optionally sheet.

Definition at line 372 of file formula.cc.

Formula::Formula  ) 
 

Creates a formula that is not owned by any sheet.

This might be useful in some cases.

Definition at line 380 of file formula.cc.

Formula::~Formula  ) 
 

Destroys the formula.

Definition at line 390 of file formula.cc.


Member Function Documentation

Cell * Formula::cell  )  const
 

Returns the cell which owns this formula.

Definition at line 395 of file formula.cc.

void Formula::clear  ) 
 

Clears everything, makes as like a newly constructed formula.

Definition at line 444 of file formula.cc.

Value Formula::eval  )  const
 

Evaluates the formula and returns the result.

Definition at line 1158 of file formula.cc.

QString Formula::expression  )  const
 

Gets the expression of this formula.

Definition at line 418 of file formula.cc.

bool Formula::isValid  )  const
 

Returns true if the specified expression is valid, i.e.

it contains no parsing error. Empty formula (i.e. without expression) is always invalid.

Definition at line 426 of file formula.cc.

Tokens Formula::scan const QString &  expr,
KLocale *  locale = 0
const
 

Given an expression, this function separates it into tokens.

If the expression contains error (e.g. unknown operator, string no terminated) this function returns tokens which is not valid.

Definition at line 466 of file formula.cc.

void Formula::setExpression const QString &  expr  ) 
 

Sets the expression for this formula.

Definition at line 409 of file formula.cc.

Sheet * Formula::sheet  )  const
 

Returns the cell which owns this formula.

Definition at line 400 of file formula.cc.

Tokens Formula::tokens  )  const
 

Returns list of tokens associated with this formula.

This has nothing to with the formula evaluation but might be useful, e.g. for syntax highlight or similar features. If the formula contains error, the returned tokens is invalid.

Definition at line 458 of file formula.cc.


The documentation for this class was generated from the following files:
KDE Home | KDE Accessibility Home | Description of Access Keys