aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSimon Pepping <spepping@apache.org>2006-02-24 11:39:01 +0000
committerSimon Pepping <spepping@apache.org>2006-02-24 11:39:01 +0000
commit3eb942fd361204404fbe7f946ae1c319637e4bf1 (patch)
tree01d290ad096877bcb12e4f45ff218153798bd989 /src
parent799ffca5bbf2939cfe34f723c826f73dcd28138f (diff)
downloadxmlgraphics-fop-3eb942fd361204404fbe7f946ae1c319637e4bf1.tar.gz
xmlgraphics-fop-3eb942fd361204404fbe7f946ae1c319637e4bf1.zip
Avoid a NullPointerException when fo:title is empty.
Let PSLM and ContentLM create LMs via LayoutManagerMaker. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@380646 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/java/org/apache/fop/layoutmgr/LayoutManagerMaker.java11
-rw-r--r--src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java9
-rw-r--r--src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java10
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java24
4 files changed, 44 insertions, 10 deletions
diff --git a/src/java/org/apache/fop/layoutmgr/LayoutManagerMaker.java b/src/java/org/apache/fop/layoutmgr/LayoutManagerMaker.java
index 2d88aeff5..c80245c2e 100644
--- a/src/java/org/apache/fop/layoutmgr/LayoutManagerMaker.java
+++ b/src/java/org/apache/fop/layoutmgr/LayoutManagerMaker.java
@@ -23,6 +23,8 @@ import org.apache.fop.fo.pagination.Flow;
import org.apache.fop.fo.pagination.PageSequence;
import org.apache.fop.fo.pagination.SideRegion;
import org.apache.fop.fo.pagination.StaticContent;
+import org.apache.fop.fo.pagination.Title;
+import org.apache.fop.layoutmgr.inline.ContentLayoutManager;
import org.apache.fop.area.AreaTreeHandler;
import org.apache.fop.area.Block;
@@ -68,6 +70,15 @@ public interface LayoutManagerMaker {
PageSequenceLayoutManager pslm, Flow flow);
/**
+ * Make a ContentLayoutManager object.
+ * @param pslm the parent PageSequenceLayoutManager object
+ * @param title the fo:title object this CLM will process
+ * @return The created ContentLayoutManager object
+ */
+ public ContentLayoutManager makeContentLayoutManager(
+ PageSequenceLayoutManager pslm, Title title);
+
+ /**
* Make a StaticContentLayoutManager object.
* @param pslm the parent PageSequenceLayoutManager object
* @param sc the fo:static-content object this SCLM will process
diff --git a/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java b/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java
index 2663d3359..902cdec66 100644
--- a/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java
+++ b/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java
@@ -64,6 +64,7 @@ import org.apache.fop.area.AreaTreeHandler;
import org.apache.fop.layoutmgr.inline.BasicLinkLayoutManager;
import org.apache.fop.layoutmgr.inline.BidiLayoutManager;
import org.apache.fop.layoutmgr.inline.CharacterLayoutManager;
+import org.apache.fop.layoutmgr.inline.ContentLayoutManager;
import org.apache.fop.layoutmgr.inline.ExternalGraphicLayoutManager;
import org.apache.fop.layoutmgr.inline.FootnoteLayoutManager;
import org.apache.fop.layoutmgr.inline.ICLayoutManager;
@@ -175,6 +176,14 @@ public class LayoutManagerMapping implements LayoutManagerMaker {
PageSequenceLayoutManager pslm, Flow flow) {
return new FlowLayoutManager(pslm, flow);
}
+
+ /*
+ * @see org.apache.fop.layoutmgr.LayoutManagerMaker#makeContentLayoutManager(PageSequenceLayoutManager, Title)
+ */
+ public ContentLayoutManager makeContentLayoutManager(PageSequenceLayoutManager pslm,
+ Title title) {
+ return new ContentLayoutManager(pslm, title);
+ }
/*
* @see org.apache.fop.layoutmgr.LayoutManagerMaker#makeStaticContentLayoutManager(PageSequenceLayoutManager, StaticContent, Region)
diff --git a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
index 52d14ad96..c8ba02f92 100644
--- a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
@@ -128,9 +128,13 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
LineArea title = null;
if (pageSeq.getTitleFO() != null) {
- ContentLayoutManager clm = new ContentLayoutManager(pageSeq
- .getTitleFO(), this);
- title = (LineArea) clm.getParentArea(null);
+ try {
+ ContentLayoutManager clm = getLayoutManagerMaker().
+ makeContentLayoutManager(this, pageSeq.getTitleFO());
+ title = (LineArea) clm.getParentArea(null);
+ } catch (IllegalStateException e) {
+ // empty title; do nothing
+ }
}
areaTreeHandler.getAreaTreeModel().startPageSequence(title);
diff --git a/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java
index a1f6950c9..f7262cafb 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java
@@ -20,6 +20,8 @@ package org.apache.fop.layoutmgr.inline;
import org.apache.fop.apps.FOUserAgent;
import org.apache.fop.fo.Constants;
+import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.flow.RetrieveMarker;
import org.apache.fop.fo.pagination.Title;
import org.apache.fop.layoutmgr.AbstractBaseLayoutManager;
import org.apache.fop.layoutmgr.KnuthElement;
@@ -68,10 +70,14 @@ public class ContentLayoutManager extends AbstractBaseLayoutManager
}
/**
- * Constructor using a fo:title formatting object and its
- * PageSequenceLayoutManager parent.
+ * Constructor using a fo:title formatting object and its PageSequenceLayoutManager parent.
+ * throws IllegalStateException if the foTitle has no children.
+ * TODO: convert IllegalStateException to FOPException;
+ * also in makeLayoutManager and makeContentLayoutManager and callers.
+ * @param pslm the PageSequenceLayoutManager parent of this LM
+ * @param foTitle the Title FO for which this LM is made
*/
- public ContentLayoutManager(Title foTitle, PageSequenceLayoutManager pslm) {
+ public ContentLayoutManager(PageSequenceLayoutManager pslm, Title foTitle) {
// get breaks then add areas to title
this.parentLM = pslm;
holder = new LineArea();
@@ -80,10 +86,14 @@ public class ContentLayoutManager extends AbstractBaseLayoutManager
// use special layout manager to add the inline areas
// to the Title.
- InlineLayoutManager lm;
- lm = new InlineLayoutManager(foTitle);
- addChildLM(lm);
- fillArea(lm);
+ try {
+ LayoutManager lm = pslm.getLayoutManagerMaker().makeLayoutManager(foTitle);
+ addChildLM(lm);
+ fillArea(lm);
+ } catch (IllegalStateException e) {
+ log.warn("Title has no content");
+ throw e;
+ }
}
public void initialize() {