1 */
56
57
58
59 package org.apache.poi.hssf.usermodel;
60 * <P>
86
87 * @author Shawn Laubach (laubach@acm.org)
88
89 */
90
91 public class HSSFFooter extends Object {
92
93
94
95 FooterRecord footerRecord;
96
97 String left;
98
99 String center;
100
101 String right;
102
103
104
105 /**
106
107 * Constructor. Creates a new footer interface from a footer record
108
109 * @param footerRecord Footer record to create the footer with
110
111 */
112
113 protected HSSFFooter(FooterRecord footerRecord) {
114
115 this.footerRecord = footerRecord;
116
117 String foot = footerRecord.getFooter();
118
119 }
120
121
122
123 /**
124
125 * Get the left side of the footer.
126
127 * @return The string representing the left side.
128
129 */
130
131 public String getLeft() {
132
133 return left;
134
135 }
136
137
138
139 /**
140
141 * Sets the left string.
142
143 * @newLeft The string to set as the left side.
144
145 */
146
147 public void setLeft(String newLeft) {
148
149 left = newLeft;
150
151 createFooterString();
152
153 }
154
155
156
157 /**
158
159 * Get the center of the footer.
160
161 * @return The string representing the center.
162
163 */
164
165 public String getCenter() {
166
167 return center;
168
169 }
170
171
172
173 /**
174
175 * Sets the center string.
176
177 * @newLeft The string to set as the center.
178
179 */
180
181 public void setCenter(String newCenter) {
182
183 center = newCenter;
184
185 createFooterString();
186
187 }
188
189
190
191 /**
192
193 * Get the right side of the footer.
194
195 * @return The string representing the right side.
196
197 */
198
199 public String getRight() {
200
201 return right;
202
203 }
204
205
206
207 /**
208
209 * Sets the right string.
210
211 * @newLeft The string to set as the right side.
212
213 */
214
215 public void setRight(String newRight) {
216
217 right = newRight;
218
219 createFooterString();
220
221 }
222
223
224
225 /**
226
227 * Creates the complete footer string based on the left, center, and middle
228
229 * strings.
230
231 */
232
233 private void createFooterString() {
234
235 footerRecord.setFooter(
236
237 "&C" + (center == null ? "" : center) +
238
239 "&L" + (left == null ? "" : left) +
240
241 "&R" + (right == null ? "" : right));
242
243 footerRecord.setFooterLength((byte)footerRecord.getFooter().length());
244
245 }
246
247
248
249 /**
250
251 * Returns the string that represents the change in font size.
252
253 * @param size the new font size
254
255 * @return The special string to represent a new font size
256
257 */
258
259 public static String fontSize(short size) {
260
261 return "&" + size;
262
263 }
264
265
266
267 /**
268
269 * Returns the string that represents the change in font.
270
271 * @param font the new font
272
273 * @param style the fonts style
274
275 * @return The special string to represent a new font size
276
277 */
278
279 public static String font(String font, String style) {
280
281 return "&\"" + font + "," + style + "\"";
282
283 }
284
285
286
287 /**
288
289 * Returns the string representing the current page number
290
291 * @return The special string for page number
292
293 */
294
295 public static String page() {
296
297 return "&P";
298
299 }
300
301
302
303 /**
304
305 * Returns the string representing the number of pages.
306
307 * @return The special string for the number of pages
308
309 */
310
311 public static String numPages() {
312
313 return "&N";
314
315 }
316
317
318
319 /**
320
321 * Returns the string representing the current date
322
323 * @return The special string for the date
324
325 */
326
327 public static String date() {
328
329 return "&D";
330
331 }
332
333
334
335 /**
336
337 * Returns the string representing the current time
338
339 * @return The special string for the time
340
341 */
342
343 public static String time() {
344
345 return "&T";
346
347 }
348
349
350
351 /**
352
353 * Returns the string representing the current file name
354
355 * @return The special string for the file name
356
357 */
358
359 public static String file() {
360
361 return "&F";
362
363 }
364
365
366
367 /**
368
369 * Returns the string representing the current tab (sheet) name
370
371 * @return The special string for tab name
372
373 */
374
375 public static String tab() {
376
377 return "&A";
378
379 }
380
381 }
382
383
384
385 ??????????????HSSFFooter?????????????????????????????????Object???FooterRecord????????????????footerRecord??????????left??????????center??????????right????????????????HSSFFooter????????????????????????FooterRecord?????????????????????????footerRecord???????????????????footerRecord????????????????????????????????getFooter????????????????????getLeft????????????left??????????????????setLeft?????left????????????newLeft?????createFooterString????????????????????getCenter????????????center??????????????????setCenter?????center??????????????newCenter?????createFooterString????????????????????getRight????????????right??????????????????setRight?????right?????????????newRight?????createFooterString???????????????????createFooterString?????footerRecord??????????????????setFooter?????????????center???????????????????????????????????center?????????????left?????????????????????????????????left?????????????right??????????????????????????????????right?????footerRecord??????????????????setFooterLength????????????????????????????????????????footerRecord?????????????????????????????????????????????????????getFooter???????????????????????????fontSize??????????????????size???????????????????????????font????????????????????font?????????????????????????????????style???????????????????????????page???????????????????????????numPages???????????????????????????date???????????????????????????time???????????????????????????file???????????????????????????tab