From: William Victor Mote Date: Mon, 6 Oct 2003 15:52:46 +0000 (+0000) Subject: move logic for creating area tree bookmarks from layoutmgr/LayoutManagerLS to area... X-Git-Tag: Root_Temp_KnuthStylePageBreaking~1070 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=bc04dfeebbe1aa3efff53517903f70403b9cb773;p=xmlgraphics-fop.git move logic for creating area tree bookmarks from layoutmgr/LayoutManagerLS to area/AreaTree: 1. because it is not layout related 2. so that it can be reused by other Layout Strategies git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@196942 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/area/AreaTree.java b/src/java/org/apache/fop/area/AreaTree.java index a5585494a..c4f8ece85 100644 --- a/src/java/org/apache/fop/area/AreaTree.java +++ b/src/java/org/apache/fop/area/AreaTree.java @@ -50,6 +50,10 @@ */ package org.apache.fop.area; +import org.apache.fop.area.extensions.BookmarkData; +import org.apache.fop.fo.extensions.Outline; +import org.apache.fop.apps.Document; + import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -233,5 +237,43 @@ public class AreaTree { } model.endDocument(); } -} + /** + * 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 document) { + if (document.getBookmarks() == null) { + return; + } + 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(createBookmarkData(out)); + } + // add data to area tree for resolving and handling + AreaTree at = document.getAreaTree(); + at.addTreeExtension(data); + data.setAreaTree(at); + } + + /** + * Create and return the bookmark data for this outline. + * This creates a bookmark data with the destination + * and adds all the data from child outlines. + * + * @return the new bookmark data + */ + public BookmarkData createBookmarkData(Outline outline) { + BookmarkData data = new BookmarkData(outline.getInternalDestination()); + data.setLabel(outline.getLabel()); + for (int count = 0; count < outline.getOutlines().size(); count++) { + Outline out = (Outline)(outline.getOutlines()).get(count); + data.addSubData(createBookmarkData(out)); + } + return data; + } + +} diff --git a/src/java/org/apache/fop/layoutmgr/LayoutManagerLS.java b/src/java/org/apache/fop/layoutmgr/LayoutManagerLS.java index f95fe253f..bcf8692aa 100644 --- a/src/java/org/apache/fop/layoutmgr/LayoutManagerLS.java +++ b/src/java/org/apache/fop/layoutmgr/LayoutManagerLS.java @@ -54,8 +54,6 @@ import org.apache.fop.apps.Document; import org.apache.fop.apps.FOPException; import org.apache.fop.area.AreaTree; import org.apache.fop.area.Title; -import org.apache.fop.area.extensions.BookmarkData; -import org.apache.fop.fo.extensions.Outline; import org.apache.fop.fo.pagination.PageSequence; import org.apache.fop.layout.LayoutStrategy; @@ -96,7 +94,7 @@ public class LayoutManagerLS extends LayoutStrategy { return; } - addBookmarksToAreaTree(); + areaTree.addBookmarksToAreaTree(this.document); // Initialize if already used? // this.layoutMasterSet.resetPageMasters(); @@ -133,44 +131,6 @@ 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() { - if (document.getBookmarks() == null) { - return; - } - 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(createBookmarkData(out)); - } - // add data to area tree for resolving and handling - AreaTree at = document.getAreaTree(); - at.addTreeExtension(data); - data.setAreaTree(at); - } - - /** - * Create and return the bookmark data for this outline. - * This creates a bookmark data with the destination - * and adds all the data from child outlines. - * - * @return the new bookmark data - */ - public BookmarkData createBookmarkData(Outline outline) { - BookmarkData data = new BookmarkData(outline.getInternalDestination()); - data.setLabel(outline.getLabel()); - for (int count = 0; count < outline.getOutlines().size(); count++) { - Outline out = (Outline)(outline.getOutlines()).get(count); - data.addSubData(createBookmarkData(out)); - } - return data; - } - /** * @return the Title area */