Author: gadams
Date: Tue Apr 17 16:15:44 2012
New Revision: 1327157
URL: http://svn.apache.org/viewvc?rev=1327157&view=rev
Log:
Bugzilla #53094: Convert block container overflow exception to event model,
improving overflow property behavior.
Added:
xmlgraphics/fop/trunk/test/events/viewport-overflow.fo
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.xml
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
xmlgraphics/fop/trunk/status.xml
xmlgraphics/fop/trunk/test/events/inline-level.fo
xmlgraphics/fop/trunk/test/java/org/apache/fop/events/EventProcessingTestCase.java
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java?rev=1327157&r1=1327156&r2=1327157&view=diff
==============================================================================
---
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
(original)
+++
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
Tue Apr 17 16:15:44 2012
@@ -86,6 +86,7 @@ public class BlockContainerLayoutManager
private MinOptMax effSpaceBefore;
private MinOptMax effSpaceAfter;
+ private int horizontalOverflow;
private double contentRectOffsetX = 0;
private double contentRectOffsetY = 0;
@@ -401,7 +402,7 @@ public class BlockContainerLayoutManager
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
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
}
}
+ /** {@inheritDoc} */
+ public boolean handleOverflow(int milliPoints) {
+ if (milliPoints > this.horizontalOverflow) {
+ this.horizontalOverflow = milliPoints;
+ }
+ return true;
+ }
}
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.java?rev=1327157&r1=1327156&r2=1327157&view=diff
==============================================================================
---
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.java
(original)
+++
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.java
Tue Apr 17 16:15:44 2012
@@ -89,19 +89,30 @@ public interface BlockLevelEventProducer
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.
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.xml
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.xml?rev=1327157&r1=1327156&r2=1327157&view=diff
==============================================================================
---
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.xml
(original)
+++
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.xml
Tue Apr 17 16:15:44 2012
@@ -22,7 +22,8 @@
<message key="tableFixedAutoWidthNotSupported">table-layout="fixed" and
width="auto", but auto-layout not supported => 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 >
{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>
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java?rev=1327157&r1=1327156&r2=1327157&view=diff
==============================================================================
---
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
(original)
+++
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
Tue Apr 17 16:15:44 2012
@@ -1249,5 +1249,16 @@ public abstract class BlockStackingLayou
// 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;
+ }
}
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java?rev=1327157&r1=1327156&r2=1327157&view=diff
==============================================================================
---
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
(original)
+++
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
Tue Apr 17 16:15:44 2012
@@ -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 I
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 I
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;
+ }
}
Modified: xmlgraphics/fop/trunk/status.xml
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=1327157&r1=1327156&r2=1327157&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Tue Apr 17 16:15:44 2012
@@ -62,6 +62,9 @@
documents. Example: the fix of marks layering will be such a case when
it's done.
-->
<release version="FOP Trunk" date="TBD">
+ <action context="Code" dev="GA" type="update" fixes-bug="53094"
due-to="Luis Bernardo">
+ Convert block container overflow exception to event model, improving
overflow property behavior.
+ </action>
<action context="Code" dev="GA" type="update" fixes-bug="51617">
Add run target for embedded examples. Add increased JVM memory heap
flag for example8 in case font cache is rebuilt.
</action>
Modified: xmlgraphics/fop/trunk/test/events/inline-level.fo
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/events/inline-level.fo?rev=1327157&r1=1327156&r2=1327157&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/events/inline-level.fo (original)
+++ xmlgraphics/fop/trunk/test/events/inline-level.fo Tue Apr 17 16:15:44 2012
@@ -2,16 +2,14 @@
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>
<fo:simple-page-master master-name="page"
- page-height="420pt" page-width="320pt" margin="10pt">
+ page-height="420pt" page-width="100pt" margin="10pt">
<fo:region-body background-color="#F0F0F0"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="page">
<fo:flow flow-name="xsl-region-body">
<fo:block>The following line overflows its container:</fo:block>
- <fo:block-container width="100pt" height="100pt" border="1pt solid
black">
- <fo:block>ThisLineOverflowsItsContainer</fo:block>
- </fo:block-container>
+ <fo:block border="1pt solid
black">ThisLineOverflowsItsContainer</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
Added: xmlgraphics/fop/trunk/test/events/viewport-overflow.fo
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/events/viewport-overflow.fo?rev=1327157&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/test/events/viewport-overflow.fo (added)
+++ xmlgraphics/fop/trunk/test/events/viewport-overflow.fo Tue Apr 17 16:15:44
2012
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+ <fo:layout-master-set>
+ <fo:simple-page-master page-width="10.0cm" page-height="10.0cm"
master-name="testpage">
+ <fo:region-body />
+ </fo:simple-page-master>
+ </fo:layout-master-set>
+ <fo:page-sequence master-reference="testpage">
+ <fo:flow flow-name="xsl-region-body">
+ <fo:block-container overflow="error-if-overflow" position="absolute"
height="20pt" width="40pt" left="30pt" top="20pt">
+ <fo:block>abcdefghijklmnopqrstuvwxyz</fo:block>
+ </fo:block-container>
+ <fo:block-container overflow="error-if-overflow" position="absolute"
height="65pt" width="40pt" left="90pt" top="20pt">
+ <fo:block>abc def ghi jkl mno pqr stu vwx yz</fo:block>
+ </fo:block-container>
+ </fo:flow>
+ </fo:page-sequence>
+</fo:root>
Modified:
xmlgraphics/fop/trunk/test/java/org/apache/fop/events/EventProcessingTestCase.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/java/org/apache/fop/events/EventProcessingTestCase.java?rev=1327157&r1=1327156&r2=1327157&view=diff
==============================================================================
---
xmlgraphics/fop/trunk/test/java/org/apache/fop/events/EventProcessingTestCase.java
(original)
+++
xmlgraphics/fop/trunk/test/java/org/apache/fop/events/EventProcessingTestCase.java
Tue Apr 17 16:15:44 2012
@@ -124,4 +124,16 @@ public class EventProcessingTestCase {
doTest("inline-level.fo",
InlineLevelEventProducer.class.getName() + ".lineOverflows");
}
+
+ @Test
+ public void testViewportIPDOverflow() throws FOPException,
TransformerException, IOException,
+ SAXException {
+ doTest("viewport-overflow.fo", BlockLevelEventProducer.class.getName()
+ ".viewportIPDOverflow");
+ }
+
+ @Test
+ public void testViewportBPDOverflow() throws FOPException,
TransformerException, IOException,
+ SAXException {
+ doTest("viewport-overflow.fo", BlockLevelEventProducer.class.getName()
+ ".viewportBPDOverflow");
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]