You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2008/03/19 11:23:49 UTC
svn commit: r638777 - in
/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java:
META-INF/services/ org/apache/fop/apps/ org/apache/fop/events/
org/apache/fop/fo/ org/apache/fop/fo/flow/ org/apache/fop/layoutmgr/
org/apache/fop/layoutmgr/table/
Author: jeremias
Date: Wed Mar 19 03:23:40 2008
New Revision: 638777
URL: http://svn.apache.org/viewvc?rev=638777&view=rev
Log:
Generalized FOValidationEventListenerProxy into FOPEventListenerProxy, the main proxy for FOP's own event manipulation proxy. Done because of support for overflow="hidden" vs. overflow="error-if-overflow".
Switched block-level layout managers to events.
Some cleanup along the way.
Added:
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/FOPEventListenerProxy.java
- copied, changed from r637938, xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FOValidationEventListenerProxy.java
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/UnsupportedOperationExceptionFactory.java (with props)
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.java (with props)
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/LayoutException.java (with props)
Removed:
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FOValidationEventListenerProxy.java
Modified:
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/META-INF/services/org.apache.fop.events.EventExceptionManager$ExceptionFactory
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/apps/FOUserAgent.java
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/EventFormatter.xml
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/ResourceEventProducer.java
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/PageBreaker.java
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/PageProvider.java
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java
xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/META-INF/services/org.apache.fop.events.EventExceptionManager$ExceptionFactory
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/META-INF/services/org.apache.fop.events.EventExceptionManager%24ExceptionFactory?rev=638777&r1=638776&r2=638777&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/META-INF/services/org.apache.fop.events.EventExceptionManager$ExceptionFactory (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/META-INF/services/org.apache.fop.events.EventExceptionManager$ExceptionFactory Wed Mar 19 03:23:40 2008
@@ -1,2 +1,4 @@
org.apache.fop.events.ValidationExceptionFactory
org.apache.fop.events.PropertyExceptionFactory
+org.apache.fop.events.UnsupportedOperationExceptionFactory
+org.apache.fop.layoutmgr.LayoutException$LayoutExceptionFactory
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/apps/FOUserAgent.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/apps/FOUserAgent.java?rev=638777&r1=638776&r2=638777&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/apps/FOUserAgent.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/apps/FOUserAgent.java Wed Mar 19 03:23:40 2008
@@ -40,8 +40,8 @@
import org.apache.fop.events.Event;
import org.apache.fop.events.EventBroadcaster;
import org.apache.fop.events.EventListener;
+import org.apache.fop.events.FOPEventListenerProxy;
import org.apache.fop.fo.FOEventHandler;
-import org.apache.fop.fo.FOValidationEventListenerProxy;
import org.apache.fop.render.Renderer;
import org.apache.fop.render.RendererFactory;
import org.apache.fop.render.XMLHandlerRegistry;
@@ -551,7 +551,7 @@
private EventListener rootListener;
public FOPEventBroadcaster() {
- this.rootListener = new FOValidationEventListenerProxy(
+ this.rootListener = new FOPEventListenerProxy(
this.listeners, FOUserAgent.this);
}
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/EventFormatter.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/EventFormatter.xml?rev=638777&r1=638776&r2=638777&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/EventFormatter.xml (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/EventFormatter.xml Wed Mar 19 03:23:40 2008
@@ -62,7 +62,15 @@
<message key="org.apache.fop.events.ResourceEventProducer.imageNotFound">Image not found. URI: {uri}{{locator}}</message>
<message key="org.apache.fop.events.ResourceEventProducer.imageError">Image not available. URI: {uri}. Reason: {e}{{locator}}</message>
<message key="org.apache.fop.events.ResourceEventProducer.imageIOError">I/O error while loading image. URI: {uri}. Reason: {ioe}{{locator}}</message>
- <message key="org.apache.fop.events.ResourceEventProducer.ifoNoIntrinsiceSize">The intrinsic dimensions of an instream-foreign-object could not be determined.{{locator}}</message>
+ <message key="org.apache.fop.events.ResourceEventProducer.ifoNoIntrinsicSize">The intrinsic dimensions of an instream-foreign-object could not be determined.{{locator}}</message>
+ <message key="org.apache.fop.events.ResourceEventProducer.uriError">Error while handling URI: {uri}. Reason: {e}{{locator}}</message>
<message key="org.apache.fop.layoutmgr.inline.InlineLevelEventProducer.leaderWithoutContent">fo:leader is set to "use-content" but has no content.{{locator}}</message>
<message key="org.apache.fop.layoutmgr.inline.InlineLevelEventProducer.lineOverflows">Line {line} of a paragraph overflows the available area by {overflowLength,choice,50000#{overflowLength} millipoints|50000<more than 50 points}.{{locator}}</message>
+ <message key="org.apache.fop.layoutmgr.BlockLevelEventProducer.rowTooTall">The contents of table-row {row} are taller than they should be (there is a block-progression-dimension or height constraint on the indicated row). Due to its contents the row grows to {effCellBPD} millipoints, but the row shouldn't get any taller than {maxCellBPD} millipoints.{{locator}}</message>
+ <message key="org.apache.fop.layoutmgr.BlockLevelEventProducer.tableFixedAutoWidthNotSupported">table-layout="fixed" and width="auto", but auto-layout not supported => assuming width="100%".{{locator}}</message>
+ <message key="org.apache.fop.layoutmgr.BlockLevelEventProducer.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="org.apache.fop.layoutmgr.BlockLevelEventProducer.overconstrainedAdjustEndIndent">Adjusting end-indent based on overconstrained geometry rules for {elementName}.{{locator}}</message>
+ <message key="org.apache.fop.layoutmgr.BlockLevelEventProducer.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="org.apache.fop.layoutmgr.BlockLevelEventProducer.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="org.apache.fop.layoutmgr.BlockLevelEventProducer.flowNotMappingToRegionBody">Flow "{flowName}" does not map to the region-body in page-master "{masterName}". FOP presently does not support this.{{locator}}</message>
</catalogue>
Copied: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/FOPEventListenerProxy.java (from r637938, xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FOValidationEventListenerProxy.java)
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/FOPEventListenerProxy.java?p2=xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/FOPEventListenerProxy.java&p1=xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FOValidationEventListenerProxy.java&r1=637938&r2=638777&rev=638777&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/FOValidationEventListenerProxy.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/FOPEventListenerProxy.java Wed Mar 19 03:23:40 2008
@@ -17,22 +17,28 @@
/* $Id$ */
-package org.apache.fop.fo;
+package org.apache.fop.events;
import org.apache.fop.apps.FOUserAgent;
-import org.apache.fop.events.Event;
-import org.apache.fop.events.EventListener;
import org.apache.fop.events.model.EventSeverity;
+import org.apache.fop.fo.FOValidationEventProducer;
+import org.apache.fop.layoutmgr.BlockLevelEventProducer;
/**
- * EventListener proxy that inspects all validation events. It reacts on each event based on
- * the strict validation setting in the user agent.
+ * EventListener proxy that inspects all events and adjusts severity levels where necessary.
+ * For validation events, it reacts on each event based on the strict validation setting in
+ * the user agent.
+ * For layout events, it reduces the default severity level if FOP signals that it can recover
+ * from the event.
*/
-public class FOValidationEventListenerProxy implements EventListener {
+public class FOPEventListenerProxy implements EventListener {
private static final String FOVALIDATION_EVENT_ID_PREFIX
= FOValidationEventProducer.class.getName();
+ private static final String BLOCK_LEVEL_EVENT_ID_PREFIX
+ = BlockLevelEventProducer.class.getName();
+
private EventListener delegate;
private FOUserAgent userAgent;
@@ -41,7 +47,7 @@
* @param delegate the event listener to delegate events to
* @param userAgent the FO user agent
*/
- public FOValidationEventListenerProxy(EventListener delegate, FOUserAgent userAgent) {
+ public FOPEventListenerProxy(EventListener delegate, FOUserAgent userAgent) {
this.delegate = delegate;
this.userAgent = userAgent;
}
@@ -51,6 +57,12 @@
if (event.getEventID().startsWith(FOVALIDATION_EVENT_ID_PREFIX)) {
Boolean canRecover = (Boolean)event.getParam("canRecover");
if (Boolean.TRUE.equals(canRecover) && !userAgent.validateStrictly()) {
+ //Reduce severity if FOP can recover
+ event.setSeverity(EventSeverity.WARN);
+ }
+ } else if (event.getEventID().startsWith(BLOCK_LEVEL_EVENT_ID_PREFIX)) {
+ Boolean canRecover = (Boolean)event.getParam("canRecover");
+ if (Boolean.TRUE.equals(canRecover)) {
//Reduce severity if FOP can recover
event.setSeverity(EventSeverity.WARN);
}
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/ResourceEventProducer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/ResourceEventProducer.java?rev=638777&r1=638776&r2=638777&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/ResourceEventProducer.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/ResourceEventProducer.java Wed Mar 19 03:23:40 2008
@@ -78,10 +78,20 @@
void imageIOError(Object source, String uri, IOException ioe, Locator loc);
/**
+ * Error while handling a URI.
+ * @param source the event source
+ * @param uri the original URI of the image
+ * @param e the original exception
+ * @param loc the location of the error or null
+ * @event.severity ERROR
+ */
+ void uriError(Object source, String uri, Exception e, Locator loc);
+
+ /**
* Intrinsic size of fo:instream-foreign-object could not be determined.
* @param source the event source
* @param loc the location of the error or null
* @event.severity ERROR
*/
- void ifoNoIntrinsiceSize(Object source, Locator loc);
+ void ifoNoIntrinsicSize(Object source, Locator loc);
}
Added: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/UnsupportedOperationExceptionFactory.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/UnsupportedOperationExceptionFactory.java?rev=638777&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/UnsupportedOperationExceptionFactory.java (added)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/UnsupportedOperationExceptionFactory.java Wed Mar 19 03:23:40 2008
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.events;
+
+import java.util.Locale;
+
+import org.apache.fop.events.EventExceptionManager.ExceptionFactory;
+
+/**
+ * Exception factory for {@link UnsupportedOperationException}.
+ */
+public class UnsupportedOperationExceptionFactory implements ExceptionFactory {
+
+ /** {@inheritDoc} */
+ public Throwable createException(Event event) {
+ String msg = EventFormatter.format(event, Locale.ENGLISH);
+ UnsupportedOperationException ex = new UnsupportedOperationException(msg);
+ return ex;
+ }
+
+ /** {@inheritDoc} */
+ public Class getExceptionClass() {
+ return UnsupportedOperationException.class;
+ }
+
+}
\ No newline at end of file
Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/UnsupportedOperationExceptionFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/events/UnsupportedOperationExceptionFactory.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java?rev=638777&r1=638776&r2=638777&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java Wed Mar 19 03:23:40 2008
@@ -100,7 +100,7 @@
if (intrinsicDimensions == null) {
ResourceEventProducer eventProducer = ResourceEventProducer.Factory.create(
getUserAgent().getEventBroadcaster());
- eventProducer.ifoNoIntrinsiceSize(this, getLocator());
+ eventProducer.ifoNoIntrinsicSize(this, getLocator());
}
intrinsicAlignmentAdjust = child.getIntrinsicAlignmentAdjust();
}
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java?rev=638777&r1=638776&r2=638777&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java Wed Mar 19 03:23:40 2008
@@ -198,11 +198,11 @@
}
/**
- * Returns a PageBreakingLayoutListener for the PageBreakingAlgorithm to notify about layout
- * problems.
+ * Creates and returns a PageBreakingLayoutListener for the PageBreakingAlgorithm to
+ * notify about layout problems.
* @return the listener instance or null if no notifications are needed
*/
- protected PageBreakingAlgorithm.PageBreakingLayoutListener getLayoutListener() {
+ protected PageBreakingAlgorithm.PageBreakingLayoutListener createLayoutListener() {
return null;
}
@@ -320,7 +320,7 @@
log.debug("PLM> start of algorithm (" + this.getClass().getName()
+ "), flow BPD =" + flowBPD);
PageBreakingAlgorithm alg = new PageBreakingAlgorithm(getTopLevelLM(),
- getPageProvider(), getLayoutListener(),
+ getPageProvider(), createLayoutListener(),
alignment, alignmentLast, footnoteSeparatorLength,
isPartOverflowRecoveryActivated(), autoHeight, isSinglePartFavored());
int iOptPageCount;
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java?rev=638777&r1=638776&r2=638777&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java Wed Mar 19 03:23:40 2008
@@ -32,12 +32,9 @@
import org.apache.fop.area.Block;
import org.apache.fop.area.BlockViewport;
import org.apache.fop.area.CTM;
-import org.apache.fop.area.BlockViewport;
-import org.apache.fop.area.CTM;
import org.apache.fop.area.Trait;
import org.apache.fop.datatypes.FODimension;
import org.apache.fop.datatypes.Length;
-import org.apache.fop.fo.FONode;
import org.apache.fop.fo.flow.BlockContainer;
import org.apache.fop.fo.properties.CommonAbsolutePosition;
import org.apache.fop.layoutmgr.inline.InlineLayoutManager;
@@ -242,11 +239,11 @@
int availableIPD = referenceIPD - getIPIndents();
if (getContentAreaIPD() > availableIPD) {
- log.warn(FONode.decorateWithContextInfo(
- "The extent in inline-progression-direction (width) of a block-container is"
- + " bigger than the available space ("
- + getContentAreaIPD() + "mpt > " + context.getRefIPD() + "mpt)",
- getBlockContainerFO()));
+ BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Factory.create(
+ getBlockContainerFO().getUserAgent().getEventBroadcaster());
+ eventProducer.objectTooWide(this, getBlockContainerFO().getName(),
+ getContentAreaIPD(), context.getRefIPD(),
+ getBlockContainerFO().getLocator());
}
MinOptMax stackLimit = new MinOptMax(relDims.bpd);
@@ -382,10 +379,12 @@
*/
if (contentOverflows) {
- log.warn("Contents overflow block-container viewport: clipping");
- if (getBlockContainerFO().getOverflow() == EN_ERROR_IF_OVERFLOW) {
- //TODO Throw layout exception
- }
+ BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Factory.create(
+ getBlockContainerFO().getUserAgent().getEventBroadcaster());
+ boolean canRecover = (getBlockContainerFO().getOverflow() != EN_ERROR_IF_OVERFLOW);
+ eventProducer.viewportOverflow(this, getBlockContainerFO().getName(),
+ breaker.getOverflowAmount(), needClip(), canRecover,
+ getBlockContainerFO().getLocator());
}
}
addKnuthElementsForBorderPaddingAfter(returnList, true);
@@ -527,10 +526,12 @@
//TODO Maybe check for page overflow when autoHeight=true
if (!autoHeight & (contentOverflows)) {
- log.warn("Contents overflow block-container viewport: clipping");
- if (getBlockContainerFO().getOverflow() == EN_ERROR_IF_OVERFLOW) {
- //TODO Throw layout exception
- }
+ BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Factory.create(
+ getBlockContainerFO().getUserAgent().getEventBroadcaster());
+ boolean canRecover = (getBlockContainerFO().getOverflow() != EN_ERROR_IF_OVERFLOW);
+ eventProducer.viewportOverflow(this, getBlockContainerFO().getName(),
+ breaker.getOverflowAmount(), needClip(), canRecover,
+ getBlockContainerFO().getLocator());
}
}
@@ -606,8 +607,15 @@
if (isEmpty()) {
return false;
} else {
- return (deferredAlg.getPageBreaks().size() > 1);
+ return (deferredAlg.getPageBreaks().size() > 1)
+ || (deferredAlg.totalWidth - deferredAlg.totalShrink)
+ > deferredAlg.getLineWidth();
}
+ }
+
+ public int getOverflowAmount() {
+ return (deferredAlg.totalWidth - deferredAlg.totalShrink)
+ - deferredAlg.getLineWidth();
}
protected LayoutManager getTopLevelLM() {
Added: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.java?rev=638777&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.java (added)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.java Wed Mar 19 03:23:40 2008
@@ -0,0 +1,133 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.layoutmgr;
+
+import org.xml.sax.Locator;
+
+import org.apache.fop.apps.FOPException;
+import org.apache.fop.events.EventBroadcaster;
+import org.apache.fop.events.EventProducer;
+
+/**
+ * Event producer interface for block-level layout managers.
+ */
+public interface BlockLevelEventProducer extends EventProducer {
+
+ /**
+ * Factory class for the event producer.
+ */
+ class Factory {
+
+ /**
+ * Creates a new event producer.
+ * @param broadcaster the event broadcaster to use
+ * @return the new event producer
+ */
+ public static BlockLevelEventProducer create(EventBroadcaster broadcaster) {
+ return (BlockLevelEventProducer)broadcaster.getEventProducerFor(
+ BlockLevelEventProducer.class);
+ }
+ }
+
+ /**
+ * The contents of a table-row are too big to fit in the constraints.
+ * @param source the event source
+ * @param row the row number
+ * @param effCellBPD the effective extent in block-progression direction of the cell
+ * @param maxCellBPD the maximum extent in block-progression direction of the cell
+ * @param loc the location of the error or null
+ * @event.severity WARN
+ */
+ void rowTooTall(Object source, int row, int effCellBPD, int maxCellBPD, Locator loc);
+
+ /**
+ * Auto-table layout is not supported, yet.
+ * @param source the event source
+ * @param loc the location of the error or null
+ * @event.severity INFO
+ */
+ void tableFixedAutoWidthNotSupported(Object source, Locator loc);
+
+ /**
+ * An formatting object is too wide.
+ * @param source the event source
+ * @param elementName the formatting object
+ * @param effIPD the effective extent in inline-progression direction of the table contents
+ * @param maxIPD the maximum extent in inline-progression direction available
+ * @param loc the location of the error or null
+ * @event.severity WARN
+ */
+ void objectTooWide(Object source, String elementName, int effIPD, int maxIPD, Locator loc);
+
+ /**
+ * An overconstrained geometry adjustment rule was triggered (5.3.4, XSL 1.0).
+ * @param source the event source
+ * @param elementName the formatting object
+ * @param amount the amount of the adjustment (in mpt)
+ * @param loc the location of the error or null
+ * @event.severity DEBUG
+ */
+ void overconstrainedAdjustEndIndent(Object source, String elementName, int amount, Locator loc);
+
+ /**
+ * Contents 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
+ */
+ void viewportOverflow(Object source, String elementName,
+ int amount, boolean clip, boolean canRecover,
+ Locator loc) throws LayoutException;
+
+ /**
+ * Contents overflow a region viewport.
+ * @param source the event source
+ * @param elementName the formatting object
+ * @param page the page number/name where the overflow happened
+ * @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
+ */
+ void regionOverflow(Object source, String elementName,
+ String page,
+ int amount, boolean clip, boolean canRecover,
+ Locator loc) throws LayoutException;
+
+ /**
+ * Indicates that FOP doesn't support flows that are not mapped to region-body, yet.
+ * @param source the event source
+ * @param flowName the flow name
+ * @param masterName the page master name
+ * @param loc the location of the error or null
+ * @throws UnsupportedOperationException the layout error provoked by the method call
+ * @event.severity FATAL
+ */
+ void flowNotMappingToRegionBody(Object source, String flowName, String masterName,
+ Locator loc) throws UnsupportedOperationException;
+
+}
Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/BlockLevelEventProducer.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java?rev=638777&r1=638776&r2=638777&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java Wed Mar 19 03:23:40 2008
@@ -201,6 +201,10 @@
if (ipd < 0) {
//5.3.4, XSL 1.0, Overconstrained Geometry
log.debug("Adjusting end-indent based on overconstrained geometry rules for " + fobj);
+ BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Factory.create(
+ getFObj().getUserAgent().getEventBroadcaster());
+ eventProducer.overconstrainedAdjustEndIndent(this,
+ getFObj().getName(), ipd, getFObj().getLocator());
endIndent += ipd;
ipd = 0;
//TODO Should we skip layout for a block that has ipd=0?
@@ -212,7 +216,7 @@
/**
* Sets the content area IPD by directly supplying the value.
* end-indent is adjusted based on overconstrained geometry rules, if necessary.
- *
+ * @param contentIPD the IPD of the content
* @return the resulting content area IPD
*/
protected int updateContentAreaIPDwithOverconstrainedAdjust(int contentIPD) {
@@ -220,6 +224,10 @@
if (ipd < 0) {
//5.3.4, XSL 1.0, Overconstrained Geometry
log.debug("Adjusting end-indent based on overconstrained geometry rules for " + fobj);
+ BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Factory.create(
+ getFObj().getUserAgent().getEventBroadcaster());
+ eventProducer.overconstrainedAdjustEndIndent(this,
+ getFObj().getName(), ipd, getFObj().getLocator());
endIndent += ipd;
}
setContentAreaIPD(contentIPD);
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java?rev=638777&r1=638776&r2=638777&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/ExternalDocumentLayoutManager.java Wed Mar 19 03:23:40 2008
@@ -21,6 +21,7 @@
import java.awt.Dimension;
import java.awt.Rectangle;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
@@ -46,6 +47,7 @@
import org.apache.fop.area.inline.Viewport;
import org.apache.fop.datatypes.FODimension;
import org.apache.fop.datatypes.URISpecification;
+import org.apache.fop.events.ResourceEventProducer;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.extensions.ExternalDocument;
import org.apache.fop.layoutmgr.inline.ImageLayout;
@@ -140,15 +142,26 @@
pageIndex++;
}
} catch (URISyntaxException e) {
- log.error("Error parsing or constructing URIs based on URI: " + uri);
+ getResourceEventProducer().uriError(this, uri, e,
+ getExternalDocument().getLocator());
return;
}
}
+ } catch (FileNotFoundException fnfe) {
+ getResourceEventProducer().imageNotFound(this, uri, fnfe,
+ getExternalDocument().getLocator());
} catch (IOException ioe) {
- log.error("Image not available: " + uri, ioe);
+ getResourceEventProducer().imageIOError(this, uri, ioe,
+ getExternalDocument().getLocator());
} catch (ImageException ie) {
- log.error("Error while inspecting image: " + uri + " (" + ie.getMessage() + ")");
+ getResourceEventProducer().imageError(this, uri, ie,
+ getExternalDocument().getLocator());
}
+ }
+
+ private ResourceEventProducer getResourceEventProducer() {
+ return ResourceEventProducer.Factory.create(
+ getExternalDocument().getUserAgent().getEventBroadcaster());
}
private void makePageForImage(ImageInfo info, ImageLayout layout) {
Added: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/LayoutException.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/LayoutException.java?rev=638777&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/LayoutException.java (added)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/LayoutException.java Wed Mar 19 03:23:40 2008
@@ -0,0 +1,105 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.layoutmgr;
+
+import java.util.Locale;
+
+import org.apache.fop.events.Event;
+import org.apache.fop.events.EventFormatter;
+import org.apache.fop.events.EventExceptionManager.ExceptionFactory;
+
+/**
+ * Exception thrown by FOP if an unrecoverable layout error occurs. An example: An area overflows
+ * a viewport that has overflow="error-if-overflow".
+ *
+ * @todo Discuss if this should become a checked exception.
+ */
+public class LayoutException extends RuntimeException {
+
+ private static final long serialVersionUID = 5157080040923740433L;
+
+ private String localizedMessage;
+ private LayoutManager layoutManager;
+
+ /**
+ * Constructs a new layout exception with the specified detail message.
+ * @param message the detail message.
+ */
+ public LayoutException(String message) {
+ this(message, null);
+ }
+
+ /**
+ * Constructs a new layout exception with the specified detail message.
+ * @param message the detail message
+ * @param lm the layout manager that throws the exception
+ */
+ public LayoutException(String message, LayoutManager lm) {
+ super(message);
+ this.layoutManager = lm;
+ }
+
+ /**
+ * Sets the localized message for this exception.
+ * @param msg the localized message
+ */
+ public void setLocalizedMessage(String msg) {
+ this.localizedMessage = msg;
+ }
+
+ /** {@inheritDoc} */
+ public String getLocalizedMessage() {
+ if (this.localizedMessage != null) {
+ return this.localizedMessage;
+ } else {
+ return super.getLocalizedMessage();
+ }
+ }
+
+ /**
+ * Returns the layout manager that detected the problem.
+ * @return the layout manager (or null)
+ */
+ public LayoutManager getLayoutManager() {
+ return this.layoutManager;
+ }
+
+ /** Exception factory for {@link LayoutException}. */
+ public static class LayoutExceptionFactory implements ExceptionFactory {
+
+ /** {@inheritDoc} */
+ public Throwable createException(Event event) {
+ Object source = event.getSource();
+ LayoutManager lm = (source instanceof LayoutManager) ? (LayoutManager)source : null;
+ String msg = EventFormatter.format(event, Locale.ENGLISH);
+ LayoutException ex = new LayoutException(msg, lm);
+ if (!Locale.ENGLISH.equals(Locale.getDefault())) {
+ ex.setLocalizedMessage(EventFormatter.format(event));
+ }
+ return ex;
+ }
+
+ /** {@inheritDoc} */
+ public Class getExceptionClass() {
+ return LayoutException.class;
+ }
+
+ }
+}
Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/LayoutException.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/LayoutException.java
------------------------------------------------------------------------------
svn:keywords = Id
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/PageBreaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/PageBreaker.java?rev=638777&r1=638776&r2=638777&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/PageBreaker.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/PageBreaker.java Wed Mar 19 03:23:40 2008
@@ -27,7 +27,6 @@
import org.apache.fop.area.Footnote;
import org.apache.fop.area.PageViewport;
import org.apache.fop.fo.Constants;
-import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.pagination.PageSequence;
import org.apache.fop.fo.pagination.Region;
@@ -79,27 +78,25 @@
return pslm.getPageProvider();
}
- /**
- * {@inheritDoc}
- */
- protected PageBreakingLayoutListener getLayoutListener() {
+ /** {@inheritDoc} */
+ protected PageBreakingLayoutListener createLayoutListener() {
return new PageBreakingLayoutListener() {
- public void notifyOverflow(int part, FObj obj) {
+ public void notifyOverflow(int part, int amount, FObj obj) {
Page p = pageProvider.getPage(
false, part, PageProvider.RELTO_CURRENT_ELEMENT_LIST);
RegionBody body = (RegionBody)p.getSimplePageMaster().getRegion(
Region.FO_REGION_BODY);
- String err = FONode.decorateWithContextInfo(
- "Content of the region-body on page "
- + p.getPageViewport().getPageNumberString()
- + " overflows the available area in block-progression dimension.",
- obj);
- if (body.getOverflow() == Constants.EN_ERROR_IF_OVERFLOW) {
- throw new RuntimeException(err);
- } else {
- log.warn(err);
- }
+ BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Factory.create(
+ body.getUserAgent().getEventBroadcaster());
+
+ boolean canRecover = (body.getOverflow() != Constants.EN_ERROR_IF_OVERFLOW);
+ boolean needClip = (body.getOverflow() == Constants.EN_HIDDEN
+ || body.getOverflow() == Constants.EN_ERROR_IF_OVERFLOW);
+ eventProducer.regionOverflow(this, body.getName(),
+ p.getPageViewport().getPageNumberString(),
+ amount, needClip, canRecover,
+ body.getLocator());
}
};
@@ -297,7 +294,7 @@
//Restart last page
PageBreakingAlgorithm algRestart = new PageBreakingAlgorithm(
getTopLevelLM(),
- getPageProvider(), getLayoutListener(),
+ getPageProvider(), createLayoutListener(),
alg.getAlignment(), alg.getAlignmentLast(),
footnoteSeparatorLength,
isPartOverflowRecoveryActivated(), false, false);
@@ -356,7 +353,7 @@
//Restart last page
PageBreakingAlgorithm algRestart = new BalancingColumnBreakingAlgorithm(
getTopLevelLM(),
- getPageProvider(), getLayoutListener(),
+ getPageProvider(), createLayoutListener(),
alignment, Constants.EN_START, footnoteSeparatorLength,
isPartOverflowRecoveryActivated(),
pslm.getCurrentPV().getBodyRegion().getColumnCount());
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java?rev=638777&r1=638776&r2=638777&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/PageBreakingAlgorithm.java Wed Mar 19 03:23:40 2008
@@ -27,7 +27,6 @@
import org.apache.commons.logging.LogFactory;
import org.apache.fop.fo.Constants;
-import org.apache.fop.fo.FONode;
import org.apache.fop.fo.FObj;
import org.apache.fop.layoutmgr.AbstractBreaker.PageBreakPosition;
import org.apache.fop.traits.MinOptMax;
@@ -289,7 +288,7 @@
private void resetFootnotes(LinkedList elementLists) {
for (int i = 0; i < elementLists.size(); i++) {
- LinkedList removedList = (LinkedList) footnotesList.remove(footnotesList.size() - 1);
+ /*LinkedList removedList = (LinkedList)*/footnotesList.remove(footnotesList.size() - 1);
lengthList.remove(lengthList.size() - 1);
// update totalFootnotesLength
@@ -332,11 +331,13 @@
actualWidth += allFootnotes;
insertedFootnotesLength = pageNode.totalFootnotes + allFootnotes;
footnoteListIndex = footnotesList.size() - 1;
- footnoteElementIndex = ((LinkedList) footnotesList.get(footnoteListIndex)).size() - 1;
- } else if (((canDeferOldFootnotes = checkCanDeferOldFootnotes(pageNode, elementIndex))
+ footnoteElementIndex
+ = ((LinkedList) footnotesList.get(footnoteListIndex)).size() - 1;
+ } else if (((canDeferOldFootnotes
+ = checkCanDeferOldFootnotes(pageNode, elementIndex))
|| newFootnotes)
- && (footnoteSplit = getFootnoteSplit(pageNode, getLineWidth() - actualWidth,
- canDeferOldFootnotes)) > 0) {
+ && (footnoteSplit = getFootnoteSplit(pageNode,
+ getLineWidth() - actualWidth, canDeferOldFootnotes)) > 0) {
// it is allowed to break or even defer footnotes if either:
// - there are new footnotes in the last piece of content, and
// there is space to add at least a piece of the first one
@@ -356,7 +357,8 @@
actualWidth += allFootnotes;
insertedFootnotesLength = pageNode.totalFootnotes + allFootnotes;
footnoteListIndex = footnotesList.size() - 1;
- footnoteElementIndex = ((LinkedList) footnotesList.get(footnoteListIndex)).size() - 1;
+ footnoteElementIndex
+ = ((LinkedList) footnotesList.get(footnoteListIndex)).size() - 1;
}
} else {
// all footnotes have already been placed on previous pages
@@ -381,7 +383,8 @@
*/
private boolean checkCanDeferOldFootnotes(KnuthPageNode node, int contentElementIndex) {
return (noBreakBetween(node.position, contentElementIndex)
- && deferredFootnotes(node.footnoteListIndex, node.footnoteElementIndex, node.totalFootnotes));
+ && deferredFootnotes(node.footnoteListIndex,
+ node.footnoteElementIndex, node.totalFootnotes));
}
/**
@@ -455,7 +458,8 @@
* @param availableLength available space for footnotes
* @param canDeferOldFootnotes
*/
- private int getFootnoteSplit(KnuthPageNode activeNode, int availableLength, boolean canDeferOldFootnotes) {
+ private int getFootnoteSplit(KnuthPageNode activeNode, int availableLength,
+ boolean canDeferOldFootnotes) {
return getFootnoteSplit(activeNode.footnoteListIndex,
activeNode.footnoteElementIndex,
activeNode.totalFootnotes,
@@ -520,7 +524,8 @@
}
// try adding a split of the next note
- noteListIterator = ((LinkedList) footnotesList.get(listIndex)).listIterator(elementIndex);
+ noteListIterator = ((LinkedList) footnotesList.get(listIndex))
+ .listIterator(elementIndex);
int prevSplitLength = 0;
int prevIndex = -1;
@@ -754,14 +759,6 @@
}
}
- private int getPartCount() {
- if (pageBreaks == null) {
- return 0;
- } else {
- return pageBreaks.size();
- }
- }
-
public void updateData1(int total, double demerits) {
}
@@ -774,12 +771,7 @@
if (difference + bestActiveNode.availableShrink < 0) {
if (!autoHeight) {
if (layoutListener != null) {
- layoutListener.notifyOverflow(bestActiveNode.line - 1, getFObj());
- } else if (log.isWarnEnabled()) {
- log.warn(FONode.decorateWithContextInfo(
- "Part/page " + (bestActiveNode.line - 1)
- + " overflows the available area in block-progression dimension.",
- getFObj()));
+ layoutListener.notifyOverflow(bestActiveNode.line - 1, -difference, getFObj());
}
}
}
@@ -890,9 +882,10 @@
/**
* Issued when an overflow is detected
* @param part the number of the part (page) this happens on
+ * @param amount the amount by which the area overflows (in mpt)
* @param obj the root FO object where this happens
*/
- void notifyOverflow(int part, FObj obj);
+ void notifyOverflow(int part, int amount, FObj obj);
}
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/PageProvider.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/PageProvider.java?rev=638777&r1=638776&r2=638777&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/PageProvider.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/PageProvider.java Wed Mar 19 03:23:40 2008
@@ -23,6 +23,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.apache.fop.apps.FOPException;
import org.apache.fop.area.AreaTreeHandler;
import org.apache.fop.fo.Constants;
@@ -74,6 +75,7 @@
/**
* Main constructor.
+ * @param ath the area tree handler
* @param ps The page-sequence the provider operates on
*/
public PageProvider(AreaTreeHandler ath, PageSequence ps) {
@@ -258,10 +260,10 @@
if (!pageSeq.getMainFlow().getFlowName().equals(body.getRegionName())) {
// this is fine by the XSL Rec (fo:flow's flow-name can be mapped to
// any region), but we don't support it yet.
- throw new FOPException("Flow '" + pageSeq.getMainFlow().getFlowName()
- + "' does not map to the region-body in page-master '"
- + spm.getMasterName() + "'. FOP presently "
- + "does not support this.");
+ BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Factory.create(
+ pageSeq.getUserAgent().getEventBroadcaster());
+ eventProducer.flowNotMappingToRegionBody(this,
+ pageSeq.getMainFlow().getFlowName(), spm.getMasterName(), spm.getLocator());
}
Page page = new Page(spm, index, pageNumberString, isBlank);
//Set unique key obtained from the AreaTreeHandler
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java?rev=638777&r1=638776&r2=638777&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java Wed Mar 19 03:23:40 2008
@@ -29,10 +29,12 @@
import org.apache.fop.area.Area;
import org.apache.fop.area.Block;
import org.apache.fop.area.RegionReference;
-import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.Constants;
+import org.apache.fop.fo.FObj;
import org.apache.fop.fo.pagination.PageSequence;
import org.apache.fop.fo.pagination.SideRegion;
import org.apache.fop.fo.pagination.StaticContent;
+import org.apache.fop.layoutmgr.PageBreakingAlgorithm.PageBreakingLayoutListener;
import org.apache.fop.layoutmgr.inline.InlineLevelLayoutManager;
import org.apache.fop.layoutmgr.inline.TextLayoutManager;
import org.apache.fop.traits.MinOptMax;
@@ -240,12 +242,17 @@
breaker.doLayout(targetBPD, autoHeight);
if (breaker.isOverflow()) {
if (!autoHeight) {
- //Overflow handling
- if (regionFO.getOverflow() == EN_ERROR_IF_OVERFLOW) {
- //TODO throw layout exception
- }
- log.warn(FONode.decorateWithContextInfo(
- "static-content overflows the available area.", fobj));
+ String page = getPSLM().getCurrentPage().getPageViewport().getPageNumberString();
+
+ BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Factory.create(
+ getStaticContentFO().getUserAgent().getEventBroadcaster());
+ boolean canRecover = (regionFO.getOverflow() != EN_ERROR_IF_OVERFLOW);
+ boolean needClip = (regionFO.getOverflow() == Constants.EN_HIDDEN
+ || regionFO.getOverflow() == Constants.EN_ERROR_IF_OVERFLOW);
+ eventProducer.regionOverflow(this, regionFO.getName(),
+ page,
+ breaker.getOverflowAmount(), needClip, canRecover,
+ getStaticContentFO().getLocator());
}
}
}
@@ -262,7 +269,7 @@
private StaticContentLayoutManager lm;
private int displayAlign;
private int ipd;
- private boolean overflow = false;
+ private int overflow = 0;
public StaticContentBreaker(StaticContentLayoutManager lm, int ipd,
int displayAlign) {
@@ -288,9 +295,26 @@
}
public boolean isOverflow() {
+ return (this.overflow != 0);
+ }
+
+ public int getOverflowAmount() {
return this.overflow;
}
+ /** {@inheritDoc} */
+ protected PageBreakingLayoutListener createLayoutListener() {
+ return new PageBreakingLayoutListener() {
+
+ public void notifyOverflow(int part, int amount, FObj obj) {
+ if (StaticContentBreaker.this.overflow == 0) {
+ StaticContentBreaker.this.overflow = amount;
+ }
+ }
+
+ };
+ }
+
protected LayoutManager getTopLevelLM() {
return lm;
}
@@ -340,9 +364,6 @@
protected void doPhase3(PageBreakingAlgorithm alg, int partCount,
BlockSequence originalList, BlockSequence effectiveList) {
- if (partCount > 1) {
- overflow = true;
- }
//Rendering all parts (not just the first) at once for the case where the parts that
//overflow should be visible.
alg.removeAllPageBreaks();
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java?rev=638777&r1=638776&r2=638777&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java Wed Mar 19 03:23:40 2008
@@ -25,9 +25,9 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.fop.datatypes.PercentBaseContext;
-import org.apache.fop.datatypes.Length;
+import org.apache.fop.datatypes.Length;
+import org.apache.fop.datatypes.PercentBaseContext;
import org.apache.fop.fo.FONode;
import org.apache.fop.fo.flow.table.Table;
import org.apache.fop.fo.flow.table.TableColumn;
@@ -77,12 +77,14 @@
}
}
//Post-processing the list (looking for gaps)
+ //TODO The following block could possibly be removed
int pos = 1;
ListIterator ppIter = columns.listIterator();
while (ppIter.hasNext()) {
TableColumn col = (TableColumn)ppIter.next();
if (col == null) {
- log.error("Found a gap in the table-columns at position " + pos);
+ assert false; //Gaps are filled earlier by fo.flow.table.Table.finalizeColumns()
+ //log.error("Found a gap in the table-columns at position " + pos);
}
pos++;
}
@@ -100,7 +102,9 @@
if (index > size) {
if (index > maxColIndexReferenced) {
maxColIndexReferenced = index;
- if (!(size == 1 && getColumn(1).isImplicitColumn())) {
+ TableColumn col = getColumn(1);
+ if (!(size == 1 && col.isImplicitColumn())) {
+ assert false; //TODO Seems to be removable as this is now done in the FO tree
log.warn(FONode.decorateWithContextInfo(
"There are fewer table-columns than are needed. "
+ "Column " + index + " was accessed, but only "
@@ -193,8 +197,7 @@
if (colWidth != null) {
sumCols += colWidth.getValue(tlm);
if (colWidth instanceof TableColLength) {
- factors +=
- ((TableColLength) colWidth).getTableUnits();
+ factors += ((TableColLength) colWidth).getTableUnits();
}
}
}
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java?rev=638777&r1=638776&r2=638777&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/table/RowGroupLayoutManager.java Wed Mar 19 03:23:40 2008
@@ -24,14 +24,15 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.apache.fop.fo.Constants;
-import org.apache.fop.fo.FONode;
import org.apache.fop.fo.flow.table.EffRow;
import org.apache.fop.fo.flow.table.GridUnit;
import org.apache.fop.fo.flow.table.PrimaryGridUnit;
import org.apache.fop.fo.flow.table.TableRow;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
import org.apache.fop.fo.properties.LengthRangeProperty;
+import org.apache.fop.layoutmgr.BlockLevelEventProducer;
import org.apache.fop.layoutmgr.ElementListObserver;
import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.MinOptMaxUtil;
@@ -207,14 +208,10 @@
row.setHeight(rowHeights[rgi]);
row.setExplicitHeight(explicitRowHeights[rgi]);
if (maxCellBPD > row.getExplicitHeight().max) {
- log.warn(FONode.decorateWithContextInfo(
- "The contents of row " + (row.getIndex() + 1)
- + " are taller than they should be (there is a"
- + " block-progression-dimension or height constraint on the indicated row)."
- + " Due to its contents the row grows"
- + " to " + maxCellBPD + " millipoints, but the row shouldn't get"
- + " any taller than " + row.getExplicitHeight() + " millipoints.",
- row.getTableRow()));
+ BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Factory.create(
+ tableRow.getUserAgent().getEventBroadcaster());
+ eventProducer.rowTooTall(this, row.getIndex() + 1,
+ maxCellBPD, row.getExplicitHeight().max, tableRow.getLocator());
}
}
if (log.isDebugEnabled()) {
Modified: xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java?rev=638777&r1=638776&r2=638777&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_ProcessingFeedback/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java Wed Mar 19 03:23:40 2008
@@ -26,6 +26,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.apache.fop.area.Area;
import org.apache.fop.area.Block;
import org.apache.fop.datatypes.LengthBase;
@@ -34,6 +35,7 @@
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.flow.table.Table;
import org.apache.fop.fo.flow.table.TableColumn;
+import org.apache.fop.layoutmgr.BlockLevelEventProducer;
import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
import org.apache.fop.layoutmgr.BreakElement;
import org.apache.fop.layoutmgr.ConditionalElementListener;
@@ -189,9 +191,9 @@
updateContentAreaIPDwithOverconstrainedAdjust(contentIPD);
} else {
if (!getTable().isAutoLayout()) {
- log.info("table-layout=\"fixed\" and width=\"auto\", "
- + "but auto-layout not supported "
- + "=> assuming width=\"100%\"");
+ BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Factory.create(
+ getTable().getUserAgent().getEventBroadcaster());
+ eventProducer.tableFixedAutoWidthNotSupported(this, getTable().getLocator());
}
updateContentAreaIPDwithOverconstrainedAdjust();
}
@@ -204,11 +206,11 @@
}
int availableIPD = referenceIPD - getIPIndents();
if (getContentAreaIPD() > availableIPD) {
- log.warn(FONode.decorateWithContextInfo(
- "The extent in inline-progression-direction (width) of a table is"
- + " bigger than the available space ("
- + getContentAreaIPD() + "mpt > " + context.getRefIPD() + "mpt)",
- getTable()));
+ BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Factory.create(
+ getTable().getUserAgent().getEventBroadcaster());
+ eventProducer.objectTooWide(this, getTable().getName(),
+ getContentAreaIPD(), context.getRefIPD(),
+ getTable().getLocator());
}
/* initialize unit to determine computed values
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org