From 68bcc37323c02a04e2af3ff99d1f54bf32b0f986 Mon Sep 17 00:00:00 2001 From: Karen Lease Date: Sun, 11 Nov 2001 14:15:10 +0000 Subject: [PATCH] Integrate layout managers for text and block git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194558 13f79535-47bb-0310-9956-ffa450edef68 --- src/org/apache/fop/fo/FOText.java | 5 ++ src/org/apache/fop/fo/FObj.java | 5 +- src/org/apache/fop/fo/flow/Block.java | 5 +- .../fop/fo/pagination/PageSequence.java | 48 ++++++++++--------- 4 files changed, 36 insertions(+), 27 deletions(-) diff --git a/src/org/apache/fop/fo/FOText.java b/src/org/apache/fop/fo/FOText.java index b0ebd2b4b..8c02cc07e 100644 --- a/src/org/apache/fop/fo/FOText.java +++ b/src/org/apache/fop/fo/FOText.java @@ -16,6 +16,8 @@ import org.apache.fop.datatypes.*; import org.apache.fop.fo.properties.*; import org.apache.fop.apps.FOPException; import org.apache.fop.system.BufferManager; +import org.apache.fop.layoutmgr.LayoutManager; +import org.apache.fop.layoutmgr.TextLayoutManager; /** * a text node in the formatting object tree @@ -234,5 +236,8 @@ public class FOText extends FObj { return -1; } + public LayoutManager getLayoutManager() { + return new TextLayoutManager(this, ca); + } } diff --git a/src/org/apache/fop/fo/FObj.java b/src/org/apache/fop/fo/FObj.java index dc74a8a01..f4b6b52e6 100644 --- a/src/org/apache/fop/fo/FObj.java +++ b/src/org/apache/fop/fo/FObj.java @@ -25,6 +25,7 @@ import java.util.Iterator; import org.xml.sax.Attributes; import java.util.Iterator; +import java.util.ListIterator; import java.util.Vector; import java.util.Hashtable; @@ -199,8 +200,8 @@ public class FObj extends FONode { } - public Iterator getChildren() { - return children.iterator(); + public ListIterator getChildren() { + return children.listIterator(); } public void setIsInTableCell() { diff --git a/src/org/apache/fop/fo/flow/Block.java b/src/org/apache/fop/fo/flow/Block.java index cb8335c4c..f548b9e1c 100644 --- a/src/org/apache/fop/fo/flow/Block.java +++ b/src/org/apache/fop/fo/flow/Block.java @@ -14,7 +14,7 @@ import org.apache.fop.layout.*; import org.apache.fop.datatypes.*; import org.apache.fop.apps.FOPException; import org.apache.fop.layoutmgr.LayoutManager; -//import org.apache.fop.layoutmgr.BlockLayoutManager; +import org.apache.fop.layoutmgr.BlockLayoutManager; import org.xml.sax.Attributes; @@ -353,8 +353,7 @@ public class Block extends FObjMixed { } public LayoutManager getLayoutManager() { - //return new BlockLayoutManager(this); - return null; + return new BlockLayoutManager(this); } } diff --git a/src/org/apache/fop/fo/pagination/PageSequence.java b/src/org/apache/fop/fo/pagination/PageSequence.java index 389be2c64..da1e22883 100644 --- a/src/org/apache/fop/fo/pagination/PageSequence.java +++ b/src/org/apache/fop/fo/pagination/PageSequence.java @@ -242,6 +242,7 @@ public class PageSequence extends FObj { else { this.mainFlow = (Flow)child; addFlow(mainFlow); + super.addChild(child); // For getChildren } } else if (childName.equals("fo:static-content")) { @@ -267,7 +268,10 @@ public class PageSequence extends FObj { public void end() { try { - format(null); + AreaTree at = new AreaTree(); + at.setTreeModel(AreaTree.createStorePagesModel()); + at.startPageSequence(null); + format(at); } catch (FOPException fopex) { log.error("Error in PageSequence.end(): " + fopex.getMessage()); @@ -277,27 +281,27 @@ public class PageSequence extends FObj { - /** - * Return children for layout. Only the main flow is laid out directly. - */ - public Iterator getChildren() { - return new Iterator() { - boolean bFirst=true; - public boolean hasNext() { - return (bFirst==true && mainFlow != null); - } - public Object next() { - if (bFirst==true && mainFlow != null) { - bFirst=false; - return mainFlow; - } - else throw new NoSuchElementException(); - } - public void remove() { - throw new UnsupportedOperationException(); - } - }; - } +// /** +// * Return children for layout. Only the main flow is laid out directly. +// */ +// public ListIterator getChildren() { +// return new ListIterator() { +// boolean bFirst=true; +// public boolean hasNext() { +// return (bFirst==true && mainFlow != null); +// } +// public Object next() { +// if (bFirst==true && mainFlow != null) { +// bFirst=false; +// return mainFlow; +// } +// else throw new NoSuchElementException(); +// } +// public void remove() { +// throw new UnsupportedOperationException(); +// } +// }; +// } /** * Runs the formatting of this page sequence into the given area tree -- 2.39.5