21#ifndef __kspread_util_h__
22#define __kspread_util_h__
26#include <tqdatetime.h>
28#include <koffice_export.h>
30#include "kspread_global.h"
31#include "kspread_value.h"
40bool util_isPointValid(TQPoint point);
41bool util_isRectValid(TQRect rect);
54class KSPREAD_EXPORT Point
57 Point() { _pos.setX( -1 ); _sheet = 0; _columnFixed =
false; _rowFixed =
false; }
58 Point(
const TQString& );
59 Point(
const TQString&,
Map*, Sheet* default_sheet = 0 );
60 Point(
const Point& c ) {
63 _sheetName = c._sheetName;
64 _columnFixed = c._columnFixed;
65 _rowFixed = c._rowFixed;
68 bool isValid()
const {
return ( util_isPointValid(pos()) && ( _sheet != 0 || _sheetName.isEmpty() ) ); }
69 bool isSheetKnown()
const {
return ( ! _sheetName.isEmpty() && _sheet != 0 ); }
73 bool operator== (
const Point &cell)
const;
74 bool operator< (
const Point &cell)
const;
76 int row ()
const {
return _pos.y(); };
77 int column ()
const {
return _pos.x(); };
78 void setRow (
int r) { _pos.setY (r); };
79 void setColumn (
int c) { _pos.setX (c); };
91 TQString sheetName()
const;
104 bool columnFixed()
const;
110 bool rowFixed()
const;
121 void init(
const TQString& );
130class KSPREAD_EXPORT Range
135 Range(
const TQString& );
136 Range(
const TQString&,
Map*, Sheet* default_sheet = 0 );
137 Range(
const Range& r );
151 bool isSheetKnown()
const {
return ( !sheetName().isEmpty() && sheet() != 0 ); }
154 void getStartPoint(
Point* pt);
156 void getEndPoint(
Point* pt);
158 int startRow ()
const {
return range().top(); };
159 int startCol ()
const {
return range().left(); };
160 int endRow ()
const {
return range().bottom(); };
161 int endCol ()
const {
return range().right(); };
167 virtual void setRange(
const TQRect& newRange) {_range=newRange;}
169 void setRange(
int newStartCol,
int newStartRow,
int newEndCol,
int newEndRow)
170 { _range=TQRect(newStartCol,newStartRow,newEndCol-newStartCol,newEndRow-newStartRow); }
173 TQRect range()
const;
176 bool contains (
const Point &cell)
const;
181 bool intersects (
const Range &r)
const;
188 TQString toString()
const;
191 void setLeftFixed(
bool fixed);
192 bool leftFixed()
const;
195 void setRightFixed(
bool fixed);
196 bool rightFixed()
const;
199 void setTopFixed(
bool fixed);
200 bool topFixed()
const;
203 void setBottomFixed(
bool fixed);
204 bool bottomFixed()
const;
207 void setSheet(Sheet* sheet);
208 Sheet* sheet()
const;
211 void setSheetName(TQString sheetName);
212 TQString sheetName()
const;
218 TQString namedArea()
const;
223 bool operator==(
const Range& range)
const;
245 TQValueList<Point> cells;
246 TQValueList<Range> ranges;
284bool formatIsDate (FormatType fmt);
285bool formatIsTime (FormatType fmt);
286bool formatIsFraction (FormatType fmt);
290KSPREAD_EXPORT TQString util_rangeName(
const TQRect &_area );
291KSPREAD_EXPORT TQString util_rangeName( Sheet *_sheet,
const TQRect &_area );
292TQString util_rangeColumnName(
const TQRect &_area);
293TQString util_rangeRowName(
const TQRect &_area);
306bool util_isAllSelected(
const TQRect &selection);
307bool util_isColumnSelected(
const TQRect &selection);
308bool util_isRowSelected(
const TQRect &selection);
309bool util_isRowOrColumnSelected(
const TQRect &selection );
313bool util_validateSheetName(
const TQString &name);
315TQDomElement util_createElement(
const TQString & tagName,
const TQFont & font, TQDomDocument & doc );
316TQDomElement util_createElement(
const TQString & tagname,
const TQPen & pen, TQDomDocument & doc );
317TQFont util_toFont( TQDomElement & element );
318TQPen util_toPen( TQDomElement & element );
319int util_penCompare( TQPen
const & pen1, TQPen
const & pen2 );
321TQString convertRefToRange(
const TQString & sheet,
const TQRect & rect );
322TQString convertRefToBase(
const TQString & sheet,
const TQRect & rect );
323TQString convertRangeToRef(
const TQString & sheetName,
const TQRect & _area );
325void insertBracket( TQString & s );
326TQString convertOasisPenToString(
const TQPen & pen );
327TQPen convertOasisStringToPen(
const TQString &str );
330KSPREAD_EXPORT
bool localReferenceAnchor(
const TQString &_ref );
343 KSPREAD_EXPORT TQString decodeFormula(
const TQString& expr,
const TDELocale* locale = 0);
350 KSPREAD_EXPORT TQString encodeFormula(
const TQString& expr,
const TDELocale* locale = 0);
For every cell in the spread sheet there is a Cell object.
A map is a simple container for all sheets.
Represents the position of a single cell in a workbook.
void setSheet(Sheet *sheet)
Sets the sheet which this point lies on.
void setColumnFixed(bool colFixed)
Sets whether or not the column (x coordinate) of this point is fixed (ie.
void setPos(TQPoint pos)
Sets the position of this point (in rows and columns).
void setSheetName(TQString name)
Sets the name of the sheet which this point lies on.
void setRowFixed(bool rowFixed)
Sets whether or not the row (y coordinate) of this point is fixed (ie.
RangeIterator(TQRect _range, Sheet *_sheet)
Contstruct the iterator with the rectangular cell area and which sheet the area is on.
bool isValid() const
Returns true if this Range represents a valid region of a spreadsheet.
bool isSheetKnown() const
Returns true if this range has an associated Sheet or false otherwise.
virtual void setRange(const TQRect &newRange)
Changes the area on the spreadsheet represented by this range.
KSPREAD_EXPORT int util_decodeColumnLabelText(const TQString &_col)
Call this function to decode the text of a column label to an integer i.e.
KSPREAD_EXPORT TQString util_encodeColumnLabelText(int column)
Call this function to encode an integer to the text of the column label i.e.
range-list and cell-list TODO: move to a separate file, improve structure, add iterators and all that...