]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Do space resolution on the children of the inline-container
authorVincent Hennebert <vhennebert@apache.org>
Mon, 28 Oct 2013 17:09:21 +0000 (17:09 +0000)
committerVincent Hennebert <vhennebert@apache.org>
Mon, 28 Oct 2013 17:09:21 +0000 (17:09 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_InlineContainer@1536418 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java
src/java/org/apache/fop/layoutmgr/inline/InlineContainerLayoutManager.java
test/layoutengine/standard-testcases/inline-container_bpd.xml

index 0ed6cb69b4c0273d6bf28c1a9e577a61c4c65abc..d731ab62a5c4a9018534769ab51018f07a750d04 100644 (file)
@@ -33,11 +33,11 @@ public final class AreaAdditionUtil {
 
     /**
      * Creates the child areas for the given layout manager.
-     * @param bslm the BlockStackingLayoutManager instance for which "addAreas" is performed.
+     * @param parentLM the parent layout manager
      * @param parentIter the position iterator
      * @param layoutContext the layout context
      */
-    public static void addAreas(BlockStackingLayoutManager bslm,
+    public static void addAreas(AbstractLayoutManager parentLM,
             PositionIterator parentIter, LayoutContext layoutContext) {
         LayoutManager childLM;
         LayoutContext lc = LayoutContext.offspringOf(layoutContext);
@@ -46,8 +46,8 @@ public final class AreaAdditionUtil {
         Position firstPos = null;
         Position lastPos = null;
 
-        if (bslm != null) {
-            bslm.addId();
+        if (parentLM != null) {
+            parentLM.addId();
         }
 
         // "unwrap" the NonLeafPositions stored in parentIter
@@ -86,11 +86,11 @@ public final class AreaAdditionUtil {
             //doesn't give us that info.
         }
 
-        if (bslm != null) {
-            bslm.registerMarkers(
+        if (parentLM != null) {
+            parentLM.registerMarkers(
                     true,
-                    bslm.isFirst(firstPos),
-                    bslm.isLast(lastPos));
+                    parentLM.isFirst(firstPos),
+                    parentLM.isLast(lastPos));
         }
 
         PositionIterator childPosIter = new PositionIterator(positionList.listIterator());
@@ -113,11 +113,11 @@ public final class AreaAdditionUtil {
             childLM.addAreas(childPosIter, lc);
         }
 
-        if (bslm != null) {
-            bslm.registerMarkers(
+        if (parentLM != null) {
+            parentLM.registerMarkers(
                     false,
-                    bslm.isFirst(firstPos),
-                    bslm.isLast(lastPos));
+                    parentLM.isFirst(firstPos),
+                    parentLM.isLast(lastPos));
         }
 
 
index 152d16a3d5ea96c73833e9fe04c99244a1ed99b1..3688bcff090484a0ef73debb907e49876e122d97 100644 (file)
@@ -35,6 +35,7 @@ import org.apache.fop.fonts.Font;
 import org.apache.fop.fonts.FontInfo;
 import org.apache.fop.fonts.FontTriplet;
 import org.apache.fop.layoutmgr.AbstractLayoutManager;
+import org.apache.fop.layoutmgr.AreaAdditionUtil;
 import org.apache.fop.layoutmgr.BlockLevelEventProducer;
 import org.apache.fop.layoutmgr.ElementListUtils;
 import org.apache.fop.layoutmgr.InlineKnuthSequence;
@@ -43,6 +44,7 @@ import org.apache.fop.layoutmgr.KnuthSequence;
 import org.apache.fop.layoutmgr.LayoutContext;
 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;
 import org.apache.fop.layoutmgr.SpaceResolver;
@@ -134,11 +136,20 @@ public class InlineContainerLayoutManager extends AbstractLayoutManager implemen
             allChildElements.addAll(childElements);
             // TODO breaks, keeps, empty content
         }
+        wrapPositions(allChildElements);
         SpaceResolver.resolveElementList(allChildElements);
         // TODO break-before, break-after
         return allChildElements;
     }
 
+    private void wrapPositions(List<ListElement> elements) {
+        for (ListElement element : elements) {
+            Position position = new NonLeafPosition(this, element.getPosition());
+            notifyPos(position);
+            element.setPosition(position);
+        }
+    }
+
     @Override
     public void addAreas(PositionIterator posIter, LayoutContext context) {
         Position inlineContainerPosition = null;
@@ -148,26 +159,12 @@ public class InlineContainerLayoutManager extends AbstractLayoutManager implemen
                 inlineContainerPosition = pos;
             }
         }
-        addId();
-//        addMarkersToPage(
-//                true,
-//                true,
-//                lastPos == null || isLast(lastPos));
-
         if (inlineContainerPosition != null) {
-            LayoutManager childLM;
+            SpaceResolver.performConditionalsNotification(childElements, 0, childElements.size() - 1, -1);
             KnuthPossPosIter childPosIter = new KnuthPossPosIter(childElements);
-            while ((childLM = childPosIter.getNextChildLM()) != null) {
-                LayoutContext childLC = LayoutContext.copyOf(context); // TODO correct?
-                childLM.addAreas(childPosIter, childLC);
-            }
+            AreaAdditionUtil.addAreas(this, childPosIter, context);
         }
 
-//        addMarkersToPage(
-//                false,
-//                true,
-//                lastPos == null || isLast(lastPos));
-
 //        boolean isLast = (context.isLastArea() && prevLM == lastChildLM);
 //        context.setFlags(LayoutContext.LAST_AREA, isLast);
     }
index bd2dfdf9e0b7a0241f46f711ba24551137841b3d..e63172b15aa5b74188bf23278b65bcafcd60e738 100644 (file)
             </fo:inline-container> After.</fo:block>
         </fo:flow>
       </fo:page-sequence>
+      <fo:page-sequence master-reference="page">
+        <fo:flow flow-name="xsl-region-body">
+          <fo:block>Before: <fo:inline-container width="80pt">
+              <fo:block space-after="10pt">Block 1</fo:block>
+              <fo:block space-before="20pt" space-after="10pt" 
+                space-after.conditionality="retain">Block 2</fo:block>
+          </fo:inline-container> After.</fo:block>
+        </fo:flow>
+      </fo:page-sequence>
     </fo:root>
   </fo>
 
   <checks>
     <eval expected="40000" xpath="//pageSequence[1]//viewport/@bpd"/>
+
     <eval expected="35000" xpath="//pageSequence[2]//viewport/@bpd"/>
     <true xpath="//pageSequence[2]//viewport/@clip"/>
+
+    <eval expected="50000" xpath="//pageSequence[3]//viewport/@bpd"/>
   </checks>
 </testcase>