pietsch 2002/08/10 13:09:40 Modified: src/org/apache/fop/fo Tag: fop-0_20_2-maintain FONode.java FOText.java FObj.java FObjMixed.java PropertyManager.java src/org/apache/fop/fo/flow Tag: fop-0_20_2-maintain Block.java Inline.java Leader.java Marker.java Wrapper.java Log: Better fix for setting TextDecoration. Changed error handling and detection of markers which are not initial children of their parent. Revision Changes Path No revision No revision 1.21.2.6 +6 -1 xml-fop/src/org/apache/fop/fo/FONode.java Index: FONode.java =================================================================== RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/FONode.java,v retrieving revision 1.21.2.5 retrieving revision 1.21.2.6 diff -u -r1.21.2.5 -r1.21.2.6 --- FONode.java 2 Aug 2002 20:28:47 -0000 1.21.2.5 +++ FONode.java 10 Aug 2002 20:09:40 -0000 1.21.2.6 @@ -202,4 +202,9 @@ ((FONode)children.get(this.marker)).rollback(snapshot); } + + public boolean mayPrecedeMarker() { + return false; + } + } 1.24.2.4 +29 -38 xml-fop/src/org/apache/fop/fo/FOText.java Index: FOText.java =================================================================== RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/FOText.java,v retrieving revision 1.24.2.3 retrieving revision 1.24.2.4 diff -u -r1.24.2.3 -r1.24.2.4 --- FOText.java 6 Jul 2002 19:05:29 -0000 1.24.2.3 +++ FOText.java 10 Aug 2002 20:09:40 -0000 1.24.2.4 @@ -22,53 +22,38 @@ */ 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 @@ -78,10 +63,21 @@ 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) { @@ -116,17 +112,12 @@ 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) { 1.20.2.4 +9 -10 xml-fop/src/org/apache/fop/fo/FObj.java Index: FObj.java =================================================================== RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/FObj.java,v retrieving revision 1.20.2.3 retrieving revision 1.20.2.4 diff -u -r1.20.2.3 -r1.20.2.4 --- FObj.java 2 Aug 2002 20:28:47 -0000 1.20.2.3 +++ FObj.java 10 Aug 2002 20:09:40 -0000 1.20.2.4 @@ -27,10 +27,6 @@ PropertyList propertyList) throws FOPException; } -// public static Maker maker() { -// return new Maker(); -// } - // protected PropertyList properties; public PropertyList properties; protected PropertyManager propMgr; @@ -38,8 +34,6 @@ // markers private HashMap markers; -// protected String name; - protected FObj(FObj parent, PropertyList propertyList) { super(parent); this.properties = propertyList; // TO BE REMOVED!!! @@ -159,9 +153,14 @@ 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(); 1.12.2.7 +8 -10 xml-fop/src/org/apache/fop/fo/FObjMixed.java Index: FObjMixed.java =================================================================== RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/FObjMixed.java,v retrieving revision 1.12.2.6 retrieving revision 1.12.2.7 diff -u -r1.12.2.6 -r1.12.2.7 --- FObjMixed.java 2 Aug 2002 20:28:47 -0000 1.12.2.6 +++ FObjMixed.java 10 Aug 2002 20:09:40 -0000 1.12.2.7 @@ -18,16 +18,19 @@ 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) { @@ -40,12 +43,7 @@ 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); } 1.7.2.4 +4 -4 xml-fop/src/org/apache/fop/fo/PropertyManager.java Index: PropertyManager.java =================================================================== RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/PropertyManager.java,v retrieving revision 1.7.2.3 retrieving revision 1.7.2.4 diff -u -r1.7.2.3 -r1.7.2.4 --- PropertyManager.java 23 Apr 2002 22:23:39 -0000 1.7.2.3 +++ PropertyManager.java 10 Aug 2002 20:09:40 -0000 1.7.2.4 @@ -12,6 +12,7 @@ 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; @@ -300,10 +301,9 @@ 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; No revision No revision 1.41.2.8 +1 -2 xml-fop/src/org/apache/fop/fo/flow/Block.java Index: Block.java =================================================================== RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/flow/Block.java,v retrieving revision 1.41.2.7 retrieving revision 1.41.2.8 diff -u -r1.41.2.7 -r1.41.2.8 --- Block.java 2 Aug 2002 20:28:48 -0000 1.41.2.7 +++ Block.java 10 Aug 2002 20:09:40 -0000 1.41.2.8 @@ -68,7 +68,6 @@ super(parent, propertyList); this.span = this.properties.get("span").getEnum(); - ts = propMgr.getTextDecoration(parent); } public String getName() { 1.8.2.6 +1 -4 xml-fop/src/org/apache/fop/fo/flow/Inline.java Index: Inline.java =================================================================== RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/flow/Inline.java,v retrieving revision 1.8.2.5 retrieving revision 1.8.2.6 diff -u -r1.8.2.5 -r1.8.2.6 --- Inline.java 2 Aug 2002 20:28:48 -0000 1.8.2.5 +++ Inline.java 10 Aug 2002 20:09:40 -0000 1.8.2.6 @@ -69,9 +69,6 @@ // this.properties.get("visibility"); // this.properties.get("z-index"); - // Text Decoration Properties - ts = propMgr.getTextDecoration(parent); - } public String getName() { 1.13.2.3 +3 -2 xml-fop/src/org/apache/fop/fo/flow/Leader.java Index: Leader.java =================================================================== RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/flow/Leader.java,v retrieving revision 1.13.2.2 retrieving revision 1.13.2.3 diff -u -r1.13.2.2 -r1.13.2.3 --- Leader.java 24 Jul 2002 01:06:22 -0000 1.13.2.2 +++ Leader.java 10 Aug 2002 20:09:40 -0000 1.13.2.3 @@ -38,7 +38,8 @@ return new Leader.Maker(); } - public Leader(FObj parent, PropertyList propertyList) { + public Leader(FObj parent, PropertyList propertyList) + throws FOPException { super(parent, propertyList); } 1.6.2.3 +7 -9 xml-fop/src/org/apache/fop/fo/flow/Marker.java Index: Marker.java =================================================================== RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/flow/Marker.java,v retrieving revision 1.6.2.2 retrieving revision 1.6.2.3 diff -u -r1.6.2.2 -r1.6.2.3 --- Marker.java 2 Aug 2002 20:28:49 -0000 1.6.2.2 +++ Marker.java 10 Aug 2002 20:09:40 -0000 1.6.2.3 @@ -31,7 +31,8 @@ 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 @@ -41,13 +42,7 @@ // 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() { @@ -89,4 +84,7 @@ return registryArea; } + public boolean mayPrecedeMarker() { + return true; + } } 1.4.2.4 +1 -2 xml-fop/src/org/apache/fop/fo/flow/Wrapper.java Index: Wrapper.java =================================================================== RCS file: /home/cvs/xml-fop/src/org/apache/fop/fo/flow/Wrapper.java,v retrieving revision 1.4.2.3 retrieving revision 1.4.2.4 diff -u -r1.4.2.3 -r1.4.2.4 --- Wrapper.java 10 Aug 2002 18:39:08 -0000 1.4.2.3 +++ Wrapper.java 10 Aug 2002 20:09:40 -0000 1.4.2.4 @@ -42,7 +42,6 @@ throws FOPException { super(parent, propertyList); // check that this occurs inside an fo:flow - ts = propMgr.getTextDecoration(parent); } }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]