aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop/fo/flow
diff options
context:
space:
mode:
authorGlenn Adams <gadams@apache.org>2012-02-26 02:29:01 +0000
committerGlenn Adams <gadams@apache.org>2012-02-26 02:29:01 +0000
commitd6d8e57b17eb2e36631115517afa003ad3afa1a1 (patch)
treebf355ee4643080bf13b8f9fa5a1b14002e968561 /src/java/org/apache/fop/fo/flow
parentfa6dc48793a4eb7476282141c1314f1198371a67 (diff)
downloadxmlgraphics-fop-d6d8e57b17eb2e36631115517afa003ad3afa1a1.tar.gz
xmlgraphics-fop-d6d8e57b17eb2e36631115517afa003ad3afa1a1.zip
apply complex scripts patch
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1293736 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/fo/flow')
-rw-r--r--src/java/org/apache/fop/fo/flow/AbstractGraphics.java20
-rw-r--r--src/java/org/apache/fop/fo/flow/AbstractPageNumberCitation.java16
-rw-r--r--src/java/org/apache/fop/fo/flow/BidiOverride.java138
-rw-r--r--src/java/org/apache/fop/fo/flow/Block.java64
-rw-r--r--src/java/org/apache/fop/fo/flow/BlockContainer.java85
-rw-r--r--src/java/org/apache/fop/fo/flow/Character.java15
-rw-r--r--src/java/org/apache/fop/fo/flow/InlineContainer.java89
-rw-r--r--src/java/org/apache/fop/fo/flow/InlineLevel.java17
-rw-r--r--src/java/org/apache/fop/fo/flow/Leader.java43
-rw-r--r--src/java/org/apache/fop/fo/flow/ListItem.java17
-rw-r--r--src/java/org/apache/fop/fo/flow/PageNumber.java6
-rw-r--r--src/java/org/apache/fop/fo/flow/Wrapper.java6
-rw-r--r--src/java/org/apache/fop/fo/flow/table/Table.java34
13 files changed, 387 insertions, 163 deletions
diff --git a/src/java/org/apache/fop/fo/flow/AbstractGraphics.java b/src/java/org/apache/fop/fo/flow/AbstractGraphics.java
index d5fe2b500..3d93eaa8f 100644
--- a/src/java/org/apache/fop/fo/flow/AbstractGraphics.java
+++ b/src/java/org/apache/fop/fo/flow/AbstractGraphics.java
@@ -19,8 +19,11 @@
package org.apache.fop.fo.flow;
+import java.util.Stack;
+
import org.apache.fop.accessibility.StructureTreeElement;
import org.apache.fop.apps.FOPException;
+import org.apache.fop.complexscripts.bidi.DelimitedTextRange;
import org.apache.fop.datatypes.Length;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
@@ -33,6 +36,7 @@ import org.apache.fop.fo.properties.KeepProperty;
import org.apache.fop.fo.properties.LengthRangeProperty;
import org.apache.fop.fo.properties.SpaceProperty;
import org.apache.fop.fo.properties.StructureTreeElementHolder;
+import org.apache.fop.util.CharUtilities;
/**
* Common base class for the <a href="http://www.w3.org/TR/xsl/#fo_instream-foreign-object">
@@ -77,8 +81,6 @@ public abstract class AbstractGraphics extends FObj
// private int scalingMethod;
// End of property values
-
-
/**
* constructs an instream-foreign-object object (called by Maker).
*
@@ -250,4 +252,18 @@ public abstract class AbstractGraphics extends FObj
/** @return the graphic's intrinsic alignment-adjust */
public abstract Length getIntrinsicAlignmentAdjust();
+
+ @Override
+ public boolean isDelimitedTextRangeBoundary ( int boundary ) {
+ return false;
+ }
+
+ @Override
+ protected Stack collectDelimitedTextRanges ( Stack ranges, DelimitedTextRange currentRange ) {
+ if ( currentRange != null ) {
+ currentRange.append ( CharUtilities.OBJECT_REPLACEMENT_CHARACTER, this );
+ }
+ return ranges;
+ }
+
}
diff --git a/src/java/org/apache/fop/fo/flow/AbstractPageNumberCitation.java b/src/java/org/apache/fop/fo/flow/AbstractPageNumberCitation.java
index 5a6893b55..ec3891632 100644
--- a/src/java/org/apache/fop/fo/flow/AbstractPageNumberCitation.java
+++ b/src/java/org/apache/fop/fo/flow/AbstractPageNumberCitation.java
@@ -20,12 +20,14 @@
package org.apache.fop.fo.flow;
import java.awt.Color;
+import java.util.Stack;
import org.xml.sax.Attributes;
import org.xml.sax.Locator;
import org.apache.fop.accessibility.StructureTreeElement;
import org.apache.fop.apps.FOPException;
+import org.apache.fop.complexscripts.bidi.DelimitedTextRange;
import org.apache.fop.datatypes.Length;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.FONode;
@@ -39,6 +41,7 @@ import org.apache.fop.fo.properties.CommonFont;
import org.apache.fop.fo.properties.CommonTextDecoration;
import org.apache.fop.fo.properties.SpaceProperty;
import org.apache.fop.fo.properties.StructureTreeElementHolder;
+import org.apache.fop.util.CharUtilities;
/**
* Common base class for the <a href="http://www.w3.org/TR/xsl/#fo_page-number-citation">
@@ -197,4 +200,17 @@ public abstract class AbstractPageNumberCitation extends FObj
return refId;
}
+ @Override
+ public boolean isDelimitedTextRangeBoundary ( int boundary ) {
+ return false;
+ }
+
+ @Override
+ protected Stack collectDelimitedTextRanges ( Stack ranges, DelimitedTextRange currentRange ) {
+ if ( currentRange != null ) {
+ currentRange.append ( CharUtilities.OBJECT_REPLACEMENT_CHARACTER, this );
+ }
+ return ranges;
+ }
+
}
diff --git a/src/java/org/apache/fop/fo/flow/BidiOverride.java b/src/java/org/apache/fop/fo/flow/BidiOverride.java
index 6e4a74379..d38df90c7 100644
--- a/src/java/org/apache/fop/fo/flow/BidiOverride.java
+++ b/src/java/org/apache/fop/fo/flow/BidiOverride.java
@@ -19,38 +19,37 @@
package org.apache.fop.fo.flow;
+import java.util.Iterator;
+import java.util.Stack;
+
import org.xml.sax.Locator;
import org.apache.fop.apps.FOPException;
+import org.apache.fop.complexscripts.bidi.DelimitedTextRange;
+import org.apache.fop.datatypes.Length;
+import org.apache.fop.fo.Constants;
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.properties.Property;
import org.apache.fop.fo.properties.SpaceProperty;
+import org.apache.fop.util.CharUtilities;
/**
* Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_bidi-override">
* <code>fo:bidi-override</code></a> object.
*/
-public class BidiOverride extends FObjMixed {
-
- // used for FO validation
- private boolean blockOrInlineItemFound = false;
- private boolean canHaveBlockLevelChildren = true;
- // The value of properties relevant for fo:bidi-override.
- // private ToBeImplementedProperty prDirection;
- // private ToBeImplementedProperty prLetterSpacing;
- private SpaceProperty lineHeight;
- // private ToBeImplementedProperty prScoreSpaces;
- // private ToBeImplementedProperty prUnicodeBidi;
-
- // Unused but valid items, commented out for performance:
- // private CommonAural commonAural;
- // private CommonFont commonFont;
- // private CommonRelativePosition commonRelativePosition;
- // private Color prColor;
- // private SpaceProperty prWordSpacing;
- // End of property values
+public class BidiOverride extends Inline {
+
+ // The value of FO traits (refined properties) that apply to fo:bidi-override
+ // (that are not implemented by InlineLevel).
+ private Property letterSpacing;
+ private Property wordSpacing;
+ private int direction;
+ private int unicodeBidi;
+ // private int scoreSpaces;
+ // End of trait values
/**
* Base constructor
@@ -59,66 +58,35 @@ public class BidiOverride extends FObjMixed {
*/
public BidiOverride(FONode parent) {
super(parent);
-
- /* Check to see if this node can have block-level children.
- * See validateChildNode() below.
- */
- int lvlLeader = findAncestor(FO_LEADER);
- int lvlInCntr = findAncestor(FO_INLINE_CONTAINER);
- int lvlInline = findAncestor(FO_INLINE);
- int lvlFootnote = findAncestor(FO_FOOTNOTE);
-
- if (lvlLeader > 0) {
- if (lvlInCntr < 0 || (lvlInCntr > 0 && lvlInCntr > lvlLeader)) {
- canHaveBlockLevelChildren = false;
- }
- } else if (lvlInline > 0 && lvlFootnote == (lvlInline + 1)) {
- if (lvlInCntr < 0 || (lvlInCntr > 0 && lvlInCntr > lvlInline)) {
- canHaveBlockLevelChildren = false;
- }
- }
-
}
/** {@inheritDoc} */
public void bind(PropertyList pList) throws FOPException {
- // prDirection = pList.get(PR_DIRECTION);
- // prLetterSpacing = pList.get(PR_LETTER_SPACING);
- lineHeight = pList.get(PR_LINE_HEIGHT).getSpace();
- // prScoreSpaces = pList.get(PR_SCORE_SPACES);
- // prUnicodeBidi = pList.get(PR_UNICODE_BIDI);
+ super.bind(pList);
+ letterSpacing = pList.get(PR_LETTER_SPACING);
+ wordSpacing = pList.get(PR_WORD_SPACING);
+ direction = pList.get(PR_DIRECTION).getEnum();
+ unicodeBidi = pList.get(PR_UNICODE_BIDI).getEnum();
}
- /**
- * {@inheritDoc}
- * <br>XSL Content Model: marker* (#PCDATA|%inline;|%block;)*
- * <br><i>Additionally: "An fo:bidi-override that is a descendant of an fo:leader
- * or of the fo:inline child of an fo:footnote may not have block-level
- * children, unless it has a nearer ancestor that is an
- * fo:inline-container."</i>
- */
- protected void validateChildNode(Locator loc, String nsURI, String localName)
- throws ValidationException {
- if (FO_URI.equals(nsURI)) {
- if (localName.equals("marker")) {
- if (blockOrInlineItemFound) {
- nodesOutOfOrderError(loc, "fo:marker",
- "(#PCDATA|%inline;|%block;)");
- }
- } else if (!isBlockOrInlineItem(nsURI, localName)) {
- invalidChildError(loc, nsURI, localName);
- } else if (!canHaveBlockLevelChildren && isBlockItem(nsURI, localName)) {
- invalidChildError(loc, getParent().getName(), nsURI, getName(),
- "rule.bidiOverrideContent");
- } else {
- blockOrInlineItemFound = true;
- }
- }
+ /** @return the "letter-spacing" trait */
+ public Property getLetterSpacing() {
+ return letterSpacing;
+ }
+
+ /** @return the "word-spacing" trait */
+ public Property getWordSpacing() {
+ return wordSpacing;
}
- /** @return the "line-height" property */
- public SpaceProperty getLineHeight() {
- return lineHeight;
+ /** @return the "direction" trait */
+ public int getDirection() {
+ return direction;
+ }
+
+ /** @return the "unicodeBidi" trait */
+ public int getUnicodeBidi() {
+ return unicodeBidi;
}
/** {@inheritDoc} */
@@ -133,4 +101,32 @@ public class BidiOverride extends FObjMixed {
public int getNameId() {
return FO_BIDI_OVERRIDE;
}
+
+ @Override
+ protected Stack collectDelimitedTextRanges ( Stack ranges, DelimitedTextRange currentRange ) {
+ char pfx = 0;
+ char sfx = 0;
+ int unicodeBidi = getUnicodeBidi();
+ int direction = getDirection();
+ if ( unicodeBidi == Constants.EN_BIDI_OVERRIDE ) {
+ pfx = ( direction == Constants.EN_RTL ) ? CharUtilities.RLO : CharUtilities.LRO;
+ sfx = CharUtilities.PDF;
+ } else if ( unicodeBidi == Constants.EN_EMBED ) {
+ pfx = ( direction == Constants.EN_RTL ) ? CharUtilities.RLE : CharUtilities.LRE;
+ sfx = CharUtilities.PDF;
+ }
+ if ( currentRange != null ) {
+ if ( pfx != 0 ) {
+ currentRange.append ( pfx, this );
+ }
+ for ( Iterator it = getChildNodes(); ( it != null ) && it.hasNext();) {
+ ranges = ( (FONode) it.next() ).collectDelimitedTextRanges ( ranges );
+ }
+ if ( sfx != 0 ) {
+ currentRange.append ( sfx, this );
+ }
+ }
+ return ranges;
+ }
+
}
diff --git a/src/java/org/apache/fop/fo/flow/Block.java b/src/java/org/apache/fop/fo/flow/Block.java
index 84f1abc1b..d93821ca6 100644
--- a/src/java/org/apache/fop/fo/flow/Block.java
+++ b/src/java/org/apache/fop/fo/flow/Block.java
@@ -54,7 +54,7 @@ public class Block extends FObjMixed implements BreakPropertySet,
private boolean blockOrInlineItemFound = false;
private boolean initialPropertySetFound = false;
- // The value of properties relevant for fo:block.
+ // The value of FO traits (refined properties) that apply to fo:block.
private CommonAccessibility commonAccessibility;
private CommonBorderPaddingBackground commonBorderPaddingBackground;
private CommonFont commonFont;
@@ -91,7 +91,7 @@ public class Block extends FObjMixed implements BreakPropertySet,
// private Length textDepth;
// private Length textAltitude;
// private int visibility;
- // End of property values
+ // End of FO trait values
/**
* Base constructor
@@ -177,87 +177,87 @@ public class Block extends FObjMixed implements BreakPropertySet,
return commonHyphenation;
}
- /** @return the "break-after" property. */
+ /** @return the "break-after" trait. */
public int getBreakAfter() {
return breakAfter;
}
- /** @return the "break-before" property. */
+ /** @return the "break-before" trait. */
public int getBreakBefore() {
return breakBefore;
}
- /** @return the "hyphenation-ladder-count" property. */
+ /** @return the "hyphenation-ladder-count" trait. */
public Numeric getHyphenationLadderCount() {
return hyphenationLadderCount;
}
- /** @return the "keep-with-next" property. */
+ /** @return the "keep-with-next" trait. */
public KeepProperty getKeepWithNext() {
return keepWithNext;
}
- /** @return the "keep-with-previous" property. */
+ /** @return the "keep-with-previous" trait. */
public KeepProperty getKeepWithPrevious() {
return keepWithPrevious;
}
- /** @return the "keep-together" property. */
+ /** @return the "keep-together" trait. */
public KeepProperty getKeepTogether() {
return keepTogether;
}
- /** @return the "orphans" property. */
+ /** @return the "orphans" trait. */
public int getOrphans() {
return orphans.getValue();
}
- /** @return the "widows" property. */
+ /** @return the "widows" trait. */
public int getWidows() {
return widows.getValue();
}
- /** @return the "line-stacking-strategy" property. */
+ /** @return the "line-stacking-strategy" trait. */
public int getLineStackingStrategy() {
return lineStackingStrategy;
}
- /** @return the "color" property */
+ /** @return the "color" trait */
public Color getColor() {
return color;
}
- /** @return the "line-height" property */
+ /** @return the "line-height" trait */
public SpaceProperty getLineHeight() {
return lineHeight;
}
- /** @return the "span" property */
+ /** @return the "span" trait */
public int getSpan() {
return this.span;
}
- /** @return the "text-align" property */
+ /** @return the "text-align" trait */
public int getTextAlign() {
return textAlign;
}
- /** @return the "text-align-last" property */
+ /** @return the "text-align-last" trait */
public int getTextAlignLast() {
return textAlignLast;
}
- /** @return the "text-indent" property */
+ /** @return the "text-indent" trait */
public Length getTextIndent() {
return textIndent;
}
- /** @return the "last-line-end-indent" property */
+ /** @return the "last-line-end-indent" trait */
public Length getLastLineEndIndent() {
return lastLineEndIndent;
}
- /** @return the "wrap-option" property */
+ /** @return the "wrap-option" trait */
public int getWrapOption() {
return wrapOption;
}
@@ -295,17 +295,17 @@ public class Block extends FObjMixed implements BreakPropertySet,
}
}
- /** @return the "linefeed-treatment" property */
+ /** @return the "linefeed-treatment" trait */
public int getLinefeedTreatment() {
return linefeedTreatment;
}
- /** @return the "white-space-treatment" property */
+ /** @return the "white-space-treatment" trait */
public int getWhitespaceTreatment() {
return whiteSpaceTreatment;
}
- /** @return the "white-space-collapse" property */
+ /** @return the "white-space-collapse" trait */
public int getWhitespaceCollapse() {
return whiteSpaceCollapse;
}
@@ -315,17 +315,17 @@ public class Block extends FObjMixed implements BreakPropertySet,
return this.commonRelativePosition;
}
- /** @return the "hyphenation-keep" property */
+ /** @return the "hyphenation-keep" trait */
public int getHyphenationKeep() {
return this.hyphenationKeep;
}
- /** @return the "intrusion-displace" property */
+ /** @return the "intrusion-displace" trait */
public int getIntrusionDisplace() {
return this.intrusionDisplace;
}
- /** @return the "line-height-shift-adjustment" property */
+ /** @return the "line-height-shift-adjustment" trait */
public int getLineHeightShiftAdjustment() {
return this.lineHeightShiftAdjustment;
}
@@ -335,9 +335,9 @@ public class Block extends FObjMixed implements BreakPropertySet,
* {@link org.apache.fop.fo.Constants#EN_TRUE},
* {@link org.apache.fop.fo.Constants#EN_FALSE}
*/
- public int getDisableColumnBalancing() {
- return disableColumnBalancing;
- }
+ public int getDisableColumnBalancing() {
+ return disableColumnBalancing;
+ }
/** {@inheritDoc} */
@@ -350,10 +350,10 @@ public class Block extends FObjMixed implements BreakPropertySet,
return "block";
}
- /**
- * {@inheritDoc}
- * @return {@link org.apache.fop.fo.Constants#FO_BLOCK}
- */
+ /**
+ * {@inheritDoc}
+ * @return {@link org.apache.fop.fo.Constants#FO_BLOCK}
+ */
public int getNameId() {
return FO_BLOCK;
}
diff --git a/src/java/org/apache/fop/fo/flow/BlockContainer.java b/src/java/org/apache/fop/fo/flow/BlockContainer.java
index 57cb6e5c6..1dc43fd36 100644
--- a/src/java/org/apache/fop/fo/flow/BlockContainer.java
+++ b/src/java/org/apache/fop/fo/flow/BlockContainer.java
@@ -31,14 +31,18 @@ import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
import org.apache.fop.fo.properties.CommonMarginBlock;
import org.apache.fop.fo.properties.KeepProperty;
import org.apache.fop.fo.properties.LengthRangeProperty;
+import org.apache.fop.traits.Direction;
+import org.apache.fop.traits.WritingMode;
+import org.apache.fop.traits.WritingModeTraits;
+import org.apache.fop.traits.WritingModeTraitsGetter;
import org.xml.sax.Locator;
/**
* Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_block-container">
* <code>fo:block-container</code></a> object.
*/
-public class BlockContainer extends FObj implements BreakPropertySet {
- // The value of properties relevant for fo:block-container.
+public class BlockContainer extends FObj implements BreakPropertySet, WritingModeTraitsGetter {
+ // The value of FO traits (refined properties) that apply to fo:block-container.
private CommonAbsolutePosition commonAbsolutePosition;
private CommonBorderPaddingBackground commonBorderPaddingBackground;
private CommonMarginBlock commonMarginBlock;
@@ -55,11 +59,11 @@ public class BlockContainer extends FObj implements BreakPropertySet {
private Numeric referenceOrientation;
private int span;
private int disableColumnBalancing;
- private int writingMode;
+ private WritingModeTraits writingModeTraits;
// Unused but valid items, commented out for performance:
// private int intrusionDisplace;
// private Numeric zIndex;
- // End of property values
+ // End of FO trait values
/** used for FO validation */
private boolean blockItemFound = false;
@@ -92,7 +96,8 @@ public class BlockContainer extends FObj implements BreakPropertySet {
overflow = pList.get(PR_OVERFLOW).getEnum();
referenceOrientation = pList.get(PR_REFERENCE_ORIENTATION).getNumeric();
span = pList.get(PR_SPAN).getEnum();
- writingMode = pList.get(PR_WRITING_MODE).getEnum();
+ writingModeTraits = new WritingModeTraits
+ ( WritingMode.valueOf(pList.get(PR_WRITING_MODE).getEnum()) );
disableColumnBalancing = pList.get(PR_X_DISABLE_COLUMN_BALANCING).getEnum();
}
@@ -161,58 +166,58 @@ public class BlockContainer extends FObj implements BreakPropertySet {
}
/**
- * @return the "block-progression-dimension" property.
+ * @return the "block-progression-dimension" FO trait.
*/
public LengthRangeProperty getBlockProgressionDimension() {
return blockProgressionDimension;
}
- /** @return the "display-align" property. */
+ /** @return the "display-align" FO trait. */
public int getDisplayAlign() {
return displayAlign;
}
- /** @return the "break-after" property. */
+ /** @return the "break-after" FO trait. */
public int getBreakAfter() {
return breakAfter;
}
- /** @return the "break-before" property. */
+ /** @return the "break-before" FO trait. */
public int getBreakBefore() {
return breakBefore;
}
- /** @return the "keep-with-next" property. */
+ /** @return the "keep-with-next" FO trait. */
public KeepProperty getKeepWithNext() {
return keepWithNext;
}
- /** @return the "keep-with-previous" property. */
+ /** @return the "keep-with-previous" FO trait. */
public KeepProperty getKeepWithPrevious() {
return keepWithPrevious;
}
- /** @return the "keep-together" property. */
+ /** @return the "keep-together" FO trait. */
public KeepProperty getKeepTogether() {
return keepTogether;
}
- /** @return the "inline-progression-dimension" property */
+ /** @return the "inline-progression-dimension" FO trait */
public LengthRangeProperty getInlineProgressionDimension() {
return inlineProgressionDimension;
}
- /** @return the "overflow" property */
+ /** @return the "overflow" FO trait */
public int getOverflow() {
return overflow;
}
- /** @return the "reference-orientation" property */
+ /** @return the "reference-orientation" FO trait */
public int getReferenceOrientation() {
return referenceOrientation.getValue();
}
- /** @return the "span" property */
+ /** @return the "span" FO trait */
public int getSpan() {
return this.span;
}
@@ -226,10 +231,52 @@ public class BlockContainer extends FObj implements BreakPropertySet {
return disableColumnBalancing;
}
+ /**
+ * Obtain inline progression direction.
+ * @return the inline progression direction
+ */
+ public Direction getInlineProgressionDirection() {
+ return writingModeTraits.getInlineProgressionDirection();
+ }
+
+ /**
+ * Obtain block progression direction.
+ * @return the block progression direction
+ */
+ public Direction getBlockProgressionDirection() {
+ return writingModeTraits.getBlockProgressionDirection();
+ }
+
+ /**
+ * Obtain column progression direction.
+ * @return the column progression direction
+ */
+ public Direction getColumnProgressionDirection() {
+ return writingModeTraits.getColumnProgressionDirection();
+ }
- /** @return the "writing-mode" property */
- public int getWritingMode() {
- return writingMode;
+ /**
+ * Obtain row progression direction.
+ * @return the row progression direction
+ */
+ public Direction getRowProgressionDirection() {
+ return writingModeTraits.getRowProgressionDirection();
+ }
+
+ /**
+ * Obtain (baseline) shift direction.
+ * @return the (baseline) shift direction
+ */
+ public Direction getShiftDirection() {
+ return writingModeTraits.getShiftDirection();
+ }
+
+ /**
+ * Obtain writing mode.
+ * @return the writing mode
+ */
+ public WritingMode getWritingMode() {
+ return writingModeTraits.getWritingMode();
}
/** {@inheritDoc} */
diff --git a/src/java/org/apache/fop/fo/flow/Character.java b/src/java/org/apache/fop/fo/flow/Character.java
index c4de9fb72..f48ff289e 100644
--- a/src/java/org/apache/fop/fo/flow/Character.java
+++ b/src/java/org/apache/fop/fo/flow/Character.java
@@ -21,11 +21,13 @@ package org.apache.fop.fo.flow;
import java.awt.Color;
import java.util.NoSuchElementException;
+import java.util.Stack;
import org.xml.sax.Locator;
import org.apache.fop.accessibility.StructureTreeElement;
import org.apache.fop.apps.FOPException;
+import org.apache.fop.complexscripts.bidi.DelimitedTextRange;
import org.apache.fop.datatypes.Length;
import org.apache.fop.fo.CharIterator;
import org.apache.fop.fo.FONode;
@@ -233,6 +235,19 @@ public class Character extends FObj implements StructureTreeElementHolder {
return FO_CHARACTER;
}
+ @Override
+ public boolean isDelimitedTextRangeBoundary ( int boundary ) {
+ return false;
+ }
+
+ @Override
+ protected Stack collectDelimitedTextRanges ( Stack ranges, DelimitedTextRange currentRange ) {
+ if ( currentRange != null ) {
+ currentRange.append ( charIterator(), this );
+ }
+ return ranges;
+ }
+
private class FOCharIterator extends CharIterator {
private boolean bFirst = true;
diff --git a/src/java/org/apache/fop/fo/flow/InlineContainer.java b/src/java/org/apache/fop/fo/flow/InlineContainer.java
index d2422a24b..a52801c3f 100644
--- a/src/java/org/apache/fop/fo/flow/InlineContainer.java
+++ b/src/java/org/apache/fop/fo/flow/InlineContainer.java
@@ -33,6 +33,10 @@ import org.apache.fop.fo.properties.CommonMarginInline;
import org.apache.fop.fo.properties.KeepProperty;
import org.apache.fop.fo.properties.LengthRangeProperty;
import org.apache.fop.fo.properties.SpaceProperty;
+import org.apache.fop.traits.Direction;
+import org.apache.fop.traits.WritingMode;
+import org.apache.fop.traits.WritingModeTraits;
+import org.apache.fop.traits.WritingModeTraitsGetter;
/**
* Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_inline-container">
@@ -40,7 +44,7 @@ import org.apache.fop.fo.properties.SpaceProperty;
*/
public class InlineContainer extends FObj {
- // The value of properties relevant for fo:inline-container.
+ // The value of FO traits (refined properties) that apply to fo:inline-container.
private Length alignmentAdjust;
private int alignmentBaseline;
private Length baselineShift;
@@ -54,7 +58,7 @@ public class InlineContainer extends FObj {
private SpaceProperty lineHeight;
private int overflow;
private Numeric referenceOrientation;
- private int writingMode;
+ private WritingModeTraits writingModeTraits;
// Unused but valid items, commented out for performance:
// private CommonRelativePosition commonRelativePosition;
// private int displayAlign;
@@ -62,7 +66,7 @@ public class InlineContainer extends FObj {
// private KeepProperty keepWithNext;
// private KeepProperty keepWithPrevious;
// private Length width;
- // End of property values
+ // End of FO trait values
/** used for FO validation */
private boolean blockItemFound = false;
@@ -92,7 +96,8 @@ public class InlineContainer extends FObj {
lineHeight = pList.get(PR_LINE_HEIGHT).getSpace();
overflow = pList.get(PR_OVERFLOW).getEnum();
referenceOrientation = pList.get(PR_REFERENCE_ORIENTATION).getNumeric();
- writingMode = pList.get(PR_WRITING_MODE).getEnum();
+ writingModeTraits = new WritingModeTraits
+ ( WritingMode.valueOf(pList.get(PR_WRITING_MODE).getEnum()) );
}
/**
@@ -121,27 +126,27 @@ public class InlineContainer extends FObj {
}
}
- /** @return the "alignment-adjust" property */
+ /** @return the "alignment-adjust" FO trait */
public Length getAlignmentAdjust() {
return alignmentAdjust;
}
- /** @return the "alignment-baseline" property */
+ /** @return the "alignment-baseline" FO trait */
public int getAlignmentBaseline() {
return alignmentBaseline;
}
- /** @return the "baseline-shift" property */
+ /** @return the "baseline-shift" FO trait */
public Length getBaselineShift() {
return baselineShift;
}
- /** @return the "block-progression-dimension" property */
+ /** @return the "block-progression-dimension" FO trait */
public LengthRangeProperty getBlockProgressionDimension() {
return blockProgressionDimension;
}
- /** @return the "clip" property */
+ /** @return the "clip" FO trait */
public int getClip() {
return clip;
}
@@ -156,39 +161,82 @@ public class InlineContainer extends FObj {
return this.commonMarginInline;
}
- /** @return the "dominant-baseline" property */
+ /** @return the "dominant-baseline" FO trait */
public int getDominantBaseline() {
return dominantBaseline;
}
- /** @return the "keep-together" property */
+ /** @return the "keep-together" FO trait */
public KeepProperty getKeepTogether() {
return keepTogether;
}
- /** @return the "inline-progression-dimension" property */
+ /** @return the "inline-progression-dimension" FO trait */
public LengthRangeProperty getInlineProgressionDimension() {
return inlineProgressionDimension;
}
- /** @return the "line-height" property */
+ /** @return the "line-height" FO trait */
public SpaceProperty getLineHeight() {
return lineHeight;
}
- /** @return the "overflow" property */
+ /** @return the "overflow" FO trait */
public int getOverflow() {
return overflow;
}
- /** @return the "reference-orientation" property */
+ /** @return the "reference-orientation" FO trait */
public int getReferenceOrientation() {
return referenceOrientation.getValue();
}
- /** @return the "writing-mode" property */
- public int getWritingMode() {
- return writingMode;
+ /**
+ * Obtain inline progression direction.
+ * @return the inline progression direction
+ */
+ public Direction getInlineProgressionDirection() {
+ return writingModeTraits.getInlineProgressionDirection();
+ }
+
+ /**
+ * Obtain block progression direction.
+ * @return the block progression direction
+ */
+ public Direction getBlockProgressionDirection() {
+ return writingModeTraits.getBlockProgressionDirection();
+ }
+
+ /**
+ * Obtain column progression direction.
+ * @return the column progression direction
+ */
+ public Direction getColumnProgressionDirection() {
+ return writingModeTraits.getColumnProgressionDirection();
+ }
+
+ /**
+ * Obtain row progression direction.
+ * @return the row progression direction
+ */
+ public Direction getRowProgressionDirection() {
+ return writingModeTraits.getRowProgressionDirection();
+ }
+
+ /**
+ * Obtain (baseline) shift direction.
+ * @return the (baseline) shift direction
+ */
+ public Direction getShiftDirection() {
+ return writingModeTraits.getShiftDirection();
+ }
+
+ /**
+ * Obtain writing mode.
+ * @return the writing mode
+ */
+ public WritingMode getWritingMode() {
+ return writingModeTraits.getWritingMode();
}
/** {@inheritDoc} */
@@ -204,4 +252,9 @@ public class InlineContainer extends FObj {
return FO_INLINE_CONTAINER;
}
+ @Override
+ public boolean isDelimitedTextRangeBoundary ( int boundary ) {
+ return false;
+ }
+
}
diff --git a/src/java/org/apache/fop/fo/flow/InlineLevel.java b/src/java/org/apache/fop/fo/flow/InlineLevel.java
index 0da769080..b0531f859 100644
--- a/src/java/org/apache/fop/fo/flow/InlineLevel.java
+++ b/src/java/org/apache/fop/fo/flow/InlineLevel.java
@@ -39,7 +39,7 @@ import org.apache.fop.fo.properties.SpaceProperty;
*/
public abstract class InlineLevel extends FObjMixed implements CommonAccessibilityHolder {
- // The value of properties relevant for inline-level FOs.
+ // The value of FO traits (refined properties) that apply to inline level FOs.
private CommonAccessibility commonAccessibility;
private CommonBorderPaddingBackground commonBorderPaddingBackground;
private CommonMarginInline commonMarginInline;
@@ -48,7 +48,7 @@ public abstract class InlineLevel extends FObjMixed implements CommonAccessibili
private KeepProperty keepWithNext;
private KeepProperty keepWithPrevious;
private SpaceProperty lineHeight;
- // End of property values
+ // End of trait values
/**
* Base constructor
@@ -92,24 +92,29 @@ public abstract class InlineLevel extends FObjMixed implements CommonAccessibili
return commonFont;
}
- /** @return the "color" property */
+ /** @return the "color" trait */
public Color getColor() {
return color;
}
- /** @return the "line-height" property */
+ /** @return the "line-height" trait */
public SpaceProperty getLineHeight() {
return lineHeight;
}
- /** @return the "keep-with-next" property */
+ /** @return the "keep-with-next" trait */
public KeepProperty getKeepWithNext() {
return keepWithNext;
}
- /** @return the "keep-with-previous" property */
+ /** @return the "keep-with-previous" trait */
public KeepProperty getKeepWithPrevious() {
return keepWithPrevious;
}
+ @Override
+ public boolean isDelimitedTextRangeBoundary ( int boundary ) {
+ return false;
+ }
+
}
diff --git a/src/java/org/apache/fop/fo/flow/Leader.java b/src/java/org/apache/fop/fo/flow/Leader.java
index f12930dde..ce166b114 100644
--- a/src/java/org/apache/fop/fo/flow/Leader.java
+++ b/src/java/org/apache/fop/fo/flow/Leader.java
@@ -19,18 +19,24 @@
package org.apache.fop.fo.flow;
+import java.util.Stack;
+
+import org.xml.sax.Locator;
+
import org.apache.fop.apps.FOPException;
+import org.apache.fop.complexscripts.bidi.DelimitedTextRange;
import org.apache.fop.datatypes.Length;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.PropertyList;
+import org.apache.fop.fo.ValidationException;
import org.apache.fop.fo.properties.LengthRangeProperty;
+import org.apache.fop.util.CharUtilities;
/**
* Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_leader">
* <code>fo:leader</code></a> object.
* The main property of <code>fo:leader</code> is leader-pattern.
* The following patterns are treated: rule, space, dots and use-content.
- * TODO implement validateChildNode()
*/
public class Leader extends InlineLevel {
// The value of properties relevant for fo:leader.
@@ -96,6 +102,28 @@ public class Leader extends InlineLevel {
// textShadow = pList.get(PR_TEXT_SHADOW);
}
+ /**
+ * {@inheritDoc}
+ * <br>XSL Content Model: (#PCDATA|%inline;)*
+ * <br><i>Additionally: "The content must not contain an
+ * fo:leader, fo:inline-container, fo:block-container, fo:float,
+ * fo:footnote, or fo:marker either as a direct child or as a
+ * descendant."</i>
+ */
+ protected void validateChildNode(Locator loc, String nsURI, String localName)
+ throws ValidationException {
+ if (FO_URI.equals(nsURI)) {
+ if ( localName.equals("leader")
+ || localName.equals("inline-container")
+ || localName.equals("block-container")
+ || localName.equals("float")
+ || localName.equals("marker")
+ || !isInlineItem(nsURI, localName) ) {
+ invalidChildError(loc, nsURI, localName);
+ }
+ }
+ }
+
/** @return the "rule-style" property */
public int getRuleStyle() {
return ruleStyle;
@@ -170,4 +198,17 @@ public class Leader extends InlineLevel {
super.endOfNode();
getFOEventHandler().endLeader(this);
}
+
+ @Override
+ protected Stack collectDelimitedTextRanges ( Stack ranges, DelimitedTextRange currentRange ) {
+ if ( currentRange != null ) {
+ if ( leaderPattern == EN_USECONTENT ) {
+ ranges = super.collectDelimitedTextRanges ( ranges, currentRange );
+ } else {
+ currentRange.append ( CharUtilities.OBJECT_REPLACEMENT_CHARACTER, this );
+ }
+ }
+ return ranges;
+ }
+
}
diff --git a/src/java/org/apache/fop/fo/flow/ListItem.java b/src/java/org/apache/fop/fo/flow/ListItem.java
index aa177777c..f61254874 100644
--- a/src/java/org/apache/fop/fo/flow/ListItem.java
+++ b/src/java/org/apache/fop/fo/flow/ListItem.java
@@ -19,9 +19,12 @@
package org.apache.fop.fo.flow;
+import java.util.Stack;
+
import org.xml.sax.Locator;
import org.apache.fop.apps.FOPException;
+import org.apache.fop.complexscripts.bidi.DelimitedTextRange;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.PropertyList;
@@ -201,5 +204,19 @@ public class ListItem extends FObj implements BreakPropertySet, CommonAccessibil
public int getNameId() {
return FO_LIST_ITEM;
}
+
+ @Override
+ protected Stack collectDelimitedTextRanges ( Stack ranges, DelimitedTextRange currentRange ) {
+ ListItemLabel label = getLabel();
+ if ( label != null ) {
+ ranges = label.collectDelimitedTextRanges ( ranges );
+ }
+ ListItemBody body = getBody();
+ if ( body != null ) {
+ ranges = body.collectDelimitedTextRanges ( ranges );
+ }
+ return ranges;
+ }
+
}
diff --git a/src/java/org/apache/fop/fo/flow/PageNumber.java b/src/java/org/apache/fop/fo/flow/PageNumber.java
index 59169c2d3..fe3e80a75 100644
--- a/src/java/org/apache/fop/fo/flow/PageNumber.java
+++ b/src/java/org/apache/fop/fo/flow/PageNumber.java
@@ -199,4 +199,10 @@ public class PageNumber extends FObj
public int getNameId() {
return FO_PAGE_NUMBER;
}
+
+ @Override
+ public boolean isDelimitedTextRangeBoundary ( int boundary ) {
+ return false;
+ }
+
}
diff --git a/src/java/org/apache/fop/fo/flow/Wrapper.java b/src/java/org/apache/fop/fo/flow/Wrapper.java
index 6c5619252..1302e3134 100644
--- a/src/java/org/apache/fop/fo/flow/Wrapper.java
+++ b/src/java/org/apache/fop/fo/flow/Wrapper.java
@@ -135,5 +135,11 @@ public class Wrapper extends FObjMixed {
public int getNameId() {
return FO_WRAPPER;
}
+
+ @Override
+ public boolean isDelimitedTextRangeBoundary ( int boundary ) {
+ return false;
+ }
+
}
diff --git a/src/java/org/apache/fop/fo/flow/table/Table.java b/src/java/org/apache/fop/fo/flow/table/Table.java
index c78f9f959..b14326af5 100644
--- a/src/java/org/apache/fop/fo/flow/table/Table.java
+++ b/src/java/org/apache/fop/fo/flow/table/Table.java
@@ -48,7 +48,7 @@ import org.apache.fop.fo.properties.TableColLength;
public class Table extends TableFObj implements ColumnNumberManagerHolder, BreakPropertySet,
CommonAccessibilityHolder {
- /** properties */
+ // The value of FO traits (refined properties) that apply to fo:table.
private CommonAccessibility commonAccessibility;
private CommonBorderPaddingBackground commonBorderPaddingBackground;
private CommonMarginBlock commonMarginBlock;
@@ -64,11 +64,12 @@ public class Table extends TableFObj implements ColumnNumberManagerHolder, Break
private int tableLayout;
private int tableOmitFooterAtBreak;
private int tableOmitHeaderAtBreak;
+ private int writingMode;
// Unused but valid items, commented out for performance:
// private CommonAural commonAural;
// private CommonRelativePosition commonRelativePosition;
// private int intrusionDisplace;
- // private int writingMode;
+ // End of FO trait values
/** extension properties */
private Length widowContentLimit;
@@ -130,6 +131,7 @@ public class Table extends TableFObj implements ColumnNumberManagerHolder, Break
tableLayout = pList.get(PR_TABLE_LAYOUT).getEnum();
tableOmitFooterAtBreak = pList.get(PR_TABLE_OMIT_FOOTER_AT_BREAK).getEnum();
tableOmitHeaderAtBreak = pList.get(PR_TABLE_OMIT_HEADER_AT_BREAK).getEnum();
+ writingMode = pList.get(PR_WRITING_MODE).getEnum();
//Bind extension properties
widowContentLimit = pList.get(PR_X_WIDOW_CONTENT_LIMIT).getLength();
@@ -336,7 +338,6 @@ public class Table extends TableFObj implements ColumnNumberManagerHolder, Break
TableColumn implicitColumn = new TableColumn(this, true);
PropertyList pList = new StaticPropertyList(
implicitColumn, this.propList);
- pList.setWritingMode();
implicitColumn.bind(pList);
implicitColumn.setColumnWidth(new TableColLength(1.0, implicitColumn));
implicitColumn.setColumnNumber(colNumber);
@@ -433,14 +434,14 @@ public class Table extends TableFObj implements ColumnNumberManagerHolder, Break
}
/**
- * @return the "inline-progression-dimension" property.
+ * @return the "inline-progression-dimension" FO trait.
*/
public LengthRangeProperty getInlineProgressionDimension() {
return inlineProgressionDimension;
}
/**
- * @return the "block-progression-dimension" property.
+ * @return the "block-progression-dimension" FO trait.
*/
public LengthRangeProperty getBlockProgressionDimension() {
return blockProgressionDimension;
@@ -460,27 +461,27 @@ public class Table extends TableFObj implements ColumnNumberManagerHolder, Break
return commonBorderPaddingBackground;
}
- /** @return the "break-after" property. */
+ /** @return the "break-after" FO trait. */
public int getBreakAfter() {
return breakAfter;
}
- /** @return the "break-before" property. */
+ /** @return the "break-before" FO trait. */
public int getBreakBefore() {
return breakBefore;
}
- /** @return the "keep-with-next" property. */
+ /** @return the "keep-with-next" FO trait. */
public KeepProperty getKeepWithNext() {
return keepWithNext;
}
- /** @return the "keep-with-previous" property. */
+ /** @return the "keep-with-previous" FO trait. */
public KeepProperty getKeepWithPrevious() {
return keepWithPrevious;
}
- /** @return the "keep-together" property. */
+ /** @return the "keep-together" FO trait. */
public KeepProperty getKeepTogether() {
return keepTogether;
}
@@ -494,7 +495,7 @@ public class Table extends TableFObj implements ColumnNumberManagerHolder, Break
|| !getKeepTogether().getWithinColumn().isAuto();
}
- /** @return the "border-collapse" property. */
+ /** @return the "border-collapse" FO trait. */
public int getBorderCollapse() {
return borderCollapse;
}
@@ -504,17 +505,22 @@ public class Table extends TableFObj implements ColumnNumberManagerHolder, Break
return (getBorderCollapse() == EN_SEPARATE);
}
- /** @return the "border-separation" property. */
+ /** @return the "border-separation" FO trait. */
public LengthPairProperty getBorderSeparation() {
return borderSeparation;
}
- /** @return the "fox:widow-content-limit" extension property */
+ /** @return the "writing-mode" FO trait */
+ public int getWritingMode() {
+ return writingMode;
+ }
+
+ /** @return the "fox:widow-content-limit" extension FO trait */
public Length getWidowContentLimit() {
return widowContentLimit;
}
- /** @return the "fox:orphan-content-limit" extension property */
+ /** @return the "fox:orphan-content-limit" extension FO trait */
public Length getOrphanContentLimit() {
return orphanContentLimit;
}