1
/* Sidewinder - Portable library for spreadsheet
2
Copyright (C) 2003 Ariya Hidayat <ariya@kde.org>
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Library General Public
6
License as published by the Free Software Foundation; either
7
version 2 of the License, or (at your option) any later version.
9
This library is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
Library General Public License for more details.
14
You should have received a copy of the GNU Library General Public License
15
along with this library; see the file COPYING.LIB. If not, write to
16
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
Boston, MA 02111-1307, US
37
// hash to store cell, FIXME replace with quad-tree
38
std::map<unsigned,Cell*> cells;
41
std::map<unsigned,Column*> columns;
42
std::map<unsigned,Row*> rows;
62
using namespace Sidewinder;
64
Sheet::Sheet( Workbook* wb )
66
d = new Sheet::Private();
68
d->name = "Sheet"; // FIXME better name ?
73
d->leftMargin = 54; // 0.75 inch
74
d->rightMargin = 54; // 0.75 inch
75
d->topMargin = 72; // 1 inch
76
d->bottomMargin = 72; // 1 inch
81
// TODO delete all cells, columns, rows
85
Workbook* Sheet::workbook()
90
UString Sheet::name() const
95
void Sheet::setName( const UString& name )
100
Cell* Sheet::cell( unsigned column, unsigned row, bool autoCreate )
102
unsigned hashed = (row+1)*1024 + column + 1;
103
Cell* c = d->cells[ hashed ];
105
// create cell if necessary
106
if( !c && autoCreate )
108
c = new Cell( this, column, row );
109
d->cells[ hashed ] = c;
111
if( row > d->maxRow ) d->maxRow = row;
112
if( column > d->maxColumn ) d->maxColumn = column;
118
Column* Sheet::column( unsigned index, bool autoCreate )
120
Column* c = d->columns[ index ];
122
// create column if necessary
123
if( !c && autoCreate )
125
c = new Column( this, index );
126
d->columns[ index ] = c;
127
if( index > d->maxColumn ) d->maxColumn = index;
133
Row* Sheet::row( unsigned index, bool autoCreate )
135
Row* r = d->rows[ index ];
137
// create row if necessary
138
if( !r && autoCreate )
140
r = new Row( this, index );
141
d->rows[ index ] = r;
142
if( index > d->maxRow ) d->maxRow = index;
148
unsigned Sheet::maxRow() const
153
unsigned Sheet::maxColumn() const
158
bool Sheet::visible() const
163
void Sheet::setVisible( bool v )
168
bool Sheet::protect() const
173
void Sheet::setProtect( bool p )
178
UString Sheet::leftHeader() const
180
return d->leftHeader;
183
void Sheet::setLeftHeader( const UString& h )
188
UString Sheet::centerHeader() const
190
return d->centerHeader;
193
void Sheet::setCenterHeader( const UString& h )
198
UString Sheet::rightHeader() const
200
return d->rightHeader;
203
void Sheet::setRightHeader( const UString& h )
208
UString Sheet::leftFooter() const
210
return d->leftFooter;
213
void Sheet::setLeftFooter( const UString& h )
218
UString Sheet::centerFooter() const
220
return d->centerFooter;
223
void Sheet::setCenterFooter( const UString& h )
228
UString Sheet::rightFooter() const
230
return d->rightFooter;
233
void Sheet::setRightFooter( const UString& h )
238
double Sheet::leftMargin() const
240
return d->leftMargin;
243
void Sheet::setLeftMargin( double m )
248
double Sheet::rightMargin() const
250
return d->rightMargin;
253
void Sheet::setRightMargin( double m )
258
double Sheet::topMargin() const
263
void Sheet::setTopMargin( double m )
268
double Sheet::bottomMargin() const
270
return d->bottomMargin;
273
void Sheet::setBottomMargin( double m )
278
class Column::Private
288
Column::Column( Sheet* sheet, unsigned index )
290
d = new Column::Private;
302
Sheet* Column::sheet() const
307
unsigned Column::index() const
312
double Column::width() const
317
void Column::setWidth( double w )
322
const Format& Column::format() const
327
void Column::setFormat( const Format& f )
332
bool Column::visible() const
337
void Column::setVisible( bool b )
352
Row::Row( Sheet* sheet, unsigned index )
354
d = new Row::Private;
366
Sheet* Row::sheet() const
371
unsigned Row::index() const
376
double Row::height() const
381
void Row::setHeight( double w )
386
const Format& Row::format() const
391
void Row::setFormat( const Format& f )
396
bool Row::visible() const
401
void Row::setVisible( bool b )
1
/* Swinder - Portable library for spreadsheet
2
Copyright (C) 2003 Ariya Hidayat <ariya@kde.org>
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Library General Public
6
License as published by the Free Software Foundation; either
7
version 2 of the License, or (at your option) any later version.
9
This library is distributed in the hope that it will be useful,
10
but WITHOUT ANY WARRANTY; without even the implied warranty of
11
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12
Library General Public License for more details.
14
You should have received a copy of the GNU Library General Public License
15
along with this library; see the file COPYING.LIB. If not, write to
16
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17
Boston, MA 02111-1307, US
37
// hash to store cell, FIXME replace with quad-tree
38
std::map<unsigned,Cell*> cells;
41
std::map<unsigned,Column*> columns;
42
std::map<unsigned,Row*> rows;
62
using namespace Swinder;
64
Sheet::Sheet( Workbook* wb )
66
d = new Sheet::Private();
68
d->name = "Sheet"; // FIXME better name ?
73
d->leftMargin = 54; // 0.75 inch
74
d->rightMargin = 54; // 0.75 inch
75
d->topMargin = 72; // 1 inch
76
d->bottomMargin = 72; // 1 inch
85
Workbook* Sheet::workbook()
93
std::map<unsigned,Cell*>::iterator cell_it;
94
for( cell_it = d->cells.begin(); cell_it != d->cells.end(); ++cell_it )
95
delete cell_it->second;
98
std::map<unsigned,Column*>::iterator col_it;
99
for( col_it = d->columns.begin(); col_it != d->columns.end(); ++col_it )
100
delete col_it->second;
103
std::map<unsigned,Row*>::iterator row_it;
104
for( row_it = d->rows.begin(); row_it != d->rows.end(); ++row_it )
105
delete row_it->second;
108
UString Sheet::name() const
113
void Sheet::setName( const UString& name )
118
Cell* Sheet::cell( unsigned column, unsigned row, bool autoCreate )
120
unsigned hashed = (row+1)*1024 + column + 1;
121
Cell* c = d->cells[ hashed ];
123
// create cell if necessary
124
if( !c && autoCreate )
126
c = new Cell( this, column, row );
127
d->cells[ hashed ] = c;
129
if( row > d->maxRow ) d->maxRow = row;
130
if( column > d->maxColumn ) d->maxColumn = column;
136
Column* Sheet::column( unsigned index, bool autoCreate )
138
Column* c = d->columns[ index ];
140
// create column if necessary
141
if( !c && autoCreate )
143
c = new Column( this, index );
144
d->columns[ index ] = c;
145
if( index > d->maxColumn ) d->maxColumn = index;
151
Row* Sheet::row( unsigned index, bool autoCreate )
153
Row* r = d->rows[ index ];
155
// create row if necessary
156
if( !r && autoCreate )
158
r = new Row( this, index );
159
d->rows[ index ] = r;
160
if( index > d->maxRow ) d->maxRow = index;
166
unsigned Sheet::maxRow() const
171
unsigned Sheet::maxColumn() const
176
bool Sheet::visible() const
181
void Sheet::setVisible( bool v )
186
bool Sheet::protect() const
191
void Sheet::setProtect( bool p )
196
UString Sheet::leftHeader() const
198
return d->leftHeader;
201
void Sheet::setLeftHeader( const UString& h )
206
UString Sheet::centerHeader() const
208
return d->centerHeader;
211
void Sheet::setCenterHeader( const UString& h )
216
UString Sheet::rightHeader() const
218
return d->rightHeader;
221
void Sheet::setRightHeader( const UString& h )
226
UString Sheet::leftFooter() const
228
return d->leftFooter;
231
void Sheet::setLeftFooter( const UString& h )
236
UString Sheet::centerFooter() const
238
return d->centerFooter;
241
void Sheet::setCenterFooter( const UString& h )
246
UString Sheet::rightFooter() const
248
return d->rightFooter;
251
void Sheet::setRightFooter( const UString& h )
256
double Sheet::leftMargin() const
258
return d->leftMargin;
261
void Sheet::setLeftMargin( double m )
266
double Sheet::rightMargin() const
268
return d->rightMargin;
271
void Sheet::setRightMargin( double m )
276
double Sheet::topMargin() const
281
void Sheet::setTopMargin( double m )
286
double Sheet::bottomMargin() const
288
return d->bottomMargin;
291
void Sheet::setBottomMargin( double m )
296
class Column::Private
306
Column::Column( Sheet* sheet, unsigned index )
308
d = new Column::Private;
320
Sheet* Column::sheet() const
325
unsigned Column::index() const
330
double Column::width() const
335
void Column::setWidth( double w )
340
const Format& Column::format() const
345
void Column::setFormat( const Format& f )
350
bool Column::visible() const
355
void Column::setVisible( bool b )
370
Row::Row( Sheet* sheet, unsigned index )
372
d = new Row::Private;
384
Sheet* Row::sheet() const
389
unsigned Row::index() const
394
double Row::height() const
399
void Row::setHeight( double w )
404
const Format& Row::format() const
409
void Row::setFormat( const Format& f )
414
bool Row::visible() const
419
void Row::setVisible( bool b )