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;
public AreaTree areaTree;
public AreaTreeModel atModel;
+ private Bookmarks bookmarks;
+
/**
* Main constructor
* @param driver the Driver object that is the "parent" of this Document
return areaTree;
}
+ public void setBookmarks(Bookmarks bookmarks) {
+ this.bookmarks = bookmarks;
+ }
+
+ public Bookmarks getBookmarks() {
+ return bookmarks;
+ }
+
}
/** 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 {
*/
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;
*/
public class Bookmarks extends ExtensionObj {
private ArrayList outlines = new ArrayList();
- private BookmarkData data;
/**
* Create a new Bookmarks object.
}
}
- /**
- * 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;
+ }
+}
import java.util.Map;
// FOP
+import org.apache.fop.extensions.Bookmarks;
import org.apache.fop.fonts.FontMetrics;
/**
public Map getFonts();
+ public void setBookmarks(Bookmarks bookmarks);
+
+ public Bookmarks getBookmarks();
+
}
foInputHandler = foih;
}
+ public FOInputHandler getFOInputHandler() {
+ return foInputHandler;
+ }
+
/**
* lets outside sources access the property list
* first used by PageNumberCitation to find the "id" property
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;
public abstract class LayoutStrategy {
private String name = "undefined";
+ public Document document;
+
+ public LayoutStrategy(Document document) {
+ this.document = document;
+ }
/**
* Returns the name of this LayoutStrategy.
*/
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
private static String name = "layoutmgr";
+ public LayoutManagerLS(Document document) {
+ super(document);
+ }
+
/**
* Runs the formatting of this page sequence into the given area tree
*
return;
}
+ addBookmarksToAreaTree();
+
// Initialize if already used?
// this.layoutMasterSet.resetPageMasters();
if (pageSeq.getPageSequenceMaster() != null) {
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);
+ }
+ }
+
}