From 55a4dc03eeea3dafceeb7c07b8508da593b73389 Mon Sep 17 00:00:00 2001 From: Glen Mazza Date: Fri, 6 Aug 2004 04:22:18 +0000 Subject: [PATCH] PR: Obtained from: Submitted by: Reviewed by: 1.) Continued conversion/deprecation of AddLMVisitor. About 16 FO's remaining. 2.) Created a *temporary* LMVisited interface to mark those FO's still needing conversion. This will be dropped once the process is complete. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197857 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/fo/FONode.java | 12 -- src/java/org/apache/fop/fo/FOText.java | 13 +- src/java/org/apache/fop/fo/FObj.java | 9 - src/java/org/apache/fop/fo/FObjMixed.java | 18 +- src/java/org/apache/fop/fo/LMVisited.java | 26 +++ .../org/apache/fop/fo/flow/BasicLink.java | 3 +- .../org/apache/fop/fo/flow/BidiOverride.java | 30 ++- src/java/org/apache/fop/fo/flow/Block.java | 18 +- .../apache/fop/fo/flow/BlockContainer.java | 15 +- .../org/apache/fop/fo/flow/Character.java | 3 +- .../apache/fop/fo/flow/ExternalGraphic.java | 3 +- src/java/org/apache/fop/fo/flow/Footnote.java | 19 +- src/java/org/apache/fop/fo/flow/Inline.java | 4 - .../apache/fop/fo/flow/InlineContainer.java | 18 +- .../fop/fo/flow/InstreamForeignObject.java | 3 +- src/java/org/apache/fop/fo/flow/Leader.java | 3 +- .../org/apache/fop/fo/flow/ListBlock.java | 16 +- src/java/org/apache/fop/fo/flow/ListItem.java | 3 +- .../org/apache/fop/fo/flow/PageNumber.java | 4 +- .../fop/fo/flow/PageNumberCitation.java | 3 +- .../apache/fop/fo/flow/RetrieveMarker.java | 4 +- src/java/org/apache/fop/fo/flow/Table.java | 3 +- .../org/apache/fop/fo/flow/TableBody.java | 4 +- .../org/apache/fop/fo/flow/TableCell.java | 18 +- .../org/apache/fop/fo/flow/TableFooter.java | 3 +- .../org/apache/fop/fo/flow/TableHeader.java | 3 +- src/java/org/apache/fop/fo/flow/TableRow.java | 16 +- src/java/org/apache/fop/fo/flow/Wrapper.java | 3 +- .../org/apache/fop/fo/pagination/Flow.java | 14 +- .../fop/fo/pagination/StaticContent.java | 10 - .../org/apache/fop/fo/pagination/Title.java | 10 - .../apache/fop/layoutmgr/AddLMVisitor.java | 172 +++--------------- .../fop/layoutmgr/BidiLayoutManager.java | 4 +- .../apache/fop/layoutmgr/ICLayoutManager.java | 2 +- 34 files changed, 209 insertions(+), 280 deletions(-) create mode 100644 src/java/org/apache/fop/fo/LMVisited.java diff --git a/src/java/org/apache/fop/fo/FONode.java b/src/java/org/apache/fop/fo/FONode.java index c7b125e76..7288b97b3 100644 --- a/src/java/org/apache/fop/fo/FONode.java +++ b/src/java/org/apache/fop/fo/FONode.java @@ -33,9 +33,6 @@ import org.apache.fop.apps.FOUserAgent; import org.apache.fop.util.CharUtilities; import org.apache.fop.fo.extensions.ExtensionElementMapping; import org.apache.fop.fo.extensions.svg.SVGElementMapping; -import org.apache.fop.layoutmgr.AddLMVisitor; - - /** * base class for nodes in the XML tree @@ -197,15 +194,6 @@ public abstract class FONode { return new OneCharIterator(CharUtilities.CODE_EOT); } - /** - * This is a hook for the AddLMVisitor class to be able to access - * this object. - * @param aLMV the AddLMVisitor object that can access this object. - */ - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveFONode(this); - } - /** * Helper function to standardize the names of all namespace URI - local * name pairs in text messages. diff --git a/src/java/org/apache/fop/fo/FOText.java b/src/java/org/apache/fop/fo/FOText.java index b94bf75f1..6c8ba742c 100644 --- a/src/java/org/apache/fop/fo/FOText.java +++ b/src/java/org/apache/fop/fo/FOText.java @@ -19,12 +19,13 @@ package org.apache.fop.fo; // Java +import java.util.List; import java.util.NoSuchElementException; // FOP import org.apache.fop.fo.flow.Block; import org.apache.fop.fo.pagination.Root; -import org.apache.fop.layoutmgr.AddLMVisitor; +import org.apache.fop.layoutmgr.TextLayoutManager; /** * A text node in the formatting object tree. @@ -492,11 +493,11 @@ public class FOText extends FObj { } /** - * This is a hook for the AddLMVisitor class to be able to access - * this object. - * @param aLMV the AddLMVisitor object that can access this object. + * @param list the list to which the layout manager(s) should be added */ - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveFOText(this); + public void addLayoutManager(List list) { + if (endIndex - startIndex > 0) { + list.add(new TextLayoutManager(this)); + } } } diff --git a/src/java/org/apache/fop/fo/FObj.java b/src/java/org/apache/fop/fo/FObj.java index 3d785d399..6d176819e 100644 --- a/src/java/org/apache/fop/fo/FObj.java +++ b/src/java/org/apache/fop/fo/FObj.java @@ -442,15 +442,6 @@ public class FObj extends FONode implements Constants { public void addLayoutManager(List list) { } - /** - * This is a hook for the AddLMVisitor class to be able to access - * this object. - * @param aLMV the AddLMVisitor object that can access this object. - */ - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveFObj(this); - } - /* * Return a string representation of the fo element. * Deactivated in order to see precise ID of each fo element created diff --git a/src/java/org/apache/fop/fo/FObjMixed.java b/src/java/org/apache/fop/fo/FObjMixed.java index 0bfc091d5..0d77a1cc2 100644 --- a/src/java/org/apache/fop/fo/FObjMixed.java +++ b/src/java/org/apache/fop/fo/FObjMixed.java @@ -18,8 +18,10 @@ package org.apache.fop.fo; +import java.util.List; import org.xml.sax.Locator; -import org.apache.fop.layoutmgr.AddLMVisitor; +import org.apache.fop.layoutmgr.LMiter; +import org.apache.fop.layoutmgr.InlineStackingLayoutManager; /** * Base class for representation of mixed content formatting objects @@ -74,12 +76,16 @@ public class FObjMixed extends FObj { } /** - * This is a hook for the AddLMVisitor class to be able to access - * this object. - * @param aLMV the AddLMVisitor object that can access this object. + * @param list the list to which the layout manager(s) should be added */ - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveFObjMixed(this); + public void addLayoutManager(List list) { + if (getChildNodes() != null) { + InlineStackingLayoutManager lm; + lm = new InlineStackingLayoutManager(this); + lm.setLMiter(new LMiter(lm, getChildNodes())); + list.add(lm); + } } + } diff --git a/src/java/org/apache/fop/fo/LMVisited.java b/src/java/org/apache/fop/fo/LMVisited.java new file mode 100644 index 000000000..7faec73d0 --- /dev/null +++ b/src/java/org/apache/fop/fo/LMVisited.java @@ -0,0 +1,26 @@ +/* + * 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/BasicLink.java b/src/java/org/apache/fop/fo/flow/BasicLink.java index 89fbc7e0b..4b24bd6c7 100644 --- a/src/java/org/apache/fop/fo/flow/BasicLink.java +++ b/src/java/org/apache/fop/fo/flow/BasicLink.java @@ -33,13 +33,14 @@ import org.apache.fop.fo.properties.CommonBorderAndPadding; import org.apache.fop.fo.properties.CommonBackground; import org.apache.fop.fo.properties.CommonMarginInline; import org.apache.fop.fo.properties.CommonRelativePosition; +import org.apache.fop.fo.LMVisited; /** * The basic link. * This sets the basic link trait on the inline parent areas * that are created by the fo element. */ -public class BasicLink extends Inline { +public class BasicLink extends Inline implements LMVisited { private String link = null; private boolean external = false; diff --git a/src/java/org/apache/fop/fo/flow/BidiOverride.java b/src/java/org/apache/fop/fo/flow/BidiOverride.java index 9e0e37cfd..10c10ec40 100644 --- a/src/java/org/apache/fop/fo/flow/BidiOverride.java +++ b/src/java/org/apache/fop/fo/flow/BidiOverride.java @@ -18,6 +18,10 @@ package org.apache.fop.fo.flow; +// Java +import java.util.ArrayList; +import java.util.List; + // XML import org.xml.sax.Attributes; import org.xml.sax.Locator; @@ -27,10 +31,13 @@ import org.xml.sax.SAXParseException; import org.apache.fop.fo.FOElementMapping; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObjMixed; -import org.apache.fop.layoutmgr.AddLMVisitor; +import org.apache.fop.layoutmgr.BidiLayoutManager; +import org.apache.fop.layoutmgr.InlineStackingLayoutManager; +import org.apache.fop.layoutmgr.LayoutManager; import org.apache.fop.fo.properties.CommonAural; import org.apache.fop.fo.properties.CommonRelativePosition; + /** * fo:bidi-override element. */ @@ -116,7 +123,24 @@ public class BidiOverride extends FObjMixed { * this object. * @param aLMV the AddLMVisitor object that can access this object. */ - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveBidiOverride(this); + public void addLayoutManager(List list) { + if (false) { + super.addLayoutManager(list); + } else { + ArrayList childList = new ArrayList(); + super.addLayoutManager(list); + for (int count = childList.size() - 1; count >= 0; count--) { + LayoutManager lm = (LayoutManager) childList.get(count); + if (lm.generatesInlineAreas()) { + LayoutManager blm = new BidiLayoutManager((InlineStackingLayoutManager) lm); + blm.setFObj(this); + list.add(blm); + } else { + list.add(lm); + } + } + } } + + } diff --git a/src/java/org/apache/fop/fo/flow/Block.java b/src/java/org/apache/fop/fo/flow/Block.java index 69131a5be..ffe9afc05 100644 --- a/src/java/org/apache/fop/fo/flow/Block.java +++ b/src/java/org/apache/fop/fo/flow/Block.java @@ -18,6 +18,9 @@ package org.apache.fop.fo.flow; +// Java +import java.util.List; + // XML import org.xml.sax.Attributes; import org.xml.sax.SAXException; @@ -30,7 +33,7 @@ import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; import org.apache.fop.fo.FObjMixed; import org.apache.fop.fo.RecursiveCharIterator; -import org.apache.fop.layoutmgr.AddLMVisitor; +import org.apache.fop.layoutmgr.BlockLayoutManager; import org.apache.fop.fo.Constants; import org.apache.fop.fo.properties.CommonAccessibility; import org.apache.fop.fo.properties.CommonAural; @@ -337,15 +340,14 @@ public class Block extends FObjMixed { } /** - * This is a hook for the AddLMVisitor class to be able to access - * this object. - * @param aLMV the AddLMVisitor object that can access this object. + * @param list the list to which the layout manager(s) should be added */ - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveBlock(this); + public void addLayoutManager(List list) { + BlockLayoutManager blm = new BlockLayoutManager(this); + list.add(blm); } - - public String getName() { + + public String getName() { return "fo:block"; } diff --git a/src/java/org/apache/fop/fo/flow/BlockContainer.java b/src/java/org/apache/fop/fo/flow/BlockContainer.java index 29adbbe7e..b0b4481ef 100644 --- a/src/java/org/apache/fop/fo/flow/BlockContainer.java +++ b/src/java/org/apache/fop/fo/flow/BlockContainer.java @@ -18,15 +18,18 @@ package org.apache.fop.fo.flow; +// Java +import java.util.List; + // FOP import org.apache.fop.datatypes.ColorType; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; -import org.apache.fop.layoutmgr.AddLMVisitor; import org.apache.fop.fo.properties.CommonAbsolutePosition; import org.apache.fop.fo.properties.CommonBackground; import org.apache.fop.fo.properties.CommonBorderAndPadding; import org.apache.fop.fo.properties.CommonMarginBlock; +import org.apache.fop.layoutmgr.BlockContainerLayoutManager; import org.xml.sax.Attributes; import org.xml.sax.SAXParseException; @@ -131,12 +134,12 @@ public class BlockContainer extends FObj { } /** - * This is a hook for the AddLMVisitor class to be able to access - * this object. - * @param aLMV the AddLMVisitor object that can access this object. + * @param list the list to which the layout manager(s) should be added */ - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveBlockContainer(this); + public void addLayoutManager(List list) { + BlockContainerLayoutManager blm = new BlockContainerLayoutManager(this); + blm.setOverflow(getProperty(PR_OVERFLOW).getEnum()); + list.add(blm); } public String getName() { diff --git a/src/java/org/apache/fop/fo/flow/Character.java b/src/java/org/apache/fop/fo/flow/Character.java index 5aa8d9a11..381b883cf 100644 --- a/src/java/org/apache/fop/fo/flow/Character.java +++ b/src/java/org/apache/fop/fo/flow/Character.java @@ -36,6 +36,7 @@ import org.apache.fop.fo.properties.CommonHyphenation; import org.apache.fop.fo.properties.CommonMarginInline; import org.apache.fop.fo.properties.CommonRelativePosition; import org.apache.fop.apps.FOPException; +import org.apache.fop.fo.LMVisited; /** * This class represents the flow object 'fo:character'. Its use is defined by @@ -50,7 +51,7 @@ import org.apache.fop.apps.FOPException; * Overrides may be specified in an implementation-specific manner." (6.6.3) * */ -public class Character extends FObj { +public class Character extends FObj implements LMVisited { /** constant indicating that the character is OK */ public static final int OK = 0; diff --git a/src/java/org/apache/fop/fo/flow/ExternalGraphic.java b/src/java/org/apache/fop/fo/flow/ExternalGraphic.java index 3c12b7899..813026b4c 100644 --- a/src/java/org/apache/fop/fo/flow/ExternalGraphic.java +++ b/src/java/org/apache/fop/fo/flow/ExternalGraphic.java @@ -33,13 +33,14 @@ import org.apache.fop.fo.FObj; import org.apache.fop.image.FopImage; import org.apache.fop.image.ImageFactory; import org.xml.sax.Attributes; +import org.apache.fop.fo.LMVisited; /** * External graphic formatting object. * This FO node handles the external graphic. It creates an image * inline area that can be added to the area tree. */ -public class ExternalGraphic extends FObj { +public class ExternalGraphic extends FObj implements LMVisited { private String url; private int breakAfter; private int breakBefore; diff --git a/src/java/org/apache/fop/fo/flow/Footnote.java b/src/java/org/apache/fop/fo/flow/Footnote.java index f234927e9..5c02ac173 100644 --- a/src/java/org/apache/fop/fo/flow/Footnote.java +++ b/src/java/org/apache/fop/fo/flow/Footnote.java @@ -18,6 +18,9 @@ package org.apache.fop.fo.flow; +// Java +import java.util.List; + // XML import org.xml.sax.Attributes; import org.xml.sax.SAXException; @@ -25,7 +28,6 @@ import org.xml.sax.SAXParseException; // FOP import org.apache.fop.fo.FONode; -import org.apache.fop.layoutmgr.AddLMVisitor; import org.apache.fop.fo.FObj; /** @@ -74,15 +76,22 @@ public class Footnote extends FObj { return inlineFO; } - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveFootnote(this); - } - protected void endOfNode() throws SAXParseException { super.endOfNode(); getFOInputHandler().endFootnote(this); } + /** + * @param list the list to which the layout manager(s) should be added + */ + public void addLayoutManager(List list) { + if (getInlineFO() == null) { + getLogger().error("inline required in footnote"); + return; + } + getInlineFO().addLayoutManager(list); + } + public String getName() { return "fo:footnote"; } diff --git a/src/java/org/apache/fop/fo/flow/Inline.java b/src/java/org/apache/fop/fo/flow/Inline.java index 61e654eb1..2be77db77 100644 --- a/src/java/org/apache/fop/fo/flow/Inline.java +++ b/src/java/org/apache/fop/fo/flow/Inline.java @@ -107,10 +107,6 @@ public class Inline extends FObjMixed { return new InlineCharIterator(this, propMgr.getBorderAndPadding()); } - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveInline(this); - } - public String getName() { return "fo:inline"; } diff --git a/src/java/org/apache/fop/fo/flow/InlineContainer.java b/src/java/org/apache/fop/fo/flow/InlineContainer.java index 050507da4..9e0d234da 100644 --- a/src/java/org/apache/fop/fo/flow/InlineContainer.java +++ b/src/java/org/apache/fop/fo/flow/InlineContainer.java @@ -18,14 +18,19 @@ package org.apache.fop.fo.flow; +// Java +import java.util.List; +import java.util.ArrayList; + // XML import org.xml.sax.Attributes; import org.xml.sax.SAXParseException; // FOP +import org.apache.fop.layoutmgr.LayoutManager; +import org.apache.fop.layoutmgr.ICLayoutManager; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; -import org.apache.fop.layoutmgr.AddLMVisitor; import org.apache.fop.fo.properties.CommonBackground; import org.apache.fop.fo.properties.CommonBorderAndPadding; import org.apache.fop.fo.properties.CommonMarginInline; @@ -89,12 +94,13 @@ public class InlineContainer extends FObj { } /** - * This is a hook for the AddLMVisitor class to be able to access - * this object. - * @param aLMV the AddLMVisitor object that can access this object. + * @param list the list to which the layout manager(s) should be added */ - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveInlineContainer(this); + public void addLayoutManager(List list) { + ArrayList childList = new ArrayList(); + super.addLayoutManager(childList); + LayoutManager lm = new ICLayoutManager(this, childList); + list.add(lm); } public String getName() { diff --git a/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java b/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java index afbeff95e..5b977cbf4 100644 --- a/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java +++ b/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java @@ -25,6 +25,7 @@ import org.xml.sax.SAXParseException; // FOP import org.apache.fop.fo.FONode; +import org.apache.fop.fo.LMVisited; import org.apache.fop.fo.FOElementMapping; import org.apache.fop.layoutmgr.AddLMVisitor; import org.apache.fop.fo.FObj; @@ -34,7 +35,7 @@ import org.apache.fop.fo.FObj; * This is an atomic inline object that contains * xml data. */ -public class InstreamForeignObject extends FObj { +public class InstreamForeignObject extends FObj implements LMVisited { boolean hasNonXSLNamespaceElement = false; diff --git a/src/java/org/apache/fop/fo/flow/Leader.java b/src/java/org/apache/fop/fo/flow/Leader.java index 2e6003d4a..522ce8c89 100644 --- a/src/java/org/apache/fop/fo/flow/Leader.java +++ b/src/java/org/apache/fop/fo/flow/Leader.java @@ -31,13 +31,14 @@ import org.apache.fop.fo.properties.CommonMarginInline; import org.apache.fop.fo.properties.CommonRelativePosition; import org.apache.fop.fo.properties.PercentLength; import org.apache.fop.fonts.Font; +import org.apache.fop.fo.LMVisited; /** * Class modelling fo:leader object. See Sec. 6.6.9 of the XSL-FO Standard. * The main property of fo:leader is leader-pattern. * The following patterns are treated: rule, space, dots and use-content. */ -public class Leader extends FObjMixed { +public class Leader extends FObjMixed implements LMVisited { private int ruleStyle; private int ruleThickness; diff --git a/src/java/org/apache/fop/fo/flow/ListBlock.java b/src/java/org/apache/fop/fo/flow/ListBlock.java index d36b3c72a..a426fb187 100644 --- a/src/java/org/apache/fop/fo/flow/ListBlock.java +++ b/src/java/org/apache/fop/fo/flow/ListBlock.java @@ -18,6 +18,9 @@ package org.apache.fop.fo.flow; +// Java +import java.util.List; + // XML import org.xml.sax.Attributes; import org.xml.sax.SAXParseException; @@ -26,7 +29,7 @@ import org.xml.sax.SAXParseException; import org.apache.fop.datatypes.ColorType; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; -import org.apache.fop.layoutmgr.AddLMVisitor; +import org.apache.fop.layoutmgr.list.ListBlockLayoutManager; import org.apache.fop.fo.properties.CommonAccessibility; import org.apache.fop.fo.properties.CommonAural; import org.apache.fop.fo.properties.CommonBackground; @@ -99,19 +102,18 @@ public class ListBlock extends FObj { } /** - * This is a hook for the AddLMVisitor class to be able to access - * this object. - * @param aLMV the AddLMVisitor object that can access this object. + * @param list the list to which the layout manager(s) should be added */ - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveListBlock(this); + public void addLayoutManager(List list) { + ListBlockLayoutManager lm = new ListBlockLayoutManager(this); + list.add(lm); } protected void endOfNode() throws SAXParseException { super.endOfNode(); getFOInputHandler().endList(this); } - + public String getName() { return "fo:list-block"; } diff --git a/src/java/org/apache/fop/fo/flow/ListItem.java b/src/java/org/apache/fop/fo/flow/ListItem.java index 25d753918..cd4c2127b 100644 --- a/src/java/org/apache/fop/fo/flow/ListItem.java +++ b/src/java/org/apache/fop/fo/flow/ListItem.java @@ -33,12 +33,13 @@ import org.apache.fop.fo.properties.CommonBackground; import org.apache.fop.fo.properties.CommonBorderAndPadding; import org.apache.fop.fo.properties.CommonMarginBlock; import org.apache.fop.fo.properties.CommonRelativePosition; +import org.apache.fop.fo.LMVisited; /** * Class modelling the fo:list-item object. See Sec. 6.8.3 of the XSL-FO * Standard. */ -public class ListItem extends FObj { +public class ListItem extends FObj implements LMVisited { private ListItemLabel label = null; private ListItemBody body = null; diff --git a/src/java/org/apache/fop/fo/flow/PageNumber.java b/src/java/org/apache/fop/fo/flow/PageNumber.java index ba8e4327b..bc7f065b6 100644 --- a/src/java/org/apache/fop/fo/flow/PageNumber.java +++ b/src/java/org/apache/fop/fo/flow/PageNumber.java @@ -35,12 +35,14 @@ import org.apache.fop.fo.properties.CommonBorderAndPadding; import org.apache.fop.fo.properties.CommonMarginInline; import org.apache.fop.fo.properties.CommonRelativePosition; import org.apache.fop.fonts.Font; +import org.apache.fop.fo.LMVisited; + /** * Class modelling the fo:page-number object. See Sec. 6.6.10 of the XSL-FO * Standard. */ -public class PageNumber extends FObj { +public class PageNumber extends FObj implements LMVisited { /** FontState for this object */ protected Font fontState; diff --git a/src/java/org/apache/fop/fo/flow/PageNumberCitation.java b/src/java/org/apache/fop/fo/flow/PageNumberCitation.java index e5cd6b0ba..40dc0eed4 100644 --- a/src/java/org/apache/fop/fo/flow/PageNumberCitation.java +++ b/src/java/org/apache/fop/fo/flow/PageNumberCitation.java @@ -34,6 +34,7 @@ import org.apache.fop.fo.properties.CommonBorderAndPadding; import org.apache.fop.fo.properties.CommonMarginInline; import org.apache.fop.fo.properties.CommonRelativePosition; import org.apache.fop.fonts.Font; +import org.apache.fop.fo.LMVisited; /** @@ -43,7 +44,7 @@ import org.apache.fop.fonts.Font; * The page number used is the page that contains the start of the * block referenced with the ref-id attribute. */ -public class PageNumberCitation extends FObj { +public class PageNumberCitation extends FObj implements LMVisited { /** Fontstate for this object **/ protected Font fontState; diff --git a/src/java/org/apache/fop/fo/flow/RetrieveMarker.java b/src/java/org/apache/fop/fo/flow/RetrieveMarker.java index 3ae22e385..b151f6068 100644 --- a/src/java/org/apache/fop/fo/flow/RetrieveMarker.java +++ b/src/java/org/apache/fop/fo/flow/RetrieveMarker.java @@ -27,13 +27,15 @@ import org.xml.sax.SAXParseException; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObjMixed; import org.apache.fop.layoutmgr.AddLMVisitor; +import org.apache.fop.fo.LMVisited; + /** * The retrieve-marker formatting object. * This will create a layout manager that will retrieve * a marker based on the information. */ -public class RetrieveMarker extends FObjMixed { +public class RetrieveMarker extends FObjMixed implements LMVisited { private String retrieveClassName; private int retrievePosition; diff --git a/src/java/org/apache/fop/fo/flow/Table.java b/src/java/org/apache/fop/fo/flow/Table.java index 55b0a7abf..8524e162c 100644 --- a/src/java/org/apache/fop/fo/flow/Table.java +++ b/src/java/org/apache/fop/fo/flow/Table.java @@ -37,11 +37,12 @@ import org.apache.fop.fo.properties.CommonBorderAndPadding; import org.apache.fop.fo.properties.CommonMarginBlock; import org.apache.fop.fo.properties.CommonRelativePosition; import org.apache.fop.fo.properties.LengthRangeProperty; +import org.apache.fop.fo.LMVisited; /** * Class modelling the fo:table object. See Sec. 6.7.3 of the XSL-FO Standard. */ -public class Table extends FObj { +public class Table extends FObj implements LMVisited { private static final int MINCOLWIDTH = 10000; // 10pt /** collection of columns in this table */ diff --git a/src/java/org/apache/fop/fo/flow/TableBody.java b/src/java/org/apache/fop/fo/flow/TableBody.java index 4aa034b11..739a4277e 100644 --- a/src/java/org/apache/fop/fo/flow/TableBody.java +++ b/src/java/org/apache/fop/fo/flow/TableBody.java @@ -34,12 +34,14 @@ import org.apache.fop.fo.properties.CommonAural; import org.apache.fop.fo.properties.CommonBackground; import org.apache.fop.fo.properties.CommonBorderAndPadding; import org.apache.fop.fo.properties.CommonRelativePosition; +import org.apache.fop.fo.LMVisited; + /** * Class modelling the fo:table-body object. See Sec. 6.7.8 of the XSL-FO * Standard. */ -public class TableBody extends FObj { +public class TableBody extends FObj implements LMVisited { private int spaceBefore; private int spaceAfter; diff --git a/src/java/org/apache/fop/fo/flow/TableCell.java b/src/java/org/apache/fop/fo/flow/TableCell.java index 412fdc02a..841eeba55 100644 --- a/src/java/org/apache/fop/fo/flow/TableCell.java +++ b/src/java/org/apache/fop/fo/flow/TableCell.java @@ -18,6 +18,9 @@ package org.apache.fop.fo.flow; +// Java +import java.util.List; + // XML import org.xml.sax.Attributes; import org.xml.sax.SAXException; @@ -27,7 +30,7 @@ import org.xml.sax.SAXParseException; import org.apache.fop.datatypes.ColorType; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; -import org.apache.fop.layoutmgr.AddLMVisitor; +import org.apache.fop.layoutmgr.table.Cell; import org.apache.fop.fo.properties.CommonAccessibility; import org.apache.fop.fo.properties.CommonAural; @@ -339,15 +342,14 @@ public class TableCell extends FObj { } /** - * This is a hook for the AddLMVisitor class to be able to access - * this object. - * @param aLMV the AddLMVisitor object that can access this object. + * @param list the list to which the layout manager(s) should be added */ - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveTableCell(this); + public void addLayoutManager(List list) { + Cell clm = new Cell(this); + list.add(clm); } - - protected void endOfNode() throws SAXParseException { + + protected void endOfNode() throws SAXParseException { getFOInputHandler().endCell(this); } diff --git a/src/java/org/apache/fop/fo/flow/TableFooter.java b/src/java/org/apache/fop/fo/flow/TableFooter.java index f3ea6f43f..411349da1 100644 --- a/src/java/org/apache/fop/fo/flow/TableFooter.java +++ b/src/java/org/apache/fop/fo/flow/TableFooter.java @@ -21,12 +21,13 @@ package org.apache.fop.fo.flow; // FOP import org.apache.fop.fo.FONode; import org.apache.fop.layoutmgr.AddLMVisitor; +import org.apache.fop.fo.LMVisited; /** * Class modelling the fo:table-footer object. See Sec. 6.7.7 of the XSL-FO * Standard. */ -public class TableFooter extends TableBody { +public class TableFooter extends TableBody implements LMVisited { /** * @param parent FONode that is the parent of this object diff --git a/src/java/org/apache/fop/fo/flow/TableHeader.java b/src/java/org/apache/fop/fo/flow/TableHeader.java index a79432890..b9698d3d3 100644 --- a/src/java/org/apache/fop/fo/flow/TableHeader.java +++ b/src/java/org/apache/fop/fo/flow/TableHeader.java @@ -21,12 +21,13 @@ package org.apache.fop.fo.flow; // FOP import org.apache.fop.fo.FONode; import org.apache.fop.layoutmgr.AddLMVisitor; +import org.apache.fop.fo.LMVisited; /** * Class modelling the fo:table-header object. See Sec. 6.7.6 of the XSL-FO * Standard. */ -public class TableHeader extends TableBody { +public class TableHeader extends TableBody implements LMVisited { /** * @param parent FONode that is the parent of this object diff --git a/src/java/org/apache/fop/fo/flow/TableRow.java b/src/java/org/apache/fop/fo/flow/TableRow.java index 54db3cd6a..5259a122e 100644 --- a/src/java/org/apache/fop/fo/flow/TableRow.java +++ b/src/java/org/apache/fop/fo/flow/TableRow.java @@ -18,6 +18,9 @@ package org.apache.fop.fo.flow; +// Java +import java.util.List; + // XML import org.xml.sax.Attributes; import org.xml.sax.SAXParseException; @@ -27,7 +30,7 @@ import org.apache.fop.datatypes.ColorType; import org.apache.fop.datatypes.KeepValue; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; -import org.apache.fop.layoutmgr.AddLMVisitor; +import org.apache.fop.layoutmgr.table.Row; import org.apache.fop.fo.Constants; import org.apache.fop.fo.properties.CommonAccessibility; @@ -135,15 +138,14 @@ public class TableRow extends FObj { } /** - * This is a hook for the AddLMVisitor class to be able to access - * this object. - * @param aLMV the AddLMVisitor object that can access this object. + * @param list the list to which the layout manager(s) should be added */ - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveTableRow(this); + public void addLayoutManager(List list) { + Row rlm = new Row(this); + list.add(rlm); } - protected void endOfNode() throws SAXParseException { + protected void endOfNode() throws SAXParseException { getFOInputHandler().endRow(this); } diff --git a/src/java/org/apache/fop/fo/flow/Wrapper.java b/src/java/org/apache/fop/fo/flow/Wrapper.java index 22cacb2e3..81c48649c 100644 --- a/src/java/org/apache/fop/fo/flow/Wrapper.java +++ b/src/java/org/apache/fop/fo/flow/Wrapper.java @@ -22,6 +22,7 @@ package org.apache.fop.fo.flow; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObjMixed; import org.apache.fop.layoutmgr.AddLMVisitor; +import org.apache.fop.fo.LMVisited; /** * Implementation for fo:wrapper formatting object. @@ -31,7 +32,7 @@ import org.apache.fop.layoutmgr.AddLMVisitor; * Content: (#PCDATA|%inline;|%block;)* * Properties: id */ -public class Wrapper extends FObjMixed { +public class Wrapper extends FObjMixed implements LMVisited { /** * @param parent FONode that is the parent of this object diff --git a/src/java/org/apache/fop/fo/pagination/Flow.java b/src/java/org/apache/fop/fo/pagination/Flow.java index cbfbecb66..ecd6e2fe9 100644 --- a/src/java/org/apache/fop/fo/pagination/Flow.java +++ b/src/java/org/apache/fop/fo/pagination/Flow.java @@ -20,6 +20,7 @@ package org.apache.fop.fo.pagination; // Java import java.util.ArrayList; +import java.util.List; // XML import org.xml.sax.Attributes; @@ -30,7 +31,7 @@ import org.xml.sax.SAXParseException; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; import org.apache.fop.fo.FOElementMapping; -import org.apache.fop.layoutmgr.AddLMVisitor; +import org.apache.fop.layoutmgr.FlowLayoutManager; /** * Class modelling the fo:flow object. See Sec. 6.4.18 in the XSL-FO Standard. @@ -171,14 +172,13 @@ public class Flow extends FObj { } /** - * This is a hook for the AddLMVisitor class to be able to access - * this object. - * @param aLMV the AddLMVisitor object that can access this object. + * @param list the list to which the layout manager(s) should be added */ - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveFlow(this); + public void addLayoutManager(List list) { + FlowLayoutManager lm = new FlowLayoutManager(this); + list.add(lm); } - + public String getName() { return "fo:flow"; } diff --git a/src/java/org/apache/fop/fo/pagination/StaticContent.java b/src/java/org/apache/fop/fo/pagination/StaticContent.java index e1fcbd734..59f24818b 100644 --- a/src/java/org/apache/fop/fo/pagination/StaticContent.java +++ b/src/java/org/apache/fop/fo/pagination/StaticContent.java @@ -26,7 +26,6 @@ import org.xml.sax.SAXParseException; // FOP import org.apache.fop.fo.FOElementMapping; import org.apache.fop.fo.FONode; -import org.apache.fop.layoutmgr.AddLMVisitor; /** * Class modelling the fo:static-content object. See Sec. 6.4.19 of the XSL-FO @@ -82,15 +81,6 @@ public class StaticContent extends Flow { } - /** - * This is a hook for the AddLMVisitor class to be able to access - * this object. - * @param aLMV the AddLMVisitor object that can access this object. - */ - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveStaticContent(this); - } - public String getName() { return "fo:static-content"; } diff --git a/src/java/org/apache/fop/fo/pagination/Title.java b/src/java/org/apache/fop/fo/pagination/Title.java index 3b1f6b960..9365c14a2 100644 --- a/src/java/org/apache/fop/fo/pagination/Title.java +++ b/src/java/org/apache/fop/fo/pagination/Title.java @@ -28,7 +28,6 @@ import org.apache.fop.datatypes.ColorType; import org.apache.fop.datatypes.Length; import org.apache.fop.fo.FObjMixed; import org.apache.fop.fo.FONode; -import org.apache.fop.layoutmgr.AddLMVisitor; import org.apache.fop.fo.properties.CommonAccessibility; import org.apache.fop.fo.properties.CommonAural; import org.apache.fop.fo.properties.CommonBackground; @@ -96,15 +95,6 @@ public class Title extends FObjMixed { } - /** - * This is a hook for the AddLMVisitor class to be able to access - * this object. - * @param aLMV the AddLMVisitor object that can access this object. - */ - public void acceptVisitor(AddLMVisitor aLMV) { - aLMV.serveTitle(this); - } - public String getName() { return "fo:title"; } diff --git a/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java b/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java index fa0aeaf16..ccb45de10 100644 --- a/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java +++ b/src/java/org/apache/fop/layoutmgr/AddLMVisitor.java @@ -41,24 +41,15 @@ import org.apache.fop.area.inline.TextArea; import org.apache.fop.datatypes.Length; import org.apache.fop.fo.Constants; import org.apache.fop.fo.FONode; -import org.apache.fop.fo.FOText; import org.apache.fop.fo.FObj; -import org.apache.fop.fo.FObjMixed; -import org.apache.fop.fo.TextInfo; -import org.apache.fop.fo.ToBeImplementedElement; import org.apache.fop.fo.XMLObj; import org.apache.fop.fo.flow.BasicLink; -import org.apache.fop.fo.flow.BidiOverride; import org.apache.fop.fo.flow.Block; -import org.apache.fop.fo.flow.BlockContainer; import org.apache.fop.fo.flow.Character; import org.apache.fop.fo.flow.ExternalGraphic; -import org.apache.fop.fo.flow.Footnote; import org.apache.fop.fo.flow.Inline; -import org.apache.fop.fo.flow.InlineContainer; import org.apache.fop.fo.flow.InstreamForeignObject; import org.apache.fop.fo.flow.Leader; -import org.apache.fop.fo.flow.ListBlock; import org.apache.fop.fo.flow.ListItem; import org.apache.fop.fo.flow.ListItemBody; import org.apache.fop.fo.flow.ListItemLabel; @@ -74,20 +65,16 @@ import org.apache.fop.fo.flow.TableFooter; import org.apache.fop.fo.flow.TableHeader; import org.apache.fop.fo.flow.TableRow; import org.apache.fop.fo.flow.Wrapper; -import org.apache.fop.fo.pagination.Flow; -import org.apache.fop.fo.pagination.StaticContent; import org.apache.fop.fo.pagination.Title; import org.apache.fop.fo.properties.CommonBackground; import org.apache.fop.fo.properties.CommonBorderAndPadding; import org.apache.fop.layoutmgr.list.Item; -import org.apache.fop.layoutmgr.list.ListBlockLayoutManager; import org.apache.fop.layoutmgr.list.ListItemLayoutManager; import org.apache.fop.layoutmgr.table.Body; -import org.apache.fop.layoutmgr.table.Cell; import org.apache.fop.layoutmgr.table.Column; -import org.apache.fop.layoutmgr.table.Row; import org.apache.fop.layoutmgr.table.TableLayoutManager; import org.apache.fop.traits.MinOptMax; +import org.apache.fop.fo.LMVisited; /** * Visitor pattern for the purpose of adding @@ -115,7 +102,11 @@ public class AddLMVisitor { /* Store the List in a global variable so that it can be accessed by the Visitor methods */ currentLMList = lmList; - fobj.acceptVisitor(this); + if (fobj instanceof LMVisited) { + ((LMVisited) fobj).acceptVisitor(this); + } else { + fobj.addLayoutManager(currentLMList); + } } /** @@ -134,81 +125,6 @@ public class AddLMVisitor { return saveLMList; } - /** - * @param node FONode object to process - */ - public void serveFONode(FONode node) { - } - - /** - * @param node FObj object to process - */ - public void serveFObj(FObj node) { - serveFONode((FONode)node); - } - - public void serveFOText(FOText foText) { - if (foText.endIndex - foText.startIndex > 0) { - currentLMList.add(new TextLayoutManager(foText)); - } - } - - public void serveFObjMixed(FObjMixed node) { - if (node.getChildNodes() != null) { - InlineStackingLayoutManager lm; - lm = new InlineStackingLayoutManager(node); - lm.setLMiter(new LMiter(lm, node.getChildNodes())); - currentLMList.add(lm); - } - } - - public void serveBidiOverride(BidiOverride node) { - if (false) { - serveFObjMixed((FObjMixed)node); - } else { - ArrayList childList = new ArrayList(); - saveLMList = currentLMList; - currentLMList = childList; - serveFObjMixed((FObjMixed)node); - currentLMList = saveLMList; - for (int count = childList.size() - 1; count >= 0; count--) { - LayoutManager lm = (LayoutManager) childList.get(count); - if (lm.generatesInlineAreas()) { - LayoutManager blm = new BidiLayoutManager((InlineStackingLayoutManager) lm); - blm.setFObj(node); - currentLMList.add(blm); - } else { - currentLMList.add(lm); - } - } - } - } - - /** - * @param node Inline object to process - */ - public void serveInline(Inline node) { - serveFObjMixed((FObjMixed)node); - } - - public void serveFootnote(Footnote node) { - if (node.getInlineFO() == null) { - node.getLogger().error("inline required in footnote"); - return; - } - serveInline(node.getInlineFO()); - } - - public void serveInlineContainer(InlineContainer node) { - ArrayList childList = new ArrayList(); - saveLMList = currentLMList; - currentLMList = childList; - serveFObj((FObj)node); - currentLMList = saveLMList; - LayoutManager lm = new ICLayoutManager(node, childList); - currentLMList.add(lm); - } - /** * Add start and end properties for the link */ @@ -243,11 +159,6 @@ public class AddLMVisitor { } } - public void serveBlock(Block node) { - BlockLayoutManager blm = new BlockLayoutManager(node); - currentLMList.add(blm); - } - public void serveLeader(final Leader node) { LeafNodeLayoutManager lm = new LeafNodeLayoutManager(node) { public InlineArea get(LayoutContext context) { @@ -417,17 +328,6 @@ public class AddLMVisitor { return vp; } - public void serveBlockContainer(BlockContainer node) { - BlockContainerLayoutManager blm = new BlockContainerLayoutManager(node); - blm.setOverflow(node.getProperty(Constants.PR_OVERFLOW).getEnum()); - currentLMList.add(blm); - } - - public void serveListBlock(ListBlock node) { - ListBlockLayoutManager blm = new ListBlockLayoutManager(node); - currentLMList.add(blm); - } - public void serveInstreamForeignObject(InstreamForeignObject node) { Viewport areaCurrent = getInstreamForeignObjectInlineArea(node); if (areaCurrent != null) { @@ -438,7 +338,6 @@ public class AddLMVisitor { currentLMList.add(lm); } } - /** * Get the inline area created by this element. * @@ -755,48 +654,6 @@ public class AddLMVisitor { return blm; } - public void serveTableCell(TableCell node) { - Cell clm = new Cell(node); - currentLMList.add(clm); - } - - public void serveTableRow(TableRow node) { - Row rlm = new Row(node); - currentLMList.add(rlm); - } - - public void serveFlow(Flow node) { - FlowLayoutManager lm = new FlowLayoutManager(node); - currentLMList.add(lm); - } - - /** - * @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(); - child.acceptVisitor(this); - } - } - - /** - * @param node StaticContent object to process - */ - public void serveStaticContent(StaticContent node) { - serveFlow((Flow)node); - } - - /** - * @param node Title object to process - */ - public void serveTitle(Title node) { - serveFObjMixed((FObjMixed)node); - } - /** * @param node TableFooter object to process */ @@ -810,4 +667,21 @@ public class AddLMVisitor { public void serveTableHeader(TableHeader node) { serveTableBody((TableBody)node); } + + /** + * @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/BidiLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BidiLayoutManager.java index b20ead1fd..46d9b74d8 100644 --- a/src/java/org/apache/fop/layoutmgr/BidiLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BidiLayoutManager.java @@ -29,11 +29,11 @@ import org.apache.fop.area.inline.InlineArea; * ltr or rtl than its parent writing mode then this * reverses the inline areas (at the character level). */ -class BidiLayoutManager extends LeafNodeLayoutManager { +public class BidiLayoutManager extends LeafNodeLayoutManager { private List children; - BidiLayoutManager(InlineStackingLayoutManager cLM) { + public BidiLayoutManager(InlineStackingLayoutManager cLM) { children = new ArrayList(); /* for (int count = cLM.size() - 1; count >= 0; count--) { diff --git a/src/java/org/apache/fop/layoutmgr/ICLayoutManager.java b/src/java/org/apache/fop/layoutmgr/ICLayoutManager.java index b35346e98..395b40960 100644 --- a/src/java/org/apache/fop/layoutmgr/ICLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/ICLayoutManager.java @@ -34,7 +34,7 @@ public class ICLayoutManager extends LeafNodeLayoutManager { private List childrenLM; - ICLayoutManager(FObj node, List childLM) { + public ICLayoutManager(FObj node, List childLM) { super(node); childrenLM = childLM; } -- 2.39.5