aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Victor Mote <vmote@apache.org>2003-08-20 19:46:47 +0000
committerWilliam Victor Mote <vmote@apache.org>2003-08-20 19:46:47 +0000
commitb9e6c74ed4636d9a2b31f64689615a8307ac7001 (patch)
treedf4c6a3756cc85d890e613025a475d378e5762d9
parentd43ad404c0e1a8725269c34b5d6479abc2c472ca (diff)
downloadxmlgraphics-fop-b9e6c74ed4636d9a2b31f64689615a8307ac7001.tar.gz
xmlgraphics-fop-b9e6c74ed4636d9a2b31f64689615a8307ac7001.zip
move logic for creating bookmarks/outlines in the area tree from extensions/Bookmarks to layoutmgr/LayoutManagerLS
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196818 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/java/org/apache/fop/apps/Document.java12
-rw-r--r--src/java/org/apache/fop/apps/Driver.java2
-rw-r--r--src/java/org/apache/fop/extensions/Bookmarks.java33
-rw-r--r--src/java/org/apache/fop/fo/FOTreeControl.java5
-rw-r--r--src/java/org/apache/fop/fo/FObj.java4
-rw-r--r--src/java/org/apache/fop/layout/LayoutStrategy.java6
-rw-r--r--src/java/org/apache/fop/layoutmgr/LayoutManagerLS.java32
7 files changed, 64 insertions, 30 deletions
diff --git a/src/java/org/apache/fop/apps/Document.java b/src/java/org/apache/fop/apps/Document.java
index a78b51d16..081d958b8 100644
--- a/src/java/org/apache/fop/apps/Document.java
+++ b/src/java/org/apache/fop/apps/Document.java
@@ -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;
+ }
+
}
diff --git a/src/java/org/apache/fop/apps/Driver.java b/src/java/org/apache/fop/apps/Driver.java
index 784060cc9..560956a50 100644
--- a/src/java/org/apache/fop/apps/Driver.java
+++ b/src/java/org/apache/fop/apps/Driver.java
@@ -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 {
diff --git a/src/java/org/apache/fop/extensions/Bookmarks.java b/src/java/org/apache/fop/extensions/Bookmarks.java
index dbd1c6a81..30bcaa1c2 100644
--- a/src/java/org/apache/fop/extensions/Bookmarks.java
+++ b/src/java/org/apache/fop/extensions/Bookmarks.java
@@ -50,11 +50,8 @@
*/
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.
@@ -89,39 +85,20 @@ 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;
+ }
+}
diff --git a/src/java/org/apache/fop/fo/FOTreeControl.java b/src/java/org/apache/fop/fo/FOTreeControl.java
index c960654cf..ca90f76bf 100644
--- a/src/java/org/apache/fop/fo/FOTreeControl.java
+++ b/src/java/org/apache/fop/fo/FOTreeControl.java
@@ -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();
+
}
diff --git a/src/java/org/apache/fop/fo/FObj.java b/src/java/org/apache/fop/fo/FObj.java
index c95bfec10..ed8de0541 100644
--- a/src/java/org/apache/fop/fo/FObj.java
+++ b/src/java/org/apache/fop/fo/FObj.java
@@ -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
diff --git a/src/java/org/apache/fop/layout/LayoutStrategy.java b/src/java/org/apache/fop/layout/LayoutStrategy.java
index 390609174..24d9cc7eb 100644
--- a/src/java/org/apache/fop/layout/LayoutStrategy.java
+++ b/src/java/org/apache/fop/layout/LayoutStrategy.java
@@ -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.
diff --git a/src/java/org/apache/fop/layoutmgr/LayoutManagerLS.java b/src/java/org/apache/fop/layoutmgr/LayoutManagerLS.java
index 2ec3f8985..2757b798f 100644
--- a/src/java/org/apache/fop/layoutmgr/LayoutManagerLS.java
+++ b/src/java/org/apache/fop/layoutmgr/LayoutManagerLS.java
@@ -50,11 +50,15 @@
*/
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);
+ }
+ }
+
}