001: /*
002: * The contents of this file are subject to the Mozilla Public License Version 1.1
003: * (the "License"); you may not use this file except in compliance with the License.
004: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
005: *
006: * Software distributed under the License is distributed on an "AS IS" basis,
007: * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
008: * for the specific language governing rights and limitations under the License.
009: *
010: * The Original Code is 'iText, a free JAVA-PDF library'.
011: *
012: * The Initial Developer of the Original Code is Bruno Lowagie. Portions created by
013: * the Initial Developer are Copyright (C) 1999, 2000, 2001, 2002 by Bruno Lowagie.
014: * All Rights Reserved.
015: * Co-Developer of the code is Paulo Soares. Portions created by the Co-Developer
016: * are Copyright (C) 2000, 2001, 2002 by Paulo Soares. All Rights Reserved.
017: *
018: * Contributor(s): all the names of the contributors are added in the source code
019: * where applicable.
020: *
021: * Alternatively, the contents of this file may be used under the terms of the
022: * LGPL license (the "GNU LIBRARY GENERAL PUBLIC LICENSE"), in which case the
023: * provisions of LGPL are applicable instead of those above. If you wish to
024: * allow use of your version of this file only under the terms of the LGPL
025: * License and not to allow others to use your version of this file under
026: * the MPL, indicate your decision by deleting the provisions above and
027: * replace them with the notice and other provisions required by the LGPL.
028: * If you do not delete the provisions above, a recipient may use your version
029: * of this file under either the MPL or the GNU LIBRARY GENERAL PUBLIC LICENSE.
030: *
031: * This library is free software; you can redistribute it and/or modify it
032: * under the terms of the MPL as stated above or under the terms of the GNU
033: * Library General Public License as published by the Free Software Foundation;
034: * either version 2 of the License, or any later version.
035: *
036: * This library is distributed in the hope that it will be useful, but WITHOUT
037: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
038: * FOR A PARTICULAR PURPOSE. See the GNU Library general Public License for more
039: * details.
040: *
041: * If you didn't download this code from the following link, you should check if
042: * you aren't using an obsolete version:
043: * http://www.lowagie.com/iText/
044: */
045:
046: package com.lowagie.text.rtf;
047:
048: import java.util.Properties;
049:
050: import com.lowagie.text.BadElementException;
051: import com.lowagie.text.Cell;
052: import com.lowagie.text.Element;
053:
054: /**
055: * A <code>Cell</code> with extended style attributes
056: *
057: * ONLY FOR USE WITH THE RtfWriter NOT with the RtfWriter2.
058: * @deprecated Please move to the RtfWriter2 and associated classes. com.lowagie.text.rtf.table.RtfCell replaces the functionality of this class.
059: */
060: public class RtfTableCell extends Cell {
061: /* Table border styles */
062:
063: /** Table border solid */
064: public static final int BORDER_UNDEFINED = 0;
065:
066: /** Table border solid */
067: public static final int BORDER_SINGLE = 1;
068:
069: /** Table border double thickness */
070: public static final int BORDER_DOUBLE_THICK = 2;
071:
072: /** Table border shadowed */
073: public static final int BORDER_SHADOWED = 3;
074:
075: /** Table border dotted */
076: public static final int BORDER_DOTTED = 4;
077:
078: /** Table border dashed */
079: public static final int BORDER_DASHED = 5;
080:
081: /** Table border hairline */
082: public static final int BORDER_HAIRLINE = 6;
083:
084: /** Table border double line */
085: public static final int BORDER_DOUBLE = 7;
086:
087: /** Table border dot dash line */
088: public static final int BORDER_DOT_DASH = 8;
089:
090: /** Table border dot dot dash line */
091: public static final int BORDER_DOT_DOT_DASH = 9;
092:
093: /** Table border triple line */
094: public static final int BORDER_TRIPLE = 10;
095:
096: /** Table border line */
097: public static final int BORDER_THICK_THIN = 11;
098:
099: /** Table border line */
100: public static final int BORDER_THIN_THICK = 12;
101:
102: /** Table border line */
103: public static final int BORDER_THIN_THICK_THIN = 13;
104:
105: /** Table border line */
106: public static final int BORDER_THICK_THIN_MED = 14;
107:
108: /** Table border line */
109: public static final int BORDER_THIN_THICK_MED = 15;
110:
111: /** Table border line */
112: public static final int BORDER_THIN_THICK_THIN_MED = 16;
113:
114: /** Table border line */
115: public static final int BORDER_THICK_THIN_LARGE = 17;
116:
117: /** Table border line */
118: public static final int BORDER_THIN_THICK_LARGE = 18;
119:
120: /** Table border line */
121: public static final int BORDER_THIN_THICK_THIN_LARGE = 19;
122:
123: /** Table border line */
124: public static final int BORDER_WAVY = 20;
125:
126: /** Table border line */
127: public static final int BORDER_DOUBLE_WAVY = 21;
128:
129: /** Table border line */
130: public static final int BORDER_STRIPED = 22;
131:
132: /** Table border line */
133: public static final int BORDER_EMBOSS = 23;
134:
135: /** Table border line */
136: public static final int BORDER_ENGRAVE = 24;
137:
138: /* Instance variables */
139: private float topBorderWidth;
140: private float leftBorderWidth;
141: private float rightBorderWidth;
142: private float bottomBorderWidth;
143: private int topBorderStyle = 1;
144: private int leftBorderStyle = 1;
145: private int rightBorderStyle = 1;
146: private int bottomBorderStyle = 1;
147:
148: /**
149: * Constructs an empty <CODE>Cell</CODE> (for internal use only).
150: *
151: * @param dummy a dummy value
152: */
153:
154: public RtfTableCell(boolean dummy) {
155: super (dummy);
156: }
157:
158: /**
159: * Constructs a <CODE>Cell</CODE> with a certain <CODE>Element</CODE>.
160: * <P>
161: * if the element is a <CODE>ListItem</CODE>, <CODE>Row</CODE> or
162: * <CODE>Cell</CODE>, an exception will be thrown.
163: *
164: * @param element the element
165: * @throws BadElementException when the creator was called with a <CODE>ListItem</CODE>, <CODE>Row</CODE> or <CODE>Cell</CODE>
166: */
167: public RtfTableCell(Element element) throws BadElementException {
168: super (element);
169: }
170:
171: /**
172: * Constructs a <CODE>Cell</CODE> with a certain content.
173: * <P>
174: * The <CODE>String</CODE> will be converted into a <CODE>Paragraph</CODE>.
175: *
176: * @param content a <CODE>String</CODE>
177: */
178: public RtfTableCell(String content) {
179: super (content);
180: }
181:
182: /**
183: * Returns a <CODE>Cell</CODE> that has been constructed taking in account
184: * the value of some <VAR>attributes</VAR>.
185: *
186: * @param attributes Some attributes
187: */
188:
189: public RtfTableCell(Properties attributes) {
190: super (attributes);
191: }
192:
193: /**
194: * Set all four borders to <code>f</code> width
195: *
196: * @param f the desired width
197: */
198: public void setBorderWidth(float f) {
199: super .setBorderWidth(f);
200: topBorderWidth = f;
201: leftBorderWidth = f;
202: rightBorderWidth = f;
203: bottomBorderWidth = f;
204: }
205:
206: /**
207: * Set the top border to <code>f</code> width
208: *
209: * @param f the desired width
210: */
211: public void setTopBorderWidth(float f) {
212: topBorderWidth = f;
213: }
214:
215: /**
216: * Get the top border width
217: * @return a width
218: */
219: public float topBorderWidth() {
220: return topBorderWidth;
221: }
222:
223: /**
224: * Set the left border to <code>f</code> width
225: *
226: * @param f the desired width
227: */
228: public void setLeftBorderWidth(float f) {
229: leftBorderWidth = f;
230: }
231:
232: /**
233: * Get the left border width
234: * @return a width
235: */
236: public float leftBorderWidth() {
237: return leftBorderWidth;
238: }
239:
240: /**
241: * Set the right border to <code>f</code> width
242: *
243: * @param f the desired width
244: */
245: public void setRightBorderWidth(float f) {
246: rightBorderWidth = f;
247: }
248:
249: /**
250: * Get the right border width
251: * @return a width
252: */
253: public float rightBorderWidth() {
254: return rightBorderWidth;
255: }
256:
257: /**
258: * Set the bottom border to <code>f</code> width
259: *
260: * @param f the desired width
261: */
262: public void setBottomBorderWidth(float f) {
263: bottomBorderWidth = f;
264: }
265:
266: /**
267: * Get the bottom border width
268: * @return a width
269: */
270: public float bottomBorderWidth() {
271: return bottomBorderWidth;
272: }
273:
274: /**
275: * Set all four borders to style defined by <code>style</code>
276: *
277: * @param style the desired style
278: */
279: public void setBorderStyle(int style) {
280: topBorderStyle = style;
281: leftBorderStyle = style;
282: rightBorderStyle = style;
283: bottomBorderStyle = style;
284: }
285:
286: /**
287: * Set the top border to style defined by <code>style</code>
288: *
289: * @param style the desired style
290: */
291: public void setTopBorderStyle(int style) {
292: topBorderStyle = style;
293: }
294:
295: /**
296: * Get the top border style
297: * @return a style value
298: */
299: public int topBorderStyle() {
300: return topBorderStyle;
301: }
302:
303: /**
304: * Set the left border to style defined by <code>style</code>
305: *
306: * @param style the desired style
307: */
308: public void setLeftBorderStyle(int style) {
309: leftBorderStyle = style;
310: }
311:
312: /**
313: * Get the left border style
314: * @return a style value
315: */
316: public int leftBorderStyle() {
317: return leftBorderStyle;
318: }
319:
320: /**
321: * Set the right border to style defined by <code>style</code>
322: *
323: * @param style the desired style
324: */
325: public void setRightBorderStyle(int style) {
326: rightBorderStyle = style;
327: }
328:
329: /**
330: * Get the right border style
331: * @return a style value
332: */
333: public int rightBorderStyle() {
334: return rightBorderStyle;
335: }
336:
337: /**
338: * Set the bottom border to style defined by <code>style</code>
339: *
340: * @param style the desired style
341: */
342: public void setBottomBorderStyle(int style) {
343: bottomBorderStyle = style;
344: }
345:
346: /**
347: * Get the bottom border style
348: * @return a style value
349: */
350: public int bottomBorderStyle() {
351: return bottomBorderStyle;
352: }
353:
354: /**
355: * Get the RTF control word for <code>style</code>
356: * @param style a style value
357: * @return a byte array corresponding with a style control word
358: */
359: protected static byte[] getStyleControlWord(int style) {
360: switch (style) {
361: case BORDER_UNDEFINED:
362: return "brdrs".getBytes();
363: case BORDER_SINGLE:
364: return "brdrs".getBytes();
365: case BORDER_DOUBLE_THICK:
366: return "brdrth".getBytes();
367: case BORDER_SHADOWED:
368: return "brdrsh".getBytes();
369: case BORDER_DOTTED:
370: return "brdrdot".getBytes();
371: case BORDER_DASHED:
372: return "brdrdash".getBytes();
373: case BORDER_HAIRLINE:
374: return "brdrhair".getBytes();
375: case BORDER_DOUBLE:
376: return "brdrdb".getBytes();
377: case BORDER_DOT_DASH:
378: return "brdrdashd".getBytes();
379: case BORDER_DOT_DOT_DASH:
380: return "brdrdashdd".getBytes();
381: case BORDER_TRIPLE:
382: return "brdrtriple".getBytes();
383: case BORDER_THICK_THIN:
384: return "brdrtnthsg".getBytes();
385: case BORDER_THIN_THICK:
386: return "brdrthtnsg".getBytes();
387: case BORDER_THIN_THICK_THIN:
388: return "brdrtnthtnsg".getBytes();
389: case BORDER_THICK_THIN_MED:
390: return "brdrtnthmg".getBytes();
391: case BORDER_THIN_THICK_MED:
392: return "brdrthtnmg".getBytes();
393: case BORDER_THIN_THICK_THIN_MED:
394: return "brdrtnthtnmg".getBytes();
395: case BORDER_THICK_THIN_LARGE:
396: return "brdrtnthlg".getBytes();
397: case BORDER_THIN_THICK_LARGE:
398: return "brdrthtnlg".getBytes();
399: case BORDER_THIN_THICK_THIN_LARGE:
400: return "brdrtnthtnlg".getBytes();
401: case BORDER_WAVY:
402: return "brdrwavy".getBytes();
403: case BORDER_DOUBLE_WAVY:
404: return "brdrwavydb".getBytes();
405: case BORDER_STRIPED:
406: return "brdrdashdotstr".getBytes();
407: case BORDER_EMBOSS:
408: return "brdremboss".getBytes();
409: case BORDER_ENGRAVE:
410: return "brdrengrave".getBytes();
411: }
412:
413: return "brdrs".getBytes();
414: }
415: }
|