You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by sp...@apache.org on 2007/11/30 22:09:35 UTC
svn commit: r599963 - in
/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking:
src/java/org/apache/fop/layoutmgr/list/ test/layoutengine/standard-testcases/
Author: spepping
Date: Fri Nov 30 13:09:33 2007
New Revision: 599963
URL: http://svn.apache.org/viewvc?rev=599963&view=rev
Log:
Nested lists solved by calling KnuthSequence.resolveElements in
ListItemLM.getNextStep. Added two test cases.
Added:
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/test/layoutengine/standard-testcases/list-block_nested.xml (with props)
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/test/layoutengine/standard-testcases/list-block_nested_fox_widow-content-limit_1.xml (with props)
Modified:
xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
Modified: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java?rev=599963&r1=599962&r2=599963&view=diff
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java (original)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java Fri Nov 30 13:09:33 2007
@@ -19,7 +19,6 @@
package org.apache.fop.layoutmgr.list;
-import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
@@ -31,6 +30,7 @@
import org.apache.fop.fo.flow.ListItem;
import org.apache.fop.fo.flow.ListItemBody;
import org.apache.fop.fo.flow.ListItemLabel;
+import org.apache.fop.layoutmgr.BlockKnuthSequence;
import org.apache.fop.layoutmgr.BlockLevelLayoutManager;
import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
import org.apache.fop.layoutmgr.BreakElement;
@@ -46,7 +46,6 @@
import org.apache.fop.layoutmgr.LeafPosition;
import org.apache.fop.layoutmgr.ListElement;
import org.apache.fop.layoutmgr.NonLeafPosition;
-import org.apache.fop.layoutmgr.ParagraphListElement;
import org.apache.fop.layoutmgr.Position;
import org.apache.fop.layoutmgr.PositionIterator;
import org.apache.fop.layoutmgr.RelSide;
@@ -76,7 +75,7 @@
private LinkedList bodyList = null;
// these data are used during getCombinedKnuthElementsForListItem;
- private List[] elementLists = null;
+ private BlockKnuthSequence[] elementLists = null;
private int[] partialHeights = {0, 0};
private int[] start = {-1, -1};
private int[] end = {-1, -1};
@@ -290,8 +289,9 @@
// At the first invocation of this method the elements in labelList and bodyList
// are copied to array lists to improve element access performance
if (elementLists == null) {
- elementLists =
- new List[] {new ArrayList(labelList), new ArrayList(bodyList)};
+ elementLists =
+ new BlockKnuthSequence[] {new BlockKnuthSequence(labelList),
+ new BlockKnuthSequence(bodyList)};
}
int step;
@@ -373,7 +373,7 @@
while (end[i] + 1 < elementLists[i].size()) {
end[i]++;
// scan for unresolved elements and paragraphs
- resolveElements(elementLists[i], end[i]);
+ elementLists[i].resolveElements(end[i]);
KnuthElement el = (KnuthElement) elementLists[i].get(end[i]);
if (el.isPenalty()) {
if (el.getP() < KnuthElement.INFINITE) {
@@ -482,32 +482,6 @@
*/
public void setIsEndOfSubsequence(boolean isEndOfSubsequence) {
this.isEndOfSubsequence = isEndOfSubsequence;
- }
-
- /**
- * The iteration stops at the first resolved element (after line breaking).
- * After space resolution it is guaranteed that seq does not to contain
- * ParagraphListElements until the first resolved element.
- * @param seq the Knuth Sequence
- * @param startIndex the start index
- */
- private void resolveElements(List seq, int startIndex) {
- for (int i = startIndex; i < seq.size(); ++i) {
- ListElement elt = (ListElement) seq.get(i);
- if (!elt.isUnresolvedElement() && !(elt instanceof ParagraphListElement)) {
- break;
- }
- if (elt instanceof ParagraphListElement) {
- LinkedList lineElts = ((ParagraphListElement) elt).doLineBreaking();
- seq.remove(i);
- seq.addAll(i, lineElts);
- // consider the new element at i
- --i;
- }
- }
-
- //Space resolution as if the contents were placed in a new reference area
- SpaceResolver.resolveElementList(seq, startIndex);
}
/**
Added: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/test/layoutengine/standard-testcases/list-block_nested.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/test/layoutengine/standard-testcases/list-block_nested.xml?rev=599963&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/test/layoutengine/standard-testcases/list-block_nested.xml (added)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/test/layoutengine/standard-testcases/list-block_nested.xml Fri Nov 30 13:09:33 2007
@@ -0,0 +1,99 @@
+<?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 the ability of FOP to render nested lists.
+ </p>
+ </info>
+ <fo>
+ <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns:fox="http://xmlgraphics.apache.org/fop/extensions">
+ <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" white-space-collapse="true" widows="0" orphans="0">
+ <fo:flow flow-name="xsl-region-body">
+ <fo:block>Some text</fo:block>
+ <fo:list-block
+ provisional-distance-between-starts="12pt" provisional-label-separation="5pt">
+ <fo:list-item>
+ <fo:list-item-label end-indent="label-end()">
+ <fo:block>â¢</fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="body-start()">
+ <fo:block>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec felis ipsum, viverra ut, aliquam porttitor, convallis id, risus. Fusce malesuada nunc nec orci.</fo:block>
+ </fo:list-item-body>
+ </fo:list-item>
+ <fo:list-item>
+ <fo:list-item-label end-indent="label-end()">
+ <fo:block>â¢</fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="body-start()">
+ <fo:block>A nested list:</fo:block>
+ <fo:list-block
+ provisional-distance-between-starts="12pt" provisional-label-separation="5pt">
+ <fo:list-item>
+ <fo:list-item-label end-indent="label-end()">
+ <fo:block>â</fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="body-start()">
+ <fo:block>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec felis ipsum, viverra ut, aliquam porttitor, convallis id, risus. Fusce malesuada nunc nec orci.</fo:block>
+ </fo:list-item-body>
+ </fo:list-item>
+ <fo:list-item>
+ <fo:list-item-label end-indent="label-end()">
+ <fo:block>â</fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="body-start()">
+ <fo:block>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec felis ipsum.</fo:block>
+ </fo:list-item-body>
+ </fo:list-item>
+ </fo:list-block>
+ </fo:list-item-body>
+ </fo:list-item>
+ <fo:list-item>
+ <fo:list-item-label end-indent="label-end()">
+ <fo:block>â¢</fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="body-start()">
+ <fo:block>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec felis ipsum.</fo:block>
+ </fo:list-item-body>
+ </fo:list-item>
+ </fo:list-block>
+ </fo:flow>
+ </fo:page-sequence>
+ </fo:root>
+ </fo>
+ <checks>
+ <!-- one page -->
+ <eval expected="1" xpath="count(/areaTree/pageSequence/pageViewport)"/>
+ <!-- two top level blocks: text and first-order list -->
+ <eval expected="2" xpath="count(/areaTree/pageSequence/pageViewport/page[1]/regionViewport/regionBody/mainReference/span/flow/block)"/>
+ <!-- three second level blocks: three first-order list items -->
+ <eval expected="3" xpath="count(/areaTree/pageSequence/pageViewport/page[1]/regionViewport/regionBody/mainReference/span/flow/block[2]/block)"/>
+ <!-- three lines in first item of nested list -->
+ <eval expected="3" xpath="count(/areaTree/pageSequence/pageViewport/page[1]/regionViewport/regionBody/mainReference/span/flow/block[2]/block[2]/block[2]/block[2]/block[1]/block[2]/block[1]/lineArea)"/>
+ <!-- two lines in second item of nested list -->
+ <eval expected="2" xpath="count(/areaTree/pageSequence/pageViewport/page[1]/regionViewport/regionBody/mainReference/span/flow/block[2]/block[2]/block[2]/block[2]/block[2]/block[2]/block[1]/lineArea)"/>
+ </checks>
+</testcase>
+
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/test/layoutengine/standard-testcases/list-block_nested.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/test/layoutengine/standard-testcases/list-block_nested.xml
------------------------------------------------------------------------------
svn:keywords = Id
Added: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/test/layoutengine/standard-testcases/list-block_nested_fox_widow-content-limit_1.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/test/layoutengine/standard-testcases/list-block_nested_fox_widow-content-limit_1.xml?rev=599963&view=auto
==============================================================================
--- xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/test/layoutengine/standard-testcases/list-block_nested_fox_widow-content-limit_1.xml (added)
+++ xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/test/layoutengine/standard-testcases/list-block_nested_fox_widow-content-limit_1.xml Fri Nov 30 13:09:33 2007
@@ -0,0 +1,150 @@
+<?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 the effect of the proprietary fox:widow-content-limit property on a nested list.
+ </p>
+ </info>
+ <fo>
+ <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns:fox="http://xmlgraphics.apache.org/fop/extensions">
+ <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" white-space-collapse="true" widows="0" orphans="0">
+ <fo:flow flow-name="xsl-region-body">
+ <fo:block space-before="5in - (7 * 1.2em)" space-before.conditionality="retain">Some text</fo:block>
+ <fo:list-block
+ provisional-distance-between-starts="12pt" provisional-label-separation="5pt">
+ <fo:list-item>
+ <fo:list-item-label end-indent="label-end()">
+ <fo:block>â¢</fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="body-start()">
+ <fo:block>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec felis ipsum, viverra ut, aliquam porttitor, convallis id, risus. Fusce malesuada nunc nec orci.</fo:block>
+ </fo:list-item-body>
+ </fo:list-item>
+ <fo:list-item>
+ <fo:list-item-label end-indent="label-end()">
+ <fo:block>â¢</fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="body-start()">
+ <fo:block>A nested list:</fo:block>
+ <fo:list-block
+ provisional-distance-between-starts="12pt" provisional-label-separation="5pt"
+ fox:widow-content-limit="3 * 1.2em">
+ <fo:list-item>
+ <fo:list-item-label end-indent="label-end()">
+ <fo:block>â</fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="body-start()">
+ <fo:block>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec felis ipsum, viverra ut, aliquam porttitor, convallis id, risus. Fusce malesuada nunc nec orci.</fo:block>
+ </fo:list-item-body>
+ </fo:list-item>
+ <fo:list-item>
+ <fo:list-item-label end-indent="label-end()">
+ <fo:block>â</fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="body-start()">
+ <fo:block>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec felis ipsum.</fo:block>
+ </fo:list-item-body>
+ </fo:list-item>
+ </fo:list-block>
+ </fo:list-item-body>
+ </fo:list-item>
+ <fo:list-item>
+ <fo:list-item-label end-indent="label-end()">
+ <fo:block>â¢</fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="body-start()">
+ <fo:block>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec felis ipsum.</fo:block>
+ </fo:list-item-body>
+ </fo:list-item>
+ </fo:list-block>
+ </fo:flow>
+ </fo:page-sequence>
+ <!-- the second page-sequence is without the extension property and just for reference. -->
+ <fo:page-sequence master-reference="normal" white-space-collapse="true" widows="0" orphans="0">
+ <fo:flow flow-name="xsl-region-body">
+ <fo:block space-before="5in - (7 * 1.2em)" space-before.conditionality="retain">Some text</fo:block>
+ <fo:list-block
+ provisional-distance-between-starts="12pt" provisional-label-separation="5pt">
+ <fo:list-item>
+ <fo:list-item-label end-indent="label-end()">
+ <fo:block>â¢</fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="body-start()">
+ <fo:block>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec felis ipsum, viverra ut, aliquam porttitor, convallis id, risus. Fusce malesuada nunc nec orci.</fo:block>
+ </fo:list-item-body>
+ </fo:list-item>
+ <fo:list-item>
+ <fo:list-item-label end-indent="label-end()">
+ <fo:block>â¢</fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="body-start()">
+ <fo:block>A nested list:</fo:block>
+ <fo:list-block
+ provisional-distance-between-starts="12pt" provisional-label-separation="5pt">
+ <fo:list-item>
+ <fo:list-item-label end-indent="label-end()">
+ <fo:block>â</fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="body-start()">
+ <fo:block>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec felis ipsum, viverra ut, aliquam porttitor, convallis id, risus. Fusce malesuada nunc nec orci.</fo:block>
+ </fo:list-item-body>
+ </fo:list-item>
+ <fo:list-item>
+ <fo:list-item-label end-indent="label-end()">
+ <fo:block>â</fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="body-start()">
+ <fo:block>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec felis ipsum.</fo:block>
+ </fo:list-item-body>
+ </fo:list-item>
+ </fo:list-block>
+ </fo:list-item-body>
+ </fo:list-item>
+ <fo:list-item>
+ <fo:list-item-label end-indent="label-end()">
+ <fo:block>â¢</fo:block>
+ </fo:list-item-label>
+ <fo:list-item-body start-indent="body-start()">
+ <fo:block>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Donec felis ipsum.</fo:block>
+ </fo:list-item-body>
+ </fo:list-item>
+ </fo:list-block>
+ </fo:flow>
+ </fo:page-sequence>
+ </fo:root>
+ </fo>
+ <checks>
+ <!-- Note that each list item label adds a separate line area -->
+ <!-- page 1 -->
+ <eval expected="7" xpath="count(/areaTree/pageSequence[1]/pageViewport[1]//lineArea)"/>
+ <!-- page 2 -->
+ <eval expected="10" xpath="count(/areaTree/pageSequence[1]/pageViewport[2]//lineArea)"/>
+ <!-- page 3 -->
+ <eval expected="10" xpath="count(/areaTree/pageSequence[2]/pageViewport[1]//lineArea)"/>
+ <!-- page 4 -->
+ <eval expected="7" xpath="count(/areaTree/pageSequence[2]/pageViewport[2]//lineArea)"/>
+ </checks>
+</testcase>
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/test/layoutengine/standard-testcases/list-block_nested_fox_widow-content-limit_1.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/branches/Temp_Interleaved_Page_Line_Breaking/test/layoutengine/standard-testcases/list-block_nested_fox_widow-content-limit_1.xml
------------------------------------------------------------------------------
svn:keywords = Id
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org