From: Glenn Adams Date: Sun, 6 Jul 2014 23:46:18 +0000 (+0000) Subject: FOP 2388: Fix Arabic text left justified on the first cell of a table with writing... X-Git-Tag: fop-2_0~105 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6ebc570ad4891b338192c2e2900424c8445efc86;p=xmlgraphics-fop.git 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 --- 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 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 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: - *
    - *
  • there exists a current range RCUR in RANGES
  • - *
  • RCUR is empty
  • - *
  • the node of the RCUR is the same node as FN or a descendent node of FN
  • - *
+ * 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 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); @@ -1023,18 +1010,6 @@ public abstract class FONode implements Cloneable { return isDelimitedTextRangeBoundary(Constants.EN_AFTER); } - /** - * 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 */ 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 collectDelimitedTextRanges(Stack 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 collectDelimitedTextRanges(Stack 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 collectDelimitedTextRanges(Stack 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 collectDelimitedTextRanges(Stack 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 collectDelimitedTextRanges(Stack 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 collectDelimitedTextRanges(Stack 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 collectDelimitedTextRanges(Stack 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 collectDelimitedTextRanges(Stack 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 collectDelimitedTextRanges(Stack ranges, + DelimitedTextRange currentRange) { // collect ranges from static content flows Map flows = getFlowMap(); if (flows != null) { diff --git a/status.xml b/status.xml index a54bab8e6..1b0495094 100644 --- a/status.xml +++ b/status.xml @@ -58,7 +58,10 @@ users, i.e. when the behaviour changes and could affect the layout of existing documents. Example: the fix of marks layering will be such a case when it's done. --> - + + + Fix Arabic text left justified on the first cell of a table with writing mode rl-tb. + Eliminate regression to shorthand properties from Bugzilla 37114 (FOP-1069). diff --git a/test/layoutengine/standard-testcases/table_jira2388.xml b/test/layoutengine/standard-testcases/table_jira2388.xml new file mode 100644 index 000000000..aea8ab5cd --- /dev/null +++ b/test/layoutengine/standard-testcases/table_jira2388.xml @@ -0,0 +1,64 @@ + + + + + +

+ This is a testcase for jira #2388: when a 2-row table with WM(rl-tb) is contained in a block + with WM(lr-tb), then content from both rows should, by default, use WM(rl-tb) from table. Prior + to fix, the first row was obtaining default WM(lr-tb) from the container block rather than table. +

+
+ + + + + + + + + + + + + + + + يرحب بكم ستاندرد تشارترد بنك و يتطلع لتقديم خدمات الحسابات المصرفية لكم + + + + + يرحب بكم ستاندرد تشارترد بنك و يتطلع لتقديم خدمات الحسابات المصرفية لكم + + + + + + + + + + + + + + + + +