Author: ssteiner Date: Thu Apr 22 10:45:11 2021 New Revision: 1889102 URL: http://svn.apache.org/viewvc?rev=1889102&view=rev Log: FOP-3008: Table with linefeed-treatment may give ClassCastException
Added: xmlgraphics/fop/trunk/fop/test/layoutengine/standard-testcases/table_linefeed.xml (with props) Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/flow/Wrapper.java xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/layoutmgr/ElementListUtils.java xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/layoutmgr/KnuthPenalty.java xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/util/ListUtil.java Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/flow/Wrapper.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/flow/Wrapper.java?rev=1889102&r1=1889101&r2=1889102&view=diff ============================================================================== --- xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/flow/Wrapper.java (original) +++ xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/flow/Wrapper.java Thu Apr 22 10:45:11 2021 @@ -121,7 +121,7 @@ public class Wrapper extends FObjMixed i while (ancestor.getNameId() == Constants.FO_WRAPPER) { ancestor = ancestor.getParent(); } - if (!(ancestor instanceof FObjMixed)) { + if (!(ancestor instanceof FObjMixed) && !child.toString().trim().isEmpty()) { invalidChildError( getLocator(), getLocalName(), Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java?rev=1889102&r1=1889101&r2=1889102&view=diff ============================================================================== --- xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java (original) +++ xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/layoutmgr/AreaAdditionUtil.java Thu Apr 22 10:45:11 2021 @@ -65,7 +65,7 @@ public final class AreaAdditionUtil { } lastPos = pos; } - if (pos instanceof NonLeafPosition) { + if (pos instanceof NonLeafPosition && pos.getPosition() != null) { // pos was created by a child of this FlowLM positionList.add(pos.getPosition()); lastLM = (pos.getPosition().getLM()); Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java?rev=1889102&r1=1889101&r2=1889102&view=diff ============================================================================== --- xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java (original) +++ xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java Thu Apr 22 10:45:11 2021 @@ -535,8 +535,8 @@ public abstract class BlockStackingLayou return; } - ListElement last = ListUtil.getLast(contentList); - if (last.isGlue()) { + ListElement last = ListUtil.getLastListElement(contentList); + if (last == null || last.isGlue()) { // the last element in contentList is a glue; // it is a feasible breakpoint, there is no need to add // a penalty Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/layoutmgr/ElementListUtils.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/layoutmgr/ElementListUtils.java?rev=1889102&r1=1889101&r2=1889102&view=diff ============================================================================== --- xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/layoutmgr/ElementListUtils.java (original) +++ xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/layoutmgr/ElementListUtils.java Thu Apr 22 10:45:11 2021 @@ -178,7 +178,8 @@ public final class ElementListUtils { * @return true if the list ends with a forced break */ public static boolean endsWithForcedBreak(List elems) { - return ((ListElement) ListUtil.getLast(elems)).isForcedBreak(); + ListElement last = ListUtil.getLastListElement(elems); + return last == null || last.isForcedBreak(); } /** Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/layoutmgr/KnuthPenalty.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/layoutmgr/KnuthPenalty.java?rev=1889102&r1=1889101&r2=1889102&view=diff ============================================================================== --- xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/layoutmgr/KnuthPenalty.java (original) +++ xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/layoutmgr/KnuthPenalty.java Thu Apr 22 10:45:11 2021 @@ -19,6 +19,8 @@ package org.apache.fop.layoutmgr; +import org.apache.fop.fo.Constants; + /** * An instance of this class represents information about a feasible * breaking point; it does not represent any piece of content. @@ -47,7 +49,7 @@ public class KnuthPenalty extends KnuthE private int penalty; private boolean penaltyFlagged; - private int breakClass = -1; + private int breakClass = Constants.EN_AUTO; /** * Create a new KnuthPenalty. Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/util/ListUtil.java URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/util/ListUtil.java?rev=1889102&r1=1889101&r2=1889102&view=diff ============================================================================== --- xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/util/ListUtil.java (original) +++ xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/util/ListUtil.java Thu Apr 22 10:45:11 2021 @@ -21,6 +21,8 @@ package org.apache.fop.util; import java.util.List; +import org.apache.fop.layoutmgr.ListElement; + /** * Provides helper functions for {@link java.util.List}. * @@ -42,6 +44,14 @@ public final class ListUtil { return list.get(list.size() - 1); } + public static ListElement getLastListElement(List list) { + Object last = getLast(list); + if (last instanceof ListElement) { + return (ListElement) last; + } + return null; + } + /** * Retrieve and remove the last element from a list. * Added: xmlgraphics/fop/trunk/fop/test/layoutengine/standard-testcases/table_linefeed.xml URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop/test/layoutengine/standard-testcases/table_linefeed.xml?rev=1889102&view=auto ============================================================================== --- xmlgraphics/fop/trunk/fop/test/layoutengine/standard-testcases/table_linefeed.xml (added) +++ xmlgraphics/fop/trunk/fop/test/layoutengine/standard-testcases/table_linefeed.xml Thu Apr 22 10:45:11 2021 @@ -0,0 +1,57 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + 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$ --> +<testcase> + <info> + <p> + This test checks table linefeed in certain situations. + </p> + </info> + <fo> +<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> + <fo:layout-master-set> + <fo:simple-page-master master-name="ref" page-height="297.0mm" page-width="210.0mm"> + <fo:region-body region-name="xsl-region-body" /> + </fo:simple-page-master> + <fo:page-sequence-master master-name="master"> + <fo:repeatable-page-master-reference master-reference="ref" maximum-repeats="99999" /> + </fo:page-sequence-master> + </fo:layout-master-set> + <fo:page-sequence master-reference="master"> + <fo:flow flow-name="xsl-region-body" linefeed-treatment="preserve"> + <fo:block> + <fo:table table-layout="fixed" > + <fo:table-column column-width="226pt" /> + <fo:table-body > + <fo:table-row> + <fo:table-cell > + <fo:wrapper> + </fo:wrapper> + </fo:table-cell> + </fo:table-row> + </fo:table-body> + </fo:table> + </fo:block> + </fo:flow> + </fo:page-sequence> +</fo:root> + </fo> + <checks> + <eval expected="595275" xpath="//lineArea[1]/@ipd"/> + </checks> +</testcase> Propchange: xmlgraphics/fop/trunk/fop/test/layoutengine/standard-testcases/table_linefeed.xml ------------------------------------------------------------------------------ svn:eol-style = native --------------------------------------------------------------------- To unsubscribe, e-mail: fop-commits-unsubscr...@xmlgraphics.apache.org For additional commands, e-mail: fop-commits-h...@xmlgraphics.apache.org