import org.apache.fop.fo.ElementMapping;
import org.apache.fop.fo.FOTreeBuilder;
import org.apache.fop.fo.FOInputHandler;
-import org.apache.fop.fo.FOTreeHandler;
+import org.apache.fop.area.AreaTreeHandler;
import org.apache.fop.render.awt.AWTRenderer;
import org.apache.fop.render.mif.MIFHandler;
import org.apache.fop.render.rtf.RTFHandler;
"Renderer must be set using setRenderer(int renderType)");
}
- foInputHandler = new FOTreeHandler(foUserAgent, rendererType,
+ foInputHandler = new AreaTreeHandler(foUserAgent, rendererType,
stream);
}
+++ /dev/null
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-package org.apache.fop.area;
-
-// Java
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.HashMap;
-import java.util.Set;
-import java.util.HashSet;
-import java.util.Iterator;
-
-// XML
-import org.xml.sax.SAXException;
-
-// Apache
-import org.apache.fop.apps.FOPException;
-import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.area.extensions.BookmarkData;
-import org.apache.fop.fo.extensions.Outline;
-import org.apache.fop.fo.extensions.Bookmarks;
-import org.apache.fop.fonts.FontInfo;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Area tree for formatting objects.
- *
- * Concepts:
- * The area tree is to be as small as possible. With minimal classes
- * and data to fully represent an area tree for formatting objects.
- * The area tree needs to be simple to render and follow the spec
- * closely.
- * This area tree has the concept of page sequences.
- * Where ever possible information is discarded or optimized to
- * keep memory use low. The data is also organized to make it
- * possible for renderers to minimize their output.
- * A page can be saved if not fully resolved and once rendered
- * a page contains only size and id reference information.
- * The area tree pages are organized in a model that depends on the
- * type of renderer.
- */
-public class AreaTree {
- // allows for different models to deal with adding/rendering
- // in different situations
- private AreaTreeModel model;
-
- // hashmap of arraylists containing pages with id area
- private Map idLocations = new HashMap();
-
- // list of id's yet to be resolved and arraylists of pages
- private Map resolve = new HashMap();
-
- private List treeExtensions = new ArrayList();
-
- private static Log log = LogFactory.getLog(AreaTree.class);
-
- private FOUserAgent foUserAgent;
-
- /**
- * Constructor.
- * @param userAgent FOUserAgent object for process
- * @param renderType Desired fo.Constants output type (RENDER_PDF,
- * RENDER_PS, etc.)
- * @param fontInfo FontInfo object
- * @param stream OutputStream
- */
- public AreaTree (FOUserAgent userAgent, int renderType,
- FontInfo fontInfo, OutputStream stream) throws FOPException {
-
- foUserAgent = userAgent;
-
- // model = new CachedRenderPagesModel(userAgent, renderType,
- // fontInfo, stream);
- model = new RenderPagesModel(userAgent, renderType, fontInfo,
- stream);
- }
-
- /**
- * Get the area tree model for this area tree.
- *
- * @return AreaTreeModel the model being used for this area tree
- */
- public AreaTreeModel getAreaTreeModel() {
- return model;
- }
-
- /**
- * Start a new page sequence.
- * This signals that a new page sequence has started in the document.
- * @param title the title of the new page sequence or null if no title
- */
- public void startPageSequence(Title title) {
- model.startPageSequence(title);
- }
-
- /**
- * Add a new page to the area tree.
- * @param page the page to add
- */
- public void addPage(PageViewport page) {
- model.addPage(page);
- }
-
- /**
- * Add an id reference pointing to a page viewport.
- * @param id the id of the reference
- * @param pv the page viewport that contains the id reference
- */
- public void addIDRef(String id, PageViewport pv) {
- List list = (List)idLocations.get(id);
- if (list == null) {
- list = new ArrayList();
- idLocations.put(id, list);
- }
- list.add(pv);
-
- Set todo = (Set)resolve.get(id);
- if (todo != null) {
- for (Iterator iter = todo.iterator(); iter.hasNext();) {
- Resolveable res = (Resolveable)iter.next();
- res.resolve(id, list);
- }
- resolve.remove(id);
- }
- }
-
- /**
- * Get the list of id references for an id.
- * @param id the id to lookup
- * @return the list of id references.
- */
- public List getIDReferences(String id) {
- return (List)idLocations.get(id);
- }
-
- /**
- * Add an unresolved object with a given id.
- * @param id the id reference that needs resolving
- * @param res the Resolveable object to resolve
- */
- public void addUnresolvedID(String id, Resolveable res) {
- Set todo = (Set)resolve.get(id);
- if (todo == null) {
- todo = new HashSet();
- resolve.put(id, todo);
- }
- todo.add(res);
- }
-
- /**
- * Add a tree extension.
- * This checks if the extension is resolveable and attempts
- * to resolve or add the resolveable ids for later resolution.
- * @param ext the tree extension to add.
- */
- public void addTreeExtension(TreeExt ext) {
- treeExtensions.add(ext);
- if (ext.isResolveable()) {
- Resolveable res = (Resolveable)ext;
- String[] ids = res.getIDs();
- for (int count = 0; count < ids.length; count++) {
- if (idLocations.containsKey(ids[count])) {
- res.resolve(ids[count], (List)idLocations.get(ids[count]));
- } else {
- Set todo = (Set)resolve.get(ids[count]);
- if (todo == null) {
- todo = new HashSet();
- resolve.put(ids[count], todo);
- }
- todo.add(ext);
- }
- }
- } else {
- handleTreeExtension(ext, TreeExt.IMMEDIATELY);
- }
- }
-
- /**
- * Handle a tree extension.
- * This sends the extension to the model for handling.
- * @param ext the tree extension to handle
- * @param when when the extension should be handled by the model
- */
- public void handleTreeExtension(TreeExt ext, int when) {
- // queue tree extension according to the when
- model.addExtension(ext, when);
- }
-
- /**
- * Signal end of document.
- * This indicates that the document is complete and any unresolved
- * reference can be dealt with.
- */
- public void endDocument() throws SAXException {
- for (Iterator iter = resolve.keySet().iterator(); iter.hasNext();) {
- String id = (String)iter.next();
- Set list = (Set)resolve.get(id);
- for (Iterator resIter = list.iterator(); resIter.hasNext();) {
- Resolveable res = (Resolveable)resIter.next();
- if (!res.isResolved()) {
- res.resolve(id, null);
- }
- }
- }
- model.endDocument();
- }
-
- /**
- * Create the bookmark data in the area tree.
- */
- public void addBookmarksToAreaTree(Bookmarks bookmarks) {
- if (bookmarks == null) {
- return;
- }
-
- log.debug("adding bookmarks to area tree");
- BookmarkData data = new BookmarkData();
- for (int count = 0; count < bookmarks.getOutlines().size(); count++) {
- Outline out = (Outline)(bookmarks.getOutlines()).get(count);
- data.addSubData(createBookmarkData(out));
- }
- addTreeExtension(data);
- data.setAreaTree(this);
- }
-
- /**
- * 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
- */
- 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;
- }
-
-}
--- /dev/null
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+package org.apache.fop.area;
+
+// Java
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.Set;
+import java.util.HashSet;
+import java.util.Iterator;
+
+// XML
+import org.xml.sax.SAXException;
+
+// Apache
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.apps.FOUserAgent;
+import org.apache.fop.area.extensions.BookmarkData;
+import org.apache.fop.fo.FOInputHandler;
+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.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;
+import org.apache.commons.logging.LogFactory;
+
+// Java
+import java.io.OutputStream;
+import java.util.HashSet;
+import java.util.Iterator;
+
+/**
+ * Area tree handler for formatting objects.
+ *
+ * Concepts:
+ * The area tree is to be as small as possible. With minimal classes
+ * and data to fully represent an area tree for formatting objects.
+ * The area tree needs to be simple to render and follow the spec
+ * closely.
+ * This area tree has the concept of page sequences.
+ * Where ever possible information is discarded or optimized to
+ * keep memory use low. The data is also organized to make it
+ * possible for renderers to minimize their output.
+ * A page can be saved if not fully resolved and once rendered
+ * a page contains only size and id reference information.
+ * The area tree pages are organized in a model that depends on the
+ * type of renderer.
+ */
+public class AreaTreeHandler extends FOInputHandler {
+
+ // TODO: Collecting of statistics should be configurable
+ private final boolean collectStatistics = true;
+ private static final boolean MEM_PROFILE_WITH_GC = false;
+ private boolean pageSequenceFound = false;
+
+ // for statistics gathering
+ private Runtime runtime;
+
+ // heap memory allocated (for statistics)
+ private long initialMemory;
+
+ // time used in rendering (for statistics)
+ private long startTime;
+
+ // count of number of pages rendered
+ private int pageCount;
+
+ /** Useful only for allowing subclasses of AddLMVisitor to be set by those
+ extending FOP **/
+ private AddLMVisitor addLMVisitor = null;
+
+ // AreaTreeModel in use
+ private AreaTreeModel model;
+
+ // hashmap of arraylists containing pages with id area
+ private Map idLocations = new HashMap();
+
+ // list of id's yet to be resolved and arraylists of pages
+ private Map resolve = new HashMap();
+
+ private List treeExtensions = new ArrayList();
+
+ private static Log log = LogFactory.getLog(AreaTreeHandler.class);
+
+ /**
+ * Constructor.
+ * @param userAgent FOUserAgent object for process
+ * @param renderType Desired fo.Constants output type (RENDER_PDF,
+ * RENDER_PS, etc.)
+ * @param stream OutputStream
+ */
+ public AreaTreeHandler (FOUserAgent userAgent, int renderType,
+ OutputStream stream) throws FOPException {
+ super(userAgent);
+
+ // model = new CachedRenderPagesModel(userAgent, renderType,
+ // fontInfo, stream);
+ model = new RenderPagesModel(userAgent, renderType, fontInfo,
+ stream);
+
+ if (collectStatistics) {
+ runtime = Runtime.getRuntime();
+ }
+ }
+
+ /**
+ * Get the area tree model for this area tree.
+ *
+ * @return AreaTreeModel the model being used for this area tree
+ */
+ public AreaTreeModel getAreaTreeModel() {
+ return model;
+ }
+
+ /**
+ * Add a new page to the area tree.
+ * @param page the page to add
+ */
+ public void addPage(PageViewport page) {
+ model.addPage(page);
+ }
+
+ /**
+ * Add an id reference pointing to a page viewport.
+ * @param id the id of the reference
+ * @param pv the page viewport that contains the id reference
+ */
+ public void addIDRef(String id, PageViewport pv) {
+ List list = (List)idLocations.get(id);
+ if (list == null) {
+ list = new ArrayList();
+ idLocations.put(id, list);
+ }
+ list.add(pv);
+
+ Set todo = (Set)resolve.get(id);
+ if (todo != null) {
+ for (Iterator iter = todo.iterator(); iter.hasNext();) {
+ Resolveable res = (Resolveable)iter.next();
+ res.resolve(id, list);
+ }
+ resolve.remove(id);
+ }
+ }
+
+ /**
+ * Get the list of id references for an id.
+ * @param id the id to lookup
+ * @return the list of id references.
+ */
+ public List getIDReferences(String id) {
+ return (List)idLocations.get(id);
+ }
+
+ /**
+ * Add an unresolved object with a given id.
+ * @param id the id reference that needs resolving
+ * @param res the Resolveable object to resolve
+ */
+ public void addUnresolvedID(String id, Resolveable res) {
+ Set todo = (Set)resolve.get(id);
+ if (todo == null) {
+ todo = new HashSet();
+ resolve.put(id, todo);
+ }
+ todo.add(res);
+ }
+
+ /**
+ * Add a tree extension.
+ * This checks if the extension is resolveable and attempts
+ * to resolve or add the resolveable ids for later resolution.
+ * @param ext the tree extension to add.
+ */
+ public void addTreeExtension(TreeExt ext) {
+ treeExtensions.add(ext);
+ if (ext.isResolveable()) {
+ Resolveable res = (Resolveable)ext;
+ String[] ids = res.getIDs();
+ for (int count = 0; count < ids.length; count++) {
+ if (idLocations.containsKey(ids[count])) {
+ res.resolve(ids[count], (List)idLocations.get(ids[count]));
+ } else {
+ Set todo = (Set)resolve.get(ids[count]);
+ if (todo == null) {
+ todo = new HashSet();
+ resolve.put(ids[count], todo);
+ }
+ todo.add(ext);
+ }
+ }
+ } else {
+ handleTreeExtension(ext, TreeExt.IMMEDIATELY);
+ }
+ }
+
+ /**
+ * Handle a tree extension.
+ * This sends the extension to the model for handling.
+ * @param ext the tree extension to handle
+ * @param when when the extension should be handled by the model
+ */
+ public void handleTreeExtension(TreeExt ext, int when) {
+ // queue tree extension according to the when
+ model.addExtension(ext, when);
+ }
+
+ /**
+ * Prepare AreaTreeHandler for document processing
+ * This is called from FOTreeBuilder.startDocument()
+ *
+ * @throws SAXException if there is an error
+ */
+ public void startDocument() throws SAXException {
+ //Initialize statistics
+ if (collectStatistics) {
+ pageCount = 0;
+ if (MEM_PROFILE_WITH_GC) {
+ System.gc(); // This takes time but gives better results
+ }
+
+ initialMemory = runtime.totalMemory() - runtime.freeMemory();
+ startTime = System.currentTimeMillis();
+ }
+ }
+
+ /**
+ * End the document.
+ *
+ * @throws SAXException if there is some error
+ */
+ public void endDocument() throws SAXException {
+ if (pageSequenceFound == false) {
+ throw new SAXException("Error: No fo:page-sequence child " +
+ "found within fo:root element.");
+ }
+
+ // deal with unresolved references
+ for (Iterator iter = resolve.keySet().iterator(); iter.hasNext();) {
+ String id = (String)iter.next();
+ Set list = (Set)resolve.get(id);
+ for (Iterator resIter = list.iterator(); resIter.hasNext();) {
+ Resolveable res = (Resolveable)resIter.next();
+ if (!res.isResolved()) {
+ res.resolve(id, null);
+ }
+ }
+ }
+ model.endDocument();
+
+ if (collectStatistics) {
+ if (MEM_PROFILE_WITH_GC) {
+ // This takes time but gives better results
+ System.gc();
+ }
+ long memoryNow = runtime.totalMemory() - runtime.freeMemory();
+ long memoryUsed = (memoryNow - initialMemory) / 1024L;
+ long timeUsed = System.currentTimeMillis() - startTime;
+ if (logger != null && logger.isDebugEnabled()) {
+ logger.debug("Initial heap size: " + (initialMemory / 1024L) + "Kb");
+ logger.debug("Current heap size: " + (memoryNow / 1024L) + "Kb");
+ logger.debug("Total memory used: " + memoryUsed + "Kb");
+ if (!MEM_PROFILE_WITH_GC) {
+ logger.debug(" Memory use is indicative; no GC was performed");
+ logger.debug(" These figures should not be used comparatively");
+ }
+ logger.debug("Total time used: " + timeUsed + "ms");
+ logger.debug("Pages rendered: " + pageCount);
+ if (pageCount > 0) {
+ logger.debug("Avg render time: " + (timeUsed / pageCount) + "ms/page");
+ }
+ }
+ }
+ }
+
+ /**
+ * Create the bookmark data in the area tree.
+ */
+ public void addBookmarks(Bookmarks bookmarks) {
+ if (bookmarks == null) {
+ return;
+ }
+
+ log.debug("adding bookmarks to area tree");
+ BookmarkData data = new BookmarkData();
+ for (int count = 0; count < bookmarks.getOutlines().size(); count++) {
+ Outline out = (Outline)(bookmarks.getOutlines()).get(count);
+ data.addSubData(createBookmarkData(out));
+ }
+ addTreeExtension(data);
+ data.setAreaTreeHandler(this);
+ }
+
+ /**
+ * 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
+ */
+ 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;
+ }
+
+ /**
+ * Start a page sequence.
+ * At the start of a page sequence it can start the page sequence
+ * on the area tree with the page sequence title.
+ *
+ * @param pageSeq the page sequence starting
+ */
+ public void startPageSequence(PageSequence pageSeq) {
+ pageSequenceFound = true;
+ }
+
+ /**
+ * End the PageSequence.
+ * The PageSequence formats Pages and adds them to the AreaTree.
+ * The area tree then handles what happens with the pages.
+ *
+ * @param pageSequence the page sequence ending
+ * @throws FOPException if there is an error formatting the pages
+ */
+ public void endPageSequence(PageSequence pageSequence)
+ throws FOPException {
+ //areaTree.setFontInfo(fontInfo);
+
+ if (collectStatistics) {
+ if (MEM_PROFILE_WITH_GC) {
+ // This takes time but gives better results
+ System.gc();
+ }
+ long memoryNow = runtime.totalMemory() - runtime.freeMemory();
+ if (logger != null) {
+ logger.debug("Current heap size: " + (memoryNow / 1024L) + "Kb");
+ }
+ }
+
+ addBookmarks(pageSequence.getRoot().getBookmarks());
+ formatPageSequence(pageSequence);
+ }
+
+ /**
+ * 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)
+ throws FOPException {
+ Title title = null;
+ if (pageSeq.getTitleFO() != null) {
+ title = getTitleArea(pageSeq.getTitleFO());
+ }
+
+ model.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(this, pageSeq);
+ 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
+ */
+ private 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 get the AddLMVisitor object that should be used.
+ * @return the AddLMVisitor object that should be used.
+ */
+ public AddLMVisitor getAddLMVisitor() {
+ if (this.addLMVisitor == null) {
+ this.addLMVisitor = new AddLMVisitor();
+ }
+ return this.addLMVisitor;
+ }
+
+}
import org.apache.fop.area.PageViewport;
import org.apache.fop.area.Resolveable;
import org.apache.fop.area.TreeExt;
-import org.apache.fop.area.AreaTree;
+import org.apache.fop.area.AreaTreeHandler;
import java.util.ArrayList;
import java.util.List;
private ArrayList subData = new ArrayList();
private HashMap idRefs = new HashMap();
- // area tree for the top level object to notify when resolved
- private AreaTree areaTree = null;
+ // area tree handler for the top level object to notify when resolved
+ private AreaTreeHandler areaTreeHandler = null;
private String idRef;
private PageViewport pageRef = null;
* This should only be called for the top level element.
* The area tree is used once resolving is complete.
*
- * @param at the area tree for the current document
+ * @param at the area tree handler for the current document
*/
- public void setAreaTree(AreaTree at) {
- areaTree = at;
+ public void setAreaTreeHandler(AreaTreeHandler ath) {
+ areaTreeHandler = ath;
}
/**
private void checkFinish() {
if (idRefs.size() == 0) {
idRefs = null;
- if (areaTree != null) {
- areaTree.handleTreeExtension(this, TreeExt.AFTER_PAGE);
+ if (areaTreeHandler != null) {
+ areaTreeHandler.handleTreeExtension(this, TreeExt.AFTER_PAGE);
}
}
}
// Apache
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.apps.FOPException;
-import org.apache.fop.area.AreaTree;
import org.apache.fop.fo.flow.BasicLink;
import org.apache.fop.fo.flow.Block;
import org.apache.fop.fo.flow.ExternalGraphic;
* This method is called to indicate the start of a new document run.
* @throws SAXException In case of a problem
*/
- public abstract void startDocument() throws SAXException;
+ public void startDocument() throws SAXException {
+ }
/**
* This method is called to indicate the end of a document run.
* @throws SAXException In case of a problem
*/
- public abstract void endDocument() throws SAXException;
+ public void endDocument() throws SAXException {
+ }
/**
*
* @param pageSeq PageSequence that is starting.
*/
- public abstract void startPageSequence(PageSequence pageSeq);
+ public void startPageSequence(PageSequence pageSeq) {
+ }
/**
*
* @param pageSeq PageSequence that is ending.
* @throws FOPException For errors encountered.
*/
- public abstract void endPageSequence(PageSequence pageSeq) throws FOPException;
+ public void endPageSequence(PageSequence pageSeq) throws FOPException {
+ }
/**
*
* @param pagenum PageNumber that is starting.
*/
- public abstract void startPageNumber(PageNumber pagenum);
+ public void startPageNumber(PageNumber pagenum) {
+ }
/**
*
* @param pagenum PageNumber that is ending.
*/
- public abstract void endPageNumber(PageNumber pagenum);
+ public void endPageNumber(PageNumber pagenum) {
+ }
/**
* This method is called to indicate the start of a new fo:flow or fo:static-content.
*
* @param fl Flow that is starting.
*/
- public abstract void startFlow(Flow fl);
+ public void startFlow(Flow fl) {
+ }
/**
*
* @param fl Flow that is ending.
*/
- public abstract void endFlow(Flow fl);
+ public void endFlow(Flow fl) {
+ }
/**
*
* @param bl Block that is starting.
*/
- public abstract void startBlock(Block bl);
+ public void startBlock(Block bl) {
+ }
/**
*
* @param bl Block that is ending.
*/
- public abstract void endBlock(Block bl);
+ public void endBlock(Block bl) {
+ }
/**
*
* @param inl Inline that is starting.
*/
- public abstract void startInline(Inline inl);
+ public void startInline(Inline inl) {
+ }
/**
*
* @param inl Inline that is ending.
*/
- public abstract void endInline(Inline inl);
+ public void endInline(Inline inl) {
+ }
// Tables
/**
*
* @param tbl Table that is starting.
*/
- public abstract void startTable(Table tbl);
+ public void startTable(Table tbl) {
+ }
/**
*
* @param tbl Table that is ending.
*/
- public abstract void endTable(Table tbl);
+ public void endTable(Table tbl) {
+ }
/**
*
* @param tc TableColumn that is starting;
*/
- public abstract void startColumn(TableColumn tc);
+ public void startColumn(TableColumn tc) {
+ }
/**
*
* @param tc TableColumn that is ending;
*/
- public abstract void endColumn(TableColumn tc);
+ public void endColumn(TableColumn tc) {
+ }
/**
*
* @param th TableBody that is starting;
*/
- public abstract void startHeader(TableBody th);
+ public void startHeader(TableBody th) {
+ }
/**
*
* @param th TableBody that is ending.
*/
- public abstract void endHeader(TableBody th);
+ public void endHeader(TableBody th) {
+ }
/**
*
* @param tf TableFooter that is starting.
*/
- public abstract void startFooter(TableBody tf);
+ public void startFooter(TableBody tf) {
+ }
/**
*
* @param tf TableFooter that is ending.
*/
- public abstract void endFooter(TableBody tf);
+ public void endFooter(TableBody tf) {
+ }
/**
*
* @param tb TableBody that is starting.
*/
- public abstract void startBody(TableBody tb);
+ public void startBody(TableBody tb) {
+ }
/**
*
* @param tb TableBody that is ending.
*/
- public abstract void endBody(TableBody tb);
+ public void endBody(TableBody tb) {
+ }
/**
*
* @param tr TableRow that is starting.
*/
- public abstract void startRow(TableRow tr);
+ public void startRow(TableRow tr) {
+ }
/**
*
* @param tr TableRow that is ending.
*/
- public abstract void endRow(TableRow tr);
+ public void endRow(TableRow tr) {
+ }
/**
*
* @param tc TableCell that is starting.
*/
- public abstract void startCell(TableCell tc);
+ public void startCell(TableCell tc) {
+ }
/**
*
* @param tc TableCell that is ending.
*/
- public abstract void endCell(TableCell tc);
+ public void endCell(TableCell tc) {
+ }
// Lists
*
* @param lb ListBlock that is starting.
*/
- public abstract void startList(ListBlock lb);
+ public void startList(ListBlock lb) {
+ }
/**
*
* @param lb ListBlock that is ending.
*/
- public abstract void endList(ListBlock lb);
+ public void endList(ListBlock lb) {
+ }
/**
*
* @param li ListItem that is starting.
*/
- public abstract void startListItem(ListItem li);
+ public void startListItem(ListItem li) {
+ }
/**
*
* @param li ListItem that is ending.
*/
- public abstract void endListItem(ListItem li);
+ public void endListItem(ListItem li) {
+ }
/**
* Process start of a ListLabel.
*/
- public abstract void startListLabel();
+ public void startListLabel() {
+ }
/**
* Process end of a ListLabel.
*/
- public abstract void endListLabel();
+ public void endListLabel() {
+ }
/**
* Process start of a ListBody.
*/
- public abstract void startListBody();
+ public void startListBody() {
+ }
/**
* Process end of a ListBody.
*/
- public abstract void endListBody();
+ public void endListBody() {
+ }
// Static Regions
/**
* Process start of a Static.
*/
- public abstract void startStatic();
+ public void startStatic() {
+ }
/**
* Process end of a Static.
*/
- public abstract void endStatic();
+ public void endStatic() {
+ }
+
/**
* Process start of a Markup.
*/
- public abstract void startMarkup();
+ public void startMarkup() {
+ }
/**
* Process end of a Markup.
*/
- public abstract void endMarkup();
+ public void endMarkup() {
+ }
/**
* Process start of a Link.
* @param basicLink BasicLink that is ending
*/
- public abstract void startLink(BasicLink basicLink);
+ public void startLink(BasicLink basicLink) {
+ }
/**
* Process end of a Link.
*/
- public abstract void endLink();
+ public void endLink() {
+ }
/**
* Process an ExternalGraphic.
* @param eg ExternalGraphic to process.
*/
- public abstract void image(ExternalGraphic eg);
+ public void image(ExternalGraphic eg) {
+ }
/**
* Process a pageRef.
*/
- public abstract void pageRef();
+ public void pageRef() {
+ }
/**
* Process an InstreamForeignObject.
* @param ifo InstreamForeignObject to process.
*/
- public abstract void foreignObject(InstreamForeignObject ifo);
+ public void foreignObject(InstreamForeignObject ifo) {
+ }
/**
* Process the start of a footnote.
* @param footnote Footnote that is starting
*/
- public abstract void startFootnote(Footnote footnote);
+ public void startFootnote(Footnote footnote) {
+ }
/**
* Process the ending of a footnote.
* @param footnote Footnote that is ending
*/
- public abstract void endFootnote(Footnote footnote);
+ public void endFootnote(Footnote footnote) {
+ }
/**
* Process the start of a footnote body.
* @param body FootnoteBody that is starting
*/
- public abstract void startFootnoteBody(FootnoteBody body);
+ public void startFootnoteBody(FootnoteBody body) {
+ }
/**
* Process the ending of a footnote body.
* @param body FootnoteBody that is ending
*/
- public abstract void endFootnoteBody(FootnoteBody body);
+ public void endFootnoteBody(FootnoteBody body) {
+ }
/**
* Process a Leader.
* @param l Leader to process.
*/
- public abstract void leader(Leader l);
+ public void leader(Leader l) {
+ }
/**
* Process character data.
* @param start Offset for characters to process.
* @param length Portion of array to process.
*/
- public abstract void characters(char data[], int start, int length);
+ public void characters(char data[], int start, int length) {
+ }
}
+++ /dev/null
-/*
- * Copyright 1999-2004 The Apache Software Foundation.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/* $Id$ */
-
-package org.apache.fop.fo;
-
-// Java
-import java.io.OutputStream;
-import java.util.HashSet;
-import java.util.Iterator;
-
-// SAX
-import org.xml.sax.SAXException;
-
-// FOP
-import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.apps.FOPException;
-import org.apache.fop.area.AreaTree;
-import org.apache.fop.area.Title;
-import org.apache.fop.fo.extensions.Bookmarks;
-import org.apache.fop.fo.flow.BasicLink;
-import org.apache.fop.fo.flow.Block;
-import org.apache.fop.fo.flow.ExternalGraphic;
-import org.apache.fop.fo.flow.Footnote;
-import org.apache.fop.fo.flow.FootnoteBody;
-import org.apache.fop.fo.flow.InstreamForeignObject;
-import org.apache.fop.fo.flow.Inline;
-import org.apache.fop.fo.flow.Leader;
-import org.apache.fop.fo.flow.ListBlock;
-import org.apache.fop.fo.flow.ListItem;
-import org.apache.fop.fo.flow.PageNumber;
-import org.apache.fop.fo.flow.Table;
-import org.apache.fop.fo.flow.TableColumn;
-import org.apache.fop.fo.flow.TableBody;
-import org.apache.fop.fo.flow.TableCell;
-import org.apache.fop.fo.flow.TableRow;
-import org.apache.fop.fo.pagination.Flow;
-import org.apache.fop.fo.pagination.PageSequence;
-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;
-
-
-/**
- * Defines how SAX events specific to XSL-FO input should be handled when
- * an FO Tree needs to be built.
- * This initiates layout processes and corresponding
- * rendering processes such as start/end.
- * @see FOInputHandler
- */
-public class FOTreeHandler extends FOInputHandler {
-
- // TODO: Collecting of statistics should be configurable
- private final boolean collectStatistics = true;
- private static final boolean MEM_PROFILE_WITH_GC = false;
- private boolean pageSequenceFound = false;
-
- /**
- * Somewhere to get our stats from.
- */
- private Runtime runtime;
-
- /** The current AreaTree for the FOTreeHandler. */
- public AreaTree areaTree;
-
- /**
- * Keep track of the number of pages rendered.
- */
- private int pageCount;
-
- /**
- * Keep track of heap memory allocated,
- * for statistical purposes.
- */
- private long initialMemory;
-
- /**
- * Keep track of time used in rendering
- */
- private long startTime;
-
- /** Useful only for allowing subclasses of AddLMVisitor to be set by those
- extending FOP **/
- private AddLMVisitor addLMVisitor = null;
-
- /**
- * Main constructor
- * @param userAgent the apps.userAgent implementation that governs
- * this FO Tree
- * @param renderType the fo.Constants value indicating desired
- * output type (RENDER_PDF, RENDER_PS, etc.)
- * @param OutputStream stream to use to output results of rendering
- *
- */
- public FOTreeHandler(FOUserAgent userAgent, int renderType,
- OutputStream stream) throws FOPException {
- super(userAgent);
-
- areaTree = new AreaTree(userAgent, renderType, fontInfo, stream);
-
- if (collectStatistics) {
- runtime = Runtime.getRuntime();
- }
- }
-
- /**
- * Prepare FOTreeHandler for FO Tree building.
- * This is called from FOTreeBuilder.startDocument()
- *
- * @throws SAXException if there is an error
- */
- public void startDocument() throws SAXException {
- //Initialize statistics
- if (collectStatistics) {
- pageCount = 0;
- if (MEM_PROFILE_WITH_GC) {
- System.gc(); // This takes time but gives better results
- }
-
- initialMemory = runtime.totalMemory() - runtime.freeMemory();
- startTime = System.currentTimeMillis();
- }
- }
-
- /**
- * End the document.
- *
- * @throws SAXException if there is some error
- */
- public void endDocument() throws SAXException {
-
- if (pageSequenceFound == false) {
- throw new SAXException("Error: No fo:page-sequence child " +
- "found within fo:root element.");
- }
-
- areaTree.endDocument();
-
- if (collectStatistics) {
- if (MEM_PROFILE_WITH_GC) {
- // This takes time but gives better results
- System.gc();
- }
- long memoryNow = runtime.totalMemory() - runtime.freeMemory();
- long memoryUsed = (memoryNow - initialMemory) / 1024L;
- long timeUsed = System.currentTimeMillis() - startTime;
- if (logger != null && logger.isDebugEnabled()) {
- logger.debug("Initial heap size: " + (initialMemory / 1024L) + "Kb");
- logger.debug("Current heap size: " + (memoryNow / 1024L) + "Kb");
- logger.debug("Total memory used: " + memoryUsed + "Kb");
- if (!MEM_PROFILE_WITH_GC) {
- logger.debug(" Memory use is indicative; no GC was performed");
- logger.debug(" These figures should not be used comparatively");
- }
- logger.debug("Total time used: " + timeUsed + "ms");
- logger.debug("Pages rendered: " + pageCount);
- if (pageCount > 0) {
- logger.debug("Avg render time: " + (timeUsed / pageCount) + "ms/page");
- }
- }
- }
- }
-
- /**
- * Start a page sequence.
- * At the start of a page sequence it can start the page sequence
- * on the area tree with the page sequence title.
- *
- * @param pageSeq the page sequence starting
- */
- public void startPageSequence(PageSequence pageSeq) {
- pageSequenceFound = true;
- }
-
- /**
- * End the PageSequence.
- * The PageSequence formats Pages and adds them to the AreaTree.
- * The area tree then handles what happens with the pages.
- *
- * @param pageSequence the page sequence ending
- * @throws FOPException if there is an error formatting the pages
- */
- public void endPageSequence(PageSequence pageSequence)
- throws FOPException {
- //areaTree.setFontInfo(fontInfo);
-
- if (collectStatistics) {
- if (MEM_PROFILE_WITH_GC) {
- // This takes time but gives better results
- System.gc();
- }
- long memoryNow = runtime.totalMemory() - runtime.freeMemory();
- if (logger != null) {
- logger.debug("Current heap size: " + (memoryNow / 1024L) + "Kb");
- }
- }
-
- areaTree.addBookmarksToAreaTree(pageSequence.getRoot().getBookmarks());
- formatPageSequence(pageSequence, areaTree);
- }
-
- /**
- * @see org.apache.fop.fo.FOInputHandler#startFlow(Flow)
- */
- public void startFlow(Flow fl) {
- }
-
- /**
- * @see org.apache.fop.fo.FOInputHandler#endFlow(Flow)
- */
- public void endFlow(Flow fl) {
- }
-
- /**
- * @see org.apache.fop.fo.FOInputHandler#startBlock(Block)
- */
- public void startBlock(Block bl) {
- }
-
- /**
- * @see org.apache.fop.fo.FOInputHandler#endBlock(Block)
- */
- public void endBlock(Block bl) {
- }
-
- /**
- *
- * @param inl Inline that is starting.
- */
- public void startInline(Inline inl){
- }
-
- /**
- *
- * @param inl Inline that is ending.
- */
- public void endInline(Inline inl){
- }
-
- /**
- * @see org.apache.fop.fo.FOInputHandler#startTable(Table)
- */
- public void startTable(Table tbl) {
- }
-
- /**
- * @see org.apache.fop.fo.FOInputHandler#endTable(Table)
- */
- public void endTable(Table tbl) {
- }
-
- /**
- *
- * @param tc TableColumn that is starting;
- */
- public void startColumn(TableColumn tc) {
- }
-
- /**
- *
- * @param tc TableColumn that is ending;
- */
- public void endColumn(TableColumn tc) {
- }
-
- /**
- * @see org.apache.fop.fo.FOInputHandler#startHeader(TableBody)
- */
- public void startHeader(TableBody th) {
- }
-
- /**
- * @see org.apache.fop.fo.FOInputHandler#endHeader(TableBody)
- */
- public void endHeader(TableBody th) {
- }
-
- /**
- * @see org.apache.fop.fo.FOInputHandler#startFooter(TableBody)
- */
- public void startFooter(TableBody tf) {
- }
-
- /**
- * @see org.apache.fop.fo.FOInputHandler#endFooter(TableBody)
- */
- public void endFooter(TableBody tf) {
- }
-
- /**
- * @see org.apache.fop.fo.FOInputHandler#startBody(TableBody)
- */
- public void startBody(TableBody tb) {
- }
-
- /**
- * @see org.apache.fop.fo.FOInputHandler#endBody(TableBody)
- */
- public void endBody(TableBody tb) {
- }
-
- /**
- * @see org.apache.fop.fo.FOInputHandler#startRow(TableRow)
- */
- public void startRow(TableRow tr) {
- }
-
- /**
- * @see org.apache.fop.fo.FOInputHandler#endRow(TableRow)
- */
- public void endRow(TableRow tr) {
- }
-
- /**
- * @see org.apache.fop.fo.FOInputHandler#startCell(TableCell)
- */
- public void startCell(TableCell tc) {
- }
-
- /**
- * @see org.apache.fop.fo.FOInputHandler#endCell(TableCell)
- */
- public void endCell(TableCell tc) {
- }
-
- // Lists
- /**
- * @see org.apache.fop.fo.FOInputHandler#startList(ListBlock)
- */
- public void startList(ListBlock lb) {
- }
-
- /**
- * @see org.apache.fop.fo.FOInputHandler#endList(ListBlock)
- */
- public void endList(ListBlock lb) {
- }
-
- /**
- * @see org.apache.fop.fo.FOInputHandler#startListItem(ListItem)
- */
- public void startListItem(ListItem li) {
- }
-
- /**
- * @see org.apache.fop.fo.FOInputHandler#endListItem(ListItem)
- */
- public void endListItem(ListItem li) {
- }
-
- /**
- * @see org.apache.fop.fo.FOInputHandler#startListLabel()
- */
- public void startListLabel() {
- }
-
- /**
- * @see org.apache.fop.fo.FOInputHandler#endListLabel()
- */
- public void endListLabel() {
- }
-
- /**
- * @see org.apache.fop.fo.FOInputHandler#startListBody()
- */
- public void startListBody() {
- }
-
- /**
- * @see org.apache.fop.fo.FOInputHandler#endListBody()
- */
- public void endListBody() {
- }
-
- // Static Regions
- /**
- * @see org.apache.fop.fo.FOInputHandler#startStatic()
- */
- public void startStatic() {
- }
-
- /**
- * @see org.apache.fop.fo.FOInputHandler#endStatic()
- */
- public void endStatic() {
- }
-
- /**
- * @see org.apache.fop.fo.FOInputHandler#startMarkup()
- */
- public void startMarkup() {
- }
-
- /**
- * @see org.apache.fop.fo.FOInputHandler#endMarkup()
- */
- public void endMarkup() {
- }
-
- /**
- * @see org.apache.fop.fo.FOInputHandler#startLink(BasicLink basicLink)
- */
- public void startLink(BasicLink basicLink) {
- }
-
- /**
- * @see org.apache.fop.fo.FOInputHandler#endLink()
- */
- public void endLink() {
- }
-
- /**
- * @see org.apache.fop.fo.FOInputHandler#image(ExternalGraphic)
- */
- public void image(ExternalGraphic eg) {
- }
-
- /**
- * @see org.apache.fop.fo.FOInputHandler#pageRef()
- */
- public void pageRef() {
- }
-
- /**
- * @see org.apache.fop.fo.FOInputHandler#foreignObject(InstreamForeignObject)
- */
- public void foreignObject(InstreamForeignObject ifo) {
- }
-
- /**
- * @see org.apache.fop.fo.FOInputHandler#startFootnote(Footnote)
- */
- public void startFootnote(Footnote footnote) {
- }
-
- /**
- * @see org.apache.fop.fo.FOInputHandler#endFootnote(Footnote)
- */
- public void endFootnote(Footnote footnote) {
- }
-
- /**
- * @see org.apache.fop.fo.FOInputHandler#startFootnoteBody(FootnoteBody)
- */
- public void startFootnoteBody(FootnoteBody body) {
- }
-
- /**
- * @see org.apache.fop.fo.FOInputHandler#endFootnoteBody(FootnoteBody)
- */
- public void endFootnoteBody(FootnoteBody body) {
- }
-
- /**
- * @see org.apache.fop.fo.FOInputHandler#leader(Leader)
- */
- public void leader(Leader l) {
- }
-
- /**
- * @see org.apache.fop.fo.FOInputHandler#characters(char[], int, int)
- */
- public void characters(char[] data, int start, int length) {
- }
-
- /**
- * 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
- */
- private 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.
- * @param addLMVisitor the AddLMVisitor object that should be used.
- */
- public void setAddLMVisitor(AddLMVisitor addLMVisitor) {
- this.addLMVisitor = addLMVisitor;
- }
-
- /**
- * Public accessor to get the AddLMVisitor object that should be used.
- * @return the AddLMVisitor object that should be used.
- */
- public AddLMVisitor getAddLMVisitor() {
- if (this.addLMVisitor == null) {
- this.addLMVisitor = new AddLMVisitor();
- }
- return this.addLMVisitor;
- }
-
- /**
- *
- * @param pagenum PageNumber that is starting.
- */
- public void startPageNumber(PageNumber pagenum) {
- }
-
- /**
- *
- * @param pagenum PageNumber that is ending.
- */
- public void endPageNumber(PageNumber pagenum) {
- }
-
-}
import org.apache.fop.fo.FObj;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.area.Area;
+import org.apache.fop.area.AreaTreeHandler;
import org.apache.fop.area.Resolveable;
import org.apache.fop.area.PageViewport;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.flow.Marker;
-import org.apache.fop.fo.FOTreeHandler;
import org.apache.fop.fo.PropertyManager;
import org.apache.commons.logging.Log;
return this.parentLM;
}
- public FOTreeHandler getFOTreeHandler() {
- return getParent().getFOTreeHandler();
+ public AreaTreeHandler getAreaTreeHandler() {
+ return getParent().getAreaTreeHandler();
}
// /**
package org.apache.fop.layoutmgr;
import org.apache.fop.fo.FObj;
-import org.apache.fop.fo.FOTreeHandler;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.fo.flow.Marker;
import org.apache.fop.area.Area;
+import org.apache.fop.area.AreaTreeHandler;
import org.apache.fop.area.Resolveable;
import org.apache.fop.area.PageViewport;
return this.parentLM;
}
- public FOTreeHandler getFOTreeHandler() {
- return getParent().getFOTreeHandler();
+ public AreaTreeHandler getAreaTreeHandler() {
+ return getParent().getAreaTreeHandler();
}
/** @see org.apache.fop.layoutmgr.LayoutManager */
}
protected boolean preLoadNext() {
- AddLMVisitor addLMVisitor = lp.getFOTreeHandler().getAddLMVisitor();
+ AddLMVisitor addLMVisitor = lp.getAreaTreeHandler().getAddLMVisitor();
// skip over child FObj's that don't add lms
while (baseIter != null && baseIter.hasNext()) {
Object theobj = baseIter.next();
import org.apache.fop.area.PageViewport;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.fo.FObj;
-import org.apache.fop.fo.FOTreeHandler;
+import org.apache.fop.area.AreaTreeHandler;
/**
* The interface for all LayoutManagers.
LayoutManager getParent();
/**
- * Get the FOTreeHandler object that is activating the LM Tree
- * @return the FOTreeHandler object
+ * Get the AreaTreeHandler object that is activating the LM Tree
+ * @return the AreaTreeHandler object
*/
- FOTreeHandler getFOTreeHandler();
+ AreaTreeHandler getAreaTreeHandler();
/**
* Initialize this layout manager.
import org.apache.fop.apps.FOPException;
import org.apache.fop.area.CTM;
-import org.apache.fop.area.AreaTree;
+import org.apache.fop.area.AreaTreeHandler;
import org.apache.fop.area.AreaTreeModel;
import org.apache.fop.area.Area;
import org.apache.fop.area.PageViewport;
import org.apache.fop.datatypes.FODimension;
import org.apache.fop.fo.FObj;
-import org.apache.fop.fo.FOTreeHandler;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.flow.Marker;
import org.apache.fop.fo.pagination.PageNumberGenerator;
* laid out and ready for rendering, except for resolution of ID
* references?
*/
- private AreaTree areaTree;
+ private AreaTreeHandler areaTreeHandler;
private PageSequence pageSequence;
- private FOTreeHandler foTreeHandler;
/**
* This is the SimplePageMaster that should be used to create the page. It
* @param areaTree the area tree to add pages to
* @param pageseq the page sequence fo
*/
- public PageLayoutManager(AreaTree areaTree, PageSequence pageseq,
- FOTreeHandler foTreeHandler) {
+ public PageLayoutManager(AreaTreeHandler areaTreeHandler, PageSequence pageseq) {
super(pageseq);
- this.areaTree = areaTree;
+ this.areaTreeHandler = areaTreeHandler;
pageSequence = pageseq;
- this.foTreeHandler = foTreeHandler;
}
/**
* @return the first page viewport that contains the reference
*/
public PageViewport resolveRefID(String ref) {
- List list = areaTree.getIDReferences(ref);
+ List list = areaTreeHandler.getIDReferences(ref);
if (list != null && list.size() > 0) {
return (PageViewport)list.get(0);
}
* @param id the ID reference to add
*/
public void addIDToPage(String id) {
- areaTree.addIDRef(id, curPage);
+ areaTreeHandler.addIDRef(id, curPage);
}
/**
// add unresolved to tree
// adds to the page viewport so it can serialize
curPage.addUnresolvedID(id, res);
- areaTree.addUnresolvedID(id, curPage);
+ areaTreeHandler.addUnresolvedID(id, curPage);
}
/**
// go back over pages until mark found
// if document boundary then keep going
boolean doc = boundary == RetrieveBoundary.DOCUMENT;
- AreaTreeModel atm = areaTree.getAreaTreeModel();
+ AreaTreeModel atm = areaTreeHandler.getAreaTreeModel();
int seq = atm.getPageSequenceCount();
int page = atm.getPageCount(seq) - 1;
while (page >= 0) {
layoutStaticContent(currentSimplePageMaster.getRegion(Region.END_CODE),
Region.END_CODE);
// Queue for ID resolution and rendering
- areaTree.addPage(curPage);
+ areaTreeHandler.addPage(curPage);
curPage = null;
curBody = null;
curSpan = null;
/**
* @return the apps.FOTreeHandler object controlling this generation
*/
- public FOTreeHandler getFOTreeHandler() {
- return foTreeHandler;
+ public AreaTreeHandler getAreaTreeHandler() {
+ return areaTreeHandler;
}
}