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;
// 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;
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);
}
-
}
+
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;
+++ /dev/null
-/*
- * 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);
-}
-
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.
* 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
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";
}
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.
+++ /dev/null
-/*
- * 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);
- }
- }
- }
-}
package org.apache.fop.layoutmgr;
+import org.apache.fop.area.AreaTreeHandler;
import org.apache.fop.fo.FObj;
import java.util.ArrayList;
}
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;
}
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.
}
}
+ /** @todo unsure how markerLMList will get tied to main currentLMList
+ of AreaTreeHandler */
protected void loadLM() {
if (loaded) {
return;
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);