From: Jordan Naftolin Date: Wed, 21 Jun 2000 01:23:10 +0000 (+0000) Subject: Added internal-link functionality X-Git-Tag: pre-columns~464 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=955d8d264007324835db3f7398da79074b737447;p=xmlgraphics-fop.git Added internal-link functionality git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193413 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/org/apache/fop/fo/flow/Block.java b/src/org/apache/fop/fo/flow/Block.java index 0d729a41f..3adb50a0c 100644 --- a/src/org/apache/fop/fo/flow/Block.java +++ b/src/org/apache/fop/fo/flow/Block.java @@ -71,6 +71,7 @@ public class Block extends FObjMixed { return new Block.Maker(); } + final static int ID_PADDING = 5000; // space to add before id y position FontState fs; int align; int alignLast; @@ -202,9 +203,26 @@ public class Block extends FObjMixed { if (anythingLaidOut) { this.textIndent = 0; - } - - this.blockArea = + } + + if ( marker==0 ) { + // set up IDReferences + IDReferences idReferences = area.getIDReferences(); + String id = this.properties.get("id").getString(); + if ( id!=null && !id.equals("") ) { + if ( idReferences.doesIDExist(id) ) { + throw new FOPException("The id \""+id+"\" already exists in this document"); + } + else { + idReferences.createNewId(id); + idReferences.removeFromIdValidationList(id); + idReferences.setYPosition(id,area.getPage().getBody().getYPosition() - area.getAbsoluteHeight()+ID_PADDING); + area.getPage().addToIDList(id); + } + } + } + + this.blockArea = new BlockArea(fs, area.getAllocationWidth(), area.spaceLeft(), startIndent, @@ -221,6 +239,7 @@ public class Block extends FObjMixed { layoutStart(area); // performs blockArea.setAbsoluteHeight(area.getAbsoluteHeight()); + blockArea.setIDReferences(area.getIDReferences()); blockArea.setTableCellXOffset(area.getTableCellXOffset()); int numChildren = this.children.size(); diff --git a/src/org/apache/fop/fo/flow/SimpleLink.java b/src/org/apache/fop/fo/flow/SimpleLink.java index 353c54d69..51ee0ca48 100644 --- a/src/org/apache/fop/fo/flow/SimpleLink.java +++ b/src/org/apache/fop/fo/flow/SimpleLink.java @@ -90,16 +90,28 @@ public class SimpleLink extends FObjMixed { } public Status layout(Area area) throws FOPException { - - String externalDest = - this.properties.get("external-destination").getString(); - + String destination; + int linkType; + + if ( !(destination = this.properties.get("internal-destination").getString()).equals("")) + { + linkType=LinkSet.INTERNAL; + } + else if ( !(destination = this.properties.get("external-destination").getString()).equals("") ) + { + linkType=LinkSet.EXTERNAL; + } + else + { + throw new FOPException("internal-destination or external-destination must be specified in simple-link"); + } + if (this.marker == START) { this.marker = 0; } // new LinkedArea to gather up inlines - LinkSet ls = new LinkSet(externalDest, area); + LinkSet ls = new LinkSet(destination, area, linkType); Page p = area.getPage();