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 38 public class RtfBookmark extends RtfElement { 39 43 44 private String bookmark = null; 45 46 public static final int MAX_BOOKMARK_LENGTH = 40; 47 48 public static final char REPLACE_CHARACTER = '_'; 49 50 51 55 62 RtfBookmark (RtfContainer parent, Writer w, String bookmark) throws IOException { 63 super (parent, w); 64 65 int now = bookmark.length (); 66 67 this.bookmark = bookmark.substring (0, 68 now < MAX_BOOKMARK_LENGTH ? now : MAX_BOOKMARK_LENGTH); 69 this.bookmark = this.bookmark.replace ('.', REPLACE_CHARACTER); 70 this.bookmark = this.bookmark.replace (' ', REPLACE_CHARACTER); 71 } 72 73 74 78 83 public void writeRtfPrefix () throws IOException { 84 startBookmark (); 85 } 86 87 92 public void writeRtfContent () throws IOException { 93 } 96 97 102 public void writeRtfSuffix () throws IOException { 103 endBookmark (); 104 } 105 106 107 111 116 private void startBookmark () throws IOException { 117 118 writeRtfBookmark ("bkmkstart"); 120 } 121 122 127 private void endBookmark () throws IOException { 128 129 writeRtfBookmark ("bkmkend"); 131 } 132 133 140 private void writeRtfBookmark (String tag) throws IOException { 141 if (bookmark == null) { 142 return; 143 144 } 145 146 this.writeGroupMark (true); 147 148 this.writeStarControlWord (tag); 150 151 writer.write (bookmark); 152 this.writeGroupMark (false); 153 } 154 155 158 public boolean isEmpty() { 159 return bookmark == null || bookmark.trim().length() == 0; 160 } 161 } 162 | Popular Tags |