aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/render/rtf/BorderAttributesConverter.java
blob: 2f9e5e4b9d97ac678d0252fb46fb0cb410dc5656 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
 * Copyright 1999-2005 The Apache Software Foundation.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 * 
 *      http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

/* $Id$ */


/*
 * This file is part of the RTF library of the FOP project, which was originally
 * created by Bertrand Delacretaz <bdelacretaz@codeconsult.ch> and by other
 * contributors to the jfor project (www.jfor.org), who agreed to donate jfor to
 * the FOP project.
 */

package org.apache.fop.render.rtf;

import org.apache.fop.fo.Constants;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
import org.apache.fop.render.rtf.rtflib.rtfdoc.IBorderAttributes;
import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfAttributes;

/** Constants for RTF border attribute names, and a static method for converting
 *  fo attribute strings. */

public class BorderAttributesConverter {

    /**
     * Create a border control word in attributes, with border properties 
     * as specified in color, style and width.
     * @param border The CommonBorderPaddingBackground object.
     * @param side The START, END, BEFORE, AFTER enum from CommonBorderPaddingBackground. 
     * @param attributes The attributes list to set the border control word.
     * @param controlWord The border control word.
     */
    public static void makeBorder(CommonBorderPaddingBackground border, int side,
            RtfAttributes attributes, String controlWord) {
        int styleEnum = border.getBorderStyle(side);
        if (styleEnum != Constants.EN_NONE) {
            FOPRtfAttributes attrs = new FOPRtfAttributes();
            attrs.set(IBorderAttributes.BORDER_COLOR, border.getBorderColor(side));
            attrs.set(convertAttributetoRtf(styleEnum));
            attrs.set(IBorderAttributes.BORDER_WIDTH, border.getBorderWidth(side, false));
            attributes.set(controlWord, attrs);
        }
    }

    /**
    *
    * @param iBorderStyle the border style to be converted
    * @return String with the converted border style
    */
   public static String convertAttributetoRtf(int iBorderStyle) {
       // Added by Normand Masse
       // "solid" is interpreted like "thin"
       if (iBorderStyle == Constants.EN_NONE) {
           return IBorderAttributes.BORDER_NIL;
       } else if (iBorderStyle == Constants.EN_SOLID) {
           return IBorderAttributes.BORDER_SINGLE_THICKNESS;
/*        } else if (iBorderStyle==Constants.EN_THIN) {
                       return IBorderAttributes.BORDER_SINGLE_THICKNESS;
       } else if (iBorderStyle==Constants.EN_THICK) {
           return IBorderAttributes.BORDER_DOUBLE_THICKNESS;
       } else if (iBorderStyle==Constants.EN_ value.equals("shadowed")) {
           return IBorderAttributes.BORDER_SHADOWED;*/
       } else if (iBorderStyle == Constants.EN_DOUBLE) {
           return IBorderAttributes.BORDER_DOUBLE;
       } else if (iBorderStyle == Constants.EN_DOTTED) {
           return IBorderAttributes.BORDER_DOTTED;
       } else if (iBorderStyle == Constants.EN_DASHED) {
           return IBorderAttributes.BORDER_DASH;
/*        } else if (iBorderStyle==Constants value.equals("hairline")) {
           return IBorderAttributes.BORDER_HAIRLINE;*/
/*        } else if (iBorderStyle==Constant value.equals("dot-dash")) {
           return IBorderAttributes.BORDER_DOT_DASH;
       } else if (iBorderStyle==Constant value.equals("dot-dot-dash")) {
           return IBorderAttributes.BORDER_DOT_DOT_DASH;
       } else if (iBorderStyle==Constant value.equals("triple")) {
           return IBorderAttributes.BORDER_TRIPLE;
       } else if (iBorderStyle==Constant value.equals("wavy")) {
           return IBorderAttributes.BORDER_WAVY;
       } else if (iBorderStyle==Constant value.equals("wavy-double")) {
           return IBorderAttributes.BORDER_WAVY_DOUBLE;
       } else if (iBorderStyle==Constant value.equals("striped")) {
           return IBorderAttributes.BORDER_STRIPED;
       } else if (iBorderStyle==Constant value.equals("emboss")) {
           return IBorderAttributes.BORDER_EMBOSS;
       } else if (iBorderStyle==Constant value.equals("engrave")) {
           return IBorderAttributes.BORDER_ENGRAVE;*/
       } else {
           return null;
       }

   }
}