diff options
author | Glen Mazza <gmazza@apache.org> | 2004-06-11 17:18:51 +0000 |
---|---|---|
committer | Glen Mazza <gmazza@apache.org> | 2004-06-11 17:18:51 +0000 |
commit | 573952b433057549a973489ab2626389e5b6bd32 (patch) | |
tree | 307a5f602b7d5268cc59916a25100e19921b8a37 /src/java/org/apache/fop/apps | |
parent | aaccdcd97f9aec51e4965d9c38cafa5fb0d7e4d7 (diff) | |
download | xmlgraphics-fop-573952b433057549a973489ab2626389e5b6bd32.tar.gz xmlgraphics-fop-573952b433057549a973489ab2626389e5b6bd32.zip |
Consolidated formatPageSequence() into FOTreeHandler.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197699 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/apps')
-rw-r--r-- | src/java/org/apache/fop/apps/Document.java | 120 | ||||
-rw-r--r-- | src/java/org/apache/fop/apps/Driver.java | 10 |
2 files changed, 9 insertions, 121 deletions
diff --git a/src/java/org/apache/fop/apps/Document.java b/src/java/org/apache/fop/apps/Document.java index 8bf576258..68c82cc73 100644 --- a/src/java/org/apache/fop/apps/Document.java +++ b/src/java/org/apache/fop/apps/Document.java @@ -20,7 +20,6 @@ package org.apache.fop.apps; // Java import java.util.Map; -import java.io.IOException; import java.util.Set; import java.util.HashSet; @@ -28,20 +27,12 @@ import java.util.HashSet; import org.apache.fop.area.AreaTree; import org.apache.fop.area.AreaTreeControl; import org.apache.fop.area.AreaTreeModel; -import org.apache.fop.area.Title; import org.apache.fop.fo.FOInputHandler; import org.apache.fop.fo.FOTreeControl; -import org.apache.fop.fo.FOTreeEvent; -import org.apache.fop.fo.FOTreeListener; import org.apache.fop.fo.extensions.Bookmarks; -import org.apache.fop.fo.pagination.PageSequence; import org.apache.fop.fonts.FontInfo; import org.apache.fop.layoutmgr.AddLMVisitor; -import org.apache.fop.layoutmgr.ContentLayoutManager; -import org.apache.fop.layoutmgr.InlineStackingLayoutManager; -import org.apache.fop.layoutmgr.LMiter; -import org.apache.fop.layoutmgr.PageLayoutManager; import org.apache.commons.logging.Log; @@ -53,8 +44,7 @@ import org.xml.sax.SAXException; * Class storing information for the FOP Document being processed, and managing * the processing of it. */ -public class Document implements FOTreeControl, FOTreeListener, - AreaTreeControl { +public class Document implements FOTreeControl, AreaTreeControl { /** The parent Driver object */ private Driver driver; @@ -112,34 +102,6 @@ public class Document implements FOTreeControl, FOTreeListener, } /** - * Required by the FOTreeListener interface. It handles an - * FOTreeEvent that is fired when a PageSequence object has been completed. - * @param event the FOTreeEvent that was fired - * @throws FOPException for errors in building the PageSequence - */ - public void foPageSequenceComplete (FOTreeEvent event) throws FOPException { - PageSequence pageSeq = event.getPageSequence(); - areaTree.addBookmarksToAreaTree(); - formatPageSequence(pageSeq, areaTree); - } - - /** - * Required by the FOTreeListener interface. It handles an FOTreeEvent that - * is fired when the Document has been completely parsed. - * @param event the FOTreeEvent that was fired - * @throws SAXException for parsing errors - */ - public void foDocumentComplete (FOTreeEvent event) throws SAXException { - //processAreaTree(atModel); - try { - areaTree.endDocument(); - driver.getRenderer().stopRenderer(); - } catch (IOException ex) { - throw new SAXException(ex); - } - } - - /** * Get the area tree for this layout handler. * * @return the area tree for this document @@ -181,86 +143,6 @@ public class Document implements FOTreeControl, FOTreeListener, } /** - * Runs the formatting of this page sequence into the given area tree - * - * @param pageSeq the PageSequence to be formatted - * @param areaTree the area tree to format this page sequence into - * @throws FOPException if there is an error formatting the contents - */ - private void formatPageSequence(PageSequence pageSeq, AreaTree areaTree) - throws FOPException { - Title title = null; - if (pageSeq.getTitleFO() != null) { - title = getTitleArea(pageSeq.getTitleFO()); - } - areaTree.startPageSequence(title); - // Make a new PageLayoutManager and a FlowLayoutManager - // Run the PLM in a thread - // Wait for them to finish. - - // If no main flow, nothing to layout! - if (pageSeq.getMainFlow() == null) { - return; - } - - // Initialize if already used? - // this.layoutMasterSet.resetPageMasters(); - if (pageSeq.getPageSequenceMaster() != null) { - pageSeq.getPageSequenceMaster().reset(); - } - - pageSeq.initPageNumber(); - - // This will layout pages and add them to the area tree - PageLayoutManager pageLM = new PageLayoutManager(areaTree, pageSeq, this); - pageLM.setPageCounting(pageSeq.getCurrentPageNumber(), - pageSeq.getPageNumberGenerator()); - - // For now, skip the threading and just call run directly. - pageLM.run(); - - // Thread layoutThread = new Thread(pageLM); - // layoutThread.start(); - // log.debug("Layout thread started"); - - // // wait on both managers - // try { - // layoutThread.join(); - // log.debug("Layout thread done"); - // } catch (InterruptedException ie) { - // log.error("PageSequence.format() interrupted waiting on layout"); - // } - - pageSeq.setCurrentPageNumber(pageLM.getPageCount()); - // Tell the root the last page number we created. - pageSeq.getRoot().setRunningPageNumberCounter(pageSeq.getCurrentPageNumber()); - } - - /** - * @return the Title area - */ - public org.apache.fop.area.Title getTitleArea(org.apache.fop.fo.pagination.Title foTitle) { - // use special layout manager to add the inline areas - // to the Title. - InlineStackingLayoutManager lm; - lm = new InlineStackingLayoutManager(foTitle); - lm.setLMiter(new LMiter(lm, foTitle.children.listIterator())); - lm.initialize(); - - // get breaks then add areas to title - org.apache.fop.area.Title title = - new org.apache.fop.area.Title(); - - ContentLayoutManager clm = new ContentLayoutManager(title); - clm.setUserAgent(foTitle.getUserAgent()); - lm.setParent(clm); - - clm.fillArea(lm); - - return title; - } - - /** * Public accessor to set the AddLMVisitor object that should be used. * This allows subclasses of AddLMVisitor to be used, which can be useful * for extensions to the FO Tree. diff --git a/src/java/org/apache/fop/apps/Driver.java b/src/java/org/apache/fop/apps/Driver.java index 8fdd30dad..cc478a198 100644 --- a/src/java/org/apache/fop/apps/Driver.java +++ b/src/java/org/apache/fop/apps/Driver.java @@ -518,7 +518,6 @@ public class Driver { public void startDocument() throws SAXException { if (foInputHandler instanceof FOTreeHandler) { FOTreeHandler foTreeHandler = (FOTreeHandler)foInputHandler; - foTreeHandler.addFOTreeListener(currentDocument); } super.startDocument(); } @@ -527,7 +526,6 @@ public class Driver { super.endDocument(); if (foInputHandler instanceof FOTreeHandler) { FOTreeHandler foTreeHandler = (FOTreeHandler)foInputHandler; - foTreeHandler.removeFOTreeListener(currentDocument); } } @@ -638,4 +636,12 @@ public class Driver { } } + /** + * Public accessor for getting the document used by this generation + * @return the current Document object + */ + public Document getCurrentDocument() { + return currentDocument; + } + } |