Patch by Robert Meyer, applied with some modifications git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1380923 13f79535-47bb-0310-9956-ffa450edef68tags/fop-2_0
@@ -21,6 +21,8 @@ package org.apache.fop.layoutmgr; | |||
import java.util.List; | |||
import org.apache.fop.fo.Constants; | |||
/** | |||
* This class represents an unresolved break possibility. | |||
*/ | |||
@@ -28,7 +30,7 @@ public class BreakElement extends UnresolvedListElement { | |||
private int penaltyWidth; | |||
private int penaltyValue; | |||
private int breakClass = -1; | |||
private int breakClass; | |||
private List pendingBeforeMarks; | |||
private List pendingAfterMarks; | |||
@@ -39,7 +41,7 @@ public class BreakElement extends UnresolvedListElement { | |||
* @param context the layout context which contains the pending conditional elements | |||
*/ | |||
public BreakElement(Position position, int penaltyValue, LayoutContext context) { | |||
this(position, penaltyValue, -1, context); | |||
this(position, penaltyValue, Constants.EN_AUTO, context); | |||
} | |||
/** | |||
@@ -80,7 +82,7 @@ public class BreakElement extends UnresolvedListElement { | |||
super(position); | |||
this.penaltyWidth = penaltyWidth; | |||
this.penaltyValue = penaltyValue; | |||
this.breakClass = breakClass; | |||
setBreakClass(breakClass); | |||
this.pendingBeforeMarks = context.getPendingBeforeMarks(); | |||
this.pendingAfterMarks = context.getPendingAfterMarks(); | |||
} | |||
@@ -142,13 +144,24 @@ public class BreakElement extends UnresolvedListElement { | |||
* | |||
* @param breakClass one of | |||
* {@link org.apache.fop.fo.Constants#EN_AUTO}, | |||
* {@link org.apache.fop.fo.Constants#EN_LINE}, | |||
* {@link org.apache.fop.fo.Constants#EN_COLUMN}, | |||
* {@link org.apache.fop.fo.Constants#EN_PAGE}, | |||
* {@link org.apache.fop.fo.Constants#EN_EVEN_PAGE}, | |||
* {@link org.apache.fop.fo.Constants#EN_ODD_PAGE}. | |||
*/ | |||
public void setBreakClass(int breakClass) { | |||
this.breakClass = breakClass; | |||
switch (breakClass) { | |||
case Constants.EN_AUTO: | |||
case Constants.EN_LINE: | |||
case Constants.EN_COLUMN: | |||
case Constants.EN_PAGE: | |||
case Constants.EN_EVEN_PAGE: | |||
case Constants.EN_ODD_PAGE: | |||
this.breakClass = breakClass; | |||
break; | |||
default: throw new IllegalArgumentException("Illegal value for break class: " + breakClass); | |||
} | |||
} | |||
/** @return the pending border and padding elements at the before edge */ |
@@ -62,6 +62,10 @@ | |||
documents. Example: the fix of marks layering will be such a case when it's done. | |||
--> | |||
<release version="FOP Trunk" date="TBD"> | |||
<action context="Layout" dev="VH" type="fix" fixes-bug="53598" due-to="Robert Meyer"> | |||
Always set the breakClass field to a legal value in BreakElement, so as to avoid | |||
IllegalArgumentExceptions in other parts of the code. | |||
</action> | |||
<action context="Layout" dev="VH" type="fix" fixes-bug="45715" due-to="Luis Bernardo"> | |||
Restored support for break-before on fo:table. | |||
</action> |
@@ -0,0 +1,37 @@ | |||
/* | |||
* 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. | |||
*/ | |||
package org.apache.fop.layoutmgr; | |||
import org.junit.Test; | |||
import static org.junit.Assert.assertEquals; | |||
import org.apache.fop.fo.Constants; | |||
public class BreakElementTestCase { | |||
/** | |||
* Tests that the constructor sets the break class to a valid default value. | |||
*/ | |||
@Test | |||
public void breakClassMustBeValid() { | |||
LayoutContext context = LayoutContext.newInstance(); | |||
BreakElement breakElement = new BreakElement(new Position(null), 0, context); | |||
assertEquals(Constants.EN_AUTO, breakElement.getBreakClass()); | |||
} | |||
} |