|
|
@@ -19,9 +19,12 @@ |
|
|
|
|
|
|
|
package org.apache.fop.fo.flow; |
|
|
|
|
|
|
|
import org.apache.fop.apps.FOPException; |
|
|
|
import org.apache.fop.fo.FONode; |
|
|
|
import org.apache.fop.fo.FObjMixed; |
|
|
|
import org.apache.fop.fo.PropertyList; |
|
|
|
import org.apache.fop.fo.ValidationException; |
|
|
|
import org.apache.fop.fo.pagination.Flow; |
|
|
|
import org.xml.sax.Locator; |
|
|
|
|
|
|
|
/** |
|
|
@@ -35,12 +38,24 @@ public class Wrapper extends FObjMixed { |
|
|
|
|
|
|
|
// used for FO validation |
|
|
|
private boolean blockOrInlineItemFound = false; |
|
|
|
private boolean isFlowChild = false; |
|
|
|
|
|
|
|
/** |
|
|
|
* @param parent FONode that is the parent of this object |
|
|
|
*/ |
|
|
|
public Wrapper(FONode parent) { |
|
|
|
super(parent); |
|
|
|
/* Check if the fo:wrapper is a child of an fo:flow or fo:static-content |
|
|
|
* (or a descendant in nested fo:wrapper sequence, the first of which |
|
|
|
* is a child of an fo:flow or fo:static-content */ |
|
|
|
FONode ancestor = this.parent; |
|
|
|
while (!(ancestor instanceof Flow) |
|
|
|
&& ancestor instanceof Wrapper) { |
|
|
|
ancestor = ancestor.getParent(); |
|
|
|
} |
|
|
|
if (ancestor instanceof Flow) { |
|
|
|
this.isFlowChild = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@@ -49,6 +64,7 @@ public class Wrapper extends FObjMixed { |
|
|
|
* Additionally (unimplemented): "An fo:wrapper that is a child of an |
|
|
|
* fo:multi-properties is only permitted to have children that would |
|
|
|
* be permitted in place of the fo:multi-properties." |
|
|
|
* |
|
|
|
*/ |
|
|
|
protected void validateChildNode(Locator loc, String nsURI, String localName) |
|
|
|
throws ValidationException { |
|
|
@@ -58,12 +74,33 @@ public class Wrapper extends FObjMixed { |
|
|
|
"(#PCDATA|%inline;|%block;)"); |
|
|
|
} |
|
|
|
} else if (isBlockOrInlineItem(nsURI, localName)) { |
|
|
|
if (isFlowChild |
|
|
|
&& isInlineItem(nsURI, localName) |
|
|
|
&& !isNeutralItem(nsURI, localName)) { |
|
|
|
invalidChildError(loc, nsURI, localName, |
|
|
|
"fo:" + localName + " not allowed as child of an fo:wrapper " |
|
|
|
+ "that is a child of an fo:flow or fo:static-content"); |
|
|
|
} |
|
|
|
blockOrInlineItemFound = true; |
|
|
|
} else { |
|
|
|
invalidChildError(loc, nsURI, localName); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
protected void addCharacters( |
|
|
|
char[] data, |
|
|
|
int start, |
|
|
|
int end, |
|
|
|
PropertyList pList, |
|
|
|
Locator locator) throws FOPException { |
|
|
|
/* Only add text if the fo:wrapper is not a child of an fo:flow |
|
|
|
* or fo:static-content */ |
|
|
|
if (!this.isFlowChild) { |
|
|
|
super.addCharacters(data, start, end, pList, locator); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
public String getLocalName() { |
|
|
|
return "wrapper"; |