1 17 18 19 20 package org.apache.fop.render.rtf; 21 22 28 29 import org.apache.fop.fo.Constants; 30 import org.apache.fop.fo.properties.CommonBorderPaddingBackground; 31 import org.apache.fop.render.rtf.rtflib.rtfdoc.IBorderAttributes; 32 import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfAttributes; 33 import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfText; 34 35 37 38 public final class BorderAttributesConverter { 39 40 43 private BorderAttributesConverter() { 44 } 45 46 54 public static void makeBorder(CommonBorderPaddingBackground border, int side, 55 RtfAttributes attributes, String controlWord) { 56 int styleEnum = border.getBorderStyle(side); 57 if (styleEnum != Constants.EN_NONE) { 58 FOPRtfAttributes attrs = new FOPRtfAttributes(); 59 attrs.set(IBorderAttributes.BORDER_COLOR, border.getBorderColor(side)); 60 attrs.set(convertAttributetoRtf(styleEnum)); 61 attrs.set(IBorderAttributes.BORDER_WIDTH, border.getBorderWidth(side, false) / 50); 63 attributes.set(controlWord, attrs); 64 } else { 69 71 double paddingPt = border.getPadding(side, false, null) / 1000.0; 73 int padding = (int) Math.round(paddingPt * FoUnitsConverter.POINT_TO_TWIPS); 75 76 if (side == CommonBorderPaddingBackground.BEFORE) { 79 attributes.addIntegerValue(padding, RtfText.SPACE_BEFORE); 80 } else if (side == CommonBorderPaddingBackground.AFTER) { 81 attributes.addIntegerValue(padding, RtfText.SPACE_AFTER); 82 } 83 } 84 } 85 86 91 public static String convertAttributetoRtf(int iBorderStyle) { 92 if (iBorderStyle == Constants.EN_NONE) { 95 return IBorderAttributes.BORDER_NIL; 96 } else if (iBorderStyle == Constants.EN_SOLID) { 97 return IBorderAttributes.BORDER_SINGLE_THICKNESS; 98 104 } else if (iBorderStyle == Constants.EN_DOUBLE) { 105 return IBorderAttributes.BORDER_DOUBLE; 106 } else if (iBorderStyle == Constants.EN_DOTTED) { 107 return IBorderAttributes.BORDER_DOTTED; 108 } else if (iBorderStyle == Constants.EN_DASHED) { 109 return IBorderAttributes.BORDER_DASH; 110 } else if (iBorderStyle == Constants.EN_GROOVE) { 111 return IBorderAttributes.BORDER_ENGRAVE; 112 } else if (iBorderStyle == Constants.EN_RIDGE) { 113 return IBorderAttributes.BORDER_EMBOSS; 114 } else if (iBorderStyle == Constants.EN_INSET) { 115 return IBorderAttributes.BORDER_ENGRAVE; 116 } else if (iBorderStyle == Constants.EN_OUTSET) { 117 return IBorderAttributes.BORDER_EMBOSS; 118 120 136 } else { 137 return IBorderAttributes.BORDER_SINGLE_THICKNESS; 138 } 139 140 } 141 } | Popular Tags |