From 19f04b9ac8fdaaea7436753ef272d19b658d0471 Mon Sep 17 00:00:00 2001 From: Vincent Hennebert Date: Mon, 28 Oct 2013 18:54:11 +0000 Subject: [PATCH] Properly handle "error-if-overflow" value of "overflow" property when overflow happens in inline-progression-direction git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_InlineContainer@1536486 13f79535-47bb-0310-9956-ffa450edef68 --- .../layoutmgr/BlockStackingLayoutManager.java | 3 ++ .../inline/InlineContainerLayoutManager.java | 30 ++++++++++++++++--- 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java index d11f062cb..250e07727 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java @@ -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; } diff --git a/src/java/org/apache/fop/layoutmgr/inline/InlineContainerLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/InlineContainerLayoutManager.java index 7e2b186be..85d21833b 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/InlineContainerLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/InlineContainerLayoutManager.java @@ -63,6 +63,7 @@ public class InlineContainerLayoutManager extends AbstractLayoutManager implemen private int contentAreaBPD; private List 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 getChildKnuthElements(LayoutContext layoutContext, int alignment) { List allChildElements = new LinkedList(); 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 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"); } -- 2.39.5