Author: jeremias
Date: Tue Nov 27 00:36:23 2007
New Revision: 598558
URL: http://svn.apache.org/viewvc?rev=598558&view=rev
Log:
Bugzilla #40230:
Bugfix: no empty page is generated anymore if there's no content after a
break-after.
Bugzilla #43917:
Bugfix for border-after painting and element list generation when a forced
break is involved.
Added:
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/block_border_bug43917.xml
(with props)
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BreakElement.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/LayoutContext.java
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/SpaceResolver.java
xmlgraphics/fop/trunk/status.xml
xmlgraphics/fop/trunk/test/layoutengine/disabled-testcases.xml
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/page-production_empty_block_only.xml
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/table-cell_block_break-after.xml
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/table-cell_conditional-spaces_1.xml
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java?rev=598558&r1=598557&r2=598558&view=diff
==============================================================================
---
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
(original)
+++
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
Tue Nov 27 00:36:23 2007
@@ -26,9 +26,10 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.apache.fop.area.Area;
-import org.apache.fop.area.BlockParent;
import org.apache.fop.area.Block;
+import org.apache.fop.area.BlockParent;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
import org.apache.fop.fo.properties.SpaceProperty;
@@ -225,9 +226,7 @@
return contentIPD;
}
- /**
- * [EMAIL PROTECTED]
- */
+ /** [EMAIL PROTECTED] */
public LinkedList getNextKnuthElements(LayoutContext context, int
alignment) {
//log.debug("BLM.getNextKnuthElements> keep-together = "
// + layoutProps.keepTogether.getType());
@@ -266,6 +265,9 @@
//Spaces, border and padding to be repeated at each break
addPendingMarks(context);
+ //Used to indicate a special break-after case when all content has
already been generated.
+ BreakElement forcedBreakAfterLast = null;
+
while ((curLM = (BlockLevelLayoutManager) getChildLM()) != null) {
LayoutContext childLC = new LayoutContext(0);
childLC.copyPendingMarksFrom(context);
@@ -292,17 +294,14 @@
&& returnedList.size() == 1
&& ((ListElement)
returnedList.getFirst()).isForcedBreak()) {
// a descendant of this block has break-before
- /*
- if (returnList.size() == 0) {
- // the first child (or its first child ...) has
- // break-before;
- // all this block, including space before, will be put in
- // the
- // following page
- bSpaceBeforeServed = false;
- }*/
contentList.addAll(returnedList);
+ if (curLM.isFinished() && !hasNextChildLM()) {
+ forcedBreakAfterLast =
(BreakElement)contentList.removeLast();
+ context.clearPendingMarks();
+ break;
+ }
+
/* extension: conversione di tutta la sequenza fin'ora
ottenuta */
if (bpUnit > 0) {
storedList = contentList;
@@ -349,6 +348,11 @@
contentList.addAll(returnedList);
if (((ListElement) returnedList.getLast()).isForcedBreak()) {
// a descendant of this block has break-after
+ if (curLM.isFinished() && !hasNextChildLM()) {
+ forcedBreakAfterLast =
(BreakElement)contentList.removeLast();
+ context.clearPendingMarks();
+ break;
+ }
/* extension: conversione di tutta la sequenza fin'ora
ottenuta */
if (bpUnit > 0) {
@@ -380,7 +384,7 @@
returnedList = new LinkedList();
if (contentList.size() > 0) {
wrapPositionElements(contentList, returnList);
- } else {
+ } else if (forcedBreakAfterLast == null) {
// Empty fo:block, zero-length box makes sure the IDs and/or
markers
// are registered.
returnList.add(new KnuthBox(0, notifyPos(new Position(this)),
true));
@@ -388,8 +392,15 @@
addKnuthElementsForBorderPaddingAfter(returnList, true);
addKnuthElementsForSpaceAfter(returnList, alignment);
- addKnuthElementsForBreakAfter(returnList, context);
+ if (forcedBreakAfterLast == null) {
+ addKnuthElementsForBreakAfter(returnList, context);
+ }
+ if (forcedBreakAfterLast != null) {
+ forcedBreakAfterLast.clearPendingMarks();
+ wrapPositionElement(forcedBreakAfterLast, returnList, false);
+ }
+
if (mustKeepWithNext()) {
context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING);
}
@@ -1455,14 +1466,25 @@
while (listIter.hasNext()) {
ListElement tempElement;
tempElement = (ListElement) listIter.next();
- if (force || tempElement.getLayoutManager() != this) {
- tempElement.setPosition(notifyPos(new NonLeafPosition(this,
- tempElement.getPosition())));
- }
- targetList.add(tempElement);
+ wrapPositionElement(tempElement, targetList, force);
+ }
+ }
+
+ /**
+ * "wrap" the Position inside the given element and add it to the target
list.
+ * @param el the list element
+ * @param targetList target list receiving the wrapped position elements
+ * @param force if true, every Position is wrapped regardless of its LM of
origin
+ */
+ protected void wrapPositionElement(ListElement el, List targetList,
boolean force) {
+ if (force || el.getLayoutManager() != this) {
+ el.setPosition(notifyPos(new NonLeafPosition(this,
+ el.getPosition())));
}
+ targetList.add(el);
}
+
/** @return the sum of start-indent and end-indent */
protected int getIPIndents() {
return startIndent + endIndent;
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BreakElement.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BreakElement.java?rev=598558&r1=598557&r2=598558&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BreakElement.java
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/BreakElement.java
Tue Nov 27 00:36:23 2007
@@ -119,6 +119,16 @@
return this.pendingAfterMarks;
}
+ /**
+ * Clears all pending marks associated with this break element. This is
used in break
+ * cases where we only know very late if the break is actually after all
the content
+ * of an FO has been generated.
+ */
+ public void clearPendingMarks() {
+ this.pendingBeforeMarks = null;
+ this.pendingAfterMarks = null;
+ }
+
/** [EMAIL PROTECTED] */
public String toString() {
StringBuffer sb = new StringBuffer();
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java?rev=598558&r1=598557&r2=598558&view=diff
==============================================================================
---
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
(original)
+++
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
Tue Nov 27 00:36:23 2007
@@ -19,16 +19,17 @@
package org.apache.fop.layoutmgr;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.ListIterator;
+
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.apache.fop.fo.pagination.Flow;
-import org.apache.fop.layoutmgr.inline.InlineLevelLayoutManager;
+
import org.apache.fop.area.Area;
import org.apache.fop.area.BlockParent;
-
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
+import org.apache.fop.fo.pagination.Flow;
+import org.apache.fop.layoutmgr.inline.InlineLevelLayoutManager;
/**
* LayoutManager for an fo:flow object.
@@ -141,6 +142,13 @@
if (returnedList.size() > 0) {
returnList.addAll(returnedList);
if (ElementListUtils.endsWithForcedBreak(returnList)) {
+ if (curLM.isFinished() && !hasNextChildLM()) {
+ //If the layout manager is finished at this point,
the pending
+ //marks become irrelevant.
+ childLC.clearPendingMarks();
+ //setFinished(true);
+ break;
+ }
// a descendant of this flow has break-after
SpaceResolver.resolveElementList(returnList);
return returnList;
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/LayoutContext.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/LayoutContext.java?rev=598558&r1=598557&r2=598558&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/LayoutContext.java
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/LayoutContext.java
Tue Nov 27 00:36:23 2007
@@ -23,9 +23,9 @@
import java.util.List;
import org.apache.fop.fo.Constants;
+import org.apache.fop.layoutmgr.inline.AlignmentContext;
import org.apache.fop.layoutmgr.inline.HyphContext;
import org.apache.fop.traits.MinOptMax;
-import org.apache.fop.layoutmgr.inline.AlignmentContext;
/**
@@ -262,6 +262,18 @@
return Collections.unmodifiableList(this.pendingAfterMarks);
} else {
return null;
+ }
+ }
+
+ /**
+ * Clears all pending marks on the LayoutContext.
+ */
+ public void clearPendingMarks() {
+ if (this.pendingBeforeMarks != null) {
+ this.pendingBeforeMarks.clear();
+ }
+ if (this.pendingAfterMarks != null) {
+ this.pendingAfterMarks.clear();
}
}
Modified:
xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/SpaceResolver.java
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/SpaceResolver.java?rev=598558&r1=598557&r2=598558&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/SpaceResolver.java
(original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/SpaceResolver.java
Tue Nov 27 00:36:23 2007
@@ -25,6 +25,7 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.apache.fop.traits.MinOptMax;
/**
@@ -441,7 +442,6 @@
glue2shrink -= glue3.opt - glue3.min;
boolean hasPrecedingNonBlock = false;
- boolean forcedBreak = false;
if (log.isDebugEnabled()) {
log.debug("noBreakLength=" + noBreakLength
+ ", glue1=" + glue1
@@ -449,11 +449,16 @@
+ ", glue3=" + glue3);
}
if (breakPoss != null) {
+ boolean forcedBreak = breakPoss.isForcedBreak();
if (glue1.isNonZero()) {
iter.add(new KnuthPenalty(0, KnuthPenalty.INFINITE,
false, (Position)null, true));
iter.add(new KnuthGlue(glue1.opt, glue1.max - glue1.opt,
glue1.opt - glue1.min,
(Position)null, true));
+ if (forcedBreak) {
+ //Otherwise, the preceding penalty and glue will be cut off
+ iter.add(new KnuthBox(0, (Position)null, true));
+ }
}
iter.add(new KnuthPenalty(breakPoss.getPenaltyWidth(),
breakPoss.getPenaltyValue(),
false, breakPoss.getBreakClass(),
Modified: xmlgraphics/fop/trunk/status.xml
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/status.xml?rev=598558&r1=598557&r2=598558&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/status.xml (original)
+++ xmlgraphics/fop/trunk/status.xml Tue Nov 27 00:36:23 2007
@@ -28,6 +28,14 @@
<changes>
<release version="FOP Trunk">
+ <action context="Code" dev="JM" type="fix" fixes-bug="43917">
+ Bugfix for border-after painting and element list generation when a
+ forced break is involved.
+ </action>
+ <action context="Code" dev="JM" type="fix" fixes-bug="40230">
+ Bugfix: no empty page is generated anymore if there's no content
+ after a break-after.
+ </action>
<action context="Code" dev="VH" type="fix" fixes-bug="43803">
Restored proper handling of fo:table-cell having no children, which is
allowed in relaxed
validation mode.
Modified: xmlgraphics/fop/trunk/test/layoutengine/disabled-testcases.xml
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/layoutengine/disabled-testcases.xml?rev=598558&r1=598557&r2=598558&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/layoutengine/disabled-testcases.xml (original)
+++ xmlgraphics/fop/trunk/test/layoutengine/disabled-testcases.xml Tue Nov 27
00:36:23 2007
@@ -307,13 +307,6 @@
added to the area tree.</description>
</testcase>
<testcase>
- <name>Bugzilla #40230: invalid extra page break</name>
- <file>block_break-after_bug40230.xml</file>
- <description>Currently an extra page is created even if there is nothing
- after a block with break-after="page"</description>
-
<reference>http://issues.apache.org/bugzilla/show_bug.cgi?id=40230</reference>
- </testcase>
- <testcase>
<name>Soft hyphen with normal hyphenation enabled</name>
<file>block_shy_linebreaking_hyph.xml</file>
<description>A soft hyphen should be a preferred as break compared to a
Added:
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/block_border_bug43917.xml
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/block_border_bug43917.xml?rev=598558&view=auto
==============================================================================
---
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/block_border_bug43917.xml
(added)
+++
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/block_border_bug43917.xml
Tue Nov 27 00:36:23 2007
@@ -0,0 +1,87 @@
+<?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 Bugzilla bug #43917 where the lower border wasn't
painted if there was
+ a hard break after the block.
+ </p>
+ </info>
+ <fo>
+ <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
+ <fo:layout-master-set>
+ <fo:simple-page-master master-name="normal" page-width="5in"
page-height="5in">
+ <fo:region-body/>
+ </fo:simple-page-master>
+ </fo:layout-master-set>
+ <fo:page-sequence master-reference="normal">
+ <fo:flow flow-name="xsl-region-body">
+ <fo:block border="1pt solid black" border-after-width="1.1pt"
break-after="page">
+ <fo:block>Line 1</fo:block>
+ <fo:block>Line 2</fo:block>
+ </fo:block>
+ </fo:flow>
+ </fo:page-sequence>
+ <fo:page-sequence master-reference="normal">
+ <fo:flow flow-name="xsl-region-body">
+ <fo:block border="1pt solid black" border-after-width="1.1pt">
+ <fo:block>Line 1</fo:block>
+ <fo:block break-after="page">Line 2</fo:block>
+ </fo:block>
+ </fo:flow>
+ </fo:page-sequence>
+ </fo:root>
+ </fo>
+ <checks>
+ <element-list category="breaker" index="0">
+ <box w="0"/> <!-- SpaceHandlingPosition -->
+ <penalty w="0" p="INF"/>
+ <glue w="1000"/> <!-- border-before -->
+
+ <box w="14400"/> <!-- Line 1 -->
+ <penalty w="0" p="0"/> <!--SpabeHandlingBreakPosition-->
+ <box w="14400"/> <!-- Line 2 -->
+
+ <penalty w="0" p="INF"/>
+ <glue w="1100"/> <!-- border-after -->
+ <box w="0" aux="true"/> <!-- aux. block -->
+
+ <skip>3</skip> <!-- the last of the three holds a
SpaceHandlingBreakPosition -->
+ </element-list>
+ <element-list category="breaker" index="1">
+ <box w="0"/> <!-- SpaceHandlingPosition -->
+ <penalty w="0" p="INF"/>
+ <glue w="1000"/> <!-- border-before -->
+
+ <box w="14400"/> <!-- Line 1 -->
+ <penalty w="0" p="0"/> <!--SpabeHandlingBreakPosition-->
+ <box w="14400"/> <!-- Line 2 -->
+
+ <penalty w="0" p="INF"/>
+ <glue w="1100"/> <!-- border-after -->
+ <box w="0" aux="true"/> <!-- aux. block -->
+
+ <skip>3</skip>
+ </element-list>
+ <eval expected="(solid,#000000,1000)"
xpath="(//flow)[1]/block[1]/@border-before"/>
+ <eval expected="(solid,#000000,1100)"
xpath="(//flow)[1]/block[1]/@border-after"/>
+ <eval expected="(solid,#000000,1000)"
xpath="(//flow)[2]/block[1]/@border-before"/>
+ <eval expected="(solid,#000000,1100)"
xpath="(//flow)[2]/block[1]/@border-after"/>
+ </checks>
+</testcase>
Propchange:
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/block_border_bug43917.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/block_border_bug43917.xml
------------------------------------------------------------------------------
svn:keywords = Id
Modified:
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/page-production_empty_block_only.xml
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/page-production_empty_block_only.xml?rev=598558&r1=598557&r2=598558&view=diff
==============================================================================
---
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/page-production_empty_block_only.xml
(original)
+++
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/page-production_empty_block_only.xml
Tue Nov 27 00:36:23 2007
@@ -51,5 +51,9 @@
</fo>
<checks>
<eval expected="3" xpath="count(//pageViewport)"/>
+ <element-list category="breaker" index="1">
+ <box w="0" aux="true"/> <!-- auxiliary box for empty box -->
+ <skip>3</skip>
+ </element-list>
</checks>
</testcase>
Modified:
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/table-cell_block_break-after.xml
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/table-cell_block_break-after.xml?rev=598558&r1=598557&r2=598558&view=diff
==============================================================================
---
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/table-cell_block_break-after.xml
(original)
+++
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/table-cell_block_break-after.xml
Tue Nov 27 00:36:23 2007
@@ -84,12 +84,10 @@
<eval expected="75000" xpath="//[EMAIL
PROTECTED]//flow/block[1]/block[1]/@ipda"/>
<eval expected="20800" xpath="//[EMAIL
PROTECTED]//flow/block[1]/block[1]/@bpd"/>
<eval expected="28800" xpath="//[EMAIL
PROTECTED]//flow/block[1]/block[1]/@bpda"/>
- <!-- Two blocks expected in the second cell -->
- <eval expected="2" xpath="count(//[EMAIL
PROTECTED]//flow/block[1]/block[2]/block)"/>
- <!-- First block has zero bpd -->
- <eval expected="0" xpath="//[EMAIL
PROTECTED]//flow/block[1]/block[2]/block[1]/@bpd"/>
- <!-- One line in the second block -->
- <eval expected="1" xpath="count(//[EMAIL
PROTECTED]//flow/block[1]/block[2]/block[2]//lineArea)"/>
+ <!-- One block expected in the second cell -->
+ <eval expected="1" xpath="count(//[EMAIL
PROTECTED]//flow/block[1]/block[2]/block)"/>
+ <!-- One line in the block -->
+ <eval expected="1" xpath="count(//[EMAIL
PROTECTED]//flow/block[1]/block[2]/block[1]//lineArea)"/>
<eval expected="63000" xpath="//[EMAIL
PROTECTED]//flow/block[1]/block[2]/@ipd"/>
<eval expected="75000" xpath="//[EMAIL
PROTECTED]//flow/block[1]/block[2]/@ipda"/>
<eval expected="16800" xpath="//[EMAIL
PROTECTED]//flow/block[1]/block[2]/@bpd"/>
Modified:
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/table-cell_conditional-spaces_1.xml
URL:
http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/table-cell_conditional-spaces_1.xml?rev=598558&r1=598557&r2=598558&view=diff
==============================================================================
---
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/table-cell_conditional-spaces_1.xml
(original)
+++
xmlgraphics/fop/trunk/test/layoutengine/standard-testcases/table-cell_conditional-spaces_1.xml
Tue Nov 27 00:36:23 2007
@@ -153,7 +153,10 @@
<penalty p="0" w="0"/>
<glue w="25000"/> <!-- The space between lines -->
<box w="16800"/> <!-- Line 2 -->
- <skip>3</skip> <!-- glue for end of page TODO missing
element for border-after!! -->
+ <penalty p="INF" w="0"/>
+ <glue w="4000"/> <!-- The border after -->
+ <box w="0" aux="true"/> <!-- aux. box to prohibit cutting away the
border -->
+ <skip>3</skip> <!-- glue for end of page -->
</element-list>
</checks>
</testcase>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]