gmazza 2004/12/16 16:19:11
Modified: src/java/org/apache/fop/area AreaTreeHandler.java
BookmarkData.java
Log:
Moved the (upcoming) fo:bookmark-tree construction code from AreaTreeHandler
to the BookmarkData object.
Revision Changes Path
1.27 +24 -54 xml-fop/src/java/org/apache/fop/area/AreaTreeHandler.java
Index: AreaTreeHandler.java
===================================================================
RCS file:
/home/cvs/xml-fop/src/java/org/apache/fop/area/AreaTreeHandler.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -r1.26 -r1.27
--- AreaTreeHandler.java 16 Dec 2004 23:59:13 -0000 1.26
+++ AreaTreeHandler.java 17 Dec 2004 00:19:10 -0000 1.27
@@ -36,7 +36,6 @@
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 @@
}
/**
- * 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 @@
}
/**
- * 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;
}
/**
1.8 +32 -2 xml-fop/src/java/org/apache/fop/area/BookmarkData.java
Index: BookmarkData.java
===================================================================
RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/area/BookmarkData.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- BookmarkData.java 16 Dec 2004 23:59:13 -0000 1.7
+++ BookmarkData.java 17 Dec 2004 00:19:11 -0000 1.8
@@ -22,6 +22,9 @@
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 @@
* 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 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;
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]