]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Removed RetrieveMarkerLM. The LMs of the marker children are attached
authorSimon Pepping <spepping@apache.org>
Tue, 7 Dec 2004 20:11:21 +0000 (20:11 +0000)
committerSimon Pepping <spepping@apache.org>
Tue, 7 Dec 2004 20:11:21 +0000 (20:11 +0000)
in the LM tree as the direct children of the LM of the parent of the
RetrieveMarker. This patch solves bug 32253.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198192 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/fo/flow/Marker.java
src/java/org/apache/fop/fo/flow/RetrieveMarker.java
src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java
src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java
src/java/org/apache/fop/layoutmgr/RetrieveMarkerLayoutManager.java [deleted file]

index 2af16dbb411753cba6ccc93c5ba96e08d2620795..8ac8b1345f6c0046cb7a6d7b842691d3d6e8c092 100644 (file)
@@ -20,6 +20,9 @@ package org.apache.fop.fo.flow;
 
 import java.util.HashMap;
 import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+
 
 import org.xml.sax.Locator;
 
@@ -70,7 +73,7 @@ public class Marker extends FObjMixed {
         // Set a new parent property list and bind all the children again.
         propertyList.setParentPropertyList(parentPropertyList);
         for (Iterator i = children.keySet().iterator(); i.hasNext(); ) {
-            Object child = i.next();
+            FONode child = (FONode) i.next();
             PropertyList childList = (PropertyList) children.get(child);
             if (child instanceof FObj) {
                 ((FObj) child).bind(childList);
@@ -126,6 +129,21 @@ public class Marker extends FObjMixed {
         }
     }
 
+    /**
+     * @see org.apache.fop.fo.FONode#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()) {
+            FONode child = (FONode) baseIter.next();
+            child.addLayoutManager(list);
+        }
+    }
+
     /**
      * Return the "marker-class-name" property.
      */
index 400ee3af785eaeb2ace58873d1c134b2196cf607..c9dd1a0790c9cb2332e361190e34aa8b48769431 100644 (file)
@@ -23,6 +23,8 @@ import java.util.List;
 
 import org.xml.sax.Locator;
 
+import org.apache.commons.logging.Log;
+
 import org.apache.fop.apps.FOPException;
 import org.apache.fop.fo.FOEventHandler;
 import org.apache.fop.fo.FONode;
@@ -30,7 +32,7 @@ import org.apache.fop.fo.FObjMixed;
 import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.StaticPropertyList;
 import org.apache.fop.fo.ValidationException;
-import org.apache.fop.layoutmgr.RetrieveMarkerLayoutManager;
+import org.apache.fop.layoutmgr.LayoutManager;
 
 
 /**
@@ -108,13 +110,14 @@ public class RetrieveMarker extends FObjMixed {
         return retrieveBoundary;
     }
 
-
-    /**
-     * @see org.apache.fop.fo.FONode#addLayoutManager(List)
-     */
-    public void addLayoutManager(List list) {
-        RetrieveMarkerLayoutManager lm = new RetrieveMarkerLayoutManager(this);
-        list.add(lm);
+    public void bindMarker(Marker marker) {
+        // assert(marker != null);
+        try {
+            marker.rebind(getPropertyList());
+        } catch (FOPException exc) {
+            Log log = getLogger();
+            log.error("fo:retrieve-marker unable to rebind property values", exc);
+        }
     }
 
     /**
index f5aa7d22acdad45a75b7a83d683f08ae1ff87f0e..9d8016f5b0e1880bd99835cc80bd9d8784e0ae4d 100644 (file)
@@ -24,6 +24,7 @@ import org.apache.fop.area.Area;
 import org.apache.fop.area.Resolvable;
 import org.apache.fop.area.PageViewport;
 import org.apache.fop.fo.Constants;
+import org.apache.fop.fo.flow.RetrieveMarker;
 import org.apache.fop.fo.flow.Marker;
 
 import org.apache.commons.logging.Log;
@@ -373,6 +374,17 @@ public abstract class AbstractLayoutManager implements LayoutManager, Constants
             Object theobj = fobjIter.next();
             if (theobj instanceof FONode) {
                 FONode foNode = (FONode) theobj;
+                if (foNode instanceof RetrieveMarker) {
+                    RetrieveMarker rm = (RetrieveMarker) foNode;
+                    Marker marker = retrieveMarker(rm.getRetrieveClassName(),
+                                                   rm.getRetrievePosition(),
+                                                   rm.getRetrieveBoundary());
+                    if (marker == null) {
+                        continue;
+                    }
+                    rm.bindMarker(marker);
+                    foNode = marker;
+                }
                 foNode.addLayoutManager(newLMs);
             }
         }
index 51ba1f1ae49c3b67aeddbf27d298d169c21bb567..9c1f6227fba4f4dfc630928ed1b97629c485000c 100644 (file)
@@ -121,7 +121,6 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
 
         while (proxyLMiter.hasNext()) {
             LayoutManager lm = (LayoutManager) proxyLMiter.next();
-            lm.setParent(this);
             if (lm.generatesInlineAreas()) {
                 LineLayoutManager lineLM = createLineManager(lm);
                 addChildLM(lineLM);
@@ -148,7 +147,6 @@ public class BlockLayoutManager extends BlockStackingLayoutManager {
         inlines.add(firstlm);
         while (proxyLMiter.hasNext()) {
             LayoutManager lm = (LayoutManager) proxyLMiter.next();
-            lm.setParent(this);
             if (lm.generatesInlineAreas()) {
                 inlines.add(lm);
             } else {
index 08130fca2f51ea3ab37e351925255dbbbd20d1f5..bdd43c94e05f46ca21da014d1c3edbe858c7fd17 100644 (file)
@@ -392,6 +392,10 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager implements
             }
         }
 
+        if (mark == null) {
+            log.debug("found no marker with name: " + name);
+        }
+
         return mark;
     }
 
diff --git a/src/java/org/apache/fop/layoutmgr/RetrieveMarkerLayoutManager.java b/src/java/org/apache/fop/layoutmgr/RetrieveMarkerLayoutManager.java
deleted file mode 100644 (file)
index fba6b94..0000000
+++ /dev/null
@@ -1,232 +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.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.apache.fop.apps.FOPException;
-import org.apache.fop.area.Area;
-import org.apache.fop.fo.flow.Marker;
-import org.apache.fop.fo.flow.RetrieveMarker;
-
-/**
- * LayoutManager for a block FO.
- */
-public class RetrieveMarkerLayoutManager extends AbstractLayoutManager 
-    implements InlineLevelLayoutManager {
-
-    private RetrieveMarker fobj;
-    
-    private LayoutManager replaceLM = null;
-    private boolean loaded = false;
-    private String name;
-    private int position;
-    private int boundary;
-    private List markerLMList = new ArrayList(10);
-
-    /**
-     * Create a new block container layout manager.
-     */
-    public RetrieveMarkerLayoutManager(RetrieveMarker node) {
-        super(node);
-        fobj = node;
-        name = node.getRetrieveClassName();
-        position = node.getRetrievePosition();
-        boundary = node.getRetrieveBoundary();
-    }
-
-    public boolean generatesInlineAreas() {
-        loadLM();
-        if (replaceLM == null) {
-            return true;
-        }
-        return replaceLM.generatesInlineAreas();
-    }
-
-    public BreakPoss getNextBreakPoss(LayoutContext context) {
-        loadLM();
-        if (replaceLM == null) {
-            return null;
-        }
-        return replaceLM.getNextBreakPoss(context);
-    }
-
-    /**
-     * @see org.apache.fop.layoutmgr.InlineLevelLayoutManager#getNextKnuthElements
-     */
-    public LinkedList getNextKnuthElements(LayoutContext context,
-            int alignment) {
-        loadLM();
-        if (replaceLM == null) {
-            return null;
-        }
-        return ((InlineLevelLayoutManager) replaceLM)
-               .getNextKnuthElements(context, alignment);
-    }
-
-    /**
-     * @see org.apache.fop.layoutmgr.InlineLevelLayoutManager#addALetterSpaceTo
-     */
-    public KnuthElement addALetterSpaceTo(KnuthElement element) {
-        loadLM();
-        if (replaceLM == null) {
-            return null;
-        }
-        return ((InlineLevelLayoutManager) replaceLM)
-            .addALetterSpaceTo(element);
-    }
-
-    /**
-     * @see org.apache.fop.layoutmgr.InlineLevelLayoutManager#getWordChars
-     */
-    public void getWordChars(StringBuffer sbChars, Position pos) {
-        loadLM();
-        if (replaceLM != null) {
-            ((InlineLevelLayoutManager) replaceLM)
-                .getWordChars(sbChars, pos);
-        }
-    }
-
-    /**
-     * @see org.apache.fop.layoutmgr.InlineLevelLayoutManager#hyphenate
-     */
-    public void hyphenate(Position pos, HyphContext hc) {
-        loadLM();
-        if (replaceLM != null) {
-            ((InlineLevelLayoutManager) replaceLM).hyphenate(pos, hc);
-        }
-    }
-
-    /**
-     * @see org.apache.fop.layoutmgr.InlineLevelLayoutManager#applyChanges
-     */
-    public boolean applyChanges(List oldList) {
-        loadLM();
-        if (replaceLM == null) {
-            return false;
-        }
-        return ((InlineLevelLayoutManager) replaceLM)
-            .applyChanges(oldList);
-    }
-
-    /**
-     * @see org.apache.fop.layoutmgr.InlineLevelLayoutManager#getChangedKnuthElements
-     */
-    public LinkedList getChangedKnuthElements(List oldList,
-                                              int flaggedPenalty,
-                                              int alignment) {
-        loadLM();
-        if (replaceLM == null) {
-            return null;
-        }
-        return ((InlineLevelLayoutManager) replaceLM)
-               .getChangedKnuthElements(oldList, flaggedPenalty,
-                                        alignment);
-    }
-
-    public void addAreas(PositionIterator parentIter,
-                         LayoutContext layoutContext) {
-
-        loadLM();
-        replaceLM.addAreas(parentIter, layoutContext);
-
-    }
-
-    public boolean isFinished() {
-        loadLM();
-        if (replaceLM == null) {
-            return true;
-        }
-        return replaceLM.isFinished();
-    }
-
-    public void setFinished(boolean fin) {
-        if (replaceLM != null) {
-            replaceLM.setFinished(fin);
-        }
-    }
-
-    /** @todo unsure how markerLMList will get tied to main currentLMList
-        of AreaTreeHandler */
-    protected void loadLM() {
-        if (loaded) {
-            return;
-        }
-        loaded = true;
-        if (replaceLM == null) {
-            List list = new ArrayList();
-            Marker marker = retrieveMarker(name, position, boundary);
-            if (marker != null) {
-                try {
-                    marker.rebind(fobj.getPropertyList());
-                } catch (FOPException exc) {
-                    log.error("fo:retrieve-marker unable to rebind property values", exc);
-                }
-                marker.addLayoutManager(list);
-                if (list.size() > 0) {
-                    replaceLM =  (LayoutManager)list.get(0);
-                    replaceLM.setParent(this);
-                    replaceLM.initialize();
-                    log.debug("retrieved: " + replaceLM + ":" + list.size());
-                }
-            } else {
-                log.debug("found no marker with name: " + name);
-            }
-        }
-    }
-
-    /**
-     * Get the parent area for children of this block container.
-     * This returns the current block container area
-     * and creates it if required.
-     *
-     * @see org.apache.fop.layoutmgr.LayoutManager#getParentArea(Area)
-     */
-    public Area getParentArea(Area childArea) {
-        return parentLM.getParentArea(childArea);
-    }
-
-    /**
-     * Add the child to the block container.
-     *
-     * @see org.apache.fop.layoutmgr.LayoutManager#addChild(Area)
-     */
-    public void addChild(Area childArea) {
-        parentLM.addChild(childArea);
-    }
-
-    /**
-     * @see org.apache.fop.layoutmgr.LayoutManager#resetPosition(Position)
-     */
-    public void resetPosition(Position resetPos) {
-        loadLM();
-        if (resetPos == null) {
-            reset(null);
-        }
-        if (replaceLM != null) {
-            replaceLM.resetPosition(null);
-        }
-        loaded = false;
-        replaceLM = null;
-    }
-
-}
-