1 17 18 19 20 package org.apache.fop.render.rtf.rtflib.rtfdoc; 21 22 28 29 import java.util.LinkedList ; 30 import java.util.Iterator ; 31 import java.io.Writer ; 32 import java.io.IOException ; 33 35 41 public class RtfListTable extends RtfContainer { 42 private LinkedList lists; 43 private LinkedList styles; 44 45 47 public static final String LIST_TABLE = "listtable"; 48 49 public static final String LIST = "list"; 50 51 public static final String LIST_TEMPLATE_ID = "listtemplateid"; 52 53 public static final String LIST_LEVEL = "listlevel"; 54 55 public static final String LIST_NUMBER_TYPE = "levelnfc"; 56 57 public static final String LIST_JUSTIFICATION = "leveljc"; 58 59 public static final String LIST_FOLLOWING_CHAR = "levelfollow"; 60 61 public static final String LIST_START_AT = "levelstartat"; 62 63 public static final String LIST_SPACE = "levelspace"; 64 65 public static final String LIST_INDENT = "levelindent"; 66 67 public static final String LIST_TEXT_FORM = "leveltext"; 68 69 public static final String LIST_NUM_POSITION = "levelnumbers"; 70 71 public static final String LIST_NAME = "listname ;"; 72 73 public static final String LIST_ID = "listid"; 74 75 public static final String LIST_FONT_TYPE = "f"; 76 77 public static final String LIST_OVR_TABLE = "listoverridetable"; 78 79 public static final String LIST_OVR = "listoverride"; 80 81 public static final String LIST_OVR_COUNT = "listoverridecount"; 82 83 public static final String LIST_NUMBER = "ls"; 84 85 86 public static final String [] LIST_TABLE_ATTR = { 87 LIST_TABLE, LIST, LIST_TEMPLATE_ID, 88 LIST_NUMBER_TYPE, LIST_JUSTIFICATION, LIST_FOLLOWING_CHAR, 89 LIST_START_AT, LIST_SPACE, LIST_INDENT, 90 LIST_TEXT_FORM, LIST_NUM_POSITION, LIST_ID, 91 LIST_OVR_TABLE, LIST_OVR, LIST_OVR_COUNT, 92 LIST_NUMBER, LIST_LEVEL 93 }; 94 95 104 public RtfListTable(RtfContainer parent, Writer w, Integer num, RtfAttributes attrs) 105 throws IOException { 106 super(parent, w, attrs); 107 108 styles = new LinkedList (); 109 } 110 111 116 public int addList(RtfList list) { 117 if (lists == null) { 118 lists = new LinkedList (); 119 } 120 121 lists.add(list); 122 123 return lists.size(); 124 } 125 126 130 public void writeRtfContent() throws IOException { 131 newLine(); 132 if (lists != null) { 133 writeGroupMark(true); 135 writeStarControlWordNS(LIST_TABLE); 136 newLine(); 137 for (Iterator it = lists.iterator(); it.hasNext();) { 138 final RtfList list = (RtfList)it.next(); 139 writeListTableEntry(list); 140 newLine(); 141 } 142 writeGroupMark(false); 143 144 newLine(); 145 writeGroupMark(true); 147 writeStarControlWordNS(LIST_OVR_TABLE); 148 int z = 1; 149 newLine(); 150 for (Iterator it = styles.iterator(); it.hasNext();) { 151 final RtfListStyle style = (RtfListStyle)it.next(); 152 153 writeGroupMark(true); 154 writeStarControlWordNS(LIST_OVR); 155 writeGroupMark(true); 156 157 writeOneAttributeNS(LIST_ID, style.getRtfList().getListId().toString()); 158 writeOneAttributeNS(LIST_OVR_COUNT, new Integer (0)); 159 writeOneAttributeNS(LIST_NUMBER, new Integer (z++)); 160 161 writeGroupMark(false); 162 writeGroupMark(false); 163 newLine(); 164 } 165 166 writeGroupMark(false); 167 newLine(); 168 } 169 } 170 171 176 public boolean isEmpty() { 177 return false; 178 } 179 180 private void writeListTableEntry(RtfList list) 181 throws IOException { 182 writeGroupMark(true); 184 writeControlWordNS(LIST); 185 writeOneAttributeNS(LIST_TEMPLATE_ID, list.getListTemplateId().toString()); 186 writeOneAttributeNS(LIST, attrib.getValue(LIST)); 187 188 writeGroupMark(true); 190 writeControlWordNS(LIST_LEVEL); 191 192 writeOneAttributeNS(LIST_JUSTIFICATION, attrib.getValue(LIST_JUSTIFICATION)); 193 writeOneAttributeNS(LIST_FOLLOWING_CHAR, attrib.getValue(LIST_FOLLOWING_CHAR)); 194 writeOneAttributeNS(LIST_SPACE, new Integer (0)); 195 writeOneAttributeNS(LIST_INDENT, attrib.getValue(LIST_INDENT)); 196 197 RtfListItem item = (RtfListItem)list.getChildren().get(0); 198 if (item != null) { 199 item.getRtfListStyle().writeLevelGroup(this); 200 } 201 202 writeGroupMark(false); 203 204 writeGroupMark(true); 205 writeControlWordNS(LIST_NAME); 206 writeGroupMark(false); 207 208 writeOneAttributeNS(LIST_ID, list.getListId().toString()); 209 210 writeGroupMark(false); 211 } 212 213 218 public int addRtfListStyle(RtfListStyle ls) { 219 styles.add(ls); 220 return styles.size(); 221 } 222 } | Popular Tags |