From 1602293aea20cc89e90fa74e102167fc488c6745 Mon Sep 17 00:00:00 2001 From: Keiron Liddle Date: Wed, 16 May 2001 09:27:27 +0000 Subject: [PATCH] shows message if some content could not fit in static content git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194242 13f79535-47bb-0310-9956-ffa450edef68 --- src/org/apache/fop/fo/flow/StaticContent.java | 139 +++++++++--------- 1 file changed, 68 insertions(+), 71 deletions(-) diff --git a/src/org/apache/fop/fo/flow/StaticContent.java b/src/org/apache/fop/fo/flow/StaticContent.java index d1a8f009b..154e90025 100644 --- a/src/org/apache/fop/fo/flow/StaticContent.java +++ b/src/org/apache/fop/fo/flow/StaticContent.java @@ -1,7 +1,7 @@ -/*-- $Id$ -- +/*-- $Id$ -- * * Copyright (C) 2001 The Apache Software Foundation. All rights reserved. - * For details on use and redistribution please refer to the + * For details on use and redistribution please refer to the * LICENSE file included with these sources." */ @@ -12,7 +12,8 @@ import org.apache.fop.fo.*; import org.apache.fop.fo.properties.*; import org.apache.fop.fo.pagination.*; import org.apache.fop.layout.Area; -import org.apache.fop.apps.FOPException; +import org.apache.fop.apps.FOPException; +import org.apache.fop.messaging.MessageHandler; // Java import java.util.Enumeration; @@ -20,89 +21,85 @@ import java.util.Enumeration; public class StaticContent extends Flow { public static class Maker extends FObj.Maker { - public FObj make(FObj parent, PropertyList propertyList) - throws FOPException { - return new StaticContent(parent, propertyList); - } + public FObj make(FObj parent, + PropertyList propertyList) throws FOPException { + return new StaticContent(parent, propertyList); + } } public static FObj.Maker maker() { - return new StaticContent.Maker(); + return new StaticContent.Maker(); } - protected StaticContent(FObj parent, PropertyList propertyList) - throws FOPException { - super(parent, propertyList); - ((PageSequence)parent).setIsFlowSet(false); // hacquery of sorts + protected StaticContent(FObj parent, + PropertyList propertyList) throws FOPException { + super(parent, propertyList); + ((PageSequence) parent).setIsFlowSet(false); // hacquery of sorts } - + public Status layout(Area area) throws FOPException { - return layout(area, null); + return layout(area, null); } - + public Status layout(Area area, Region region) throws FOPException { - int numChildren = this.children.size(); - // Set area absolute height so that link rectangles will be drawn correctly in xsl-before and xsl-after - String regionClass = "none"; - if (region != null) { - regionClass = region.getRegionClass(); - } - else { - if(getFlowName().equals("xsl-region-before")) { - regionClass = RegionBefore.REGION_CLASS; - } - else if(getFlowName().equals("xsl-region-after")) { - regionClass = RegionAfter.REGION_CLASS; - } - else if(getFlowName().equals("xsl-region-start")) { - regionClass = RegionStart.REGION_CLASS; - } - else if(getFlowName().equals("xsl-region-end")) { - regionClass = RegionEnd.REGION_CLASS; - } - - } - - if(regionClass.equals(RegionBefore.REGION_CLASS)) { - area.setAbsoluteHeight(-area.getMaxHeight()); - } - else if(regionClass.equals(RegionAfter.REGION_CLASS)) { - area.setAbsoluteHeight(area.getPage().getBody().getMaxHeight()); - } - - for (int i = 0; i < numChildren; i++) { - FObj fo = (FObj) children.elementAt(i); - - Status status; - if ((status = fo.layout(area)).isIncomplete()) { - this.marker = i; - if ((i != 0) && (status.getCode() == Status.AREA_FULL_NONE)) { - status = new Status(Status.AREA_FULL_SOME); - } - return(status); - } - } - resetMarker(); - return new Status(Status.OK); + int numChildren = this.children.size(); + // Set area absolute height so that link rectangles will be drawn correctly in xsl-before and xsl-after + String regionClass = "none"; + if (region != null) { + regionClass = region.getRegionClass(); + } else { + if (getFlowName().equals("xsl-region-before")) { + regionClass = RegionBefore.REGION_CLASS; + } else if (getFlowName().equals("xsl-region-after")) { + regionClass = RegionAfter.REGION_CLASS; + } else if (getFlowName().equals("xsl-region-start")) { + regionClass = RegionStart.REGION_CLASS; + } else if (getFlowName().equals("xsl-region-end")) { + regionClass = RegionEnd.REGION_CLASS; + } + + } + + if (regionClass.equals(RegionBefore.REGION_CLASS)) { + area.setAbsoluteHeight(-area.getMaxHeight()); + } else if (regionClass.equals(RegionAfter.REGION_CLASS)) { + area.setAbsoluteHeight( + area.getPage().getBody().getMaxHeight()); + } + + for (int i = 0; i < numChildren; i++) { + FObj fo = (FObj) children.elementAt(i); + + Status status; + if ((status = fo.layout(area)).isIncomplete()) { + // in fact all should be laid out and clip, error etc depending on 'overflow' + MessageHandler.logln("Warning: Some static content could not fit in the area."); + this.marker = i; + if ((i != 0) && + (status.getCode() == Status.AREA_FULL_NONE)) { + status = new Status(Status.AREA_FULL_SOME); + } + return(status); + } + } + resetMarker(); + return new Status(Status.OK); } - protected String getElementName() - { - return "fo:static-content"; + protected String getElementName() { + return "fo:static-content"; } // flowname checking is more stringient for static content currently - protected void setFlowName(String name) - throws FOPException - { - if (name == null || name.equals("")) { - throw new FOPException("A 'flow-name' is required for "+getElementName()+"."); - } - else { - super.setFlowName(name); - } - + protected void setFlowName(String name) throws FOPException { + if (name == null || name.equals("")) { + throw new FOPException("A 'flow-name' is required for "+ + getElementName() + "."); + } else { + super.setFlowName(name); + } + } } -- 2.39.5