kspread_util.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __kspread_util_h__
00021 #define __kspread_util_h__
00022
00023 #include <qstring.h>
00024 #include <qrect.h>
00025 #include <qdatetime.h>
00026
00027 #include "kspread_global.h"
00028 #include "kspread_value.h"
00029 #include <koffice_export.h>
00030 class KSpreadCell;
00031 class KSpreadMap;
00032 class KSpreadSheet;
00033 class KLocale;
00034
00035 class QFont;
00036 class QPen;
00037 class QDomElement;
00038 class QDomDocument;
00039
00040 struct KSPREAD_EXPORT KSpreadPoint
00041 {
00042 public:
00043 KSpreadPoint() { pos.setX( -1 ); sheet = 0; columnFixed = false; rowFixed = false; }
00044 KSpreadPoint( const QString& );
00045 KSpreadPoint( const QString&, KSpreadMap*, KSpreadSheet* default_sheet = 0 );
00046 KSpreadPoint( const KSpreadPoint& c ) {
00047 pos = c.pos;
00048 sheet = c.sheet; sheetName = c.sheetName;
00049 columnFixed = c.columnFixed;
00050 rowFixed = c.rowFixed;
00051 }
00052
00053 bool isValid() const { return ( pos.x() >= 0 && ( sheet != 0 || sheetName.isEmpty() ) ); }
00054 bool isSheetKnown() const { return ( !sheetName.isEmpty() && sheet != 0 ); }
00055
00056 KSpreadCell* cell() const;
00057
00058 bool operator== (const KSpreadPoint &cell) const;
00059 bool operator< (const KSpreadPoint &cell) const;
00060
00061 int row () const { return pos.y(); };
00062 int column () const { return pos.x(); };
00063 void setRow (int r) { pos.setY (r); };
00064 void setColumn (int c) { pos.setX (c); };
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 KSpreadSheet* sheet;
00077 QString sheetName;
00078 QPoint pos;
00079 bool columnFixed;
00080 bool rowFixed;
00081
00082 private:
00083 void init( const QString& );
00084 };
00085
00086 struct KSPREAD_EXPORT KSpreadRange
00087 {
00088 KSpreadRange() { sheet = 0; range.setLeft( -1 ); }
00089 KSpreadRange( const QString& );
00090 KSpreadRange( const QString&, KSpreadMap*, KSpreadSheet* default_sheet = 0 );
00091 KSpreadRange( const KSpreadRange& r ) {
00092 sheet = r.sheet;
00093 sheetName = r.sheetName;
00094 range = r.range;
00095 }
00096 KSpreadRange( const KSpreadPoint& ul, const KSpreadPoint& lr )
00097 {
00098 range = QRect( ul.pos, lr.pos );
00099 if ( ul.sheetName != lr.sheetName )
00100 {
00101 range.setLeft( -1 );
00102 return;
00103 }
00104 sheetName = ul.sheetName;
00105 sheet = ul.sheet;
00106 leftFixed = ul.columnFixed;
00107 rightFixed = lr.columnFixed;
00108 topFixed = ul.rowFixed;
00109 bottomFixed = lr.rowFixed;
00110 }
00111
00112 bool isValid() const { return ( range.left() >= 0 && range.right() >= 0 && ( sheet != 0 || sheetName.isEmpty() ) ); }
00113 bool isSheetKnown() const { return ( !sheetName.isEmpty() && sheet != 0 ); }
00114
00115 int startRow () const { return range.top(); };
00116 int startCol () const { return range.left(); };
00117 int endRow () const { return range.bottom(); };
00118 int endCol () const { return range.right(); };
00119
00121 bool contains (const KSpreadPoint &cell) const;
00123 bool intersects (const KSpreadRange &r) const;
00124
00125 KSpreadSheet* sheet;
00126 QString sheetName;
00127 QRect range;
00128 bool leftFixed;
00129 bool rightFixed;
00130 bool topFixed;
00131 bool bottomFixed;
00132 };
00133
00141 struct RangeList {
00142 QValueList<KSpreadPoint> cells;
00143 QValueList<KSpreadRange> ranges;
00144 };
00145
00146
00153 class KSpreadRangeIterator
00154 {
00155 public:
00160 KSpreadRangeIterator(QRect _range, KSpreadSheet* _sheet);
00161 ~KSpreadRangeIterator();
00162
00166 KSpreadCell* first();
00167
00172 KSpreadCell* next();
00173 private:
00174
00175 QRect range;
00176 KSpreadSheet* sheet;
00177 QPoint current;
00178 };
00179
00180
00181 bool formatIsDate (FormatType fmt);
00182 bool formatIsTime (FormatType fmt);
00183 bool formatIsFraction (FormatType fmt);
00184
00185
00186
00187 KSPREAD_EXPORT QString util_rangeName( const QRect &_area );
00188 KSPREAD_EXPORT QString util_rangeName( KSpreadSheet *_sheet, const QRect &_area );
00189 QString util_rangeColumnName( const QRect &_area);
00190 QString util_rangeRowName( const QRect &_area);
00191
00196 KSPREAD_EXPORT int util_decodeColumnLabelText( const QString &_col );
00201 KSPREAD_EXPORT QString util_encodeColumnLabelText( int column );
00202
00203 QString formatNumber( KSpreadValue const & value, QString format, bool & setRed,
00204 KLocale const * const locale, bool insert );
00205
00206 double util_fact( double val, double end );
00207
00208 bool util_isAllSelected(const QRect &selection);
00209 bool util_isColumnSelected(const QRect &selection);
00210 bool util_isRowSelected(const QRect &selection);
00211
00212 bool util_validateSheetName(const QString &name);
00213
00214 QDomElement util_createElement( const QString & tagName, const QFont & font, QDomDocument & doc );
00215 QDomElement util_createElement( const QString & tagname, const QPen & pen, QDomDocument & doc );
00216 QFont util_toFont( QDomElement & element );
00217 QPen util_toPen( QDomElement & element );
00218 int util_penCompare( QPen const & pen1, QPen const & pen2 );
00219
00220 QString convertRefToRange( const QString & sheet, const QRect & rect );
00221 QString convertRefToBase( const QString & sheet, const QRect & rect );
00222 QString convertRangeToRef( const QString & sheetName, const QRect & _area );
00223
00224 void insertBracket( QString & s );
00225 QString convertOasisPenToString( const QPen & pen );
00226 QPen convertOasisStringToPen( const QString &str );
00227
00228
00229 KSPREAD_EXPORT bool localReferenceAnchor( const QString &_ref );
00230
00231
00232 #endif
This file is part of the documentation for kspread Library Version 1.4.2.