1 17 18 19 20 package org.apache.fop.render.mif; 21 22 import java.io.IOException ; 24 import java.io.OutputStream ; 25 import java.util.Iterator ; 26 import java.util.List ; 27 28 34 public class MIFFile extends MIFElement { 35 36 protected MIFElement colorCatalog = null; 37 protected PGFElement pgfCatalog = null; 38 protected MIFElement fontCatalog = null; 39 protected RulingElement rulingCatalog = null; 40 protected MIFElement tblCatalog = null; 41 protected MIFElement views = null; 42 protected MIFElement variableFormats = null; 43 protected MIFElement xRefFormats = null; 44 protected MIFElement document = null; 45 protected MIFElement bookComponent = null; 46 protected MIFElement initialAutoNums = null; 47 protected MIFElement aFrames = null; 48 protected MIFElement tbls = null; 49 protected List pages = new java.util.ArrayList (); 50 protected List textFlows = null; 51 52 53 public MIFFile() { 54 super(""); 55 valueElements = new java.util.ArrayList (); 56 setup(); 57 } 58 59 63 protected void setup() { 64 MIFElement unit = new MIFElement("Units"); 65 unit.setValue("Ucm"); 66 addElement(unit); 67 68 colorCatalog = new MIFElement("ColorCatalog"); 69 MIFElement color = new MIFElement("Color"); 70 MIFElement prop = new MIFElement("ColorTag"); 71 prop.setValue("`Black'"); 72 color.addElement(prop); 73 prop = new MIFElement("ColorCyan"); 74 prop.setValue("0.000000"); 75 color.addElement(prop); 76 77 prop = new MIFElement("ColorMagenta"); 78 prop.setValue("0.000000"); 79 color.addElement(prop); 80 prop = new MIFElement("ColorYellow"); 81 prop.setValue("0.000000"); 82 color.addElement(prop); 83 prop = new MIFElement("ColorBlack"); 84 prop.setValue("100.000000"); 85 color.addElement(prop); 86 prop = new MIFElement("ColorAttribute"); 87 prop.setValue("ColorIsBlack"); 88 color.addElement(prop); 89 prop = new MIFElement("ColorAttribute"); 90 prop.setValue("ColorIsReserved"); 91 color.addElement(prop); 92 color.finish(true); 93 94 colorCatalog.addElement(color); 95 addElement(colorCatalog); 96 97 pgfCatalog = new PGFElement(); 98 pgfCatalog.lookupElement(null); 99 addElement(pgfCatalog); 100 101 rulingCatalog = new RulingElement(); 102 rulingCatalog.lookupElement(null); 103 addElement(rulingCatalog); 104 105 } 106 107 public void output(OutputStream os) throws IOException { 108 if (finished) { 109 return; 110 } 111 112 if (!started) { 113 os.write(("<MIFFile 5.00> # Generated by FOP\n").getBytes()); 114 started = true; 115 } 116 boolean done = true; 117 118 for (Iterator iter = valueElements.iterator(); iter.hasNext();) { 119 MIFElement el = (MIFElement)iter.next(); 120 boolean d = el.output(os, 0); 121 if (d) { 122 iter.remove(); 123 } else { 124 done = false; 125 break; 126 } 127 } 128 if (done && finish) { 129 os.write(("# end of MIFFile").getBytes()); 130 } 131 } 132 133 public void addPage(MIFElement p) { 134 pages.add(p); 135 addElement(p); 136 } 137 } 138 139 | Popular Tags |