]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Properly handle "error-if-overflow" value of "overflow" property when overflow happen...
authorVincent Hennebert <vhennebert@apache.org>
Mon, 28 Oct 2013 18:54:11 +0000 (18:54 +0000)
committerVincent Hennebert <vhennebert@apache.org>
Mon, 28 Oct 2013 18:54:11 +0000 (18:54 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_InlineContainer@1536486 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
src/java/org/apache/fop/layoutmgr/inline/InlineContainerLayoutManager.java

index d11f062cb4ee4b5e60280851a9c02571b3a67ba3..250e0772766e3d1993bc15df35dc6f29c7dc5b76 100644 (file)
@@ -36,6 +36,7 @@ import org.apache.fop.fo.properties.BreakPropertySet;
 import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
 import org.apache.fop.fo.properties.KeepProperty;
 import org.apache.fop.fo.properties.SpaceProperty;
+import org.apache.fop.layoutmgr.inline.InlineContainerLayoutManager;
 import org.apache.fop.layoutmgr.inline.InlineLayoutManager;
 import org.apache.fop.traits.MinOptMax;
 import org.apache.fop.util.ListUtil;
@@ -1246,6 +1247,8 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
     public boolean handleOverflow(int milliPoints) {
         if (getParent() instanceof BlockStackingLayoutManager) {
             return ((BlockStackingLayoutManager) getParent()).handleOverflow(milliPoints);
+        } else if (getParent() instanceof InlineContainerLayoutManager) {
+            return ((InlineContainerLayoutManager) getParent()).handleOverflow(milliPoints);
         }
         return false;
     }
index 7e2b186bebe788d7f421ef338527265348446275..85d21833bbf520ceb97202635308874ca5f22453 100644 (file)
@@ -63,6 +63,7 @@ public class InlineContainerLayoutManager extends AbstractLayoutManager implemen
     private int contentAreaBPD;
 
     private List<ListElement> childElements;
+    private int ipdOverflow;
     private InlineViewport currentViewport;
     private Container referenceArea;
 
@@ -119,17 +120,23 @@ public class InlineContainerLayoutManager extends AbstractLayoutManager implemen
             } else {
                 contentAreaBPD = (int) Math.round(bpdValue);
                 if (contentAreaBPD < actualBPD) {
-                    BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Provider.get(
-                            fobj.getUserAgent().getEventBroadcaster());
-                    boolean canRecover = (((InlineContainer) fobj).getOverflow() != EN_ERROR_IF_OVERFLOW);
+                    BlockLevelEventProducer eventProducer = getBlockLevelEventProducer();
                     eventProducer.viewportBPDOverflow(this, fobj.getName(),
-                            actualBPD - contentAreaBPD, needClip(), canRecover,
+                            actualBPD - contentAreaBPD, needClip(), canRecoverFromOverflow(),
                             fobj.getLocator());
                 }
             }
         }
     }
 
+    private BlockLevelEventProducer getBlockLevelEventProducer() {
+        return BlockLevelEventProducer.Provider.get(fobj.getUserAgent().getEventBroadcaster());
+    }
+
+    private boolean canRecoverFromOverflow() {
+        return ((InlineContainer) fobj).getOverflow() != EN_ERROR_IF_OVERFLOW;
+    }
+
     private List<ListElement> getChildKnuthElements(LayoutContext layoutContext, int alignment) {
         List<ListElement> allChildElements = new LinkedList<ListElement>();
         LayoutManager childLM;
@@ -141,12 +148,22 @@ public class InlineContainerLayoutManager extends AbstractLayoutManager implemen
             allChildElements.addAll(childElements);
             // TODO breaks, keeps, empty content
         }
+        handleIPDOverflow();
         wrapPositions(allChildElements);
         SpaceResolver.resolveElementList(allChildElements);
         // TODO break-before, break-after
         return allChildElements;
     }
 
+    private void handleIPDOverflow() {
+        if (ipdOverflow > 0) {
+            BlockLevelEventProducer eventProducer = getBlockLevelEventProducer();
+            eventProducer.viewportIPDOverflow(this, fobj.getName(),
+                    ipdOverflow, needClip(), canRecoverFromOverflow(),
+                    fobj.getLocator());
+        }
+    }
+
     private void wrapPositions(List<ListElement> elements) {
         for (ListElement element : elements) {
             Position position = new NonLeafPosition(this, element.getPosition());
@@ -234,6 +251,11 @@ public class InlineContainerLayoutManager extends AbstractLayoutManager implemen
                 context.getWritingMode());
     }
 
+    public boolean handleOverflow(int milliPoints) {
+        ipdOverflow = Math.max(ipdOverflow, milliPoints);
+        return true;
+    }
+
     public List addALetterSpaceTo(List oldList) {
         throw new UnsupportedOperationException("Not implemented");
     }