rem The default commons logger for JDK1.4 is JDK1.4Logger.
rem To use a different logger, uncomment the one desired below
rem set LOGCHOICE=-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.NoOpLog
-rem set LOGCHOICE=-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog
+set LOGCHOICE=-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog
rem set LOGCHOICE=-Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Log4JLogger
set LOGLEVEL=
import org.xml.sax.SAXException;
// Apache
+import org.apache.commons.logging.Log;
+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.Bookmarks;
import org.apache.fop.fo.pagination.PageSequence;
import org.apache.fop.layoutmgr.PageSequenceLayoutManager;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
/**
* Area tree handler for formatting objects.
* @throws SAXException if there is some error
*/
public void endDocument() throws SAXException {
- /*
- * inform Resolveable objects that certain idrefs
- * could not be found
- * @todo unsure if this block is needed.
- */
- for (Iterator iter = unresolvedIDRefs.keySet().iterator();
- iter.hasNext();) {
- String idref = (String) iter.next();
- Set list = (Set) unresolvedIDRefs.get(idref);
- for (Iterator resIter = list.iterator(); resIter.hasNext();) {
- Resolvable res = (Resolvable) resIter.next();
- if (!res.isResolved()) {
- res.resolveIDRef(idref, null);
- }
- }
- }
model.endDocument();
if (outputStatistics) {
}
/**
- * Check prepared pages
- * If a page is resolved it loads the page contents from
- * the file.
- *
- * @param newpage the new page being added
- * @return true if the current page should be rendered
- * false if the renderer doesn't support out of order
- * rendering and there are pending pages
+ * @see org.apache.fop.area.RenderPagesModel#checkPreparedPages(PageViewport, boolean)
*/
- protected boolean checkPreparedPages(PageViewport newpage) {
+ protected boolean checkPreparedPages(PageViewport newpage, boolean renderUnresolved) {
for (Iterator iter = prepared.iterator(); iter.hasNext();) {
PageViewport p = (PageViewport)iter.next();
- if (p.isResolved()) {
+ if (p.isResolved() || renderUnresolved) {
if (p != newpage) {
try {
// load page from cache
try {
renderer.renderPage(p);
+ if (!p.isResolved()) {
+ String[] idrefs = p.getIDs();
+ for (int count = 0; count < idrefs.length; count++) {
+ log.warn("Page " + p.getPageNumber() +
+ ": Unresolved id reference \"" + idrefs[count]
+ + "\" found.");
+ }
+ }
} catch (Exception e) {
// use error handler to handle this FOP or IO Exception
e.printStackTrace();
package org.apache.fop.area;
import java.io.Serializable;
-import java.util.Map;
+import java.util.HashMap;
import org.apache.fop.fo.Constants;
private RegionViewport regionAfter = null;
// temporary map of unresolved objects used when serializing the page
- private Map unresolved = null;
+ private HashMap unresolved = null;
/**
* Set the region on this page.
/**
* Set the unresolved references on this page for serializing.
*
- * @param unres the map of unresolved objects
+ * @param unres the HashMap of unresolved objects
*/
- public void setUnresolvedReferences(Map unres) {
+ public void setUnresolvedReferences(HashMap unres) {
unresolved = unres;
}
* This should be called after deserializing to retrieve
* the map of unresolved references that were serialized.
*
- * @return the de-serialized map of unresolved objects
+ * @return the de-serialized HashMap of unresolved objects
*/
- public Map getUnresolvedReferences() {
+ public HashMap getUnresolvedReferences() {
return unresolved;
}
}
// this keeps a list of currently unresolved areas or extensions
// once an idref is resolved it is removed
// when this is empty the page can be rendered
- private Map unresolvedIDRefs = new HashMap();
+ private HashMap unresolvedIDRefs = new HashMap();
- private Map unresolved = null;
-
private Map pendingResolved = null;
// hashmap of markers for this page
}
/**
- * Add an unresolved id to this page.
- * All unresolved ids for the contents of this page are
- * added to this page. This is so that the resolvers can be
- * serialized with the page to preserve the proper function.
- * @param id the id of the reference
- * @param res the resolver of the reference
+ * Add an idref to this page.
+ * All idrefs found for child areas of this PageViewport are added
+ * to unresolvedIDRefs, for subsequent resolution by AreaTreeHandler
+ * calls to this object's resolveIDRef().
+ *
+ * @param id the idref
+ * @param res the child element of this page that needs this
+ * idref resolved
*/
public void addUnresolvedIDRef(String idref, Resolvable res) {
if (unresolvedIDRefs == null) {
}
/**
- * Get the id references for this page.
- * @return always null
+ * Get the unresolved idrefs for this page.
+ * @return String array of idref's that still have not been resolved
*/
public String[] getIDs() {
- return null;
+ return (unresolvedIDRefs == null) ? null :
+ (String[]) unresolvedIDRefs.keySet().toArray(new String[] {});
}
/**
}
}
}
- if (unresolvedIDRefs != null) {
+ if (unresolvedIDRefs != null && pages != null) {
unresolvedIDRefs.remove(id);
if (unresolvedIDRefs.isEmpty()) {
unresolvedIDRefs = null;
*/
public void savePage(ObjectOutputStream out) throws Exception {
// set the unresolved references so they are serialized
- page.setUnresolvedReferences(unresolved);
+ page.setUnresolvedReferences(unresolvedIDRefs);
out.writeObject(page);
page = null;
}
*/
public void loadPage(ObjectInputStream in) throws Exception {
page = (Page) in.readObject();
- unresolved = page.getUnresolvedReferences();
- if (unresolved != null && pendingResolved != null) {
+ unresolvedIDRefs = page.getUnresolvedReferences();
+ if (unresolvedIDRefs != null && pendingResolved != null) {
for (Iterator iter = pendingResolved.keySet().iterator();
iter.hasNext();) {
String id = (String) iter.next();
// check prepared pages
- boolean cont = checkPreparedPages(page);
+ boolean cont = checkPreparedPages(page, false);
if (cont) {
processOffDocumentItems(pendingODI);
* Check prepared pages
*
* @param newpage the new page being added
+ * @param renderUnresolved render pages with unresolved idref's
+ * (done at end-of-document processing)
* @return true if the current page should be rendered
* false if the renderer doesn't support out of order
* rendering and there are pending pages
*/
- protected boolean checkPreparedPages(PageViewport newpage) {
+ protected boolean checkPreparedPages(PageViewport newpage, boolean
+ renderUnresolved) {
for (Iterator iter = prepared.iterator(); iter.hasNext();) {
PageViewport p = (PageViewport)iter.next();
- if (p.isResolved()) {
+ if (p.isResolved() || renderUnresolved) {
try {
renderer.renderPage(p);
+ if (!p.isResolved()) {
+ String[] idrefs = p.getIDs();
+ for (int count = 0; count < idrefs.length; count++) {
+ log.warn("Page " + p.getPageNumber() +
+ ": Unresolved id reference \"" + idrefs[count]
+ + "\" found.");
+ }
+ }
} catch (Exception e) {
// use error handler to handle this FOP or IO Exception
e.printStackTrace();
*/
public void endDocument() throws SAXException {
// render any pages that had unresolved ids
- checkPreparedPages(null);
+ checkPreparedPages(null, true);
processOffDocumentItems(pendingODI);
pendingODI.clear();
// XML
import org.xml.sax.SAXException;
+// Apache
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
/**
* This class stores all the pages in the document
private List currSequence;
private List offDocumentItems = new java.util.ArrayList();
+ protected static Log log = LogFactory.getLog(StorePagesModel.class);
+
/**
* Create a new store pages model
*/