]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Added internal-link functionality
authorJordan Naftolin <jordan@apache.org>
Wed, 21 Jun 2000 01:23:10 +0000 (01:23 +0000)
committerJordan Naftolin <jordan@apache.org>
Wed, 21 Jun 2000 01:23:10 +0000 (01:23 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193413 13f79535-47bb-0310-9956-ffa450edef68

src/org/apache/fop/fo/flow/Block.java
src/org/apache/fop/fo/flow/SimpleLink.java

index 0d729a41f280681809cb69274087ca1dabe37288..3adb50a0cf9746fd6ca26c50b4e7a243065379fa 100644 (file)
@@ -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();
index 353c54d69183a0fc7c7add94b6bf3ca8402336b9..51ee0ca48411843c9e18cd36059c782e58c670ea 100644 (file)
@@ -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();