/*
- * Copyright 1999-2005 The Apache Software Foundation.
+ * Copyright 1999-2006 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
contentList.addAll(returnedList);
if (((ListElement) returnedList.getLast()).isForcedBreak()) {
// a descendant of this block has break-after
- if (curLM.isFinished()) {
- // there is no other content in this block;
- // it's useless to add space after before a page break
- setFinished(true);
- }
/* extension: conversione di tutta la sequenza fin'ora ottenuta */
if (bpUnit > 0) {
return returnList;
}
- /*
- if (allocatedSpace.min > context.getStackLimit().max) {
- log.debug("Allocated space exceeds stack limit, returning early.");
- return returnList;
- }*/
}
// propagate and clear
context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING, childLC.isKeepWithNextPending());
/**
* Creates Knuth elements for before border padding and adds them to the return list.
* @param returnList return list to add the additional elements to
+ * @param isFirst true if this is the first time a layout manager instance needs to generate
+ * border and padding
*/
protected void addKnuthElementsForBorderPaddingBefore(LinkedList returnList, boolean isFirst) {
//Border and Padding (before)
/**
* Creates Knuth elements for after border padding and adds them to the return list.
* @param returnList return list to add the additional elements to
+ * @param isLast true if this is the last time a layout manager instance needs to generate
+ * border and padding
*/
protected void addKnuthElementsForBorderPaddingAfter(LinkedList returnList, boolean isLast) {
//Border and Padding (after)
/**
* Creates Knuth elements for break-before and adds them to the return list.
* @param returnList return list to add the additional elements to
+ * @param context the layout context
* @return true if an element has been added due to a break-before.
*/
protected boolean addKnuthElementsForBreakBefore(LinkedList returnList,
breakBefore = ((org.apache.fop.fo.flow.Block) fobj).getBreakBefore();
} else if (fobj instanceof org.apache.fop.fo.flow.BlockContainer) {
breakBefore = ((org.apache.fop.fo.flow.BlockContainer) fobj).getBreakBefore();
+ } else if (fobj instanceof org.apache.fop.fo.flow.ListBlock) {
+ breakBefore = ((org.apache.fop.fo.flow.ListBlock) fobj).getBreakBefore();
+ } else if (fobj instanceof org.apache.fop.fo.flow.ListItem) {
+ breakBefore = ((org.apache.fop.fo.flow.ListItem) fobj).getBreakBefore();
} else if (fobj instanceof org.apache.fop.fo.flow.Table) {
breakBefore = ((org.apache.fop.fo.flow.Table) fobj).getBreakBefore();
}
// return a penalty element, representing a forced page break
returnList.add(new BreakElement(getAuxiliaryPosition(),
0, -KnuthElement.INFINITE, breakBefore, context));
- //returnList.add(new KnuthPenalty(0, -KnuthElement.INFINITE, false,
- // breakBefore, getAuxiliaryPosition(), false));
return true;
} else {
return false;
/**
* Creates Knuth elements for break-after and adds them to the return list.
* @param returnList return list to add the additional elements to
+ * @param context the layout context
* @return true if an element has been added due to a break-after.
*/
protected boolean addKnuthElementsForBreakAfter(LinkedList returnList,
breakAfter = ((org.apache.fop.fo.flow.Block) fobj).getBreakAfter();
} else if (fobj instanceof org.apache.fop.fo.flow.BlockContainer) {
breakAfter = ((org.apache.fop.fo.flow.BlockContainer) fobj).getBreakAfter();
+ } else if (fobj instanceof org.apache.fop.fo.flow.ListBlock) {
+ breakAfter = ((org.apache.fop.fo.flow.ListBlock) fobj).getBreakAfter();
+ } else if (fobj instanceof org.apache.fop.fo.flow.ListItem) {
+ breakAfter = ((org.apache.fop.fo.flow.ListItem) fobj).getBreakAfter();
} else if (fobj instanceof org.apache.fop.fo.flow.Table) {
breakAfter = ((org.apache.fop.fo.flow.Table) fobj).getBreakAfter();
}
// add a penalty element, representing a forced page break
returnList.add(new BreakElement(getAuxiliaryPosition(),
0, -KnuthElement.INFINITE, breakAfter, context));
- //returnList.add(new KnuthPenalty(0, -KnuthElement.INFINITE, false,
- // breakAfter, getAuxiliaryPosition(), false));
return true;
} else {
return false;
LinkedList returnList = new LinkedList();
+ if (!breakBeforeServed) {
+ try {
+ if (addKnuthElementsForBreakBefore(returnList, context)) {
+ return returnList;
+ }
+ } finally {
+ breakBeforeServed = true;
+ }
+ }
+
addKnuthElementsForSpaceBefore(returnList, alignment);
+ addKnuthElementsForBorderPaddingBefore(returnList, !firstVisibleMarkServed);
+ firstVisibleMarkServed = true;
+
//Spaces, border and padding to be repeated at each break
addPendingMarks(context);
// "wrap" the Position inside each element
wrapPositionElements(returnedList, returnList, true);
+ addKnuthElementsForBorderPaddingAfter(returnList, true);
addKnuthElementsForSpaceAfter(returnList, alignment);
+ addKnuthElementsForBreakAfter(returnList, context);
if (keepWithNextPendingOnLabel || keepWithNextPendingOnBody || mustKeepWithNext()) {
context.setFlags(LayoutContext.KEEP_WITH_NEXT_PENDING);
<changes>
<release version="FOP Trunk">
+ <action context="Code" dev="JM" type="fix">
+ Bugfix: padding-top and padding-bottom on list-items could lead to wrong page
+ break decisions and thus to overlapping text.
+ </action>
+ <action context="Code" dev="JM" type="fix">
+ Bugfix: break-before and break-after were ignored on list-items.
+ </action>
<action context="Code" dev="LF" type="fix" fixes-bug="38507">
Bugfix: The elements representing a non-breaking space weren't always correct.
</action>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2006 The Apache Software Foundation
+
+ Licensed 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 element list generation with breaks on list-items.
+ </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:list-block provisional-distance-between-starts="1in" provisional-label-separation="0.1in">
+ <fo:list-item background-color="yellow" break-after="page">
+ <fo:list-item-label end-indent="label-end()">
+ <fo:block>label 1</fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="body-start()">
+ <fo:block>
+ body 1: We'll break after this yellow list item.
+ </fo:block>
+ </fo:list-item-body>
+ </fo:list-item>
+ <fo:list-item>
+ <fo:list-item-label end-indent="label-end()">
+ <fo:block>label 2</fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="body-start()">
+ <fo:block>
+ body 2: This is just a boring list item.
+ </fo:block>
+ </fo:list-item-body>
+ </fo:list-item>
+ <fo:list-item background-color="orange" break-before="page">
+ <fo:list-item-label end-indent="label-end()">
+ <fo:block>label 3</fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="body-start()">
+ <fo:block>
+ body 3: We had a break before this orange list item.
+ </fo:block>
+ </fo:list-item-body>
+ </fo:list-item>
+ </fo:list-block>
+ </fo:flow>
+ </fo:page-sequence>
+ </fo:root>
+ </fo>
+ <checks>
+ <element-list category="breaker" index="0">
+ <box w="14400"/>
+ <skip>3</skip>
+ </element-list>
+ <element-list category="breaker" index="1">
+ <box w="14400"/>
+ <skip>3</skip>
+ </element-list>
+ <element-list category="breaker" index="2">
+ <box w="14400"/>
+ <skip>3</skip>
+ </element-list>
+ </checks>
+</testcase>
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2006 The Apache Software Foundation
+
+ Licensed 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 element list generation with padding in lists (list-item).
+ </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:list-block provisional-distance-between-starts="1in" provisional-label-separation="0.1in">
+ <fo:list-item padding-top="5pt" padding-bottom="8pt" background-color="yellow">
+ <fo:list-item-label end-indent="label-end()">
+ <fo:block>label 1</fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="body-start()">
+ <fo:block>
+ body 1: We should have 5pt padding-before and 8pt padding-after for this yellow list item.
+ </fo:block>
+ </fo:list-item-body>
+ </fo:list-item>
+ <fo:list-item padding-top="5pt" padding-bottom="8pt">
+ <fo:list-item-label end-indent="label-end()">
+ <fo:block>label 2</fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="body-start()">
+ <fo:block>
+ body 2: We should have 5pt padding-before and 8pt padding-after for this list item.
+ </fo:block>
+ </fo:list-item-body>
+ </fo:list-item>
+ </fo:list-block>
+ </fo:flow>
+ </fo:page-sequence>
+ </fo:root>
+ </fo>
+ <checks>
+ <element-list category="breaker">
+ <box w="0"/> <!-- Starting SpaceHandlingPosition -->
+ <penalty w="0" p="INF"/>
+ <glue w="5000" y="0" z="0"/>
+ <box w="28800"/>
+ <penalty w="0" p="INF"/>
+ <glue w="8000" y="0" z="0"/>
+
+ <penalty w="0" p="0"/>
+
+ <box w="0"/>
+ <penalty w="0" p="INF"/>
+ <glue w="5000" y="0" z="0"/>
+ <box w="28800"/>
+ <box w="0"/> <!-- SpaceHandlingPosition -->
+ <penalty w="0" p="INF"/>
+ <glue w="8000" y="0" z="0"/>
+ <box w="0"/>
+
+ <skip>3</skip>
+ </element-list>
+ </checks>
+</testcase>