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 35 36 public class RtfTable extends RtfContainer { 37 private RtfTableRow row; 38 private int highestRow = 0; 39 private Boolean isNestedTable = null; 40 private RtfAttributes borderAttributes = null; 41 42 44 private ITableColumnsInfo tableContext; 45 46 47 RtfTable(IRtfTableContainer parent, Writer w, ITableColumnsInfo tc) 48 throws IOException { 49 super((RtfContainer)parent, w); 50 tableContext = tc; 52 } 53 54 57 RtfTable(IRtfTableContainer parent, Writer w, RtfAttributes attrs, 58 ITableColumnsInfo tc) throws IOException { 59 super((RtfContainer)parent, w, attrs); 60 tableContext = tc; 62 } 63 64 69 public RtfTableRow newTableRow() throws IOException { 70 if (row != null) { 71 row.close(); 72 } 73 74 highestRow++; 75 row = new RtfTableRow(this, writer, attrib, highestRow); 76 return row; 77 } 78 79 85 public RtfTableRow newTableRow(RtfAttributes attrs) throws IOException { 86 RtfAttributes attr = null; 87 if (attrib != null) { 88 attr = (RtfAttributes) attrib.clone (); 89 attr.set (attrs); 90 } else { 91 attr = attrs; 92 } 93 if (row != null) { 94 row.close(); 95 } 96 highestRow++; 97 98 row = new RtfTableRow(this, writer, attr, highestRow); 99 return row; 100 } 101 102 103 104 108 protected void writeRtfPrefix() throws IOException { 109 if (isNestedTable()) { 110 writeControlWordNS("pard"); 111 } 112 113 writeGroupMark(true); 114 } 115 116 120 protected void writeRtfSuffix() throws IOException { 121 writeGroupMark(false); 122 123 if (isNestedTable()) { 124 getRow().writeRowAndCellsDefintions(); 125 } 126 } 127 128 133 public boolean isHighestRow(int id) { 134 return (highestRow == id) ? true : false; 135 } 136 137 141 public ITableColumnsInfo getITableColumnsInfo() { 142 return this.tableContext; 143 } 144 145 private RtfAttributes headerAttribs = null; 146 147 152 public void setHeaderAttribs(RtfAttributes attrs) { 153 headerAttribs = attrs; 154 } 155 156 160 public RtfAttributes getHeaderAttribs() { 161 return headerAttribs; 162 } 163 164 169 public RtfAttributes getRtfAttributes() { 170 if (headerAttribs != null) { 171 return headerAttribs; 172 } 173 174 return super.getRtfAttributes(); 175 } 176 177 178 public boolean isNestedTable() { 179 if (isNestedTable == null) { 180 RtfElement e = this; 181 while (e.parent != null) { 182 if (e.parent instanceof RtfTableCell) { 183 isNestedTable = Boolean.TRUE; 184 return true; 185 } 186 187 e = e.parent; 188 } 189 190 isNestedTable = Boolean.FALSE; 191 } else { 192 return isNestedTable.booleanValue(); 193 } 194 195 return false; 196 } 197 198 202 public RtfTableRow getRow() { 203 RtfElement e = this; 204 while (e.parent != null) { 205 if (e.parent instanceof RtfTableRow) { 206 return (RtfTableRow) e.parent; 207 } 208 209 e = e.parent; 210 } 211 212 return null; 213 } 214 215 219 public void setBorderAttributes(RtfAttributes attributes) { 220 borderAttributes = attributes; 221 } 222 223 227 public RtfAttributes getBorderAttributes() { 228 return borderAttributes; 229 } 230 } 231 | Popular Tags |