1 17 18 19 20 package org.apache.fop.render.rtf; 21 22 import java.awt.Color ; 23 import org.apache.fop.datatypes.Length; 24 import org.apache.fop.datatypes.PercentBaseContext; 25 import org.apache.fop.fo.FObj; 26 import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfAttributes; 27 import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfColorTable; 28 29 30 33 public class FOPRtfAttributes extends RtfAttributes { 34 35 41 public RtfAttributes setTwips(String name, Length value) { 42 set(name, value.getValue() / (1000 / 20)); return this; 44 } 45 46 52 public RtfAttributes setTwips(String name, int value) { 53 set(name, value / (1000 / 20)); return this; 55 } 56 57 63 public RtfAttributes setHalfPoints(String name, Length value) { 64 set(name, value.getValue(DummyPercentBaseContext.singleton) / (1000 / 2)); 66 return this; 67 } 68 69 75 public RtfAttributes set(String name, Color color) { 76 int redComponent = color.getRed(); 78 int greenComponent = color.getGreen(); 79 int blueComponent = color.getBlue(); 80 set(name, RtfColorTable.getInstance().getColorNumber( 81 redComponent, greenComponent, blueComponent).intValue()); 82 return this; 83 } 84 85 private static class DummyPercentBaseContext implements PercentBaseContext { 86 87 static DummyPercentBaseContext singleton = new DummyPercentBaseContext(); 88 89 private DummyPercentBaseContext() { 90 } 92 93 public int getBaseLength(int lengthBase, FObj fobj) { 94 return 0; 95 } 96 } 97 98 } 99 | Popular Tags |