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 36 public class RtfPageNumberCitation extends RtfContainer { 37 41 42 43 public static final String RTF_FIELD = "field"; 44 45 public static final String RTF_FIELD_PAGEREF_MODEL = "fldinst { PAGEREF }"; 46 47 public static final String RTF_FIELD_RESULT = "fldrslt"; 48 49 private String id = null; 51 52 53 RtfPageNumberCitation (IRtfPageNumberCitationContainer parent, Writer w, String id) 54 throws IOException { 55 super((RtfContainer)parent, w); 56 this.id = id; 57 } 58 59 61 RtfPageNumberCitation (RtfParagraph parent, Writer w, String id) 62 throws IOException { 63 super((RtfContainer)parent, w, parent.attrib); 65 if (parent.getTextAttributes() != null) { 66 attrib.set(parent.getTextAttributes()); 67 } 68 this.id = id; 69 } 70 71 75 protected void writeRtfContent() throws IOException { 76 if (isValid()) { 78 String pageRef = RTF_FIELD_PAGEREF_MODEL; 80 final int insertionIndex = pageRef.indexOf("}"); 81 pageRef = pageRef.substring(0, insertionIndex) 82 + "\"" + id 83 + "\"" + " " 84 + pageRef.substring(insertionIndex, pageRef.length()); 85 id = null; 86 87 writeGroupMark(true); 89 writeControlWord(RTF_FIELD); 90 writeGroupMark(true); 91 writeAttributes(attrib, RtfText.ATTR_NAMES); writeStarControlWord(pageRef); 93 writeGroupMark(false); 94 writeGroupMark(true); 95 writeControlWord(RTF_FIELD_RESULT); 96 writeGroupMark(false); 97 writeGroupMark(false); 98 } 99 } 100 101 102 private boolean isValid() { 103 return (id != null); 104 } 105 106 109 public boolean isEmpty() { 110 return false; 111 } 112 } | Popular Tags |