From: Simon Pepping Date: Wed, 22 Dec 2004 08:54:10 +0000 (+0000) Subject: Removed instances of InlineStackingLayoutManager. Created a new FO X-Git-Tag: Root_Temp_KnuthStylePageBreaking~302 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=2ca1efa3177579a4da21ee1097193ab57cc09419;p=xmlgraphics-fop.git Removed instances of InlineStackingLayoutManager. Created a new FO node class, InlineLevel, a subclass of FObjMixed, a base class for several inline-level FObj: Inline, Leader, Title. The InlineLayoutManager constructor requires an FObj of this type. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198205 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/fo/FObjMixed.java b/src/java/org/apache/fop/fo/FObjMixed.java index 9cf9ccd70..9c338f4ca 100644 --- a/src/java/org/apache/fop/fo/FObjMixed.java +++ b/src/java/org/apache/fop/fo/FObjMixed.java @@ -23,17 +23,17 @@ import java.util.List; import org.xml.sax.Locator; import org.apache.fop.apps.FOPException; -import org.apache.fop.layoutmgr.InlineStackingLayoutManager; /** * Base class for representation of mixed content formatting objects - * (i.e., those that can contain both child FO's and text nodes/PCDATA) + * (i.e., those that can contain both child FO's and text nodes/PCDATA). + * It should not be instantiated directly. */ public class FObjMixed extends FObj { /** * @param parent FONode that is the parent of this object */ - public FObjMixed(FONode parent) { + protected FObjMixed(FONode parent) { super(parent); } @@ -66,11 +66,7 @@ public class FObjMixed extends FObj { * @see org.apache.fop.fo.FONode#addLayoutManager(List) */ public void addLayoutManager(List list) { - if (getChildNodes() != null) { - InlineStackingLayoutManager lm; - lm = new InlineStackingLayoutManager(this); - list.add(lm); - } + // no layout manager } } diff --git a/src/java/org/apache/fop/fo/flow/BidiOverride.java b/src/java/org/apache/fop/fo/flow/BidiOverride.java index 5c156d7d4..f7d6219ec 100644 --- a/src/java/org/apache/fop/fo/flow/BidiOverride.java +++ b/src/java/org/apache/fop/fo/flow/BidiOverride.java @@ -36,7 +36,7 @@ import org.apache.fop.fo.properties.CommonFont; import org.apache.fop.fo.properties.CommonRelativePosition; import org.apache.fop.fo.properties.SpaceProperty; import org.apache.fop.layoutmgr.BidiLayoutManager; -import org.apache.fop.layoutmgr.InlineStackingLayoutManager; +import org.apache.fop.layoutmgr.InlineLayoutManager; import org.apache.fop.layoutmgr.LayoutManager; /** @@ -148,7 +148,7 @@ public class BidiOverride extends FObjMixed { LayoutManager lm = (LayoutManager) childList.get(count); if (lm.generatesInlineAreas()) { LayoutManager blm = new BidiLayoutManager(this, - (InlineStackingLayoutManager) lm); + (InlineLayoutManager) lm); list.add(blm); } else { list.add(lm); diff --git a/src/java/org/apache/fop/fo/flow/Inline.java b/src/java/org/apache/fop/fo/flow/Inline.java index 9084d4ae9..e39c2a8b6 100644 --- a/src/java/org/apache/fop/fo/flow/Inline.java +++ b/src/java/org/apache/fop/fo/flow/Inline.java @@ -23,19 +23,12 @@ import java.util.List; import org.xml.sax.Locator; import org.apache.fop.apps.FOPException; -import org.apache.fop.datatypes.ColorType; import org.apache.fop.datatypes.Length; import org.apache.fop.fo.CharIterator; import org.apache.fop.fo.FONode; -import org.apache.fop.fo.FObjMixed; import org.apache.fop.fo.InlineCharIterator; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.ValidationException; -import org.apache.fop.fo.properties.CommonAccessibility; -import org.apache.fop.fo.properties.CommonAural; -import org.apache.fop.fo.properties.CommonBorderPaddingBackground; -import org.apache.fop.fo.properties.CommonFont; -import org.apache.fop.fo.properties.CommonMarginInline; import org.apache.fop.fo.properties.CommonRelativePosition; import org.apache.fop.fo.properties.KeepProperty; import org.apache.fop.fo.properties.LengthRangeProperty; @@ -44,19 +37,14 @@ import org.apache.fop.layoutmgr.InlineLayoutManager; /** * Class modelling the fo:inline formatting object. */ -public class Inline extends FObjMixed { +public class Inline extends InlineLevel { // The value of properties relevant for fo:inline. - private CommonAccessibility commonAccessibility; - private CommonAural commonAural; - private CommonBorderPaddingBackground commonBorderPaddingBackground; - private CommonFont commonFont; - private CommonMarginInline commonMarginInline; + // See also superclass InlineLevel private CommonRelativePosition commonRelativePosition; private Length alignmentAdjust; private int alignmentBaseline; private Length baselineShift; private LengthRangeProperty blockProgressionDimension; - private ColorType color; private int dominantBaseline; private Length height; private String id; @@ -64,10 +52,8 @@ public class Inline extends FObjMixed { private KeepProperty keepTogether; private KeepProperty keepWithNext; private KeepProperty keepWithPrevious; - private Length lineHeight; private int textDecoration; private int verticalAlign; - private int visibility; private Length width; private int wrapOption; // End of property values @@ -87,17 +73,12 @@ public class Inline extends FObjMixed { * @see org.apache.fop.fo.FObj#bind(PropertyList) */ public void bind(PropertyList pList) throws FOPException { - commonAccessibility = pList.getAccessibilityProps(); - commonAural = pList.getAuralProps(); - commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps(); - commonFont = pList.getFontProps(); - commonMarginInline = pList.getMarginInlineProps(); + super.bind(pList); commonRelativePosition = pList.getRelativePositionProps(); alignmentAdjust = pList.get(PR_ALIGNMENT_ADJUST).getLength(); alignmentBaseline = pList.get(PR_ALIGNMENT_BASELINE).getEnum(); baselineShift = pList.get(PR_BASELINE_SHIFT).getLength(); blockProgressionDimension = pList.get(PR_BLOCK_PROGRESSION_DIMENSION).getLengthRange(); - color = pList.get(PR_COLOR).getColorType(); dominantBaseline = pList.get(PR_DOMINANT_BASELINE).getEnum(); height = pList.get(PR_HEIGHT).getLength(); id = pList.get(PR_ID).getString(); @@ -105,10 +86,8 @@ public class Inline extends FObjMixed { keepTogether = pList.get(PR_KEEP_TOGETHER).getKeep(); keepWithNext = pList.get(PR_KEEP_WITH_NEXT).getKeep(); keepWithPrevious = pList.get(PR_KEEP_WITH_PREVIOUS).getKeep(); - lineHeight = pList.get(PR_LINE_HEIGHT).getLength(); textDecoration = pList.get(PR_TEXT_DECORATION).getEnum(); verticalAlign = pList.get(PR_VERTICAL_ALIGN).getEnum(); - visibility = pList.get(PR_VISIBILITY).getEnum(); width = pList.get(PR_WIDTH).getLength(); wrapOption = pList.get(PR_WRAP_OPTION).getEnum(); } @@ -174,34 +153,6 @@ public class Inline extends FObjMixed { } } - /** - * Return the Common Margin Properties-Inline. - */ - public CommonMarginInline getCommonMarginInline() { - return commonMarginInline; - } - - /** - * Return the Common Border, Padding, and Background Properties. - */ - public CommonBorderPaddingBackground getCommonBorderPaddingBackground() { - return commonBorderPaddingBackground; - } - - /** - * Return the Common Font Properties. - */ - public CommonFont getCommonFont() { - return commonFont; - } - - /** - * Return the "color" property. - */ - public ColorType getColor() { - return color; - } - /** * Return the "id" property. */ diff --git a/src/java/org/apache/fop/fo/flow/InlineLevel.java b/src/java/org/apache/fop/fo/flow/InlineLevel.java new file mode 100644 index 000000000..5ce0a611c --- /dev/null +++ b/src/java/org/apache/fop/fo/flow/InlineLevel.java @@ -0,0 +1,112 @@ +/* + * Copyright 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.flow; + +import java.util.List; + +import org.apache.fop.apps.FOPException; +import org.apache.fop.datatypes.ColorType; +import org.apache.fop.datatypes.Length; +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.FObjMixed; +import org.apache.fop.fo.PropertyList; +import org.apache.fop.fo.properties.CommonAccessibility; +import org.apache.fop.fo.properties.CommonAural; +import org.apache.fop.fo.properties.CommonBorderPaddingBackground; +import org.apache.fop.fo.properties.CommonFont; +import org.apache.fop.fo.properties.CommonMarginInline; +import org.apache.fop.layoutmgr.InlineLayoutManager; + +/** + * Class modelling the commonalities of several inline-level + * formatting objects. It should not be instantiated directly. + */ +public class InlineLevel extends FObjMixed { + protected CommonBorderPaddingBackground commonBorderPaddingBackground; + protected CommonAccessibility commonAccessibility; + protected CommonMarginInline commonMarginInline; + protected CommonAural commonAural; + protected CommonFont commonFont; + protected ColorType color; + protected Length lineHeight; + protected int visibility; + // End of property values + + /** + * @param parent FONode that is the parent of this object + */ + protected InlineLevel(FONode parent) { + super(parent); + } + + /** + * @see org.apache.fop.fo.FObj#bind(PropertyList) + */ + public void bind(PropertyList pList) throws FOPException { + commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps(); + commonAccessibility = pList.getAccessibilityProps(); + commonMarginInline = pList.getMarginInlineProps(); + commonAural = pList.getAuralProps(); + commonFont = pList.getFontProps(); + color = pList.get(PR_COLOR).getColorType(); + lineHeight = pList.get(PR_LINE_HEIGHT).getLength(); + visibility = pList.get(PR_VISIBILITY).getEnum(); + } + + /** + * Return the Common Margin Properties-Inline. + */ + public CommonMarginInline getCommonMarginInline() { + return commonMarginInline; + } + + /** + * Return the Common Border, Padding, and Background Properties. + */ + public CommonBorderPaddingBackground getCommonBorderPaddingBackground() { + return commonBorderPaddingBackground; + } + + /** + * Return the Common Font Properties. + */ + public CommonFont getCommonFont() { + return commonFont; + } + + /** + * Return the "color" property. + */ + public ColorType getColor() { + return color; + } + + /** + * @see org.apache.fop.fo.FONode#addLayoutManager(List) + */ + public void addLayoutManager(List list) { + if (getChildNodes() != null) { + InlineLayoutManager lm; + lm = new InlineLayoutManager(this); + list.add(lm); + } + } + +} + diff --git a/src/java/org/apache/fop/fo/flow/Leader.java b/src/java/org/apache/fop/fo/flow/Leader.java index 377a452b2..3e245eec7 100644 --- a/src/java/org/apache/fop/fo/flow/Leader.java +++ b/src/java/org/apache/fop/fo/flow/Leader.java @@ -22,16 +22,9 @@ package org.apache.fop.fo.flow; import java.util.List; import org.apache.fop.apps.FOPException; -import org.apache.fop.datatypes.ColorType; import org.apache.fop.datatypes.Length; import org.apache.fop.fo.FONode; -import org.apache.fop.fo.FObjMixed; import org.apache.fop.fo.PropertyList; -import org.apache.fop.fo.properties.CommonAccessibility; -import org.apache.fop.fo.properties.CommonAural; -import org.apache.fop.fo.properties.CommonBorderPaddingBackground; -import org.apache.fop.fo.properties.CommonFont; -import org.apache.fop.fo.properties.CommonMarginInline; import org.apache.fop.fo.properties.CommonRelativePosition; import org.apache.fop.fo.properties.KeepProperty; import org.apache.fop.fo.properties.LengthRangeProperty; @@ -44,19 +37,14 @@ import org.apache.fop.layoutmgr.LeaderLayoutManager; * The following patterns are treated: rule, space, dots and use-content. * @todo implement validateChildNode() */ -public class Leader extends FObjMixed { +public class Leader extends InlineLevel { // The value of properties relevant for fo:leader. - private CommonAccessibility commonAccessibility; - private CommonAural commonAural; - private CommonBorderPaddingBackground commonBorderPaddingBackground; - private CommonFont commonFont; - private CommonMarginInline commonMarginInline; + // See also superclass InlineLevel private CommonRelativePosition commonRelativePosition; private Length alignmentAdjust; private int alignmentBaseline; private int verticalAlign; private Length baselineShift; - private ColorType color; private int dominantBaseline; private Length textDepth; private Length textAltitude; @@ -70,9 +58,7 @@ public class Leader extends FObjMixed { private int ruleStyle; private Length ruleThickness; // private ToBeImplementedProperty letterSpacing; - private Length lineHeight; // private ToBeImplementedProperty textShadow; - private int visibility; private SpaceProperty wordSpacing; // End of property values @@ -87,17 +73,12 @@ public class Leader extends FObjMixed { * @see org.apache.fop.fo.FObj#bind(PropertyList) */ public void bind(PropertyList pList) throws FOPException { - commonAccessibility = pList.getAccessibilityProps(); - commonAural = pList.getAuralProps(); - commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps(); - commonFont = pList.getFontProps(); - commonMarginInline = pList.getMarginInlineProps(); + super.bind(pList); commonRelativePosition = pList.getRelativePositionProps(); alignmentAdjust = pList.get(PR_ALIGNMENT_ADJUST).getLength(); alignmentBaseline = pList.get(PR_ALIGNMENT_BASELINE).getEnum(); verticalAlign = pList.get(PR_VERTICAL_ALIGN).getEnum(); baselineShift = pList.get(PR_BASELINE_SHIFT).getLength(); - color = pList.get(PR_COLOR).getColorType(); dominantBaseline = pList.get(PR_DOMINANT_BASELINE).getEnum(); textDepth = pList.get(PR_TEXT_DEPTH).getLength(); textAltitude = pList.get(PR_TEXT_ALTITUDE).getLength(); @@ -126,9 +107,7 @@ public class Leader extends FObjMixed { break; } // letterSpacing = pList.get(PR_LETTER_SPACING); - lineHeight = pList.get(PR_LINE_HEIGHT).getLength(); // textShadow = pList.get(PR_TEXT_SHADOW); - visibility = pList.get(PR_VISIBILITY).getEnum(); wordSpacing = pList.get(PR_WORD_SPACING).getSpace(); } @@ -139,26 +118,6 @@ public class Leader extends FObjMixed { checkId(id); } - /** - * Return the Common Margin Properties-Inline. - */ - public CommonMarginInline getCommonMarginInline() { - return commonMarginInline; - } - - /** - * Return the Common Border, Padding, and Background Properties. - */ - public CommonBorderPaddingBackground getCommonBorderPaddingBackground() { - return commonBorderPaddingBackground; - } - - /** - * Return the Common Font Properties. - */ - public CommonFont getCommonFont() { - return commonFont; - } /** * Return the "id" property. diff --git a/src/java/org/apache/fop/fo/pagination/Title.java b/src/java/org/apache/fop/fo/pagination/Title.java index 0eb51e8d3..b64a9beec 100644 --- a/src/java/org/apache/fop/fo/pagination/Title.java +++ b/src/java/org/apache/fop/fo/pagination/Title.java @@ -22,31 +22,18 @@ package org.apache.fop.fo.pagination; import org.xml.sax.Locator; import org.apache.fop.apps.FOPException; -import org.apache.fop.datatypes.ColorType; import org.apache.fop.datatypes.Length; import org.apache.fop.fo.FONode; -import org.apache.fop.fo.FObjMixed; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.ValidationException; -import org.apache.fop.fo.properties.CommonAccessibility; -import org.apache.fop.fo.properties.CommonAural; -import org.apache.fop.fo.properties.CommonBorderPaddingBackground; -import org.apache.fop.fo.properties.CommonFont; -import org.apache.fop.fo.properties.CommonMarginInline; +import org.apache.fop.fo.flow.InlineLevel; /** * Class modelling the fo:title object. */ -public class Title extends FObjMixed { +public class Title extends InlineLevel { // The value of properties relevant for fo:title. - private CommonAccessibility commonAccessibility; - private CommonAural commonAural; - private CommonBorderPaddingBackground commonBorderPaddingBackground; - private CommonFont commonFont; - private CommonMarginInline commonMarginInline; - private ColorType color; - private Length lineHeight; - private int visibility; + // See also superclass InlineLevel // End of property values /** @@ -57,14 +44,7 @@ public class Title extends FObjMixed { } public void bind(PropertyList pList) throws FOPException { - commonAccessibility = pList.getAccessibilityProps(); - commonAural = pList.getAuralProps(); - commonBorderPaddingBackground = pList.getBorderPaddingBackgroundProps(); - commonFont = pList.getFontProps(); - commonMarginInline = pList.getMarginInlineProps(); - color = pList.get(PR_COLOR).getColorType(); - lineHeight = pList.get(PR_LINE_HEIGHT).getLength(); - visibility = pList.get(PR_VISIBILITY).getEnum(); + super.bind(pList); } /** diff --git a/src/java/org/apache/fop/layoutmgr/BidiLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BidiLayoutManager.java index 39d9a2e9a..c20237ac2 100644 --- a/src/java/org/apache/fop/layoutmgr/BidiLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BidiLayoutManager.java @@ -34,7 +34,7 @@ public class BidiLayoutManager extends LeafNodeLayoutManager { private List children; - public BidiLayoutManager(BidiOverride node, InlineStackingLayoutManager cLM) { + public BidiLayoutManager(BidiOverride node, InlineLayoutManager cLM) { super(node); children = new ArrayList(); setFObj(node); diff --git a/src/java/org/apache/fop/layoutmgr/InlineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/InlineLayoutManager.java index a3b8d403d..c20270670 100755 --- a/src/java/org/apache/fop/layoutmgr/InlineLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/InlineLayoutManager.java @@ -23,8 +23,7 @@ import java.util.ListIterator; import java.util.LinkedList; import org.apache.fop.fo.FObj; -import org.apache.fop.fo.flow.Inline; -import org.apache.fop.fo.flow.Leader; +import org.apache.fop.fo.flow.InlineLevel; import org.apache.fop.fo.properties.CommonBorderPaddingBackground; import org.apache.fop.fo.properties.CommonMarginInline; import org.apache.fop.fo.properties.SpaceProperty; @@ -37,7 +36,7 @@ import org.apache.fop.traits.SpaceVal; */ public class InlineLayoutManager extends InlineStackingLayoutManager implements InlineLevelLayoutManager { - private FObj fobj; + private InlineLevel fobj; private CommonMarginInline inlineProps = null; private CommonBorderPaddingBackground borderProps = null; @@ -49,19 +48,8 @@ public class InlineLayoutManager extends InlineStackingLayoutManager * * @param node the formatting object that creates the area */ - public InlineLayoutManager(Inline node) { - super(node); - fobj = node; - } - - /** - * Create an inline layout manager. - * This is used for fo's that create areas that - * contain inline areas. - * - * @param node the formatting object that creates the area - */ - public InlineLayoutManager(Leader node) { + // The node should be FObjMixed + public InlineLayoutManager(InlineLevel node) { super(node); fobj = node; } @@ -70,14 +58,9 @@ public class InlineLayoutManager extends InlineStackingLayoutManager * @see org.apache.fop.layoutmgr.AbstractLayoutManager#initProperties() */ protected void initProperties() { - // fobj can be either an Inline or a Leader - if (fobj instanceof Inline) { - inlineProps = ((Inline) fobj).getCommonMarginInline(); - borderProps = ((Inline) fobj).getCommonBorderPaddingBackground(); - } else { - inlineProps = ((Leader) fobj).getCommonMarginInline(); - borderProps = ((Leader) fobj).getCommonBorderPaddingBackground(); - } + inlineProps = fobj.getCommonMarginInline(); + borderProps = fobj.getCommonBorderPaddingBackground(); + int iPad = borderProps.getPadding(CommonBorderPaddingBackground.BEFORE, false); iPad += borderProps.getBorderWidth(CommonBorderPaddingBackground.BEFORE, false); diff --git a/src/java/org/apache/fop/layoutmgr/InlineStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/InlineStackingLayoutManager.java index 594e33cc2..b3782629a 100644 --- a/src/java/org/apache/fop/layoutmgr/InlineStackingLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/InlineStackingLayoutManager.java @@ -33,8 +33,9 @@ import org.apache.fop.area.inline.Space; import org.apache.fop.traits.MinOptMax; /** - * LayoutManager for objects which stack children in the inline direction, - * such as Inline or Line + * Class modelling the commonalities of layoutmanagers for objects + * which stack children in the inline direction, such as Inline or + * Line. It should not be instantiated directly. */ public class InlineStackingLayoutManager extends AbstractLayoutManager { @@ -85,7 +86,7 @@ public class InlineStackingLayoutManager extends AbstractLayoutManager { * * @param node the formatting object that creates the area */ - public InlineStackingLayoutManager(FObj node) { + protected InlineStackingLayoutManager(FObj node) { super(node); extraBPD = new MinOptMax(0); } diff --git a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java index 4af629500..74ceb0745 100644 --- a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java @@ -177,8 +177,8 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager { // use special layout manager to add the inline areas // to the Title. - InlineStackingLayoutManager lm; - lm = new InlineStackingLayoutManager(foTitle); + InlineLayoutManager lm; + lm = new InlineLayoutManager(foTitle); clm.addChildLM(lm); clm.fillArea(lm);