From: Simon Pepping Date: Tue, 7 Dec 2004 20:11:21 +0000 (+0000) Subject: Removed RetrieveMarkerLM. The LMs of the marker children are attached X-Git-Tag: Root_Temp_KnuthStylePageBreaking~315 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=c2684bdf43d04e12668b66a088973d2e1bdeb7aa;p=xmlgraphics-fop.git Removed RetrieveMarkerLM. The LMs of the marker children are attached 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 --- diff --git a/src/java/org/apache/fop/fo/flow/Marker.java b/src/java/org/apache/fop/fo/flow/Marker.java index 2af16dbb4..8ac8b1345 100644 --- a/src/java/org/apache/fop/fo/flow/Marker.java +++ b/src/java/org/apache/fop/fo/flow/Marker.java @@ -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. */ diff --git a/src/java/org/apache/fop/fo/flow/RetrieveMarker.java b/src/java/org/apache/fop/fo/flow/RetrieveMarker.java index 400ee3af7..c9dd1a079 100644 --- a/src/java/org/apache/fop/fo/flow/RetrieveMarker.java +++ b/src/java/org/apache/fop/fo/flow/RetrieveMarker.java @@ -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); + } } /** diff --git a/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java b/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java index f5aa7d22a..9d8016f5b 100644 --- a/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java @@ -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); } } diff --git a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java index 51ba1f1ae..9c1f6227f 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java @@ -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 { diff --git a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java index 08130fca2..bdd43c94e 100644 --- a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java @@ -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 index fba6b94e1..000000000 --- a/src/java/org/apache/fop/layoutmgr/RetrieveMarkerLayoutManager.java +++ /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; - } - -} -