filters

sheet.h
1/* Swinder - Portable library for spreadsheet
2 Copyright (C) 2003 Ariya Hidayat <ariya@kde.org>
3
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.
8
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.
13
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., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA
18*/
19
20#ifndef SWINDER_SHEET_H
21#define SWINDER_SHEET_H
22
23#include "ustring.h"
24#include "format.h"
25
26namespace Swinder
27{
28
29class Workbook;
30class Cell;
31class Column;
32class Row;
33
34class Sheet
35{
36public:
37
38 Sheet( Workbook* workbook );
39
40 virtual ~Sheet();
41
42 // get workbook that owns this sheet
43 Workbook* workbook();
44
45 /*
46 * Clears the sheet, i.e. makes it as if it is just constructed.
47 */
48 void clear();
49
50 void setName( const UString& name );
51
52 UString name() const;
53
54 // return cell at specified column and row
55 // automatically create the cell if previously there is no cell there
56 // return NULL if no cell there _and_ autoCreate is false
57 // first column (A) is 0, first row is 0
58 Cell* cell( unsigned column, unsigned row, bool autoCreate = true );
59
60 Column* column( unsigned index, bool autoCreate = true );
61
62 Row* row( unsigned index, bool autoCreate = true );
63
64 bool visible() const;
65 void setVisible( bool v );
66
67 bool protect() const;
68 void setProtect( bool p );
69
70 /*
71 * &P current page number
72 * &D current date
73 * &T current time
74 * &A sheet name
75 * &F file name without path
76 * &Z file path without file name
77 * &G picture
78 * &B bold on/off
79 * &I italic on/off
80 * &U underlining on/off
81 * &E double underlining on/off
82 * &S strikeout on/off
83 * &X superscript on/off
84 * &Y subscript on/off
85 *
86 * &"<fontname>" set font name
87 * &"<fontname>,<fontstyle>" set font name and style
88 * &<fontheight> set font height
89
90 */
91
92 UString leftHeader() const;
93 void setLeftHeader( const UString& h );
94 UString centerHeader() const;
95 void setCenterHeader( const UString& h );
96 UString rightHeader() const;
97 void setRightHeader( const UString& h );
98
99 UString leftFooter() const;
100 void setLeftFooter( const UString& f );
101 UString centerFooter() const;
102 void setCenterFooter( const UString& f );
103 UString rightFooter() const;
104 void setRightFooter( const UString& f );
105
106 // left margin, in points (pt)
107 double leftMargin() const;
108 void setLeftMargin( double m );
109
110 // right margin, in points (pt)
111 double rightMargin() const;
112 void setRightMargin( double m );
113
114 // top margin, in points (pt)
115 double topMargin() const;
116 void setTopMargin( double m );
117
118 // bottom margin, in points (pt)
119 double bottomMargin() const;
120 void setBottomMargin( double m );
121
122 unsigned maxRow() const;
123 unsigned maxColumn() const;
124
125private:
126 // no copy or assign
127 Sheet( const Sheet& );
128 Sheet& operator=( const Sheet& );
129
130 class Private;
131 Private *d;
132};
133
134class Column
135{
136public:
137
138 Column( Sheet* sheet, unsigned index );
139
140 virtual ~Column();
141
142 Sheet* sheet() const;
143
144 unsigned index() const;
145
146 // width of column, in pt
147 double width() const;
148
149 // set the width of column, in pt
150 void setWidth( double w );
151
152 const Format& format() const;
153
154 void setFormat( const Format& f );
155
156 void setFormatIndex( int index );
157
158 int formatIndex() const;
159
160 bool visible() const;
161
162 void setVisible( bool v );
163
164private:
165 // no copy or assign
166 Column( const Column& );
167 Column& operator=( const Column& );
168
169 class Private;
170 Private *d;
171};
172
173class Row
174{
175public:
176
177 Row( Sheet* sheet, unsigned index );
178
179 virtual ~Row();
180
181 Sheet* sheet() const;
182
183 unsigned index() const;
184
185 // height of row, in pt
186 double height() const;
187
188 // set the height of row, in pt
189 void setHeight( double w );
190
191 const Format& format() const;
192
193 void setFormat( const Format& f );
194
195 void setFormatIndex( int index );
196
197 int formatIndex() const;
198
199 bool visible() const;
200
201 void setVisible( bool v );
202
203private:
204 // no copy or assign
205 Row( const Row& );
206 Row& operator=( const Row& );
207
208 class Private;
209 Private *d;
210};
211
212
213}
214
215#endif // SWINDER_SHEET_H
216