diff options
author | Glenn Adams <gadams@apache.org> | 2014-07-06 23:46:18 +0000 |
---|---|---|
committer | Glenn Adams <gadams@apache.org> | 2014-07-06 23:46:18 +0000 |
commit | 6ebc570ad4891b338192c2e2900424c8445efc86 (patch) | |
tree | 12db084b6a5acebab4467eac453f697a29f53752 /src/java/org | |
parent | e7015eb126ea5a302045a207e565edde4f239898 (diff) | |
download | xmlgraphics-fop-6ebc570ad4891b338192c2e2900424c8445efc86.tar.gz xmlgraphics-fop-6ebc570ad4891b338192c2e2900424c8445efc86.zip |
FOP 2388: Fix Arabic text left justified on the first cell of a table with writing mode rl-tb.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1608314 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org')
12 files changed, 49 insertions, 49 deletions
diff --git a/src/java/org/apache/fop/complexscripts/bidi/BidiResolver.java b/src/java/org/apache/fop/complexscripts/bidi/BidiResolver.java index f1a4d2a69..e458e781c 100644 --- a/src/java/org/apache/fop/complexscripts/bidi/BidiResolver.java +++ b/src/java/org/apache/fop/complexscripts/bidi/BidiResolver.java @@ -57,7 +57,17 @@ public final class BidiResolver { if (log.isDebugEnabled()) { log.debug("BD: RESOLVE: " + ps); } - List ranges = pruneEmptyRanges(ps.collectDelimitedTextRanges(new Stack())); + // 1. collect delimited text ranges + List ranges = ps.collectDelimitedTextRanges(new Stack()); + if (log.isDebugEnabled()) { + dumpRanges("BD: RESOLVE: RANGES:", ranges); + } + // 2. prune empty ranges + ranges = pruneEmptyRanges(ranges); + if (log.isDebugEnabled()) { + dumpRanges("BD: RESOLVE: PRUNED RANGES:", ranges); + } + // 3. resolve inline directionaly of unpruned ranges resolveInlineDirectionality(ranges); } @@ -223,8 +233,14 @@ public final class BidiResolver { log.debug(ir); } } - - private static List pruneEmptyRanges(Stack ranges) { + private static void dumpRanges(String header, List ranges) { + log.debug(header); + for (Iterator it = ranges.iterator(); it.hasNext(); ) { + DelimitedTextRange r = (DelimitedTextRange) it.next(); + log.debug(r); + } + } + private static List pruneEmptyRanges(List ranges) { Vector rv = new Vector(); for (Iterator it = ranges.iterator(); it.hasNext(); ) { DelimitedTextRange r = (DelimitedTextRange) it.next(); diff --git a/src/java/org/apache/fop/complexscripts/bidi/UnicodeBidiAlgorithm.java b/src/java/org/apache/fop/complexscripts/bidi/UnicodeBidiAlgorithm.java index 694cc9245..6b47450b7 100644 --- a/src/java/org/apache/fop/complexscripts/bidi/UnicodeBidiAlgorithm.java +++ b/src/java/org/apache/fop/complexscripts/bidi/UnicodeBidiAlgorithm.java @@ -38,7 +38,7 @@ public final class UnicodeBidiAlgorithm implements BidiConstants { /** * logging instance */ - private static final Log log = LogFactory.getLog(BidiResolver.class); + private static final Log log = LogFactory.getLog(UnicodeBidiAlgorithm.class); private UnicodeBidiAlgorithm() { } diff --git a/src/java/org/apache/fop/fo/FONode.java b/src/java/org/apache/fop/fo/FONode.java index e2b91b55c..c2c9940ca 100644 --- a/src/java/org/apache/fop/fo/FONode.java +++ b/src/java/org/apache/fop/fo/FONode.java @@ -936,7 +936,7 @@ public abstract class FONode implements Cloneable { * @param ranges a stack of delimited text ranges * @return the (possibly) updated stack of delimited text ranges */ - public Stack collectDelimitedTextRanges(Stack ranges) { + public Stack collectDelimitedTextRanges(Stack<DelimitedTextRange> ranges) { // if boundary before, then push new range if (isRangeBoundaryBefore()) { maybeNewRange(ranges); @@ -944,7 +944,7 @@ public abstract class FONode implements Cloneable { // get current range, if one exists DelimitedTextRange currentRange; if (ranges.size() > 0) { - currentRange = (DelimitedTextRange) ranges.peek(); + currentRange = ranges.peek(); } else { currentRange = null; } @@ -965,7 +965,7 @@ public abstract class FONode implements Cloneable { * @param currentRange the current range or null (if none) * @return the (possibly) updated stack of delimited text ranges */ - protected Stack collectDelimitedTextRanges(Stack ranges, DelimitedTextRange currentRange) { + protected Stack collectDelimitedTextRanges(Stack<DelimitedTextRange> ranges, DelimitedTextRange currentRange) { for (Iterator it = getChildNodes(); (it != null) && it.hasNext();) { ranges = ((FONode) it.next()).collectDelimitedTextRanges(ranges); } @@ -981,31 +981,18 @@ public abstract class FONode implements Cloneable { } /** - * Conditionally add a new delimited text range to RANGES, where new range is - * associated with current FONode. A new text range is added unless all of the following are - * true: - * <ul> - * <li>there exists a current range RCUR in RANGES</li> - * <li>RCUR is empty</li> - * <li>the node of the RCUR is the same node as FN or a descendent node of FN</li> - * </ul> + * Conditionally add a new delimited text range to RANGES. Always add new + * range unless there are no ranges on the stack yet and this node is not a block item. * @param ranges stack of delimited text ranges * @return new range (if constructed and pushed onto stack) or current range (if any) or null */ - private DelimitedTextRange maybeNewRange(Stack ranges) { - DelimitedTextRange rCur = null; // current range (top of range stack) - DelimitedTextRange rNew = null; // new range to be pushed onto range stack - if (ranges.empty()) { - if (isBidiRangeBlockItem()) { - rNew = new DelimitedTextRange(this); - } + private DelimitedTextRange maybeNewRange(Stack<DelimitedTextRange> ranges) { + DelimitedTextRange rCur = !ranges.empty() ? ranges.peek() : null; + DelimitedTextRange rNew; + if ((rCur != null) || isBidiRangeBlockItem()) { + rNew = new DelimitedTextRange(this); } else { - rCur = (DelimitedTextRange) ranges.peek(); - if (rCur != null) { - if (!rCur.isEmpty() || !isSelfOrDescendent(rCur.getNode(), this)) { - rNew = new DelimitedTextRange(this); - } - } + rNew = null; } if (rNew != null) { ranges.push(rNew); @@ -1024,18 +1011,6 @@ public abstract class FONode implements Cloneable { } /** - * Determine if node N2 is the same or a descendent of node N1. - */ - private static boolean isSelfOrDescendent(FONode n1, FONode n2) { - for (FONode n = n2; n != null; n = n.getParent()) { - if (n == n1) { - return true; - } - } - return false; - } - - /** * Base iterator interface over a FO's children */ public interface FONodeIterator extends ListIterator { diff --git a/src/java/org/apache/fop/fo/FOText.java b/src/java/org/apache/fop/fo/FOText.java index 0b7dde212..e32094907 100644 --- a/src/java/org/apache/fop/fo/FOText.java +++ b/src/java/org/apache/fop/fo/FOText.java @@ -802,7 +802,8 @@ public class FOText extends FONode implements CharSequence, TextFragment { } @Override - protected Stack collectDelimitedTextRanges(Stack ranges, DelimitedTextRange currentRange) { + protected Stack<DelimitedTextRange> collectDelimitedTextRanges(Stack<DelimitedTextRange> ranges, + DelimitedTextRange currentRange) { if (currentRange != null) { currentRange.append(charIterator(), this); } diff --git a/src/java/org/apache/fop/fo/flow/AbstractGraphics.java b/src/java/org/apache/fop/fo/flow/AbstractGraphics.java index 9d94644b9..34bf83fb4 100644 --- a/src/java/org/apache/fop/fo/flow/AbstractGraphics.java +++ b/src/java/org/apache/fop/fo/flow/AbstractGraphics.java @@ -259,7 +259,8 @@ public abstract class AbstractGraphics extends FObj } @Override - protected Stack collectDelimitedTextRanges(Stack ranges, DelimitedTextRange currentRange) { + protected Stack<DelimitedTextRange> collectDelimitedTextRanges(Stack<DelimitedTextRange> ranges, + DelimitedTextRange currentRange) { if (currentRange != null) { currentRange.append(CharUtilities.OBJECT_REPLACEMENT_CHARACTER, this); } diff --git a/src/java/org/apache/fop/fo/flow/AbstractPageNumberCitation.java b/src/java/org/apache/fop/fo/flow/AbstractPageNumberCitation.java index af6c5d316..f32ca5abd 100644 --- a/src/java/org/apache/fop/fo/flow/AbstractPageNumberCitation.java +++ b/src/java/org/apache/fop/fo/flow/AbstractPageNumberCitation.java @@ -206,7 +206,8 @@ public abstract class AbstractPageNumberCitation extends FObj } @Override - protected Stack collectDelimitedTextRanges(Stack ranges, DelimitedTextRange currentRange) { + protected Stack<DelimitedTextRange> collectDelimitedTextRanges(Stack<DelimitedTextRange> ranges, + DelimitedTextRange currentRange) { if (currentRange != null) { currentRange.append(CharUtilities.OBJECT_REPLACEMENT_CHARACTER, this); } diff --git a/src/java/org/apache/fop/fo/flow/BidiOverride.java b/src/java/org/apache/fop/fo/flow/BidiOverride.java index 9f0ea2470..7b20a0b87 100644 --- a/src/java/org/apache/fop/fo/flow/BidiOverride.java +++ b/src/java/org/apache/fop/fo/flow/BidiOverride.java @@ -97,7 +97,8 @@ public class BidiOverride extends Inline { } @Override - protected Stack collectDelimitedTextRanges(Stack ranges, DelimitedTextRange currentRange) { + protected Stack<DelimitedTextRange> collectDelimitedTextRanges(Stack<DelimitedTextRange> ranges, + DelimitedTextRange currentRange) { char pfx = 0; char sfx = 0; int unicodeBidi = getUnicodeBidi(); diff --git a/src/java/org/apache/fop/fo/flow/Character.java b/src/java/org/apache/fop/fo/flow/Character.java index e5f5dadd9..c075d8b7e 100644 --- a/src/java/org/apache/fop/fo/flow/Character.java +++ b/src/java/org/apache/fop/fo/flow/Character.java @@ -241,7 +241,8 @@ public class Character extends FObj implements StructureTreeElementHolder { } @Override - protected Stack collectDelimitedTextRanges(Stack ranges, DelimitedTextRange currentRange) { + protected Stack<DelimitedTextRange> collectDelimitedTextRanges(Stack<DelimitedTextRange> ranges, + DelimitedTextRange currentRange) { if (currentRange != null) { currentRange.append(charIterator(), this); } diff --git a/src/java/org/apache/fop/fo/flow/Leader.java b/src/java/org/apache/fop/fo/flow/Leader.java index 123da0c48..b4243f22e 100644 --- a/src/java/org/apache/fop/fo/flow/Leader.java +++ b/src/java/org/apache/fop/fo/flow/Leader.java @@ -203,7 +203,8 @@ public class Leader extends InlineLevel { } @Override - protected Stack collectDelimitedTextRanges(Stack ranges, DelimitedTextRange currentRange) { + protected Stack<DelimitedTextRange> collectDelimitedTextRanges(Stack<DelimitedTextRange> ranges, + DelimitedTextRange currentRange) { if (currentRange != null) { if (leaderPattern == EN_USECONTENT) { ranges = super.collectDelimitedTextRanges(ranges, currentRange); diff --git a/src/java/org/apache/fop/fo/flow/ListItem.java b/src/java/org/apache/fop/fo/flow/ListItem.java index b7f6e15cc..1f6973942 100644 --- a/src/java/org/apache/fop/fo/flow/ListItem.java +++ b/src/java/org/apache/fop/fo/flow/ListItem.java @@ -206,7 +206,8 @@ public class ListItem extends FObj implements BreakPropertySet, CommonAccessibil } @Override - protected Stack collectDelimitedTextRanges(Stack ranges, DelimitedTextRange currentRange) { + protected Stack<DelimitedTextRange> collectDelimitedTextRanges(Stack<DelimitedTextRange> ranges, + DelimitedTextRange currentRange) { ListItemLabel label = getLabel(); if (label != null) { ranges = label.collectDelimitedTextRanges(ranges); 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 e1252e45e..3389112d3 100644 --- a/src/java/org/apache/fop/fo/flow/table/Table.java +++ b/src/java/org/apache/fop/fo/flow/table/Table.java @@ -608,7 +608,8 @@ public class Table extends TableFObj implements ColumnNumberManagerHolder, Break } @Override - protected Stack collectDelimitedTextRanges(Stack ranges, DelimitedTextRange currentRange) { + protected Stack<DelimitedTextRange> collectDelimitedTextRanges(Stack<DelimitedTextRange> ranges, + DelimitedTextRange currentRange) { // header sub-tree TableHeader header = getTableHeader(); if (header != null) { diff --git a/src/java/org/apache/fop/fo/pagination/PageSequence.java b/src/java/org/apache/fop/fo/pagination/PageSequence.java index ba874d31f..bddc47fa3 100644 --- a/src/java/org/apache/fop/fo/pagination/PageSequence.java +++ b/src/java/org/apache/fop/fo/pagination/PageSequence.java @@ -416,7 +416,8 @@ public class PageSequence extends AbstractPageSequence implements WritingModeTra } @Override - protected Stack collectDelimitedTextRanges(Stack ranges, DelimitedTextRange currentRange) { + protected Stack<DelimitedTextRange> collectDelimitedTextRanges(Stack<DelimitedTextRange> ranges, + DelimitedTextRange currentRange) { // collect ranges from static content flows Map<String, FONode> flows = getFlowMap(); if (flows != null) { |