((FONode)children.get(this.marker)).rollback(snapshot);
}
+
+ public boolean mayPrecedeMarker() {
+ return false;
+ }
+
}
*/
public class FOText extends FONode {
- protected char[] ca;
- protected int length;
+ private char[] ca;
- FontState fs;
- float red;
- float green;
- float blue;
- int wrapOption;
- int whiteSpaceCollapse;
- int verticalAlign;
+ private FontState fs;
+ private float red;
+ private float green;
+ private float blue;
+ private int wrapOption;
+ private int whiteSpaceCollapse;
+ private int verticalAlign;
// Textdecoration
- protected boolean underlined = false;
- protected boolean overlined = false;
- protected boolean lineThrough = false;
-
- TextState ts;
+ private TextState ts;
public FOText(StringBuffer b, FObj parent) {
super(parent);
- this.length = b.length();
- this.ca = new char[this.length];
- b.getChars(0,length,ca,0);
- }
-
- public void setUnderlined(boolean ul) {
- this.underlined = ul;
+ this.ca = new char[b.length()];
+ b.getChars(0,b.length(),ca,0);
}
- public void setOverlined(boolean ol) {
- this.overlined = ol;
+ public void setTextState(TextState ts) {
+ this.ts = ts;
}
- public void setLineThrough(boolean lt) {
- this.lineThrough = lt;
- }
-
-
public boolean willCreateArea() {
this.whiteSpaceCollapse =
this.parent.properties.get("white-space-collapse").getEnum();
if (this.whiteSpaceCollapse == WhiteSpaceCollapse.FALSE
- && length > 0) {
+ && ca.length > 0) {
return true;
}
- for (int i = 0; i < length; i++) {
+ for (int i = 0; i < ca.length; i++) {
char ch = ca[i];
if (!((ch == ' ') || (ch == '\n') || (ch == '\r')
|| (ch == '\t'))) { // whitespace
return false;
}
+ public boolean mayPrecedeMarker() {
+ for (int i = 0; i < ca.length; i++) {
+ char ch = ca[i];
+ if ((ch != ' ') || (ch != '\n') || (ch != '\r')
+ || (ch != '\t')) { // whitespace
+ return true;
+ }
+ }
+ return false;
+ }
+
public Status layout(Area area) throws FOPException {
if (!(area instanceof BlockArea)) {
log.error("text outside block area"
- + new String(ca, 0, length));
+ + new String(ca, 0, ca.length));
return new Status(Status.OK);
}
if (this.marker == START) {
this.parent.properties.get("wrap-option").getEnum();
this.whiteSpaceCollapse =
this.parent.properties.get("white-space-collapse").getEnum();
- this.ts = new TextState();
- ts.setUnderlined(underlined);
- ts.setOverlined(overlined);
- ts.setLineThrough(lineThrough);
-
this.marker = 0;
}
int orig_start = this.marker;
this.marker = addText((BlockArea)area, fs, red, green, blue,
wrapOption, this.getLinkSet(),
- whiteSpaceCollapse, ca, this.marker, length,
+ whiteSpaceCollapse, ca, this.marker, ca.length,
ts, verticalAlign);
if (this.marker == -1) {
PropertyList propertyList) throws FOPException;
}
-// public static Maker maker() {
-// return new Maker();
-// }
-
// protected PropertyList properties;
public PropertyList properties;
protected PropertyManager propMgr;
// markers
private HashMap markers;
-// protected String name;
-
protected FObj(FObj parent, PropertyList propertyList) {
super(parent);
this.properties = propertyList; // TO BE REMOVED!!!
public void addMarker(Marker marker) throws FOPException {
String mcname = marker.getMarkerClassName();
- if (!children.isEmpty()) {
- throw new FOPException("A fo:marker must be an initial child of '"
- + getName());
+ if (children != null) {
+ for (int i = 0; i < children.size(); i++) {
+ FONode child = (FONode)children.get(i);
+ if (!child.mayPrecedeMarker()) {
+ throw new FOPException("A fo:marker must be an initial child of '"
+ + getName()+"'");
+ }
+ }
}
if (markers==null) {
markers = new HashMap();
public abstract class FObjMixed extends FObj {
// Textdecoration
- protected TextState ts;
+ protected TextState textState;
private StringBuffer textBuffer;
- protected FObjMixed(FObj parent, PropertyList propertyList) {
+ protected FObjMixed(FObj parent, PropertyList propertyList)
+ throws FOPException {
super(parent, propertyList);
+ textState = propMgr.getTextDecoration(parent);
+
}
public TextState getTextState() {
- return ts;
+ return textState;
}
protected void addCharacters(char data[], int start, int length) {
private final void finalizeText() {
if (textBuffer!=null) {
FOText ft = new FOText(textBuffer, this);
- ft.setLogger(log);
- if (ts != null) {
- ft.setUnderlined(ts.getUnderlined());
- ft.setOverlined(ts.getOverlined());
- ft.setLineThrough(ts.getLineThrough());
- }
+ ft.setTextState(textState);
super.addChild(ft);
textBuffer.setLength(0);
}
import java.text.MessageFormat;
import org.apache.fop.apps.FOPException;
+import org.apache.fop.fo.flow.AbstractFlow;
import org.apache.fop.fo.properties.BreakAfter;
import org.apache.fop.fo.properties.BreakBefore;
import org.apache.fop.fo.properties.Constants;
boolean found = false;
do {
- String fname = parent.getName();
- if (fname.equals("fo:flow") || fname.equals("fo:static-content")) {
+ if (parent instanceof AbstractFlow) {
found = true;
- } else if (fname.equals("fo:block") || fname.equals("fo:inline")) {
+ } else if (parent instanceof FObjMixed) {
FObjMixed fom = (FObjMixed) parent;
tsp = fom.getTextState();
found = true;
super(parent, propertyList);
this.span = this.properties.get("span").getEnum();
- ts = propMgr.getTextDecoration(parent);
}
public String getName() {
// this.properties.get("visibility");
// this.properties.get("z-index");
- // Text Decoration Properties
- ts = propMgr.getTextDecoration(parent);
-
}
public String getName() {
return new Leader.Maker();
}
- public Leader(FObj parent, PropertyList propertyList) {
+ public Leader(FObj parent, PropertyList propertyList)
+ throws FOPException {
super(parent, propertyList);
}
return new Marker.Maker();
}
- public Marker(FObj parent, PropertyList propertyList) {
+ public Marker(FObj parent, PropertyList propertyList)
+ throws FOPException {
super(parent, propertyList);
// do check to see that 'this' is under fo:flow
// check to ensure that no other marker with same parent
// has this 'marker-class-name' is in addMarker() method
- try {
- parent.addMarker(this);
- } catch (FOPException fopex) {
- // log is null in constructor
- //log.error("marker cannot be added to '" + parent
- // + "'");
- }
+ parent.addMarker(this);
}
public String getName() {
return registryArea;
}
+ public boolean mayPrecedeMarker() {
+ return true;
+ }
}
throws FOPException {
super(parent, propertyList);
// check that this occurs inside an fo:flow
- ts = propMgr.getTextDecoration(parent);
}
}