aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--fop.bat2
-rw-r--r--src/java/org/apache/fop/fo/flow/ExternalGraphic.java2
-rw-r--r--src/java/org/apache/fop/fo/flow/Float.java2
-rw-r--r--src/java/org/apache/fop/fo/flow/Footnote.java2
-rw-r--r--src/java/org/apache/fop/fo/flow/FootnoteBody.java2
-rw-r--r--src/java/org/apache/fop/fo/flow/InstreamForeignObject.java2
-rw-r--r--src/java/org/apache/fop/fo/flow/Leader.java39
-rw-r--r--src/java/org/apache/fop/fo/flow/ListBlock.java44
-rw-r--r--src/java/org/apache/fop/fo/pagination/Flow.java2
-rw-r--r--src/java/org/apache/fop/fo/pagination/StaticContent.java2
-rw-r--r--src/java/org/apache/fop/layoutmgr/AddLMVisitor.java110
-rw-r--r--src/java/org/apache/fop/layoutmgr/LeaderLayoutManager.java140
-rw-r--r--src/java/org/apache/fop/layoutmgr/PageNumberCitationLayoutManager.java4
13 files changed, 206 insertions, 147 deletions
diff --git a/fop.bat b/fop.bat
index ac51e7af4..459d3d164 100644
--- a/fop.bat
+++ b/fop.bat
@@ -43,7 +43,7 @@ set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\xercesImpl-2.2.1.jar
set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\xalan-2.4.1.jar
set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\batik.jar
set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\avalon-framework-4.1.4.jar
-set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\commons-io-dev-20040206.jar
+set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\commons-io-1.0.jar
set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\commons-logging-1.0.3.jar
set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\jimi-1.0.jar
set LOCALCLASSPATH=%LOCALCLASSPATH%;%LIBDIR%\jai_core.jar
diff --git a/src/java/org/apache/fop/fo/flow/ExternalGraphic.java b/src/java/org/apache/fop/fo/flow/ExternalGraphic.java
index 581ab9fc2..99bb8bedb 100644
--- a/src/java/org/apache/fop/fo/flow/ExternalGraphic.java
+++ b/src/java/org/apache/fop/fo/flow/ExternalGraphic.java
@@ -72,7 +72,7 @@ public class ExternalGraphic extends FObj {
/**
* @see org.apache.fop.fo.FObj#addLayoutManager(List)
- */
+ */
public void addLayoutManager(List list) {
if (getURL() != null) {
ExternalGraphicLayoutManager lm = new ExternalGraphicLayoutManager(this);
diff --git a/src/java/org/apache/fop/fo/flow/Float.java b/src/java/org/apache/fop/fo/flow/Float.java
index 31c4b93cc..56acb0ce9 100644
--- a/src/java/org/apache/fop/fo/flow/Float.java
+++ b/src/java/org/apache/fop/fo/flow/Float.java
@@ -52,7 +52,7 @@ public class Float extends ToBeImplementedElement {
/**
* Make sure content model satisfied, if so then tell the
- * StructureRenderer that we are at the end of the flow.
+ * FOInputHandler that we are at the end of the flow.
* @see org.apache.fop.fo.FONode#end
*/
protected void endOfNode() throws SAXParseException {
diff --git a/src/java/org/apache/fop/fo/flow/Footnote.java b/src/java/org/apache/fop/fo/flow/Footnote.java
index 024c49ff1..252f31d93 100644
--- a/src/java/org/apache/fop/fo/flow/Footnote.java
+++ b/src/java/org/apache/fop/fo/flow/Footnote.java
@@ -82,7 +82,7 @@ public class Footnote extends FObj {
/**
* Make sure content model satisfied, if so then tell the
- * StructureRenderer that we are at the end of the flow.
+ * FOInputHandler that we are at the end of the flow.
* @see org.apache.fop.fo.FONode#end
*/
protected void endOfNode() throws SAXParseException {
diff --git a/src/java/org/apache/fop/fo/flow/FootnoteBody.java b/src/java/org/apache/fop/fo/flow/FootnoteBody.java
index a7f86b6f5..d8734f4d4 100644
--- a/src/java/org/apache/fop/fo/flow/FootnoteBody.java
+++ b/src/java/org/apache/fop/fo/flow/FootnoteBody.java
@@ -60,7 +60,7 @@ public class FootnoteBody extends FObj {
/**
* Make sure content model satisfied, if so then tell the
- * StructureRenderer that we are at the end of the flow.
+ * FOInputHandler that we are at the end of the flow.
* @see org.apache.fop.fo.FONode#end
*/
protected void endOfNode() throws SAXParseException {
diff --git a/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java b/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java
index 5c7264aa4..8bd5a5f49 100644
--- a/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java
+++ b/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java
@@ -66,7 +66,7 @@ public class InstreamForeignObject extends FObj {
/**
* Make sure content model satisfied, if so then tell the
- * StructureRenderer that we are at the end of the flow.
+ * FOInputHandler that we are at the end of the flow.
* @see org.apache.fop.fo.FONode#end
*/
protected void endOfNode() throws SAXParseException {
diff --git a/src/java/org/apache/fop/fo/flow/Leader.java b/src/java/org/apache/fop/fo/flow/Leader.java
index 77c8e4c3f..1aa240c6b 100644
--- a/src/java/org/apache/fop/fo/flow/Leader.java
+++ b/src/java/org/apache/fop/fo/flow/Leader.java
@@ -18,21 +18,24 @@
package org.apache.fop.fo.flow;
+// Java
+import java.util.List;
+
+// FOP
import org.apache.fop.datatypes.ColorType;
import org.apache.fop.datatypes.Length;
import org.apache.fop.fo.FONode;
-import org.apache.fop.layoutmgr.AddLMVisitor;
import org.apache.fop.fo.FObjMixed;
import org.apache.fop.fo.properties.PercentLength;
import org.apache.fop.fonts.Font;
-import org.apache.fop.fo.LMVisited;
+import org.apache.fop.layoutmgr.LeaderLayoutManager;
/**
- * Class modelling fo:leader object. See Sec. 6.6.9 of the XSL-FO Standard.
+ * Class modelling fo:leader object.
* The main property of fo:leader is leader-pattern.
* The following patterns are treated: rule, space, dots and use-content.
*/
-public class Leader extends FObjMixed implements LMVisited {
+public class Leader extends FObjMixed {
private int ruleStyle;
private int ruleThickness;
@@ -89,12 +92,14 @@ public class Leader extends FObjMixed implements LMVisited {
}
+ /**
+ * @todo check need for each of these accessors (should be LM instead?)
+ */
public int getLength(int propId, int dim) {
int length;
Length maxlength = propertyList.get(propId).getLength();
if (maxlength instanceof PercentLength) {
- length = (int)(((PercentLength)maxlength).value()
- * dim);
+ length = (int)(((PercentLength)maxlength).value() * dim);
} else {
length = maxlength.getValue();
}
@@ -121,20 +126,22 @@ public class Leader extends FObjMixed implements LMVisited {
return patternWidth;
}
- public String getName() {
- return "fo:leader";
- }
-
/**
- * This is a hook for the AddLMVisitor class to be able to access
- * this object.
- * @param aLMV the AddLMVisitor object that can access this object.
+ * @see org.apache.fop.fo.FObj#addLayoutManager(List)
*/
- public void acceptVisitor(AddLMVisitor aLMV) {
+ public void addLayoutManager(List list) {
setup();
- aLMV.serveLeader(this);
+ LeaderLayoutManager lm = new LeaderLayoutManager(this);
+ list.add(lm);
}
-
+
+ /**
+ * @see org.apache.fop.fo.FObj#getName()
+ */
+ public String getName() {
+ return "fo:leader";
+ }
+
/**
* @see org.apache.fop.fo.FObj#getNameId()
*/
diff --git a/src/java/org/apache/fop/fo/flow/ListBlock.java b/src/java/org/apache/fop/fo/flow/ListBlock.java
index e16d39ce7..86d6b70e8 100644
--- a/src/java/org/apache/fop/fo/flow/ListBlock.java
+++ b/src/java/org/apache/fop/fo/flow/ListBlock.java
@@ -23,6 +23,7 @@ import java.util.List;
// XML
import org.xml.sax.Attributes;
+import org.xml.sax.Locator;
import org.xml.sax.SAXParseException;
// FOP
@@ -30,12 +31,6 @@ import org.apache.fop.datatypes.ColorType;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
import org.apache.fop.layoutmgr.list.ListBlockLayoutManager;
-import org.apache.fop.fo.properties.CommonAccessibility;
-import org.apache.fop.fo.properties.CommonAural;
-import org.apache.fop.fo.properties.CommonBackground;
-import org.apache.fop.fo.properties.CommonBorderAndPadding;
-import org.apache.fop.fo.properties.CommonMarginBlock;
-import org.apache.fop.fo.properties.CommonRelativePosition;
/**
* Class modelling the fo:list-block object. See Sec. 6.8.2 of the XSL-FO
@@ -54,6 +49,9 @@ public class ListBlock extends FObj {
private int spaceAfter;
private int spaceBetweenListRows = 0;
private ColorType backgroundColor;
+
+ // used for child node validation
+ private boolean hasListItem = false;
/**
* @param parent FONode that is the parent of this object
@@ -87,6 +85,35 @@ public class ListBlock extends FObj {
}
/**
+ * @see org.apache.fop.fo.FONode#validateChildNode(Locator, String, String)
+ * XSL Content Model: marker* (list-item)+
+ */
+ protected void validateChildNode(Locator loc, String nsURI, String localName)
+ throws SAXParseException {
+ if (nsURI == FO_URI && localName.equals("marker")) {
+ if (hasListItem) {
+ nodesOutOfOrderError(loc, "fo:marker", "fo:list-item");
+ }
+ } else if (nsURI == FO_URI && localName.equals("list-item")) {
+ hasListItem = true;
+ } else {
+ invalidChildError(loc, nsURI, localName);
+ }
+ }
+
+ /**
+ * Make sure content model satisfied, if so then tell the
+ * FOInputHandler that we are at the end of the flow.
+ * @see org.apache.fop.fo.FONode#end
+ */
+ protected void endOfNode() throws SAXParseException {
+ if (!hasListItem) {
+ missingChildElementError("marker* (list-item)+");
+ }
+ getFOInputHandler().endList(this);
+ }
+
+ /**
* @return false (ListBlock does not generate inline areas)
*/
public boolean generatesInlineAreas() {
@@ -101,11 +128,6 @@ public class ListBlock extends FObj {
list.add(lm);
}
- protected void endOfNode() throws SAXParseException {
- super.endOfNode();
- getFOInputHandler().endList(this);
- }
-
public String getName() {
return "fo:list-block";
}
diff --git a/src/java/org/apache/fop/fo/pagination/Flow.java b/src/java/org/apache/fop/fo/pagination/Flow.java
index b659d1e5b..37233ca14 100644
--- a/src/java/org/apache/fop/fo/pagination/Flow.java
+++ b/src/java/org/apache/fop/fo/pagination/Flow.java
@@ -86,7 +86,7 @@ public class Flow extends FObj {
/**
* Make sure content model satisfied, if so then tell the
- * StructureRenderer that we are at the end of the flow.
+ * FOInputHandler that we are at the end of the flow.
* @see org.apache.fop.fo.FONode#end
*/
protected void endOfNode() throws SAXParseException {
diff --git a/src/java/org/apache/fop/fo/pagination/StaticContent.java b/src/java/org/apache/fop/fo/pagination/StaticContent.java
index 3a1b96820..405e8d014 100644
--- a/src/java/org/apache/fop/fo/pagination/StaticContent.java
+++ b/src/java/org/apache/fop/fo/pagination/StaticContent.java
@@ -55,7 +55,7 @@ public class StaticContent extends Flow {
/**
* Make sure content model satisfied, if so then tell the
- * StructureRenderer that we are at the end of the flow.
+ * FOInputHandler that we are at the end of the flow.
* @see org.apache.fop.fo.FONode#end
*/
protected void endOfNode() throws SAXParseException {
diff --git a/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java b/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java
index fd2d684fa..db84ef953 100644
--- a/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java
+++ b/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java
@@ -21,18 +21,8 @@ package org.apache.fop.layoutmgr;
import java.util.List;
import java.util.ListIterator;
-import org.apache.fop.area.Trait;
-import org.apache.fop.area.inline.FilledArea;
-import org.apache.fop.area.inline.InlineArea;
-import org.apache.fop.area.inline.Space;
-import org.apache.fop.area.inline.TextArea;
-import org.apache.fop.datatypes.Length;
-import org.apache.fop.fo.Constants;
import org.apache.fop.fo.FObj;
-import org.apache.fop.fo.flow.Inline;
-import org.apache.fop.fo.flow.Leader;
import org.apache.fop.fo.flow.Wrapper;
-import org.apache.fop.traits.MinOptMax;
import org.apache.fop.fo.LMVisited;
/**
@@ -100,104 +90,4 @@ public class AddLMVisitor {
}
}
}
-
- public void serveLeader(final Leader node) {
- LeafNodeLayoutManager lm = new LeafNodeLayoutManager(node) {
- public InlineArea get(LayoutContext context) {
- return getLeaderInlineArea(node, this);
- }
-
- protected MinOptMax getAllocationIPD(int refIPD) {
- return getLeaderAllocIPD(node, refIPD);
- }
-
- /*protected void offsetArea(LayoutContext context) {
- if(leaderPattern == LeaderPattern.DOTS) {
- curArea.setOffset(context.getBaseline());
- }
- }*/
- };
- lm.setAlignment(node.getProperty(Constants.PR_LEADER_ALIGNMENT).getEnum());
- currentLMList.add(lm);
- }
-
- public MinOptMax getLeaderAllocIPD(Leader node, int ipd) {
- // length of the leader
- int opt = node.getLength(Constants.PR_LEADER_LENGTH | Constants.CP_OPTIMUM, ipd);
- int min = node.getLength(Constants.PR_LEADER_LENGTH | Constants.CP_MINIMUM, ipd);
- int max = node.getLength(Constants.PR_LEADER_LENGTH | Constants.CP_MAXIMUM, ipd);
-
- return new MinOptMax(min, opt, max);
- }
-
- private InlineArea getLeaderInlineArea(Leader node, LayoutManager parentLM) {
- InlineArea leaderArea = null;
-
- if (node.getLeaderPattern() == Constants.LeaderPattern.RULE) {
- org.apache.fop.area.inline.Leader leader = new org.apache.fop.area.inline.Leader();
- leader.setRuleStyle(node.getRuleStyle());
- leader.setRuleThickness(node.getRuleThickness());
- leaderArea = leader;
- } else if (node.getLeaderPattern() == Constants.LeaderPattern.SPACE) {
- leaderArea = new Space();
- } else if (node.getLeaderPattern() == Constants.LeaderPattern.DOTS) {
- TextArea t = new TextArea();
- char dot = '.'; // userAgent.getLeaderDotCharacter();
-
- t.setTextArea("" + dot);
- t.addTrait(Trait.FONT_NAME, node.getFontState().getFontName());
- t.addTrait(Trait.FONT_SIZE,
- new Integer(node.getFontState().getFontSize()));
- // set offset of dot within inline parent
- t.setOffset(node.getFontState().getAscender());
- int width = node.getFontState().getCharWidth(dot);
- Space spacer = null;
- if (node.getPatternWidth() > width) {
- spacer = new Space();
- spacer.setWidth(node.getPatternWidth() - width);
- width = node.getPatternWidth();
- }
- FilledArea fa = new FilledArea();
- fa.setUnitWidth(width);
- fa.addChild(t);
- if (spacer != null) {
- fa.addChild(spacer);
- }
- fa.setHeight(node.getFontState().getAscender());
-
- leaderArea = fa;
- } else if (node.getLeaderPattern() == Constants.LeaderPattern.USECONTENT) {
- if (node.getChildNodes() == null) {
- node.getLogger().error("Leader use-content with no content");
- return null;
- }
- InlineStackingLayoutManager lm;
- lm = new InlineStackingLayoutManager(node);
- lm.setLMiter(new LMiter(lm, node.getChildNodes()));
- lm.initialize();
-
- // get breaks then add areas to FilledArea
- FilledArea fa = new FilledArea();
-
- ContentLayoutManager clm = new ContentLayoutManager(fa);
- clm.setParent(parentLM);
- clm.setUserAgent(node.getUserAgent());
- lm.setParent(clm);
-
- clm.fillArea(lm);
- int width = clm.getStackingSize();
- Space spacer = null;
- if (node.getPatternWidth() > width) {
- spacer = new Space();
- spacer.setWidth(node.getPatternWidth() - width);
- width = node.getPatternWidth();
- }
- fa.setUnitWidth(width);
- if (spacer != null) {
- fa.addChild(spacer);
- }
- leaderArea = fa;
- }
- return leaderArea;
- }
}
diff --git a/src/java/org/apache/fop/layoutmgr/LeaderLayoutManager.java b/src/java/org/apache/fop/layoutmgr/LeaderLayoutManager.java
new file mode 100644
index 000000000..e1b94425a
--- /dev/null
+++ b/src/java/org/apache/fop/layoutmgr/LeaderLayoutManager.java
@@ -0,0 +1,140 @@
+/*
+ * 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.layoutmgr;
+
+import org.apache.fop.area.Trait;
+import org.apache.fop.area.inline.FilledArea;
+import org.apache.fop.area.inline.InlineArea;
+import org.apache.fop.area.inline.Space;
+import org.apache.fop.area.inline.TextArea;
+import org.apache.fop.datatypes.Length;
+import org.apache.fop.fo.Constants;
+import org.apache.fop.fo.flow.Inline;
+import org.apache.fop.fo.flow.Leader;
+import org.apache.fop.fonts.Font;
+import org.apache.fop.traits.MinOptMax;
+
+/**
+ * LayoutManager for the fo:leader formatting object
+ */
+public class LeaderLayoutManager extends LeafNodeLayoutManager {
+
+ Leader ldrNode;
+ Font font = null;
+
+ /**
+ * Constructor
+ *
+ * @param node the formatting object that creates this area
+ * @todo better null checking of font object
+ */
+ public LeaderLayoutManager(Leader node) {
+ super(node);
+ ldrNode = node;
+ font = node.getFontState();
+ setAlignment(node.getProperty(PR_LEADER_ALIGNMENT).getEnum());
+ }
+
+ public InlineArea get(LayoutContext context) {
+ return getLeaderInlineArea();
+ }
+
+ protected MinOptMax getAllocationIPD(int refIPD) {
+ return getLeaderAllocIPD(refIPD);
+ }
+
+ private MinOptMax getLeaderAllocIPD(int ipd) {
+ // length of the leader
+ int opt = ldrNode.getLength(PR_LEADER_LENGTH | CP_OPTIMUM, ipd);
+ int min = ldrNode.getLength(PR_LEADER_LENGTH | CP_MINIMUM, ipd);
+ int max = ldrNode.getLength(PR_LEADER_LENGTH | CP_MAXIMUM, ipd);
+ return new MinOptMax(min, opt, max);
+ }
+
+ private InlineArea getLeaderInlineArea() {
+ InlineArea leaderArea = null;
+
+ if (ldrNode.getLeaderPattern() == LeaderPattern.RULE) {
+ org.apache.fop.area.inline.Leader leader =
+ new org.apache.fop.area.inline.Leader();
+ leader.setRuleStyle(ldrNode.getRuleStyle());
+ leader.setRuleThickness(ldrNode.getRuleThickness());
+ leaderArea = leader;
+ } else if (ldrNode.getLeaderPattern() == LeaderPattern.SPACE) {
+ leaderArea = new Space();
+ } else if (ldrNode.getLeaderPattern() == LeaderPattern.DOTS) {
+ TextArea t = new TextArea();
+ char dot = '.'; // userAgent.getLeaderDotCharacter();
+
+ t.setTextArea("" + dot);
+ t.addTrait(Trait.FONT_NAME, font.getFontName());
+ t.addTrait(Trait.FONT_SIZE, new Integer(font.getFontSize()));
+ // set offset of dot within inline parent
+ t.setOffset(font.getAscender());
+ int width = font.getCharWidth(dot);
+ Space spacer = null;
+ if (ldrNode.getPatternWidth() > width) {
+ spacer = new Space();
+ spacer.setWidth(ldrNode.getPatternWidth() - width);
+ width = ldrNode.getPatternWidth();
+ }
+ FilledArea fa = new FilledArea();
+ fa.setUnitWidth(width);
+ fa.addChild(t);
+ if (spacer != null) {
+ fa.addChild(spacer);
+ }
+ fa.setHeight(font.getAscender());
+
+ leaderArea = fa;
+ } else if (ldrNode.getLeaderPattern() == LeaderPattern.USECONTENT) {
+ if (ldrNode.getChildNodes() == null) {
+ ldrNode.getLogger().error("Leader use-content with no content");
+ return null;
+ }
+ InlineStackingLayoutManager lm;
+ lm = new InlineStackingLayoutManager(ldrNode);
+ lm.setLMiter(new LMiter(lm, ldrNode.getChildNodes()));
+ lm.initialize();
+
+ // get breaks then add areas to FilledArea
+ FilledArea fa = new FilledArea();
+
+ ContentLayoutManager clm = new ContentLayoutManager(fa);
+ clm.setParent(this);
+ clm.setUserAgent(ldrNode.getUserAgent());
+ lm.setParent(clm);
+
+ clm.fillArea(lm);
+ int width = clm.getStackingSize();
+ Space spacer = null;
+ if (ldrNode.getPatternWidth() > width) {
+ spacer = new Space();
+ spacer.setWidth(ldrNode.getPatternWidth() - width);
+ width = ldrNode.getPatternWidth();
+ }
+ fa.setUnitWidth(width);
+ if (spacer != null) {
+ fa.addChild(spacer);
+ }
+ leaderArea = fa;
+ }
+ return leaderArea;
+ }
+}
diff --git a/src/java/org/apache/fop/layoutmgr/PageNumberCitationLayoutManager.java b/src/java/org/apache/fop/layoutmgr/PageNumberCitationLayoutManager.java
index 06185a33a..9d1163520 100644
--- a/src/java/org/apache/fop/layoutmgr/PageNumberCitationLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/PageNumberCitationLayoutManager.java
@@ -28,7 +28,7 @@ import org.apache.fop.area.inline.TextArea;
import org.apache.fop.fonts.Font;
/**
- * LayoutManager for the fo:basic-link formatting object
+ * LayoutManager for the fo:page-number-citation formatting object
*/
public class PageNumberCitationLayoutManager extends LeafNodeLayoutManager {
@@ -39,7 +39,7 @@ public class PageNumberCitationLayoutManager extends LeafNodeLayoutManager {
* Constructor
*
* @param node the formatting object that creates this area
- * @todo better null checking font
+ * @todo better null checking of font object
*/
public PageNumberCitationLayoutManager(PageNumberCitation node) {
super(node);