diff options
author | Glen Mazza <gmazza@apache.org> | 2004-12-17 00:19:11 +0000 |
---|---|---|
committer | Glen Mazza <gmazza@apache.org> | 2004-12-17 00:19:11 +0000 |
commit | 5e3226de17b719d795eaa44bc7d940c5a80fc808 (patch) | |
tree | fc8c77e10e24bc602f3212d3cabc1e35d6c2ff61 /src | |
parent | 316fa029c4eae2f0f68e730828aa125b947a64fb (diff) | |
download | xmlgraphics-fop-5e3226de17b719d795eaa44bc7d940c5a80fc808.tar.gz xmlgraphics-fop-5e3226de17b719d795eaa44bc7d940c5a80fc808.zip |
Moved the (upcoming) fo:bookmark-tree construction code from AreaTreeHandler
to the BookmarkData object.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198203 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r-- | src/java/org/apache/fop/area/AreaTreeHandler.java | 76 | ||||
-rw-r--r-- | src/java/org/apache/fop/area/BookmarkData.java | 32 |
2 files changed, 54 insertions, 54 deletions
diff --git a/src/java/org/apache/fop/area/AreaTreeHandler.java b/src/java/org/apache/fop/area/AreaTreeHandler.java index 68ac04914..df60e0cbb 100644 --- a/src/java/org/apache/fop/area/AreaTreeHandler.java +++ b/src/java/org/apache/fop/area/AreaTreeHandler.java @@ -36,7 +36,6 @@ import org.apache.commons.logging.LogFactory; import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.fo.FOEventHandler; -import org.apache.fop.fo.extensions.Outline; import org.apache.fop.fo.extensions.Bookmarks; import org.apache.fop.fo.pagination.PageSequence; import org.apache.fop.fo.pagination.Root; @@ -194,31 +193,6 @@ public class AreaTreeHandler extends FOEventHandler { } /** - * End the document. - * - * @throws SAXException if there is some error - */ - public void endDocument() throws SAXException { - addBookmarks(rootFObj.getBookmarks()); - - model.endDocument(); - - if (outputStatistics) { - long memoryNow = runtime.totalMemory() - runtime.freeMemory(); - long memoryUsed = (memoryNow - initialMemory) / 1024L; - long timeUsed = System.currentTimeMillis() - startTime; - log.debug("Initial heap size: " + (initialMemory / 1024L) + "Kb"); - log.debug("Current heap size: " + (memoryNow / 1024L) + "Kb"); - log.debug("Total memory used: " + memoryUsed + "Kb"); - log.debug("Total time used: " + timeUsed + "ms"); - log.debug("Pages rendered: " + pageCount); - if (pageCount > 0) { - log.debug("Avg render time: " + (timeUsed / pageCount) + "ms/page"); - } - } - } - - /** * End the PageSequence. * The PageSequence formats Pages and adds them to the AreaTree. * The area tree then handles what happens with the pages. @@ -243,38 +217,34 @@ public class AreaTreeHandler extends FOEventHandler { } /** - * Create the bookmark data in the area tree. + * End the document. + * + * @throws SAXException if there is some error */ - private void addBookmarks(Bookmarks bookmarks) { - if (bookmarks == null) { - return; - } + public void endDocument() throws SAXException { - BookmarkData data = new BookmarkData(); - for (int count = 0; count < bookmarks.getOutlines().size(); count++) { - Outline out = (Outline)(bookmarks.getOutlines()).get(count); - data.addSubData(createBookmarkData(out)); + // process fo:bookmark-tree + Bookmarks bookmarks = rootFObj.getBookmarks(); + if (bookmarks != null) { + BookmarkData data = new BookmarkData(bookmarks); + addOffDocumentItem(data); } - addOffDocumentItem(data); - } - /** - * 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. - * - * @param outline the Outline object for which a bookmark entry should be - * created - * @return the new bookmark data - */ - private 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)); + model.endDocument(); + + if (outputStatistics) { + long memoryNow = runtime.totalMemory() - runtime.freeMemory(); + long memoryUsed = (memoryNow - initialMemory) / 1024L; + long timeUsed = System.currentTimeMillis() - startTime; + log.debug("Initial heap size: " + (initialMemory / 1024L) + "Kb"); + log.debug("Current heap size: " + (memoryNow / 1024L) + "Kb"); + log.debug("Total memory used: " + memoryUsed + "Kb"); + log.debug("Total time used: " + timeUsed + "ms"); + log.debug("Pages rendered: " + pageCount); + if (pageCount > 0) { + log.debug("Avg render time: " + (timeUsed / pageCount) + "ms/page"); + } } - return data; } /** diff --git a/src/java/org/apache/fop/area/BookmarkData.java b/src/java/org/apache/fop/area/BookmarkData.java index 9e814a0d9..8a0a4b39d 100644 --- a/src/java/org/apache/fop/area/BookmarkData.java +++ b/src/java/org/apache/fop/area/BookmarkData.java @@ -22,6 +22,9 @@ import java.util.ArrayList; import java.util.List; import java.util.HashMap; +import org.apache.fop.fo.extensions.Bookmarks; +import org.apache.fop.fo.extensions.Outline; + /** * An instance of this class is either a PDF bookmark-tree and * its child bookmark-items, or a bookmark-item and the child @@ -46,10 +49,17 @@ public class BookmarkData extends OffDocumentItem implements Resolvable { * Create a new bookmark data object. * This should only be called by the bookmark-tree item because * it has no idref item that needs to be resolved. + * + * @param bookmarks fo:bookmark-tree for this document */ - public BookmarkData() { + public BookmarkData(Bookmarks bookmarks) { idRef = null; whenToProcess = END_OF_DOC; + + for (int count = 0; count < bookmarks.getOutlines().size(); count++) { + Outline out = (Outline)(bookmarks.getOutlines()).get(count); + addSubData(createBookmarkData(out)); + } } /** @@ -183,5 +193,25 @@ public class BookmarkData extends OffDocumentItem implements Resolvable { public String getName() { return "Bookmarks"; } + + /** + * 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. + * + * @param outline the Outline object for which a bookmark entry should be + * created + * @return the new bookmark data + */ + private 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; + } + } |