Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/jfor/jfor/rtflib/rtfdoc/BorderAttributesConverter.java


1   package org.jfor.jfor.rtflib.rtfdoc;
2   
3   /*-----------------------------------------------------------------------------
4    * jfor - Open-Source XSL-FO to RTF converter - see www.jfor.org
5    *
6    * ====================================================================
7    * jfor Apache-Style Software License.
8    * Copyright (c) 2002 by the jfor project. All rights reserved.
9    *
10   * Redistribution and use in source and binary forms, with or without
11   * modification, are permitted provided that the following conditions
12   * are met:
13   *
14   * 1. Redistributions of source code must retain the above copyright
15   * notice, this list of conditions and the following disclaimer.
16   *
17   * 2. Redistributions in binary form must reproduce the above copyright
18   * notice, this list of conditions and the following disclaimer in
19   * the documentation and/or other materials provided with the
20   * distribution.
21   *
22   * 3. The end-user documentation included with the redistribution,
23   * if any, must include the following acknowledgment:
24   * "This product includes software developed
25   * by the jfor project (http://www.jfor.org)."
26   * Alternately, this acknowledgment may appear in the software itself,
27   * if and wherever such third-party acknowledgments normally appear.
28   *
29   * 4. The name "jfor" must not be used to endorse
30   * or promote products derived from this software without prior written
31   * permission.  For written permission, please contact info@jfor.org.
32   *
33   * 5. Products derived from this software may not be called "jfor",
34   * nor may "jfor" appear in their name, without prior written
35   * permission of info@jfor.org.
36   *
37   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
38   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
39   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
40   * DISCLAIMED.  IN NO EVENT SHALL THE JFOR PROJECT OR ITS CONTRIBUTORS BE
41   * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
42   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
43   * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
44   * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
45   * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
46   * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
47   * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
48   * ====================================================================
49   * Contributor(s):
50   * Christopher Scott, scottc@westinghouse.com
51   * Portions created by Christopher Scott are Coypright (C) 2001
52   * Westinghouse Electric Company. All Rights Reserved.
53  -----------------------------------------------------------------------------*/
54  
55  //------------------------------------------------------------------------------
56  // $Id: BorderAttributesConverter.java,v 1.3 2003/02/18 16:10:56 rmarra Exp $
57  // $Log: BorderAttributesConverter.java,v $
58  // Revision 1.3  2003/02/18 16:10:56  rmarra
59  // Contributions Normand Massé
60  // inheritance and other fixes
61  //
62  // Revision 1.2  2002/07/12 08:08:31  bdelacretaz
63  // License changed to jfor Apache-style license
64  //
65  // Revision 1.1  2001/12/28 17:10:23  bdelacretaz
66  // V0.5.2 - first integration of Chris Scott's changes
67  //
68  //------------------------------------------------------------------------------
69  
70  /** Constants for RTF border attribute names, and a static method for converting fo attribute strings. */
71  
72  public class BorderAttributesConverter {
73      
74      public static final String BORDER_SINGLE_THICKNESS = "brdrs";
75      public static final String BORDER_DOUBLE_THICKNESS = "brdrth";
76      public static final String BORDER_SHADOWED ="brdrsh";
77      public static final String BORDER_DOUBLE ="brdrdb";
78      public static final String BORDER_DOTTED ="brdrdot";
79      public static final String BORDER_DASH ="brdrdash";
80      public static final String BORDER_HAIRLINE ="brdrhair";
81      public static final String BORDER_DASH_SMALL ="brdrdashsm";
82      public static final String BORDER_DOT_DASH = "brdrdashd";
83      public static final String BORDER_DOT_DOT_DASH = "brdrdashdd";
84      public static final String BORDER_TRIPLE = "brdrtriple";
85      public static final String BORDER_THINK_THIN_SMALL = "brdrtnthsg";
86      public static final String BORDER_THIN_THICK_SMALL = "brdrthtnsg";
87      public static final String BORDER_THIN_THICK_THIN_SMALL = "brdrthtnthsg";
88      public static final String BORDER_THINK_THIN_MEDIUM = "brdrtnthmg";
89      public static final String BORDER_THIN_THICK_MEDIUM = "brdrthtnmg";
90      public static final String BORDER_THIN_THICK_THIN_MEDIUM = "brdrthtnthmg";
91      public static final String BORDER_THINK_THIN_LARGE = "brdrtnthlg";
92      public static final String BORDER_THIN_THICK_LARGE = "brdrthtnlg";
93      public static final String BORDER_THIN_THICK_THIN_LARGE = "brdrthtnthlg";
94      public static final String BORDER_WAVY = "brdrwavy";
95      public static final String BORDER_WAVY_DOUBLE = "brdrwavydb";
96      public static final String BORDER_STRIPED = "brdrdashdotstr";
97      public static final String BORDER_EMBOSS = "brdremboss";
98      public static final String BORDER_ENGRAVE = "brdrengrave";
99      public static final String BORDER_COLOR = "brdrcf";
100     public static final String BORDER_SPACE = "brsp";
101     public static final String BORDER_WIDTH = "brdrw";
102     
103     public static final String [] BORDERS = new String[] {
104         BORDER_SINGLE_THICKNESS,    BORDER_DOUBLE_THICKNESS,    BORDER_SHADOWED,
105         BORDER_DOUBLE,        BORDER_DOTTED,           BORDER_DASH,
106         BORDER_HAIRLINE,         BORDER_DASH_SMALL,        BORDER_DOT_DASH,
107         BORDER_DOT_DOT_DASH,    BORDER_TRIPLE,            BORDER_THINK_THIN_SMALL,
108         BORDER_THIN_THICK_SMALL,    BORDER_THIN_THICK_THIN_SMALL,   BORDER_THINK_THIN_MEDIUM,
109         BORDER_THIN_THICK_MEDIUM,  BORDER_THIN_THICK_THIN_MEDIUM,    BORDER_THINK_THIN_LARGE,
110         BORDER_THIN_THICK_LARGE,    BORDER_THIN_THICK_THIN_LARGE,   BORDER_WAVY,
111         BORDER_WAVY_DOUBLE,     BORDER_STRIPED,           BORDER_EMBOSS,
112         BORDER_ENGRAVE,        BORDER_COLOR,            BORDER_SPACE,
113         BORDER_WIDTH
114     };
115     
116     /**BorderAttributesConverter: Static Method for converting FO strings
117      * to RTF control words*/
118     public static String convertAttributetoRtf(String value) {
119         // Added by Normand Masse
120         // "solid" is interpreted like "thin"        
121     if(value.equals("thin") || value.equals("solid")){
122             return BORDER_SINGLE_THICKNESS;
123         }else if (value.equals("thick")) {
124             return BORDER_DOUBLE_THICKNESS;
125         }else if(value.equals("shadowed")){
126             return BORDER_SHADOWED;
127         }else if(value.equals("double")){
128             return BORDER_DOUBLE;
129         }else if(value.equals("dotted")){
130             return BORDER_DOTTED;
131         }else if(value.equals("dash")){
132             return BORDER_DASH;
133         }else if(value.equals("hairline")){
134             return BORDER_HAIRLINE;
135         }else if(value.equals("dot-dash")){
136             return BORDER_DOT_DASH;
137         }else if(value.equals("dot-dot-dash")){
138             return BORDER_DOT_DOT_DASH;
139         }else if(value.equals("triple")){
140             return BORDER_TRIPLE;
141         }else if(value.equals("wavy")){
142             return BORDER_WAVY;
143         }else if(value.equals("wavy-double")){
144             return BORDER_WAVY_DOUBLE;
145         }else if(value.equals("striped")){
146             return BORDER_STRIPED;
147         }else if(value.equals("emboss")){
148             return BORDER_EMBOSS;
149         }else if(value.equals("engrave")){
150             return BORDER_ENGRAVE;
151         }else{
152             return null;
153         }
154     }
155     
156     
157 }