Author: gadams
Date: Thu Oct 23 07:36:33 2014
New Revision: 1633759

URL: http://svn.apache.org/r1633759
Log:
FOP-2420: ensure word area's bidi level is initialized when word is mapped to 
empty string, e.g., when controls are elided

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/area/inline/TextArea.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/area/inline/WordArea.java
    
xmlgraphics/fop/trunk/src/java/org/apache/fop/complexscripts/bidi/InlineRun.java
    
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java

Modified: 
xmlgraphics/fop/trunk/src/java/org/apache/fop/area/inline/TextArea.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/area/inline/TextArea.java?rev=1633759&r1=1633758&r2=1633759&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/area/inline/TextArea.java 
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/area/inline/TextArea.java Thu 
Oct 23 07:36:33 2014
@@ -91,7 +91,7 @@ public class TextArea extends AbstractTe
     public void addWord(
         String word, int ipd, int[] letterAdjust, int[] levels,
           int[][] gposAdjustments, int blockProgressionOffset) {
-        int minWordLevel = findMinLevel(levels);
+        int minWordLevel = findMinLevel(levels, getBidiLevel());
         WordArea wordArea = new WordArea(
             blockProgressionOffset, minWordLevel, word, letterAdjust, levels, 
gposAdjustments);
         wordArea.setIPD(ipd);
@@ -167,7 +167,7 @@ public class TextArea extends AbstractTe
         return sb.toString();
     }
 
-    private void updateLevel(int newLevel) {
+    public void updateLevel(int newLevel) {
         if (newLevel >= 0) {
             int curLevel = getBidiLevel();
             if (curLevel >= 0) {
@@ -180,7 +180,7 @@ public class TextArea extends AbstractTe
         }
     }
 
-    private static int findMinLevel(int[] levels) {
+    private static int findMinLevel(int[] levels, int defaultLevel) {
         if (levels != null) {
             int lMin = Integer.MAX_VALUE;
             for (int i = 0, n = levels.length; i < n; i++) {
@@ -195,7 +195,7 @@ public class TextArea extends AbstractTe
                 return lMin;
             }
         } else {
-            return -1;
+            return defaultLevel;
         }
     }
 

Modified: 
xmlgraphics/fop/trunk/src/java/org/apache/fop/area/inline/WordArea.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/area/inline/WordArea.java?rev=1633759&r1=1633758&r2=1633759&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/area/inline/WordArea.java 
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/area/inline/WordArea.java Thu 
Oct 23 07:36:33 2014
@@ -155,10 +155,11 @@ public class WordArea extends InlineArea
     public List collectInlineRuns(List runs) {
         assert runs != null;
         InlineRun r;
-        if (getBidiLevels() != null) {
-            r = new InlineRun(this, getBidiLevels());
+        int[] levels = getBidiLevels();
+        if ((levels != null) && (levels.length > 0)) {
+            r = new InlineRun(this, levels);
         } else {
-            r = new InlineRun(this, -1, word.length());
+            r = new InlineRun(this, getBidiLevel(), word.length());
         }
         runs.add(r);
         return runs;

Modified: 
xmlgraphics/fop/trunk/src/java/org/apache/fop/complexscripts/bidi/InlineRun.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/complexscripts/bidi/InlineRun.java?rev=1633759&r1=1633758&r2=1633759&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/src/java/org/apache/fop/complexscripts/bidi/InlineRun.java
 (original)
+++ 
xmlgraphics/fop/trunk/src/java/org/apache/fop/complexscripts/bidi/InlineRun.java
 Thu Oct 23 07:36:33 2014
@@ -293,7 +293,7 @@ public class InlineRun {
         return lb.toString();
     }
     private static int[] makeLevels(int level, int count) {
-        int[] levels = new int [ count ];
+        int[] levels = new int [ count > 0 ? count : 1 ];
         Arrays.fill(levels, level);
         return levels;
     }

Modified: 
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
URL: 
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java?rev=1633759&r1=1633758&r2=1633759&view=diff
==============================================================================
--- 
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
 (original)
+++ 
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
 Thu Oct 23 07:36:33 2014
@@ -443,6 +443,7 @@ public class TextLayoutManager extends L
             int wordCharLength = 0;
             for (int wordIndex = firstIndex; wordIndex <= lastIndex; 
wordIndex++) {
                 mapping = getGlyphMapping(wordIndex);
+                textArea.updateLevel(mapping.level);
                 if (mapping.isSpace) {
                     addSpaces();
                 } else {



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to