1 51 package org.apache.fop.fo.flow; 52 53 import org.apache.fop.fo.*; 55 import org.apache.fop.apps.FOPException; 56 import org.apache.fop.fo.properties.*; 57 import org.apache.fop.layout.*; 58 59 public class BasicLink extends Inline { 60 61 public static class Maker extends FObj.Maker { 62 public FObj make(FObj parent, PropertyList propertyList, 63 String systemId, int line, int column) 64 throws FOPException { 65 return new BasicLink(parent, propertyList, systemId, line, column); 66 } 67 } 68 69 public static FObj.Maker maker() { 70 return new BasicLink.Maker(); 71 } 72 73 public BasicLink(FObj parent, PropertyList propertyList, 74 String systemId, int line, int column) throws FOPException { 75 super(parent, propertyList, systemId, line, column); 76 } 77 78 public String getName() { 79 return "fo:basic-link"; 80 } 81 82 public int layout(Area area) throws FOPException { 83 String destination; 84 int linkType; 85 86 AccessibilityProps mAccProps = propMgr.getAccessibilityProps(); 88 89 AuralProps mAurProps = propMgr.getAuralProps(); 91 92 BorderAndPadding bap = propMgr.getBorderAndPadding(); 94 BackgroundProps bProps = propMgr.getBackgroundProps(); 95 96 MarginInlineProps mProps = propMgr.getMarginInlineProps(); 98 99 RelativePositionProps mRelProps = propMgr.getRelativePositionProps(); 101 102 121 if (!(destination = 122 this.properties.get("internal-destination").getString()).equals("")) { 123 linkType = LinkSet.INTERNAL; 124 } else if (!(destination = 125 this.properties.get("external-destination").getString()).equals("")) { 126 linkType = LinkSet.EXTERNAL; 127 if (destination.startsWith("url(") && destination.endsWith(")")) { 128 destination = destination.substring(4, destination.length() - 1).trim(); 129 if (destination.startsWith("\"") && destination.endsWith("\"")) { 130 destination = destination.substring(1, destination.length() - 1); 131 } else if (destination.startsWith("'") && destination.endsWith("'")) { 132 destination = destination.substring(1, destination.length() - 1); 133 } 134 } 135 } else { 136 throw new FOPException("internal-destination or external-destination must be specified in basic-link", systemId, line, column); 137 } 138 139 if (this.marker == START) { 140 String id = this.properties.get("id").getString(); 142 try { 143 area.getIDReferences().initializeID(id, area); 144 } 145 catch(FOPException e) { 146 if (!e.isLocationSet()) { 147 e.setLocation(systemId, line, column); 148 } 149 throw e; 150 } 151 this.marker = 0; 152 } 153 154 LinkSet ls = new LinkSet(destination, area, linkType); 156 157 Page p = area.getPage(); 158 159 AreaContainer ac = area.getNearestAncestorAreaContainer(); 161 while (ac!=null && ac.getPosition()!=Position.ABSOLUTE) { 162 ac = ac.getNearestAncestorAreaContainer(); 163 } 164 if (ac == null) { 165 ac = p.getBody().getCurrentColumnArea(); 166 } 168 if (ac == null) { 169 throw new FOPException("Couldn't get ancestor AreaContainer when processing basic-link", systemId, line, column); 170 } 171 172 int numChildren = this.children.size(); 173 for (int i = this.marker; i < numChildren; i++) { 174 FONode fo = (FONode)children.get(i); 175 fo.setLinkSet(ls); 176 177 int status; 178 if (Status.isIncomplete((status = fo.layout(area)))) { 179 this.marker = i; 180 return status; 181 } 182 } 183 184 ls.applyAreaContainerOffsets(ac, area); 185 186 String mergeLinks = System.getProperty("links.merge"); 188 if ((null == mergeLinks) || mergeLinks.equalsIgnoreCase("yes")) { 189 ls.mergeLinks(); 190 } 191 192 p.addLinkSet(ls); 193 194 return Status.OK; 195 } 196 197 } 198 | Popular Tags |