]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
move logic for creating bookmarks/outlines in the area tree from extensions/Bookmarks...
authorWilliam Victor Mote <vmote@apache.org>
Wed, 20 Aug 2003 19:46:47 +0000 (19:46 +0000)
committerWilliam Victor Mote <vmote@apache.org>
Wed, 20 Aug 2003 19:46:47 +0000 (19:46 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196818 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/apps/Document.java
src/java/org/apache/fop/apps/Driver.java
src/java/org/apache/fop/extensions/Bookmarks.java
src/java/org/apache/fop/fo/FOTreeControl.java
src/java/org/apache/fop/fo/FObj.java
src/java/org/apache/fop/layout/LayoutStrategy.java
src/java/org/apache/fop/layoutmgr/LayoutManagerLS.java

index a78b51d165faf4d32868939acc2a8dab9a527fcf..081d958b8ec07d7060dfa21f848eca171168faa5 100644 (file)
@@ -58,7 +58,7 @@ import java.io.IOException;
 import org.apache.fop.area.AreaTree;
 import org.apache.fop.area.AreaTreeModel;
 
-
+import org.apache.fop.extensions.Bookmarks;
 import org.apache.fop.fo.FOTreeControl;
 import org.apache.fop.fo.FOTreeEvent;
 import org.apache.fop.fo.FOTreeListener;
@@ -101,6 +101,8 @@ public class Document implements FOTreeControl, FOTreeListener {
     public AreaTree areaTree;
     public AreaTreeModel atModel;
 
+    private Bookmarks bookmarks;
+
     /**
      * Main constructor
      * @param driver the Driver object that is the "parent" of this Document
@@ -348,5 +350,13 @@ public class Document implements FOTreeControl, FOTreeListener {
         return areaTree;
     }
 
+    public void setBookmarks(Bookmarks bookmarks) {
+        this.bookmarks = bookmarks;
+    }
+
+    public Bookmarks getBookmarks() {
+        return bookmarks;
+    }
+
 }
 
index 784060cc9e702b67ea1203557f6dfa6172b23b73..560956a503558e14ecca086d44481fb6bd1060ca 100644 (file)
@@ -579,7 +579,7 @@ public class Driver implements LogEnabled {
         /** LayoutStrategy is hard-wired for now, but needs to be made
         accessible through the API and/or configuration */
         if (foInputHandler instanceof FOTreeHandler) {
-            currentDocument.setLayoutStrategy(new LayoutManagerLS());
+            currentDocument.setLayoutStrategy(new LayoutManagerLS(currentDocument));
         }
         treeBuilder.foTreeControl = currentDocument;
         try {
index dbd1c6a815fc01ff895153598d14f8c3959fe880..30bcaa1c2831ba94b44fd422f5f4629bee6fd4e6 100644 (file)
  */
 package org.apache.fop.extensions;
 
-import org.apache.fop.fo.FOTreeHandler;
 import org.apache.fop.fo.FONode;
 import org.apache.fop.fo.FOTreeVisitor;
-import org.apache.fop.area.AreaTree;
-import org.apache.fop.apps.Document;
 
 import java.util.ArrayList;
 
@@ -65,7 +62,6 @@ import java.util.ArrayList;
  */
 public class Bookmarks extends ExtensionObj {
     private ArrayList outlines = new ArrayList();
-    private BookmarkData data;
 
     /**
      * Create a new Bookmarks object.
@@ -88,40 +84,21 @@ public class Bookmarks extends ExtensionObj {
         }
     }
 
-    /**
-     * Get the data created for this bookmark.
-     *
-     * @return the bookmark data
-     */
-    public BookmarkData getData() {
-        return data;
-    }
-
     /**
      * When this element is finished then it can create
      * the bookmark data from the child elements and add
      * the extension to the area tree.
      */
     public void end() {
-        getLogger().debug("adding bookmarks to area tree");
-        data = new BookmarkData();
-        for (int count = 0; count < outlines.size(); count++) {
-            Outline out = (Outline)outlines.get(count);
-            data.addSubData(out.getData());
-        }
-        // add data to area tree for resolving and handling
-        if (foInputHandler instanceof FOTreeHandler) {
-            FOTreeHandler foth = (FOTreeHandler)foInputHandler;
-            Document doc = (Document)foth.foTreeControl;
-            AreaTree at = doc.getAreaTree();
-            at.addTreeExtension(data);
-            data.setAreaTree(at);
-        }
+        getFOTreeControl().setBookmarks(this);
     }
 
     public void acceptVisitor(FOTreeVisitor fotv) {
         fotv.serveVisitor(this);
     }
 
-}
+    public ArrayList getOutlines() {
+        return outlines;
+    }
 
+}
index c960654cfbeb2b4156a9faf9207a1f63e13a4a28..ca90f76bf86d8e8967efb231cc8d2c69013c0dfa 100644 (file)
@@ -55,6 +55,7 @@ package org.apache.fop.fo;
 import java.util.Map;
 
 // FOP
+import org.apache.fop.extensions.Bookmarks;
 import org.apache.fop.fonts.FontMetrics;
 
 /**
@@ -77,4 +78,8 @@ public interface FOTreeControl {
 
     public Map getFonts();
 
+    public void setBookmarks(Bookmarks bookmarks);
+
+    public Bookmarks getBookmarks();
+
 }
index c95bfec109a6834fc104ed2c754b914411c5bd0e..ed8de054126b7645702b22e74f41d8ba149e5370 100644 (file)
@@ -260,6 +260,10 @@ public class FObj extends FONode {
         foInputHandler = foih;
     }
 
+    public FOInputHandler getFOInputHandler() {
+        return foInputHandler;
+    }
+
     /**
      * lets outside sources access the property list
      * first used by PageNumberCitation to find the "id" property
index 39060917497c72d6d9bd7bbc84107c196fec4728..24d9cc7ebf0fc378bb880f0ff2be49d52598704e 100644 (file)
@@ -51,6 +51,7 @@
 
 package org.apache.fop.layout;
 
+import org.apache.fop.apps.Document;
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.area.AreaTree;
 import org.apache.fop.fo.pagination.PageSequence;
@@ -63,6 +64,11 @@ import org.apache.fop.fo.pagination.PageSequence;
 public abstract class LayoutStrategy {
 
     private String name = "undefined";
+    public Document document;
+
+    public LayoutStrategy(Document document) {
+        this.document = document;
+    }
 
     /**
      * Returns the name of this LayoutStrategy.
index 2ec3f8985051609d2c8d27b7413fbb6982b8d789..2757b798f40d4bde97f01d048adb285688c90b8e 100644 (file)
  */
 package org.apache.fop.layoutmgr;
 
+import org.apache.fop.extensions.BookmarkData;
+import org.apache.fop.extensions.Outline;
+import org.apache.fop.apps.Document;
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.layout.LayoutStrategy;
 import org.apache.fop.area.AreaTree;
 import org.apache.fop.area.Title;
 import org.apache.fop.fo.pagination.PageSequence;
+import org.apache.fop.fo.FOTreeHandler;
 
 /**
  * The implementation of LayoutStrategy for the "redesign" or second generation
@@ -64,6 +68,10 @@ public class LayoutManagerLS extends LayoutStrategy {
 
     private static String name = "layoutmgr";
 
+    public LayoutManagerLS(Document document) {
+        super(document);
+    }
+
     /**
      * Runs the formatting of this page sequence into the given area tree
      *
@@ -86,6 +94,8 @@ public class LayoutManagerLS extends LayoutStrategy {
             return;
         }
 
+        addBookmarksToAreaTree();
+
         // Initialize if already used?
         //    this.layoutMasterSet.resetPageMasters();
         if (pageSeq.getPageSequenceMaster() != null) {
@@ -121,4 +131,26 @@ public class LayoutManagerLS extends LayoutStrategy {
         pageSeq.getRoot().setRunningPageNumberCounter(pageSeq.getCurrentPageNumber());
     }
 
+    /**
+     * When this element is finished then it can create
+     * the bookmark data from the child elements and add
+     * the extension to the area tree.
+     */
+    public void addBookmarksToAreaTree() {
+        document.getDriver().getLogger().debug("adding bookmarks to area tree");
+        BookmarkData data = new BookmarkData();
+        for (int count = 0; count < document.getBookmarks().getOutlines().size(); count++) {
+            Outline out = (Outline)(document.getBookmarks().getOutlines()).get(count);
+            data.addSubData(out.getData());
+        }
+        // add data to area tree for resolving and handling
+        if (document.getBookmarks().getFOInputHandler() instanceof FOTreeHandler) {
+            FOTreeHandler foth = (FOTreeHandler)document.getBookmarks().getFOInputHandler();
+            Document doc = (Document)foth.foTreeControl;
+            AreaTree at = doc.getAreaTree();
+            at.addTreeExtension(data);
+            data.setAreaTree(at);
+        }
+    }
+
 }