aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/java/org/apache/fop/area/PageViewport.java16
-rw-r--r--src/java/org/apache/fop/area/RegionReference.java10
-rw-r--r--src/java/org/apache/fop/layoutmgr/LayoutManagerMaker.java13
-rw-r--r--src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java16
-rw-r--r--src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java10
-rw-r--r--src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java29
6 files changed, 48 insertions, 46 deletions
diff --git a/src/java/org/apache/fop/area/PageViewport.java b/src/java/org/apache/fop/area/PageViewport.java
index c27f24b43..783461cb4 100644
--- a/src/java/org/apache/fop/area/PageViewport.java
+++ b/src/java/org/apache/fop/area/PageViewport.java
@@ -33,6 +33,7 @@ import org.apache.commons.logging.LogFactory;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.pagination.SimplePageMaster;
+import org.apache.fop.layoutmgr.StaticContentLayoutManager;
/**
* Page viewport that specifies the viewport area and holds the page contents.
@@ -470,5 +471,18 @@ public class PageViewport implements Resolvable, Cloneable {
*/
public NormalFlow moveToNextFlow() {
return getCurrentSpan().moveToNextFlow();
- }
+ }
+
+ /**
+ * Convenience method to return a given region-reference-area,
+ * keyed by the Constants class identifier for the corresponding
+ * formatting object (ie. Constants.FO_REGION_BODY, FO_REGION_START,
+ * etc.)
+ *
+ * @param id the Constants class identifier for the region.
+ * @return the corresponding region-reference-area for this page.
+ */
+ public RegionReference getRegionReference(int id) {
+ return getPage().getRegionViewport(id).getRegionReference();
+ }
} \ No newline at end of file
diff --git a/src/java/org/apache/fop/area/RegionReference.java b/src/java/org/apache/fop/area/RegionReference.java
index b9f256517..86e8dd186 100644
--- a/src/java/org/apache/fop/area/RegionReference.java
+++ b/src/java/org/apache/fop/area/RegionReference.java
@@ -98,16 +98,6 @@ public class RegionReference extends Area implements Cloneable {
}
/**
- * Return the Region FO which provides the
- * traits for this region.
- *
- * @return the region formatting object
- */
- public Region getRegionFO() {
- return regionFO;
- }
-
- /**
* Add a block area to this region reference area.
*
* @param block the block area to add
diff --git a/src/java/org/apache/fop/layoutmgr/LayoutManagerMaker.java b/src/java/org/apache/fop/layoutmgr/LayoutManagerMaker.java
index b0d723444..38ddc1e57 100644
--- a/src/java/org/apache/fop/layoutmgr/LayoutManagerMaker.java
+++ b/src/java/org/apache/fop/layoutmgr/LayoutManagerMaker.java
@@ -20,6 +20,8 @@ package org.apache.fop.layoutmgr;
import java.util.List;
import org.apache.fop.fo.FONode;
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.area.AreaTreeHandler;
@@ -55,5 +57,16 @@ public interface LayoutManagerMaker {
public PageSequenceLayoutManager makePageSequenceLayoutManager(
AreaTreeHandler ath, PageSequence ps);
+ /**
+ * Make a StaticContentLayoutManager object.
+ * @param pslm the parent PageSequenceLayoutManager object
+ * @param sc the fo:static-content object this SCLM will process
+ * @param reg the side region indicating where the static content
+ * needs to be processed.
+ * @return The created StaticContentLayoutManager object
+ */
+ public StaticContentLayoutManager makeStaticContentLayoutManager(
+ PageSequenceLayoutManager pslm, StaticContent sc, SideRegion reg);
+
}
diff --git a/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java b/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java
index 4b235c09d..d47cd059f 100644
--- a/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java
+++ b/src/java/org/apache/fop/layoutmgr/LayoutManagerMapping.java
@@ -56,6 +56,7 @@ import org.apache.fop.fo.flow.TableRow;
import org.apache.fop.fo.flow.Wrapper;
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.area.AreaTreeHandler;
@@ -118,7 +119,6 @@ public class LayoutManagerMapping implements LayoutManagerMaker {
makers.put(TableFooter.class, new /*TableBodyLayoutManager*/Maker());
makers.put(TableHeader.class, new /*TableBodyLayoutManager*/Maker());
makers.put(Flow.class, new FlowLayoutManagerMaker());
- makers.put(StaticContent.class, new StaticContentLayoutManagerMaker());
makers.put(Wrapper.class, new WrapperLayoutManagerMaker());
makers.put(Title.class, new InlineLayoutManagerMaker());
}
@@ -158,6 +158,14 @@ public class LayoutManagerMapping implements LayoutManagerMaker {
return new PageSequenceLayoutManager(ath, ps);
}
+ /*
+ * @see org.apache.fop.layoutmgr.LayoutManagerMaker#makeStaticContentLayoutManager(org.apache.fop.layoutmgr.PageSequenceLayoutManager, org.apache.fop.fo.pagination.StaticContent, org.apache.fop.fo.pagination.Region)
+ */
+ public StaticContentLayoutManager makeStaticContentLayoutManager(
+ PageSequenceLayoutManager pslm, StaticContent sc, SideRegion reg) {
+ return new StaticContentLayoutManager(pslm, sc, reg);
+ }
+
public static class Maker {
public void make(FONode node, List lms) {
// no layout manager
@@ -389,12 +397,6 @@ public class LayoutManagerMapping implements LayoutManagerMaker {
}
}
- public static class StaticContentLayoutManagerMaker extends Maker {
- public void make(FONode node, List lms) {
- lms.add(new StaticContentLayoutManager((StaticContent) node));
- }
- }
-
public class WrapperLayoutManagerMaker extends Maker {
public void make(FONode node, List lms) {
Iterator baseIter;
diff --git a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
index 7b1cd4e01..4983027cc 100644
--- a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
@@ -24,7 +24,6 @@ import org.apache.fop.area.AreaTreeHandler;
import org.apache.fop.area.AreaTreeModel;
import org.apache.fop.area.PageViewport;
import org.apache.fop.area.LineArea;
-import org.apache.fop.area.RegionViewport;
import org.apache.fop.area.Resolvable;
import org.apache.fop.datatypes.PercentBase;
@@ -426,12 +425,9 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager {
return;
}
- RegionViewport rv = curPV.getPage().getRegionViewport(regionID);
- StaticContentLayoutManager lm;
- lm = (StaticContentLayoutManager)
- getLayoutManagerMaker().makeLayoutManager(sc);
- lm.setTargetRegion(rv.getRegionReference());
- lm.setParent(this);
+ StaticContentLayoutManager lm = (StaticContentLayoutManager)
+ getLayoutManagerMaker().makeStaticContentLayoutManager(
+ this, sc, reg);
lm.doLayout();
lm.reset(null);
}
diff --git a/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java
index 8129473d0..828f2bf6a 100644
--- a/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java
@@ -22,7 +22,6 @@ import org.apache.fop.area.RegionReference;
import org.apache.fop.area.Area;
import org.apache.fop.area.Block;
import org.apache.fop.datatypes.PercentBase;
-import org.apache.fop.fo.pagination.Region;
import org.apache.fop.fo.pagination.SideRegion;
import org.apache.fop.fo.pagination.StaticContent;
import org.apache.fop.traits.MinOptMax;
@@ -41,28 +40,17 @@ import java.util.ListIterator;
public class StaticContentLayoutManager extends BlockStackingLayoutManager {
private RegionReference targetRegion;
private List blockBreaks = new ArrayList();
+ private SideRegion regionFO;
- public StaticContentLayoutManager(StaticContent node) {
+ public StaticContentLayoutManager(PageSequenceLayoutManager pslm,
+ StaticContent node, SideRegion reg) {
super(node);
+ setParent(pslm);
+ regionFO = reg;
+ targetRegion = getCurrentPV().getRegionReference(regionFO.getNameId());
}
/**
- * Sets the region reference
- * @param region region reference
- */
- public void setTargetRegion(RegionReference targetRegion) {
- this.targetRegion = targetRegion;
- }
-
- /**
- * @return the region-reference-area that this
- * static content is directed to.
- */
- public RegionReference getTargetRegion() {
- return targetRegion;
- }
-
- /**
* @see org.apache.fop.layoutmgr.LayoutManager#getNextKnuthElements(org.apache.fop.layoutmgr.LayoutContext, int)
*/
public LinkedList getNextKnuthElements(LayoutContext context, int alignment) {
@@ -229,12 +217,11 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager {
}
public void doLayout() {
- Region region = targetRegion.getRegionFO();
StaticContentBreaker breaker = new StaticContentBreaker(
- this, targetRegion.getIPD(), region.getDisplayAlign());
+ this, targetRegion.getIPD(), regionFO.getDisplayAlign());
breaker.doLayout(targetRegion.getBPD());
if (breaker.isOverflow()) {
- if (region.getOverflow() == EN_ERROR_IF_OVERFLOW) {
+ if (regionFO.getOverflow() == EN_ERROR_IF_OVERFLOW) {
//TODO throw layout exception
}
log.warn("static-content overflows the available area.");