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 ad...@apache.org on 2011/02/06 16:33:17 UTC

svn commit: r1067684 - /xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java

Author: adelmelle
Date: Sun Feb  6 15:33:17 2011
New Revision: 1067684

URL: http://svn.apache.org/viewvc?rev=1067684&view=rev
Log:
Code fixups

Modified:
    xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java?rev=1067684&r1=1067683&r2=1067684&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java Sun Feb  6 15:33:17 2011
@@ -24,10 +24,16 @@ import org.apache.fop.area.Block;
 import org.apache.fop.fo.flow.Wrapper;
 import org.apache.fop.layoutmgr.BlockLayoutManager;
 import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
+import org.apache.fop.layoutmgr.KnuthBox;
+import org.apache.fop.layoutmgr.KnuthSequence;
 import org.apache.fop.layoutmgr.LayoutContext;
+import org.apache.fop.layoutmgr.ListElement;
 import org.apache.fop.layoutmgr.PositionIterator;
 import org.apache.fop.layoutmgr.TraitSetter;
 
+import java.util.LinkedList;
+import java.util.List;
+
 /**
  * This is the layout manager for the fo:wrapper formatting object.
  */
@@ -42,6 +48,7 @@ public class WrapperLayoutManager extend
     }
 
     /** {@inheritDoc} */
+    @Override
     public InlineArea get(LayoutContext context) {
         // Create a zero-width, zero-height dummy area so this node can
         // participate in the ID handling. Otherwise, addId() wouldn't
@@ -55,13 +62,37 @@ public class WrapperLayoutManager extend
     }
 
     /**
+     * Overridden to generate a proper {@link ListElement}, if the parent
+     * requires it (i.e. is a block-container, list-item-body...)
+     * If the parent is a block, the line LM will take care of properly
+     * wrapping the sequence in a line box.
+     * {@inheritDoc}
+     */
+    @Override
+    public List getNextKnuthElements(LayoutContext context, int alignment) {
+        List returnList = super.getNextKnuthElements(context, alignment);
+        KnuthSequence seq = (KnuthSequence) returnList.get(0);
+        ListElement tempElement = (ListElement) seq.get(0);
+        if (parentLayoutManager instanceof BlockStackingLayoutManager
+                && !(parentLayoutManager instanceof BlockLayoutManager)) {
+            // replace inline box with a block box
+            returnList = new LinkedList();
+            KnuthBox auxiliaryBox = new KnuthBox(0, tempElement.getPosition(), true);
+            returnList.add(auxiliaryBox);
+        } else {
+            // make sure the inline box is an auxiliary one
+            seq.set(0, new KnuthInlineBox(0, null, tempElement.getPosition(), true));
+        }
+        return returnList;
+    }
+
+    /**
      * Add the area for this layout manager.
      * This adds the dummy area to the parent, *if* it has an id
      * - otherwise it serves no purpose.
-     *
-     * @param posIter the position iterator
-     * @param context the layout context for adding the area
+     * {@inheritDoc}
      */
+    @Override
     public void addAreas(PositionIterator posIter, LayoutContext context) {
         if (fobj.hasId()) {
             addId();



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