瀏覽代碼

Minor tweaks:

* only add text to a fo:wrapper if it is not a direct flow-descendant
* error if an fo:wrapper that is a direct flow-descendant contains inline-level children


git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@603926 13f79535-47bb-0310-9956-ffa450edef68
tags/fop-0_95beta
Andreas L. Delmelle 16 年之前
父節點
當前提交
26b5548ee2
共有 1 個文件被更改,包括 37 次插入0 次删除
  1. 37
    0
      src/java/org/apache/fop/fo/flow/Wrapper.java

+ 37
- 0
src/java/org/apache/fop/fo/flow/Wrapper.java 查看文件

@@ -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";

Loading…
取消
儲存