~ubuntu-branches/ubuntu/karmic/libitext-java/karmic

« back to all changes in this revision

Viewing changes to com/lowagie/text/rtf/RtfCell.java

  • Committer: Bazaar Package Importer
  • Author(s): Adriaan Peeters
  • Date: 2008-11-23 12:26:51 UTC
  • mfrom: (5.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20081123122651-ab7juwjz41q1123k
Tags: 2.1.4-1
New upstream release

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/**
2
 
 * $Id: RtfCell.java,v 1.38 2006/09/12 13:12:53 blowagie Exp $
3
 
 * $Name:  $
4
 
 *
5
 
 * Copyright 2001, 2002 by Mark Hall
6
 
 *
7
 
 * The contents of this file are subject to the Mozilla Public License Version 1.1
8
 
 * (the "License"); you may not use this file except in compliance with the License.
9
 
 * You may obtain a copy of the License at http://www.mozilla.org/MPL/
10
 
 *
11
 
 * Software distributed under the License is distributed on an "AS IS" basis,
12
 
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13
 
 * for the specific language governing rights and limitations under the License.
14
 
 *
15
 
 * The Original Code is 'iText, a free JAVA-PDF library'.
16
 
 *
17
 
 * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
18
 
 * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
19
 
 * All Rights Reserved.
20
 
 * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
21
 
 * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
22
 
 *
23
 
 * Contributor(s): all the names of the contributors are added in the source code
24
 
 * where applicable.
25
 
 *
26
 
 * Alternatively, the contents of this file may be used under the terms of the
27
 
 * LGPL license (the ?GNU LIBRARY GENERAL PUBLIC LICENSE?), in which case the
28
 
 * provisions of LGPL are applicable instead of those above.  If you wish to
29
 
 * allow use of your version of this file only under the terms of the LGPL
30
 
 * License and not to allow others to use your version of this file under
31
 
 * the MPL, indicate your decision by deleting the provisions above and
32
 
 * replace them with the notice and other provisions required by the LGPL.
33
 
 * If you do not delete the provisions above, a recipient may use your version
34
 
 * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
35
 
 *
36
 
 * This library is free software; you can redistribute it and/or modify it
37
 
 * under the terms of the MPL as stated above or under the terms of the GNU
38
 
 * Library General Public License as published by the Free Software Foundation;
39
 
 * either version 2 of the License, or any later version.
40
 
 *
41
 
 * This library is distributed in the hope that it will be useful, but WITHOUT
42
 
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
43
 
 * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
44
 
 * details.
45
 
 *
46
 
 * If you didn't download this code from the following link, you should check if
47
 
 * you aren't using an obsolete version:
48
 
 * http://www.lowagie.com/iText/
49
 
 */
50
 
 
51
 
package com.lowagie.text.rtf;
52
 
 
53
 
import com.lowagie.text.*;
54
 
 
55
 
import java.util.Iterator;
56
 
import java.io.*;
57
 
import java.awt.Color;
58
 
 
59
 
/**
60
 
 * A Helper Class for the <CODE>RtfWriter</CODE>.
61
 
 * <P>
62
 
 * Do not use it directly
63
 
 * 
64
 
 * ONLY FOR USE WITH THE RtfWriter NOT with the RtfWriter2.
65
 
 *
66
 
 * Parts of this Class were contributed by Steffen Stundzig. Many thanks for the
67
 
 * improvements.
68
 
 * Updates by Benoit Wiart
69
 
 * @deprecated Please move to the RtfWriter2 and associated classes.
70
 
 */
71
 
public class RtfCell {
72
 
    /** Constants for merging Cells */
73
 
 
74
 
    /** A possible value for merging */
75
 
    private static final int MERGE_HORIZ_FIRST = 1;
76
 
    /** A possible value for merging */
77
 
    private static final int MERGE_VERT_FIRST = 2;
78
 
    /** A possible value for merging */
79
 
    private static final int MERGE_BOTH_FIRST = 3;
80
 
    /** A possible value for merging */
81
 
    private static final int MERGE_HORIZ_PREV = 4;
82
 
    /** A possible value for merging */
83
 
    private static final int MERGE_VERT_PREV = 5;
84
 
    /** A possible value for merging */
85
 
    private static final int MERGE_BOTH_PREV = 6;
86
 
 
87
 
    /**
88
 
     * RTF Tags
89
 
     */
90
 
 
91
 
    /** First cell to merge with - Horizontal */
92
 
    private static final byte[] cellMergeFirst = "clmgf".getBytes();
93
 
    /** First cell to merge with - Vertical */
94
 
    private static final byte[] cellVMergeFirst = "clvmgf".getBytes();
95
 
    /** Merge cell with previous horizontal cell */
96
 
    private static final byte[] cellMergePrev = "clmrg".getBytes();
97
 
    /** Merge cell with previous vertical cell */
98
 
    private static final byte[] cellVMergePrev = "clvmrg".getBytes();
99
 
    /** Cell content vertical alignment bottom */
100
 
    private static final byte[] cellVerticalAlignBottom = "clvertalb".getBytes();
101
 
    /** Cell content vertical alignment center */
102
 
    private static final byte[] cellVerticalAlignCenter = "clvertalc".getBytes();
103
 
    /** Cell content vertical alignment top */
104
 
    private static final byte[] cellVerticalAlignTop = "clvertalt".getBytes();
105
 
    /** Cell border left */
106
 
    private static final byte[] cellBorderLeft = "clbrdrl".getBytes();
107
 
    /** Cell border right */
108
 
    private static final byte[] cellBorderRight = "clbrdrr".getBytes();
109
 
    /** Cell border top */
110
 
    private static final byte[] cellBorderTop = "clbrdrt".getBytes();
111
 
    /** Cell border bottom */
112
 
    private static final byte[] cellBorderBottom = "clbrdrb".getBytes();
113
 
    /** Cell background color */
114
 
    private static final byte[] cellBackgroundColor = "clcbpat".getBytes();
115
 
    /** Cell width format */
116
 
    private static final byte[] cellWidthStyle = "clftsWidth3".getBytes();
117
 
    /** Cell width */
118
 
    private static final byte[] cellWidthTag = "clwWidth".getBytes();
119
 
    /** Cell right border position */
120
 
    private static final byte[] cellRightBorder = "cellx".getBytes();
121
 
    /** Cell is part of table */
122
 
    protected static final byte[] cellInTable = "intbl".getBytes();
123
 
    /** End of cell */
124
 
    private static final byte[] cellEnd = "cell".getBytes();
125
 
 
126
 
    /** padding top */
127
 
    private static final byte[] cellPaddingTop = "clpadt".getBytes();
128
 
    /** padding top unit */
129
 
    private static final byte[] cellPaddingTopUnit = "clpadft3".getBytes();
130
 
    /** padding bottom */
131
 
    private static final byte[] cellPaddingBottom = "clpadb".getBytes();
132
 
    /** padding bottom unit */
133
 
    private static final byte[] cellPaddingBottomUnit = "clpadfb3".getBytes();
134
 
    /** padding left */
135
 
    private static final byte[] cellPaddingLeft = "clpadl".getBytes();
136
 
    /** padding left unit */
137
 
    private static final byte[] cellPaddingLeftUnit = "clpadfl3".getBytes();
138
 
    /** padding right */
139
 
    private static final byte[] cellPaddingRight = "clpadr".getBytes();
140
 
    /** padding right unit */
141
 
    private static final byte[] cellPaddingRightUnit = "clpadfr3".getBytes();
142
 
 
143
 
    /** The <code>RtfWriter</code> to which this <code>RtfCell</code> belongs. */
144
 
    private RtfWriter writer = null;
145
 
    /** The <code>RtfTable</code> to which this <code>RtfCell</code> belongs. */
146
 
    private RtfTable mainTable = null;
147
 
 
148
 
    /** Cell width */
149
 
    private int cellWidth = 0;
150
 
    /** Cell right border position */
151
 
    private int cellRight = 0;
152
 
    /** <code>Cell</code> containing the actual data */
153
 
    private Cell store = null;
154
 
    /** Is this an empty cell */
155
 
    private boolean emptyCell = true;
156
 
    /** Type of merging to do */
157
 
    private int mergeType = 0;
158
 
    /** cell padding, because the table only renders the left and right cell padding
159
 
     * and not the top and bottom one
160
 
     */
161
 
    private int cellpadding = 0;
162
 
 
163
 
    /**
164
 
     * Create a new <code>RtfCell</code>.
165
 
     *
166
 
     * @param writer The <code>RtfWriter</code> that this <code>RtfCell</code> belongs to
167
 
     * @param mainTable The <code>RtfTable</code> that created the
168
 
     * <code>RtfRow</code> that created the <code>RtfCell</code> :-)
169
 
     */
170
 
    public RtfCell(RtfWriter writer, RtfTable mainTable) {
171
 
        super();
172
 
        this.writer = writer;
173
 
        this.mainTable = mainTable;
174
 
    }
175
 
 
176
 
    /**
177
 
     * Import a <code>Cell</code>.
178
 
     * <P>
179
 
     * @param cell The <code>Cell</code> containing the data for this
180
 
     * <code>RtfCell</code>
181
 
     * @param cellLeft The position of the left border
182
 
     * @param cellWidth The default width of a cell
183
 
     * @param x The column index of this <code>RtfCell</code>
184
 
     * @param y The row index of this <code>RtfCell</code>
185
 
     * @param cellpadding the cellpadding
186
 
     * @return the position of the right side of the cell
187
 
     */
188
 
    public int importCell(Cell cell, int cellLeft, int cellWidth, int x, int y, int cellpadding) {
189
 
        this.cellpadding = cellpadding;
190
 
 
191
 
        // set this value in any case
192
 
        this.cellWidth = cellWidth;
193
 
        if (cell == null) {
194
 
            cellRight = cellLeft + cellWidth;
195
 
            return cellRight;
196
 
        }
197
 
        if (cell.cellWidth() != null && !cell.cellWidth().equals("")) {
198
 
 
199
 
            this.cellWidth = (int) (Integer.parseInt(cell.cellWidth()) * RtfWriter.TWIPSFACTOR);
200
 
        }
201
 
        cellRight = cellLeft + this.cellWidth;
202
 
        store = cell;
203
 
        emptyCell = false;
204
 
        if (cell.colspan() > 1) {
205
 
            if (cell.rowspan() > 1) {
206
 
                mergeType = MERGE_BOTH_FIRST;
207
 
                for (int i = y; i < y + cell.rowspan(); i++) {
208
 
                    if (i > y) mainTable.setMerge(x, i, MERGE_VERT_PREV, this);
209
 
                    for (int j = x + 1; j < x + cell.colspan(); j++) {
210
 
                        mainTable.setMerge(j, i, MERGE_BOTH_PREV, this);
211
 
                    }
212
 
                }
213
 
            } else {
214
 
                mergeType = MERGE_HORIZ_FIRST;
215
 
                for (int i = x + 1; i < x + cell.colspan(); i++) {
216
 
                    mainTable.setMerge(i, y, MERGE_HORIZ_PREV, this);
217
 
                }
218
 
            }
219
 
        } else if (cell.rowspan() > 1) {
220
 
            mergeType = MERGE_VERT_FIRST;
221
 
            for (int i = y + 1; i < y + cell.rowspan(); i++) {
222
 
                mainTable.setMerge(x, i, MERGE_VERT_PREV, this);
223
 
            }
224
 
        }
225
 
        return cellRight;
226
 
    }
227
 
 
228
 
    /**
229
 
     * Write the properties of the <code>RtfCell</code>.
230
 
     *
231
 
     * @param os The <code>OutputStream</code> to which to write the properties
232
 
     * of the <code>RtfCell</code> to.
233
 
     * @return true if writing the cell settings succeeded
234
 
     * @throws DocumentException
235
 
     */
236
 
    public boolean writeCellSettings(ByteArrayOutputStream os) throws DocumentException {
237
 
        try {
238
 
            float lWidth, tWidth, rWidth, bWidth;
239
 
            byte[] lStyle, tStyle, rStyle, bStyle;
240
 
 
241
 
            if (store instanceof RtfTableCell) {
242
 
                RtfTableCell c = (RtfTableCell) store;
243
 
                lWidth = c.leftBorderWidth();
244
 
                tWidth = c.topBorderWidth();
245
 
                rWidth = c.rightBorderWidth();
246
 
                bWidth = c.bottomBorderWidth();
247
 
                lStyle = RtfTableCell.getStyleControlWord(c.leftBorderStyle());
248
 
                tStyle = RtfTableCell.getStyleControlWord(c.topBorderStyle());
249
 
                rStyle = RtfTableCell.getStyleControlWord(c.rightBorderStyle());
250
 
                bStyle = RtfTableCell.getStyleControlWord(c.bottomBorderStyle());
251
 
            } else {
252
 
                lWidth = tWidth = rWidth = bWidth = store.borderWidth();
253
 
                lStyle = tStyle = rStyle = bStyle = RtfRow.tableBorder;
254
 
            }
255
 
 
256
 
            if (mergeType == MERGE_HORIZ_PREV || mergeType == MERGE_BOTH_PREV) {
257
 
                return true;
258
 
            }
259
 
            switch (mergeType) {
260
 
                case MERGE_VERT_FIRST:
261
 
                    os.write(RtfWriter.escape);
262
 
                    os.write(cellVMergeFirst);
263
 
                    break;
264
 
                case MERGE_BOTH_FIRST:
265
 
                    os.write(RtfWriter.escape);
266
 
                    os.write(cellVMergeFirst);
267
 
                    break;
268
 
                case MERGE_HORIZ_PREV:
269
 
                    os.write(RtfWriter.escape);
270
 
                    os.write(cellMergePrev);
271
 
                    break;
272
 
                case MERGE_VERT_PREV:
273
 
                    os.write(RtfWriter.escape);
274
 
                    os.write(cellVMergePrev);
275
 
                    break;
276
 
                case MERGE_BOTH_PREV:
277
 
                    os.write(RtfWriter.escape);
278
 
                    os.write(cellMergeFirst);
279
 
                    break;
280
 
            }
281
 
            switch (store.verticalAlignment()) {
282
 
                case Element.ALIGN_BOTTOM:
283
 
                    os.write(RtfWriter.escape);
284
 
                    os.write(cellVerticalAlignBottom);
285
 
                    break;
286
 
                case Element.ALIGN_CENTER:
287
 
                case Element.ALIGN_MIDDLE:
288
 
                    os.write(RtfWriter.escape);
289
 
                    os.write(cellVerticalAlignCenter);
290
 
                    break;
291
 
                case Element.ALIGN_TOP:
292
 
                    os.write(RtfWriter.escape);
293
 
                    os.write(cellVerticalAlignTop);
294
 
                    break;
295
 
            }
296
 
 
297
 
            if (((store.border() & Rectangle.LEFT) == Rectangle.LEFT) &&
298
 
                    (lWidth > 0)) {
299
 
                os.write(RtfWriter.escape);
300
 
                os.write(cellBorderLeft);
301
 
                os.write(RtfWriter.escape);
302
 
                os.write(lStyle);
303
 
                os.write(RtfWriter.escape);
304
 
                os.write(RtfRow.tableBorderWidth);
305
 
                writeInt(os, (int) (lWidth * RtfWriter.TWIPSFACTOR));
306
 
                os.write(RtfWriter.escape);
307
 
                os.write(RtfRow.tableBorderColor);
308
 
                if (store.borderColor() == null)
309
 
                    writeInt(os, writer.addColor(new
310
 
                            Color(0, 0, 0)));
311
 
                else
312
 
                    writeInt(os, writer.addColor(store.borderColor()));
313
 
                os.write((byte) '\n');
314
 
            }
315
 
            if (((store.border() & Rectangle.TOP) == Rectangle.TOP) && (tWidth > 0)) {
316
 
                os.write(RtfWriter.escape);
317
 
                os.write(cellBorderTop);
318
 
                os.write(RtfWriter.escape);
319
 
                os.write(tStyle);
320
 
                os.write(RtfWriter.escape);
321
 
                os.write(RtfRow.tableBorderWidth);
322
 
                writeInt(os, (int) (tWidth * RtfWriter.TWIPSFACTOR));
323
 
                os.write(RtfWriter.escape);
324
 
                os.write(RtfRow.tableBorderColor);
325
 
                if (store.borderColor() == null)
326
 
                    writeInt(os, writer.addColor(new
327
 
                            Color(0, 0, 0)));
328
 
                else
329
 
                    writeInt(os, writer.addColor(store.borderColor()));
330
 
                os.write((byte) '\n');
331
 
            }
332
 
            if (((store.border() & Rectangle.BOTTOM) == Rectangle.BOTTOM) &&
333
 
                    (bWidth > 0)) {
334
 
                os.write(RtfWriter.escape);
335
 
                os.write(cellBorderBottom);
336
 
                os.write(RtfWriter.escape);
337
 
                os.write(bStyle);
338
 
                os.write(RtfWriter.escape);
339
 
                os.write(RtfRow.tableBorderWidth);
340
 
                writeInt(os, (int) (bWidth * RtfWriter.TWIPSFACTOR));
341
 
                os.write(RtfWriter.escape);
342
 
                os.write(RtfRow.tableBorderColor);
343
 
                if (store.borderColor() == null)
344
 
                    writeInt(os, writer.addColor(new
345
 
                            Color(0, 0, 0)));
346
 
                else
347
 
                    writeInt(os, writer.addColor(store.borderColor()));
348
 
                os.write((byte) '\n');
349
 
            }
350
 
            if (((store.border() & Rectangle.RIGHT) == Rectangle.RIGHT) &&
351
 
                    (rWidth > 0)) {
352
 
                os.write(RtfWriter.escape);
353
 
                os.write(cellBorderRight);
354
 
                os.write(RtfWriter.escape);
355
 
                os.write(rStyle);
356
 
                os.write(RtfWriter.escape);
357
 
                os.write(RtfRow.tableBorderWidth);
358
 
                writeInt(os, (int) (rWidth * RtfWriter.TWIPSFACTOR));
359
 
                os.write(RtfWriter.escape);
360
 
                os.write(RtfRow.tableBorderColor);
361
 
                if (store.borderColor() == null)
362
 
                    writeInt(os, writer.addColor(new
363
 
                            Color(0, 0, 0)));
364
 
                else
365
 
                    writeInt(os, writer.addColor(store.borderColor()));
366
 
                os.write((byte) '\n');
367
 
            }
368
 
            os.write(RtfWriter.escape);
369
 
            os.write(cellBackgroundColor);
370
 
            if (store.backgroundColor() == null) {
371
 
                writeInt(os, writer.addColor(new Color(255, 255, 255)));
372
 
            } else {
373
 
                writeInt(os, writer.addColor(store.backgroundColor()));
374
 
            }
375
 
            os.write((byte) '\n');
376
 
            os.write(RtfWriter.escape);
377
 
            os.write(cellWidthStyle);
378
 
            os.write((byte) '\n');
379
 
            os.write(RtfWriter.escape);
380
 
            os.write(cellWidthTag);
381
 
            writeInt(os, cellWidth);
382
 
            os.write((byte) '\n');
383
 
            if (cellpadding > 0) {
384
 
                // values
385
 
                os.write(RtfWriter.escape);
386
 
                os.write(cellPaddingLeft);
387
 
                writeInt(os, cellpadding / 2);
388
 
                os.write(RtfWriter.escape);
389
 
                os.write(cellPaddingTop);
390
 
                writeInt(os, cellpadding / 2);
391
 
                os.write(RtfWriter.escape);
392
 
                os.write(cellPaddingRight);
393
 
                writeInt(os, cellpadding / 2);
394
 
                os.write(RtfWriter.escape);
395
 
                os.write(cellPaddingBottom);
396
 
                writeInt(os, cellpadding / 2);
397
 
                // unit
398
 
                os.write(RtfWriter.escape);
399
 
                os.write(cellPaddingLeftUnit);
400
 
                os.write(RtfWriter.escape);
401
 
                os.write(cellPaddingTopUnit);
402
 
                os.write(RtfWriter.escape);
403
 
                os.write(cellPaddingRightUnit);
404
 
                os.write(RtfWriter.escape);
405
 
                os.write(cellPaddingBottomUnit);
406
 
            }
407
 
            os.write(RtfWriter.escape);
408
 
            os.write(cellRightBorder);
409
 
            writeInt(os, cellRight);
410
 
        } catch (IOException e) {
411
 
            return false;
412
 
        }
413
 
        return true;
414
 
    }
415
 
 
416
 
    /**
417
 
     * Write the content of the <code>RtfCell</code>.
418
 
     *
419
 
     * @param os The <code>OutputStream</code> to which to write the content of
420
 
     * the <code>RtfCell</code> to.
421
 
     * @return true if writing the cell content succeeded
422
 
     * @throws DocumentException
423
 
     */
424
 
    public boolean writeCellContent(ByteArrayOutputStream os) throws DocumentException {
425
 
        try {
426
 
            if (mergeType == MERGE_HORIZ_PREV || mergeType == MERGE_BOTH_PREV) {
427
 
                return true;
428
 
            }
429
 
            
430
 
            if (!emptyCell) {
431
 
                Iterator cellIterator = store.getElements();
432
 
                Paragraph container = null;
433
 
                while (cellIterator.hasNext()) {
434
 
                    Element element = (Element) cellIterator.next();
435
 
                    // should we wrap it in a paragraph
436
 
                    if(!(element instanceof Paragraph)) {
437
 
                        if(container != null) {
438
 
                            container.add(element);
439
 
                        } else {
440
 
                            container = new Paragraph();
441
 
                            container.setAlignment(store.horizontalAlignment());
442
 
                            container.add(element);
443
 
                        }
444
 
                    } else {
445
 
                        if(container != null) {
446
 
                            writer.addElement(container, os);
447
 
                            container =null;
448
 
                            container =null;
449
 
                        }
450
 
                        
451
 
                        
452
 
                        // if horizontal alignment is undefined overwrite
453
 
                        // with that of enclosing cell
454
 
                        if (element instanceof Paragraph && ((Paragraph) element).alignment() == Element.ALIGN_UNDEFINED) {
455
 
                            ((Paragraph) element).setAlignment(store.horizontalAlignment());
456
 
                        }
457
 
                        writer.addElement(element, os);
458
 
                        if (element.type() == Element.PARAGRAPH && cellIterator.hasNext()) {
459
 
                            os.write(RtfWriter.escape);
460
 
                            os.write(RtfWriter.paragraph);
461
 
                        }
462
 
                    }
463
 
                }
464
 
                if(container != null) {
465
 
                    writer.addElement(container, os);
466
 
                    container =null;
467
 
                }
468
 
            } else {
469
 
                os.write(RtfWriter.escape);
470
 
                os.write(RtfWriter.paragraphDefaults);
471
 
                os.write(RtfWriter.escape);
472
 
                os.write(cellInTable);
473
 
            }
474
 
            os.write(RtfWriter.escape);
475
 
            os.write(cellEnd);
476
 
        } catch (IOException e) {
477
 
            return false;
478
 
        }
479
 
        return true;
480
 
    }
481
 
 
482
 
    /**
483
 
     * Sets the merge type and the <code>RtfCell</code> with which this
484
 
     * <code>RtfCell</code> is to be merged.
485
 
     *
486
 
     * @param mergeType The merge type specifies the kind of merge to be applied
487
 
     * (MERGE_HORIZ_PREV, MERGE_VERT_PREV, MERGE_BOTH_PREV)
488
 
     * @param mergeCell The <code>RtfCell</code> that the cell at x and y is to
489
 
     * be merged with
490
 
     */
491
 
    public void setMerge(int mergeType, RtfCell mergeCell) {
492
 
        this.mergeType = mergeType;
493
 
        store = mergeCell.getStore();
494
 
    }
495
 
 
496
 
    /**
497
 
     * Get the <code>Cell</code> with the actual content.
498
 
     *
499
 
     * @return <code>Cell</code> which is contained in the <code>RtfCell</code>
500
 
     */
501
 
    public Cell getStore() {
502
 
        return store;
503
 
    }
504
 
 
505
 
    /**
506
 
     * Get the with of this <code>RtfCell</code>
507
 
     *
508
 
     * @return Width of the current <code>RtfCell</code>
509
 
     */
510
 
    public int getCellWidth() {
511
 
        return cellWidth;
512
 
    }
513
 
 
514
 
    /**
515
 
     * sets the width of the cell
516
 
     * @param value a width
517
 
     */
518
 
    public void setCellWidth(int value) {
519
 
        cellWidth = value;
520
 
    }
521
 
 
522
 
    /**
523
 
     * Get the position of the right border of this <code>RtfCell</code>.
524
 
     * @return position of the right border
525
 
     */
526
 
    public int getCellRight() {
527
 
        return cellRight;
528
 
    }
529
 
 
530
 
 
531
 
    /**
532
 
     * Sets the right position of the cell
533
 
     * @param value a cell position
534
 
     */
535
 
    public void setCellRight(int value) {
536
 
        cellRight = value;
537
 
    }
538
 
 
539
 
    /**
540
 
     * Write an Integer to the Outputstream.
541
 
     *
542
 
     * @param out The <code>OutputStream</code> to be written to.
543
 
     * @param i The int to be written.
544
 
     * @throws IOException
545
 
     */
546
 
    private void writeInt(ByteArrayOutputStream out, int i) throws IOException {
547
 
        out.write(Integer.toString(i).getBytes());
548
 
    }
549
 
}