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 vh...@apache.org on 2012/04/05 18:20:17 UTC

svn commit: r1309921 [24/42] - in /xmlgraphics/fop/branches/Temp_TrueTypeInPostScript: ./ examples/embedding/ examples/embedding/java/embedding/ examples/embedding/java/embedding/atxml/ examples/embedding/java/embedding/tools/ examples/plan/src/org/apa...

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/AbstractGraphicsLayoutManager.java Thu Apr  5 16:19:19 2012
@@ -24,7 +24,7 @@ import java.awt.Rectangle;
 import java.util.List;
 
 import org.apache.fop.area.Area;
-import org.apache.fop.area.inline.Viewport;
+import org.apache.fop.area.inline.InlineViewport;
 import org.apache.fop.datatypes.LengthBase;
 import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.flow.AbstractGraphics;
@@ -54,11 +54,12 @@ public abstract class AbstractGraphicsLa
      *
      * @return the viewport inline area
      */
-    private Viewport getInlineArea() {
+    private InlineViewport getInlineArea() {
         final AbstractGraphics fobj = (AbstractGraphics)this.fobj;
         Dimension intrinsicSize = new Dimension(
                 fobj.getIntrinsicWidth(),
                 fobj.getIntrinsicHeight());
+        int bidiLevel = fobj.getBidiLevel();
 
         //TODO Investigate if the line-height property has to be taken into the calculation
         //somehow. There was some code here that hints in this direction but it was disabled.
@@ -67,6 +68,7 @@ public abstract class AbstractGraphicsLa
         Rectangle placement = imageLayout.getPlacement();
 
         CommonBorderPaddingBackground borderProps = fobj.getCommonBorderPaddingBackground();
+        setCommonBorderPaddingBackground(borderProps);
 
         //Determine extra BPD from borders and padding
         int beforeBPD = borderProps.getPadding(CommonBorderPaddingBackground.BEFORE, false, this);
@@ -75,30 +77,35 @@ public abstract class AbstractGraphicsLa
         placement.y += beforeBPD;
 
         //Determine extra IPD from borders and padding
-        int startIPD = borderProps.getPadding(CommonBorderPaddingBackground.START, false, this);
-        startIPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.START, false);
-
-        placement.x += startIPD;
+        if ( ( bidiLevel == -1 ) || ( ( bidiLevel & 1 ) == 0 ) ) {
+            int startIPD = borderProps.getPadding(CommonBorderPaddingBackground.START, false, this);
+            startIPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.START, false);
+            placement.x += startIPD;
+        } else {
+            int endIPD = borderProps.getPadding(CommonBorderPaddingBackground.END, false, this);
+            endIPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.END, false);
+            placement.x += endIPD;
+        }
 
         Area viewportArea = getChildArea();
         TraitSetter.setProducerID(viewportArea, fobj.getId());
         transferForeignAttributes(viewportArea);
 
-        Viewport vp = new Viewport(viewportArea);
-        TraitSetter.addPtr(vp, fobj.getPtr());  // used for accessibility
+        InlineViewport vp = new InlineViewport(viewportArea, bidiLevel);
+        TraitSetter.addStructureTreeElement(vp, fobj.getStructureTreeElement());
         TraitSetter.setProducerID(vp, fobj.getId());
         vp.setIPD(imageLayout.getViewportSize().width);
         vp.setBPD(imageLayout.getViewportSize().height);
         vp.setContentPosition(placement);
         vp.setClip(imageLayout.isClipped());
-        vp.setOffset(0);
+        vp.setBlockProgressionOffset(0);
 
         // Common Border, Padding, and Background Properties
-        TraitSetter.addBorders(vp, fobj.getCommonBorderPaddingBackground()
+        TraitSetter.addBorders(vp, borderProps
                                 , false, false, false, false, this);
-        TraitSetter.addPadding(vp, fobj.getCommonBorderPaddingBackground()
+        TraitSetter.addPadding(vp, borderProps
                                 , false, false, false, false, this);
-        TraitSetter.addBackground(vp, fobj.getCommonBorderPaddingBackground(), this);
+        TraitSetter.addBackground(vp, borderProps, this);
 
         return vp;
     }
@@ -106,7 +113,7 @@ public abstract class AbstractGraphicsLa
     /** {@inheritDoc} */
     public List getNextKnuthElements(LayoutContext context,
                                            int alignment) {
-        Viewport areaCurrent = getInlineArea();
+        InlineViewport areaCurrent = getInlineArea();
         setCurrentArea(areaCurrent);
         return super.getNextKnuthElements(context, alignment);
     }

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/AbstractPageNumberCitationLayoutManager.java Thu Apr  5 16:19:19 2012
@@ -19,12 +19,10 @@
 
 package org.apache.fop.layoutmgr.inline;
 
-import org.apache.fop.area.PageViewport;
 import org.apache.fop.area.Resolvable;
 import org.apache.fop.area.Trait;
 import org.apache.fop.area.inline.InlineArea;
 import org.apache.fop.area.inline.TextArea;
-import org.apache.fop.area.inline.UnresolvedPageNumber;
 import org.apache.fop.fo.flow.AbstractPageNumberCitation;
 import org.apache.fop.fonts.Font;
 import org.apache.fop.fonts.FontInfo;
@@ -81,10 +79,7 @@ public abstract class AbstractPageNumber
     }
 
     /** {@inheritDoc} */
-    public InlineArea get(LayoutContext context) {
-        curArea = getPageNumberCitationInlineArea();
-        return curArea;
-    }
+    public abstract InlineArea get(LayoutContext context);
 
     /**
      * {@inheritDoc}
@@ -98,35 +93,6 @@ public abstract class AbstractPageNumber
     }
 
     /**
-     * If id can be resolved then simply return a text area, otherwise
-     * return a resolvable area
-     *
-     * @return a corresponding InlineArea
-     */
-    private InlineArea getPageNumberCitationInlineArea() {
-        PageViewport page = getPSLM().getFirstPVWithID(fobj.getRefId());
-        TextArea text;
-        if (page != null) {
-            String str = page.getPageNumberString();
-            // get page string from parent, build area
-            text = new TextArea();
-            int width = getStringWidth(str);
-            text.addWord(str, 0);
-            text.setIPD(width);
-            resolved = true;
-        } else {
-            resolved = false;
-            text = new UnresolvedPageNumber(fobj.getRefId(), font);
-            String str = "MMM"; // reserve three spaces for page number
-            int width = getStringWidth(str);
-            text.setIPD(width);
-        }
-        updateTextAreaTraits(text);
-
-        return text;
-    }
-
-    /**
      * Updates the traits for the generated text area.
      * @param text the text area
      */
@@ -136,7 +102,7 @@ public abstract class AbstractPageNumber
         text.setBaselineOffset(font.getAscender());
         TraitSetter.addFontTraits(text, font);
         text.addTrait(Trait.COLOR, fobj.getColor());
-        TraitSetter.addPtr(text, fobj.getPtr());   // used for accessibility
+        TraitSetter.addStructureTreeElement(text, fobj.getStructureTreeElement());
         TraitSetter.addTextDecoration(text, fobj.getTextDecoration());
     }
 
@@ -152,5 +118,12 @@ public abstract class AbstractPageNumber
         return width;
     }
 
+    /**
+     * @return bidi level governing abstract page number citation
+     */
+    protected int getBidiLevel() {
+        return fobj.getBidiLevel();
+    }
+
 }
 

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/AlignmentContext.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/AlignmentContext.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/AlignmentContext.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/AlignmentContext.java Thu Apr  5 16:19:19 2012
@@ -24,6 +24,7 @@ import org.apache.fop.datatypes.LengthBa
 import org.apache.fop.datatypes.SimplePercentBaseContext;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fonts.Font;
