[FOray-commit] SF.net SVN: foray: [7431] trunk/foray/foray-areatree/src/java/org/foray/area
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2006-06-06 22:00:04
|
Revision: 7431 Author: victormote Date: 2006-06-06 14:59:40 -0700 (Tue, 06 Jun 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7431&view=rev Log Message: ----------- 1. Implement new axsl methods related to handling of text content. 2. Use new FOTextContent to unify the FOText constructor. 3. Allow FONodes in Area Tree constructors (so that FOText items can be used). 4. If TextArea encapsulates an FOText, for the "generated by", have the FOText return its parent. Modified Paths: -------------- trunk/foray/foray-areatree/src/java/org/foray/area/AbstractInlineArea.java trunk/foray/foray-areatree/src/java/org/foray/area/Area.java trunk/foray/foray-areatree/src/java/org/foray/area/AreaFlexible.java trunk/foray/foray-areatree/src/java/org/foray/area/LineArea.java trunk/foray/foray-areatree/src/java/org/foray/area/TextArea.java Modified: trunk/foray/foray-areatree/src/java/org/foray/area/AbstractInlineArea.java =================================================================== --- trunk/foray/foray-areatree/src/java/org/foray/area/AbstractInlineArea.java 2006-06-06 20:17:53 UTC (rev 7430) +++ trunk/foray/foray-areatree/src/java/org/foray/area/AbstractInlineArea.java 2006-06-06 21:59:40 UTC (rev 7431) @@ -27,7 +27,7 @@ import org.axsl.areaR.GeneralInlineArea; import org.axsl.areaW.AreaWException; import org.axsl.common.Constants; -import org.axsl.foR.FObj; +import org.axsl.foR.FONode; /** * Common superclass for all areas generated by inline formatting objects. @@ -37,7 +37,7 @@ public abstract class AbstractInlineArea extends AreaFlexible implements GeneralInlineArea { - public AbstractInlineArea(FObj generatedBy, Area parentArea) { + public AbstractInlineArea(FONode generatedBy, Area parentArea) { super(generatedBy, parentArea); } Modified: trunk/foray/foray-areatree/src/java/org/foray/area/Area.java =================================================================== --- trunk/foray/foray-areatree/src/java/org/foray/area/Area.java 2006-06-06 20:17:53 UTC (rev 7430) +++ trunk/foray/foray-areatree/src/java/org/foray/area/Area.java 2006-06-06 21:59:40 UTC (rev 7431) @@ -30,7 +30,7 @@ import org.axsl.areaW.NormalBlockArea; import org.axsl.areaW.TableArea; import org.axsl.common.Constants; -import org.axsl.foR.FObj; +import org.axsl.foR.FONode; import org.axsl.foR.WritingMode; import org.axsl.foR.fo.BasicLink; import org.axsl.foR.fo.Block; @@ -53,7 +53,7 @@ * @param generatedBy * @param parentArea */ - public Area(FObj generatedBy, AreaNode parentArea) { + public Area(FONode generatedBy, AreaNode parentArea) { super(generatedBy, parentArea); } Modified: trunk/foray/foray-areatree/src/java/org/foray/area/AreaFlexible.java =================================================================== --- trunk/foray/foray-areatree/src/java/org/foray/area/AreaFlexible.java 2006-06-06 20:17:53 UTC (rev 7430) +++ trunk/foray/foray-areatree/src/java/org/foray/area/AreaFlexible.java 2006-06-06 21:59:40 UTC (rev 7431) @@ -25,7 +25,7 @@ package org.foray.area; import org.axsl.common.Constants; -import org.axsl.foR.FObj; +import org.axsl.foR.FONode; import java.util.List; @@ -51,7 +51,7 @@ */ private int anteriorSpace; - public AreaFlexible(FObj generatedBy, AreaNode parentArea) { + public AreaFlexible(FONode generatedBy, AreaNode parentArea) { super(generatedBy, parentArea); initializeProgressionDimension(); initializeAnteriorSpace(); Modified: trunk/foray/foray-areatree/src/java/org/foray/area/LineArea.java =================================================================== --- trunk/foray/foray-areatree/src/java/org/foray/area/LineArea.java 2006-06-06 20:17:53 UTC (rev 7430) +++ trunk/foray/foray-areatree/src/java/org/foray/area/LineArea.java 2006-06-06 21:59:40 UTC (rev 7431) @@ -28,9 +28,8 @@ import org.axsl.common.Constants; import org.axsl.common.ConstantsAreaTree; import org.axsl.foR.FOText; +import org.axsl.foR.FOTextContent; import org.axsl.foR.FObj; -import org.axsl.foR.FObjMixed; -import org.axsl.foR.fo.Character; import org.axsl.foR.fo.ExternalGraphic; import org.axsl.foR.fo.InstreamForeignObject; import org.axsl.foR.fo.Leader; @@ -804,7 +803,7 @@ return new PageNumberCitationArea(citation, parentArea, ipd); } - public static org.axsl.areaW.TextArea makeTextArea(FOText foText, + public static org.axsl.areaW.TextArea makeTextArea(FOTextContent foText, Area parentArea, int ipd, int startOffset, int sizeInChars, boolean hasDiscretionaryHyphen, boolean hasFauxSmallCaps, boolean isLastItemOnLine) { @@ -828,20 +827,8 @@ } /* Go ahead and create*/ - FObj parent = foText.parentFO(); - if (parent instanceof FObjMixed) { - FObjMixed mixed = (FObjMixed) foText.parentFO(); - int sequence = mixed.getChildren().indexOf(foText); - return new TextArea(mixed, parentArea, sequence, - startOffset, sizeInChars, ipd, - hasDiscretionaryHyphen, - hasFauxSmallCaps); - } - if (parent instanceof Character) { - return new TextArea((Character) parent, parentArea, ipd, - hasDiscretionaryHyphen, hasFauxSmallCaps); - } - return null; + return new TextArea(foText, parentArea, startOffset, sizeInChars, ipd, + hasDiscretionaryHyphen, hasFauxSmallCaps); } public org.axsl.areaW.ForeignObjectArea makeForeignObjectArea( Modified: trunk/foray/foray-areatree/src/java/org/foray/area/TextArea.java =================================================================== --- trunk/foray/foray-areatree/src/java/org/foray/area/TextArea.java 2006-06-06 20:17:53 UTC (rev 7430) +++ trunk/foray/foray-areatree/src/java/org/foray/area/TextArea.java 2006-06-06 21:59:40 UTC (rev 7431) @@ -28,8 +28,9 @@ import org.axsl.common.Constants; import org.axsl.common.ConstantsAreaTree; -import org.axsl.foR.FObjMixed; -import org.axsl.foR.fo.Character; +import org.axsl.foR.FONode; +import org.axsl.foR.FOTextContent; +import org.axsl.foR.FObj; import org.axsl.fontR.Font; import org.axsl.fontR.FontUse; @@ -55,17 +56,6 @@ implements org.axsl.areaR.TextArea, org.axsl.areaW.TextArea { /** - * Index into the Collection of the children of the generated-by that - * matches the FOText node that is the real generated-by for this - * TextSegment. For example, if the parent FObjMixed has 3 FO children: - * 1. a chunk of text, 2. an <fo:inline> element, and 3. another - * chunk of text, and the third item of these contains the text that is the - * backing for this TextSegment, then backingSequence should be 2 (the - * third ordinal item). - */ - int backingSequence; - - /** * The index of the first character in the char array that is the backing * for the text in this object. For example, if the text in this TextSegment * starts at array element 5 and has a size of 14, backingOffset will be 5. @@ -108,12 +98,11 @@ */ boolean hasFauxSmallCaps = false; - public TextArea(FObjMixed generatedBy, Area parentArea, - int backingSequence, int backingOffset, int backingSize, + public TextArea(FOTextContent generatedBy, Area parentArea, + int backingOffset, int backingSize, int progressionDimensionUsed, boolean hasDiscretionaryHyphen, boolean hasFauxSmallCaps) { super(generatedBy, parentArea); - this.backingSequence = backingSequence; this.backingOffset = backingOffset; this.backingSize = backingSize; this.resolvedLetterSpacing = parentArea.traitLetterSpacingOpt(); @@ -123,18 +112,6 @@ setProgressionDimension(progressionDimensionUsed); } - public TextArea(Character generatedBy, Area parentArea, - int progressionDimensionUsed, boolean hasDiscretionaryHyphen, - boolean hasFauxSmallCaps) { - super(generatedBy, parentArea); - this.backingSize = 1; - this.resolvedLetterSpacing = 0; - this.resolvedWordSpacing = 0; - this.hasDiscretionaryHyphen = hasDiscretionaryHyphen; - this.hasFauxSmallCaps = hasFauxSmallCaps; - setProgressionDimension(progressionDimensionUsed); - } - /** * <p>Computes and returns the text that should actually be used in the * output document. Note that it may be different from the char array that @@ -192,16 +169,17 @@ return returnChars; } + public FOTextContent getTextContent() { + FONode foNode = this.generatedBy.getFONode(); + /* Cast verified at construction. */ + return (FOTextContent) foNode; + } + /** * @return The raw text from the FO Tree. */ protected char[] getRawText() { - if (traitGeneratedBy() instanceof Character) { - return new char[] {traitGeneratedBy().traitCharacter()}; - } - // Cast verified at construction. - FObjMixed gb = (FObjMixed) traitGeneratedBy(); - return gb.getText(backingSequence); + return this.getTextContent().getAreaTreeText(); } public byte getAreaType() { @@ -550,4 +528,18 @@ return "text"; } + /** + * Override the standard method so that, if this is not an FObj, an ancestor + * FObj can be used instead. + */ + public FObj traitGeneratedBy() { + FONode generatedBy = this.generatedBy.getFONode(); + if (generatedBy instanceof FObj) { + /* If generated by Character. */ + return (FObj) generatedBy; + } + /* If generated by FOText. */ + return generatedBy.parentFO(); + } + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |