You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-dev@xmlgraphics.apache.org by Art Welch <ar...@EASTPOINT.COM> on 2000/09/08 21:10:22 UTC

Static content with page break after problem.

We seem to be encountering a problem with static content that ends with a
block containing break-after="page". What we have is something like the
following:

	<fo:page-sequence  initial-page-number="1">
	<fo:static-content flow-name="xsl-region-before" >
		<fo:block>Top Content</fo:block>
	</fo:static-content>

		<fo:flow flow-name="xsl-region-body">
			<fo:block>Body Content</fo:block>
		</fo:flow>
		
	<fo:static-content flow-name="xsl-region-after">
		<fo:block font-size="9pt" break-after="page">
			Bottom Content
		</fo:block>
				
		<!-- fo:block break-after="page"/ -->		
	</fo:static-content>
	</fo:page-sequence>

When this goes onto the second page we get the following exception:

java.lang.ArrayIndexOutOfBoundsException: -1
	at org.apache.fop.layout.LineArea.addText(Compiled Code)
	at org.apache.fop.layout.BlockArea.addText(Compiled Code)
	at org.apache.fop.fo.FOText.layout(Compiled Code)
	at org.apache.fop.fo.flow.Block.layout(Compiled Code)
	at org.apache.fop.fo.flow.StaticContent.layout(Compiled Code)
	at org.apache.fop.fo.pagination.PageSequence.format(Compiled Code)
	at org.apache.fop.fo.pagination.Root.format(Compiled Code)
	at resetableFOTreeBuilder.format(Compiled Code)
	at org.apache.fop.apps.Driver.format(Compiled Code)
	at XSLTDocumentHandler.endReport(Compiled Code)
	at XSLTDocumentHandler.endReport(Compiled Code)
	at org.apache.xalan.xpath.ExtensionFunctionHandler.callJava(Compiled
Code)
	at
org.apache.xalan.xpath.ExtensionFunctionHandler.callFunction(Compiled Code)
	at org.apache.xalan.xslt.ExtensionNSHandler.processElement(Compiled
Code)
	at org.apache.xalan.xslt.ElemExtensionCall.execute(Compiled Code)
	at
org.apache.xalan.xslt.ElemTemplateElement.executeChildren(Compiled Code)
	at org.apache.xalan.xslt.ElemTemplateElement.transformChild(Compiled
Code)
	at
org.apache.xalan.xslt.ElemTemplateElement.processLocatedNode(Compiled Code)
	at org.apache.xalan.xpath.SimpleNodeLocator.findChildren(Compiled
Code)
	at org.apache.xalan.xpath.SimpleNodeLocator.step(Compiled Code)
	at org.apache.xalan.xpath.SimpleNodeLocator.locationPath(Compiled
Code)
	at org.apache.xalan.xpath.XPath.locationPath(Compiled Code)
	at org.apache.xalan.xpath.XPath.execute(Compiled Code)
	at org.apache.xalan.xpath.XPath.execute(Compiled Code)
	at org.apache.xalan.xpath.XPath.execute(Compiled Code)
	at
org.apache.xalan.xslt.ElemTemplateElement.transformSelectedChildren(Compiled
Code)
	at org.apache.xalan.xslt.ElemApplyTemplates.execute(Compiled Code)
	at
org.apache.xalan.xslt.ElemTemplateElement.executeChildren(Compiled Code)
	at org.apache.xalan.xslt.ElemTemplateElement.transformChild(Compiled
Code)
	at
org.apache.xalan.xslt.ElemTemplateElement.processLocatedNode(Compiled Code)
	at org.apache.xalan.xpath.SimpleNodeLocator.findChildren(Compiled
Code)
	at org.apache.xalan.xpath.SimpleNodeLocator.step(Compiled Code)
	at org.apache.xalan.xpath.SimpleNodeLocator.locationPath(Compiled
Code)
	at org.apache.xalan.xpath.XPath.locationPath(Compiled Code)
	at org.apache.xalan.xpath.XPath.execute(Compiled Code)
	at org.apache.xalan.xpath.XPath.execute(Compiled Code)
	at org.apache.xalan.xpath.XPath.execute(Compiled Code)
	at
org.apache.xalan.xslt.ElemTemplateElement.transformSelectedChildren(Compiled
Code)
	at org.apache.xalan.xslt.ElemApplyTemplates.execute(Compiled Code)
	at
org.apache.xalan.xslt.ElemTemplateElement.executeChildren(Compiled Code)
	at org.apache.xalan.xslt.ElemTemplate.execute(Compiled Code)
	at org.apache.xalan.xslt.StylesheetRoot.process(Compiled Code)
	at XSLTDocumentHandler.run(Compiled Code)
	at java.lang.Thread.run(Compiled Code)

I have been working through the code (CVS version from a week or so ago) to
figure out what is happening here and this is what I think is happening:

At the end of the static content in xsl-region-after the final block with
break-after="page" is returning to StaticContent.layout() with
Status=FORCE_PAGE_BREAK. Status.isIncomplete() then returns true and
prevents StaticContent.layout() from calling resetMarker(). Since the
markers on the FOText children of StaticContent are all at -1. When the new
page is formatted it eventually gets to the StaticContent at the end of the
page. When it attempts to do layout() on this the first FOText still has
marker=-1, so eventually LineArea.addText() is called with -1 as the start
of the text. This of course throws the exception when it attempts to access
the -1 element of the character data array.

My thinking is that the problem is in Status.isIncomplete() where it does
the following:

    public boolean isIncomplete() {
	return ((this.code != OK) && (this.code != KEEP_WITH_NEXT));
    }

I would think that in light of this problem it should rather be:

    public boolean isIncomplete() {
	return ((this.code == AREA_FULL_NONE) || (this.code ==
AREA_FULL_SOME));
    }

This is the first time that I have looked at the FOP layout code, so I am
not sure if this is correct or what the consequences would be. Can someone
who knows this stuff better than I comment on this please.

Thank You,
Art