diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/java/org/apache/fop/area/AreaTreeHandler.java | 32 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/FObj.java | 1 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/LMVisited.java | 26 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/flow/Wrapper.java | 29 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/pagination/Root.java | 1 | ||||
-rw-r--r-- | src/java/org/apache/fop/layoutmgr/AddLMVisitor.java | 93 | ||||
-rw-r--r-- | src/java/org/apache/fop/layoutmgr/LMiter.java | 5 | ||||
-rw-r--r-- | src/java/org/apache/fop/layoutmgr/RetrieveMarkerLayoutManager.java | 6 |
8 files changed, 50 insertions, 143 deletions
diff --git a/src/java/org/apache/fop/area/AreaTreeHandler.java b/src/java/org/apache/fop/area/AreaTreeHandler.java index d2ff24740..38566fa96 100644 --- a/src/java/org/apache/fop/area/AreaTreeHandler.java +++ b/src/java/org/apache/fop/area/AreaTreeHandler.java @@ -35,11 +35,11 @@ import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.area.extensions.BookmarkData; import org.apache.fop.fo.FOInputHandler; +import org.apache.fop.fo.FObj; import org.apache.fop.fo.extensions.Outline; import org.apache.fop.fo.extensions.Bookmarks; import org.apache.fop.fo.pagination.PageSequence; import org.apache.fop.fonts.FontInfo; -import org.apache.fop.layoutmgr.AddLMVisitor; import org.apache.fop.layoutmgr.ContentLayoutManager; import org.apache.fop.layoutmgr.InlineStackingLayoutManager; import org.apache.fop.layoutmgr.LMiter; @@ -88,9 +88,8 @@ public class AreaTreeHandler extends FOInputHandler { // count of number of pages rendered private int pageCount; - /** Useful only for allowing subclasses of AddLMVisitor to be set by those - extending FOP **/ - private AddLMVisitor addLMVisitor = null; + /** The List object to which FO's should add Layout Managers */ + protected List currentLMList; // AreaTreeModel in use private AreaTreeModel model; @@ -452,16 +451,25 @@ public class AreaTreeHandler extends FOInputHandler { return title; } + + /** + * Accessor for the currentLMList. + * @return the currentLMList. + * @todo see if should have initialization of LM list occur here + */ + public List getCurrentLMList() { + return currentLMList; + } /** - * Public accessor to get the AddLMVisitor object that should be used. - * @return the AddLMVisitor object that should be used. + * + * @param fobj the FObj object for which a layout manager should be created + * @param lmList the list to which the newly created layout manager(s) + * should be added */ - public AddLMVisitor getAddLMVisitor() { - if (this.addLMVisitor == null) { - this.addLMVisitor = new AddLMVisitor(); - } - return this.addLMVisitor; + public void addLayoutManager(FObj fobj, List lmList) { + currentLMList = lmList; + fobj.addLayoutManager(currentLMList); } - } + diff --git a/src/java/org/apache/fop/fo/FObj.java b/src/java/org/apache/fop/fo/FObj.java index 03d35f542..f0e6f7461 100644 --- a/src/java/org/apache/fop/fo/FObj.java +++ b/src/java/org/apache/fop/fo/FObj.java @@ -29,7 +29,6 @@ import java.util.Set; import org.apache.fop.fo.flow.Marker; import org.apache.fop.fo.properties.Property; import org.apache.fop.fo.properties.PropertyMaker; -import org.apache.fop.layoutmgr.AddLMVisitor; import org.xml.sax.Attributes; import org.xml.sax.Locator; diff --git a/src/java/org/apache/fop/fo/LMVisited.java b/src/java/org/apache/fop/fo/LMVisited.java deleted file mode 100644 index 7faec73d0..000000000 --- a/src/java/org/apache/fop/fo/LMVisited.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Copyright 1999-2004 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$ */ - -package org.apache.fop.fo; - -import org.apache.fop.layoutmgr.AddLMVisitor; - -public interface LMVisited { - public void acceptVisitor(AddLMVisitor aLMV); -} - diff --git a/src/java/org/apache/fop/fo/flow/Wrapper.java b/src/java/org/apache/fop/fo/flow/Wrapper.java index 82a9be783..fe294f9e9 100644 --- a/src/java/org/apache/fop/fo/flow/Wrapper.java +++ b/src/java/org/apache/fop/fo/flow/Wrapper.java @@ -18,11 +18,14 @@ package org.apache.fop.fo.flow; +// Java +import java.util.List; +import java.util.ListIterator; + // FOP import org.apache.fop.fo.FONode; +import org.apache.fop.fo.FObj; import org.apache.fop.fo.FObjMixed; -import org.apache.fop.layoutmgr.AddLMVisitor; -import org.apache.fop.fo.LMVisited; /** * Implementation for fo:wrapper formatting object. @@ -32,7 +35,7 @@ import org.apache.fop.fo.LMVisited; * Content: (#PCDATA|%inline;|%block;)* * Properties: id */ -public class Wrapper extends FObjMixed implements LMVisited { +public class Wrapper extends FObjMixed { /** * @param parent FONode that is the parent of this object @@ -41,10 +44,24 @@ public class Wrapper extends FObjMixed implements LMVisited { super(parent); } - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveWrapper(this); + /** + * @see org.apache.fop.fo.FObj#addLayoutManager(List) + * @todo remove null check when vCN() & endOfNode() implemented + */ + public void addLayoutManager(List list) { + ListIterator baseIter = getChildNodes(); + if (baseIter == null) { + return; + } + while (baseIter.hasNext()) { + FObj child = (FObj) baseIter.next(); + child.addLayoutManager(list); + } } - + + /** + * @see org.apache.fop.fo.FObj#getName() + */ public String getName() { return "fo:wrapper"; } diff --git a/src/java/org/apache/fop/fo/pagination/Root.java b/src/java/org/apache/fop/fo/pagination/Root.java index 4c81da5c8..0f8189092 100644 --- a/src/java/org/apache/fop/fo/pagination/Root.java +++ b/src/java/org/apache/fop/fo/pagination/Root.java @@ -31,7 +31,6 @@ import org.apache.fop.fo.FObj; import org.apache.fop.fo.extensions.ExtensionElementMapping; import org.apache.fop.fo.extensions.Bookmarks; import org.apache.fop.fo.FOInputHandler; -import org.apache.fop.layoutmgr.AddLMVisitor; /** * The fo:root formatting object. Contains page masters, page-sequences. diff --git a/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java b/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java deleted file mode 100644 index db84ef953..000000000 --- a/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java +++ /dev/null @@ -1,93 +0,0 @@ -/* - * Copyright 1999-2004 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$ */ - -package org.apache.fop.layoutmgr; - -import java.util.List; -import java.util.ListIterator; - -import org.apache.fop.fo.FObj; -import org.apache.fop.fo.flow.Wrapper; -import org.apache.fop.fo.LMVisited; - -/** - * Visitor pattern for the purpose of adding - * Layout Managers to nodes in the FOTree. - * Each method is responsible to return a LayoutManager - * responsible for laying out this FObj's content. - */ -public class AddLMVisitor { - - /** The List object to which methods in this class should add Layout - * Managers */ - protected List currentLMList; - - /** A List object which can be used to save and restore the currentLMList if - * another List should temporarily be used */ - protected List saveLMList; - - /** - * - * @param fobj the FObj object for which a layout manager should be created - * @param lmList the list to which the newly created layout manager(s) - * should be added - */ - public void addLayoutManager(FObj fobj, List lmList) { - /* Store the List in a global variable so that it can be accessed by the - Visitor methods */ - currentLMList = lmList; - if (fobj instanceof LMVisited) { - ((LMVisited) fobj).acceptVisitor(this); - } else { - fobj.addLayoutManager(currentLMList); - } - } - - /** - * Accessor for the currentLMList. - * @return the currentLMList. - */ - public List getCurrentLMList() { - return currentLMList; - } - - /** - * Accessor for the saveLMList. - * @return the saveLMList. - */ - public List getSaveLMList() { - return saveLMList; - } - - /** - * @param node Wrapper object to process - */ - public void serveWrapper(Wrapper node) { - ListIterator baseIter; - baseIter = node.getChildNodes(); - if (baseIter == null) return; - while (baseIter.hasNext()) { - FObj child = (FObj) baseIter.next(); - if (child instanceof LMVisited) { - ((LMVisited) child).acceptVisitor(this); - } else { - child.addLayoutManager(currentLMList); - } - } - } -} diff --git a/src/java/org/apache/fop/layoutmgr/LMiter.java b/src/java/org/apache/fop/layoutmgr/LMiter.java index e7d64719d..ee62cec1f 100644 --- a/src/java/org/apache/fop/layoutmgr/LMiter.java +++ b/src/java/org/apache/fop/layoutmgr/LMiter.java @@ -18,6 +18,7 @@ package org.apache.fop.layoutmgr; +import org.apache.fop.area.AreaTreeHandler; import org.apache.fop.fo.FObj; import java.util.ArrayList; @@ -46,14 +47,14 @@ public class LMiter implements ListIterator { } protected boolean preLoadNext() { - AddLMVisitor addLMVisitor = lp.getAreaTreeHandler().getAddLMVisitor(); + AreaTreeHandler areaTreeHandler = lp.getAreaTreeHandler(); // skip over child FObj's that don't add lms while (baseIter != null && baseIter.hasNext()) { Object theobj = baseIter.next(); if (theobj instanceof FObj) { FObj fobj = (FObj) theobj; //listLMs.add(fobj.getLayoutManager()); - addLMVisitor.addLayoutManager(fobj, listLMs); + areaTreeHandler.addLayoutManager(fobj, listLMs); if (curPos < listLMs.size()) { return true; } diff --git a/src/java/org/apache/fop/layoutmgr/RetrieveMarkerLayoutManager.java b/src/java/org/apache/fop/layoutmgr/RetrieveMarkerLayoutManager.java index f66962afc..b01534e03 100644 --- a/src/java/org/apache/fop/layoutmgr/RetrieveMarkerLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/RetrieveMarkerLayoutManager.java @@ -35,7 +35,7 @@ public class RetrieveMarkerLayoutManager extends AbstractLayoutManager { private String name; private int position; private int boundary; - private AddLMVisitor addLMVisitor = new AddLMVisitor(); + private List markerLMList = new ArrayList(10); /** * Create a new block container layout manager. @@ -86,6 +86,8 @@ public class RetrieveMarkerLayoutManager extends AbstractLayoutManager { } } + /** @todo unsure how markerLMList will get tied to main currentLMList + of AreaTreeHandler */ protected void loadLM() { if (loaded) { return; @@ -95,7 +97,7 @@ public class RetrieveMarkerLayoutManager extends AbstractLayoutManager { List list = new ArrayList(); Marker marker = retrieveMarker(name, position, boundary); if (marker != null) { - addLMVisitor.addLayoutManager(marker, list); + marker.addLayoutManager(markerLMList); if (list.size() > 0) { replaceLM = (LayoutManager)list.get(0); replaceLM.setParent(this); |