1 17 18 19 20 package org.apache.fop.render.rtf.rtflib.rtfdoc; 21 22 28 29 import java.io.Writer ; 30 import java.io.IOException ; 31 32 37 38 abstract class RtfAfterBeforeBase 39 extends RtfContainer 40 implements IRtfParagraphContainer, IRtfExternalGraphicContainer, IRtfTableContainer, 41 IRtfTextrunContainer { 42 protected RtfAttributes attrib; 43 private RtfParagraph para; 44 private RtfExternalGraphic externalGraphic; 45 private RtfTable table; 46 47 RtfAfterBeforeBase(RtfSection parent, Writer w, RtfAttributes attrs) throws IOException { 48 super((RtfContainer)parent, w, attrs); 49 attrib = attrs; 50 } 51 52 public RtfParagraph newParagraph() throws IOException { 53 closeAll(); 54 para = new RtfParagraph(this, writer); 55 return para; 56 } 57 58 public RtfParagraph newParagraph(RtfAttributes attrs) throws IOException { 59 closeAll(); 60 para = new RtfParagraph(this, writer, attrs); 61 return para; 62 } 63 64 public RtfExternalGraphic newImage() throws IOException { 65 closeAll(); 66 externalGraphic = new RtfExternalGraphic(this, writer); 67 return externalGraphic; 68 } 69 70 private void closeCurrentParagraph() throws IOException { 71 if (para != null) { 72 para.close(); 73 } 74 } 75 76 private void closeCurrentExternalGraphic() throws IOException { 77 if (externalGraphic != null) { 78 externalGraphic.close(); 79 } 80 } 81 82 private void closeCurrentTable() throws IOException { 83 if (table != null) { 84 table.close(); 85 } 86 } 87 88 protected void writeRtfPrefix() throws IOException { 89 writeGroupMark(true); 90 writeMyAttributes(); 91 } 92 93 94 protected abstract void writeMyAttributes() throws IOException ; 95 96 protected void writeRtfSuffix() throws IOException { 97 writeGroupMark(false); 98 } 99 100 public RtfAttributes getAttributes() { 101 return attrib; 102 } 103 104 public void closeAll() throws IOException { 105 closeCurrentParagraph(); 106 closeCurrentExternalGraphic(); 107 closeCurrentTable(); 108 } 109 110 114 public RtfTable newTable(RtfAttributes attrs, ITableColumnsInfo tc) throws IOException { 115 closeAll(); 116 table = new RtfTable(this, writer, attrs, tc); 117 return table; 118 } 119 120 121 public RtfTable newTable(ITableColumnsInfo tc) throws IOException { 122 closeAll(); 123 table = new RtfTable(this, writer, tc); 124 return table; 125 } 126 127 public RtfTextrun getTextrun() 128 throws IOException { 129 return RtfTextrun.getTextrun(this, writer, null); 130 } 131 } 132 | Popular Tags |