* Detect internal or external link and add it as an area trait
*
* @param area the basic-link's area
*/
private void setupBasicLinkArea(InlineArea area) {
BasicLink fobj = (BasicLink) this.fobj;
// internal destinations take precedence:
TraitSetter.addStructureTreeElement(area, fobj.getStructureTreeElement());
if (fobj.hasInternalDestination()) {
String idref = fobj.getInternalDestination();
PageSequenceLayoutManager pslm = getPSLM();
// the INTERNAL_LINK trait is added by the LinkResolver
// if and when the link is resolved:
LinkResolver res = new LinkResolver(idref, area);
res.resolveIDRef(idref, pslm.getFirstPVWithID(idref));
if (!res.isResolved()) {
pslm.addUnresolvedArea(idref, res);
if ( area instanceof BasicLinkArea ) {
// establish back-pointer from BasicLinkArea to LinkResolver to
// handle inline area unflattening during line bidi reordering;
// needed to create internal link trait on synthesized basic link area
((BasicLinkArea)area).setResolver(res);
}
}
} else if (fobj.hasExternalDestination()) {
String url = URISpecification.getURL(fobj.getExternalDestination());
boolean newWindow = (fobj.getShowDestination() == Constants.EN_NEW);
if (url.length() > 0) {
area.addTrait(Trait.EXTERNAL_LINK,
new Trait.ExternalLink(url, newWindow));
}
}