aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache
diff options
context:
space:
mode:
authorGlenn Adams <gadams@apache.org>2012-04-17 16:15:44 +0000
committerGlenn Adams <gadams@apache.org>2012-04-17 16:15:44 +0000
commita915c74aa4d3bcad9448d1808e5baba10ba91e24 (patch)
tree0b2e38660d9d0a2e8575daf9120bd69794a06536 /src/java/org/apache
parente67c4d1633a8b503ee75f393e8c2e69f31490645 (diff)
downloadxmlgraphics-fop-a915c74aa4d3bcad9448d1808e5baba10ba91e24.tar.gz
xmlgraphics-fop-a915c74aa4d3bcad9448d1808e5baba10ba91e24.zip
Bugzilla #53094: Convert block container overflow exception to event model, improving overflow property behavior.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1327157 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache')
-rw-r--r--src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java20
-rw-r--r--src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.java23
-rw-r--r--src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.xml3
-rw-r--r--src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java11
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java17
5 files changed, 64 insertions, 10 deletions
diff --git a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
index aab505d8b..8b656a753 100644
--- a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
@@ -86,6 +86,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager
private MinOptMax effSpaceBefore;
private MinOptMax effSpaceAfter;
+ private int horizontalOverflow;
private double contentRectOffsetX = 0;
private double contentRectOffsetY = 0;
@@ -401,7 +402,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager
BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Provider.get(
getBlockContainerFO().getUserAgent().getEventBroadcaster());
boolean canRecover = (getBlockContainerFO().getOverflow() != EN_ERROR_IF_OVERFLOW);
- eventProducer.viewportOverflow(this, getBlockContainerFO().getName(),
+ eventProducer.viewportBPDOverflow(this, getBlockContainerFO().getName(),
breaker.getOverflowAmount(), needClip(), canRecover,
getBlockContainerFO().getLocator());
}
@@ -553,10 +554,18 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager
BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Provider.get(
getBlockContainerFO().getUserAgent().getEventBroadcaster());
boolean canRecover = (getBlockContainerFO().getOverflow() != EN_ERROR_IF_OVERFLOW);
- eventProducer.viewportOverflow(this, getBlockContainerFO().getName(),
+ eventProducer.viewportBPDOverflow(this, getBlockContainerFO().getName(),
breaker.getOverflowAmount(), needClip(), canRecover,
getBlockContainerFO().getLocator());
}
+ // this handles the IPD (horizontal) overflow
+ if (this.horizontalOverflow > 0) {
+ BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Provider
+ .get(getBlockContainerFO().getUserAgent().getEventBroadcaster());
+ boolean canRecover = (getBlockContainerFO().getOverflow() != EN_ERROR_IF_OVERFLOW);
+ eventProducer.viewportIPDOverflow(this, getBlockContainerFO().getName(),
+ this.horizontalOverflow, needClip(), canRecover, getBlockContainerFO().getLocator());
+ }
}
setFinished(true);
@@ -1027,6 +1036,13 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager
}
}
+ /** {@inheritDoc} */
+ public boolean handleOverflow(int milliPoints) {
+ if (milliPoints > this.horizontalOverflow) {
+ this.horizontalOverflow = milliPoints;
+ }
+ return true;
+ }
}
diff --git a/src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.java b/src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.java
index 7d3964181..d9de09a46 100644
--- a/src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.java
+++ b/src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.java
@@ -89,19 +89,30 @@ public interface BlockLevelEventProducer extends EventProducer {
void overconstrainedAdjustEndIndent(Object source, String elementName, int amount, Locator loc);
/**
- * Contents overflow a viewport.
+ * Contents IPD overflow a viewport.
* @param source the event source
* @param elementName the formatting object
* @param amount the amount by which the contents overflow (in mpt)
* @param clip true if the content will be clipped
* @param canRecover indicates whether FOP can recover from this problem and continue working
* @param loc the location of the error or null
- * @throws LayoutException the layout error provoked by the method call
- * @event.severity FATAL
+ * @event.severity ERROR
*/
- void viewportOverflow(Object source, String elementName,
- int amount, boolean clip, boolean canRecover,
- Locator loc) throws LayoutException;
+ void viewportIPDOverflow(Object source, String elementName, int amount, boolean clip,
+ boolean canRecover, Locator loc);
+
+ /**
+ * Contents BPD overflow a viewport.
+ * @param source the event source
+ * @param elementName the formatting object
+ * @param amount the amount by which the contents overflow (in mpt)
+ * @param clip true if the content will be clipped
+ * @param canRecover indicates whether FOP can recover from this problem and continue working
+ * @param loc the location of the error or null
+ * @event.severity ERROR
+ */
+ void viewportBPDOverflow(Object source, String elementName, int amount, boolean clip,
+ boolean canRecover, Locator loc);
/**
* Contents overflow a region viewport.
diff --git a/src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.xml b/src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.xml
index a89f9ed32..d3e243a63 100644
--- a/src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.xml
+++ b/src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.xml
@@ -22,7 +22,8 @@
<message key="tableFixedAutoWidthNotSupported">table-layout="fixed" and width="auto", but auto-layout not supported =&gt; assuming width="100%".{{locator}}</message>
<message key="objectTooWide">The extent in inline-progression-direction (width) of a {elementName} is bigger than the available space ({effIPD}mpt &gt; {maxIPD}mpt).{{locator}}</message>
<message key="overconstrainedAdjustEndIndent">An {elementName} {{locator}} is wider than the available room in inline-progression-dimension. Adjusting end-indent based on overconstrained geometry rules (XSL 1.1, ch. 5.3.4)</message>
- <message key="viewportOverflow">Content overflows the viewport of an {elementName} in block-progression direction by {amount} millipoints.{clip,if, Content will be clipped.}{{locator}}</message>
+ <message key="viewportIPDOverflow">Content overflows the viewport of an {elementName} in inline-progression direction by {amount} millipoints.{clip,if, Content will be clipped.}{{locator}}</message>
+ <message key="viewportBPDOverflow">Content overflows the viewport of an {elementName} in block-progression direction by {amount} millipoints.{clip,if, Content will be clipped.}{{locator}}</message>
<message key="regionOverflow">Content overflows the viewport of the {elementName} on page {page} in block-progression direction by {amount} millipoints.{clip,if, Content will be clipped.}{{locator}}</message>
<message key="flowNotMappingToRegionBody">Flow "{flowName}" does not map to the region-body in page-master "{masterName}". FOP presently does not support this.{{locator}}</message>
<message key="pageSequenceMasterExhausted">Subsequences exhausted in page-sequence-master "{pageSequenceMasterName}", {canRecover,if,using previous subsequence,cannot recover}.{{locator}}</message>
diff --git a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
index 56c02795c..403bd6f68 100644
--- a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
@@ -1249,5 +1249,16 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
// TODO startIndent, endIndent
}
+ /**
+ * Whether this LM can handle horizontal overflow error messages (only a BlockContainerLayoutManager can).
+ * @param milliPoints horizontal overflow
+ * @return true if handled by a BlockContainerLayoutManager
+ */
+ public boolean handleOverflow(int milliPoints) {
+ if (getParent() instanceof BlockStackingLayoutManager) {
+ return ((BlockStackingLayoutManager) getParent()).handleOverflow(milliPoints);
+ }
+ return false;
+ }
}
diff --git a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
index 3b2f11ea2..27958f7e0 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
@@ -45,6 +45,7 @@ import org.apache.fop.fonts.FontTriplet;
import org.apache.fop.hyphenation.Hyphenation;
import org.apache.fop.hyphenation.Hyphenator;
import org.apache.fop.layoutmgr.Adjustment;
+import org.apache.fop.layoutmgr.BlockLayoutManager;
import org.apache.fop.layoutmgr.BlockLevelLayoutManager;
import org.apache.fop.layoutmgr.BreakElement;
import org.apache.fop.layoutmgr.BreakingAlgorithm;
@@ -389,7 +390,10 @@ public class LineLayoutManager extends InlineStackingLayoutManager
if (log.isWarnEnabled()) {
int lack = difference + bestActiveNode.availableShrink;
- if (lack < 0) {
+ // if this LLM is nested inside a BlockContainerLayoutManager that is constraining
+ // the available width and thus responsible for the overflow then we do not issue
+ // warning event here and instead let the BCLM handle that at a later stage
+ if (lack < 0 && !handleOverflow(-lack)) {
InlineLevelEventProducer eventProducer
= InlineLevelEventProducer.Provider.get(
getFObj().getUserAgent().getEventBroadcaster());
@@ -1635,4 +1639,15 @@ public class LineLayoutManager extends InlineStackingLayoutManager
return true;
}
+ /**
+ * Whether this LM can handle horizontal overflow error messages (only a BlockContainerLayoutManager can).
+ * @param milliPoints horizontal overflow
+ * @return true if handled by a BlockContainerLayoutManager
+ */
+ public boolean handleOverflow(int milliPoints) {
+ if (getParent() instanceof BlockLayoutManager) {
+ return ((BlockLayoutManager) getParent()).handleOverflow(milliPoints);
+ }
+ return false;
+ }
}