1 50 package com.lowagie.text.rtf.direct; 51 52 import java.awt.Color ; 53 import java.util.HashMap ; 54 55 import com.lowagie.text.rtf.document.RtfDocument; 56 import com.lowagie.text.rtf.style.RtfColor; 57 import com.lowagie.text.rtf.style.RtfFont; 58 59 70 public class RtfImportHeader { 71 74 private HashMap importFontMapping = null; 75 78 private HashMap importColorMapping = null; 79 82 private RtfDocument rtfDoc = null; 83 84 89 public RtfImportHeader(RtfDocument rtfDoc) { 90 this.rtfDoc = rtfDoc; 91 this.importFontMapping = new HashMap (); 92 this.importColorMapping = new HashMap (); 93 } 94 95 102 public void importFont(String fontNr, String fontName) { 103 RtfFont rtfFont = new RtfFont(fontName); 104 rtfFont.setRtfDocument(this.rtfDoc); 105 this.importFontMapping.put(fontNr, Integer.toString(this.rtfDoc.getDocumentHeader().getFontNumber(rtfFont))); 106 } 107 108 117 public String mapFontNr(String fontNr) { 118 if(this.importFontMapping.containsKey(fontNr)) { 119 return (String ) this.importFontMapping.get(fontNr); 120 } else { 121 return "0"; 122 } 123 } 124 125 133 public void importColor(String colorNr, Color color) { 134 RtfColor rtfColor = new RtfColor(this.rtfDoc, color); 135 this.importColorMapping.put(colorNr, Integer.toString(rtfColor.getColorNumber())); 136 } 137 138 147 public String mapColorNr(String colorNr) { 148 if(this.importColorMapping.containsKey(colorNr)) { 149 return (String ) this.importColorMapping.get(colorNr); 150 } else { 151 return "0"; 152 } 153 } 154 } 155 | Popular Tags |