You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ga...@apache.org on 2012/02/26 03:29:29 UTC
svn commit: r1293736 [16/38] - in /xmlgraphics/fop/trunk: ./
src/codegen/java/org/apache/fop/tools/
src/codegen/unicode/java/org/apache/fop/complexscripts/
src/codegen/unicode/java/org/apache/fop/complexscripts/bidi/
src/documentation/content/xdocs/tru...
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOPropertyMapping.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOPropertyMapping.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOPropertyMapping.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOPropertyMapping.java Sun Feb 26 02:29:01 2012
@@ -632,7 +632,7 @@ public final class FOPropertyMapping imp
m.setDefault("black");
corr = new CorrespondingPropertyMaker(m);
corr.setCorresponding(PR_BORDER_TOP_COLOR, PR_BORDER_TOP_COLOR,
- PR_BORDER_RIGHT_COLOR);
+ PR_BORDER_RIGHT_COLOR, PR_BORDER_LEFT_COLOR);
corr.setRelative(true);
addPropertyMaker("border-before-color", m);
@@ -641,7 +641,7 @@ public final class FOPropertyMapping imp
m.useGeneric(genericBorderStyle);
corr = new CorrespondingPropertyMaker(m);
corr.setCorresponding(PR_BORDER_TOP_STYLE, PR_BORDER_TOP_STYLE,
- PR_BORDER_RIGHT_STYLE);
+ PR_BORDER_RIGHT_STYLE, PR_BORDER_LEFT_STYLE);
corr.setRelative(true);
addPropertyMaker("border-before-style", m);
@@ -651,7 +651,7 @@ public final class FOPropertyMapping imp
m.getSubpropMaker(CP_CONDITIONALITY).setDefault("discard");
corr = new CorrespondingPropertyMaker(m);
corr.setCorresponding(PR_BORDER_TOP_WIDTH, PR_BORDER_TOP_WIDTH,
- PR_BORDER_RIGHT_WIDTH);
+ PR_BORDER_RIGHT_WIDTH, PR_BORDER_LEFT_WIDTH);
corr.setRelative(true);
addPropertyMaker("border-before-width", m);
@@ -662,7 +662,7 @@ public final class FOPropertyMapping imp
m.setDefault("black");
corr = new CorrespondingPropertyMaker(m);
corr.setCorresponding(PR_BORDER_BOTTOM_COLOR, PR_BORDER_BOTTOM_COLOR,
- PR_BORDER_LEFT_COLOR);
+ PR_BORDER_LEFT_COLOR, PR_BORDER_RIGHT_COLOR);
corr.setRelative(true);
addPropertyMaker("border-after-color", m);
@@ -671,7 +671,7 @@ public final class FOPropertyMapping imp
m.useGeneric(genericBorderStyle);
corr = new CorrespondingPropertyMaker(m);
corr.setCorresponding(PR_BORDER_BOTTOM_STYLE, PR_BORDER_BOTTOM_STYLE,
- PR_BORDER_LEFT_STYLE);
+ PR_BORDER_LEFT_STYLE, PR_BORDER_RIGHT_STYLE);
corr.setRelative(true);
addPropertyMaker("border-after-style", m);
@@ -681,7 +681,7 @@ public final class FOPropertyMapping imp
m.getSubpropMaker(CP_CONDITIONALITY).setDefault("discard");
corr = new CorrespondingPropertyMaker(m);
corr.setCorresponding(PR_BORDER_BOTTOM_WIDTH, PR_BORDER_BOTTOM_WIDTH,
- PR_BORDER_LEFT_WIDTH);
+ PR_BORDER_LEFT_WIDTH, PR_BORDER_LEFT_WIDTH);
corr.setRelative(true);
addPropertyMaker("border-after-width", m);
@@ -692,7 +692,7 @@ public final class FOPropertyMapping imp
m.setDefault("black");
corr = new CorrespondingPropertyMaker(m);
corr.setCorresponding(PR_BORDER_LEFT_COLOR, PR_BORDER_RIGHT_COLOR,
- PR_BORDER_TOP_COLOR);
+ PR_BORDER_TOP_COLOR, PR_BORDER_TOP_COLOR);
corr.setRelative(true);
addPropertyMaker("border-start-color", m);
@@ -701,7 +701,7 @@ public final class FOPropertyMapping imp
m.useGeneric(genericBorderStyle);
corr = new CorrespondingPropertyMaker(m);
corr.setCorresponding(PR_BORDER_LEFT_STYLE, PR_BORDER_RIGHT_STYLE,
- PR_BORDER_TOP_STYLE);
+ PR_BORDER_TOP_STYLE, PR_BORDER_TOP_STYLE);
corr.setRelative(true);
addPropertyMaker("border-start-style", m);
@@ -711,7 +711,7 @@ public final class FOPropertyMapping imp
m.getSubpropMaker(CP_CONDITIONALITY).setDefault("discard");
corr = new CorrespondingPropertyMaker(m);
corr.setCorresponding(PR_BORDER_LEFT_WIDTH, PR_BORDER_RIGHT_WIDTH,
- PR_BORDER_TOP_WIDTH);
+ PR_BORDER_TOP_WIDTH, PR_BORDER_TOP_WIDTH);
corr.setRelative(true);
addPropertyMaker("border-start-width", m);
@@ -722,7 +722,7 @@ public final class FOPropertyMapping imp
m.setDefault("black");
corr = new CorrespondingPropertyMaker(m);
corr.setCorresponding(PR_BORDER_RIGHT_COLOR, PR_BORDER_LEFT_COLOR,
- PR_BORDER_BOTTOM_COLOR);
+ PR_BORDER_BOTTOM_COLOR, PR_BORDER_BOTTOM_COLOR);
corr.setRelative(true);
addPropertyMaker("border-end-color", m);
@@ -731,7 +731,7 @@ public final class FOPropertyMapping imp
m.useGeneric(genericBorderStyle);
corr = new CorrespondingPropertyMaker(m);
corr.setCorresponding(PR_BORDER_RIGHT_STYLE, PR_BORDER_LEFT_STYLE,
- PR_BORDER_BOTTOM_STYLE);
+ PR_BORDER_BOTTOM_STYLE, PR_BORDER_BOTTOM_STYLE);
corr.setRelative(true);
addPropertyMaker("border-end-style", m);
@@ -741,7 +741,7 @@ public final class FOPropertyMapping imp
m.getSubpropMaker(CP_CONDITIONALITY).setDefault("discard");
corr = new CorrespondingPropertyMaker(m);
corr.setCorresponding(PR_BORDER_RIGHT_WIDTH, PR_BORDER_LEFT_WIDTH,
- PR_BORDER_BOTTOM_WIDTH);
+ PR_BORDER_BOTTOM_WIDTH, PR_BORDER_BOTTOM_WIDTH);
corr.setRelative(true);
addPropertyMaker("border-end-width", m);
@@ -755,7 +755,7 @@ public final class FOPropertyMapping imp
m.addShorthand(generics[PR_BORDER]);
corr = new CorrespondingPropertyMaker(m);
corr.setCorresponding(PR_BORDER_BEFORE_COLOR, PR_BORDER_BEFORE_COLOR,
- PR_BORDER_START_COLOR);
+ PR_BORDER_START_COLOR, PR_BORDER_START_COLOR);
addPropertyMaker("border-top-color", m);
// border-top-style
@@ -766,7 +766,7 @@ public final class FOPropertyMapping imp
m.addShorthand(generics[PR_BORDER]);
corr = new CorrespondingPropertyMaker(m);
corr.setCorresponding(PR_BORDER_BEFORE_STYLE, PR_BORDER_BEFORE_STYLE,
- PR_BORDER_START_STYLE);
+ PR_BORDER_START_STYLE, PR_BORDER_START_STYLE);
addPropertyMaker("border-top-style", m);
// border-top-width
@@ -778,7 +778,7 @@ public final class FOPropertyMapping imp
bwm.addShorthand(generics[PR_BORDER]);
corr = new CorrespondingPropertyMaker(bwm);
corr.setCorresponding(PR_BORDER_BEFORE_WIDTH, PR_BORDER_BEFORE_WIDTH,
- PR_BORDER_START_WIDTH);
+ PR_BORDER_START_WIDTH, PR_BORDER_START_WIDTH);
addPropertyMaker("border-top-width", bwm);
// border-bottom-color
@@ -791,7 +791,7 @@ public final class FOPropertyMapping imp
m.addShorthand(generics[PR_BORDER]);
corr = new CorrespondingPropertyMaker(m);
corr.setCorresponding(PR_BORDER_AFTER_COLOR, PR_BORDER_AFTER_COLOR,
- PR_BORDER_END_COLOR);
+ PR_BORDER_END_COLOR, PR_BORDER_END_COLOR);
addPropertyMaker("border-bottom-color", m);
// border-bottom-style
@@ -802,7 +802,7 @@ public final class FOPropertyMapping imp
m.addShorthand(generics[PR_BORDER]);
corr = new CorrespondingPropertyMaker(m);
corr.setCorresponding(PR_BORDER_AFTER_STYLE, PR_BORDER_AFTER_STYLE,
- PR_BORDER_END_STYLE);
+ PR_BORDER_END_STYLE, PR_BORDER_END_STYLE);
addPropertyMaker("border-bottom-style", m);
// border-bottom-width
@@ -814,7 +814,7 @@ public final class FOPropertyMapping imp
bwm.addShorthand(generics[PR_BORDER]);
corr = new CorrespondingPropertyMaker(bwm);
corr.setCorresponding(PR_BORDER_AFTER_WIDTH, PR_BORDER_AFTER_WIDTH,
- PR_BORDER_END_WIDTH);
+ PR_BORDER_END_WIDTH, PR_BORDER_END_WIDTH);
addPropertyMaker("border-bottom-width", bwm);
// border-left-color
@@ -827,7 +827,7 @@ public final class FOPropertyMapping imp
m.addShorthand(generics[PR_BORDER]);
corr = new CorrespondingPropertyMaker(m);
corr.setCorresponding(PR_BORDER_START_COLOR, PR_BORDER_END_COLOR,
- PR_BORDER_AFTER_COLOR);
+ PR_BORDER_AFTER_COLOR, PR_BORDER_BEFORE_COLOR);
addPropertyMaker("border-left-color", m);
// border-left-style
@@ -838,7 +838,7 @@ public final class FOPropertyMapping imp
m.addShorthand(generics[PR_BORDER]);
corr = new CorrespondingPropertyMaker(m);
corr.setCorresponding(PR_BORDER_START_STYLE, PR_BORDER_END_STYLE,
- PR_BORDER_AFTER_STYLE);
+ PR_BORDER_AFTER_STYLE, PR_BORDER_BEFORE_STYLE);
addPropertyMaker("border-left-style", m);
// border-left-width
@@ -850,7 +850,7 @@ public final class FOPropertyMapping imp
bwm.addShorthand(generics[PR_BORDER]);
corr = new CorrespondingPropertyMaker(bwm);
corr.setCorresponding(PR_BORDER_START_WIDTH, PR_BORDER_END_WIDTH,
- PR_BORDER_AFTER_WIDTH);
+ PR_BORDER_AFTER_WIDTH, PR_BORDER_BEFORE_WIDTH);
addPropertyMaker("border-left-width", bwm);
// border-right-color
@@ -863,7 +863,7 @@ public final class FOPropertyMapping imp
m.addShorthand(generics[PR_BORDER]);
corr = new CorrespondingPropertyMaker(m);
corr.setCorresponding(PR_BORDER_END_COLOR, PR_BORDER_START_COLOR,
- PR_BORDER_BEFORE_COLOR);
+ PR_BORDER_BEFORE_COLOR, PR_BORDER_AFTER_COLOR);
addPropertyMaker("border-right-color", m);
// border-right-style
@@ -874,7 +874,7 @@ public final class FOPropertyMapping imp
m.addShorthand(generics[PR_BORDER]);
corr = new CorrespondingPropertyMaker(m);
corr.setCorresponding(PR_BORDER_END_STYLE, PR_BORDER_START_STYLE,
- PR_BORDER_BEFORE_STYLE);
+ PR_BORDER_BEFORE_STYLE, PR_BORDER_AFTER_STYLE);
addPropertyMaker("border-right-style", m);
// border-right-width
@@ -886,7 +886,7 @@ public final class FOPropertyMapping imp
bwm.addShorthand(generics[PR_BORDER]);
corr = new CorrespondingPropertyMaker(bwm);
corr.setCorresponding(PR_BORDER_END_WIDTH, PR_BORDER_START_WIDTH,
- PR_BORDER_BEFORE_WIDTH);
+ PR_BORDER_BEFORE_WIDTH, PR_BORDER_AFTER_WIDTH);
addPropertyMaker("border-right-width", bwm);
// padding-before
@@ -895,7 +895,7 @@ public final class FOPropertyMapping imp
m.getSubpropMaker(CP_CONDITIONALITY).setDefault("discard");
corr = new CorrespondingPropertyMaker(m);
corr.setCorresponding(PR_PADDING_TOP, PR_PADDING_TOP,
- PR_PADDING_RIGHT);
+ PR_PADDING_RIGHT, PR_PADDING_LEFT);
corr.setRelative(true);
addPropertyMaker("padding-before", m);
@@ -905,7 +905,7 @@ public final class FOPropertyMapping imp
m.getSubpropMaker(CP_CONDITIONALITY).setDefault("discard");
corr = new CorrespondingPropertyMaker(m);
corr.setCorresponding(PR_PADDING_BOTTOM, PR_PADDING_BOTTOM,
- PR_PADDING_LEFT);
+ PR_PADDING_LEFT, PR_PADDING_RIGHT);
corr.setRelative(true);
addPropertyMaker("padding-after", m);
@@ -915,7 +915,7 @@ public final class FOPropertyMapping imp
m.getSubpropMaker(CP_CONDITIONALITY).setDefault("discard");
corr = new CorrespondingPropertyMaker(m);
corr.setCorresponding(PR_PADDING_LEFT, PR_PADDING_RIGHT,
- PR_PADDING_TOP);
+ PR_PADDING_TOP, PR_PADDING_TOP);
corr.setRelative(true);
addPropertyMaker("padding-start", m);
@@ -925,7 +925,7 @@ public final class FOPropertyMapping imp
m.getSubpropMaker(CP_CONDITIONALITY).setDefault("discard");
corr = new CorrespondingPropertyMaker(m);
corr.setCorresponding(PR_PADDING_RIGHT, PR_PADDING_LEFT,
- PR_PADDING_BOTTOM);
+ PR_PADDING_BOTTOM, PR_PADDING_BOTTOM);
corr.setRelative(true);
addPropertyMaker("padding-end", m);
@@ -934,7 +934,7 @@ public final class FOPropertyMapping imp
m.useGeneric(genericPadding);
corr = new CorrespondingPropertyMaker(m);
corr.setCorresponding(PR_PADDING_BEFORE, PR_PADDING_BEFORE,
- PR_PADDING_START);
+ PR_PADDING_START, PR_PADDING_START);
addPropertyMaker("padding-top", m);
// padding-bottom
@@ -942,7 +942,7 @@ public final class FOPropertyMapping imp
m.useGeneric(genericPadding);
corr = new CorrespondingPropertyMaker(m);
corr.setCorresponding(PR_PADDING_AFTER, PR_PADDING_AFTER,
- PR_PADDING_END);
+ PR_PADDING_END, PR_PADDING_END);
addPropertyMaker("padding-bottom", m);
// padding-left
@@ -950,7 +950,7 @@ public final class FOPropertyMapping imp
m.useGeneric(genericPadding);
corr = new CorrespondingPropertyMaker(m);
corr.setCorresponding(PR_PADDING_START, PR_PADDING_END,
- PR_PADDING_AFTER);
+ PR_PADDING_AFTER, PR_PADDING_BEFORE);
addPropertyMaker("padding-left", m);
// padding-right
@@ -958,7 +958,7 @@ public final class FOPropertyMapping imp
m.useGeneric(genericPadding);
corr = new CorrespondingPropertyMaker(m);
corr.setCorresponding(PR_PADDING_END, PR_PADDING_START,
- PR_PADDING_BEFORE);
+ PR_PADDING_BEFORE, PR_PADDING_AFTER);
addPropertyMaker("padding-right", m);
}
@@ -1151,7 +1151,7 @@ public final class FOPropertyMapping imp
m = new SpaceProperty.Maker(PR_SPACE_BEFORE);
m.useGeneric(genericSpace);
corr = new SpacePropertyMaker(m);
- corr.setCorresponding(PR_MARGIN_TOP, PR_MARGIN_TOP, PR_MARGIN_RIGHT);
+ corr.setCorresponding(PR_MARGIN_TOP, PR_MARGIN_TOP, PR_MARGIN_RIGHT, PR_MARGIN_LEFT);
corr.setUseParent(false);
corr.setRelative(true);
addPropertyMaker("space-before", m);
@@ -1160,7 +1160,7 @@ public final class FOPropertyMapping imp
m = new SpaceProperty.Maker(PR_SPACE_AFTER);
m.useGeneric(genericSpace);
corr = new SpacePropertyMaker(m);
- corr.setCorresponding(PR_MARGIN_BOTTOM, PR_MARGIN_BOTTOM, PR_MARGIN_LEFT);
+ corr.setCorresponding(PR_MARGIN_BOTTOM, PR_MARGIN_BOTTOM, PR_MARGIN_LEFT, PR_MARGIN_RIGHT);
corr.setUseParent(false);
corr.setRelative(true);
addPropertyMaker("space-after", m);
@@ -1171,14 +1171,14 @@ public final class FOPropertyMapping imp
m.setDefault("0pt");
m.setPercentBase(LengthBase.CONTAINING_REFAREA_WIDTH);
IndentPropertyMaker sCorr = new IndentPropertyMaker(m);
- sCorr.setCorresponding(PR_MARGIN_LEFT, PR_MARGIN_RIGHT, PR_MARGIN_TOP);
+ sCorr.setCorresponding(PR_MARGIN_LEFT, PR_MARGIN_RIGHT, PR_MARGIN_TOP, PR_MARGIN_TOP);
sCorr.setUseParent(false);
sCorr.setRelative(true);
sCorr.setPaddingCorresponding(new int[] {
- PR_PADDING_LEFT, PR_PADDING_RIGHT, PR_PADDING_TOP
+ PR_PADDING_LEFT, PR_PADDING_RIGHT, PR_PADDING_TOP, PR_PADDING_TOP
});
sCorr.setBorderWidthCorresponding(new int[] {
- PR_BORDER_LEFT_WIDTH, PR_BORDER_RIGHT_WIDTH, PR_BORDER_TOP_WIDTH
+ PR_BORDER_LEFT_WIDTH, PR_BORDER_RIGHT_WIDTH, PR_BORDER_TOP_WIDTH, PR_BORDER_TOP_WIDTH
});
addPropertyMaker("start-indent", m);
@@ -1188,14 +1188,16 @@ public final class FOPropertyMapping imp
m.setDefault("0pt");
m.setPercentBase(LengthBase.CONTAINING_REFAREA_WIDTH);
IndentPropertyMaker eCorr = new IndentPropertyMaker(m);
- eCorr.setCorresponding(PR_MARGIN_RIGHT, PR_MARGIN_LEFT, PR_MARGIN_BOTTOM);
+ eCorr.setCorresponding(PR_MARGIN_RIGHT, PR_MARGIN_LEFT,
+ PR_MARGIN_BOTTOM, PR_MARGIN_BOTTOM);
eCorr.setUseParent(false);
eCorr.setRelative(true);
eCorr.setPaddingCorresponding(new int[] {
- PR_PADDING_RIGHT, PR_PADDING_LEFT, PR_PADDING_BOTTOM
+ PR_PADDING_RIGHT, PR_PADDING_LEFT, PR_PADDING_BOTTOM, PR_PADDING_BOTTOM
});
eCorr.setBorderWidthCorresponding(new int[] {
- PR_BORDER_RIGHT_WIDTH, PR_BORDER_LEFT_WIDTH, PR_BORDER_BOTTOM_WIDTH
+ PR_BORDER_RIGHT_WIDTH, PR_BORDER_LEFT_WIDTH,
+ PR_BORDER_BOTTOM_WIDTH, PR_BORDER_BOTTOM_WIDTH
});
addPropertyMaker("end-indent", m);
}
@@ -1352,10 +1354,10 @@ public final class FOPropertyMapping imp
m.addSubpropMaker(l);
pdim = new DimensionPropertyMaker(m);
- pdim.setCorresponding(PR_HEIGHT, PR_HEIGHT, PR_WIDTH);
+ pdim.setCorresponding(PR_HEIGHT, PR_HEIGHT, PR_WIDTH, PR_WIDTH);
pdim.setExtraCorresponding(new int[][] {
- {PR_MIN_HEIGHT, PR_MIN_HEIGHT, PR_MIN_WIDTH, },
- {PR_MAX_HEIGHT, PR_MAX_HEIGHT, PR_MAX_WIDTH, }
+ {PR_MIN_HEIGHT, PR_MIN_HEIGHT, PR_MIN_WIDTH, PR_MIN_WIDTH},
+ {PR_MAX_HEIGHT, PR_MAX_HEIGHT, PR_MAX_WIDTH, PR_MAX_WIDTH}
});
pdim.setRelative(true);
m.setCorresponding(pdim);
@@ -1419,10 +1421,10 @@ public final class FOPropertyMapping imp
pdim = new DimensionPropertyMaker(m);
pdim.setRelative(true);
- pdim.setCorresponding(PR_WIDTH, PR_WIDTH, PR_HEIGHT);
+ pdim.setCorresponding(PR_WIDTH, PR_WIDTH, PR_HEIGHT, PR_HEIGHT);
pdim.setExtraCorresponding(new int[][] {
- {PR_MIN_WIDTH, PR_MIN_WIDTH, PR_MIN_HEIGHT, },
- {PR_MAX_WIDTH, PR_MAX_WIDTH, PR_MAX_HEIGHT, }
+ {PR_MIN_WIDTH, PR_MIN_WIDTH, PR_MIN_HEIGHT, PR_MIN_HEIGHT },
+ {PR_MAX_WIDTH, PR_MAX_WIDTH, PR_MAX_HEIGHT, PR_MIN_HEIGHT }
});
m.setCorresponding(pdim);
addPropertyMaker("inline-progression-dimension", m);
@@ -1491,6 +1493,37 @@ public final class FOPropertyMapping imp
addPropertyMaker("fox:block-progression-unit", l);
}
+ private Property calcWritingModeDependent ( int pv, int wm ) {
+ if ( pv == EN_LEFT ) {
+ if ( wm == Constants.EN_LR_TB ) {
+ pv = EN_START;
+ } else if ( wm == Constants.EN_RL_TB ) {
+ pv = EN_END;
+ } else {
+ pv = EN_START;
+ }
+ } else if ( pv == EN_RIGHT ) {
+ if ( wm == Constants.EN_LR_TB ) {
+ pv = EN_END;
+ } else if ( wm == Constants.EN_RL_TB ) {
+ pv = EN_START;
+ } else {
+ pv = EN_END;
+ }
+ }
+ return makeWritingModeDependentEnum ( pv );
+ }
+
+ private Property makeWritingModeDependentEnum ( int pv ) {
+ if ( pv == EN_START ) {
+ return getEnumProperty ( EN_START, "START" );
+ } else if ( pv == EN_END ) {
+ return getEnumProperty ( EN_END, "END" );
+ } else {
+ return null;
+ }
+ }
+
private void createBlockAndLineProperties() { // CSOK: MethodLength
PropertyMaker m;
@@ -1576,16 +1609,29 @@ public final class FOPropertyMapping imp
addPropertyMaker("white-space-treatment", m);
// text-align TODO: make it a StringProperty with enums.
- m = new EnumProperty.Maker(PR_TEXT_ALIGN);
+ m = new EnumProperty.Maker(PR_TEXT_ALIGN) {
+ public Property get(int subpropId, PropertyList propertyList,
+ boolean bTryInherit, boolean bTryDefault) throws PropertyException {
+ Property p = super.get(subpropId, propertyList, bTryInherit, bTryDefault);
+ if ( p != null ) {
+ int pv = p.getEnum();
+ if ( ( pv == EN_LEFT ) || ( pv == EN_RIGHT ) ) {
+ p = calcWritingModeDependent
+ ( pv, propertyList.get(Constants.PR_WRITING_MODE).getEnum() );
+ }
+ }
+ return p;
+ }
+ };
m.setInherited(true);
- // Note: both 'end', 'right' and 'outside' are mapped to END
- // both 'start', 'left' and 'inside' are mapped to START
m.addEnum("center", getEnumProperty(EN_CENTER, "CENTER"));
m.addEnum("end", getEnumProperty(EN_END, "END"));
- m.addEnum("right", getEnumProperty(EN_END, "END"));
m.addEnum("start", getEnumProperty(EN_START, "START"));
- m.addEnum("left", getEnumProperty(EN_START, "START"));
m.addEnum("justify", getEnumProperty(EN_JUSTIFY, "JUSTIFY"));
+ // [GA] must defer writing-mode relative mapping of left/right
+ m.addEnum("left", getEnumProperty(EN_LEFT, "LEFT"));
+ m.addEnum("right", getEnumProperty(EN_RIGHT, "RIGHT"));
+ // [GA] inside and outside are not correctly implemented by the following mapping
m.addEnum("inside", getEnumProperty(EN_START, "START"));
m.addEnum("outside", getEnumProperty(EN_END, "END"));
m.setDefault("start");
@@ -1605,7 +1651,6 @@ public final class FOPropertyMapping imp
}
return p;
}
-
private Property calcRelative(PropertyList propertyList) throws PropertyException {
Property corresponding = propertyList.get(PR_TEXT_ALIGN);
if (corresponding == null) {
@@ -1620,6 +1665,12 @@ public final class FOPropertyMapping imp
return getEnumProperty(EN_START, "START");
} else if (correspondingValue == EN_CENTER) {
return getEnumProperty(EN_CENTER, "CENTER");
+ } else if (correspondingValue == EN_LEFT) {
+ return calcWritingModeDependent
+ ( EN_LEFT, propertyList.get(Constants.PR_WRITING_MODE).getEnum() );
+ } else if (correspondingValue == EN_RIGHT) {
+ return calcWritingModeDependent
+ ( EN_RIGHT, propertyList.get(Constants.PR_WRITING_MODE).getEnum() );
} else {
return null;
}
@@ -2171,6 +2222,12 @@ public final class FOPropertyMapping imp
m.addEnum("auto", getEnumProperty(EN_AUTO, "AUTO"));
m.setDefault("auto");
addPropertyMaker("letter-value", m);
+
+ // fox:alt-text, used for accessibility
+ m = new StringProperty.Maker(PR_X_NUMBER_CONVERSION_FEATURES);
+ m.setInherited(false);
+ m.setDefault("");
+ addPropertyMaker("fox:number-conversion-features", m);
}
private void createPaginationAndLayoutProperties() {
@@ -2512,6 +2569,7 @@ public final class FOPropertyMapping imp
m.addEnum("lr-tb", getEnumProperty(EN_LR_TB, "LR_TB"));
m.addEnum("rl-tb", getEnumProperty(EN_RL_TB, "RL_TB"));
m.addEnum("tb-rl", getEnumProperty(EN_TB_RL, "TB_RL"));
+ m.addEnum("tb-lr", getEnumProperty(EN_TB_LR, "TB_LR"));
m.addKeyword("lr", "lr-tb");
m.addKeyword("rl", "rl-tb");
m.addKeyword("tb", "tb-rl");
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOText.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOText.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOText.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FOText.java Sun Feb 26 02:29:01 2012
@@ -21,12 +21,15 @@ package org.apache.fop.fo;
import java.awt.Color;
import java.nio.CharBuffer;
+import java.util.Map;
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.flow.Block;
import org.apache.fop.fo.properties.CommonFont;
@@ -45,7 +48,8 @@ public class FOText extends FONode imple
/** the <code>CharBuffer</code> containing the text */
private CharBuffer charBuffer;
- /** properties relevant for #PCDATA */
+ // The value of FO traits (refined properties) that apply to #PCDATA
+ // (aka implicit sequence of fo:character)
private CommonFont commonFont;
private CommonHyphenation commonHyphenation;
private Color color;
@@ -58,6 +62,10 @@ public class FOText extends FONode imple
private Property wordSpacing;
private int wrapOption;
private Length baselineShift;
+ private String country;
+ private String language;
+ private String script;
+ // End of trait values
/**
* Points to the previous FOText object created within the current
@@ -82,6 +90,12 @@ public class FOText extends FONode imple
private StructureTreeElement structureTreeElement;
+ /* bidi levels */
+ private int[] bidiLevels;
+
+ /* advanced script processing state */
+ private Map/*<MapRange,String>*/ mappings;
+
private static final int IS_WORD_CHAR_FALSE = 0;
private static final int IS_WORD_CHAR_TRUE = 1;
private static final int IS_WORD_CHAR_MAYBE = 2;
@@ -98,21 +112,31 @@ public class FOText extends FONode imple
/** {@inheritDoc} */
protected void characters(char[] data, int start, int length,
PropertyList list, Locator locator) throws FOPException {
-
- if (this.charBuffer == null) {
+ if (charBuffer == null) {
// buffer not yet initialized, do so now
- this.charBuffer = CharBuffer.allocate(length);
+ int newLength = ( length < 16 ) ? 16 : length;
+ charBuffer = CharBuffer.allocate(newLength);
} else {
// allocate a larger buffer, and transfer contents
- int newLength = this.charBuffer.limit() + length;
- CharBuffer newBuffer = CharBuffer.allocate(newLength);
- this.charBuffer.rewind();
- newBuffer.put(this.charBuffer);
- this.charBuffer = newBuffer;
+ int requires = charBuffer.position() + length;
+ int capacity = charBuffer.capacity();
+ if ( requires > capacity ) {
+ int newCapacity = capacity * 2;
+ if ( requires > newCapacity ) {
+ newCapacity = requires;
+ }
+ CharBuffer newBuffer = CharBuffer.allocate(newCapacity);
+ charBuffer.rewind();
+ newBuffer.put(charBuffer);
+ charBuffer = newBuffer;
+ }
}
+ // extend limit to capacity
+ charBuffer.limit(charBuffer.capacity());
// append characters
- this.charBuffer.put(data, start, length);
-
+ charBuffer.put(data, start, length);
+ // shrink limit to position
+ charBuffer.limit(charBuffer.position());
}
/**
@@ -135,10 +159,10 @@ public class FOText extends FONode imple
if (removeChildren) {
// not really removing, just make sure the char buffer
// pointed to is really a different one
- if (this.charBuffer != null) {
- ft.charBuffer = CharBuffer.allocate(this.charBuffer.limit());
- this.charBuffer.rewind();
- ft.charBuffer.put(this.charBuffer);
+ if (charBuffer != null) {
+ ft.charBuffer = CharBuffer.allocate(charBuffer.limit());
+ charBuffer.rewind();
+ ft.charBuffer.put(charBuffer);
ft.charBuffer.rewind();
}
}
@@ -163,10 +187,16 @@ public class FOText extends FONode imple
this.wrapOption = pList.get(Constants.PR_WRAP_OPTION).getEnum();
this.textDecoration = pList.getTextDecorationProps();
this.baselineShift = pList.get(Constants.PR_BASELINE_SHIFT).getLength();
+ this.country = pList.get(Constants.PR_COUNTRY).getString();
+ this.language = pList.get(Constants.PR_LANGUAGE).getString();
+ this.script = pList.get(Constants.PR_SCRIPT).getString();
}
/** {@inheritDoc} */
protected void endOfNode() throws FOPException {
+ if ( charBuffer != null ) {
+ charBuffer.rewind();
+ }
super.endOfNode();
getFOEventHandler().characters(this);
}
@@ -187,20 +217,20 @@ public class FOText extends FONode imple
*/
public boolean willCreateArea() {
if (whiteSpaceCollapse == Constants.EN_FALSE
- && this.charBuffer.limit() > 0) {
+ && charBuffer.limit() > 0) {
return true;
}
char ch;
- this.charBuffer.rewind();
- while (this.charBuffer.hasRemaining()) {
- ch = this.charBuffer.get();
+ charBuffer.rewind();
+ while (charBuffer.hasRemaining()) {
+ ch = charBuffer.get();
if (!((ch == CharUtilities.SPACE)
|| (ch == CharUtilities.LINEFEED_CHAR)
|| (ch == CharUtilities.CARRIAGE_RETURN)
|| (ch == CharUtilities.TAB))) {
// not whitespace
- this.charBuffer.rewind();
+ charBuffer.rewind();
return true;
}
}
@@ -243,13 +273,13 @@ public class FOText extends FONode imple
return;
}
- this.charBuffer.rewind();
- CharBuffer tmp = this.charBuffer.slice();
+ charBuffer.rewind();
+ CharBuffer tmp = charBuffer.slice();
char c;
- int lim = this.charBuffer.limit();
+ int lim = charBuffer.limit();
int pos = -1;
while (++pos < lim) {
- c = this.charBuffer.get();
+ c = charBuffer.get();
switch (textTransform) {
case Constants.EN_UPPERCASE:
tmp.put(Character.toUpperCase(c));
@@ -374,25 +404,25 @@ public class FOText extends FONode imple
* @return The previous FOText node in this Block; null, if this is the
* first FOText in this Block.
*/
- public FOText getPrevFOTextThisBlock () {
- return prevFOTextThisBlock;
- }
+ //public FOText getPrevFOTextThisBlock () {
+ // return prevFOTextThisBlock;
+ //}
/**
* @return The next FOText node in this Block; null if this is the last
* FOText in this Block; null if subsequent FOText nodes have not yet been
* processed.
*/
- public FOText getNextFOTextThisBlock () {
- return nextFOTextThisBlock;
- }
+ //public FOText getNextFOTextThisBlock () {
+ // return nextFOTextThisBlock;
+ //}
/**
* @return The nearest ancestor block object which contains this FOText.
*/
- public Block getAncestorBlock () {
- return ancestorBlock;
- }
+ //public Block getAncestorBlock () {
+ // return ancestorBlock;
+ //}
/**
* Determines whether the input char should be considered part of a
@@ -485,6 +515,9 @@ public class FOText extends FONode imple
private boolean canRemove = false;
private boolean canReplace = false;
+ public TextCharIterator() {
+ }
+
/** {@inheritDoc} */
public boolean hasNext() {
return (this.currentPosition < charBuffer.limit());
@@ -556,67 +589,88 @@ public class FOText extends FONode imple
}
/**
- * @return the "color" property.
+ * @return the "color" trait.
*/
public Color getColor() {
return color;
}
/**
- * @return the "keep-together" property.
+ * @return the "keep-together" trait.
*/
public KeepProperty getKeepTogether() {
return keepTogether;
}
/**
- * @return the "letter-spacing" property.
+ * @return the "letter-spacing" trait.
*/
public Property getLetterSpacing() {
return letterSpacing;
}
/**
- * @return the "line-height" property.
+ * @return the "line-height" trait.
*/
public SpaceProperty getLineHeight() {
return lineHeight;
}
/**
- * @return the "white-space-treatment" property
+ * @return the "white-space-treatment" trait
*/
public int getWhitespaceTreatment() {
return whiteSpaceTreatment;
}
/**
- * @return the "word-spacing" property.
+ * @return the "word-spacing" trait.
*/
public Property getWordSpacing() {
return wordSpacing;
}
/**
- * @return the "wrap-option" property.
+ * @return the "wrap-option" trait.
*/
public int getWrapOption() {
return wrapOption;
}
- /** @return the "text-decoration" property. */
+ /** @return the "text-decoration" trait. */
public CommonTextDecoration getTextDecoration() {
return textDecoration;
}
- /** @return the baseline-shift property */
+ /** @return the baseline-shift trait */
public Length getBaseLineShift() {
return baselineShift;
}
+ /** @return the country trait */
+ public String getCountry() {
+ return country;
+ }
+
+ /** @return the language trait */
+ public String getLanguage() {
+ return language;
+ }
+
+ /** @return the script trait */
+ public String getScript() {
+ return script;
+ }
+
/** {@inheritDoc} */
public String toString() {
- return (this.charBuffer == null) ? "" : this.charBuffer.toString();
+ if ( charBuffer == null ) {
+ return "";
+ } else {
+ CharBuffer cb = charBuffer.duplicate();
+ cb.rewind();
+ return cb.toString();
+ }
}
/** {@inheritDoc} */
@@ -640,29 +694,34 @@ public class FOText extends FONode imple
/** {@inheritDoc} */
public char charAt(int position) {
- return this.charBuffer.get(position);
+ return charBuffer.get(position);
}
/** {@inheritDoc} */
public CharSequence subSequence(int start, int end) {
- return this.charBuffer.subSequence(start, end);
+ return charBuffer.subSequence(start, end);
}
/** {@inheritDoc} */
public int length() {
- return this.charBuffer.limit();
+ return charBuffer.limit();
}
/**
* Resets the backing <code>java.nio.CharBuffer</code>
*/
public void resetBuffer() {
- if (this.charBuffer != null) {
- this.charBuffer.rewind();
+ if (charBuffer != null) {
+ charBuffer.rewind();
}
}
@Override
+ public boolean isDelimitedTextRangeBoundary ( int boundary ) {
+ return false;
+ }
+
+ @Override
public void setStructureTreeElement(StructureTreeElement structureTreeElement) {
this.structureTreeElement = structureTreeElement;
}
@@ -672,4 +731,192 @@ public class FOText extends FONode imple
return structureTreeElement;
}
+ /**
+ * Set bidirectional level over interval [start,end).
+ * @param level the resolved level
+ * @param start the starting index of interval
+ * @param end the ending index of interval
+ */
+ public void setBidiLevel ( int level, int start, int end ) {
+ if ( start < end ) {
+ if ( bidiLevels == null ) {
+ bidiLevels = new int [ length() ];
+ }
+ for ( int i = start, n = end; i < n; i++ ) {
+ bidiLevels [ i ] = level;
+ }
+ if ( parent != null ) {
+ ( (FObj) parent ).setBidiLevel ( level );
+ }
+ } else {
+ assert start < end;
+ }
+ }
+
+ /**
+ * Obtain bidirectional level of each character
+ * represented by this FOText.
+ * @return a (possibly empty) array of bidi levels or null
+ * in case no bidi levels have been assigned
+ */
+ public int[] getBidiLevels() {
+ return bidiLevels;
+ }
+
+ /**
+ * Obtain bidirectional level of each character over
+ * interval [start,end).
+ * @param start the starting index of interval
+ * @param end the ending index of interval
+ * @return a (possibly empty) array of bidi levels or null
+ * in case no bidi levels have been assigned
+ */
+ public int[] getBidiLevels ( int start, int end ) {
+ if ( this.bidiLevels != null ) {
+ assert start <= end;
+ int n = end - start;
+ int[] bidiLevels = new int [ n ];
+ for ( int i = 0; i < n; i++ ) {
+ bidiLevels[i] = this.bidiLevels [ start + i ];
+ }
+ return bidiLevels;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Obtain bidirectional level of character at
+ * specified position, which must be a non-negative integer
+ * less than the length of this FO.
+ * @param position an offset position into FO's characters
+ * @return a resolved bidi level or -1 if default
+ * @throws IndexOutOfBoundsException if position is not non-negative integer
+ * or is greater than or equal to length
+ */
+ public int bidiLevelAt ( int position ) throws IndexOutOfBoundsException {
+ if ( ( position < 0 ) || ( position >= length() ) ) {
+ throw new IndexOutOfBoundsException();
+ } else if ( bidiLevels != null ) {
+ return bidiLevels [ position ];
+ } else {
+ return -1;
+ }
+ }
+
+ /**
+ * Add characters mapped by script substitution processing.
+ * @param start index in character buffer
+ * @param end index in character buffer
+ * @param mappedChars sequence of character codes denoting substituted characters
+ */
+ public void addMapping ( int start, int end, CharSequence mappedChars ) {
+ if ( mappings == null ) {
+ mappings = new java.util.HashMap();
+ }
+ mappings.put ( new MapRange ( start, end ), mappedChars.toString() );
+ }
+
+ /**
+ * Determine if characters over specific interval have a mapping.
+ * @param start index in character buffer
+ * @param end index in character buffer
+ * @return true if a mapping exist such that the mapping's interval is coincident to
+ * [start,end)
+ */
+ public boolean hasMapping ( int start, int end ) {
+ return ( mappings != null ) && ( mappings.containsKey ( new MapRange ( start, end ) ) );
+ }
+
+ /**
+ * Obtain mapping of characters over specific interval.
+ * @param start index in character buffer
+ * @param end index in character buffer
+ * @return a string of characters representing the mapping over the interval
+ * [start,end)
+ */
+ public String getMapping ( int start, int end ) {
+ if ( mappings != null ) {
+ return (String) mappings.get ( new MapRange ( start, end ) );
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Obtain length of mapping of characters over specific interval.
+ * @param start index in character buffer
+ * @param end index in character buffer
+ * @return the length of the mapping (if present) or zero
+ */
+ public int getMappingLength ( int start, int end ) {
+ if ( mappings != null ) {
+ return ( (String) mappings.get ( new MapRange ( start, end ) ) ) .length();
+ } else {
+ return 0;
+ }
+ }
+
+ /**
+ * Obtain bidirectional levels of mapping of characters over specific interval.
+ * @param start index in character buffer
+ * @param end index in character buffer
+ * @return a (possibly empty) array of bidi levels or null
+ * in case no bidi levels have been assigned
+ */
+ public int[] getMappingBidiLevels ( int start, int end ) {
+ if ( hasMapping ( start, end ) ) {
+ int nc = end - start;
+ int nm = getMappingLength ( start, end );
+ int[] la = getBidiLevels ( start, end );
+ if ( la == null ) {
+ return null;
+ } else if ( nm == nc ) { // mapping is same length as mapped range
+ return la;
+ } else if ( nm > nc ) { // mapping is longer than mapped range
+ int[] ma = new int [ nm ];
+ System.arraycopy ( la, 0, ma, 0, la.length );
+ for ( int i = la.length,
+ n = ma.length, l = ( i > 0 ) ? la [ i - 1 ] : 0; i < n; i++ ) {
+ ma [ i ] = l;
+ }
+ return ma;
+ } else { // mapping is shorter than mapped range
+ int[] ma = new int [ nm ];
+ System.arraycopy ( la, 0, ma, 0, ma.length );
+ return ma;
+ }
+ } else {
+ return getBidiLevels ( start, end );
+ }
+ }
+
+ @Override
+ protected Stack collectDelimitedTextRanges ( Stack ranges, DelimitedTextRange currentRange ) {
+ if ( currentRange != null ) {
+ currentRange.append ( charIterator(), this );
+ }
+ return ranges;
+ }
+
+ private static class MapRange {
+ private int start;
+ private int end;
+ MapRange(int start, int end) {
+ this.start = start;
+ this.end = end;
+ }
+ public int hashCode() {
+ return ( start * 31 ) + end;
+ }
+ public boolean equals ( Object o ) {
+ if ( o instanceof MapRange ) {
+ MapRange r = (MapRange) o;
+ return ( r.start == start ) && ( r.end == end );
+ } else {
+ return false;
+ }
+ }
+ }
+
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FObj.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FObj.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FObj.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/FObj.java Sun Feb 26 02:29:01 2012
@@ -67,6 +67,8 @@ public abstract class FObj extends FONod
/** Markers added to this element. */
private Map markers = null;
+ private int bidiLevel = -1;
+
// The value of properties relevant for all fo objects
private String id = null;
// End of property values
@@ -118,9 +120,7 @@ public abstract class FObj extends FONod
throws FOPException {
setLocator(locator);
pList.addAttributesToList(attlist);
- if (!inMarker()
- || "marker".equals(elementName)) {
- pList.setWritingMode();
+ if (!inMarker() || "marker".equals(elementName)) {
bind(pList);
}
}
@@ -558,6 +558,63 @@ public abstract class FObj extends FONod
return "fo";
}
+ /** {@inheritDoc} */
+ public boolean isBidiRangeBlockItem() {
+ String ns = getNamespaceURI();
+ String ln = getLocalName();
+ return !isNeutralItem(ns, ln) && isBlockItem(ns, ln);
+ }
+
+ /**
+ * Recursively set resolved bidirectional level of FO (and its ancestors) if
+ * and only if it is non-negative and if either the current value is reset (-1)
+ * or the new value is less than the current value.
+ * @param bidiLevel a non-negative bidi embedding level
+ */
+ public void setBidiLevel(int bidiLevel) {
+ assert bidiLevel >= 0;
+ if ( bidiLevel >= 0 ) {
+ if ( ( this.bidiLevel < 0 ) || ( bidiLevel < this.bidiLevel ) ) {
+ this.bidiLevel = bidiLevel;
+ if ( parent != null ) {
+ FObj foParent = (FObj) parent;
+ int parentBidiLevel = foParent.getBidiLevel();
+ if ( ( parentBidiLevel < 0 ) || ( bidiLevel < parentBidiLevel ) ) {
+ foParent.setBidiLevel ( bidiLevel );
+ }
+ }
+ }
+ }
+ }
+
+ /**
+ * Obtain resolved bidirectional level of FO.
+ * @return either a non-negative bidi embedding level or -1
+ * in case no bidi levels have been assigned
+ */
+ public int getBidiLevel() {
+ return bidiLevel;
+ }
+
+ /**
+ * Obtain resolved bidirectional level of FO or nearest FO
+ * ancestor that has a resolved level.
+ * @return either a non-negative bidi embedding level or -1
+ * in case no bidi levels have been assigned to this FO or
+ * any ancestor
+ */
+ public int getBidiLevelRecursive() {
+ for ( FONode fn = this; fn != null; fn = fn.getParent() ) {
+ if ( fn instanceof FObj ) {
+ int level = ( (FObj) fn).getBidiLevel();
+ if ( level >= 0 ) {
+ return level;
+ }
+ }
+ }
+ return -1;
+ }
+
/**
* Add a new extension attachment to this FObj.
* (see org.apache.fop.fo.FONode for details)
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/PropertyList.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/PropertyList.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/PropertyList.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/PropertyList.java Sun Feb 26 02:29:01 2012
@@ -46,8 +46,6 @@ import org.apache.fop.fo.properties.Prop
*/
public abstract class PropertyList {
- // writing-mode index
- private int writingMode;
private static boolean[] inheritableProperty;
@@ -220,58 +218,60 @@ public abstract class PropertyList {
}
/**
- * Set writing mode for this FO.
- * Use that from the nearest ancestor, including self, which generates
- * reference areas, or from root FO if no ancestor found.
- * @throws PropertyException ...
- */
- public void setWritingMode() throws PropertyException {
- FObj p = fobj.findNearestAncestorFObj();
- // If this is a reference area or the root, use the property value.
- if (fobj.generatesReferenceAreas() || p == null) {
- writingMode = get(Constants.PR_WRITING_MODE).getEnum();
- } else {
- // Otherwise get the writing mode value from the parent.
- writingMode = getParentPropertyList().getWritingMode();
- }
- }
-
- /**
- * Return the "writing-mode" property value.
- * @return the "writing-mode" property value.
- */
- public int getWritingMode() {
- return writingMode;
- }
-
-
- /**
- * Uses the stored writingMode.
+ * Select a writing mode dependent property ID based on value of writing mode property.
* @param lrtb the property ID to return under lrtb writingmode.
* @param rltb the property ID to return under rltb writingmode.
* @param tbrl the property ID to return under tbrl writingmode.
+ * @param tblr the property ID to return under tblr writingmode.
* @return one of the property IDs, depending on the writing mode.
*/
- public int getWritingMode(int lrtb, int rltb, int tbrl) {
- switch (writingMode) {
- case Constants.EN_LR_TB: return lrtb;
- case Constants.EN_RL_TB: return rltb;
- case Constants.EN_TB_RL: return tbrl;
+ public int selectFromWritingMode(int lrtb, int rltb, int tbrl, int tblr) {
+ int propID;
+ try {
+ switch (get(Constants.PR_WRITING_MODE).getEnum()) {
+ case Constants.EN_LR_TB:
+ propID = lrtb;
+ break;
+ case Constants.EN_RL_TB:
+ propID = rltb;
+ break;
+ case Constants.EN_TB_RL:
+ propID = tbrl;
+ break;
+ case Constants.EN_TB_LR:
+ propID = tblr;
+ break;
default:
- //nop
+ propID = -1;
+ break;
+ }
+ } catch ( PropertyException e ) {
+ propID = -1;
}
- return -1;
+ return propID;
}
private String addAttributeToList(Attributes attributes,
String attributeName) throws ValidationException {
String attributeValue = attributes.getValue(attributeName);
- convertAttributeToProperty(attributes, attributeName, attributeValue);
+ if ( attributeValue != null ) {
+ convertAttributeToProperty(attributes, attributeName, attributeValue);
+ }
return attributeValue;
}
/**
- * Adds the attributes, passed in by the parser to the PropertyList
+ * <p>Adds the attributes, passed in by the parser to the PropertyList.</p>
+ * <p>Note that certain attributes are given priority in terms of order of
+ * processing due to conversion dependencies, where the order is as follows:</p>
+ * <ol>
+ * <li>writing-mode</li>
+ * <li>column-number</li>
+ * <li>number-columns-spanned</li>
+ * <li>font</li>
+ * <li>font-size</li>
+ * <li><emph>all others in order of appearance</emph></li>
+ * </ol>
*
* @param attributes Collection of attributes passed to us from the parser.
* @throws ValidationException if there is an attribute that does not
@@ -280,6 +280,11 @@ public abstract class PropertyList {
public void addAttributesToList(Attributes attributes)
throws ValidationException {
/*
+ * Give writing-mode highest conversion priority.
+ */
+ addAttributeToList(attributes, "writing-mode");
+
+ /*
* If column-number/number-columns-spanned are specified, then we
* need them before all others (possible from-table-column() on any
* other property further in the list...
@@ -300,9 +305,9 @@ public abstract class PropertyList {
addAttributeToList(attributes, "font-size");
}
+ String attributeNS;
String attributeName;
String attributeValue;
- String attributeNS;
FopFactory factory = getFObj().getUserAgent().getFactory();
for (int i = 0; i < attributes.getLength(); i++) {
/* convert all attributes with the same namespace as the fo element
@@ -646,4 +651,3 @@ public abstract class PropertyList {
return CommonTextDecoration.createFromPropertyList(this);
}
}
-
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/AbstractGraphics.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/AbstractGraphics.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/AbstractGraphics.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/AbstractGraphics.java Sun Feb 26 02:29:01 2012
@@ -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.Keep
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 e
// private int scalingMethod;
// End of property values
-
-
/**
* constructs an instream-foreign-object object (called by Maker).
*
@@ -250,4 +252,18 @@ public abstract class AbstractGraphics e
/** @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;
+ }
+
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/AbstractPageNumberCitation.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/AbstractPageNumberCitation.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/AbstractPageNumberCitation.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/AbstractPageNumberCitation.java Sun Feb 26 02:29:01 2012
@@ -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.Comm
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 AbstractPageNumber
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;
+ }
+
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/BidiOverride.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/BidiOverride.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/BidiOverride.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/BidiOverride.java Sun Feb 26 02:29:01 2012
@@ -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 {
+public class BidiOverride extends Inline {
- // 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
+ // 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 FObjMi
*/
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 FObjMi
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;
+ }
+
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/Block.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/Block.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/Block.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/Block.java Sun Feb 26 02:29:01 2012
@@ -54,7 +54,7 @@ public class Block extends FObjMixed imp
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 imp
// 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 imp
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 imp
}
}
- /** @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 imp
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 imp
* {@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 imp
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;
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/BlockContainer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/BlockContainer.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/BlockContainer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/BlockContainer.java Sun Feb 26 02:29:01 2012
@@ -31,14 +31,18 @@ import org.apache.fop.fo.properties.Comm
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
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
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
}
/**
- * @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
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} */
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/Character.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/Character.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/Character.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/Character.java Sun Feb 26 02:29:01 2012
@@ -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 impl
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;
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/InlineContainer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/InlineContainer.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/InlineContainer.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/InlineContainer.java Sun Feb 26 02:29:01 2012
@@ -33,6 +33,10 @@ import org.apache.fop.fo.properties.Comm
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.Spac
*/
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 FOb
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 FOb
// 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 FOb
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 FOb
}
}
- /** @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 FOb
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 FOb
return FO_INLINE_CONTAINER;
}
+ @Override
+ public boolean isDelimitedTextRangeBoundary ( int boundary ) {
+ return false;
+ }
+
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/InlineLevel.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/InlineLevel.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/InlineLevel.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/InlineLevel.java Sun Feb 26 02:29:01 2012
@@ -39,7 +39,7 @@ import org.apache.fop.fo.properties.Spac
*/
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 extend
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 extend
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;
+ }
+
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/Leader.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/Leader.java?rev=1293736&r1=1293735&r2=1293736&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/Leader.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/flow/Leader.java Sun Feb 26 02:29:01 2012
@@ -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;
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org