[FOray-commit] SF.net SVN: foray: [9975] trunk/foray
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2007-07-11 00:32:03
|
Revision: 9975
http://svn.sourceforge.net/foray/?rev=9975&view=rev
Author: victormote
Date: 2007-07-10 17:32:03 -0700 (Tue, 10 Jul 2007)
Log Message:
-----------
Conform to axsl (and XSL-FO 1.1) changes allowing multiple region-body instances on the same page.
Modified Paths:
--------------
trunk/foray/foray-app/src/javatest/org/foray/app/area/AbstractAreaTreeTest.java
trunk/foray/foray-areatree/src/java/org/foray/area/PageRA.java
trunk/foray/foray-areatree/src/java/org/foray/area/RegionRABody.java
trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/SimplePageMaster.java
trunk/foray/foray-pioneer/src/java/org/foray/pioneer/FootnoteBodyPL.java
trunk/foray/foray-pioneer/src/java/org/foray/pioneer/PioneerLS.java
trunk/foray/foray-render/src/java/org/foray/render/Renderer.java
trunk/foray/foray-render/src/java/org/foray/render/xml/XMLRenderer.java
Modified: trunk/foray/foray-app/src/javatest/org/foray/app/area/AbstractAreaTreeTest.java
===================================================================
--- trunk/foray/foray-app/src/javatest/org/foray/app/area/AbstractAreaTreeTest.java 2007-07-10 23:36:20 UTC (rev 9974)
+++ trunk/foray/foray-app/src/javatest/org/foray/app/area/AbstractAreaTreeTest.java 2007-07-11 00:32:03 UTC (rev 9975)
@@ -56,7 +56,8 @@
protected NormalFlowRA getFirstNormalFlowArea(final AreaTree areaTree) {
final PageCollection pageCollection = getPageCollection(areaTree, 1);
final PageRA firstPage = getPage(pageCollection, 1);
- final RegionRABody regionBody = firstPage.getRegionBody();
+ final RegionRABody regionBody = firstPage.getRegionBody(
+ "xsl-region-body");
final MainRA main = regionBody.getMainRefArea();
AreaNode node = main.getChildAt(0);
assertTrue(node instanceof SpanRA);
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/PageRA.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/PageRA.java 2007-07-10 23:36:20 UTC (rev 9974)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/PageRA.java 2007-07-11 00:32:03 UTC (rev 9975)
@@ -51,7 +51,10 @@
import org.axsl.galley.RenderVisitor;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
/**
* Area containing a page.
@@ -68,8 +71,9 @@
/** The children of this node. */
private List<AreaNode> children = new ArrayList<AreaNode>();
- /** The child region-body. */
- private RegionRABody body;
+ /** The child region-body(s). */
+ private Map<String, RegionRABody> bodies =
+ new HashMap<String, RegionRABody>();
/** The child region-before. */
private RegionRA before;
@@ -201,8 +205,8 @@
/**
* {@inheritDoc}
*/
- public RegionRABody getRegionBody() {
- return this.body;
+ public Collection<RegionRABody> getRegionBodies() {
+ return this.bodies.values();
}
/**
@@ -259,14 +263,13 @@
*/
private void createRegionBody() {
final SimplePageMaster simplePageMaster = getPageMaster();
- if (simplePageMaster.getRegionBody() == null) {
- return;
+ for (RegionBody regionBody : simplePageMaster.getRegionBodies()) {
+ final RegionRABody area = RegionRABody.makeRegionBodyArea(
+ regionBody, this);
+ this.children.add(area);
+ final String name = regionBody.traitRegionName();
+ this.bodies.put(name, area);
}
- final RegionBody regionBody = simplePageMaster.getRegionBody();
- final RegionRABody area = RegionRABody.makeRegionBodyArea(regionBody,
- this);
- this.children.add(area);
- this.body = area;
}
/**
@@ -765,7 +768,21 @@
* @return True iff this page is blank.
*/
public boolean isBlank() {
- return ! this.body.hasChildren();
+ for (RegionRABody body : this.bodies.values()) {
+ if (body.hasChildren()) {
+ return false;
+ }
+ }
+ return true;
}
+ /**
+ * Returns the region-body area for a named region.
+ * @param regionName The name of the region to be returned.
+ * @return The named region.
+ */
+ public RegionRABody getRegionBody(final String regionName) {
+ return this.bodies.get(regionName);
+ }
+
}
Modified: trunk/foray/foray-areatree/src/java/org/foray/area/RegionRABody.java
===================================================================
--- trunk/foray/foray-areatree/src/java/org/foray/area/RegionRABody.java 2007-07-10 23:36:20 UTC (rev 9974)
+++ trunk/foray/foray-areatree/src/java/org/foray/area/RegionRABody.java 2007-07-11 00:32:03 UTC (rev 9975)
@@ -267,7 +267,8 @@
public Area getOverflowArea(final Area childRequesting)
throws AreaTreeException {
final PageRA page = (PageRA) ancestorArea().getOverflowArea(this);
- return page.getRegionBody();
+ final String name = this.traitGeneratedBy().traitRegionName();
+ return page.getRegionBody(name);
}
/**
Modified: trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/SimplePageMaster.java
===================================================================
--- trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/SimplePageMaster.java 2007-07-10 23:36:20 UTC (rev 9974)
+++ trunk/foray/foray-fotree/src/java/org/foray/fotree/fo/obj/SimplePageMaster.java 2007-07-11 00:32:03 UTC (rev 9975)
@@ -35,6 +35,11 @@
import org.axsl.fo.FoTreeException;
import org.axsl.fo.ProxyFactory;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
/**
* A "simple-page-master" object in XSL-FO.
*/
@@ -59,8 +64,9 @@
/** The child regiond-end. */
private RegionEnd regionEnd;
- /** The child region-body. */
- private RegionBody regionBody;
+ /** The child region-body(s). */
+ private Map<String, RegionBody> regionBodies =
+ new HashMap<String, RegionBody>(1);
/**
* Constructor.
@@ -90,8 +96,9 @@
* {@inheritDoc}
*/
protected void validateDescendants() throws FoTreeException {
- if (getRegionBody() == null) {
- throwException(getFullName() + " must have an fo:region-body.");
+ if (this.regionBodies.size() < 1) {
+ throwException(getFullName() + " must have at least one child "
+ + "fo:region-body.");
}
}
@@ -161,10 +168,8 @@
*/
protected void addRegionBody(final RegionBody regionBody)
throws FoTreeException {
- if (this.regionBody != null) {
- duplicateRegionClass(regionBody);
- }
- this.regionBody = regionBody;
+ final String regionName = regionBody.traitRegionName();
+ this.regionBodies.put(regionName, regionBody);
}
/**
@@ -182,35 +187,42 @@
/**
* {@inheritDoc}
*/
- public org.axsl.fo.fo.RegionBody getRegionBody() {
- return this.regionBody;
+ public Collection<RegionBody> getRegionBodies() {
+ return Collections.unmodifiableCollection(this.regionBodies.values());
}
/**
* {@inheritDoc}
*/
- public org.axsl.fo.fo.RegionBefore getRegionBefore() {
+ public RegionBody getRegionBody(final String regionName) {
+ return this.regionBodies.get(regionName);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public RegionBefore getRegionBefore() {
return this.regionBefore;
}
/**
* {@inheritDoc}
*/
- public org.axsl.fo.fo.RegionAfter getRegionAfter() {
+ public RegionAfter getRegionAfter() {
return this.regionAfter;
}
/**
* {@inheritDoc}
*/
- public org.axsl.fo.fo.RegionStart getRegionStart() {
+ public RegionStart getRegionStart() {
return this.regionStart;
}
/**
* {@inheritDoc}
*/
- public org.axsl.fo.fo.RegionEnd getRegionEnd() {
+ public RegionEnd getRegionEnd() {
return this.regionEnd;
}
Modified: trunk/foray/foray-pioneer/src/java/org/foray/pioneer/FootnoteBodyPL.java
===================================================================
--- trunk/foray/foray-pioneer/src/java/org/foray/pioneer/FootnoteBodyPL.java 2007-07-10 23:36:20 UTC (rev 9974)
+++ trunk/foray/foray-pioneer/src/java/org/foray/pioneer/FootnoteBodyPL.java 2007-07-11 00:32:03 UTC (rev 9975)
@@ -92,7 +92,8 @@
*/
public boolean layoutFootnote(final PageArea p,
final GraftingPoint graftingPoint) {
- final RegionBodyRefArea bac = p.getRegionBody();
+ /* TODO: This needs to handle multiple body-regions properly. */
+ final RegionBodyRefArea bac = p.getRegionBody("xsl-region-body");
final FootnoteRefArea footArea = bac.getFootnoteRefArea();
try {
layoutFootnoteSeparator(bac, footArea);
Modified: trunk/foray/foray-pioneer/src/java/org/foray/pioneer/PioneerLS.java
===================================================================
--- trunk/foray/foray-pioneer/src/java/org/foray/pioneer/PioneerLS.java 2007-07-10 23:36:20 UTC (rev 9974)
+++ trunk/foray/foray-pioneer/src/java/org/foray/pioneer/PioneerLS.java 2007-07-11 00:32:03 UTC (rev 9975)
@@ -208,9 +208,10 @@
* Because of markers, lay out the fo:flow first, then the
* static content. This is likely also justifiable because of spec.
*/
- final RegionBodyRefArea bodyArea = currentPage.getRegionBody();
final FlowPL flowPL = (FlowPL) this.getLayoutProxy(flow);
- flowPL.layout(bodyArea, null);
+ for (RegionBodyRefArea bodyArea : currentPage.getRegionBodies()) {
+ flowPL.layout(bodyArea, null);
+ }
this.formatStaticContent(currentPage);
currentPage.layoutComplete();
status = flowPL.getStatus();
Modified: trunk/foray/foray-render/src/java/org/foray/render/Renderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/Renderer.java 2007-07-10 23:36:20 UTC (rev 9974)
+++ trunk/foray/foray-render/src/java/org/foray/render/Renderer.java 2007-07-11 00:32:03 UTC (rev 9975)
@@ -336,7 +336,9 @@
* @param page The page whose regions should be rendered.
*/
protected void renderRegions(final Page page) {
- render(page.getRegionBody());
+ for (RegionArea regionBody : page.getRegionBodies()) {
+ render(regionBody);
+ }
if (page.getRegionBefore() != null) {
render(page.getRegionBefore());
}
Modified: trunk/foray/foray-render/src/java/org/foray/render/xml/XMLRenderer.java
===================================================================
--- trunk/foray/foray-render/src/java/org/foray/render/xml/XMLRenderer.java 2007-07-10 23:36:20 UTC (rev 9974)
+++ trunk/foray/foray-render/src/java/org/foray/render/xml/XMLRenderer.java 2007-07-11 00:32:03 UTC (rev 9975)
@@ -100,7 +100,6 @@
* {@inheritDoc}
*/
public void render(final Page page) {
- final RegionArea body = page.getRegionBody();
final RegionArea before = page.getRegionBefore();
final RegionArea after = page.getRegionAfter();
final RegionArea start = page.getRegionStart();
@@ -120,8 +119,8 @@
if (end != null) {
this.render(end);
}
- if (body != null) {
- this.render(body);
+ for (RegionArea regionBody : page.getRegionBodies()) {
+ this.render(regionBody);
}
this.writeEndTag(page);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|