+import org.apache.fop.traits.WritingMode;
 
 /**
  * The alignment context is carried within a LayoutContext and as
@@ -32,21 +33,27 @@ import org.apache.fop.fonts.Font;
  */
 public class AlignmentContext implements Constants {
 
-    /** The height or BPD of this context */
+    /** The height or BPD of this context. */
     private int areaHeight;
-    /** The computed line-height property value applicable */
+
+    /** The computed line-height property value applicable. */
     private int lineHeight;
-    /** The distance in BPD from the top of the box to the alignmentPoint */
+
+    /** The distance in BPD from the top of the box to the alignmentPoint. */
     private int alignmentPoint;
-    /** The baseline shift value in effect */
+
+    /** The baseline shift value in effect. */
     private int baselineShiftValue;
-    /** The computed alignment baseline identifier */
+
+    /** The computed alignment baseline identifier. */
     private int alignmentBaselineIdentifier;
-    /** The x height */
+
+    /** The x height. */
     private int xHeight;
-    private ScaledBaselineTable scaledBaselineTable = null;
-    private ScaledBaselineTable actualBaselineTable = null;
-    private AlignmentContext parentAlignmentContext = null;
+
+    private ScaledBaselineTable scaledBaselineTable;
+    private ScaledBaselineTable actualBaselineTable;
+    private AlignmentContext parentAlignmentContext;
 
     /**
      * Creates a new instance of AlignmentContext
@@ -58,57 +65,20 @@ public class AlignmentContext implements
      * @param dominantBaseline the dominant-baseline property
      * @param parentAlignmentContext the parent alignment context
      */
-    public AlignmentContext(int height
-                            , Length alignmentAdjust
-                            , int alignmentBaseline
-                            , Length baselineShift
-                            , int dominantBaseline
-                            , AlignmentContext parentAlignmentContext) {
-
-        this.areaHeight = height;
-        this.lineHeight = height;
-        this.xHeight = height;
-        this.parentAlignmentContext = parentAlignmentContext;
-        this.scaledBaselineTable = parentAlignmentContext.getScaledBaselineTable();
-        setAlignmentBaselineIdentifier(alignmentBaseline
-                                       , parentAlignmentContext.getDominantBaselineIdentifier());
-        setBaselineShift(baselineShift);
-        int dominantBaselineIdentifier = parentAlignmentContext.getDominantBaselineIdentifier();
-        boolean newScaledBaselineTableRequired = false;
-        if (baselineShiftValue != 0) {
-            newScaledBaselineTableRequired = true;
-        }
-        switch (dominantBaseline) {
-            case EN_AUTO:
-                newScaledBaselineTableRequired = baselineShiftValue != 0;
-                break;
-            case EN_USE_SCRIPT: // TODO
-                break;
-            case EN_NO_CHANGE:
-                break;
-            case EN_RESET_SIZE:
-                newScaledBaselineTableRequired = true;
-                break;
-            default:
-                newScaledBaselineTableRequired = true;
-                dominantBaselineIdentifier = dominantBaseline;
-                break;
-        }
-        actualBaselineTable = ScaledBaselineTableFactory.makeGraphicsScaledBaselineTable(
-                                                            height,
-                                                            dominantBaselineIdentifier,
-                                                            scaledBaselineTable.getWritingMode());
-        if (newScaledBaselineTableRequired) {
-            scaledBaselineTable = ScaledBaselineTableFactory.makeGraphicsScaledBaselineTable(
-                                                            height,
-                                                            dominantBaselineIdentifier,
-                                                            scaledBaselineTable.getWritingMode());
-        }
-        setAlignmentAdjust(alignmentAdjust);
+    AlignmentContext(int height,
+            Length alignmentAdjust,
+            int alignmentBaseline,
+            Length baselineShift,
+            int dominantBaseline,
+            AlignmentContext parentAlignmentContext) {
+
+        this(height, 0, height, height, alignmentAdjust, alignmentBaseline, baselineShift,
+                dominantBaseline, parentAlignmentContext);
     }
 
     /**
-     * Creates a new instance of AlignmentContext
+     * Creates a new instance.
+     *
      * @param font the font
      * @param lineHeight the computed value of the lineHeight property
      * @param alignmentAdjust the alignment-adjust property
@@ -117,18 +87,45 @@ public class AlignmentContext implements
      * @param dominantBaseline the dominant-baseline property
      * @param parentAlignmentContext the parent alignment context
      */
-    public AlignmentContext(Font font
-                            , int lineHeight
-                            , Length alignmentAdjust
-                            , int alignmentBaseline
-                            , Length baselineShift
-                            , int dominantBaseline
-                            , AlignmentContext parentAlignmentContext) {
-        this.areaHeight = font.getAscender() - font.getDescender();
+    AlignmentContext(Font font,
+            int lineHeight,
+            Length alignmentAdjust,
+            int alignmentBaseline,
+            Length baselineShift,
+            int dominantBaseline,
+            AlignmentContext parentAlignmentContext) {
+        this(font.getAscender(), font.getDescender(), lineHeight, font.getXHeight(),
+                alignmentAdjust, alignmentBaseline, baselineShift, dominantBaseline,
+                parentAlignmentContext);
+    }
+
+    /**
+     * Creates a new instance of AlignmentContext.
+     * @param altitude the altitude of the area
+     * @param depth the depth of the area
+     * @param lineHeight the line height
+     * @param xHeight the xHeight
+     * @param alignmentAdjust the alignment-adjust property
+     * @param alignmentBaseline the alignment-baseline property
+     * @param baselineShift the baseline-shift property
+     * @param dominantBaseline the dominant-baseline property
+     * @param parentAlignmentContext the parent alignment context
+     */
+    private AlignmentContext(int altitude,                              // CSOK: ParameterNumber
+            int depth,
+            int lineHeight,
+            int xHeight,
+            Length alignmentAdjust,
+            int alignmentBaseline,
+            Length baselineShift,
+            int dominantBaseline,
+            AlignmentContext parentAlignmentContext) {
+
+        this.areaHeight = altitude - depth;
         this.lineHeight = lineHeight;
+        this.xHeight = xHeight;
         this.parentAlignmentContext = parentAlignmentContext;
         this.scaledBaselineTable = parentAlignmentContext.getScaledBaselineTable();
-        this.xHeight = font.getXHeight();
         setAlignmentBaselineIdentifier(alignmentBaseline
                                        , parentAlignmentContext.getDominantBaselineIdentifier());
         setBaselineShift(baselineShift);
@@ -153,13 +150,19 @@ public class AlignmentContext implements
                 dominantBaselineIdentifier = dominantBaseline;
                 break;
         }
-        actualBaselineTable = ScaledBaselineTableFactory.makeFontScaledBaselineTable(font,
-                                                            dominantBaselineIdentifier,
-                                                            scaledBaselineTable.getWritingMode());
+        actualBaselineTable = new ScaledBaselineTable(
+                altitude,
+                depth,
+                xHeight,
+                dominantBaselineIdentifier,
+                scaledBaselineTable.getWritingMode());
         if (newScaledBaselineTableRequired) {
-            scaledBaselineTable = ScaledBaselineTableFactory.makeFontScaledBaselineTable(font,
-                                    dominantBaselineIdentifier,
-                                    scaledBaselineTable.getWritingMode());
+            scaledBaselineTable = new ScaledBaselineTable(
+                    altitude,
+                    depth,
+                    xHeight,
+                    dominantBaselineIdentifier,
+                    scaledBaselineTable.getWritingMode());
         }
         setAlignmentAdjust(alignmentAdjust);
     }
@@ -171,13 +174,12 @@ public class AlignmentContext implements
      * @param lineHeight the computed value of the lineHeight property
      * @param writingMode the current writing mode
      */
-    public AlignmentContext(Font font, int lineHeight, int writingMode) {
+    AlignmentContext(Font font, int lineHeight, WritingMode writingMode) {
         this.areaHeight = font.getAscender() - font.getDescender();
         this.lineHeight = lineHeight;
         this.xHeight = font.getXHeight();
-        this.parentAlignmentContext = null;
-        this.scaledBaselineTable
-                    = ScaledBaselineTableFactory.makeFontScaledBaselineTable(font, writingMode);
+        this.scaledBaselineTable = new ScaledBaselineTable(font.getAscender(), font.getDescender(),
+                font.getXHeight(), Constants.EN_ALPHABETIC, writingMode);
         this.actualBaselineTable = scaledBaselineTable;
         this.alignmentBaselineIdentifier = getDominantBaselineIdentifier();
         this.alignmentPoint = font.getAscender();
@@ -203,7 +205,8 @@ public class AlignmentContext implements
     }
 
     /**
-     * Returns the current alignment baseline identifier
+     * Returns the current alignment baseline identifier.
+     *
      * @return the alignment baseline identifier
      */
     public int getAlignmentBaselineIdentifier() {
@@ -211,7 +214,7 @@ public class AlignmentContext implements
     }
 
     /**
-     * Sets the current alignment baseline identifer. For
+     * Sets the current alignment baseline identifier. For
      * alignment-baseline values of "auto" and "baseline" this
      * method does the conversion into the appropriate computed
      * value assuming script is "auto" and the fo is not fo:character.
@@ -237,8 +240,7 @@ public class AlignmentContext implements
             case EN_MATHEMATICAL:
                 this.alignmentBaselineIdentifier = alignmentBaseline;
                 break;
-            default:
-                break;
+            default: throw new IllegalArgumentException(String.valueOf(alignmentBaseline));
         }
     }
 
@@ -285,7 +287,7 @@ public class AlignmentContext implements
      * Return the scaled baseline table for this context.
      * @return the scaled baseline table
      */
-    public ScaledBaselineTable getScaledBaselineTable() {
+    private ScaledBaselineTable getScaledBaselineTable() {
         return this.scaledBaselineTable;
     }
 
@@ -293,17 +295,17 @@ public class AlignmentContext implements
      * Return the dominant baseline identifier.
      * @return the dominant baseline identifier
      */
-    public int getDominantBaselineIdentifier() {
-        return scaledBaselineTable.getDominantBaselineIdentifier();
+    private int getDominantBaselineIdentifier() {
+        return actualBaselineTable.getDominantBaselineIdentifier();
     }
 
     /**
      * Return the writing mode.
      * @return the writing mode
      */
-    public int getWritingMode() {
+/*    public WritingMode getWritingMode() {
         return scaledBaselineTable.getWritingMode();
-    }
+    }*/
 
     /**
      * Calculates the baseline shift value based on the baseline-shift
@@ -312,7 +314,6 @@ public class AlignmentContext implements
      */
     private void setBaselineShift(Length baselineShift) {
         baselineShiftValue = 0;
-        ScaledBaselineTable sbt = null;
         switch (baselineShift.getEnum()) {
             case EN_BASELINE: //Nothing to do
                 break;
@@ -332,9 +333,7 @@ public class AlignmentContext implements
                                                 , LengthBase.CUSTOM_BASE
                                                 , parentAlignmentContext.getLineHeight()));
                 break;
-            default:
-                break;
-
+            default: throw new IllegalArgumentException(String.valueOf(baselineShift.getEnum()));
         }
     }
 
@@ -351,7 +350,7 @@ public class AlignmentContext implements
      * the parent dominant baseline.
      * @return the offset in shift direction
      */
-    public int getBaselineOffset() {
+    private int getBaselineOffset() {
         if (parentAlignmentContext == null) {
             return 0;
         }
@@ -370,9 +369,9 @@ public class AlignmentContext implements
     /**
      * Return the offset between the current dominant baseline and
      * the outermost parent dominant baseline.
-     * @return the offet in shift direction
+     * @return the offset in shift direction
      */
-    public int getTotalBaselineOffset() {
+    private int getTotalBaselineOffset() {
         int offset = 0;
         if (parentAlignmentContext != null) {
             offset = getBaselineOffset() + parentAlignmentContext.getTotalBaselineOffset();
@@ -395,7 +394,7 @@ public class AlignmentContext implements
      * @param alignmentBaselineId the alignment baseline
      * @return the offset
      */
-    public int getTotalAlignmentBaselineOffset(int alignmentBaselineId) {
+    private int getTotalAlignmentBaselineOffset(int alignmentBaselineId) {
         int offset = baselineShiftValue;
         if (parentAlignmentContext != null) {
             offset = parentAlignmentContext.getTotalBaselineOffset()
@@ -408,11 +407,12 @@ public class AlignmentContext implements
 
     /**
      * Return the offset between the dominant baseline and
-     * the given actual baseline
+     * the given actual baseline.
+     *
      * @param baselineIdentifier the baseline
      * @return the offset
      */
-    public int getActualBaselineOffset(int baselineIdentifier) {
+    private int getActualBaselineOffset(int baselineIdentifier) {
         // This is the offset from the dominant baseline to the alignment baseline
         int offset = getTotalAlignmentBaselineOffset() - getTotalBaselineOffset();
         // Add the offset to the actual baseline we want
@@ -443,7 +443,7 @@ public class AlignmentContext implements
      * Return the line height of the context.
      * @return the height
      */
-    public int getLineHeight() {
+    private int getLineHeight() {
         return lineHeight;
     }
 
@@ -469,7 +469,7 @@ public class AlignmentContext implements
      * The x height of the context.
      * @return the x height
      */
-    public int getXHeight() {
+    private int getXHeight() {
         return this.xHeight;
     }
 
@@ -513,18 +513,18 @@ public class AlignmentContext implements
                     && parentAlignmentContext.usesInitialBaselineTable());
     }
 
-    private boolean isHorizontalWritingMode() {
-        return (getWritingMode() == EN_LR_TB || getWritingMode() == EN_RL_TB);
-    }
+    /* private boolean isHorizontalWritingMode() {
+        return (getWritingMode() == WritingMode.LR_TB || getWritingMode() == WritingMode.RL_TB);
+    }*/
 
     /** {@inheritDoc} */
     public String toString() {
         StringBuffer sb = new StringBuffer(64);
-        sb.append("areaHeight=" + areaHeight);
-        sb.append(" lineHeight=" + lineHeight);
-        sb.append(" alignmentPoint=" + alignmentPoint);
-        sb.append(" alignmentBaselineID=" + alignmentBaselineIdentifier);
-        sb.append(" baselineShift=" + baselineShiftValue);
+        sb.append("areaHeight=").append(areaHeight);
+        sb.append(" lineHeight=").append(lineHeight);
+        sb.append(" alignmentPoint=").append(alignmentPoint);
+        sb.append(" alignmentBaselineID=").append(alignmentBaselineIdentifier);
+        sb.append(" baselineShift=").append(baselineShiftValue);
         return sb.toString();
     }
 

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/BasicLinkLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/BasicLinkLayoutManager.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/BasicLinkLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/BasicLinkLayoutManager.java Thu Apr  5 16:19:19 2012
@@ -21,7 +21,9 @@ package org.apache.fop.layoutmgr.inline;
 
 import org.apache.fop.area.LinkResolver;
 import org.apache.fop.area.Trait;
+import org.apache.fop.area.inline.BasicLinkArea;
 import org.apache.fop.area.inline.InlineArea;
+import org.apache.fop.area.inline.InlineParent;
 import org.apache.fop.datatypes.URISpecification;
 import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.flow.BasicLink;
@@ -57,7 +59,7 @@ public class BasicLinkLayoutManager exte
     private void setupBasicLinkArea(InlineArea area) {
         BasicLink fobj = (BasicLink) this.fobj;
         // internal destinations take precedence:
-        TraitSetter.addPtr(area, fobj.getPtr()); // used for accessibility
+        TraitSetter.addStructureTreeElement(area, fobj.getStructureTreeElement());
         if (fobj.hasInternalDestination()) {
             String idref = fobj.getInternalDestination();
             PageSequenceLayoutManager pslm = getPSLM();
@@ -67,6 +69,12 @@ public class BasicLinkLayoutManager exte
             res.resolveIDRef(idref, pslm.getFirstPVWithID(idref));
             if (!res.isResolved()) {
                 pslm.addUnresolvedArea(idref, res);
+                if ( area instanceof BasicLinkArea ) {
+                    // establish back-pointer from BasicLinkArea to LinkResolver to
+                    // handle inline area unflattening during line bidi reordering;
+                    // needed to create internal link trait on synthesized basic link area
+                    ((BasicLinkArea)area).setResolver(res);
+                }
             }
         } else if (fobj.hasExternalDestination()) {
             String url = URISpecification.getURL(fobj.getExternalDestination());
@@ -77,4 +85,10 @@ public class BasicLinkLayoutManager exte
             }
         }
     }
+
+    @Override
+    protected InlineParent createInlineParent() {
+        return new BasicLinkArea();
+    }
+
 }

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/BidiLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/BidiLayoutManager.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/BidiLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/BidiLayoutManager.java Thu Apr  5 16:19:19 2012
@@ -19,56 +19,19 @@
 
 package org.apache.fop.layoutmgr.inline;
 
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.fop.area.inline.InlineArea;
 import org.apache.fop.fo.flow.BidiOverride;
 
-
 /**
- * If this bidi has a different writing mode direction
- * ltr or rtl than its parent writing mode then this
- * reverses the inline areas (at the character level).
+ * Layout manager for fo:bidi-override.
  */
-public class BidiLayoutManager extends LeafNodeLayoutManager {
-
-    private List children;
+public class BidiLayoutManager extends InlineLayoutManager {
 
     /**
      * Construct bidi layout manager.
-     * @param node bidi override FO
-     * @param cLM parent layout manager
+     * @param node an BidiOverride FONode
      */
-    public BidiLayoutManager(BidiOverride node, InlineLayoutManager cLM) {
+    public BidiLayoutManager(BidiOverride node) {
         super(node);
-        setParent(cLM);
-        children = new ArrayList();
-/*
-        for (int count = cLM.size() - 1; count >= 0; count--) {
-            InlineArea ia = cLM.get(count);
-            if (ia instanceof Word) {
-                // reverse word
-                Word word = (Word) ia;
-                StringBuffer sb = new StringBuffer(word.getWord());
-                word.setWord(sb.reverse().toString());
-            }
-            children.add(ia);
-        }
-*/
-    }
-
-    /** @return number of children */
-    public int size() {
-        return children.size();
-    }
-
-    /**
-     * @param index of child inline area
-     * @return a child inline area
-     */
-    public InlineArea get(int index) {
-        return (InlineArea) children.get(index);
     }
 
 }

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java Thu Apr  5 16:19:19 2012
@@ -60,6 +60,7 @@ public class CharacterLayoutManager exte
     }
 
     /** {@inheritDoc} */
+    @Override
     public void initialize() {
         Character fobj = (Character)this.fobj;
         font = FontSelector.selectFontForCharacter(fobj, this);
@@ -76,21 +77,27 @@ public class CharacterLayoutManager exte
     private TextArea getCharacterInlineArea(Character node) {
         TextArea text = new TextArea();
         char ch = node.getCharacter();
+        int ipd = font.getCharWidth(ch);
+        int blockProgressionOffset = 0;
+        int level = node.getBidiLevel();
         if (CharUtilities.isAnySpace(ch)) {
             // add space unless it's zero-width:
             if (!CharUtilities.isZeroWidthSpace(ch)) {
-                text.addSpace(ch, 0, CharUtilities.isAdjustableSpace(ch));
+                text.addSpace(ch, ipd, CharUtilities.isAdjustableSpace(ch),
+                              blockProgressionOffset, level);
             }
         } else {
-            text.addWord(String.valueOf(ch), 0);
+            int[] levels = ( level >= 0 ) ? new int[] {level} : null;
+            text.addWord(String.valueOf(ch), ipd, null, levels, null, blockProgressionOffset);
         }
         TraitSetter.setProducerID(text, node.getId());
         TraitSetter.addTextDecoration(text, node.getTextDecoration());
-        TraitSetter.addPtr(text, node.getPtr()); // used for accessibility
+        TraitSetter.addStructureTreeElement(text, node.getStructureTreeElement());
         return text;
     }
 
     /** {@inheritDoc} */
+    @Override
     public List getNextKnuthElements(LayoutContext context, int alignment) {
         MinOptMax ipd;
         curArea = get(context);
@@ -103,9 +110,8 @@ public class CharacterLayoutManager exte
 
         Character fobj = (Character)this.fobj;
 
-        ipd = MinOptMax.getInstance(font.getCharWidth(fobj.getCharacter()));
+        ipd = MinOptMax.getInstance(curArea.getIPD());
 
-        curArea.setIPD(ipd.getOpt());
         curArea.setBPD(font.getAscender() - font.getDescender());
 
         TraitSetter.addFontTraits(curArea, font);
@@ -147,23 +153,25 @@ public class CharacterLayoutManager exte
 
         addKnuthElementsForBorderPaddingEnd(seq);
 
-        LinkedList returnList = new LinkedList();
+        LinkedList<KnuthSequence> returnList = new LinkedList<KnuthSequence>();
         returnList.add(seq);
         setFinished(true);
         return returnList;
     }
 
     /** {@inheritDoc} */
+    @Override
     public String getWordChars(Position pos) {
         return ((TextArea) curArea).getText();
     }
 
     /** {@inheritDoc} */
+    @Override
     public void hyphenate(Position pos, HyphContext hc) {
         if (hc.getNextHyphPoint() == 1) {
             // the character ends a syllable
-            areaInfo.bHyphenated = true;
-            isSomethingChanged = true;
+            areaInfo.isHyphenated = true;
+            somethingChanged = true;
         } else {
             // hc.getNextHyphPoint() returned -1 (no more hyphenation points)
             // or a number > 1;
@@ -173,42 +181,44 @@ public class CharacterLayoutManager exte
     }
 
     /** {@inheritDoc} */
+    @Override
     public boolean applyChanges(List oldList) {
         setFinished(false);
-        return isSomethingChanged;
+        return somethingChanged;
     }
 
     /** {@inheritDoc} */
+    @Override
     public List getChangedKnuthElements(List oldList, int alignment) {
         if (isFinished()) {
             return null;
         }
 
-        LinkedList returnList = new LinkedList();
+        LinkedList<KnuthElement> returnList = new LinkedList<KnuthElement>();
 
         addKnuthElementsForBorderPaddingStart(returnList);
 
-        if (letterSpaceIPD.isStiff() || areaInfo.iLScount == 0) {
+        if (letterSpaceIPD.isStiff() || areaInfo.letterSpaces == 0) {
             // constant letter space, or no letter space
             returnList.add(new KnuthInlineBox(areaInfo.ipdArea.getOpt(),
                                         areaInfo.alignmentContext,
                                         notifyPos(new LeafPosition(this, 0)), false));
-            if (areaInfo.bHyphenated) {
+            if (areaInfo.isHyphenated) {
                 returnList.add(new KnuthPenalty(hyphIPD, KnuthPenalty.FLAGGED_PENALTY, true,
                         new LeafPosition(this, -1), false));
             }
         } else {
             // adjustable letter space
             returnList.add(new KnuthInlineBox(areaInfo.ipdArea.getOpt()
-                    - areaInfo.iLScount * letterSpaceIPD.getOpt(), areaInfo.alignmentContext,
+                    - areaInfo.letterSpaces * letterSpaceIPD.getOpt(), areaInfo.alignmentContext,
                     notifyPos(new LeafPosition(this, 0)), false));
             returnList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false,
                     new LeafPosition(this, -1), true));
-            returnList.add(new KnuthGlue(letterSpaceIPD.mult(areaInfo.iLScount),
+            returnList.add(new KnuthGlue(letterSpaceIPD.mult(areaInfo.letterSpaces),
                     new LeafPosition(this, -1), true));
             returnList.add (
                     new KnuthInlineBox(0, null, notifyPos(new LeafPosition(this, -1)), true));
-            if (areaInfo.bHyphenated) {
+            if (areaInfo.isHyphenated) {
                 returnList.add(new KnuthPenalty(hyphIPD, KnuthPenalty.FLAGGED_PENALTY, true,
                         new LeafPosition(this, -1), false));
             }
@@ -221,4 +231,3 @@ public class CharacterLayoutManager exte
     }
 
 }
-

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java Thu Apr  5 16:19:19 2012
@@ -292,14 +292,9 @@ public class ContentLayoutManager extend
         return oldList;
     }
 
-    /**
-     * Remove the word space represented by the given elements
-     *
-     * @param oldList the elements representing the word space
-     */
-    public void removeWordSpace(List oldList) {
-        // do nothing
-        log.warn(this.getClass().getName() + " should not receive a call to removeWordSpace(list)");
+    /** {@inheritDoc} */
+    public List addALetterSpaceTo(List oldList, int depth) {
+        return addALetterSpaceTo(oldList);
     }
 
     /** {@inheritDoc} */
@@ -317,13 +312,21 @@ public class ContentLayoutManager extend
     }
 
     /** {@inheritDoc} */
-    public List getChangedKnuthElements(List oldList,
-                                              /*int flaggedPenalty,*/
-                                              int alignment) {
+    public boolean applyChanges(List oldList, int depth) {
+        return applyChanges(oldList);
+    }
+
+    /** {@inheritDoc} */
+    public List getChangedKnuthElements(List oldList, int alignment) {
         return null;
     }
 
     /** {@inheritDoc} */
+    public List getChangedKnuthElements(List oldList, int alignment, int depth) {
+        return getChangedKnuthElements(oldList, alignment);
+    }
+
+    /** {@inheritDoc} */
     public PageSequenceLayoutManager getPSLM() {
         return parentLM.getPSLM();
     }

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.java Thu Apr  5 16:19:19 2012
@@ -25,6 +25,7 @@ import java.util.ListIterator;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+
 import org.apache.fop.fo.flow.Footnote;
 import org.apache.fop.layoutmgr.FootnoteBodyLayoutManager;
 import org.apache.fop.layoutmgr.InlineKnuthSequence;
@@ -34,6 +35,7 @@ import org.apache.fop.layoutmgr.LayoutCo
 import org.apache.fop.layoutmgr.LayoutManager;
 import org.apache.fop.layoutmgr.ListElement;
 import org.apache.fop.layoutmgr.NonLeafPosition;
+import org.apache.fop.layoutmgr.Position;
 import org.apache.fop.layoutmgr.PositionIterator;
 
 /**
@@ -62,6 +64,7 @@ public class FootnoteLayoutManager exten
     }
 
     /** {@inheritDoc} */
+    @Override
     public void initialize() {
         // create an InlineStackingLM handling the fo:inline child of fo:footnote
         citationLM = new InlineLayoutManager(footnote.getFootnoteCitation());
@@ -71,6 +74,7 @@ public class FootnoteLayoutManager exten
     }
 
     /** {@inheritDoc} */
+    @Override
     public List getNextKnuthElements(LayoutContext context,
                                            int alignment) {
         // for the moment, this LM is set as the citationLM's parent
@@ -119,27 +123,24 @@ public class FootnoteLayoutManager exten
         return returnedList;
     }
 
-    /**
-     * {@inheritDoc}
-     */
-    public List getChangedKnuthElements(List oldList,
-                                              int alignment) {
-        List returnedList = super.getChangedKnuthElements(oldList, alignment);
+    /** {@inheritDoc} */
+    @Override
+    public List getChangedKnuthElements(List oldList, int alignment, int depth) {
+        List returnedList = super.getChangedKnuthElements(oldList, alignment, depth);
         addAnchor(returnedList);
         return returnedList;
     }
 
 
-    /**
-     * {@inheritDoc}
-     */
+    /** {@inheritDoc} */
+    @Override
     public void addAreas(PositionIterator posIter, LayoutContext context) {
         // "Unwrap" the NonLeafPositions stored in posIter and put
         // them in a new list, that will be given to the citationLM
-        LinkedList positionList = new LinkedList();
-        NonLeafPosition pos = null;
+        LinkedList<Position> positionList = new LinkedList<Position>();
+        Position pos;
         while (posIter.hasNext()) {
-            pos = (NonLeafPosition) posIter.next();
+            pos = posIter.next();
             if (pos != null && pos.getPosition() != null) {
                 positionList.add(pos.getPosition());
             }
@@ -151,7 +152,7 @@ public class FootnoteLayoutManager exten
 
         // make the citationLM add its areas
         LayoutContext childContext = new LayoutContext(context);
-        StackingIter childPosIter = new StackingIter(positionList.listIterator());
+        PositionIterator childPosIter = new PositionIterator(positionList.listIterator());
         LayoutManager childLM;
         while ((childLM = childPosIter.getNextChildLM()) != null) {
             childLM.addAreas(childPosIter, childContext);

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/ImageLayout.java Thu Apr  5 16:19:19 2012
@@ -361,4 +361,4 @@ public class ImageLayout implements Cons
         return this.clip;
     }
 
-}
\ No newline at end of file
+}

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java Thu Apr  5 16:19:19 2012
@@ -32,6 +32,7 @@ import org.apache.fop.area.inline.Inline
 import org.apache.fop.area.inline.InlineBlockParent;
 import org.apache.fop.area.inline.InlineParent;
 import org.apache.fop.datatypes.Length;
+import org.apache.fop.fo.flow.BasicLink;
 import org.apache.fop.fo.flow.Inline;
 import org.apache.fop.fo.flow.InlineLevel;
 import org.apache.fop.fo.flow.Leader;
@@ -77,8 +78,6 @@ public class InlineLayoutManager extends
     private boolean areaCreated = false;
     private LayoutManager lastChildLM = null; // Set when return last breakposs;
 
-    private Position auxiliaryPosition;
-
     private Font font;
 
     /** The alignment adjust property */
@@ -108,11 +107,8 @@ public class InlineLayoutManager extends
         super(node);
     }
 
-    private Inline getInlineFO() {
-        return (Inline) fobj;
-    }
-
     /** {@inheritDoc} */
+    @Override
     public void initialize() {
         InlineLevel fobj = (InlineLevel) this.fobj;
 
@@ -137,6 +133,11 @@ public class InlineLayoutManager extends
             alignmentBaseline = ((Leader)fobj).getAlignmentBaseline();
             baselineShift = ((Leader)fobj).getBaselineShift();
             dominantBaseline = ((Leader)fobj).getDominantBaseline();
+        } else if (fobj instanceof BasicLink) {
+            alignmentAdjust = ((BasicLink)fobj).getAlignmentAdjust();
+            alignmentBaseline = ((BasicLink)fobj).getAlignmentBaseline();
+            baselineShift = ((BasicLink)fobj).getBaselineShift();
+            dominantBaseline = ((BasicLink)fobj).getDominantBaseline();
         }
         if (borderProps != null) {
             padding = borderProps.getPadding(CommonBorderPaddingBackground.BEFORE, false, this);
@@ -150,6 +151,7 @@ public class InlineLayoutManager extends
     }
 
     /** {@inheritDoc} */
+    @Override
     protected MinOptMax getExtraIPD(boolean isNotFirst, boolean isNotLast) {
         int borderAndPadding = 0;
         if (borderProps != null) {
@@ -167,6 +169,7 @@ public class InlineLayoutManager extends
 
 
     /** {@inheritDoc} */
+    @Override
     protected boolean hasLeadingFence(boolean isNotFirst) {
         return borderProps != null
             && (borderProps.getPadding(CommonBorderPaddingBackground.START, isNotFirst, this) > 0
@@ -175,6 +178,7 @@ public class InlineLayoutManager extends
     }
 
     /** {@inheritDoc} */
+    @Override
     protected boolean hasTrailingFence(boolean isNotLast) {
         return borderProps != null
             && (borderProps.getPadding(CommonBorderPaddingBackground.END, isNotLast, this) > 0
@@ -183,10 +187,12 @@ public class InlineLayoutManager extends
     }
 
     /** {@inheritDoc} */
+    @Override
     protected SpaceProperty getSpaceStart() {
         return inlineProps != null ? inlineProps.spaceStart : null;
     }
     /** {@inheritDoc} */
+    @Override
     protected SpaceProperty getSpaceEnd() {
         return inlineProps != null ? inlineProps.spaceEnd : null;
     }
@@ -194,24 +200,35 @@ public class InlineLayoutManager extends
     /**
      * Create and initialize an <code>InlineArea</code>
      *
-     * @param hasInlineParent   true if the parent is an inline
+     * @param isInline   true if the parent is an inline
      * @return the area
      */
-    protected InlineArea createArea(boolean hasInlineParent) {
+    protected InlineArea createArea(boolean isInline) {
         InlineArea area;
-        if (hasInlineParent) {
-            area = new InlineParent();
-            area.setOffset(0);
+        if (isInline) {
+            area = createInlineParent();
+            area.setBlockProgressionOffset(0);
         } else {
             area = new InlineBlockParent();
         }
-        if (fobj instanceof Inline) {
-            TraitSetter.setProducerID(area, getInlineFO().getId());
+        if (fobj instanceof Inline || fobj instanceof BasicLink) {
+            TraitSetter.setProducerID(area, fobj.getId());
         }
         return area;
     }
 
+    /**
+     * Creates the inline area that will contain the areas returned by the
+     * children of this layout manager.
+     *
+     * @return a new inline area
+     */
+    protected InlineParent createInlineParent() {
+        return new InlineParent();
+    }
+
     /** {@inheritDoc} */
+    @Override
     protected void setTraits(boolean isNotFirst, boolean isNotLast) {
         if (borderProps != null) {
             // Add border and padding to current area and set flags (FIRST, LAST ...)
@@ -239,15 +256,16 @@ public class InlineLayoutManager extends
     }
 
     /** {@inheritDoc} */
-    public List getNextKnuthElements                            // CSOK: MethodLength
+    @Override                                                   // CSOK: MethodLength
+    public List getNextKnuthElements
         (LayoutContext context, int alignment) {
         LayoutManager curLM;
 
         // the list returned by child LM
-        List returnedList;
+        List<KnuthSequence> returnedList;
 
         // the list which will be returned to the parent LM
-        List returnList = new LinkedList();
+        List<KnuthSequence> returnList = new LinkedList<KnuthSequence>();
         KnuthSequence lastSequence = null;
 
         if (fobj instanceof Title) {
@@ -328,16 +346,16 @@ public class InlineLayoutManager extends
                     sequence.wrapPositions(this);
                 }
                 int insertionStartIndex = 0;
-                if (lastSequence != null && lastSequence.appendSequenceOrClose
-                        ((KnuthSequence) returnedList.get(0))) {
+                if (lastSequence != null
+                        && lastSequence.appendSequenceOrClose(returnedList.get(0))) {
                     insertionStartIndex = 1;
                 }
                 // add border and padding to the first complete sequence of this LM
                 if (!borderAdded && !returnedList.isEmpty()) {
-                    addKnuthElementsForBorderPaddingStart((KnuthSequence) returnedList.get(0));
+                    addKnuthElementsForBorderPaddingStart(returnedList.get(0));
                     borderAdded = true;
                 }
-                for (Iterator iter = returnedList.listIterator(insertionStartIndex);
+                for (Iterator<KnuthSequence> iter = returnedList.listIterator(insertionStartIndex);
                         iter.hasNext();) {
                     returnList.add(iter.next());
                 }
@@ -368,7 +386,7 @@ public class InlineLayoutManager extends
                 context.updateKeepWithNextPending(childLC.getKeepWithNextPending());
                 childLC.clearKeepsPending();
             }
-            lastSequence = (KnuthSequence) ListUtil.getLast(returnList);
+            lastSequence = ListUtil.getLast(returnList);
             lastChildLM = curLM;
         }
 
@@ -408,6 +426,7 @@ public class InlineLayoutManager extends
      * by this LayoutManager.
      * @param context layout context.
      */
+    @Override
     public void addAreas(PositionIterator parentIter,
                          LayoutContext context) {
 
@@ -415,39 +434,44 @@ public class InlineLayoutManager extends
 
         setChildContext(new LayoutContext(context)); // Store current value
 
-        // If this LM has fence, make a new leading space specifier.
-        if (hasLeadingFence(areaCreated)) {
-            getContext().setLeadingSpace(new SpaceSpecifier(false));
-            getContext().setFlags(LayoutContext.RESOLVE_LEADING_SPACE, true);
-        } else {
-            getContext().setFlags(LayoutContext.RESOLVE_LEADING_SPACE, false);
-        }
-
-        if (getSpaceStart() != null) {
-            context.getLeadingSpace().addSpace(new SpaceVal(getSpaceStart(), this));
-        }
-
         // "Unwrap" the NonLeafPositions stored in parentIter and put
         // them in a new list.  Set lastLM to be the LayoutManager
         // which created the last Position: if the LAST_AREA flag is
         // set in the layout context, it must be also set in the
         // layout context given to lastLM, but must be cleared in the
         // layout context given to the other LMs.
-        List positionList = new LinkedList();
-        NonLeafPosition pos;
+        List<Position> positionList = new LinkedList<Position>();
+        Position pos;
         LayoutManager lastLM = null; // last child LM in this iterator
         Position lastPos = null;
         while (parentIter.hasNext()) {
-            pos = (NonLeafPosition) parentIter.next();
+            pos = parentIter.next();
             if (pos != null && pos.getPosition() != null) {
+                if (isFirst(pos)) {
+                    /*
+                     * If this element is a descendant of a table-header/footer,
+                     * its content may be repeated over pages, so the generation
+                     * of its areas may be restarted.
+                     */
+                    areaCreated = false;
+                }
                 positionList.add(pos.getPosition());
                 lastLM = pos.getPosition().getLM();
                 lastPos = pos;
             }
         }
-        /*if (pos != null) {
-            lastLM = pos.getPosition().getLM();
-        }*/
+
+        // If this LM has fence, make a new leading space specifier.
+        if (hasLeadingFence(areaCreated)) {
+            getContext().setLeadingSpace(new SpaceSpecifier(false));
+            getContext().setFlags(LayoutContext.RESOLVE_LEADING_SPACE, true);
+        } else {
+            getContext().setFlags(LayoutContext.RESOLVE_LEADING_SPACE, false);
+        }
+
+        if (getSpaceStart() != null) {
+            context.getLeadingSpace().addSpace(new SpaceVal(getSpaceStart(), this));
+        }
 
         addMarkersToPage(
                 true,
@@ -458,19 +482,19 @@ public class InlineLayoutManager extends
                                         || lastLM instanceof InlineLevelLayoutManager);
         parent.setBPD(alignmentContext.getHeight());
         if (parent instanceof InlineParent) {
-            parent.setOffset(alignmentContext.getOffset());
+            parent.setBlockProgressionOffset(alignmentContext.getOffset());
         } else if (parent instanceof InlineBlockParent) {
             // All inline elements are positioned by the renderers relative to
             // the before edge of their content rectangle
             if (borderProps != null) {
-                parent.setOffset(borderProps.getPaddingBefore(false, this)
+                parent.setBlockProgressionOffset(borderProps.getPaddingBefore(false, this)
                                 + borderProps.getBorderBeforeWidth(false));
             }
         }
         setCurrentArea(parent);
 
-        StackingIter childPosIter
-            = new StackingIter(positionList.listIterator());
+        PositionIterator childPosIter
+            = new PositionIterator(positionList.listIterator());
 
         LayoutManager prevLM = null;
         LayoutManager childLM;
@@ -522,6 +546,7 @@ public class InlineLayoutManager extends
     }
 
     /** {@inheritDoc} */
+    @Override
     public void addChildArea(Area childArea) {
         Area parent = getCurrentArea();
         if (getContext().resolveLeadingSpace()) {
@@ -532,10 +557,11 @@ public class InlineLayoutManager extends
     }
 
     /** {@inheritDoc} */
-    public List getChangedKnuthElements(List oldList, int alignment) {
+    @Override
+    public List getChangedKnuthElements(List oldList, int alignment, int depth) {
         List returnedList = new LinkedList();
         addKnuthElementsForBorderPaddingStart(returnedList);
-        returnedList.addAll(super.getChangedKnuthElements(oldList, alignment));
+        returnedList.addAll(super.getChangedKnuthElements(oldList, alignment, depth));
         addKnuthElementsForBorderPaddingEnd(returnedList);
         return returnedList;
     }
@@ -546,7 +572,7 @@ public class InlineLayoutManager extends
      */
     protected void addKnuthElementsForBorderPaddingStart(List returnList) {
         //Border and Padding (start)
-        /**
+        /*
          * If the returnlist is a BlockKnuthSequence, the border and padding should be added
          * to the first paragraph inside it, but it is too late to do that now.
          * At least, avoid adding it to the bpd sequence.
@@ -571,7 +597,7 @@ public class InlineLayoutManager extends
      */
     protected void addKnuthElementsForBorderPaddingEnd(List returnList) {
         //Border and Padding (after)
-        /**
+        /*
          * If the returnlist is a BlockKnuthSequence, the border and padding should be added
          * to the last paragraph inside it, but it is too late to do that now.
          * At least, avoid adding it to the bpd sequence.
@@ -590,13 +616,8 @@ public class InlineLayoutManager extends
         }
     }
 
-    /** @return a cached auxiliary Position instance used for things like spaces. */
+    /** @return an auxiliary {@link Position} instance used for things like spaces. */
     protected Position getAuxiliaryPosition() {
-        //if (this.auxiliaryPosition == null) {
-            //this.auxiliaryPosition = new NonLeafPosition(this, new LeafPosition(this, -1));
-            this.auxiliaryPosition = new NonLeafPosition(this, null);
-        //}
-        return this.auxiliaryPosition;
+        return new NonLeafPosition(this, null);
     }
-
 }

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/InlineLevelLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/InlineLevelLayoutManager.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/InlineLevelLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/InlineLevelLayoutManager.java Thu Apr  5 16:19:19 2012
@@ -40,12 +40,15 @@ public interface InlineLevelLayoutManage
     List addALetterSpaceTo(List oldList);
 
     /**
-     * Tell the LM to modify its data, removing the word space
-     * represented by the given elements
+     * Tell the LM to modify its data, adding a letter space
+     * to the word fragment represented by the given elements,
+     * and returning the corrected elements
      *
-     * @param oldList the elements representing the word space
+     * @param oldList the elements which must be given one more letter space
+     * @param depth the depth at which the Positions for this LM in oldList are found
+     * @return        the new elements replacing the old ones
      */
-    void removeWordSpace(List oldList);
+List addALetterSpaceTo(List oldList, int depth);
 
     /**
      * Get the word chars corresponding to the given position.
@@ -71,4 +74,23 @@ public interface InlineLevelLayoutManage
      */
     boolean applyChanges(List oldList);
 
+    /**
+     * Tell the LM to apply the changes due to hyphenation
+     *
+     * @param oldList the list of the old elements the changes refer to
+     * @param depth the depth at which the Positions for this LM in oldList are found
+     * @return        true if the LM had to change its data, false otherwise
+     */
+    boolean applyChanges(List oldList, int depth);
+
+    /**
+     * Get a sequence of KnuthElements representing the content
+     * of the node assigned to the LM, after changes have been applied
+     * @param oldList        the elements to replace
+     * @param alignment      the desired text alignment
+     * @param depth the depth at which the Positions for this LM in oldList are found
+     * @return               the updated list of KnuthElements
+     **/
+    List getChangedKnuthElements(List oldList, int alignment, int depth);
+
 }

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/InlineStackingLayoutManager.java Thu Apr  5 16:19:19 2012
@@ -19,7 +19,6 @@
 
 package org.apache.fop.layoutmgr.inline;
 
-import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
 import java.util.ListIterator;
@@ -31,10 +30,8 @@ import org.apache.fop.fo.properties.Spac
 import org.apache.fop.layoutmgr.AbstractLayoutManager;
 import org.apache.fop.layoutmgr.KnuthElement;
 import org.apache.fop.layoutmgr.LayoutContext;
-import org.apache.fop.layoutmgr.LayoutManager;
 import org.apache.fop.layoutmgr.NonLeafPosition;
 import org.apache.fop.layoutmgr.Position;
-import org.apache.fop.layoutmgr.PositionIterator;
 import org.apache.fop.traits.MinOptMax;
 
 /**
@@ -45,33 +42,6 @@ import org.apache.fop.traits.MinOptMax;
 public abstract class InlineStackingLayoutManager extends AbstractLayoutManager
                                          implements InlineLevelLayoutManager {
 
-
-    /**
-     * A stacking iterator.
-     */
-    protected static class StackingIter extends PositionIterator {
-
-        StackingIter(Iterator parentIter) {
-            super(parentIter);
-        }
-
-        /**
-         * @param nextObj the next object
-         * @return layout manager of next object
-         */
-        protected LayoutManager getLM(Object nextObj) {
-            return ((Position) nextObj).getLM();
-        }
-
-        /**
-         * @param nextObj the next object
-         * @return position of next object
-         */
-        protected Position getPos(Object nextObj) {
-            return ((Position) nextObj);
-        }
-    }
-
     /**
      * Size of border and padding in BPD (ie, before and after).
      */
@@ -210,6 +180,10 @@ public abstract class InlineStackingLayo
                 //getLogger().debug("Add leading space: " + iAdjust);
                 Space ls = new Space();
                 ls.setIPD(iAdjust);
+                int level = parentArea.getBidiLevel();
+                if ( level >= 0 ) {
+                    ls.setBidiLevel ( level );
+                }
                 parentArea.addChildArea(ls);
             }
         }
@@ -217,54 +191,48 @@ public abstract class InlineStackingLayo
 
     /** {@inheritDoc} */
     public List addALetterSpaceTo(List oldList) {
+        return addALetterSpaceTo(oldList, 0);
+    }
+
+    /** {@inheritDoc} */
+    public List addALetterSpaceTo(List oldList, int thisDepth) {
         // old list contains only a box, or the sequence: box penalty glue box
 
-        ListIterator oldListIterator = oldList.listIterator();
-        KnuthElement element = null;
-        // "unwrap" the Position stored in each element of oldList
-        while (oldListIterator.hasNext()) {
-            element = (KnuthElement) oldListIterator.next();
-            element.setPosition(element.getPosition().getPosition());
-        }
+        ListIterator oldListIterator = oldList.listIterator(oldList.size());
+        KnuthElement element = (KnuthElement) oldListIterator.previous();
+        int depth = thisDepth + 1;
 
         // The last element may not have a layout manager (its position == null);
         // this may happen if it is a padding box; see bug 39571.
-        InlineLevelLayoutManager lm
-            = (InlineLevelLayoutManager) element.getLayoutManager();
-        if (lm != null) {
-            oldList = lm.addALetterSpaceTo(oldList);
+        Position pos = element.getPosition();
+        InlineLevelLayoutManager lm = null;
+        if (pos != null) {
+            lm = (InlineLevelLayoutManager) pos.getLM(depth);
         }
-        // "wrap" again the Position stored in each element of oldList
+        if (lm == null) {
+            return oldList;
+        }
+        oldList = lm.addALetterSpaceTo(oldList, depth);
+        // "wrap" the Position stored in new elements of oldList
         oldListIterator = oldList.listIterator();
         while (oldListIterator.hasNext()) {
             element = (KnuthElement) oldListIterator.next();
-            element.setPosition(notifyPos(new NonLeafPosition(this, element.getPosition())));
+            pos = element.getPosition();
+            lm = null;
+            if (pos != null) {
+                lm = (InlineLevelLayoutManager) pos.getLM(thisDepth);
+            }
+            // in old elements the position at thisDepth is a position for this LM
+            // only wrap new elements
+            if (lm != this) {
+                // new element, wrap position
+                element.setPosition(notifyPos(new NonLeafPosition(this, element.getPosition())));
+            }
         }
 
         return oldList;
     }
 
-    /**
-     * remove the AreaInfo object represented by the given elements,
-     * so that it won't generate any element when getChangedKnuthElements
-     * will be called
-     *
-     * @param oldList the elements representing the word space
-     */
-    public void removeWordSpace(List oldList) {
-        ListIterator oldListIterator = oldList.listIterator();
-        KnuthElement element = null;
-        // "unwrap" the Position stored in each element of oldList
-        while (oldListIterator.hasNext()) {
-            element = (KnuthElement) oldListIterator.next();
-            element.setPosition(element.getPosition().getPosition());
-        }
-
-        ((InlineLevelLayoutManager)
-                   element.getLayoutManager()).removeWordSpace(oldList);
-
-    }
-
     /** {@inheritDoc} */
     public String getWordChars(Position pos) {
         Position newPos = pos.getPosition();
@@ -280,16 +248,14 @@ public abstract class InlineStackingLayo
 
     /** {@inheritDoc} */
     public boolean applyChanges(List oldList) {
-        // "unwrap" the Positions stored in the elements
+        return applyChanges(oldList, 0);
+    }
+
+    /** {@inheritDoc} */
+    public boolean applyChanges(List oldList, int depth) {
         ListIterator oldListIterator = oldList.listIterator();
         KnuthElement oldElement;
-        while (oldListIterator.hasNext()) {
-            oldElement = (KnuthElement) oldListIterator.next();
-            oldElement.setPosition
-                (oldElement.getPosition().getPosition());
-        }
-        // reset the iterator
-        oldListIterator = oldList.listIterator();
+        depth += 1;
 
         InlineLevelLayoutManager prevLM = null;
         InlineLevelLayoutManager currLM;
@@ -298,7 +264,13 @@ public abstract class InlineStackingLayo
         boolean bSomethingChanged = false;
         while (oldListIterator.hasNext()) {
             oldElement = (KnuthElement) oldListIterator.next();
-            currLM = (InlineLevelLayoutManager) oldElement.getLayoutManager();
+            Position pos = oldElement.getPosition();
+            if (pos == null) {
+                currLM = null;
+            } else {
+                currLM = (InlineLevelLayoutManager) pos.getLM(depth);
+            }
+
             // initialize prevLM
             if (prevLM == null) {
                 prevLM = currLM;
@@ -309,38 +281,34 @@ public abstract class InlineStackingLayo
                     prevLM = currLM;
                 } else if (oldListIterator.hasNext()) {
                     bSomethingChanged
-                        = prevLM.applyChanges(oldList.subList(fromIndex
-                                                              , oldListIterator.previousIndex()))
+                        = prevLM.applyChanges(oldList.subList(fromIndex,
+                                                              oldListIterator.previousIndex()),
+                                                              depth)
                         || bSomethingChanged;
                     prevLM = currLM;
                     fromIndex = oldListIterator.previousIndex();
                 } else if (currLM == prevLM) {
                     bSomethingChanged
                         = (prevLM != null)
-                            && prevLM.applyChanges(oldList.subList(fromIndex, oldList.size()))
+                            && prevLM.applyChanges(oldList.subList(fromIndex,
+                                                                   oldList.size()), depth)
                             || bSomethingChanged;
                 } else {
                     bSomethingChanged
-                        = prevLM.applyChanges(oldList.subList(fromIndex
-                                                              , oldListIterator.previousIndex()))
+                        = prevLM.applyChanges(oldList.subList(fromIndex,
+                                                              oldListIterator.previousIndex()),
+                                                              depth)
                             || bSomethingChanged;
                     if (currLM != null) {
                         bSomethingChanged
-                            = currLM.applyChanges(oldList.subList(oldListIterator.previousIndex()
-                                                                  , oldList.size()))
+                            = currLM.applyChanges(oldList.subList(oldListIterator.previousIndex(),
+                                                                  oldList.size()), depth)
                             || bSomethingChanged;
                     }
                 }
             }
         }
 
-        // "wrap" again the Positions stored in the elements
-        oldListIterator = oldList.listIterator();
-        while (oldListIterator.hasNext()) {
-            oldElement = (KnuthElement) oldListIterator.next();
-            oldElement.setPosition
-                (notifyPos(new NonLeafPosition(this, oldElement.getPosition())));
-        }
         return bSomethingChanged;
     }
 
@@ -348,16 +316,15 @@ public abstract class InlineStackingLayo
      * {@inheritDoc}
      */
     public List getChangedKnuthElements(List oldList, int alignment) {
+        return getChangedKnuthElements(oldList, alignment, 0);
+    }
+
+    /** {@inheritDoc} */
+    public List getChangedKnuthElements(List oldList, int alignment, int depth) {
         // "unwrap" the Positions stored in the elements
         ListIterator oldListIterator = oldList.listIterator();
         KnuthElement oldElement;
-        while (oldListIterator.hasNext()) {
-            oldElement = (KnuthElement) oldListIterator.next();
-            oldElement.setPosition
-                (oldElement.getPosition().getPosition());
-        }
-        // reset the iterator
-        oldListIterator = oldList.listIterator();
+        depth += 1;
 
         KnuthElement returnedElement;
         LinkedList returnedList = new LinkedList();
@@ -368,7 +335,12 @@ public abstract class InlineStackingLayo
 
         while (oldListIterator.hasNext()) {
             oldElement = (KnuthElement) oldListIterator.next();
-            currLM = (InlineLevelLayoutManager) oldElement.getLayoutManager();
+            Position pos = oldElement.getPosition();
+            if (pos == null) {
+                currLM = null;
+            } else {
+                currLM = (InlineLevelLayoutManager) pos.getLM(depth);
+            }
             if (prevLM == null) {
                 prevLM = currLM;
             }
@@ -377,33 +349,31 @@ public abstract class InlineStackingLayo
                 if (oldListIterator.hasNext()) {
                     returnedList.addAll
                         (prevLM.getChangedKnuthElements
-                         (oldList.subList(fromIndex,
-                                          oldListIterator.previousIndex()),
-                          /*flaggedPenalty,*/ alignment));
+                         (oldList.subList(fromIndex, oldListIterator.previousIndex()),
+                          alignment, depth));
                     prevLM = currLM;
                     fromIndex = oldListIterator.previousIndex();
                 } else if (currLM == prevLM) {
                     returnedList.addAll
                         (prevLM.getChangedKnuthElements
                          (oldList.subList(fromIndex, oldList.size()),
-                          /*flaggedPenalty,*/ alignment));
+                          alignment, depth));
                 } else {
                     returnedList.addAll
                         (prevLM.getChangedKnuthElements
-                         (oldList.subList(fromIndex,
-                                          oldListIterator.previousIndex()),
-                          /*flaggedPenalty,*/ alignment));
+                         (oldList.subList(fromIndex, oldListIterator.previousIndex()),
+                          alignment, depth));
                     if (currLM != null) {
                         returnedList.addAll
                             (currLM.getChangedKnuthElements
-                             (oldList.subList(oldListIterator.previousIndex(),
-                                              oldList.size()),
-                              /*flaggedPenalty,*/ alignment));
+                             (oldList.subList(oldListIterator.previousIndex(), oldList.size()),
+                              alignment, depth));
                     }
                 }
             }
         }
 
+        // this is a new list
         // "wrap" the Position stored in each element of returnedList
         ListIterator listIter = returnedList.listIterator();
         while (listIter.hasNext()) {
@@ -412,6 +382,7 @@ public abstract class InlineStackingLayo
                 (notifyPos(new NonLeafPosition(this, returnedElement.getPosition())));
             returnList.add(returnedElement);
         }
+
         return returnList;
     }
 }

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java Thu Apr  5 16:19:19 2012
@@ -115,7 +115,7 @@ public class LeaderLayoutManager extends
 
     private InlineArea getLeaderInlineArea(LayoutContext context) {
         InlineArea leaderArea = null;
-
+        int level = fobj.getBidiLevel();
         if (fobj.getLeaderPattern() == EN_RULE) {
             if (fobj.getRuleStyle() != EN_NONE) {
                 org.apache.fop.area.inline.Leader leader
@@ -125,28 +125,41 @@ public class LeaderLayoutManager extends
                 leaderArea = leader;
             } else {
                 leaderArea = new Space();
+                if ( level >= 0 ) {
+                    leaderArea.setBidiLevel ( level );
+                }
             }
             leaderArea.setBPD(fobj.getRuleThickness().getValue(this));
             leaderArea.addTrait(Trait.COLOR, fobj.getColor());
+            if ( level >= 0 ) {
+                leaderArea.setBidiLevel ( level );
+            }
         } else if (fobj.getLeaderPattern() == EN_SPACE) {
             leaderArea = new Space();
             leaderArea.setBPD(fobj.getRuleThickness().getValue(this));
+            if ( level >= 0 ) {
+                leaderArea.setBidiLevel ( level );
+            }
         } else if (fobj.getLeaderPattern() == EN_DOTS) {
             TextArea t = new TextArea();
             char dot = '.'; // userAgent.getLeaderDotCharacter();
-
             int width = font.getCharWidth(dot);
-            t.addWord("" + dot, 0);
+            int[] levels = ( level < 0 ) ? null : new int[] {level};
+            t.addWord("" + dot, width, null, levels, null, 0);
             t.setIPD(width);
             t.setBPD(width);
             t.setBaselineOffset(width);
             TraitSetter.addFontTraits(t, font);
             t.addTrait(Trait.COLOR, fobj.getColor());
             Space spacer = null;
-            if (fobj.getLeaderPatternWidth().getValue(this) > width) {
+            int widthLeaderPattern = fobj.getLeaderPatternWidth().getValue(this);
+            if (widthLeaderPattern > width) {
                 spacer = new Space();
-                spacer.setIPD(fobj.getLeaderPatternWidth().getValue(this) - width);
-                width = fobj.getLeaderPatternWidth().getValue(this);
+                spacer.setIPD(widthLeaderPattern - width);
+                if ( level >= 0 ) {
+                    spacer.setBidiLevel ( level );
+                }
+                width = widthLeaderPattern;
             }
             FilledArea fa = new FilledArea();
             fa.setUnitWidth(width);
@@ -155,7 +168,6 @@ public class LeaderLayoutManager extends
                 fa.addChildArea(spacer);
             }
             fa.setBPD(t.getBPD());
-
             leaderArea = fa;
         } else if (fobj.getLeaderPattern() == EN_USECONTENT) {
             if (fobj.getChildNodes() == null) {
@@ -188,6 +200,9 @@ public class LeaderLayoutManager extends
                 if (fobj.getLeaderPatternWidth().getValue(this) > width) {
                     spacer = new Space();
                     spacer.setIPD(fobj.getLeaderPatternWidth().getValue(this) - width);
+                    if ( level >= 0 ) {
+                        spacer.setBidiLevel ( level );
+                    }
                     width = fobj.getLeaderPatternWidth().getValue(this);
                 }
                 fa.setUnitWidth(width);
@@ -199,6 +214,7 @@ public class LeaderLayoutManager extends
                 //Content collapsed to nothing, so use a space
                 leaderArea = new Space();
                 leaderArea.setBPD(fobj.getRuleThickness().getValue(this));
+                leaderArea.setBidiLevel ( fobj.getBidiLevelRecursive() );
             }
         }
         TraitSetter.setProducerID(leaderArea, fobj.getId());

Modified: xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java?rev=1309921&r1=1309920&r2=1309921&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_TrueTypeInPostScript/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java Thu Apr  5 16:19:19 2012
@@ -19,12 +19,13 @@
 
 package org.apache.fop.layoutmgr.inline;
 
+import java.util.Collections;
 import java.util.LinkedList;
 import java.util.List;
-import java.util.Collections;
 
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
+
 import org.apache.fop.area.Area;
 import org.apache.fop.area.inline.InlineArea;
 import org.apache.fop.fo.FObj;
@@ -48,19 +49,14 @@ import org.apache.fop.traits.MinOptMax;
  * an exception to this rule.)
  * This class can be extended to handle the creation and adding of the
  * inline area.
- * TODO [GA] replace use of hungarian notation with normalized java naming
  */
 public abstract class LeafNodeLayoutManager extends AbstractLayoutManager
                                    implements InlineLevelLayoutManager {
 
-    /**
-     * logging instance
-     */
+    /** logging instance */
     protected static final Log log = LogFactory.getLog(LeafNodeLayoutManager.class);
 
-    /**
-     * The inline area that this leafnode will add.
-     */
+    /** The inline area that this leafnode will add. */
     protected InlineArea curArea = null;
     /** Any border, padding and background properties applying to this area */
     protected CommonBorderPaddingBackground commonBorderPaddingBackground = null;
@@ -68,7 +64,7 @@ public abstract class LeafNodeLayoutMana
     protected AlignmentContext alignmentContext = null;
 
     /** Flag to indicate if something was changed as part of the getChangeKnuthElements sequence */
-    protected boolean isSomethingChanged = false;
+    protected boolean somethingChanged = false;
     /** Our area info for the Knuth elements */
     protected AreaInfo areaInfo = null;
 
@@ -77,32 +73,31 @@ public abstract class LeafNodeLayoutMana
      */
     protected class AreaInfo {
         /** letter space count */
-        protected short iLScount;
+        protected short letterSpaces;
         /** ipd of area */
         protected MinOptMax ipdArea;
         /** true if hyphenated */
-        protected boolean bHyphenated;
+        protected boolean isHyphenated;
         /** alignment context */
         protected AlignmentContext alignmentContext;
 
         /**
          * Construct an area information item.
-         * @param iLS letter space count
+         * @param letterSpaces letter space count
          * @param ipd inline progression dimension
-         * @param bHyph true if hyphenated
+         * @param isHyphenated true if hyphenated
          * @param alignmentContext an alignment context
          */
-        public AreaInfo(short iLS, MinOptMax ipd, boolean bHyph,
+        public AreaInfo(short letterSpaces, MinOptMax ipd, boolean isHyphenated,
                         AlignmentContext alignmentContext) {
-            iLScount = iLS;
-            ipdArea = ipd;
-            bHyphenated = bHyph;
+            this.letterSpaces = letterSpaces;
+            this.ipdArea = ipd;
+            this.isHyphenated = isHyphenated;
             this.alignmentContext = alignmentContext;
         }
 
     }
 
-
     /**
      * Create a Leaf node layout manager.
      * @param node the FObj to attach to this LM.
@@ -145,18 +140,22 @@ public abstract class LeafNodeLayoutMana
     }
 
     /**
-     * This is a leaf-node, so this method is never called.
+     * This is a leaf-node, so this method should never be called.
      * @param childArea the childArea to add
      */
+    @Override
     public void addChildArea(Area childArea) {
+        assert false;
     }
 
     /**
-     * This is a leaf-node, so this method is never called.
+     * This is a leaf-node, so this method should never be called.
      * @param childArea the childArea to get the parent for
      * @return the parent area
      */
+    @Override
     public Area getParentArea(Area childArea) {
+        assert false;
         return null;
     }
 
@@ -185,6 +184,7 @@ public abstract class LeafNodeLayoutMana
      * @param posIter the position iterator
      * @param context the layout context for adding the area
      */
+    @Override
     public void addAreas(PositionIterator posIter, LayoutContext context) {
         addId();
 
@@ -225,7 +225,7 @@ public abstract class LeafNodeLayoutMana
      * @param context the layout context used for adding the area
      */
     protected void offsetArea(InlineArea area, LayoutContext context) {
-        area.setOffset(alignmentContext.getOffset());
+        area.setBlockProgressionOffset(alignmentContext.getOffset());
     }
 
     /**
@@ -260,6 +260,7 @@ public abstract class LeafNodeLayoutMana
     }
 
     /** {@inheritDoc} */
+    @Override
     public List getNextKnuthElements(LayoutContext context, int alignment) {
         curArea = get(context);
 
@@ -297,13 +298,11 @@ public abstract class LeafNodeLayoutMana
     }
 
     /**
-     * Remove the word space represented by the given elements
-     *
-     * @param oldList the elements representing the word space
-     */
-    public void removeWordSpace(List oldList) {
-        // do nothing
-        log.warn(this.getClass().getName() + " should not receive a call to removeWordSpace(list)");
+     * {@inheritDoc}
+     * Only TextLM has a meaningful implementation of this method
+     */
+    public List addALetterSpaceTo(List oldList, int depth) {
+        return addALetterSpaceTo(oldList);
     }
 
     /** {@inheritDoc} */
@@ -321,9 +320,25 @@ public abstract class LeafNodeLayoutMana
         return false;
     }
 
+    /**
+     * {@inheritDoc}
+     * Only TextLM has a meaningful implementation of this method
+     */
+    public boolean applyChanges(List oldList, int depth) {
+        return applyChanges(oldList);
+    }
+
+    /**
+     * {@inheritDoc}
+     * No subclass has a meaningful implementation of this method
+     */
+    public List getChangedKnuthElements(List oldList, int alignment, int depth) {
+        return getChangedKnuthElements(oldList, alignment);
+    }
+
     /** {@inheritDoc} */
-    public List getChangedKnuthElements(List oldList,
-                                              int alignment) {
+    @Override
+    public List getChangedKnuthElements(List oldList, int alignment) {
         if (isFinished()) {
             return null;
         }



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org