diff options
Diffstat (limited to 'src/java/org/apache')
79 files changed, 2517 insertions, 837 deletions
diff --git a/src/java/org/apache/fop/area/Page.java b/src/java/org/apache/fop/area/Page.java index 2f327b55a..e36e3338f 100644 --- a/src/java/org/apache/fop/area/Page.java +++ b/src/java/org/apache/fop/area/Page.java @@ -25,7 +25,9 @@ import java.util.HashMap; import java.util.Iterator; import org.apache.fop.datatypes.FODimension; -import org.apache.fop.datatypes.PercentBase; +import org.apache.fop.datatypes.LengthBase; +import org.apache.fop.datatypes.PercentBaseContext; +import org.apache.fop.datatypes.SimplePercentBaseContext; import org.apache.fop.fo.Constants; import org.apache.fop.fo.pagination.Region; import org.apache.fop.fo.pagination.RegionBody; @@ -70,22 +72,35 @@ public class Page implements Serializable, Cloneable { * page-reference-area */ public Page(SimplePageMaster spm) { - int pageWidth = spm.getPageWidth().getValue(); - int pageHeight = spm.getPageHeight().getValue(); + // Width and Height of the page view port + FODimension pageViewPortDims = new FODimension(spm.getPageWidth().getValue() + , spm.getPageHeight().getValue()); // Get absolute margin properties (top, left, bottom, right) CommonMarginBlock mProps = spm.getCommonMarginBlock(); - + /* * Create the page reference area rectangle (0,0 is at top left * of the "page media" and y increases * when moving towards the bottom of the page. * The media rectangle itself is (0,0,pageWidth,pageHeight). */ + /* Special rules apply to resolving margins in the page context. + * Contrary to normal margins in this case top and bottom margin + * are resolved relative to the height. In the property subsystem + * all margin properties are configured to using BLOCK_WIDTH. + * That's why we 'cheat' here and setup a context for the height but + * use the LengthBase.BLOCK_WIDTH. + */ + SimplePercentBaseContext pageWidthContext + = new SimplePercentBaseContext(null, LengthBase.CONTAINING_BLOCK_WIDTH, pageViewPortDims.ipd); + SimplePercentBaseContext pageHeightContext + = new SimplePercentBaseContext(null, LengthBase.CONTAINING_BLOCK_WIDTH, pageViewPortDims.bpd); + Rectangle pageRefRect = - new Rectangle(mProps.marginLeft.getValue(), mProps.marginTop.getValue(), - pageWidth - mProps.marginLeft.getValue() - mProps.marginRight.getValue(), - pageHeight - mProps.marginTop.getValue() - mProps.marginBottom.getValue()); + new Rectangle(mProps.marginLeft.getValue(pageWidthContext), mProps.marginTop.getValue(pageHeightContext), + pageViewPortDims.ipd - mProps.marginLeft.getValue(pageWidthContext) - mProps.marginRight.getValue(pageWidthContext), + pageViewPortDims.bpd - mProps.marginTop.getValue(pageHeightContext) - mProps.marginBottom.getValue(pageHeightContext)); // Set up the CTM on the page reference area based on writing-mode // and reference-orientation @@ -98,9 +113,7 @@ public class Page implements Serializable, Cloneable { for (Iterator regenum = spm.getRegions().values().iterator(); regenum.hasNext();) { Region r = (Region)regenum.next(); - RegionViewport rvp = makeRegionViewport(r, reldims, pageCTM); - r.setLayoutDimension(PercentBase.BLOCK_IPD, rvp.getIPD()); - r.setLayoutDimension(PercentBase.BLOCK_BPD, rvp.getBPD()); + RegionViewport rvp = makeRegionViewport(r, reldims, pageCTM, pageViewPortDims); if (r.getNameId() == Constants.FO_REGION_BODY) { rr = new BodyRegion((RegionBody) r, rvp); } else { @@ -125,15 +138,16 @@ public class Page implements Serializable, Cloneable { * @param pageCTM page coordinate transformation matrix * @return the new region viewport */ - private RegionViewport makeRegionViewport(Region r, FODimension reldims, CTM pageCTM) { - Rectangle2D relRegionRect = r.getViewportRectangle(reldims); + private RegionViewport makeRegionViewport(Region r, FODimension reldims, CTM pageCTM, + FODimension pageViewPortDims) { + Rectangle2D relRegionRect = r.getViewportRectangle(reldims, pageViewPortDims); Rectangle2D absRegionRect = pageCTM.transform(relRegionRect); // Get the region viewport rectangle in absolute coords by // transforming it using the page CTM RegionViewport rv = new RegionViewport(absRegionRect); rv.setBPD((int)relRegionRect.getHeight()); rv.setIPD((int)relRegionRect.getWidth()); - TraitSetter.addBackground(rv, r.getCommonBorderPaddingBackground()); + TraitSetter.addBackground(rv, r.getCommonBorderPaddingBackground(), null); rv.setClip(r.getOverflow() == Constants.EN_HIDDEN || r.getOverflow() == Constants.EN_ERROR_IF_OVERFLOW); return rv; @@ -263,5 +277,6 @@ public class Page implements Serializable, Cloneable { public HashMap getUnresolvedReferences() { return unresolved; } + } diff --git a/src/java/org/apache/fop/datatypes/Length.java b/src/java/org/apache/fop/datatypes/Length.java index d64b2172d..13f7cf5da 100644 --- a/src/java/org/apache/fop/datatypes/Length.java +++ b/src/java/org/apache/fop/datatypes/Length.java @@ -27,4 +27,12 @@ public interface Length extends Numeric { * @return the length in millipoints */ public int getValue(); + + /** + * Returns the length in 1/1000ths of a point (millipoints) + * @param context The context for the length calculation (for percentage based lengths) + * @return the length in millipoints + */ + public int getValue(PercentBaseContext context); + } diff --git a/src/java/org/apache/fop/datatypes/LengthBase.java b/src/java/org/apache/fop/datatypes/LengthBase.java index 21e15a86f..eceaf6139 100644 --- a/src/java/org/apache/fop/datatypes/LengthBase.java +++ b/src/java/org/apache/fop/datatypes/LengthBase.java @@ -36,67 +36,59 @@ public class LengthBase implements PercentBase { /** constant for an inh font-size percent-based length */ public static final int INH_FONTSIZE = 2; /** constant for a containing box percent-based length */ - public static final int CONTAINING_BOX = 3; + public static final int PARENT_AREA_WIDTH = 3; /** constant for a containing refarea percent-based length */ - public static final int CONTAINING_REFAREA = 4; + public static final int CONTAINING_REFAREA_WIDTH = 4; /** constant for a containing block percent-based length */ - public static final int BLOCK_WIDTH = 5; + public static final int CONTAINING_BLOCK_WIDTH = 5; /** constant for a containing block percent-based length */ - public static final int BLOCK_HEIGHT = 6; + public static final int CONTAINING_BLOCK_HEIGHT = 6; /** constant for a image intrinsic percent-based length */ public static final int IMAGE_INTRINSIC_WIDTH = 7; /** constant for a image intrinsic percent-based length */ public static final int IMAGE_INTRINSIC_HEIGHT = 8; + /** constant for a image background position horizontal percent-based length */ + public static final int IMAGE_BACKGROUND_POSITION_HORIZONTAL = 9; + /** constant for a image background position vertical percent-based length */ + public static final int IMAGE_BACKGROUND_POSITION_VERTICAL = 10; /** array of valid percent-based length types */ public static final int[] PERCENT_BASED_LENGTH_TYPES - = {CUSTOM_BASE, FONTSIZE, INH_FONTSIZE, CONTAINING_BOX, - CONTAINING_REFAREA, - IMAGE_INTRINSIC_WIDTH, IMAGE_INTRINSIC_HEIGHT}; + = {CUSTOM_BASE, FONTSIZE, INH_FONTSIZE, PARENT_AREA_WIDTH, + CONTAINING_REFAREA_WIDTH, + IMAGE_INTRINSIC_WIDTH, IMAGE_INTRINSIC_HEIGHT, + IMAGE_BACKGROUND_POSITION_HORIZONTAL, IMAGE_BACKGROUND_POSITION_VERTICAL + }; /** - * FO parent of the FO for which this property is to be calculated. + * The FO for which this property is to be calculated. */ - protected /* final */ FObj parentFO; - - /** - * PropertyList for the FO where this property is calculated. - */ - private /* final */ PropertyList propertyList; + protected /* final */ FObj fobj; /** * One of the defined types of LengthBase */ private /* final */ int iBaseType; + private Length fontSize; + /** * Constructor * @param parentFO parent FO for this * @param plist property list for this * @param iBaseType a member of {@link #PERCENT_BASED_LENGTH_TYPES} */ - public LengthBase(FObj parentFO, PropertyList plist, int iBaseType) { - this.parentFO = parentFO; - this.propertyList = plist; + public LengthBase(FObj parentFO, PropertyList plist, int iBaseType) throws PropertyException { + this.fobj = plist.getFObj(); this.iBaseType = iBaseType; - } - - /** - * Accessor for parentFO object from subclasses which define - * custom kinds of LengthBase calculations. - * @return this object's parent FO - */ - protected FObj getParentFO() { - return parentFO; - } - - /** - * Accessor for propertyList object from subclasses which define - * custom kinds of LengthBase calculations. - * @return this object's PropertyList - */ - protected PropertyList getPropertyList() { - return propertyList; + switch (iBaseType) { + case FONTSIZE: + this.fontSize = plist.get(Constants.PR_FONT_SIZE).getLength(); + break; + case INH_FONTSIZE: + this.fontSize = plist.getInherited(Constants.PR_FONT_SIZE).getLength(); + break; + } } /** @@ -114,42 +106,17 @@ public class LengthBase implements PercentBase { } /** @see org.apache.fop.datatypes.PercentBase#getBaseLength() */ - public int getBaseLength() throws PropertyException { - //TODO Don't use propertyList here - //See http://nagoya.apache.org/eyebrowse/ReadMsg?listName=fop-dev@xml.apache.org&msgNo=10342 - switch (iBaseType) { - case FONTSIZE: - return propertyList.get(Constants.PR_FONT_SIZE).getLength().getValue(); - case INH_FONTSIZE: - return propertyList.getInherited(Constants.PR_FONT_SIZE).getLength().getValue(); - case BLOCK_WIDTH: - return parentFO.getLayoutDimension(PercentBase.BLOCK_IPD).intValue(); - case BLOCK_HEIGHT: - return parentFO.getLayoutDimension(PercentBase.BLOCK_BPD).intValue(); - case CONTAINING_REFAREA: // example: start-indent, end-indent - FObj fo; - fo = parentFO; - while (fo != null && !fo.generatesReferenceAreas()) { - fo = fo.findNearestAncestorFObj(); - } - if (fo != null && fo instanceof FObj) { - return fo.getLayoutDimension(PercentBase.BLOCK_IPD).intValue(); - } else { - return 0; + public int getBaseLength(PercentBaseContext context) throws PropertyException { + int baseLength = 0; + if (context != null) { + if (iBaseType == FONTSIZE || iBaseType == INH_FONTSIZE) { + return fontSize.getValue(context); } - case IMAGE_INTRINSIC_WIDTH: - return propertyList.getFObj() - .getLayoutDimension(PercentBase.IMAGE_INTRINSIC_WIDTH).intValue(); - case IMAGE_INTRINSIC_HEIGHT: - return propertyList.getFObj() - .getLayoutDimension(PercentBase.IMAGE_INTRINSIC_HEIGHT).intValue(); - case CUSTOM_BASE: - //log.debug("!!! LengthBase.getBaseLength() called on CUSTOM_BASE type !!!"); - return 0; - default: - parentFO.getLogger().error("Unknown base type for LengthBase."); - return 0; + baseLength = context.getBaseLength(iBaseType, fobj); + } else { + fobj.getLogger().error("getBaseLength called without context"); } + return baseLength; } } diff --git a/src/java/org/apache/fop/datatypes/Numeric.java b/src/java/org/apache/fop/datatypes/Numeric.java index 85a41e862..c8b9af75c 100644 --- a/src/java/org/apache/fop/datatypes/Numeric.java +++ b/src/java/org/apache/fop/datatypes/Numeric.java @@ -41,6 +41,14 @@ public interface Numeric { double getNumericValue() throws PropertyException; /** + * Return the value of this Numeric + * @param context The context for the length calculation (for percentage based lengths) + * @return the computed value. + * @throws PropertyException + */ + double getNumericValue(PercentBaseContext context) throws PropertyException; + + /** * Return the dimension of this numeric. Plain numbers has a dimension of * 0 and length has a dimension of 1. Other dimension can occur as a result * of multiplications and divisions. @@ -62,6 +70,13 @@ public interface Numeric { public int getValue(); /** + * Returns the value of this numeric as an int. + * @param conext The context for the length calculation (for percentage based lengths) + * @return the value as an integer. + */ + public int getValue(PercentBaseContext context); + + /** * Return the resolved value. This method will becalled during evaluation * of the expression tree and relative numerics can then return a * resolved absolute Numeric. Absolute numerics can just return themself. diff --git a/src/java/org/apache/fop/datatypes/PercentBase.java b/src/java/org/apache/fop/datatypes/PercentBase.java index 7011c774e..a166725b1 100644 --- a/src/java/org/apache/fop/datatypes/PercentBase.java +++ b/src/java/org/apache/fop/datatypes/PercentBase.java @@ -30,18 +30,6 @@ public interface PercentBase { /** table units */ LayoutDimension TABLE_UNITS = new LayoutDimension("table-units"); - /** Block IPD */ - LayoutDimension BLOCK_IPD = new LayoutDimension("block-ipd"); - /** Block BPD */ - LayoutDimension BLOCK_BPD = new LayoutDimension("block-bpd"); - /** Reference Area IPD */ - LayoutDimension REFERENCE_AREA_IPD = new LayoutDimension("reference-area-ipd"); - /** Reference Area BPD */ - LayoutDimension REFERENCE_AREA_BPD = new LayoutDimension("reference-area-bpd"); - /** Intrinsic width of an image or foreign-object */ - LayoutDimension IMAGE_INTRINSIC_WIDTH = new LayoutDimension("image-intrinsic-width"); - /** Intrinsic height of an image or foreign-object */ - LayoutDimension IMAGE_INTRINSIC_HEIGHT = new LayoutDimension("image-intrinsic-heigth"); /** * Determines whether a numeric property is created or one with a percentage @@ -53,13 +41,14 @@ public interface PercentBase { double getBaseValue(); /** + * @param context The context for percentage evaluation * @return the integer size in millipoints of the object (this will be used * as the base to which a percentage will be applied to compute the length * of the referencing item) * @throws PropertyException if a problem occurs during evaluation of this * value. */ - int getBaseLength() throws PropertyException; + int getBaseLength(PercentBaseContext context) throws PropertyException; /** Enum class for dimension types. */ public class LayoutDimension { diff --git a/src/java/org/apache/fop/datatypes/PercentBaseContext.java b/src/java/org/apache/fop/datatypes/PercentBaseContext.java new file mode 100644 index 000000000..6ba943ea3 --- /dev/null +++ b/src/java/org/apache/fop/datatypes/PercentBaseContext.java @@ -0,0 +1,40 @@ +/* + * Copyright 2005 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.datatypes; + +import org.apache.fop.fo.FObj; + +/** + * This interface is used by the layout managers to provide relevant information + * back to the property percentage resolution logic, that is + * the percentages based property getValue() functions expect an object implementing + * this interface as an argument. + */ +public interface PercentBaseContext { + + /** + * Returns the base length for the given length base. + * Length base should be one of the constants defined in {@link LengthBase}. + * @param lengthBase Indicates which type of the base length value is to be returned + * @param fobj The FO object against which the percentage should be evaluated + * @return The base length value of the given kind + */ + public int getBaseLength(int lengthBase, FObj fobj); + +} diff --git a/src/java/org/apache/fop/datatypes/SimplePercentBaseContext.java b/src/java/org/apache/fop/datatypes/SimplePercentBaseContext.java new file mode 100644 index 000000000..acb4de6a2 --- /dev/null +++ b/src/java/org/apache/fop/datatypes/SimplePercentBaseContext.java @@ -0,0 +1,51 @@ +/* + * SimplePercentBaseContext.java + * + * Created on 29 August 2005, 17:02 + * + * To change this template, choose Tools | Options and locate the template under + * the Source Creation and Management node. Right-click the template and choose + * Open. You can then make changes to the template in the Source Editor. + */ + +package org.apache.fop.datatypes; + +import org.apache.fop.fo.FObj; + +/** + * Class to implement a simple lookup context for a single percent base value. + */ +public class SimplePercentBaseContext implements PercentBaseContext { + + private PercentBaseContext parentContext; + private int lengthBase; + private int lengthBaseValue; + + /** + * @param parentContext the context to be used for all percentages other than lengthBase + * @param lengthBase the particular percentage length base for which this context provides a value + * @param lengthBaseValue the value to be returned for requests to the given lengthBase + */ + public SimplePercentBaseContext(PercentBaseContext parentContext, + int lengthBase, + int lengthBaseValue) { + this.parentContext = parentContext; + this.lengthBase = lengthBase; + this.lengthBaseValue = lengthBaseValue; + } + + /** + * Returns the value for the given lengthBase. + * @see org.apache.fop.datatypes.PercentBaseContext#getBaseLength(int, fobj) + */ + public int getBaseLength(int lengthBase, FObj fobj) { + // if its for us return our value otherwise delegate to parent context + if (lengthBase == this.lengthBase) { + return lengthBaseValue; + } else if (parentContext != null) { + return parentContext.getBaseLength(lengthBase, fobj); + } + return -1; + } + +} diff --git a/src/java/org/apache/fop/fo/Constants.java b/src/java/org/apache/fop/fo/Constants.java index 833105498..a7674100f 100644 --- a/src/java/org/apache/fop/fo/Constants.java +++ b/src/java/org/apache/fop/fo/Constants.java @@ -16,9 +16,18 @@ /* $Id$ */ - package org.apache.fop.fo; +/** + * Definition of constants used throughout FOP. + * There are sets of constants describing: + * <ul> + * <li>Input and output formats</li> + * <li>Formatting objects</li> + * <li>Formatting properties</li> + * <li>Enumerated values used in formatting properties</li> + * </ul> + */ public interface Constants { /* These constants are used by apps.CommandLineOptions and @@ -27,6 +36,7 @@ public interface Constants { /** render constants for bounds checking */ int RENDER_MIN_CONST = 1; + /** render constants for bounds checking */ int RENDER_MAX_CONST = 12; /** input / output not set */ int NOT_SET = 0; @@ -60,505 +70,1006 @@ public interface Constants { int RENDER_PNG = 12; // element constants - int FO_UNKNOWN_NODE = 0; // FObj base class + /** FObj base class */ + int FO_UNKNOWN_NODE = 0; + /** FO element constant */ int FO_BASIC_LINK = 1; + /** FO element constant */ int FO_BIDI_OVERRIDE = 2; + /** FO element constant */ int FO_BLOCK = 3; + /** FO element constant */ int FO_BLOCK_CONTAINER = 4; + /** FO element constant */ int FO_CHARACTER = 5; + /** FO element constant */ int FO_COLOR_PROFILE = 6; + /** FO element constant */ int FO_CONDITIONAL_PAGE_MASTER_REFERENCE = 7; + /** FO element constant */ int FO_DECLARATIONS = 8; + /** FO element constant */ int FO_EXTERNAL_GRAPHIC = 9; + /** FO element constant */ int FO_FLOAT = 10; + /** FO element constant */ int FO_FLOW = 11; + /** FO element constant */ int FO_FOOTNOTE = 12; + /** FO element constant */ int FO_FOOTNOTE_BODY = 13; + /** FO element constant */ int FO_INITIAL_PROPERTY_SET = 14; + /** FO element constant */ int FO_INLINE = 15; + /** FO element constant */ int FO_INLINE_CONTAINER = 16; + /** FO element constant */ int FO_INSTREAM_FOREIGN_OBJECT = 17; + /** FO element constant */ int FO_LAYOUT_MASTER_SET = 18; + /** FO element constant */ int FO_LEADER = 19; + /** FO element constant */ int FO_LIST_BLOCK = 20; + /** FO element constant */ int FO_LIST_ITEM = 21; + /** FO element constant */ int FO_LIST_ITEM_BODY = 22; + /** FO element constant */ int FO_LIST_ITEM_LABEL = 23; + /** FO element constant */ int FO_MARKER = 24; + /** FO element constant */ int FO_MULTI_CASE = 25; + /** FO element constant */ int FO_MULTI_PROPERTIES = 26; + /** FO element constant */ int FO_MULTI_PROPERTY_SET = 27; + /** FO element constant */ int FO_MULTI_SWITCH = 28; + /** FO element constant */ int FO_MULTI_TOGGLE = 29; + /** FO element constant */ int FO_PAGE_NUMBER = 30; + /** FO element constant */ int FO_PAGE_NUMBER_CITATION = 31; + /** FO element constant */ int FO_PAGE_SEQUENCE = 32; + /** FO element constant */ int FO_PAGE_SEQUENCE_MASTER = 33; + /** FO element constant */ int FO_REGION_AFTER = 34; + /** FO element constant */ int FO_REGION_BEFORE = 35; + /** FO element constant */ int FO_REGION_BODY = 36; + /** FO element constant */ int FO_REGION_END = 37; + /** FO element constant */ int FO_REGION_START = 38; + /** FO element constant */ int FO_REPEATABLE_PAGE_MASTER_ALTERNATIVES = 39; + /** FO element constant */ int FO_REPEATABLE_PAGE_MASTER_REFERENCE = 40; + /** FO element constant */ int FO_RETRIEVE_MARKER = 41; + /** FO element constant */ int FO_ROOT = 42; + /** FO element constant */ int FO_SIMPLE_PAGE_MASTER = 43; + /** FO element constant */ int FO_SINGLE_PAGE_MASTER_REFERENCE = 44; + /** FO element constant */ int FO_STATIC_CONTENT = 45; + /** FO element constant */ int FO_TABLE = 46; + /** FO element constant */ int FO_TABLE_AND_CAPTION = 47; + /** FO element constant */ int FO_TABLE_BODY = 48; + /** FO element constant */ int FO_TABLE_CAPTION = 49; + /** FO element constant */ int FO_TABLE_CELL = 50; + /** FO element constant */ int FO_TABLE_COLUMN = 51; + /** FO element constant */ int FO_TABLE_FOOTER = 52; + /** FO element constant */ int FO_TABLE_HEADER = 53; + /** FO element constant */ int FO_TABLE_ROW = 54; + /** FO element constant */ int FO_TITLE = 55; + /** FO element constant */ int FO_WRAPPER = 56; - int FO_BOOKMARK_TREE = 57; // XSL 1.1 - int FO_BOOKMARK = 58; // XSL 1.1 - int FO_BOOKMARK_TITLE = 59; // XSL 1.1 - int FO_PAGE_SEQUENCE_WRAPPER = 60; // XSL 1.1 + /** FO element constant - XSL 1.1 */ + int FO_BOOKMARK_TREE = 57; + /** FO element constant - XSL 1.1 */ + int FO_BOOKMARK = 58; + /** FO element constant - XSL 1.1 */ + int FO_BOOKMARK_TITLE = 59; + /** FO element constant - XSL 1.1 */ + int FO_PAGE_SEQUENCE_WRAPPER = 60; + /** Number of FO element constants defined */ int FRM_OBJ_COUNT = 60; // Masks + /** + * For compound properties the property constant value is shifted by this amount. + * The low order bits hold the constant for the component property. + */ int COMPOUND_SHIFT = 9; - int PROPERTY_MASK = (1 << COMPOUND_SHIFT)-1; + /** + * Mask that when applied to a compound property returns the constant of + * the component property. + */ + int PROPERTY_MASK = (1 << COMPOUND_SHIFT) - 1; + /** + * Mask that when applied to a compound property returns the constant of + * the compound property. + */ int COMPOUND_MASK = ~PROPERTY_MASK; + /** Number of compund properties defined */ int COMPOUND_COUNT = 11; // property constants + /** Property constant */ int PR_ABSOLUTE_POSITION = 1; + /** Property constant */ int PR_ACTIVE_STATE = 2; + /** Property constant */ int PR_ALIGNMENT_ADJUST = 3; + /** Property constant */ int PR_ALIGNMENT_BASELINE = 4; + /** Property constant */ int PR_AUTO_RESTORE = 5; + /** Property constant */ int PR_AZIMUTH = 6; + /** Property constant */ int PR_BACKGROUND = 7; + /** Property constant */ int PR_BACKGROUND_ATTACHMENT = 8; + /** Property constant */ int PR_BACKGROUND_COLOR = 9; + /** Property constant */ int PR_BACKGROUND_IMAGE = 10; + /** Property constant */ int PR_BACKGROUND_POSITION = 11; + /** Property constant */ int PR_BACKGROUND_POSITION_HORIZONTAL = 12; + /** Property constant */ int PR_BACKGROUND_POSITION_VERTICAL = 13; + /** Property constant */ int PR_BACKGROUND_REPEAT = 14; + /** Property constant */ int PR_BASELINE_SHIFT = 15; + /** Property constant */ int PR_BLANK_OR_NOT_BLANK = 16; + /** Property constant */ int PR_BLOCK_PROGRESSION_DIMENSION = 17; + /** Property constant */ int PR_BORDER = 18; + /** Property constant */ int PR_BORDER_AFTER_COLOR = 19; + /** Property constant */ int PR_BORDER_AFTER_PRECEDENCE = 20; + /** Property constant */ int PR_BORDER_AFTER_STYLE = 21; + /** Property constant */ int PR_BORDER_AFTER_WIDTH = 22; + /** Property constant */ int PR_BORDER_BEFORE_COLOR = 23; + /** Property constant */ int PR_BORDER_BEFORE_PRECEDENCE = 24; + /** Property constant */ int PR_BORDER_BEFORE_STYLE = 25; + /** Property constant */ int PR_BORDER_BEFORE_WIDTH = 26; + /** Property constant */ int PR_BORDER_BOTTOM = 27; + /** Property constant */ int PR_BORDER_BOTTOM_COLOR = 28; + /** Property constant */ int PR_BORDER_BOTTOM_STYLE = 29; + /** Property constant */ int PR_BORDER_BOTTOM_WIDTH = 30; + /** Property constant */ int PR_BORDER_COLLAPSE = 31; + /** Property constant */ int PR_BORDER_COLOR = 32; + /** Property constant */ int PR_BORDER_END_COLOR = 33; + /** Property constant */ int PR_BORDER_END_PRECEDENCE = 34; + /** Property constant */ int PR_BORDER_END_STYLE = 35; + /** Property constant */ int PR_BORDER_END_WIDTH = 36; + /** Property constant */ int PR_BORDER_LEFT = 37; + /** Property constant */ int PR_BORDER_LEFT_COLOR = 38; + /** Property constant */ int PR_BORDER_LEFT_STYLE = 39; + /** Property constant */ int PR_BORDER_LEFT_WIDTH = 40; + /** Property constant */ int PR_BORDER_RIGHT = 41; + /** Property constant */ int PR_BORDER_RIGHT_COLOR = 42; + /** Property constant */ int PR_BORDER_RIGHT_STYLE = 43; + /** Property constant */ int PR_BORDER_RIGHT_WIDTH = 44; + /** Property constant */ int PR_BORDER_SEPARATION = 45; + /** Property constant */ int PR_BORDER_SPACING = 46; + /** Property constant */ int PR_BORDER_START_COLOR = 47; + /** Property constant */ int PR_BORDER_START_PRECEDENCE = 48; + /** Property constant */ int PR_BORDER_START_STYLE = 49; + /** Property constant */ int PR_BORDER_START_WIDTH = 50; + /** Property constant */ int PR_BORDER_STYLE = 51; + /** Property constant */ int PR_BORDER_TOP = 52; + /** Property constant */ int PR_BORDER_TOP_COLOR = 53; + /** Property constant */ int PR_BORDER_TOP_STYLE = 54; + /** Property constant */ int PR_BORDER_TOP_WIDTH = 55; + /** Property constant */ int PR_BORDER_WIDTH = 56; + /** Property constant */ int PR_BOTTOM = 57; + /** Property constant */ int PR_BREAK_AFTER = 58; + /** Property constant */ int PR_BREAK_BEFORE = 59; + /** Property constant */ int PR_CAPTION_SIDE = 60; + /** Property constant */ int PR_CASE_NAME = 61; + /** Property constant */ int PR_CASE_TITLE = 62; + /** Property constant */ int PR_CHARACTER = 63; + /** Property constant */ int PR_CLEAR = 64; + /** Property constant */ int PR_CLIP = 65; + /** Property constant */ int PR_COLOR = 66; + /** Property constant */ int PR_COLOR_PROFILE_NAME = 67; + /** Property constant */ int PR_COLUMN_COUNT = 68; + /** Property constant */ int PR_COLUMN_GAP = 69; + /** Property constant */ int PR_COLUMN_NUMBER = 70; + /** Property constant */ int PR_COLUMN_WIDTH = 71; + /** Property constant */ int PR_CONTENT_HEIGHT = 72; + /** Property constant */ int PR_CONTENT_TYPE = 73; + /** Property constant */ int PR_CONTENT_WIDTH = 74; + /** Property constant */ int PR_COUNTRY = 75; + /** Property constant */ int PR_CUE = 76; + /** Property constant */ int PR_CUE_AFTER = 77; + /** Property constant */ int PR_CUE_BEFORE = 78; + /** Property constant */ int PR_DESTINATION_PLACEMENT_OFFSET = 79; + /** Property constant */ int PR_DIRECTION = 80; + /** Property constant */ int PR_DISPLAY_ALIGN = 81; + /** Property constant */ int PR_DOMINANT_BASELINE = 82; + /** Property constant */ int PR_ELEVATION = 83; + /** Property constant */ int PR_EMPTY_CELLS = 84; + /** Property constant */ int PR_END_INDENT = 85; + /** Property constant */ int PR_ENDS_ROW = 86; + /** Property constant */ int PR_EXTENT = 87; + /** Property constant */ int PR_EXTERNAL_DESTINATION = 88; + /** Property constant */ int PR_FLOAT = 89; + /** Property constant */ int PR_FLOW_NAME = 90; + /** Property constant */ int PR_FONT = 91; + /** Property constant */ int PR_FONT_FAMILY = 92; + /** Property constant */ int PR_FONT_SELECTION_STRATEGY = 93; + /** Property constant */ int PR_FONT_SIZE = 94; + /** Property constant */ int PR_FONT_SIZE_ADJUST = 95; + /** Property constant */ int PR_FONT_STRETCH = 96; + /** Property constant */ int PR_FONT_STYLE = 97; + /** Property constant */ int PR_FONT_VARIANT = 98; + /** Property constant */ int PR_FONT_WEIGHT = 99; + /** Property constant */ int PR_FORCE_PAGE_COUNT = 100; + /** Property constant */ int PR_FORMAT = 101; + /** Property constant */ int PR_GLYPH_ORIENTATION_HORIZONTAL = 102; + /** Property constant */ int PR_GLYPH_ORIENTATION_VERTICAL = 103; + /** Property constant */ int PR_GROUPING_SEPARATOR = 104; + /** Property constant */ int PR_GROUPING_SIZE = 105; + /** Property constant */ int PR_HEIGHT = 106; + /** Property constant */ int PR_HYPHENATE = 107; + /** Property constant */ int PR_HYPHENATION_CHARACTER = 108; + /** Property constant */ int PR_HYPHENATION_KEEP = 109; + /** Property constant */ int PR_HYPHENATION_LADDER_COUNT = 110; + /** Property constant */ int PR_HYPHENATION_PUSH_CHARACTER_COUNT = 111; + /** Property constant */ int PR_HYPHENATION_REMAIN_CHARACTER_COUNT = 112; + /** Property constant */ int PR_ID = 113; + /** Property constant */ int PR_INDICATE_DESTINATION = 114; + /** Property constant */ int PR_INITIAL_PAGE_NUMBER = 115; + /** Property constant */ int PR_INLINE_PROGRESSION_DIMENSION = 116; + /** Property constant */ int PR_INTERNAL_DESTINATION = 117; + /** Property constant */ int PR_KEEP_TOGETHER = 118; + /** Property constant */ int PR_KEEP_WITH_NEXT = 119; + /** Property constant */ int PR_KEEP_WITH_PREVIOUS = 120; + /** Property constant */ int PR_LANGUAGE = 121; + /** Property constant */ int PR_LAST_LINE_END_INDENT = 122; + /** Property constant */ int PR_LEADER_ALIGNMENT = 123; + /** Property constant */ int PR_LEADER_LENGTH = 124; + /** Property constant */ int PR_LEADER_PATTERN = 125; + /** Property constant */ int PR_LEADER_PATTERN_WIDTH = 126; + /** Property constant */ int PR_LEFT = 127; + /** Property constant */ int PR_LETTER_SPACING = 128; + /** Property constant */ int PR_LETTER_VALUE = 129; + /** Property constant */ int PR_LINEFEED_TREATMENT = 130; + /** Property constant */ int PR_LINE_HEIGHT = 131; + /** Property constant */ int PR_LINE_HEIGHT_SHIFT_ADJUSTMENT = 132; + /** Property constant */ int PR_LINE_STACKING_STRATEGY = 133; + /** Property constant */ int PR_MARGIN = 134; + /** Property constant */ int PR_MARGIN_BOTTOM = 135; + /** Property constant */ int PR_MARGIN_LEFT = 136; + /** Property constant */ int PR_MARGIN_RIGHT = 137; + /** Property constant */ int PR_MARGIN_TOP = 138; + /** Property constant */ int PR_MARKER_CLASS_NAME = 139; + /** Property constant */ int PR_MASTER_NAME = 140; + /** Property constant */ int PR_MASTER_REFERENCE = 141; + /** Property constant */ int PR_MAX_HEIGHT = 142; + /** Property constant */ int PR_MAXIMUM_REPEATS = 143; + /** Property constant */ int PR_MAX_WIDTH = 144; + /** Property constant */ int PR_MEDIA_USAGE = 145; + /** Property constant */ int PR_MIN_HEIGHT = 146; + /** Property constant */ int PR_MIN_WIDTH = 147; + /** Property constant */ int PR_NUMBER_COLUMNS_REPEATED = 148; + /** Property constant */ int PR_NUMBER_COLUMNS_SPANNED = 149; + /** Property constant */ int PR_NUMBER_ROWS_SPANNED = 150; + /** Property constant */ int PR_ODD_OR_EVEN = 151; + /** Property constant */ int PR_ORPHANS = 152; + /** Property constant */ int PR_OVERFLOW = 153; + /** Property constant */ int PR_PADDING = 154; + /** Property constant */ int PR_PADDING_AFTER = 155; + /** Property constant */ int PR_PADDING_BEFORE = 156; + /** Property constant */ int PR_PADDING_BOTTOM = 157; + /** Property constant */ int PR_PADDING_END = 158; + /** Property constant */ int PR_PADDING_LEFT = 159; + /** Property constant */ int PR_PADDING_RIGHT = 160; + /** Property constant */ int PR_PADDING_START = 161; + /** Property constant */ int PR_PADDING_TOP = 162; + /** Property constant */ int PR_PAGE_BREAK_AFTER = 163; + /** Property constant */ int PR_PAGE_BREAK_BEFORE = 164; + /** Property constant */ int PR_PAGE_BREAK_INSIDE = 165; + /** Property constant */ int PR_PAGE_HEIGHT = 166; + /** Property constant */ int PR_PAGE_POSITION = 167; + /** Property constant */ int PR_PAGE_WIDTH = 168; + /** Property constant */ int PR_PAUSE = 169; + /** Property constant */ int PR_PAUSE_AFTER = 170; + /** Property constant */ int PR_PAUSE_BEFORE = 171; + /** Property constant */ int PR_PITCH = 172; + /** Property constant */ int PR_PITCH_RANGE = 173; + /** Property constant */ int PR_PLAY_DURING = 174; + /** Property constant */ int PR_POSITION = 175; + /** Property constant */ int PR_PRECEDENCE = 176; + /** Property constant */ int PR_PROVISIONAL_DISTANCE_BETWEEN_STARTS = 177; + /** Property constant */ int PR_PROVISIONAL_LABEL_SEPARATION = 178; + /** Property constant */ int PR_REFERENCE_ORIENTATION = 179; + /** Property constant */ int PR_REF_ID = 180; + /** Property constant */ int PR_REGION_NAME = 181; + /** Property constant */ int PR_RELATIVE_ALIGN = 182; + /** Property constant */ int PR_RELATIVE_POSITION = 183; + /** Property constant */ int PR_RENDERING_INTENT = 184; + /** Property constant */ int PR_RETRIEVE_BOUNDARY = 185; + /** Property constant */ int PR_RETRIEVE_CLASS_NAME = 186; + /** Property constant */ int PR_RETRIEVE_POSITION = 187; + /** Property constant */ int PR_RICHNESS = 188; + /** Property constant */ int PR_RIGHT = 189; + /** Property constant */ int PR_ROLE = 190; + /** Property constant */ int PR_RULE_STYLE = 191; + /** Property constant */ int PR_RULE_THICKNESS = 192; + /** Property constant */ int PR_SCALING = 193; + /** Property constant */ int PR_SCALING_METHOD = 194; + /** Property constant */ int PR_SCORE_SPACES = 195; + /** Property constant */ int PR_SCRIPT = 196; + /** Property constant */ int PR_SHOW_DESTINATION = 197; + /** Property constant */ int PR_SIZE = 198; + /** Property constant */ int PR_SOURCE_DOCUMENT = 199; + /** Property constant */ int PR_SPACE_AFTER = 200; + /** Property constant */ int PR_SPACE_BEFORE = 201; + /** Property constant */ int PR_SPACE_END = 202; + /** Property constant */ int PR_SPACE_START = 203; + /** Property constant */ int PR_SPAN = 204; + /** Property constant */ int PR_SPEAK = 205; + /** Property constant */ int PR_SPEAK_HEADER = 206; + /** Property constant */ int PR_SPEAK_NUMERAL = 207; + /** Property constant */ int PR_SPEAK_PUNCTUATION = 208; + /** Property constant */ int PR_SPEECH_RATE = 209; + /** Property constant */ int PR_SRC = 210; + /** Property constant */ int PR_START_INDENT = 211; + /** Property constant */ int PR_STARTING_STATE = 212; + /** Property constant */ int PR_STARTS_ROW = 213; + /** Property constant */ int PR_STRESS = 214; + /** Property constant */ int PR_SUPPRESS_AT_LINE_BREAK = 215; + /** Property constant */ int PR_SWITCH_TO = 216; + /** Property constant */ int PR_TABLE_LAYOUT = 217; + /** Property constant */ int PR_TABLE_OMIT_FOOTER_AT_BREAK = 218; + /** Property constant */ int PR_TABLE_OMIT_HEADER_AT_BREAK = 219; + /** Property constant */ int PR_TARGET_PRESENTATION_CONTEXT = 220; + /** Property constant */ int PR_TARGET_PROCESSING_CONTEXT = 221; + /** Property constant */ int PR_TARGET_STYLESHEET = 222; + /** Property constant */ int PR_TEXT_ALIGN = 223; + /** Property constant */ int PR_TEXT_ALIGN_LAST = 224; + /** Property constant */ int PR_TEXT_ALTITUDE = 225; + /** Property constant */ int PR_TEXT_DECORATION = 226; + /** Property constant */ int PR_TEXT_DEPTH = 227; + /** Property constant */ int PR_TEXT_INDENT = 228; + /** Property constant */ int PR_TEXT_SHADOW = 229; + /** Property constant */ int PR_TEXT_TRANSFORM = 230; + /** Property constant */ int PR_TOP = 231; + /** Property constant */ int PR_TREAT_AS_WORD_SPACE = 232; + /** Property constant */ int PR_UNICODE_BIDI = 233; + /** Property constant */ int PR_VERTICAL_ALIGN = 234; + /** Property constant */ int PR_VISIBILITY = 235; + /** Property constant */ int PR_VOICE_FAMILY = 236; + /** Property constant */ int PR_VOLUME = 237; + /** Property constant */ int PR_WHITE_SPACE_COLLAPSE = 238; + /** Property constant */ int PR_WHITE_SPACE_TREATMENT = 239; + /** Property constant */ int PR_WIDOWS = 240; + /** Property constant */ int PR_WIDTH = 241; + /** Property constant */ int PR_WORD_SPACING = 242; + /** Property constant */ int PR_WRAP_OPTION = 243; + /** Property constant */ int PR_WRITING_MODE = 244; + /** Property constant */ int PR_XML_LANG = 245; + /** Property constant */ int PR_Z_INDEX = 246; + /** Property constant */ int PR_INTRUSION_DISPLACE = 247; - int PR_INDEX_CLASS = 248; // XSL 1.1 - int PR_INDEX_KEY = 249; // XSL 1.1 - int PR_X_BLOCK_PROGRESSION_UNIT = 250; //Custom extension + /** Property constant - XSL 1.1 */ + int PR_INDEX_CLASS = 248; + /** Property constant - XSL 1.1 */ + int PR_INDEX_KEY = 249; + /** Property constant - Custom extension */ + int PR_X_BLOCK_PROGRESSION_UNIT = 250; + /** Number of property constants defined */ int PROPERTY_COUNT = 250; // compound property constants + /** Property constant for compund property */ int CP_BLOCK_PROGRESSION_DIRECTION = 1 << COMPOUND_SHIFT; + /** Property constant for compund property */ int CP_CONDITIONALITY = 2 << COMPOUND_SHIFT; + /** Property constant for compund property */ int CP_INLINE_PROGRESSION_DIRECTION = 3 << COMPOUND_SHIFT; + /** Property constant for compund property */ int CP_LENGTH = 4 << COMPOUND_SHIFT; + /** Property constant for compund property */ int CP_MAXIMUM = 5 << COMPOUND_SHIFT; + /** Property constant for compund property */ int CP_MINIMUM = 6 << COMPOUND_SHIFT; + /** Property constant for compund property */ int CP_OPTIMUM = 7 << COMPOUND_SHIFT; + /** Property constant for compund property */ int CP_PRECEDENCE = 8 << COMPOUND_SHIFT; + /** Property constant for compund property */ int CP_WITHIN_COLUMN = 9 << COMPOUND_SHIFT; + /** Property constant for compund property */ int CP_WITHIN_LINE = 10 << COMPOUND_SHIFT; + /** Property constant for compund property */ int CP_WITHIN_PAGE = 11 << COMPOUND_SHIFT; // Enumeration constants + /** Enumeration constant */ int EN_ABSOLUTE = 1; + /** Enumeration constant */ int EN_ABSOLUTE_COLORMETRIC = 2; + /** Enumeration constant */ int EN_AFTER = 3; + /** Enumeration constant */ int EN_AFTER_EDGE = 4; + /** Enumeration constant */ int EN_ALL = 5; + /** Enumeration constant */ int EN_ALPHABETIC = 6; + /** Enumeration constant */ int EN_ALWAYS = 7; + /** Enumeration constant */ int EN_ANY = 8; + /** Enumeration constant */ int EN_AUTO = 9; + /** Enumeration constant */ int EN_AUTO_EVEN = 10; + /** Enumeration constant */ int EN_AUTO_ODD = 11; + /** Enumeration constant */ int EN_BASELINE = 12; + /** Enumeration constant */ int EN_BEFORE = 13; + /** Enumeration constant */ int EN_BEFORE_EDGE = 14; + /** Enumeration constant */ int EN_BIDI_OVERRIDE = 15; + /** Enumeration constant */ int EN_BLANK = 16; + /** Enumeration constant */ int EN_BLINK = 17; + /** Enumeration constant */ int EN_BLOCK = 18; + /** Enumeration constant */ int EN_BOTH = 19; + /** Enumeration constant */ int EN_BOTTOM = 20; + /** Enumeration constant */ int EN_BOUNDED_IN_ONE_DIMENSION = 21; + /** Enumeration constant */ int EN_CAPITALIZE = 22; + /** Enumeration constant */ int EN_CENTER = 23; + /** Enumeration constant */ int EN_CENTRAL = 24; + /** Enumeration constant */ int EN_CHARACTER_BY_CHARACTER = 25; + /** Enumeration constant */ int EN_COLLAPSE = 26; + /** Enumeration constant */ int EN_COLLAPSE_WITH_PRECEDENCE = 27; + /** Enumeration constant */ int EN_COLUMN = 28; + /** Enumeration constant */ int EN_CONDENSED = 29; + /** Enumeration constant */ int EN_CONSIDER_SHIFTS = 30; + /** Enumeration constant */ int EN_DASHED = 31; + /** Enumeration constant */ int EN_DISCARD = 32; + /** Enumeration constant */ int EN_DISREGARD_SHIFTS = 33; + /** Enumeration constant */ int EN_DOCUMENT = 34; + /** Enumeration constant */ int EN_DOTS = 35; + /** Enumeration constant */ int EN_DOTTED = 36; + /** Enumeration constant */ int EN_DOUBLE = 37; + /** Enumeration constant */ int EN_EMBED = 38; + /** Enumeration constant */ int EN_END = 39; + /** Enumeration constant */ int EN_END_ON_EVEN = 40; + /** Enumeration constant */ int EN_END_ON_ODD = 41; + /** Enumeration constant */ int EN_ERROR_IF_OVERFLOW = 42; + /** Enumeration constant */ int EN_EVEN = 43; + /** Enumeration constant */ int EN_EVEN_PAGE = 44; + /** Enumeration constant */ int EN_EXPANDED = 45; + /** Enumeration constant */ int EN_EXTRA_CONDENSED = 46; + /** Enumeration constant */ int EN_EXTRA_EXPANDED = 47; + /** Enumeration constant */ int EN_FALSE = 48; + /** Enumeration constant */ int EN_FIC = 49; + /** Enumeration constant */ int EN_FIRST = 50; + /** Enumeration constant */ int EN_FIXED = 51; + /** Enumeration constant */ int EN_FONT_HEIGHT = 52; + /** Enumeration constant */ int EN_FORCE = 53; + /** Enumeration constant */ int EN_FSWP = 54; + /** Enumeration constant */ int EN_GROOVE = 55; + /** Enumeration constant */ int EN_HANGING = 56; + /** Enumeration constant */ int EN_HIDDEN = 57; + /** Enumeration constant */ int EN_HIDE = 58; + /** Enumeration constant */ int EN_IDEOGRAPHIC = 59; + /** Enumeration constant */ int EN_IGNORE = 60; + /** Enumeration constant */ int EN_IGNORE_IF_AFTER_LINEFEED = 61; + /** Enumeration constant */ int EN_IGNORE_IF_BEFORE_LINEFEED = 62; + /** Enumeration constant */ int EN_IGNORE_IF_SURROUNDING_LINEFEED = 63; + /** Enumeration constant */ int EN_INDEFINITE = 64; + /** Enumeration constant */ int EN_INDENT = 65; + /** Enumeration constant */ int EN_INHERIT = 66; + /** Enumeration constant */ int EN_INSET = 67; + /** Enumeration constant */ int EN_INSIDE = 68; + /** Enumeration constant */ int EN_INTEGER_PIXELS = 69; + /** Enumeration constant */ int EN_JUSTIFY = 70; + /** Enumeration constant */ int EN_LARGER = 71; + /** Enumeration constant */ int EN_LAST = 72; + /** Enumeration constant */ int EN_LEFT = 73; + /** Enumeration constant */ int EN_LEWP = 74; + /** Enumeration constant */ int EN_LINE = 75; + /** Enumeration constant */ int EN_LINE_HEIGHT = 76; + /** Enumeration constant */ int EN_LINE_THROUGH = 77; + /** Enumeration constant */ int EN_LOWERCASE = 78; + /** Enumeration constant */ int EN_LR_TB = 79; + /** Enumeration constant */ int EN_LTR = 80; + /** Enumeration constant */ int EN_LSWP = 81; + /** Enumeration constant */ int EN_MATHEMATICAL = 82; + /** Enumeration constant */ int EN_MAX_HEIGHT = 83; + /** Enumeration constant */ int EN_MIDDLE = 84; + /** Enumeration constant */ int EN_NARROWER = 85; + /** Enumeration constant */ int EN_NO_BLINK = 86; + /** Enumeration constant */ int EN_NO_CHANGE = 87; + /** Enumeration constant */ int EN_NO_FORCE = 88; + /** Enumeration constant */ int EN_NO_LIMIT = 89; + /** Enumeration constant */ int EN_NO_LINE_THROUGH = 90; + /** Enumeration constant */ int EN_NO_OVERLINE = 91; + /** Enumeration constant */ int EN_NO_UNDERLINE = 92; + /** Enumeration constant */ int EN_NO_WRAP = 93; + /** Enumeration constant */ int EN_NON_UNIFORM = 94; + /** Enumeration constant */ int EN_NONE = 95; + /** Enumeration constant */ int EN_NOREPEAT = 96; + /** Enumeration constant */ int EN_NORMAL = 97; + /** Enumeration constant */ int EN_NOT_BLANK = 98; + /** Enumeration constant */ int EN_ODD = 99; + /** Enumeration constant */ int EN_ODD_PAGE = 100; + /** Enumeration constant */ int EN_OUTSET = 101; + /** Enumeration constant */ int EN_OUTSIDE = 102; + /** Enumeration constant */ int EN_OVERLINE = 103; + /** Enumeration constant */ int EN_PAGE = 104; + /** Enumeration constant */ int EN_PAGE_SEQUENCE = 105; + /** Enumeration constant */ int EN_PAGINATE = 106; + /** Enumeration constant */ int EN_PERCEPTUAL = 107; + /** Enumeration constant */ int EN_PRESERVE = 108; + /** Enumeration constant */ int EN_REFERENCE_AREA = 109; + /** Enumeration constant */ int EN_RELATIVE = 110; + /** Enumeration constant */ int EN_RELATIVE_COLOMETRIC = 111; + /** Enumeration constant */ int EN_REPEAT = 112; + /** Enumeration constant */ int EN_REPEATX = 113; + /** Enumeration constant */ int EN_REPEATY = 114; + /** Enumeration constant */ int EN_RESAMPLE_ANY_METHOD = 115; + /** Enumeration constant */ int EN_RESET_SIZE = 116; + /** Enumeration constant */ int EN_REST = 117; + /** Enumeration constant */ int EN_RETAIN = 118; + /** Enumeration constant */ int EN_RIDGE = 119; + /** Enumeration constant */ int EN_RIGHT = 120; + /** Enumeration constant */ int EN_RL_TB = 121; + /** Enumeration constant */ int EN_RTL = 122; + /** Enumeration constant */ int EN_RULE = 123; + /** Enumeration constant */ int EN_SATURATION = 124; + /** Enumeration constant */ int EN_SCALE_TO_FIT = 125; + /** Enumeration constant */ int EN_SCROLL = 126; + /** Enumeration constant */ int EN_SEMI_CONDENSED = 127; + /** Enumeration constant */ int EN_SEMI_EXPANDED = 128; + /** Enumeration constant */ int EN_SEPARATE = 129; + /** Enumeration constant */ int EN_SHOW = 130; + /** Enumeration constant */ int EN_SMALL_CAPS = 131; + /** Enumeration constant */ int EN_SMALLER = 132; + /** Enumeration constant */ int EN_SOLID = 133; + /** Enumeration constant */ int EN_SPACE = 134; + /** Enumeration constant */ int EN_START = 135; + /** Enumeration constant */ int EN_STATIC = 136; + /** Enumeration constant */ int EN_SUB = 137; + /** Enumeration constant */ int EN_SUPER = 138; + /** Enumeration constant */ int EN_SUPPRESS = 139; + /** Enumeration constant */ int EN_TB_RL = 140; + /** Enumeration constant */ int EN_TEXT_AFTER_EDGE = 141; + /** Enumeration constant */ int EN_TEXT_BEFORE_EDGE = 142; + /** Enumeration constant */ int EN_TEXT_BOTTOM = 143; + /** Enumeration constant */ int EN_TEXT_TOP = 144; + /** Enumeration constant */ int EN_TOP = 145; + /** Enumeration constant */ int EN_TRADITIONAL = 146; + /** Enumeration constant */ int EN_TREAT_AS_SPACE = 147; + /** Enumeration constant */ int EN_TREAT_AS_ZERO_WIDTH_SPACE = 148; + /** Enumeration constant */ int EN_TRUE = 149; + /** Enumeration constant */ int EN_ULTRA_CONDENSED = 150; + /** Enumeration constant */ int EN_ULTRA_EXPANDED = 151; + /** Enumeration constant */ int EN_UNBOUNDED = 152; + /** Enumeration constant */ int EN_UNDERLINE = 153; + /** Enumeration constant */ int EN_UNIFORM = 154; + /** Enumeration constant */ int EN_UPPERCASE = 155; + /** Enumeration constant */ int EN_USE_FONT_METRICS = 156; + /** Enumeration constant */ int EN_USE_SCRIPT = 157; + /** Enumeration constant */ int EN_USECONTENT = 158; + /** Enumeration constant */ int EN_VISIBLE = 159; + /** Enumeration constant */ int EN_WIDER = 160; + /** Enumeration constant */ int EN_WRAP = 161; - int EN_X_FILL = 162; //non-standard for display-align - int EN_X_DISTRIBUTE = 163; //non-standard for display-align + /** Enumeration constant - non-standard for display-align */ + int EN_X_FILL = 162; + /** Enumeration constant - non-standard for display-align */ + int EN_X_DISTRIBUTE = 163; + /** Number of enumeration constants defined */ int ENUM_COUNT = 163; } diff --git a/src/java/org/apache/fop/fo/FOPropertyMapping.java b/src/java/org/apache/fop/fo/FOPropertyMapping.java index f49d4d94e..7ff94a888 100644 --- a/src/java/org/apache/fop/fo/FOPropertyMapping.java +++ b/src/java/org/apache/fop/fo/FOPropertyMapping.java @@ -280,12 +280,13 @@ public class FOPropertyMapping implements Constants { genericCondPadding.useGeneric(genericCondLength); genericCondPadding.setInherited(false); genericCondPadding.getSubpropMaker(CP_LENGTH).setDefault("0pt"); + genericCondPadding.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH); // GenericPadding genericPadding = new LengthProperty.Maker(0); genericPadding.setInherited(false); genericPadding.setDefault("0pt"); - genericPadding.setPercentBase(LengthBase.BLOCK_WIDTH); + genericPadding.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH); genericPadding.addShorthand(s_generics[PR_PADDING]); // GenericCondBorderWidth @@ -716,7 +717,7 @@ public class FOPropertyMapping implements Constants { m.addKeyword("left", "0%"); m.addKeyword("center", "50%"); m.addKeyword("right", "100%"); - m.setPercentBase(LengthBase.CONTAINING_BOX); + m.setPercentBase(LengthBase.IMAGE_BACKGROUND_POSITION_HORIZONTAL); addPropertyMaker("background-position-horizontal", m); // background-position-vertical @@ -726,7 +727,7 @@ public class FOPropertyMapping implements Constants { m.addKeyword("top", "0%"); m.addKeyword("center", "50%"); m.addKeyword("bottom", "100%"); - m.setPercentBase(LengthBase.CONTAINING_BOX); + m.setPercentBase(LengthBase.IMAGE_BACKGROUND_POSITION_VERTICAL); addPropertyMaker("background-position-vertical", m); // border-before-color @@ -1202,7 +1203,7 @@ public class FOPropertyMapping implements Constants { m.setInherited(false); m.setDefault("0pt"); m.addShorthand(s_generics[PR_MARGIN]); - m.setPercentBase(LengthBase.BLOCK_WIDTH); + m.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH); addPropertyMaker("margin-top", m); // margin-bottom @@ -1210,7 +1211,7 @@ public class FOPropertyMapping implements Constants { m.setInherited(false); m.setDefault("0pt"); m.addShorthand(s_generics[PR_MARGIN]); - m.setPercentBase(LengthBase.BLOCK_WIDTH); + m.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH); addPropertyMaker("margin-bottom", m); // margin-left @@ -1218,7 +1219,7 @@ public class FOPropertyMapping implements Constants { m.setInherited(false); m.setDefault("0pt"); m.addShorthand(s_generics[PR_MARGIN]); - m.setPercentBase(LengthBase.BLOCK_WIDTH); + m.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH); addPropertyMaker("margin-left", m); // margin-right @@ -1226,7 +1227,7 @@ public class FOPropertyMapping implements Constants { m.setInherited(false); m.setDefault("0pt"); m.addShorthand(s_generics[PR_MARGIN]); - m.setPercentBase(LengthBase.BLOCK_WIDTH); + m.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH); addPropertyMaker("margin-right", m); // space-before @@ -1407,26 +1408,26 @@ public class FOPropertyMapping implements Constants { // block-progression-dimension m = new LengthRangeProperty.Maker(PR_BLOCK_PROGRESSION_DIMENSION); m.setInherited(false); - m.setPercentBase(LengthBase.BLOCK_HEIGHT); + m.setPercentBase(LengthBase.CONTAINING_BLOCK_HEIGHT); l = new LengthProperty.Maker(CP_MINIMUM); l.setDefault("auto"); l.addEnum("auto", getEnumProperty(EN_AUTO, "AUTO")); - l.setPercentBase(LengthBase.CONTAINING_BOX); + l.setPercentBase(LengthBase.CONTAINING_BLOCK_HEIGHT); l.setByShorthand(true); m.addSubpropMaker(l); l = new LengthProperty.Maker(CP_OPTIMUM); l.setDefault("auto"); l.addEnum("auto", getEnumProperty(EN_AUTO, "AUTO")); - l.setPercentBase(LengthBase.CONTAINING_BOX); + l.setPercentBase(LengthBase.CONTAINING_BLOCK_HEIGHT); l.setByShorthand(true); m.addSubpropMaker(l); l = new LengthProperty.Maker(CP_MAXIMUM); l.addEnum("auto", getEnumProperty(EN_AUTO, "AUTO")); l.setDefault("auto"); - l.setPercentBase(LengthBase.CONTAINING_BOX); + l.setPercentBase(LengthBase.CONTAINING_BLOCK_HEIGHT); l.setByShorthand(true); m.addSubpropMaker(l); @@ -1462,33 +1463,33 @@ public class FOPropertyMapping implements Constants { l = new LengthProperty.Maker(PR_HEIGHT); l.setInherited(false); l.addEnum("auto", getEnumProperty(EN_AUTO, "AUTO")); - l.setPercentBase(LengthBase.BLOCK_HEIGHT); + l.setPercentBase(LengthBase.CONTAINING_BLOCK_HEIGHT); l.setDefault("auto"); addPropertyMaker("height", l); // inline-progression-dimension m = new LengthRangeProperty.Maker(PR_INLINE_PROGRESSION_DIMENSION); m.setInherited(false); - m.setPercentBase(LengthBase.BLOCK_WIDTH); + m.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH); l = new LengthProperty.Maker(CP_MINIMUM); l.setDefault("auto"); l.addEnum("auto", getEnumProperty(EN_AUTO, "AUTO")); - l.setPercentBase(LengthBase.CONTAINING_BOX); + l.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH); l.setByShorthand(true); m.addSubpropMaker(l); l = new LengthProperty.Maker(CP_OPTIMUM); l.setDefault("auto"); l.addEnum("auto", getEnumProperty(EN_AUTO, "AUTO")); - l.setPercentBase(LengthBase.CONTAINING_BOX); + l.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH); l.setByShorthand(true); m.addSubpropMaker(l); l = new LengthProperty.Maker(CP_MAXIMUM); l.addEnum("auto", getEnumProperty(EN_AUTO, "AUTO")); l.setDefault("auto"); - l.setPercentBase(LengthBase.CONTAINING_BOX); + l.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH); l.setByShorthand(true); m.addSubpropMaker(l); @@ -1547,7 +1548,7 @@ public class FOPropertyMapping implements Constants { l = new LengthProperty.Maker(PR_WIDTH); l.setInherited(false); l.addEnum("auto", getEnumProperty(EN_AUTO, "AUTO")); - l.setPercentBase(LengthBase.BLOCK_WIDTH); + l.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH); l.setDefault("auto"); addPropertyMaker("width", l); @@ -1679,7 +1680,7 @@ public class FOPropertyMapping implements Constants { m = new LengthProperty.Maker(PR_TEXT_INDENT); m.setInherited(true); m.setDefault("0pt"); - m.setPercentBase(LengthBase.BLOCK_WIDTH); + m.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH); addPropertyMaker("text-indent", m); // white-space-collapse @@ -1957,29 +1958,29 @@ public class FOPropertyMapping implements Constants { m.setInherited(true); m.setDefault("use-font-metrics", true); m.addKeyword("use-font-metrics", "0pt"); - m.setPercentBase(LengthBase.CONTAINING_BOX); + m.setPercentBase(LengthBase.PARENT_AREA_WIDTH); addPropertyMaker("leader-pattern-width", m); // leader-length m = new LengthRangeProperty.Maker(PR_LEADER_LENGTH); m.setInherited(true); - m.setPercentBase(LengthBase.CONTAINING_BOX); + m.setPercentBase(LengthBase.PARENT_AREA_WIDTH); sub = new LengthProperty.Maker(CP_MINIMUM); sub.setDefault("0pt"); - sub.setPercentBase(LengthBase.BLOCK_WIDTH); + sub.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH); sub.setByShorthand(true); m.addSubpropMaker(sub); sub = new LengthProperty.Maker(CP_OPTIMUM); sub.setDefault("12.0pt"); - sub.setPercentBase(LengthBase.BLOCK_WIDTH); + sub.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH); sub.setByShorthand(true); m.addSubpropMaker(sub); sub = new LengthProperty.Maker(CP_MAXIMUM); sub.setDefault("100%", true); - sub.setPercentBase(LengthBase.BLOCK_WIDTH); + sub.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH); sub.setByShorthand(true); m.addSubpropMaker(sub); addPropertyMaker("leader-length", m); @@ -2190,6 +2191,7 @@ public class FOPropertyMapping implements Constants { m = new LengthProperty.Maker(PR_EXTENT); m.setInherited(true); m.setDefault("0pt"); + m.setPercentBase(LengthBase.CUSTOM_BASE); addPropertyMaker("extent", m); // flow-name @@ -2376,7 +2378,7 @@ public class FOPropertyMapping implements Constants { m = new LengthProperty.Maker(PR_COLUMN_WIDTH); m.setInherited(false); m.setDefault("proportional-column-width(1)", true); - m.setPercentBase(LengthBase.BLOCK_WIDTH); + m.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH); addPropertyMaker("column-width", m); // empty-cells @@ -2651,13 +2653,14 @@ public class FOPropertyMapping implements Constants { m.setInherited(false); m.setDefault(""); m.setDatatypeParser(new BoxPropShorthandParser()); - m.setPercentBase(LengthBase.BLOCK_WIDTH); + m.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH); addPropertyMaker("margin", m); // padding m = new ListProperty.Maker(PR_PADDING); m.setInherited(false); m.setDatatypeParser(new BoxPropShorthandParser()); + m.setPercentBase(LengthBase.CONTAINING_BLOCK_WIDTH); addPropertyMaker("padding", m); // page-break-after diff --git a/src/java/org/apache/fop/fo/InlineCharIterator.java b/src/java/org/apache/fop/fo/InlineCharIterator.java index 02ef5f341..ed90d50c0 100644 --- a/src/java/org/apache/fop/fo/InlineCharIterator.java +++ b/src/java/org/apache/fop/fo/InlineCharIterator.java @@ -40,9 +40,9 @@ public class InlineCharIterator extends RecursiveCharIterator { private void checkBoundaries(CommonBorderPaddingBackground bpb) { bStartBoundary = (bpb.getBorderStartWidth(false) > 0 - || bpb.getPaddingStart(false) > 0); + || bpb.getPaddingStart(false, null) > 0); // TODO do we need context here? bEndBoundary = (bpb.getBorderEndWidth(false) > 0 - || bpb.getPaddingEnd(false) > 0); + || bpb.getPaddingEnd(false, null) > 0); // TODO do we need context here? } /** diff --git a/src/java/org/apache/fop/fo/expr/LabelEndFunction.java b/src/java/org/apache/fop/fo/expr/LabelEndFunction.java index d014662b3..4682272b5 100644 --- a/src/java/org/apache/fop/fo/expr/LabelEndFunction.java +++ b/src/java/org/apache/fop/fo/expr/LabelEndFunction.java @@ -66,7 +66,7 @@ public class LabelEndFunction extends FunctionBase { Length startIndent = pList.get(Constants.PR_START_INDENT).getLength(); LengthBase base = new LengthBase(pList.getFObj(), pInfo.getPropertyList(), - LengthBase.CONTAINING_REFAREA); + LengthBase.CONTAINING_REFAREA_WIDTH); PercentLength refWidth = new PercentLength(1.0, base); Numeric labelEnd = distance; diff --git a/src/java/org/apache/fop/fo/expr/NumericOp.java b/src/java/org/apache/fop/fo/expr/NumericOp.java index 34aa29d00..3edc41196 100755 --- a/src/java/org/apache/fop/fo/expr/NumericOp.java +++ b/src/java/org/apache/fop/fo/expr/NumericOp.java @@ -18,6 +18,7 @@ package org.apache.fop.fo.expr; +import org.apache.fop.datatypes.PercentBaseContext; import org.apache.fop.datatypes.Numeric; /** @@ -39,17 +40,17 @@ public class NumericOp { */ public static Numeric addition(Numeric op1, Numeric op2) throws PropertyException { if (op1.isAbsolute() && op2.isAbsolute()) { - return addition2(op1, op2); + return addition2(op1, op2, null); } else { return new RelativeNumericProperty(RelativeNumericProperty.ADDITION, op1, op2); } } - public static Numeric addition2(Numeric op1, Numeric op2) throws PropertyException { + public static Numeric addition2(Numeric op1, Numeric op2, PercentBaseContext context) throws PropertyException { if (op1.getDimension() != op2.getDimension()) { throw new PropertyException("Can't subtract Numerics of different dimensions"); } - return numeric(op1.getNumericValue() + op2.getNumericValue(), op1.getDimension()); + return numeric(op1.getNumericValue(context) + op2.getNumericValue(context), op1.getDimension()); } /** @@ -63,17 +64,17 @@ public class NumericOp { */ public static Numeric subtraction(Numeric op1, Numeric op2) throws PropertyException { if (op1.isAbsolute() && op2.isAbsolute()) { - return subtraction2(op1, op2); + return subtraction2(op1, op2, null); } else { return new RelativeNumericProperty(RelativeNumericProperty.SUBTRACTION, op1, op2); } } - public static Numeric subtraction2(Numeric op1, Numeric op2) throws PropertyException { + public static Numeric subtraction2(Numeric op1, Numeric op2, PercentBaseContext context) throws PropertyException { if (op1.getDimension() != op2.getDimension()) { throw new PropertyException("Can't subtract Numerics of different dimensions"); } - return numeric(op1.getNumericValue() - op2.getNumericValue(), op1.getDimension()); + return numeric(op1.getNumericValue(context) - op2.getNumericValue(context), op1.getDimension()); } /** @@ -87,14 +88,14 @@ public class NumericOp { */ public static Numeric multiply(Numeric op1, Numeric op2) throws PropertyException { if (op1.isAbsolute() && op2.isAbsolute()) { - return multiply2(op1, op2); + return multiply2(op1, op2, null); } else { return new RelativeNumericProperty(RelativeNumericProperty.MULTIPLY, op1, op2); } } - public static Numeric multiply2(Numeric op1, Numeric op2) throws PropertyException { - return numeric(op1.getNumericValue() * op2.getNumericValue(), + public static Numeric multiply2(Numeric op1, Numeric op2, PercentBaseContext context) throws PropertyException { + return numeric(op1.getNumericValue(context) * op2.getNumericValue(context), op1.getDimension() + op2.getDimension()); } @@ -110,14 +111,14 @@ public class NumericOp { */ public static Numeric divide(Numeric op1, Numeric op2) throws PropertyException { if (op1.isAbsolute() && op2.isAbsolute()) { - return divide2(op1, op2); + return divide2(op1, op2, null); } else { return new RelativeNumericProperty(RelativeNumericProperty.DIVIDE, op1, op2); } } - public static Numeric divide2(Numeric op1, Numeric op2) throws PropertyException { - return numeric(op1.getNumericValue() / op2.getNumericValue(), + public static Numeric divide2(Numeric op1, Numeric op2, PercentBaseContext context) throws PropertyException { + return numeric(op1.getNumericValue(context) / op2.getNumericValue(context), op1.getDimension() - op2.getDimension()); } @@ -129,14 +130,14 @@ public class NumericOp { */ public static Numeric modulo(Numeric op1, Numeric op2) throws PropertyException { if (op1.isAbsolute() && op2.isAbsolute()) { - return modulo2(op1, op2); + return modulo2(op1, op2, null); } else { return new RelativeNumericProperty(RelativeNumericProperty.MODULO, op1, op2); } } - public static Numeric modulo2(Numeric op1, Numeric op2) throws PropertyException { - return numeric(op1.getNumericValue() % op2.getNumericValue(), op1.getDimension()); + public static Numeric modulo2(Numeric op1, Numeric op2, PercentBaseContext context) throws PropertyException { + return numeric(op1.getNumericValue(context) % op2.getNumericValue(context), op1.getDimension()); } /** @@ -146,14 +147,14 @@ public class NumericOp { */ public static Numeric abs(Numeric op) throws PropertyException { if (op.isAbsolute()) { - return abs2(op); + return abs2(op, null); } else { return new RelativeNumericProperty(RelativeNumericProperty.ABS, op); } } - public static Numeric abs2(Numeric op) throws PropertyException { - return numeric(Math.abs(op.getNumericValue()), op.getDimension()); + public static Numeric abs2(Numeric op, PercentBaseContext context) throws PropertyException { + return numeric(Math.abs(op.getNumericValue(context)), op.getDimension()); } /** @@ -163,14 +164,14 @@ public class NumericOp { */ public static Numeric negate(Numeric op) throws PropertyException { if (op.isAbsolute()) { - return negate2(op); + return negate2(op, null); } else { return new RelativeNumericProperty(RelativeNumericProperty.NEGATE, op); } } - public static Numeric negate2(Numeric op) throws PropertyException { - return numeric(- op.getNumericValue(), op.getDimension()); + public static Numeric negate2(Numeric op, PercentBaseContext context) throws PropertyException { + return numeric(- op.getNumericValue(context), op.getDimension()); } /** @@ -182,17 +183,17 @@ public class NumericOp { */ public static Numeric max(Numeric op1, Numeric op2) throws PropertyException { if (op1.isAbsolute() && op2.isAbsolute()) { - return max2(op1, op2); + return max2(op1, op2, null); } else { return new RelativeNumericProperty(RelativeNumericProperty.MAX, op1, op2); } } - public static Numeric max2(Numeric op1, Numeric op2) throws PropertyException { + public static Numeric max2(Numeric op1, Numeric op2, PercentBaseContext context) throws PropertyException { if (op1.getDimension() != op2.getDimension()) { throw new PropertyException("Arguments to max() must have same dimensions"); } - return op1.getNumericValue() > op2.getNumericValue() ? op1 : op2; + return op1.getNumericValue(context) > op2.getNumericValue(context) ? op1 : op2; } /** @@ -204,17 +205,17 @@ public class NumericOp { */ public static Numeric min(Numeric op1, Numeric op2) throws PropertyException { if (op1.isAbsolute() && op2.isAbsolute()) { - return min2(op1, op2); + return min2(op1, op2, null); } else { return new RelativeNumericProperty(RelativeNumericProperty.MIN, op1, op2); } } - public static Numeric min2(Numeric op1, Numeric op2) throws PropertyException { + public static Numeric min2(Numeric op1, Numeric op2, PercentBaseContext context) throws PropertyException { if (op1.getDimension() != op2.getDimension()) { throw new PropertyException("Arguments to min() must have same dimensions"); } - return op1.getNumericValue() <= op2.getNumericValue() ? op1 : op2; + return op1.getNumericValue(context) <= op2.getNumericValue(context) ? op1 : op2; } /** diff --git a/src/java/org/apache/fop/fo/expr/NumericProperty.java b/src/java/org/apache/fop/fo/expr/NumericProperty.java index 72de27750..dd146ce7f 100644 --- a/src/java/org/apache/fop/fo/expr/NumericProperty.java +++ b/src/java/org/apache/fop/fo/expr/NumericProperty.java @@ -19,6 +19,7 @@ package org.apache.fop.fo.expr; import org.apache.fop.datatypes.Length; +import org.apache.fop.datatypes.PercentBaseContext; import org.apache.fop.datatypes.Numeric; import org.apache.fop.fo.properties.ColorTypeProperty; import org.apache.fop.fo.properties.Property; @@ -60,6 +61,15 @@ public class NumericProperty extends Property implements Numeric, Length { } /** + * Return the value. + * @param Evaluation context + * @see Numeric#getNumericValue(Object) + */ + public double getNumericValue(PercentBaseContext context) { + return value; + } + + /** * Return true of the numeric is absolute. * @see Numeric#isAbsolute() */ @@ -89,6 +99,14 @@ public class NumericProperty extends Property implements Numeric, Length { } /** + * Return the value of this numeric as a length in millipoints. + * @param Evaluation context + */ + public int getValue(PercentBaseContext context) { + return (int) value; + } + + /** * Cast this as a length. That is only possible when the dimension is * one. */ diff --git a/src/java/org/apache/fop/fo/expr/PropertyInfo.java b/src/java/org/apache/fop/fo/expr/PropertyInfo.java index fb59332de..9cd5e714e 100644 --- a/src/java/org/apache/fop/fo/expr/PropertyInfo.java +++ b/src/java/org/apache/fop/fo/expr/PropertyInfo.java @@ -20,11 +20,12 @@ package org.apache.fop.fo.expr; import java.util.Stack; +import org.apache.fop.datatypes.Length; +import org.apache.fop.datatypes.PercentBase; import org.apache.fop.fo.Constants; -import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.FObj; +import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.properties.PropertyMaker; -import org.apache.fop.datatypes.PercentBase; /** @@ -57,7 +58,7 @@ public class PropertyInfo { * Propagates to the Maker. * @return The PercentBase object or null if percentLengthOK()=false. */ - public PercentBase getPercentBase() { + public PercentBase getPercentBase() throws PropertyException { PercentBase pcbase = getFunctionPercentBase(); return (pcbase != null) ? pcbase : maker.getPercentBase(fo, plist); } @@ -65,8 +66,8 @@ public class PropertyInfo { /** * @return the current font-size value as base units (milli-points). */ - public int currentFontSize() throws PropertyException { - return plist.get(Constants.PR_FONT_SIZE).getLength().getValue(); + public Length currentFontSize() throws PropertyException { + return plist.get(Constants.PR_FONT_SIZE).getLength(); } /** diff --git a/src/java/org/apache/fop/fo/expr/PropertyParser.java b/src/java/org/apache/fop/fo/expr/PropertyParser.java index 7d77d7f9b..4ab7e7249 100644 --- a/src/java/org/apache/fop/fo/expr/PropertyParser.java +++ b/src/java/org/apache/fop/fo/expr/PropertyParser.java @@ -285,18 +285,11 @@ public class PropertyParser extends PropertyTokenizer { String unitPart = currentTokenValue.substring(numLen); Double numPart = new Double(currentTokenValue.substring(0, numLen)); - LengthProperty length = null; if (unitPart.equals(RELUNIT)) { - length = new FixedLength(numPart.doubleValue(), + prop = (Property) NumericOp.multiply(new NumberProperty(numPart.doubleValue()), propInfo.currentFontSize()); } else { - length = new FixedLength(numPart.doubleValue(), unitPart); - } - if (length == null) { - throw new PropertyException("unrecognized unit name: " - + currentTokenValue); - } else { - prop = length; + prop = new FixedLength(numPart.doubleValue(), unitPart); } break; diff --git a/src/java/org/apache/fop/fo/expr/RGBColorFunction.java b/src/java/org/apache/fop/fo/expr/RGBColorFunction.java index ee1e28daa..4e050bd08 100644 --- a/src/java/org/apache/fop/fo/expr/RGBColorFunction.java +++ b/src/java/org/apache/fop/fo/expr/RGBColorFunction.java @@ -19,9 +19,10 @@ package org.apache.fop.fo.expr; +import org.apache.fop.datatypes.PercentBaseContext; +import org.apache.fop.datatypes.PercentBase; import org.apache.fop.fo.properties.ColorTypeProperty; import org.apache.fop.fo.properties.Property; -import org.apache.fop.datatypes.PercentBase; class RGBColorFunction extends FunctionBase { public int nbArgs() { @@ -68,7 +69,7 @@ class RGBColorFunction extends FunctionBase { return 255f; } - public int getBaseLength() { + public int getBaseLength(PercentBaseContext context) { return 0; } diff --git a/src/java/org/apache/fop/fo/expr/RelativeNumericProperty.java b/src/java/org/apache/fop/fo/expr/RelativeNumericProperty.java index 97e940d0b..15017440d 100755 --- a/src/java/org/apache/fop/fo/expr/RelativeNumericProperty.java +++ b/src/java/org/apache/fop/fo/expr/RelativeNumericProperty.java @@ -18,6 +18,8 @@ package org.apache.fop.fo.expr; +import org.apache.fop.datatypes.Length; +import org.apache.fop.datatypes.PercentBaseContext; import org.apache.fop.datatypes.Numeric; import org.apache.fop.datatypes.Length; import org.apache.fop.fo.properties.Property; @@ -96,29 +98,30 @@ public class RelativeNumericProperty extends Property implements Numeric, Length /** * Return a resolved (calculated) Numeric with the value of the expression. + * @param context Evaluation context * @throws PropertyException when an exception occur during evaluation. */ - private Numeric getResolved() throws PropertyException { + private Numeric getResolved(PercentBaseContext context) throws PropertyException { Numeric n; switch (operation) { case ADDITION: - return NumericOp.addition2(op1, op2); + return NumericOp.addition2(op1, op2, context); case SUBTRACTION: - return NumericOp.subtraction2(op1, op2); + return NumericOp.subtraction2(op1, op2, context); case MULTIPLY: - return NumericOp.multiply2(op1, op2); + return NumericOp.multiply2(op1, op2, context); case DIVIDE: - return NumericOp.divide2(op1, op2); + return NumericOp.divide2(op1, op2, context); case MODULO: - return NumericOp.modulo2(op1, op2); + return NumericOp.modulo2(op1, op2, context); case NEGATE: - return NumericOp.negate2(op1); + return NumericOp.negate2(op1, context); case ABS: - return NumericOp.abs2(op1); + return NumericOp.abs2(op1, context); case MAX: - return NumericOp.max2(op1, op2); + return NumericOp.max2(op1, op2, context); case MIN: - return NumericOp.min2(op1, op2); + return NumericOp.min2(op1, op2, context); default: throw new PropertyException("Unknown expr operation " + operation); } @@ -129,7 +132,16 @@ public class RelativeNumericProperty extends Property implements Numeric, Length * @see Numeric#getNumericValue() */ public double getNumericValue() throws PropertyException { - return getResolved().getNumericValue(); + return getResolved(null).getNumericValue(null); + } + + /** + * Return the value. + * @param Evaluation context + * @see Numeric#getNumericValue(Object) + */ + public double getNumericValue(PercentBaseContext context) throws PropertyException { + return getResolved(context).getNumericValue(context); } /** @@ -175,6 +187,19 @@ public class RelativeNumericProperty extends Property implements Numeric, Length } /** + * Return the value of this numeric as a length in millipoints. + * @param Evaluation context + */ + public int getValue(PercentBaseContext context) { + try { + return (int) getNumericValue(context); + } catch (PropertyException exc) { + log.error(exc); + } + return 0; + } + + /** * Return a string represention of the expression. Only used for debugging. */ public String toString() { diff --git a/src/java/org/apache/fop/fo/flow/ExternalGraphic.java b/src/java/org/apache/fop/fo/flow/ExternalGraphic.java index eeaa5080a..5dbc1606c 100644 --- a/src/java/org/apache/fop/fo/flow/ExternalGraphic.java +++ b/src/java/org/apache/fop/fo/flow/ExternalGraphic.java @@ -280,19 +280,6 @@ public class ExternalGraphic extends FObj { } /** - * @see org.apache.fop.fo.FObj#getLayoutDimension(org.apache.fop.datatypes.PercentBase.LayoutDimension) - */ - public Number getLayoutDimension(PercentBase.LayoutDimension key) { - if (key == PercentBase.IMAGE_INTRINSIC_WIDTH) { - return new Integer(getIntrinsicWidth()); - } else if (key == PercentBase.IMAGE_INTRINSIC_HEIGHT) { - return new Integer(getIntrinsicHeight()); - } else { - return super.getLayoutDimension(key); - } - } - - /** * @see org.apache.fop.fo.IntrinsicSizeAccess#getIntrinsicWidth() */ public int getIntrinsicWidth() { diff --git a/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java b/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java index 5c67135ef..070162ed0 100644 --- a/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java +++ b/src/java/org/apache/fop/fo/flow/InstreamForeignObject.java @@ -285,17 +285,6 @@ public class InstreamForeignObject extends FObj { return FO_INSTREAM_FOREIGN_OBJECT; } - /** @see org.apache.fop.fo.FObj */ - public Number getLayoutDimension(PercentBase.LayoutDimension key) { - if (key == PercentBase.IMAGE_INTRINSIC_WIDTH) { - return new Integer(getIntrinsicWidth()); - } else if (key == PercentBase.IMAGE_INTRINSIC_HEIGHT) { - return new Integer(getIntrinsicHeight()); - } else { - return super.getLayoutDimension(key); - } - } - /** * Preloads the image so the intrinsic size is available. */ diff --git a/src/java/org/apache/fop/fo/flow/Table.java b/src/java/org/apache/fop/fo/flow/Table.java index bb9f126e2..4b0dd7a7c 100644 --- a/src/java/org/apache/fop/fo/flow/Table.java +++ b/src/java/org/apache/fop/fo/flow/Table.java @@ -132,11 +132,13 @@ public class Table extends FObj { PropertyList colPList = new StaticPropertyList(defaultColumn, pList); colPList.setWritingMode(); defaultColumn.bind(colPList); - + + /* TODO hasPadding requires context for evaluation - need to move this to layout if (borderCollapse != EN_SEPARATE && commonBorderPaddingBackground.hasPadding()) { //See "17.6.2 The collapsing border model" in CSS2 getLogger().error("Table may not have padding when using the collapsing border model."); } + */ if (borderCollapse != EN_SEPARATE) { getLogger().warn("The collapsing border model on an fo:table " + "is currently not supported by FOP"); diff --git a/src/java/org/apache/fop/fo/flow/TableCell.java b/src/java/org/apache/fop/fo/flow/TableCell.java index 3951c3515..b3583d37f 100644 --- a/src/java/org/apache/fop/fo/flow/TableCell.java +++ b/src/java/org/apache/fop/fo/flow/TableCell.java @@ -188,95 +188,97 @@ public class TableCell extends FObj { * Calculate cell border and padding, including offset of content * rectangle from the theoretical grid position. */ - private void calcBorders(CommonBorderPaddingBackground bp) { - if (this.borderCollapse == EN_SEPARATE) { - /* - * Easy case. - * Cell border is the property specified directly on cell. - * Offset content rect by half the border-separation value, - * in addition to the border and padding values. Note: - * border-separate should only be specified on the table object, - * but it inherits. - */ - int iSep = borderSeparation.getIPD().getLength().getValue(); - this.startAdjust = iSep / 2 + bp.getBorderStartWidth(false) - + bp.getPaddingStart(false); - - this.widthAdjust = startAdjust + iSep - iSep / 2 - + bp.getBorderEndWidth(false) - + bp.getPaddingEnd(false); - - // Offset of content rectangle in the block-progression direction - int bSep = borderSeparation.getBPD().getLength().getValue(); - this.beforeOffset = bSep / 2 - + bp.getBorderBeforeWidth(false) - + bp.getPaddingBefore(false); - - } else { - // System.err.println("Collapse borders"); - /* - * Hard case. - * Cell border is combination of other cell borders, or table - * border for edge cells. Also seems to border values specified - * on row and column FO in the table (if I read CR correclty.) - */ - - // Set up before and after borders, taking into account row - // and table border properties. - // ??? What about table-body, header,footer - - /* - * We can't calculate before and after because we aren't sure - * whether this row will be the first or last in its area, due - * to redoing break decisions (at least in the "new" architecture.) - * So in the general case, we will calculate two possible values: - * the first/last one and the "middle" one. - * Example: border-before - * 1. If the cell is in the first row in the first table body, it - * will combine with the last row of the header, or with the - * top (before) table border if there is no header. - * 2. Otherwise there are two cases: - * a. the row is first in its (non-first) Area. - * The border can combine with either: - * i. the last row of table-header and its cells, or - * ii. the table before border (no table-header or it is - * omitted on non-first Areas). - * b. the row isn't first in its Area. - * The border combines with the border of the previous - * row and the cells which end in that row. - */ - - /* - * if-first - * Calculate the effective border of the cell before-border, - * it's parent row before-border, the last header row after-border, - * the after border of the cell(s) which end in the last header - * row. - */ - /* - * if-not-first - * Calculate the effective border of the cell before-border, - * it's parent row before-border, the previous row after-border, - * the after border of the cell(s) which end in the previous - * row. - */ - - - /* ivan demakov */ - int borderStart = bp.getBorderStartWidth(false); - int borderEnd = bp.getBorderEndWidth(false); - int borderBefore = bp.getBorderBeforeWidth(false); - int borderAfter = bp.getBorderAfterWidth(false); - - this.startAdjust = borderStart / 2 + bp.getPaddingStart(false); - - this.widthAdjust = startAdjust + borderEnd / 2 - + bp.getPaddingEnd(false); - this.beforeOffset = borderBefore / 2 + bp.getPaddingBefore(false); - // Half border height to fix overestimate of area size! - this.borderHeight = (borderBefore + borderAfter) / 2; - } - } +// TODO This whole method is not used it refers to padding which requires layout +// context to evaluate +// private void calcBorders(CommonBorderPaddingBackground bp) { +// if (this.borderCollapse == EN_SEPARATE) { +// /* +// * Easy case. +// * Cell border is the property specified directly on cell. +// * Offset content rect by half the border-separation value, +// * in addition to the border and padding values. Note: +// * border-separate should only be specified on the table object, +// * but it inherits. +// */ +// int iSep = borderSeparation.getIPD().getLength().getValue(); +// this.startAdjust = iSep / 2 + bp.getBorderStartWidth(false) +// + bp.getPaddingStart(false); +// +// this.widthAdjust = startAdjust + iSep - iSep / 2 +// + bp.getBorderEndWidth(false) +// + bp.getPaddingEnd(false); +// +// // Offset of content rectangle in the block-progression direction +// int bSep = borderSeparation.getBPD().getLength().getValue(); +// this.beforeOffset = bSep / 2 +// + bp.getBorderBeforeWidth(false) +// + bp.getPaddingBefore(false); +// +// } else { +// // System.err.println("Collapse borders"); +// /* +// * Hard case. +// * Cell border is combination of other cell borders, or table +// * border for edge cells. Also seems to border values specified +// * on row and column FO in the table (if I read CR correclty.) +// */ +// +// // Set up before and after borders, taking into account row +// // and table border properties. +// // ??? What about table-body, header,footer +// +// /* +// * We can't calculate before and after because we aren't sure +// * whether this row will be the first or last in its area, due +// * to redoing break decisions (at least in the "new" architecture.) +// * So in the general case, we will calculate two possible values: +// * the first/last one and the "middle" one. +// * Example: border-before +// * 1. If the cell is in the first row in the first table body, it +// * will combine with the last row of the header, or with the +// * top (before) table border if there is no header. +// * 2. Otherwise there are two cases: +// * a. the row is first in its (non-first) Area. +// * The border can combine with either: +// * i. the last row of table-header and its cells, or +// * ii. the table before border (no table-header or it is +// * omitted on non-first Areas). +// * b. the row isn't first in its Area. +// * The border combines with the border of the previous +// * row and the cells which end in that row. +// */ +// +// /* +// * if-first +// * Calculate the effective border of the cell before-border, +// * it's parent row before-border, the last header row after-border, +// * the after border of the cell(s) which end in the last header +// * row. +// */ +// /* +// * if-not-first +// * Calculate the effective border of the cell before-border, +// * it's parent row before-border, the previous row after-border, +// * the after border of the cell(s) which end in the previous +// * row. +// */ +// +// +// /* ivan demakov */ +// int borderStart = bp.getBorderStartWidth(false); +// int borderEnd = bp.getBorderEndWidth(false); +// int borderBefore = bp.getBorderBeforeWidth(false); +// int borderAfter = bp.getBorderAfterWidth(false); +// +// this.startAdjust = borderStart / 2 + bp.getPaddingStart(false); +// +// this.widthAdjust = startAdjust + borderEnd / 2 +// + bp.getPaddingEnd(false); +// this.beforeOffset = borderBefore / 2 + bp.getPaddingBefore(false); +// // Half border height to fix overestimate of area size! +// this.borderHeight = (borderBefore + borderAfter) / 2; +// } +// } /** * @return the Common Border, Padding, and Background Properties. diff --git a/src/java/org/apache/fop/fo/pagination/Region.java b/src/java/org/apache/fop/fo/pagination/Region.java index 0d3aa6991..4980d057e 100644 --- a/src/java/org/apache/fop/fo/pagination/Region.java +++ b/src/java/org/apache/fop/fo/pagination/Region.java @@ -81,8 +81,8 @@ public abstract class Region extends FObj { } } - if (getCommonBorderPaddingBackground().getBPPaddingAndBorder(false) != 0 - || getCommonBorderPaddingBackground().getIPPaddingAndBorder(false) != 0) { + if (getCommonBorderPaddingBackground().getBPPaddingAndBorder(false, null) != 0 //TODO do we need context here? + || getCommonBorderPaddingBackground().getIPPaddingAndBorder(false, null) != 0) { //TODO do we need context here? throw new PropertyException("Border and padding for a region " + "must be '0' (See 6.4.13 in XSL 1.0)."); } @@ -99,9 +99,11 @@ public abstract class Region extends FObj { /** * @param pageRefRect reference dimension of the page area. + * @param pageViewRectRect page view port dimensions. * @return the rectangle for the viewport area */ - public abstract Rectangle getViewportRectangle(FODimension pageRefRect); + public abstract Rectangle getViewportRectangle(FODimension pageRefRect + , FODimension pageViewPortRect); /** * Returns the default region name (xsl-region-before, xsl-region-start, diff --git a/src/java/org/apache/fop/fo/pagination/RegionAfter.java b/src/java/org/apache/fop/fo/pagination/RegionAfter.java index dc8fafd36..68d6d066d 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionAfter.java +++ b/src/java/org/apache/fop/fo/pagination/RegionAfter.java @@ -24,6 +24,8 @@ import java.awt.Rectangle; // FOP import org.apache.fop.fo.FONode; import org.apache.fop.datatypes.FODimension; +import org.apache.fop.datatypes.LengthBase; +import org.apache.fop.datatypes.SimplePercentBaseContext; /** * The fo:region-after element. @@ -40,16 +42,29 @@ public class RegionAfter extends RegionBA { /** * @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension) */ - public Rectangle getViewportRectangle (FODimension reldims) { + public Rectangle getViewportRectangle (FODimension reldims, FODimension pageViewPortRect) { // Depends on extent, precedence ans writing mode + /* Special rules apply to resolving extent. + * In the property subsystem the extent property is configured to + * using BLOCK_WIDTH as its percent base. + * However, depending on the writing mode extent import resolved either + * against the page width or the page height. + */ Rectangle vpRect; + SimplePercentBaseContext pageWidthContext + = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, pageViewPortRect.ipd); + SimplePercentBaseContext pageHeightContext + = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, pageViewPortRect.bpd); + SimplePercentBaseContext neighbourContext; if (getWritingMode() == EN_LR_TB || getWritingMode() == EN_RL_TB) { - vpRect = new Rectangle(0, reldims.bpd - getExtent().getValue(), reldims.ipd, getExtent().getValue()); + neighbourContext = pageWidthContext; + vpRect = new Rectangle(0, reldims.bpd - getExtent().getValue(pageHeightContext), reldims.ipd, getExtent().getValue(pageHeightContext)); } else { - vpRect = new Rectangle(0, reldims.bpd - getExtent().getValue(), getExtent().getValue(), reldims.ipd); + neighbourContext = pageHeightContext; + vpRect = new Rectangle(0, reldims.bpd - getExtent().getValue(pageWidthContext), getExtent().getValue(pageWidthContext), reldims.ipd); } if (getPrecedence() == EN_FALSE) { - adjustIPD(vpRect, getWritingMode()); + adjustIPD(vpRect, getWritingMode(), neighbourContext); } return vpRect; } diff --git a/src/java/org/apache/fop/fo/pagination/RegionBA.java b/src/java/org/apache/fop/fo/pagination/RegionBA.java index 6d35dae20..f732c721f 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionBA.java +++ b/src/java/org/apache/fop/fo/pagination/RegionBA.java @@ -22,6 +22,7 @@ package org.apache.fop.fo.pagination; import java.awt.Rectangle; import org.apache.fop.apps.FOPException; +import org.apache.fop.datatypes.PercentBaseContext; import org.apache.fop.fo.FONode; import org.apache.fop.fo.PropertyList; @@ -63,17 +64,18 @@ public abstract class RegionBA extends SideRegion { * and end regions if they are present. * @param vpRefRect viewport reference rectangle * @param wm writing mode + * @param siblingContext the context to use to resolve extent on siblings */ - protected void adjustIPD(Rectangle vpRefRect, int wm) { + protected void adjustIPD(Rectangle vpRefRect, int wm, PercentBaseContext siblingContext) { int offset = 0; RegionStart start = (RegionStart) getSiblingRegion(FO_REGION_START); if (start != null) { - offset = start.getExtent().getValue(); + offset = start.getExtent().getValue(siblingContext); vpRefRect.translate(offset, 0); // move (x, y) units } RegionEnd end = (RegionEnd) getSiblingRegion(FO_REGION_END); if (end != null) { - offset += end.getExtent().getValue(); + offset += end.getExtent().getValue(siblingContext); } if (offset > 0) { if (wm == EN_LR_TB || wm == EN_RL_TB) { diff --git a/src/java/org/apache/fop/fo/pagination/RegionBefore.java b/src/java/org/apache/fop/fo/pagination/RegionBefore.java index 19607f9b1..c1f683c05 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionBefore.java +++ b/src/java/org/apache/fop/fo/pagination/RegionBefore.java @@ -23,6 +23,8 @@ import java.awt.Rectangle; // FOP import org.apache.fop.datatypes.FODimension; +import org.apache.fop.datatypes.LengthBase; +import org.apache.fop.datatypes.SimplePercentBaseContext; import org.apache.fop.fo.FONode; /** @@ -46,21 +48,34 @@ public class RegionBefore extends RegionBA { /** * @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension) */ - public Rectangle getViewportRectangle (FODimension reldims) { + public Rectangle getViewportRectangle (FODimension reldims, FODimension pageViewPortRect) { // Depends on extent, precedence and writing mode // This should return rectangle in writing-mode coordinates relative // to the page-reference area rectangle // This means the origin is (start, before) and the dimensions are (ipd,bpd) // Before is always 0, start depends on extent // ipd depends on precedence, bpd=extent + /* Special rules apply to resolving extent. + * In the property subsystem the extent property is configured to + * using BLOCK_WIDTH as its percent base. + * However, depending on the writing mode extent import resolved either + * against the page width or the page height. + */ Rectangle vpRect; + SimplePercentBaseContext pageWidthContext + = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, pageViewPortRect.ipd); + SimplePercentBaseContext pageHeightContext + = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, pageViewPortRect.bpd); + SimplePercentBaseContext neighbourContext; if (getWritingMode() == EN_LR_TB || getWritingMode() == EN_RL_TB) { - vpRect = new Rectangle(0, 0, reldims.ipd, getExtent().getValue()); + neighbourContext = pageWidthContext; + vpRect = new Rectangle(0, 0, reldims.ipd, getExtent().getValue(pageHeightContext)); } else { - vpRect = new Rectangle(0, 0, getExtent().getValue(), reldims.ipd); + neighbourContext = pageHeightContext; + vpRect = new Rectangle(0, 0, getExtent().getValue(pageWidthContext), reldims.ipd); } if (getPrecedence() == EN_FALSE) { - adjustIPD(vpRect, getWritingMode()); + adjustIPD(vpRect, getWritingMode(), neighbourContext); } return vpRect; } diff --git a/src/java/org/apache/fop/fo/pagination/RegionBody.java b/src/java/org/apache/fop/fo/pagination/RegionBody.java index 00acca4da..835802469 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionBody.java +++ b/src/java/org/apache/fop/fo/pagination/RegionBody.java @@ -24,7 +24,9 @@ import java.awt.Rectangle; import org.apache.fop.apps.FOPException; import org.apache.fop.datatypes.FODimension; import org.apache.fop.datatypes.Length; +import org.apache.fop.datatypes.LengthBase; import org.apache.fop.datatypes.Numeric; +import org.apache.fop.datatypes.SimplePercentBaseContext; import org.apache.fop.fo.FONode; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.properties.CommonMarginBlock; @@ -90,11 +92,24 @@ public class RegionBody extends Region { /** * @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension) */ - public Rectangle getViewportRectangle (FODimension reldims) { - int left = commonMarginBlock.marginLeft.getValue(); - int right = commonMarginBlock.marginRight.getValue(); - int top = commonMarginBlock.marginTop.getValue(); - int bottom = commonMarginBlock.marginBottom.getValue(); + public Rectangle getViewportRectangle (FODimension reldims, FODimension pageViewPortRect) { + /* Special rules apply to resolving margins in the page context. + * Contrary to normal margins in this case top and bottom margin + * are resolved relative to the height. In the property subsystem + * all margin properties are configured to using BLOCK_WIDTH. + * That's why we 'cheat' here and setup a context for the height but + * use the LengthBase.BLOCK_WIDTH. + * Also the values are resolved relative to the page size. + */ + SimplePercentBaseContext pageWidthContext + = new SimplePercentBaseContext(null, LengthBase.CONTAINING_BLOCK_WIDTH, pageViewPortRect.ipd); + SimplePercentBaseContext pageHeightContext + = new SimplePercentBaseContext(null, LengthBase.CONTAINING_BLOCK_WIDTH, pageViewPortRect.bpd); + + int left = commonMarginBlock.marginLeft.getValue(pageWidthContext); + int right = commonMarginBlock.marginRight.getValue(pageWidthContext); + int top = commonMarginBlock.marginTop.getValue(pageHeightContext); + int bottom = commonMarginBlock.marginBottom.getValue(pageHeightContext); return new Rectangle(left, top, reldims.ipd - left - right, reldims.bpd - top - bottom); diff --git a/src/java/org/apache/fop/fo/pagination/RegionEnd.java b/src/java/org/apache/fop/fo/pagination/RegionEnd.java index e4aff17e6..a097ec375 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionEnd.java +++ b/src/java/org/apache/fop/fo/pagination/RegionEnd.java @@ -24,6 +24,8 @@ import java.awt.Rectangle; // FOP import org.apache.fop.fo.FONode; import org.apache.fop.datatypes.FODimension; +import org.apache.fop.datatypes.LengthBase; +import org.apache.fop.datatypes.SimplePercentBaseContext; /** * The fo:region-end element. @@ -39,19 +41,31 @@ public class RegionEnd extends RegionSE { /** * @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension) */ - public Rectangle getViewportRectangle (FODimension reldims) { + public Rectangle getViewportRectangle (FODimension reldims, FODimension pageViewPortRect) { // Depends on extent, precedence and writing mode + /* Special rules apply to resolving extent. + * In the property subsystem the extent property is configured to + * using BLOCK_WIDTH as its percent base. + * However, depending on the writing mode extent import resolved either + * against the page width or the page height. + */ Rectangle vpRect; + SimplePercentBaseContext pageWidthContext + = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, pageViewPortRect.ipd); + SimplePercentBaseContext pageHeightContext + = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, pageViewPortRect.bpd); + SimplePercentBaseContext neighbourContext; if (getWritingMode() == EN_LR_TB || getWritingMode() == EN_RL_TB) { - // Rectangle: x , y (of top left point), width, height - vpRect = new Rectangle(reldims.ipd - getExtent().getValue(), 0, - getExtent().getValue(), reldims.bpd); + neighbourContext = pageHeightContext; + vpRect = new Rectangle(reldims.ipd - getExtent().getValue(pageWidthContext), 0, + getExtent().getValue(pageWidthContext), reldims.bpd); } else { // Rectangle: x , y (of top left point), width, height - vpRect = new Rectangle(reldims.ipd - getExtent().getValue(), 0, - reldims.bpd, getExtent().getValue()); + neighbourContext = pageWidthContext; + vpRect = new Rectangle(reldims.ipd - getExtent().getValue(pageHeightContext), 0, + reldims.bpd, getExtent().getValue(pageHeightContext)); } - adjustIPD(vpRect, getWritingMode()); + adjustIPD(vpRect, getWritingMode(), neighbourContext); return vpRect; } diff --git a/src/java/org/apache/fop/fo/pagination/RegionSE.java b/src/java/org/apache/fop/fo/pagination/RegionSE.java index 9100c0981..4ab2ebd05 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionSE.java +++ b/src/java/org/apache/fop/fo/pagination/RegionSE.java @@ -22,6 +22,7 @@ package org.apache.fop.fo.pagination; import java.awt.Rectangle; import org.apache.fop.apps.FOPException; +import org.apache.fop.datatypes.PercentBaseContext; import org.apache.fop.fo.FONode; import org.apache.fop.fo.PropertyList; @@ -55,17 +56,18 @@ public abstract class RegionSE extends SideRegion { * diminish by extend of start and end if present. * @param vpRefRect viewport reference rectangle * @param wm writing mode + * @param siblingContext the context to use to resolve extent on siblings */ - protected void adjustIPD(Rectangle vpRefRect, int wm) { + protected void adjustIPD(Rectangle vpRefRect, int wm, PercentBaseContext siblingContext) { int offset = 0; RegionBefore before = (RegionBefore) getSiblingRegion(FO_REGION_BEFORE); if (before != null && before.getPrecedence() == EN_TRUE) { - offset = before.getExtent().getValue(); + offset = before.getExtent().getValue(siblingContext); vpRefRect.translate(0, offset); } RegionAfter after = (RegionAfter) getSiblingRegion(FO_REGION_AFTER); if (after != null && after.getPrecedence() == EN_TRUE) { - offset += after.getExtent().getValue(); + offset += after.getExtent().getValue(siblingContext); } if (offset > 0) { if (wm == EN_LR_TB || wm == EN_RL_TB) { diff --git a/src/java/org/apache/fop/fo/pagination/RegionStart.java b/src/java/org/apache/fop/fo/pagination/RegionStart.java index 9668dceeb..2de7cc68f 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionStart.java +++ b/src/java/org/apache/fop/fo/pagination/RegionStart.java @@ -24,6 +24,8 @@ import java.awt.Rectangle; // FOP import org.apache.fop.fo.FONode; import org.apache.fop.datatypes.FODimension; +import org.apache.fop.datatypes.LengthBase; +import org.apache.fop.datatypes.SimplePercentBaseContext; /** * The fo:region-start element. @@ -39,17 +41,30 @@ public class RegionStart extends RegionSE { /** * @see org.apache.fop.fo.pagination.Region#getViewportRectangle(FODimension) */ - public Rectangle getViewportRectangle (FODimension reldims) { + public Rectangle getViewportRectangle (FODimension reldims, FODimension pageViewPortRect) { // Depends on extent, precedence and writing mode // This is the rectangle relative to the page-reference area in // writing-mode relative coordinates + /* Special rules apply to resolving extent. + * In the property subsystem the extent property is configured to + * using BLOCK_WIDTH as its percent base. + * However, depending on the writing mode extent import resolved either + * against the page width or the page height. + */ Rectangle vpRect; + SimplePercentBaseContext pageWidthContext + = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, pageViewPortRect.ipd); + SimplePercentBaseContext pageHeightContext + = new SimplePercentBaseContext(null, LengthBase.CUSTOM_BASE, pageViewPortRect.bpd); + SimplePercentBaseContext neighbourContext; if (getWritingMode() == EN_LR_TB || getWritingMode() == EN_RL_TB) { - vpRect = new Rectangle(0, 0, getExtent().getValue(), reldims.bpd); + neighbourContext = pageHeightContext; + vpRect = new Rectangle(0, 0, getExtent().getValue(pageWidthContext), reldims.bpd); } else { - vpRect = new Rectangle(0, 0, reldims.bpd, getExtent().getValue()); + neighbourContext = pageWidthContext; + vpRect = new Rectangle(0, 0, reldims.bpd, getExtent().getValue(pageHeightContext)); } - adjustIPD(vpRect, getWritingMode()); + adjustIPD(vpRect, getWritingMode(), neighbourContext); return vpRect; } diff --git a/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java b/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java index f60b37bca..ecdec78c8 100755 --- a/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java +++ b/src/java/org/apache/fop/fo/properties/CommonBorderPaddingBackground.java @@ -20,6 +20,7 @@ package org.apache.fop.fo.properties; import org.apache.fop.datatypes.ColorType; import org.apache.fop.datatypes.Length; +import org.apache.fop.datatypes.PercentBaseContext; import org.apache.fop.fo.Constants; import org.apache.fop.fo.FObj; import org.apache.fop.fo.PropertyList; @@ -224,6 +225,14 @@ public class CommonBorderPaddingBackground implements Cloneable { } /** + * Set padding. + * @param source the padding info to copy from + */ + public void setPadding(CommonBorderPaddingBackground source) { + this.padding = source.padding; + } + + /** * @return the background image as a preloaded FopImage, null if there is * no background image. */ @@ -247,20 +256,20 @@ public class CommonBorderPaddingBackground implements Cloneable { return getBorderWidth(AFTER, bDiscard); } - public int getPaddingStart(boolean bDiscard) { - return getPadding(START, bDiscard); + public int getPaddingStart(boolean bDiscard, PercentBaseContext context) { + return getPadding(START, bDiscard, context); } - public int getPaddingEnd(boolean bDiscard) { - return getPadding(END, bDiscard); + public int getPaddingEnd(boolean bDiscard, PercentBaseContext context) { + return getPadding(END, bDiscard, context); } - public int getPaddingBefore(boolean bDiscard) { - return getPadding(BEFORE, bDiscard); + public int getPaddingBefore(boolean bDiscard, PercentBaseContext context) { + return getPadding(BEFORE, bDiscard, context); } - public int getPaddingAfter(boolean bDiscard) { - return getPadding(AFTER, bDiscard); + public int getPaddingAfter(boolean bDiscard, PercentBaseContext context) { + return getPadding(AFTER, bDiscard, context); } public int getBorderWidth(int side, boolean bDiscard) { @@ -290,11 +299,11 @@ public class CommonBorderPaddingBackground implements Cloneable { } } - public int getPadding(int side, boolean bDiscard) { + public int getPadding(int side, boolean bDiscard, PercentBaseContext context) { if ((padding[side] == null) || (bDiscard && padding[side].isDiscard())) { return 0; } else { - return padding[side].getLengthValue(); + return padding[side].getLengthValue(context); } } @@ -302,11 +311,12 @@ public class CommonBorderPaddingBackground implements Cloneable { * Return all the border and padding width in the inline progression * dimension. * @param bDiscard the discard flag. + * @param context for percentage evaluation. * @return all the padding and border width. */ - public int getIPPaddingAndBorder(boolean bDiscard) { - return getPaddingStart(bDiscard) - + getPaddingEnd(bDiscard) + public int getIPPaddingAndBorder(boolean bDiscard, PercentBaseContext context) { + return getPaddingStart(bDiscard, context) + + getPaddingEnd(bDiscard, context) + getBorderStartWidth(bDiscard) + getBorderEndWidth(bDiscard); } @@ -315,10 +325,11 @@ public class CommonBorderPaddingBackground implements Cloneable { * Return all the border and padding height in the block progression * dimension. * @param bDiscard the discard flag. + * @param context for percentage evaluation * @return all the padding and border height. */ - public int getBPPaddingAndBorder(boolean bDiscard) { - return getPaddingBefore(bDiscard) + getPaddingAfter(bDiscard) + + public int getBPPaddingAndBorder(boolean bDiscard, PercentBaseContext context) { + return getPaddingBefore(bDiscard, context) + getPaddingAfter(bDiscard, context) + getBorderBeforeWidth(bDiscard) + getBorderAfterWidth(bDiscard); } @@ -328,8 +339,8 @@ public class CommonBorderPaddingBackground implements Cloneable { getBorderStartWidth(false) + ", " + getBorderEndWidth(false) + ")\n" + "Border Colors: (" + getBorderColor(BEFORE) + ", " + getBorderColor(AFTER) + ", " + getBorderColor(START) + ", " + getBorderColor(END) + ")\n" + - "Padding: (" + getPaddingBefore(false) + ", " + getPaddingAfter(false) + ", " + - getPaddingStart(false) + ", " + getPaddingEnd(false) + ")\n"; + "Padding: (" + getPaddingBefore(false, null) + ", " + getPaddingAfter(false, null) + ", " + + getPaddingStart(false, null) + ", " + getPaddingEnd(false, null) + ")\n"; } /** @@ -345,9 +356,12 @@ public class CommonBorderPaddingBackground implements Cloneable { + getBorderStartWidth(false) + getBorderEndWidth(false)) > 0); } - /** @return true if padding is non-zero. */ - public boolean hasPadding() { - return ((getPaddingBefore(false) + getPaddingAfter(false) - + getPaddingStart(false) + getPaddingEnd(false)) > 0); + /** + * @param context for percentage based evaluation. + * @return true if padding is non-zero. + */ + public boolean hasPadding(PercentBaseContext context) { + return ((getPaddingBefore(false, context) + getPaddingAfter(false, context) + + getPaddingStart(false, context) + getPaddingEnd(false, context)) > 0); } } diff --git a/src/java/org/apache/fop/fo/properties/CommonFont.java b/src/java/org/apache/fop/fo/properties/CommonFont.java index 77fbe53c1..c24c0c941 100755 --- a/src/java/org/apache/fop/fo/properties/CommonFont.java +++ b/src/java/org/apache/fop/fo/properties/CommonFont.java @@ -21,6 +21,7 @@ package org.apache.fop.fo.properties; // FOP import org.apache.fop.datatypes.Length; import org.apache.fop.datatypes.Numeric; +import org.apache.fop.datatypes.PercentBaseContext; import org.apache.fop.fo.Constants; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.expr.PropertyException; @@ -96,7 +97,7 @@ public class CommonFont { * @param fontInfo * @return a Font object. */ - public Font getFontState(FontInfo fontInfo) { + public Font getFontState(FontInfo fontInfo, PercentBaseContext context) { if (fontState == null) { /**@todo this is ugly. need to improve. */ @@ -124,7 +125,7 @@ public class CommonFont { String fname = fontInfo.fontLookup(fontFamily, fontStyle, font_weight); FontMetrics metrics = fontInfo.getMetricsFor(fname); - fontState = new Font(fname, metrics, fontSize.getValue()); + fontState = new Font(fname, metrics, fontSize.getValue(context)); } return fontState; } diff --git a/src/java/org/apache/fop/fo/properties/CommonMarginBlock.java b/src/java/org/apache/fop/fo/properties/CommonMarginBlock.java index d049d275a..8875de051 100644 --- a/src/java/org/apache/fop/fo/properties/CommonMarginBlock.java +++ b/src/java/org/apache/fop/fo/properties/CommonMarginBlock.java @@ -22,6 +22,7 @@ import org.apache.fop.datatypes.Length; import org.apache.fop.fo.Constants; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.expr.PropertyException; +import org.apache.fop.fo.expr.RelativeNumericProperty; /** * Store all common margin properties for blocks. diff --git a/src/java/org/apache/fop/fo/properties/CondLengthProperty.java b/src/java/org/apache/fop/fo/properties/CondLengthProperty.java index b14f12df3..0253e8a81 100644 --- a/src/java/org/apache/fop/fo/properties/CondLengthProperty.java +++ b/src/java/org/apache/fop/fo/properties/CondLengthProperty.java @@ -20,6 +20,7 @@ package org.apache.fop.fo.properties; import org.apache.fop.datatypes.CompoundDatatype; import org.apache.fop.datatypes.Length; +import org.apache.fop.datatypes.PercentBaseContext; import org.apache.fop.fo.Constants; import org.apache.fop.fo.FObj; import org.apache.fop.fo.PropertyList; @@ -122,6 +123,14 @@ public class CondLengthProperty extends Property implements CompoundDatatype { return this.length.getLength().getValue(); } + /** + * Returns the computed length value. + * @return the length in millipoints + */ + public int getLengthValue(PercentBaseContext context) { + return this.length.getLength().getValue(context); + } + public String toString() { return "CondLength[" + (isDiscard() ? "discard, " : "") + length.getObject().toString() + "]"; diff --git a/src/java/org/apache/fop/fo/properties/EnumLength.java b/src/java/org/apache/fop/fo/properties/EnumLength.java index 2d45a1966..04efebaa6 100755 --- a/src/java/org/apache/fop/fo/properties/EnumLength.java +++ b/src/java/org/apache/fop/fo/properties/EnumLength.java @@ -18,6 +18,8 @@ package org.apache.fop.fo.properties; +import org.apache.fop.datatypes.PercentBaseContext; + /** * A length quantity in XSL which is specified as an enum, such as "auto" */ @@ -38,6 +40,7 @@ public class EnumLength extends LengthProperty { public boolean isAbsolute() { return false; } + /** * Returns the length in 1/1000ths of a point (millipoints) * @return the length in millipoints @@ -48,6 +51,16 @@ public class EnumLength extends LengthProperty { } /** + * Returns the length in 1/1000ths of a point (millipoints) + * @param Evaluation context + * @return the length in millipoints + */ + public int getValue(PercentBaseContext context) { + log.error("getValue() called on " + enumProperty + " length"); + return 0; + } + + /** * Returns the value as numeric. * @return the length in millipoints */ @@ -57,6 +70,16 @@ public class EnumLength extends LengthProperty { } /** + * Returns the value as numeric. + * @param context Evaluation context + * @return the length in millipoints + */ + public double getNumericValue(PercentBaseContext context) { + log.error("getNumericValue() called on " + enumProperty + " number"); + return 0; + } + + /** * @see org.apache.fop.fo.properties.Property#getString() */ public String getString() { diff --git a/src/java/org/apache/fop/fo/properties/FixedLength.java b/src/java/org/apache/fop/fo/properties/FixedLength.java index cba009e57..347051990 100644 --- a/src/java/org/apache/fop/fo/properties/FixedLength.java +++ b/src/java/org/apache/fop/fo/properties/FixedLength.java @@ -18,6 +18,8 @@ package org.apache.fop.fo.properties; +import org.apache.fop.datatypes.PercentBaseContext; + /** * An absolute length quantity in XSL */ @@ -99,14 +101,34 @@ public class FixedLength extends LengthProperty { } /** + * Returns the length in 1/1000ths of a point (millipoints) + * @param Evaluation context + * @return the length in millipoints + */ + public int getValue(PercentBaseContext context) { + return millipoints; + } + + /** * Returns the value as numeric. * @return the length in millipoints + * @see Numeric#getNumericValue() */ public double getNumericValue() { return millipoints; } /** + * Return the value of this Numeric. + * @param context Evaluation context + * @return the length in millipoints + * @see Numeric#getNumericValue(Object) + */ + public double getNumericValue(PercentBaseContext context) { + return millipoints; + } + + /** * Return true since FixedLength are always absolute. * @see org.apache.fop.datatypes.Numeric#isAbsolute() */ diff --git a/src/java/org/apache/fop/fo/properties/FontSizePropertyMaker.java b/src/java/org/apache/fop/fo/properties/FontSizePropertyMaker.java index 83379dfa4..3719c72d4 100644 --- a/src/java/org/apache/fop/fo/properties/FontSizePropertyMaker.java +++ b/src/java/org/apache/fop/fo/properties/FontSizePropertyMaker.java @@ -17,10 +17,14 @@ /* $Id: $ */ package org.apache.fop.fo.properties; +import org.apache.fop.datatypes.Length; +import org.apache.fop.datatypes.LengthBase; +import org.apache.fop.datatypes.SimplePercentBaseContext; import org.apache.fop.fo.Constants; import org.apache.fop.fo.FObj; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.expr.PropertyException; +import org.apache.fop.fo.expr.RelativeNumericProperty; /** * This subclass of LengthProperty.Maker handles the special treatment of diff --git a/src/java/org/apache/fop/fo/properties/LengthRangeProperty.java b/src/java/org/apache/fop/fo/properties/LengthRangeProperty.java index 732f99e14..37e40028b 100644 --- a/src/java/org/apache/fop/fo/properties/LengthRangeProperty.java +++ b/src/java/org/apache/fop/fo/properties/LengthRangeProperty.java @@ -19,6 +19,7 @@ package org.apache.fop.fo.properties; import org.apache.fop.datatypes.CompoundDatatype; +import org.apache.fop.datatypes.PercentBaseContext; import org.apache.fop.fo.FObj; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.expr.PropertyException; @@ -90,11 +91,11 @@ public class LengthRangeProperty extends Property implements CompoundDatatype { */ public Property getComponent(int cmpId) { if (cmpId == CP_MINIMUM) { - return getMinimum(); + return getMinimum(null); } else if (cmpId == CP_OPTIMUM) { - return getOptimum(); + return getOptimum(null); } else if (cmpId == CP_MAXIMUM) { - return getMaximum(); + return getMaximum(null); } else { return null; // SHOULDN'T HAPPEN } @@ -146,15 +147,18 @@ public class LengthRangeProperty extends Property implements CompoundDatatype { } // Minimum is prioritaire, if explicit - private void checkConsistency() { + private void checkConsistency(PercentBaseContext context) { if (consistent) { return; } + if (context == null) { + return; + } // Make sure max >= min // Must also control if have any allowed enum values! if (!minimum.isAuto() && !maximum.isAuto() - && minimum.getLength().getValue() > maximum.getLength().getValue()) { + && minimum.getLength().getValue(context) > maximum.getLength().getValue(context)) { if ((bfSet & MINSET) != 0) { // if minimum is explicit, force max to min if ((bfSet & MAXSET) != 0) { @@ -168,7 +172,7 @@ public class LengthRangeProperty extends Property implements CompoundDatatype { } // Now make sure opt <= max and opt >= min if (!optimum.isAuto() && !maximum.isAuto() - && optimum.getLength().getValue() > maximum.getLength().getValue()) { + && optimum.getLength().getValue(context) > maximum.getLength().getValue(context)) { if ((bfSet & OPTSET) != 0) { if ((bfSet & MAXSET) != 0) { // Warning: opt > max, resetting opt to max @@ -182,7 +186,7 @@ public class LengthRangeProperty extends Property implements CompoundDatatype { optimum = maximum; } } else if (!optimum.isAuto() && !minimum.isAuto() && - optimum.getLength().getValue() < minimum.getLength().getValue()) { + optimum.getLength().getValue(context) < minimum.getLength().getValue(context)) { if ((bfSet & MINSET) != 0) { // if minimum is explicit, force opt to min if ((bfSet & OPTSET) != 0) { @@ -198,34 +202,37 @@ public class LengthRangeProperty extends Property implements CompoundDatatype { } /** + * @param context Percentage evaluation context * @return minimum length */ - public Property getMinimum() { - checkConsistency(); + public Property getMinimum(PercentBaseContext context) { + checkConsistency(context); return this.minimum; } /** + * @param context Percentage evaluation context * @return maximum length */ - public Property getMaximum() { - checkConsistency(); + public Property getMaximum(PercentBaseContext context) { + checkConsistency(context); return this.maximum; } /** + * @param context Percentage evaluation context * @return optimum length */ - public Property getOptimum() { - checkConsistency(); + public Property getOptimum(PercentBaseContext context) { + checkConsistency(context); return this.optimum; } public String toString() { return "LengthRange[" + - "min:" + getMinimum().getObject() + - ", max:" + getMaximum().getObject() + - ", opt:" + getOptimum().getObject() + "]"; + "min:" + getMinimum(null).getObject() + + ", max:" + getMaximum(null).getObject() + + ", opt:" + getOptimum(null).getObject() + "]"; } /** diff --git a/src/java/org/apache/fop/fo/properties/LineHeightPropertyMaker.java b/src/java/org/apache/fop/fo/properties/LineHeightPropertyMaker.java index e1fa1215a..5c4507ae5 100644 --- a/src/java/org/apache/fop/fo/properties/LineHeightPropertyMaker.java +++ b/src/java/org/apache/fop/fo/properties/LineHeightPropertyMaker.java @@ -17,11 +17,14 @@ /* $Id$ */ package org.apache.fop.fo.properties; - +import org.apache.fop.datatypes.LengthBase; import org.apache.fop.datatypes.Numeric; +import org.apache.fop.datatypes.SimplePercentBaseContext; +import org.apache.fop.fo.Constants; import org.apache.fop.fo.FObj; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.expr.PropertyException; +import org.apache.fop.fo.expr.RelativeNumericProperty; /** * A maker which calculates the line-height property. @@ -60,10 +63,13 @@ public class LineHeightPropertyMaker extends SpaceProperty.Maker { return null; } + /** + * @see SpaceProperty#convertProperty(Property, PropertyList, FObj) + */ public Property convertProperty(Property p, PropertyList propertyList, FObj fo) throws PropertyException { - Numeric numval = p.getNumeric(); + Numeric numval = p.getNumeric(); if (numval != null && numval.getDimension() == 0) { p = new PercentLength(numval.getNumericValue(), getPercentBase(fo,propertyList)); Property spaceProp = super.convertProperty(p, propertyList, fo); diff --git a/src/java/org/apache/fop/fo/properties/NumberProperty.java b/src/java/org/apache/fop/fo/properties/NumberProperty.java index a93e68b55..268066c57 100644 --- a/src/java/org/apache/fop/fo/properties/NumberProperty.java +++ b/src/java/org/apache/fop/fo/properties/NumberProperty.java @@ -18,6 +18,7 @@ package org.apache.fop.fo.properties; +import org.apache.fop.datatypes.PercentBaseContext; import org.apache.fop.datatypes.Numeric; import org.apache.fop.fo.FObj; import org.apache.fop.fo.PropertyList; @@ -104,11 +105,31 @@ public class NumberProperty extends Property implements Numeric { return number.doubleValue(); } + /** + * Return the value of this Numeric. + * @param context Evaluation context + * @return The value as a double. + * @see Numeric#getNumericValue(Object) + */ + public double getNumericValue(PercentBaseContext context) { + return getNumericValue(); + } + public int getValue() { return number.intValue(); } /** + * Return the value + * @param context Evaluation context + * @return The value as an int. + * @see Numeric#getValue(Object) + */ + public int getValue(PercentBaseContext context) { + return getValue(); + } + + /** * Return true because all numbers are absolute. * @return true. * @see Numeric#isAbsolute() diff --git a/src/java/org/apache/fop/fo/properties/PercentLength.java b/src/java/org/apache/fop/fo/properties/PercentLength.java index 82c52adaf..ccad91d79 100644 --- a/src/java/org/apache/fop/fo/properties/PercentLength.java +++ b/src/java/org/apache/fop/fo/properties/PercentLength.java @@ -18,6 +18,7 @@ package org.apache.fop.fo.properties; +import org.apache.fop.datatypes.PercentBaseContext; import org.apache.fop.datatypes.PercentBase; import org.apache.fop.fo.expr.PropertyException; @@ -37,6 +38,8 @@ public class PercentLength extends LengthProperty { * {@link #factor} should be applied to compute the actual length */ private PercentBase lbase = null; + + private double resolvedValue; /** * Main constructor. Construct an object based on a factor (the percent, @@ -80,8 +83,19 @@ public class PercentLength extends LengthProperty { * @see org.apache.fop.datatypes.Numeric#getNumericValue() */ public double getNumericValue() { + return getNumericValue(null); + } + + /** + * Return the value of this Numeric. + * @param context Evaluation context + * @return the length in millipoints + * @see Numeric#getNumericValue(Object) + */ + public double getNumericValue(PercentBaseContext context) { try { - return factor * lbase.getBaseLength(); + resolvedValue = factor * lbase.getBaseLength(context); + return resolvedValue; } catch (PropertyException exc) { log.error(exc); return 0; @@ -97,6 +111,14 @@ public class PercentLength extends LengthProperty { } /** + * Return the value of this numeric as a length in millipoints. + * @param Evaluation context + */ + public int getValue(PercentBaseContext context) { + return (int) getNumericValue(context); + } + + /** * @return the String equivalent of this */ public String toString() { diff --git a/src/java/org/apache/fop/fo/properties/PropertyMaker.java b/src/java/org/apache/fop/fo/properties/PropertyMaker.java index 51116fbaf..6f0d86bfb 100644 --- a/src/java/org/apache/fop/fo/properties/PropertyMaker.java +++ b/src/java/org/apache/fop/fo/properties/PropertyMaker.java @@ -308,7 +308,7 @@ public class PropertyMaker implements Cloneable { * what this is used for, or remove it from the signature.) * @return an object implementing the PercentBase interface. */ - public PercentBase getPercentBase(FObj fo, PropertyList pl) { + public PercentBase getPercentBase(FObj fo, PropertyList pl) throws PropertyException { if (percentBase == -1) return null; return new LengthBase(fo, pl, percentBase); diff --git a/src/java/org/apache/fop/fo/properties/SpaceProperty.java b/src/java/org/apache/fop/fo/properties/SpaceProperty.java index 2ef52a48f..45dce11a9 100644 --- a/src/java/org/apache/fop/fo/properties/SpaceProperty.java +++ b/src/java/org/apache/fop/fo/properties/SpaceProperty.java @@ -137,9 +137,9 @@ public class SpaceProperty extends LengthRangeProperty { public String toString() { return "Space[" + - "min:" + getMinimum().getObject() + - ", max:" + getMaximum().getObject() + - ", opt:" + getOptimum().getObject() + + "min:" + getMinimum(null).getObject() + + ", max:" + getMaximum(null).getObject() + + ", opt:" + getOptimum(null).getObject() + ", precedence:" + precedence.getObject() + ", conditionality:" + conditionality.getObject() + "]"; } diff --git a/src/java/org/apache/fop/fo/properties/TableColLength.java b/src/java/org/apache/fop/fo/properties/TableColLength.java index 78e2eac5f..a8cb201d3 100644 --- a/src/java/org/apache/fop/fo/properties/TableColLength.java +++ b/src/java/org/apache/fop/fo/properties/TableColLength.java @@ -18,6 +18,7 @@ package org.apache.fop.fo.properties; +import org.apache.fop.datatypes.PercentBaseContext; import org.apache.fop.datatypes.PercentBase; import org.apache.fop.fo.FObj; @@ -77,6 +78,16 @@ public class TableColLength extends LengthProperty { } /** + * Return the value of this Numeric. + * @param context Evaluation context + * @return the value + * @see Numeric#getNumericValue(Object) + */ + public double getNumericValue(PercentBaseContext context) { + return getNumericValue(); + } + + /** * Return the value as a length. * @see org.apache.fop.datatypes.Length#getValue() */ @@ -85,6 +96,15 @@ public class TableColLength extends LengthProperty { } /** + * Returns the length in 1/1000ths of a point (millipoints) + * @param Evaluation context + * @return the length in millipoints + */ + public int getValue(PercentBaseContext context) { + return getValue(); + } + + /** * Convert this to a String * @return the string representation of this */ diff --git a/src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.java b/src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.java new file mode 100644 index 000000000..ea8dab3e7 --- /dev/null +++ b/src/java/org/apache/fop/layoutmgr/AbstractBaseLayoutManager.java @@ -0,0 +1,265 @@ +/* + * Copyright 2005 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 org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.apache.fop.datatypes.LengthBase; +import org.apache.fop.datatypes.PercentBaseContext; +import org.apache.fop.fo.FObj; + +/** + * The base class for nearly all LayoutManagers. + * Provides the functionality for merging the {@link LayoutManager} + * and the {@link org.apache.fop.datatypes.PercentBaseContext} interfaces + * into a common base calls for all higher LayoutManagers. + */ +public abstract class AbstractBaseLayoutManager + implements LayoutManager, PercentBaseContext { + + protected boolean generatesReferenceArea = false; + protected boolean generatesBlockArea = false; + + protected FObj fobj = null; + + /** + * logging instance + */ + protected static Log log = LogFactory.getLog(LayoutManager.class); + + /** + * Abstract base layout manager. + */ + public AbstractBaseLayoutManager() { + } + + /** + * Abstract base layout manager. + * + * @param fo the formatting object for this layout manager + */ + public AbstractBaseLayoutManager(FObj fo) { + fobj = fo; + setGeneratesReferenceArea(fo.generatesReferenceAreas()); + if (getGeneratesReferenceArea()) { + setGeneratesBlockArea(true); + } + } + + // --------- Property Resolution related functions --------- // + + /** + * @see org.apache.fop.datatypes.PercentBaseContext#getBaseLength(int, FObj) + */ + public int getBaseLength(int lengthBase, FObj fobj) { + if (fobj == getFObj()) { + switch (lengthBase) { + case LengthBase.CONTAINING_BLOCK_WIDTH: + return getAncestorBlockAreaIPD(); + case LengthBase.CONTAINING_BLOCK_HEIGHT: + return getAncestorBlockAreaBPD(); + case LengthBase.PARENT_AREA_WIDTH: + return getParentAreaIPD(); + case LengthBase.CONTAINING_REFAREA_WIDTH: + return getReferenceAreaIPD(); + default: + log.error("Unknown base type for LengthBase:" + lengthBase); + new Exception().printStackTrace(); + return 0; + } + } else { + LayoutManager lm = getParent(); + while (lm != null && fobj != lm.getFObj()) { + lm = lm.getParent(); + } + if (lm != null) { + return lm.getBaseLength(lengthBase, fobj); + } + } + log.error("Cannot find LM to handle given FO for LengthBase."); + return 0; + } + + /** + * Find the first ancestor area that is a block area + * and returns its IPD. + * @return the ipd of the ancestor block area + */ + protected int getAncestorBlockAreaIPD() { + LayoutManager lm = getParent(); + while (lm != null) { + if (lm.getGeneratesBlockArea() && !lm.getGeneratesLineArea()) { + return lm.getContentAreaIPD(); + } + lm = lm.getParent(); + } + if (lm == null) { + log.error("No parent LM found"); + } + return 0; + } + + /** + * Find the first ancestor area that is a block area + * and returns its BPD. + * @return the bpd of the ancestor block area + */ + protected int getAncestorBlockAreaBPD() { + LayoutManager lm = getParent(); + while (lm != null) { + if (lm.getGeneratesBlockArea() && !lm.getGeneratesLineArea()) { + return lm.getContentAreaBPD(); + } + lm = lm.getParent(); + } + if (lm == null) { + log.error("No parent LM found"); + } + return 0; + } + + /** + * Find the parent area and returns its IPD. + * @return the ipd of the parent area + */ + protected int getParentAreaIPD() { + LayoutManager lm = getParent(); + if (lm != null) { + return lm.getContentAreaIPD(); + } + log.error("No parent LM found"); + return 0; + } + + /** + * Find the parent area and returns its BPD. + * @return the bpd of the parent area + */ + protected int getParentAreaBPD() { + LayoutManager lm = getParent(); + if (lm != null) { + return lm.getContentAreaBPD(); + } + log.error("No parent LM found"); + return 0; + } + + /** + * Find the first ancestor area that is a reference area + * and returns its IPD. + * @return the ipd of the ancestor reference area + */ + public int getReferenceAreaIPD() { + LayoutManager lm = getParent(); + while (lm != null) { + if (lm.getGeneratesReferenceArea()) { + return lm.getContentAreaIPD(); + } + lm = lm.getParent(); + } + if (lm == null) { + log.error("No parent LM found"); + } + return 0; + } + + /** + * Find the first ancestor area that is a reference area + * and returns its BPD. + * @return the bpd of the ancestor reference area + */ + protected int getReferenceAreaBPD() { + LayoutManager lm = getParent(); + while (lm != null) { + if (lm.getGeneratesReferenceArea()) { + return lm.getContentAreaBPD(); + } + lm = lm.getParent(); + } + if (lm == null) { + log.error("No parent LM found"); + } + return 0; + } + + /** + * Returns the IPD of the content area + * @return the IPD of the content area + * @see LayoutManager#getContentAreaIPD + */ + public int getContentAreaIPD() { + log.error("getContentAreaIPD called when it should have been overwritten"); + return 0; + } + + /** + * Returns the BPD of the content area + * @return the BPD of the content area + * @see LayoutManager#getContentAreaBPD + */ + public int getContentAreaBPD() { + log.error("getContentAreaBPD called when it should have been overwritten"); + return 0; + } + + /** + * @see LayoutManager#getGeneratesReferenceArea + */ + public boolean getGeneratesReferenceArea() { + return generatesReferenceArea; + } + + /** + * Lets implementing LM set the flag indicating if they + * generate reference areas. + * @param generatesReferenceArea if true the areas generates by this LM are + * reference areas. + */ + protected void setGeneratesReferenceArea(boolean generatesReferenceArea) { + this.generatesReferenceArea = generatesReferenceArea; + } + + /** + * @see LayoutManager#getGeneratesBlockArea + */ + public boolean getGeneratesBlockArea() { + return generatesBlockArea; + } + + /** + * Lets implementing LM set the flag indicating if they + * generate block areas. + * @param generatesBlockArea if true the areas generates by this LM are block areas. + */ + protected void setGeneratesBlockArea(boolean generatesBlockArea) { + this.generatesBlockArea = generatesBlockArea; + } + + /** + * @see org.apache.fop.layoutmgr.LayoutManager#getGeneratesLineArea + */ + public boolean getGeneratesLineArea() { + return false; + } + + public FObj getFObj() { + return fobj; + } + +} diff --git a/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java b/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java index cb33e9b0c..1ad147f53 100644 --- a/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/AbstractLayoutManager.java @@ -22,6 +22,8 @@ import org.apache.fop.fo.FObj; import org.apache.fop.fo.FONode; import org.apache.fop.area.Area; import org.apache.fop.area.PageViewport; +import org.apache.fop.datatypes.LengthBase; +import org.apache.fop.datatypes.PercentBaseContext; import org.apache.fop.fo.Constants; import org.apache.fop.fo.flow.RetrieveMarker; @@ -37,7 +39,8 @@ import java.util.Map; /** * The base class for most LayoutManagers. */ -public abstract class AbstractLayoutManager implements LayoutManager, Constants { +public abstract class AbstractLayoutManager extends AbstractBaseLayoutManager + implements Constants { protected LayoutManager parentLM = null; protected List childLMs = null; protected ListIterator fobjIter = null; @@ -49,12 +52,7 @@ public abstract class AbstractLayoutManager implements LayoutManager, Constants /** child LM and child LM iterator during getNextBreakPoss phase */ protected LayoutManager curChildLM = null; protected ListIterator childLMiter = null; - - /** - * logging instance - */ - protected static Log log = LogFactory.getLog(LayoutManager.class); - + /** * Abstract layout manager. */ @@ -67,6 +65,7 @@ public abstract class AbstractLayoutManager implements LayoutManager, Constants * @param fo the formatting object for this layout manager */ public AbstractLayoutManager(FObj fo) { + super(fo); if (fo == null) { throw new IllegalStateException("Null formatting object found."); } @@ -83,6 +82,10 @@ public abstract class AbstractLayoutManager implements LayoutManager, Constants return this.parentLM; } + public void initialize() { + // Empty + } + /** * Return currently active child LayoutManager or null if * all children have finished layout. @@ -95,6 +98,7 @@ public abstract class AbstractLayoutManager implements LayoutManager, Constants } while (childLMiter.hasNext()) { curChildLM = (LayoutManager) childLMiter.next(); + curChildLM.initialize(); return curChildLM; } return null; @@ -157,6 +161,9 @@ public abstract class AbstractLayoutManager implements LayoutManager, Constants public void addAreas(PositionIterator posIter, LayoutContext context) { } + /** + * @see org.apache.fop.layoutmgr.LayoutManager#getNextKnuthElements(LayoutContext, int) + */ public LinkedList getNextKnuthElements(LayoutContext context, int alignment) { log.warn("null implementation of getNextKnuthElements() called!"); @@ -283,4 +290,5 @@ public abstract class AbstractLayoutManager implements LayoutManager, Constants addChildLM(lm); } } + } diff --git a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java index a183732a3..2fe1c2d38 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java @@ -74,45 +74,48 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager { */ public BlockContainerLayoutManager(BlockContainer node) { super(node); - initialize(); } - private void initialize() { + public void initialize() { abProps = getBlockContainerFO().getCommonAbsolutePosition(); foBlockSpaceBefore = new SpaceVal(getBlockContainerFO().getCommonMarginBlock() - .spaceBefore).getSpace(); + .spaceBefore, this).getSpace(); foBlockSpaceAfter = new SpaceVal(getBlockContainerFO().getCommonMarginBlock() - .spaceAfter).getSpace(); + .spaceAfter, this).getSpace(); boolean rotated = (getBlockContainerFO().getReferenceOrientation() % 180 != 0); if (rotated) { - height = getBlockContainerFO().getInlineProgressionDimension().getOptimum().getLength(); - width = getBlockContainerFO().getBlockProgressionDimension().getOptimum().getLength(); + height = getBlockContainerFO().getInlineProgressionDimension() + .getOptimum(this).getLength(); + width = getBlockContainerFO().getBlockProgressionDimension() + .getOptimum(this).getLength(); } else { - height = getBlockContainerFO().getBlockProgressionDimension().getOptimum().getLength(); - width = getBlockContainerFO().getInlineProgressionDimension().getOptimum().getLength(); + height = getBlockContainerFO().getBlockProgressionDimension() + .getOptimum(this).getLength(); + width = getBlockContainerFO().getInlineProgressionDimension() + .getOptimum(this).getLength(); } bpUnit = 0; //layoutProps.blockProgressionUnit; if (bpUnit == 0) { // use optimum space values adjustedSpaceBefore = getBlockContainerFO().getCommonMarginBlock() - .spaceBefore.getSpace().getOptimum().getLength().getValue(); + .spaceBefore.getSpace().getOptimum(this).getLength().getValue(this); adjustedSpaceAfter = getBlockContainerFO().getCommonMarginBlock() - .spaceAfter.getSpace().getOptimum().getLength().getValue(); + .spaceAfter.getSpace().getOptimum(this).getLength().getValue(this); } else { // use minimum space values adjustedSpaceBefore = getBlockContainerFO().getCommonMarginBlock() - .spaceBefore.getSpace().getMinimum().getLength().getValue(); + .spaceBefore.getSpace().getMinimum(this).getLength().getValue(this); adjustedSpaceAfter = getBlockContainerFO().getCommonMarginBlock() - .spaceAfter.getSpace().getMinimum().getLength().getValue(); + .spaceAfter.getSpace().getMinimum(this).getLength().getValue(this); } } /** @return the content IPD */ protected int getRotatedIPD() { return getBlockContainerFO().getInlineProgressionDimension() - .getOptimum().getLength().getValue(); + .getOptimum(this).getLength().getValue(this); } private int getSpaceBefore() { @@ -122,18 +125,18 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager { private int getBPIndents() { int indents = 0; indents += getBlockContainerFO().getCommonMarginBlock() - .spaceBefore.getOptimum().getLength().getValue(); + .spaceBefore.getOptimum(this).getLength().getValue(this); indents += getBlockContainerFO().getCommonMarginBlock() - .spaceAfter.getOptimum().getLength().getValue(); + .spaceAfter.getOptimum(this).getLength().getValue(this); indents += getBlockContainerFO().getCommonBorderPaddingBackground() - .getBPPaddingAndBorder(false); + .getBPPaddingAndBorder(false, this); return indents; } private int getIPIndents() { int iIndents = 0; - iIndents += getBlockContainerFO().getCommonMarginBlock().startIndent.getValue(); - iIndents += getBlockContainerFO().getCommonMarginBlock().endIndent.getValue(); + iIndents += getBlockContainerFO().getCommonMarginBlock().startIndent.getValue(this); + iIndents += getBlockContainerFO().getCommonMarginBlock().endIndent.getValue(this); return iIndents; } @@ -158,14 +161,14 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager { int maxbpd = context.getStackLimit().opt; int allocBPD, allocIPD; if (height.getEnum() != EN_AUTO) { - allocBPD = height.getValue(); //this is the content-height + allocBPD = height.getValue(this); //this is the content-height allocBPD += getBPIndents(); } else { allocBPD = maxbpd; autoHeight = true; } if (width.getEnum() != EN_AUTO) { - allocIPD = width.getValue(); //this is the content-width + allocIPD = width.getValue(this); //this is the content-width allocIPD += getIPIndents(); } else { allocIPD = referenceIPD; @@ -173,14 +176,15 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager { vpContentBPD = allocBPD - getBPIndents(); vpContentIPD = allocIPD - getIPIndents(); - + setContentAreaIPD(vpContentIPD); double contentRectOffsetX = 0; - contentRectOffsetX += getBlockContainerFO().getCommonMarginBlock().startIndent.getValue(); + contentRectOffsetX += getBlockContainerFO() + .getCommonMarginBlock().startIndent.getValue(this); double contentRectOffsetY = 0; contentRectOffsetY += getBlockContainerFO() .getCommonBorderPaddingBackground().getBorderBeforeWidth(false); contentRectOffsetY += getBlockContainerFO() - .getCommonBorderPaddingBackground().getPaddingBefore(false); + .getCommonBorderPaddingBackground().getPaddingBefore(false, this); Rectangle2D rect = new Rectangle2D.Double( contentRectOffsetX, contentRectOffsetY, @@ -337,7 +341,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager { Point offset = getAbsOffset(); int allocBPD, allocIPD; if (height.getEnum() != EN_AUTO) { - allocBPD = height.getValue(); //this is the content-height + allocBPD = height.getValue(this); //this is the content-height allocBPD += getBPIndents(); } else { allocBPD = 0; @@ -351,12 +355,12 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager { allocBPD = availHeight; allocBPD -= offset.y; if (abProps.bottom.getEnum() != EN_AUTO) { - allocBPD -= abProps.bottom.getValue(); + allocBPD -= abProps.bottom.getValue(this); if (allocBPD < 0) { log.error("The current combination of top and bottom properties results" + " in a negative extent for the block-container. 'bottom' may be" - + " at most " + (allocBPD + abProps.bottom.getValue()) + " mpt," - + " but was actually " + abProps.bottom.getValue() + " mpt." + + " at most " + (allocBPD + abProps.bottom.getValue(this)) + " mpt," + + " but was actually " + abProps.bottom.getValue(this) + " mpt." + " The nominal available height is " + availHeight + " mpt."); allocBPD = 0; } @@ -375,7 +379,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager { } } if (width.getEnum() != EN_AUTO) { - allocIPD = width.getValue(); //this is the content-width + allocIPD = width.getValue(this); //this is the content-width allocIPD += getIPIndents(); } else { int availWidth; @@ -386,15 +390,15 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager { } allocIPD = availWidth; if (abProps.left.getEnum() != EN_AUTO) { - allocIPD -= abProps.left.getValue(); + allocIPD -= abProps.left.getValue(this); } if (abProps.right.getEnum() != EN_AUTO) { - allocIPD -= abProps.right.getValue(); + allocIPD -= abProps.right.getValue(this); if (allocIPD < 0) { log.error("The current combination of left and right properties results" + " in a negative extent for the block-container. 'right' may be" - + " at most " + (allocIPD + abProps.right.getValue()) + " mpt," - + " but was actually " + abProps.right.getValue() + " mpt." + + " at most " + (allocIPD + abProps.right.getValue(this)) + " mpt," + + " but was actually " + abProps.right.getValue(this) + " mpt." + " The nominal available width is " + availWidth + " mpt."); allocIPD = 0; } @@ -403,7 +407,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager { log.error("The current combination of left and right properties results" + " in a negative extent for the block-container. 'left' may be" + " at most " + allocIPD + " mpt," - + " but was actually " + abProps.left.getValue() + " mpt." + + " but was actually " + abProps.left.getValue(this) + " mpt." + " The nominal available width is " + availWidth + " mpt."); allocIPD = 0; } @@ -414,13 +418,14 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager { vpContentIPD = allocIPD - getIPIndents(); double contentRectOffsetX = offset.getX(); - contentRectOffsetX += getBlockContainerFO().getCommonMarginBlock().startIndent.getValue(); + contentRectOffsetX += getBlockContainerFO() + .getCommonMarginBlock().startIndent.getValue(this); double contentRectOffsetY = offset.getY(); contentRectOffsetY += getSpaceBefore(); contentRectOffsetY += getBlockContainerFO() .getCommonBorderPaddingBackground().getBorderBeforeWidth(false); contentRectOffsetY += getBlockContainerFO() - .getCommonBorderPaddingBackground().getPaddingBefore(false); + .getCommonBorderPaddingBackground().getPaddingBefore(false, this); Rectangle2D rect = new Rectangle2D.Double( contentRectOffsetX, contentRectOffsetY, @@ -589,10 +594,10 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager { int x = 0; int y = 0; if (abProps.left.getEnum() != EN_AUTO) { - x = abProps.left.getValue(); + x = abProps.left.getValue(this); } if (abProps.top.getEnum() != EN_AUTO) { - y = abProps.top.getValue(); + y = abProps.top.getValue(this); } return new Point(x, y); } @@ -730,9 +735,9 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager { // to reach a multiple of bpUnit if (bSpaceBefore && bSpaceAfter) { foBlockSpaceBefore = new SpaceVal(getBlockContainerFO() - .getCommonMarginBlock().spaceBefore).getSpace(); + .getCommonMarginBlock().spaceBefore, this).getSpace(); foBlockSpaceAfter = new SpaceVal(getBlockContainerFO() - .getCommonMarginBlock().spaceAfter).getSpace(); + .getCommonMarginBlock().spaceAfter, this).getSpace(); adjustedSpaceBefore = (neededUnits(splitLength + foBlockSpaceBefore.min + foBlockSpaceAfter.min) @@ -818,12 +823,14 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager { TraitSetter.setProducerID(viewportBlockArea, getBlockContainerFO().getId()); TraitSetter.addBorders(viewportBlockArea, - getBlockContainerFO().getCommonBorderPaddingBackground()); - TraitSetter.addBackground(viewportBlockArea, - getBlockContainerFO().getCommonBorderPaddingBackground()); + getBlockContainerFO().getCommonBorderPaddingBackground(), this); + // TraitSetter.addBackground(viewportBlockArea, + // getBlockContainerFO().getCommonBorderPaddingBackground(), + // this); TraitSetter.addMargins(viewportBlockArea, getBlockContainerFO().getCommonBorderPaddingBackground(), - getBlockContainerFO().getCommonMarginBlock()); + getBlockContainerFO().getCommonMarginBlock(), + this); viewportBlockArea.setCTM(absoluteCTM); viewportBlockArea.setClip(clip); @@ -892,6 +899,10 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager { protected void flush() { viewportBlockArea.addBlock(referenceArea, autoHeight); + TraitSetter.addBackground(viewportBlockArea, + getBlockContainerFO().getCommonBorderPaddingBackground(), + this); + // Fake a 0 height for absolute positioned blocks. int saveBPD = viewportBlockArea.getBPD(); if (viewportBlockArea.getPositioning() == Block.ABSOLUTE) { @@ -952,5 +963,22 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager { protected BlockContainer getBlockContainerFO() { return (BlockContainer) fobj; } + + // --------- Property Resolution related functions --------- // + + /** + * @see org.apache.fop.layoutmgr.LayoutManager#getGeneratesReferenceArea + */ + public boolean getGeneratesReferenceArea() { + return true; + } + + /** + * @see org.apache.fop.layoutmgr.LayoutManager#getGeneratesBlockArea + */ + public boolean getGeneratesBlockArea() { + return true; + } + } diff --git a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java index 46f2f68e4..0b9b2cd6c 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java @@ -19,17 +19,18 @@ package org.apache.fop.layoutmgr; import java.util.LinkedList; -import java.util.ListIterator; import java.util.List; +import java.util.ListIterator; -import org.apache.fop.fonts.Font; -import org.apache.fop.layoutmgr.inline.InlineLevelLayoutManager; -import org.apache.fop.layoutmgr.inline.LineLayoutManager; import org.apache.fop.area.Area; import org.apache.fop.area.Block; import org.apache.fop.area.LineArea; -import org.apache.fop.traits.SpaceVal; +import org.apache.fop.datatypes.Length; +import org.apache.fop.fonts.Font; +import org.apache.fop.layoutmgr.inline.InlineLevelLayoutManager; +import org.apache.fop.layoutmgr.inline.LineLayoutManager; import org.apache.fop.traits.MinOptMax; +import org.apache.fop.traits.SpaceVal; /** * LayoutManager for a block FO. @@ -42,7 +43,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager { protected ListIterator proxyLMiter; private int lead = 12000; - private int lineHeight = 14000; + private Length lineHeight; private int follow = 2000; private int middleShift = 0; @@ -56,29 +57,33 @@ public class BlockLayoutManager extends BlockStackingLayoutManager { public BlockLayoutManager(org.apache.fop.fo.flow.Block inBlock) { super(inBlock); proxyLMiter = new ProxyLMiter(); + } + public void initialize() { Font fs = getBlockFO().getCommonFont().getFontState( - getBlockFO().getFOEventHandler().getFontInfo()); + getBlockFO().getFOEventHandler().getFontInfo(), this); lead = fs.getAscender(); follow = -fs.getDescender(); middleShift = -fs.getXHeight() / 2; - lineHeight = getBlockFO().getLineHeight().getOptimum().getLength().getValue(); - initialize(); - } - - private void initialize() { - foSpaceBefore = new SpaceVal(getBlockFO().getCommonMarginBlock().spaceBefore).getSpace(); - foSpaceAfter = new SpaceVal(getBlockFO().getCommonMarginBlock().spaceAfter).getSpace(); + lineHeight = getBlockFO().getLineHeight().getOptimum(this).getLength(); + foSpaceBefore = new SpaceVal(getBlockFO().getCommonMarginBlock().spaceBefore, this) + .getSpace(); + foSpaceAfter = new SpaceVal(getBlockFO().getCommonMarginBlock().spaceAfter, this) + .getSpace(); bpUnit = 0; // non-standard extension if (bpUnit == 0) { // use optimum space values - adjustedSpaceBefore = getBlockFO().getCommonMarginBlock().spaceBefore.getSpace().getOptimum().getLength().getValue(); - adjustedSpaceAfter = getBlockFO().getCommonMarginBlock().spaceAfter.getSpace().getOptimum().getLength().getValue(); + adjustedSpaceBefore = getBlockFO().getCommonMarginBlock().spaceBefore.getSpace() + .getOptimum(this).getLength().getValue(this); + adjustedSpaceAfter = getBlockFO().getCommonMarginBlock().spaceAfter.getSpace() + .getOptimum(this).getLength().getValue(this); } else { // use minimum space values - adjustedSpaceBefore = getBlockFO().getCommonMarginBlock().spaceBefore.getSpace().getMinimum().getLength().getValue(); - adjustedSpaceAfter = getBlockFO().getCommonMarginBlock().spaceAfter.getSpace().getMinimum().getLength().getValue(); + adjustedSpaceBefore = getBlockFO().getCommonMarginBlock().spaceBefore.getSpace() + .getMinimum(this).getLength().getValue(this); + adjustedSpaceAfter = getBlockFO().getCommonMarginBlock().spaceAfter.getSpace() + .getMinimum(this).getLength().getValue(this); } } @@ -92,15 +97,24 @@ public class BlockLayoutManager extends BlockStackingLayoutManager { */ protected class ProxyLMiter extends LMiter { + /* + * Constructs a proxy iterator for Block LM. + */ public ProxyLMiter() { super(BlockLayoutManager.this); listLMs = new java.util.ArrayList(10); } + /** + * @return true if there are more child lms + */ public boolean hasNext() { return (curPos < listLMs.size()) ? true : createNextChildLMs(curPos); } + /** + * @return true if new child lms were added + */ protected boolean createNextChildLMs(int pos) { List newLMs = createChildLMs(pos + 1 - listLMs.size()); if (newLMs != null) { @@ -156,8 +170,8 @@ public class BlockLayoutManager extends BlockStackingLayoutManager { private int getIPIndents() { int iIndents = 0; - iIndents += getBlockFO().getCommonMarginBlock().startIndent.getValue(); - iIndents += getBlockFO().getCommonMarginBlock().endIndent.getValue(); + iIndents += getBlockFO().getCommonMarginBlock().startIndent.getValue(this); + iIndents += getBlockFO().getCommonMarginBlock().endIndent.getValue(this); return iIndents; } @@ -190,6 +204,9 @@ public class BlockLayoutManager extends BlockStackingLayoutManager { || !getBlockFO().getKeepWithNext().getWithinColumn().isAuto(); } + /** + * @see org.apache.fop.layoutmgr.LayoutManager#addAreas(org.apache.fop.layoutmgr.PositionIterator, org.apache.fop.layoutmgr.LayoutContext) + */ public void addAreas(PositionIterator parentIter, LayoutContext layoutContext) { //System.out.println(" BLM.addAreas>"); @@ -315,8 +332,10 @@ public class BlockLayoutManager extends BlockStackingLayoutManager { // add space before and / or after the paragraph // to reach a multiple of bpUnit if (bSpaceBefore && bSpaceAfter) { - foSpaceBefore = new SpaceVal(getBlockFO().getCommonMarginBlock().spaceBefore).getSpace(); - foSpaceAfter = new SpaceVal(getBlockFO().getCommonMarginBlock().spaceAfter).getSpace(); + foSpaceBefore = new SpaceVal(getBlockFO() + .getCommonMarginBlock().spaceBefore, this).getSpace(); + foSpaceAfter = new SpaceVal(getBlockFO() + .getCommonMarginBlock().spaceAfter, this).getSpace(); adjustedSpaceBefore = (neededUnits(splitLength + foSpaceBefore.min + foSpaceAfter.min) @@ -359,7 +378,8 @@ public class BlockLayoutManager extends BlockStackingLayoutManager { childLM.addAreas(childPosIter, lc); } - //int bIndents = getBlockFO().getCommonBorderPaddingBackground().getBPPaddingAndBorder(false); + //int bIndents = getBlockFO().getCommonBorderPaddingBackground() + // .getBPPaddingAndBorder(false); if (markers != null) { getCurrentPV().addMarkers(markers, false, isFirst(firstPos), isLast(lastPos)); @@ -386,11 +406,16 @@ public class BlockLayoutManager extends BlockStackingLayoutManager { * its own area. This includes setting the content IPD and the maximum * BPD. * @param childArea area to get the parent area for + * @return the parent area */ public Area getParentArea(Area childArea) { if (curBlockArea == null) { curBlockArea = new Block(); + int contentIPD = referenceIPD - getIPIndents(); + + curBlockArea.setIPD(contentIPD/*parentwidth*/); + TraitSetter.addBreaks(curBlockArea, getBlockFO().getBreakBefore(), getBlockFO().getBreakAfter()); @@ -401,10 +426,11 @@ public class BlockLayoutManager extends BlockStackingLayoutManager { // set traits TraitSetter.setProducerID(curBlockArea, getBlockFO().getId()); TraitSetter.addBorders(curBlockArea, - getBlockFO().getCommonBorderPaddingBackground()); + getBlockFO().getCommonBorderPaddingBackground(), this); TraitSetter.addMargins(curBlockArea, getBlockFO().getCommonBorderPaddingBackground(), - getBlockFO().getCommonMarginBlock()); + getBlockFO().getCommonMarginBlock(), + this); // Set up dimensions // Get reference IPD from parentArea @@ -424,11 +450,6 @@ public class BlockLayoutManager extends BlockStackingLayoutManager { parentwidth -= getIPIndents(); */ - int contentIPD = referenceIPD - getIPIndents(); - - curBlockArea.setIPD(contentIPD/*parentwidth*/); - TraitSetter.addBackground(curBlockArea, - getBlockFO().getCommonBorderPaddingBackground()); setCurrentArea(curBlockArea); // ??? for generic operations } return curBlockArea; @@ -448,6 +469,19 @@ public class BlockLayoutManager extends BlockStackingLayoutManager { } /** + * Force current area to be added to parent area. + * @see org.apache.fop.layoutmgr.BlockStackingLayoutManager#flush() + */ + protected void flush() { + if (curBlockArea != null) { + TraitSetter.addBackground(curBlockArea, + getBlockFO().getCommonBorderPaddingBackground(), + this); + super.flush(); + } + } + + /** * @see org.apache.fop.layoutmgr.LayoutManager#resetPosition(org.apache.fop.layoutmgr.Position) */ public void resetPosition(Position resetPos) { @@ -462,9 +496,43 @@ public class BlockLayoutManager extends BlockStackingLayoutManager { /** * convenience method that returns the Block node + * @return the block node */ protected org.apache.fop.fo.flow.Block getBlockFO() { return (org.apache.fop.fo.flow.Block) fobj; } + + // --------- Property Resolution related functions --------- // + + /** + * Returns the IPD of the content area + * @return the IPD of the content area + */ + public int getContentAreaIPD() { + if (curBlockArea != null) { + return curBlockArea.getIPD(); + } + return super.getContentAreaIPD(); + } + + + /** + * Returns the BPD of the content area + * @return the BPD of the content area + */ + public int getContentAreaBPD() { + if (curBlockArea != null) { + return curBlockArea.getBPD(); + } + return -1; + } + + /** + * @see org.apache.fop.layoutmgr.LayoutManager#getGeneratesBlockArea + */ + public boolean getGeneratesBlockArea() { + return true; + } + } diff --git a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java index feec2f783..822974e7b 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java @@ -62,29 +62,37 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager protected boolean bSpaceBeforeServed = false; /** Reference IPD available */ protected int referenceIPD = 0; - - /* holds the (one-time use) fo:block space-before - and -after properties. Large fo:blocks are split - into multiple Area.Blocks to accomodate the subsequent - regions (pages) they are placed on. space-before - is applied at the beginning of the first - Block and space-after at the end of the last Block - used in rendering the fo:block. - */ + /** + * Holds the (one-time use) fo:block space-before + * and -after properties. Large fo:blocks are split + * into multiple Area. Blocks to accomodate the subsequent + * regions (pages) they are placed on. space-before + * is applied at the beginning of the first + * Block and space-after at the end of the last Block + * used in rendering the fo:block. + */ protected MinOptMax foSpaceBefore = null; + /** see foSpaceBefore */ protected MinOptMax foSpaceAfter = null; private int lastGeneratedPosition = -1; private int smallestPosNumberChecked = Integer.MAX_VALUE; private Position auxiliaryPosition; + + private int contentAreaIPD = 0; + /** + * @param the fo this LM deals with + */ public BlockStackingLayoutManager(FObj node) { super(node); + setGeneratesBlockArea(true); fobj = node; } - /** return current area being filled + /** + * @return current area being filled */ protected BlockParent getCurrentArea() { return this.parentArea; @@ -93,6 +101,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager /** * Set the current area being filled. + * @param parentArea the current area to be filled */ protected void setCurrentArea(BlockParent parentArea) { this.parentArea = parentArea; @@ -240,6 +249,9 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager return (int) Math.ceil((float)len / bpUnit); } + /** + * @see LayoutManager#getNextKnuthElements(LayoutContext, int) + */ public LinkedList getNextKnuthElements(LayoutContext context, int alignment) { /* LF *///System.err.println("BLM.getNextKnuthElements> keep-together = " // + layoutProps.keepTogether.getType()); @@ -251,21 +263,21 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager BlockLevelLayoutManager prevLM = null; // previously active LM referenceIPD = context.getRefIPD(); + int iIndents = 0; int bIndents = 0; if (fobj instanceof org.apache.fop.fo.flow.Block) { org.apache.fop.fo.flow.Block block = (org.apache.fop.fo.flow.Block)fobj; - iIndents = block.getCommonMarginBlock().startIndent.getValue() - + block.getCommonMarginBlock().endIndent.getValue(); - bIndents = block.getCommonBorderPaddingBackground().getBPPaddingAndBorder(false); + iIndents = block.getCommonMarginBlock().startIndent.getValue(this) + + block.getCommonMarginBlock().endIndent.getValue(this); + bIndents = block.getCommonBorderPaddingBackground().getBPPaddingAndBorder(false, this); } int ipd = referenceIPD - iIndents; MinOptMax stackSize = new MinOptMax(); // Set context for percentage property values. - fobj.setLayoutDimension(PercentBase.BLOCK_IPD, ipd); - fobj.setLayoutDimension(PercentBase.BLOCK_BPD, -1); + setContentAreaIPD(ipd); LinkedList returnedList = null; LinkedList contentList = new LinkedList(); @@ -437,6 +449,9 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager return returnList; } + /** + * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#negotiateBPDAdjustment(int, org.apache.fop.layoutmgr.KnuthElement) + */ public int negotiateBPDAdjustment(int adj, KnuthElement lastElement) { /*LF*/ //System.out.println(" BLM.negotiateBPDAdjustment> " + adj); /*LF*/ //System.out.println(" lastElement e' " + (lastElement.isPenalty() @@ -517,6 +532,9 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager } } + /** + * @see BlockLevelLayoutManager#discardSpace(KnuthGlue) + */ public void discardSpace(KnuthGlue spaceGlue) { //System.out.println(" BLM.discardSpace> " + spaceGlue.getPosition().getClass().getName()); Position innerPosition = ((NonLeafPosition) spaceGlue.getPosition()).getPosition(); @@ -544,6 +562,9 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager } } + /** + * @see LayoutManager#getChangedKnuthElements(List, int) + */ public LinkedList getChangedKnuthElements(List oldList, int alignment) { /*LF*/ //System.out.println(""); /*LF*/ //System.out.println(" BLM.getChangedKnuthElements> inizio: oldList.size() = " @@ -775,7 +796,6 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager /** * Creates Knuth elements for before border padding and adds them to the return list. * @param returnList return list to add the additional elements to - * @param returnPosition applicable return position */ protected void addKnuthElementsForBorderPaddingBefore(LinkedList returnList/*, Position returnPosition*/) { @@ -791,7 +811,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager if (borderAndPadding != null) { //TODO Handle conditionality int bpBefore = borderAndPadding.getBorderBeforeWidth(false) - + borderAndPadding.getPaddingBefore(false); + + borderAndPadding.getPaddingBefore(false, this); if (bpBefore > 0) { returnList.add(new KnuthBox(bpBefore, getAuxiliaryPosition(), true)); } @@ -801,7 +821,6 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager /** * Creates Knuth elements for after border padding and adds them to the return list. * @param returnList return list to add the additional elements to - * @param returnPosition applicable return position */ protected void addKnuthElementsForBorderPaddingAfter(LinkedList returnList/*, Position returnPosition*/) { @@ -817,7 +836,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager if (borderAndPadding != null) { //TODO Handle conditionality int bpAfter = borderAndPadding.getBorderAfterWidth(false) - + borderAndPadding.getPaddingAfter(false); + + borderAndPadding.getPaddingAfter(false, this); if (bpAfter > 0) { returnList.add(new KnuthBox(bpAfter, getAuxiliaryPosition(), true)); } @@ -827,7 +846,6 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager /** * Creates Knuth elements for break-before and adds them to the return list. * @param returnList return list to add the additional elements to - * @param returnPosition applicable return position * @return true if an element has been added due to a break-before. */ protected boolean addKnuthElementsForBreakBefore(LinkedList returnList/*, @@ -856,7 +874,6 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager /** * Creates Knuth elements for break-after and adds them to the return list. * @param returnList return list to add the additional elements to - * @param returnPosition applicable return position * @return true if an element has been added due to a break-after. */ protected boolean addKnuthElementsForBreakAfter(LinkedList returnList/*, @@ -885,7 +902,6 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager /** * Creates Knuth elements for space-before and adds them to the return list. * @param returnList return list to add the additional elements to - * @param returnPosition applicable return position * @param alignment vertical alignment */ protected void addKnuthElementsForSpaceBefore(LinkedList returnList/*, @@ -907,8 +923,8 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager // append elements representing space-before if (bpUnit > 0 || spaceBefore != null - && !(spaceBefore.getMinimum().getLength().getValue() == 0 - && spaceBefore.getMaximum().getLength().getValue() == 0)) { + && !(spaceBefore.getMinimum(this).getLength().getValue(this) == 0 + && spaceBefore.getMaximum(this).getLength().getValue(this) == 0)) { if (spaceBefore != null && !spaceBefore.getSpace().isDiscard()) { // add elements to prevent the glue to be discarded returnList.add(new KnuthBox(0, getAuxiliaryPosition(), false)); @@ -921,16 +937,16 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager getAuxiliaryPosition(), true)); } else /*if (alignment == EN_JUSTIFY)*/ { returnList.add(new KnuthGlue( - spaceBefore.getOptimum().getLength().getValue(), - spaceBefore.getMaximum().getLength().getValue() - - spaceBefore.getOptimum().getLength().getValue(), - spaceBefore.getOptimum().getLength().getValue() - - spaceBefore.getMinimum().getLength().getValue(), + spaceBefore.getOptimum(this).getLength().getValue(this), + spaceBefore.getMaximum(this).getLength().getValue(this) + - spaceBefore.getOptimum(this).getLength().getValue(this), + spaceBefore.getOptimum(this).getLength().getValue(this) + - spaceBefore.getMinimum(this).getLength().getValue(this), BlockLevelLayoutManager.SPACE_BEFORE_ADJUSTMENT, getAuxiliaryPosition(), true)); } /*else { returnList.add(new KnuthGlue( - spaceBefore.getOptimum().getLength().getValue(), + spaceBefore.getOptimum().getLength().getValue(this), 0, 0, BlockLevelLayoutManager.SPACE_BEFORE_ADJUSTMENT, returnPosition, true)); }*/ @@ -940,7 +956,6 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager /** * Creates Knuth elements for space-after and adds them to the return list. * @param returnList return list to add the additional elements to - * @param returnPosition applicable return position * @param alignment vertical alignment */ protected void addKnuthElementsForSpaceAfter(LinkedList returnList/*, Position returnPosition*/, @@ -962,8 +977,8 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager // append elements representing space-after if (bpUnit > 0 || spaceAfter != null - && !(spaceAfter.getMinimum().getLength().getValue() == 0 - && spaceAfter.getMaximum().getLength().getValue() == 0)) { + && !(spaceAfter.getMinimum(this).getLength().getValue(this) == 0 + && spaceAfter.getMaximum(this).getLength().getValue(this) == 0)) { if (spaceAfter != null && !spaceAfter.getSpace().isDiscard()) { returnList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, getAuxiliaryPosition(), false)); @@ -974,16 +989,16 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager getAuxiliaryPosition(), true)); } else /*if (alignment == EN_JUSTIFY)*/ { returnList.add(new KnuthGlue( - spaceAfter.getOptimum().getLength().getValue(), - spaceAfter.getMaximum().getLength().getValue() - - spaceAfter.getOptimum().getLength().getValue(), - spaceAfter.getOptimum().getLength().getValue() - - spaceAfter.getMinimum().getLength().getValue(), + spaceAfter.getOptimum(this).getLength().getValue(this), + spaceAfter.getMaximum(this).getLength().getValue(this) + - spaceAfter.getOptimum(this).getLength().getValue(this), + spaceAfter.getOptimum(this).getLength().getValue(this) + - spaceAfter.getMinimum(this).getLength().getValue(this), BlockLevelLayoutManager.SPACE_AFTER_ADJUSTMENT, getAuxiliaryPosition(), (!spaceAfter.getSpace().isDiscard()) ? false : true)); } /*else { returnList.add(new KnuthGlue( - spaceAfter.getOptimum().getLength().getValue(), 0, 0, + spaceAfter.getOptimum().getLength().getValue(this), 0, 0, BlockLevelLayoutManager.SPACE_AFTER_ADJUSTMENT, returnPosition, (!spaceAfter.getSpace().isDiscard()) ? false : true)); }*/ @@ -1378,5 +1393,25 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager } } + /** + * Returns the IPD of the content area + * @return the IPD of the content area + */ + public int getContentAreaIPD() { + return contentAreaIPD; + } + + protected void setContentAreaIPD(int contentAreaIPD) { + this.contentAreaIPD = contentAreaIPD; + } + + /** + * Returns the BPD of the content area + * @return the BPD of the content area + */ + public int getContentAreaBPD() { + return -1; + } + } diff --git a/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java b/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java index a400078c2..70f481532 100644 --- a/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java @@ -62,10 +62,6 @@ public class FlowLayoutManager extends BlockStackingLayoutManager // set layout dimensions int flowIPD = getCurrentPV().getCurrentSpan().getColumnWidth(); int flowBPD = (int) getCurrentPV().getBodyRegion().getBPD(); - fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_IPD, flowIPD); - fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_BPD, flowBPD); - fobj.setLayoutDimension(PercentBase.BLOCK_IPD, context.getRefIPD()); - fobj.setLayoutDimension(PercentBase.BLOCK_BPD, context.getStackLimit().opt); // currently active LM BlockLevelLayoutManager curLM; @@ -338,5 +334,21 @@ public class FlowLayoutManager extends BlockStackingLayoutManager reset(null); } } + /** + * Returns the IPD of the content area + * @return the IPD of the content area + */ + public int getContentAreaIPD() { + return getCurrentPV().getCurrentSpan().getColumnWidth(); + } + + /** + * Returns the BPD of the content area + * @return the BPD of the content area + */ + public int getContentAreaBPD() { + return (int) getCurrentPV().getBodyRegion().getBPD(); + } + } diff --git a/src/java/org/apache/fop/layoutmgr/LayoutManager.java b/src/java/org/apache/fop/layoutmgr/LayoutManager.java index 3d6053248..33250110f 100644 --- a/src/java/org/apache/fop/layoutmgr/LayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/LayoutManager.java @@ -22,11 +22,13 @@ import java.util.LinkedList; import java.util.List; import org.apache.fop.area.Area; +import org.apache.fop.datatypes.PercentBaseContext; +import org.apache.fop.fo.FObj; /** * The interface for all LayoutManagers. */ -public interface LayoutManager { +public interface LayoutManager extends PercentBaseContext { /** * Set the parent layout manager. @@ -43,6 +45,12 @@ public interface LayoutManager { LayoutManager getParent(); /** + * initialize the layout manager. Allows each layout manager + * to calculate often used values. + */ + public void initialize(); + + /** * Get the active PageSequenceLayoutManager instance for this * layout process. * @return the PageSequenceLayoutManager @@ -143,11 +151,46 @@ public interface LayoutManager { * of the node assigned to the LM, after changes have been applied * * @param oldList the elements to replace - * @param flaggedPenalty the penalty value for hyphenated lines * @param alignment the desired text alignment * @return the updated list of KnuthElements */ LinkedList getChangedKnuthElements(List oldList, /*int flaggedPenalty,*/ int alignment); + + /** + * Returns the IPD of the content area + * @return the IPD of the content area + */ + int getContentAreaIPD(); + /** + * Returns the BPD of the content area + * @return the BPD of the content area + */ + int getContentAreaBPD(); + + /** + * Returns an indication if the layout manager generates a reference area. + * @return True if the layout manager generates a reference area + */ + boolean getGeneratesReferenceArea(); + + /** + * Returns an indication if the layout manager generates a block area. + * @return True if the layout manager generates a block area + */ + boolean getGeneratesBlockArea(); + + /** + * Returns an indication if the layout manager generates a line area. + * @return True if the layout manager generates a line area + */ + boolean getGeneratesLineArea(); + + /** + * Returns the fo this layout manager is associated with. + * @return The fo for this layout manager or null. + */ + FObj getFObj(); + } diff --git a/src/java/org/apache/fop/layoutmgr/MinOptMaxUtil.java b/src/java/org/apache/fop/layoutmgr/MinOptMaxUtil.java index a17748e24..e99ec6853 100644 --- a/src/java/org/apache/fop/layoutmgr/MinOptMaxUtil.java +++ b/src/java/org/apache/fop/layoutmgr/MinOptMaxUtil.java @@ -18,6 +18,7 @@ package org.apache.fop.layoutmgr; +import org.apache.fop.datatypes.PercentBaseContext; import org.apache.fop.fo.Constants; import org.apache.fop.fo.properties.LengthRangeProperty; import org.apache.fop.traits.MinOptMax; @@ -31,18 +32,20 @@ public class MinOptMaxUtil { * Restricts a MinOptMax using the values from a LengthRangeProperty. * @param mom MinOptMax to restrict * @param lr restricting source + * @param context Percentage evaluation context */ - public static void restrict(MinOptMax mom, LengthRangeProperty lr) { + public static void restrict(MinOptMax mom, LengthRangeProperty lr, + PercentBaseContext context) { if (lr.getEnum() != Constants.EN_AUTO) { - if (lr.getMinimum().getEnum() != Constants.EN_AUTO) { - int min = lr.getMinimum().getLength().getValue(); + if (lr.getMinimum(context).getEnum() != Constants.EN_AUTO) { + int min = lr.getMinimum(context).getLength().getValue(context); if (min > mom.min) { mom.min = min; fixAfterMinChanged(mom); } } - if (lr.getMaximum().getEnum() != Constants.EN_AUTO) { - int max = lr.getMaximum().getLength().getValue(); + if (lr.getMaximum(context).getEnum() != Constants.EN_AUTO) { + int max = lr.getMaximum(context).getLength().getValue(context); if (max < mom.max) { mom.max = max; if (mom.max < mom.opt) { @@ -51,8 +54,8 @@ public class MinOptMaxUtil { } } } - if (lr.getOptimum().getEnum() != Constants.EN_AUTO) { - int opt = lr.getOptimum().getLength().getValue(); + if (lr.getOptimum(context).getEnum() != Constants.EN_AUTO) { + int opt = lr.getOptimum(context).getLength().getValue(context); if (opt > mom.min) { mom.opt = opt; if (mom.opt > mom.max) { @@ -63,6 +66,13 @@ public class MinOptMaxUtil { } } + /** + * Extend the minimum length to the given length. + * @param mom the min/opt/max trait + * @param len the new minimum length + * @param optToLen if set adjusts the optimum length to be the smaller of the + * minimum length and the given length + */ public static void extendMinimum(MinOptMax mom, int len, boolean optToLen) { if (mom.min < len) { mom.min = len; @@ -91,17 +101,18 @@ public class MinOptMaxUtil { /** * Converts a LengthRangeProperty to a MinOptMax. * @param prop LengthRangeProperty + * @param context Percentage evaluation context * @return the requested MinOptMax instance */ - public static MinOptMax toMinOptMax(LengthRangeProperty prop) { + public static MinOptMax toMinOptMax(LengthRangeProperty prop, PercentBaseContext context) { MinOptMax mom = new MinOptMax( - (prop.getMinimum().isAuto() - ? 0 : prop.getMinimum().getLength().getValue()), - (prop.getOptimum().isAuto() - ? 0 : prop.getOptimum().getLength().getValue()), - (prop.getMinimum().isAuto() + (prop.getMinimum(context).isAuto() + ? 0 : prop.getMinimum(context).getLength().getValue(context)), + (prop.getOptimum(context).isAuto() + ? 0 : prop.getOptimum(context).getLength().getValue(context)), + (prop.getMinimum(context).isAuto() ? Integer.MAX_VALUE - : prop.getMaximum().getLength().getValue())); + : prop.getMaximum(context).getLength().getValue(context))); return mom; } diff --git a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java index c052bf94e..57ceb82a0 100644 --- a/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/PageSequenceLayoutManager.java @@ -243,6 +243,7 @@ public class PageSequenceLayoutManager extends AbstractLayoutManager { FootnoteBodyLayoutManager fblm = (FootnoteBodyLayoutManager) footnoteBodyIterator.next(); fblm.setParent(childFLM); + fblm.initialize(); ((KnuthBlockBox) element).addElementList( fblm.getNextKnuthElements(footnoteContext, alignment)); } diff --git a/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java index 5412d80fc..37ab04395 100644 --- a/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java @@ -42,6 +42,9 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { private Block targetBlock; private SideRegion regionFO; + private int contentAreaIPD = 0; + private int contentAreaBPD = -1; + /** * Creates a new StaticContentLayoutManager. * @param pslm PageSequenceLayoutManager this layout manager belongs to @@ -53,9 +56,15 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { super(node); setParent(pslm); regionFO = reg; - targetRegion = getCurrentPV().getRegionReference(regionFO.getNameId()); + targetRegion = getCurrentPV().getRegionReference(regionFO.getNameId()); } + /** + * Creates a new StaticContentLayoutManager. + * @param pslm PageSequenceLayoutManager this layout manager belongs to + * @param node static-content FO + * @param block the block to layout into + */ public StaticContentLayoutManager(PageSequenceLayoutManager pslm, StaticContent node, Block block) { super(node); @@ -68,8 +77,8 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { */ public LinkedList getNextKnuthElements(LayoutContext context, int alignment) { // set layout dimensions - fobj.setLayoutDimension(PercentBase.BLOCK_IPD, context.getRefIPD()); - fobj.setLayoutDimension(PercentBase.BLOCK_BPD, context.getStackLimit().opt); + setContentAreaIPD(context.getRefIPD()); + setContentAreaBPD(context.getStackLimit().opt); //TODO Copied from elsewhere. May be worthwhile to factor out the common parts. // currently active LM @@ -218,7 +227,8 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { } /** - * convenience method that returns the Static Content node + * Convenience method that returns the Static Content node. + * @return the static content node */ protected StaticContent getStaticContentFO() { return (StaticContent) fobj; @@ -307,6 +317,31 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { protected LayoutManager getCurrentChildLM() { return null; //TODO NYI } - } + } + + /** + * Returns the IPD of the content area + * @return the IPD of the content area + */ + public int getContentAreaIPD() { + return contentAreaIPD; + } + + private void setContentAreaIPD(int contentAreaIPD) { + this.contentAreaIPD = contentAreaIPD; + } + + /** + * Returns the BPD of the content area + * @return the BPD of the content area + */ + public int getContentAreaBPD() { + return contentAreaBPD; + } + + private void setContentAreaBPD(int contentAreaBPD) { + this.contentAreaBPD = contentAreaBPD; + } + } diff --git a/src/java/org/apache/fop/layoutmgr/TraitSetter.java b/src/java/org/apache/fop/layoutmgr/TraitSetter.java index c1322d570..8e2c72a0f 100644 --- a/src/java/org/apache/fop/layoutmgr/TraitSetter.java +++ b/src/java/org/apache/fop/layoutmgr/TraitSetter.java @@ -23,6 +23,9 @@ import org.apache.commons.logging.LogFactory; import org.apache.fop.traits.BorderProps; import org.apache.fop.area.Area; import org.apache.fop.area.Trait; +import org.apache.fop.datatypes.LengthBase; +import org.apache.fop.datatypes.PercentBaseContext; +import org.apache.fop.datatypes.SimplePercentBaseContext; import org.apache.fop.fo.Constants; import org.apache.fop.fo.properties.CommonMarginBlock; import org.apache.fop.fo.properties.CommonBorderPaddingBackground; @@ -43,23 +46,25 @@ public class TraitSetter { * @param bpProps border and padding properties * @param bNotFirst True if the area is not the first area * @param bNotLast True if the area is not the last area + * @param context Property evaluation context */ public static void setBorderPaddingTraits(Area area, - CommonBorderPaddingBackground bpProps, boolean bNotFirst, boolean bNotLast) { + CommonBorderPaddingBackground bpProps, boolean bNotFirst, boolean bNotLast, + PercentBaseContext context) { int iBP; - iBP = bpProps.getPadding(CommonBorderPaddingBackground.START, bNotFirst); + iBP = bpProps.getPadding(CommonBorderPaddingBackground.START, bNotFirst, context); if (iBP > 0) { area.addTrait(Trait.PADDING_START, new Integer(iBP)); } - iBP = bpProps.getPadding(CommonBorderPaddingBackground.END, bNotLast); + iBP = bpProps.getPadding(CommonBorderPaddingBackground.END, bNotLast, context); if (iBP > 0) { area.addTrait(Trait.PADDING_END, new Integer(iBP)); } - iBP = bpProps.getPadding(CommonBorderPaddingBackground.BEFORE, false); + iBP = bpProps.getPadding(CommonBorderPaddingBackground.BEFORE, false, context); if (iBP > 0) { area.addTrait(Trait.PADDING_BEFORE, new Integer(iBP)); } - iBP = bpProps.getPadding(CommonBorderPaddingBackground.AFTER, false); + iBP = bpProps.getPadding(CommonBorderPaddingBackground.AFTER, false, context); if (iBP > 0) { area.addTrait(Trait.PADDING_AFTER, new Integer(iBP)); } @@ -106,8 +111,10 @@ public class TraitSetter { * add the borders to the area. * @param area the area to set the traits on. * @param bordProps border properties + * @param context Property evaluation context */ - public static void addBorders(Area area, CommonBorderPaddingBackground bordProps) { + public static void addBorders(Area area, CommonBorderPaddingBackground bordProps, + PercentBaseContext context) { BorderProps bps = getBorderProps(bordProps, CommonBorderPaddingBackground.BEFORE); if (bps != null) { area.addTrait(Trait.BORDER_BEFORE, bps); @@ -125,7 +132,7 @@ public class TraitSetter { area.addTrait(Trait.BORDER_END, bps); } - addPadding(area, bordProps); + addPadding(area, bordProps, context); } /** @@ -136,10 +143,12 @@ public class TraitSetter { * @param bordProps border properties * @param outer 4 boolean values indicating if the side represents the * table's outer border. Order: before, after, start, end + * @param context Property evaluation context */ public static void addCollapsingBorders(Area area, CommonBorderPaddingBackground bordProps, - boolean[] outer) { + boolean[] outer, + PercentBaseContext context) { BorderProps bps = getCollapsingBorderProps(bordProps, CommonBorderPaddingBackground.BEFORE, outer[0]); if (bps != null) { @@ -161,26 +170,27 @@ public class TraitSetter { area.addTrait(Trait.BORDER_END, bps); } - addPadding(area, bordProps); + addPadding(area, bordProps, context); } - private static void addPadding(Area area, CommonBorderPaddingBackground bordProps) { - int padding = bordProps.getPadding(CommonBorderPaddingBackground.START, false); + private static void addPadding(Area area, CommonBorderPaddingBackground bordProps, + PercentBaseContext context) { + int padding = bordProps.getPadding(CommonBorderPaddingBackground.START, false, context); if (padding != 0) { area.addTrait(Trait.PADDING_START, new java.lang.Integer(padding)); } - padding = bordProps.getPadding(CommonBorderPaddingBackground.END, false); + padding = bordProps.getPadding(CommonBorderPaddingBackground.END, false, context); if (padding != 0) { area.addTrait(Trait.PADDING_END, new java.lang.Integer(padding)); } - padding = bordProps.getPadding(CommonBorderPaddingBackground.BEFORE, false); + padding = bordProps.getPadding(CommonBorderPaddingBackground.BEFORE, false, context); if (padding != 0) { area.addTrait(Trait.PADDING_BEFORE, new java.lang.Integer(padding)); } - padding = bordProps.getPadding(CommonBorderPaddingBackground.AFTER, false); + padding = bordProps.getPadding(CommonBorderPaddingBackground.AFTER, false, context); if (padding != 0) { area.addTrait(Trait.PADDING_AFTER, new java.lang.Integer(padding)); } @@ -221,8 +231,11 @@ public class TraitSetter { * Note: The area's IPD and BPD must be set before calling this method. * @param area the area to set the traits on * @param backProps the background properties + * @param context Property evaluation context */ - public static void addBackground(Area area, CommonBorderPaddingBackground backProps) { + public static void addBackground(Area area, + CommonBorderPaddingBackground backProps, + PercentBaseContext context) { if (!backProps.hasBackground()) { return; } @@ -236,43 +249,42 @@ public class TraitSetter { if (backProps.backgroundPositionHorizontal != null) { if (back.getRepeat() == Constants.EN_NOREPEAT || back.getRepeat() == Constants.EN_REPEATY) { - if (backProps.backgroundPositionHorizontal instanceof PercentLength) { - if (area.getIPD() > 0) { - int width = area.getIPD(); - width += backProps.getPaddingStart(false); - width += backProps.getPaddingEnd(false); - back.setHoriz((int)((width - back.getFopImage().getIntrinsicWidth()) - * ((PercentLength)backProps.backgroundPositionHorizontal).value())); - } else { - //TODO Area IPD has to be set for this to work - log.warn("Horizontal background image positioning ignored" - + " because the IPD was not set on the area." - + " (Yes, it's a bug in FOP)"); - } + if (area.getIPD() > 0) { + int width = area.getIPD(); + width += backProps.getPaddingStart(false, context); + width += backProps.getPaddingEnd(false, context); + back.setHoriz(backProps.backgroundPositionHorizontal.getValue( + new SimplePercentBaseContext(context, + LengthBase.IMAGE_BACKGROUND_POSITION_HORIZONTAL, + (width - back.getFopImage().getIntrinsicWidth()) + ) + )); } else { - back.setHoriz(backProps.backgroundPositionHorizontal.getValue()); + //TODO Area IPD has to be set for this to work + log.warn("Horizontal background image positioning ignored" + + " because the IPD was not set on the area." + + " (Yes, it's a bug in FOP)"); } } } if (backProps.backgroundPositionVertical != null) { if (back.getRepeat() == Constants.EN_NOREPEAT || back.getRepeat() == Constants.EN_REPEATX) { - if (backProps.backgroundPositionVertical instanceof PercentLength) { - if (area.getBPD() > 0) { - int height = area.getBPD(); - height += backProps.getPaddingBefore(false); - height += backProps.getPaddingAfter(false); - back.setVertical( - (int)((height - back.getFopImage().getIntrinsicHeight()) - * ((PercentLength)backProps.backgroundPositionVertical).value())); - } else { - //TODO Area BPD has to be set for this to work - log.warn("Vertical background image positioning ignored" - + " because the BPD was not set on the area." - + " (Yes, it's a bug in FOP)"); - } + if (area.getBPD() > 0) { + int height = area.getBPD(); + height += backProps.getPaddingBefore(false, context); + height += backProps.getPaddingAfter(false, context); + back.setVertical(backProps.backgroundPositionVertical.getValue( + new SimplePercentBaseContext(context, + LengthBase.IMAGE_BACKGROUND_POSITION_VERTICAL, + (height - back.getFopImage().getIntrinsicHeight()) + ) + )); } else { - back.setVertical(backProps.backgroundPositionVertical.getValue()); + //TODO Area BPD has to be set for this to work + log.warn("Vertical background image positioning ignored" + + " because the BPD was not set on the area." + + " (Yes, it's a bug in FOP)"); } } } @@ -288,29 +300,31 @@ public class TraitSetter { * @param area the area to set the traits on. * @param bpProps the border, padding and background properties * @param marginProps the margin properties. + * @param context the context for evaluation of percentages */ public static void addMargins(Area area, CommonBorderPaddingBackground bpProps, - CommonMarginBlock marginProps) { - int startIndent = marginProps.startIndent.getValue(); + CommonMarginBlock marginProps, + PercentBaseContext context) { + int startIndent = marginProps.startIndent.getValue(context); if (startIndent != 0) { area.addTrait(Trait.START_INDENT, new Integer(startIndent)); } - int spaceStart = marginProps.startIndent.getValue() + int spaceStart = marginProps.startIndent.getValue(context) - bpProps.getBorderStartWidth(false) - - bpProps.getPaddingStart(false); + - bpProps.getPaddingStart(false, context); if (spaceStart != 0) { area.addTrait(Trait.SPACE_START, new Integer(spaceStart)); } - int endIndent = marginProps.endIndent.getValue(); + int endIndent = marginProps.endIndent.getValue(context); if (endIndent != 0) { area.addTrait(Trait.END_INDENT, new Integer(endIndent)); } - int spaceEnd = marginProps.endIndent.getValue() + int spaceEnd = marginProps.endIndent.getValue(context) - bpProps.getBorderEndWidth(false) - - bpProps.getPaddingEnd(false); + - bpProps.getPaddingEnd(false, context); if (spaceEnd != 0) { area.addTrait(Trait.SPACE_END, new Integer(spaceEnd)); } diff --git a/src/java/org/apache/fop/layoutmgr/inline/BidiLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/BidiLayoutManager.java index 6a60f4205..bc6a0d44a 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/BidiLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/BidiLayoutManager.java @@ -1,5 +1,5 @@ /* - * Copyright 1999-2004 The Apache Software Foundation. + * Copyright 1999-2005 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. @@ -36,6 +36,7 @@ public class BidiLayoutManager extends LeafNodeLayoutManager { public BidiLayoutManager(BidiOverride node, InlineLayoutManager cLM) { super(node); + setParent(cLM); children = new ArrayList(); /* for (int count = cLM.size() - 1; count >= 0; count--) { diff --git a/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java index b278c0f2b..c15ee02c4 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/CharacterLayoutManager.java @@ -54,10 +54,14 @@ public class CharacterLayoutManager extends LeafNodeLayoutManager { public CharacterLayoutManager(Character node) { super(node); fobj = node; - InlineArea inline = getCharacterInlineArea(node); + } + + public void initialize() { + InlineArea inline = getCharacterInlineArea(fobj); setCurrentArea(inline); + setAlignment(fobj.getVerticalAlign()); - fs = fobj.getCommonFont().getFontState(fobj.getFOEventHandler().getFontInfo()); + fs = fobj.getCommonFont().getFontState(fobj.getFOEventHandler().getFontInfo(), this); SpaceVal ls = SpaceVal.makeLetterSpacing(fobj.getLetterSpacing()); letterSpaceIPD = ls.getSpace(); diff --git a/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java index d55208a20..6c094f6a3 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java @@ -21,6 +21,7 @@ package org.apache.fop.layoutmgr.inline; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.fo.Constants; import org.apache.fop.fo.pagination.Title; +import org.apache.fop.layoutmgr.AbstractBaseLayoutManager; import org.apache.fop.layoutmgr.KnuthElement; import org.apache.fop.layoutmgr.KnuthPossPosIter; import org.apache.fop.layoutmgr.LayoutContext; @@ -41,13 +42,15 @@ import org.apache.fop.traits.MinOptMax; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.fop.area.Block; /** * Content Layout Manager. * For use with objects that contain inline areas such as * leader use-content and title. */ -public class ContentLayoutManager implements InlineLevelLayoutManager { +public class ContentLayoutManager extends AbstractBaseLayoutManager + implements InlineLevelLayoutManager { private FOUserAgent userAgent; private Area holder; private int stackSize; @@ -55,11 +58,6 @@ public class ContentLayoutManager implements InlineLevelLayoutManager { private InlineLevelLayoutManager childLM = null; /** - * logging instance - */ - protected static Log log = LogFactory.getLog(LayoutManager.class); - - /** * Constructs a new ContentLayoutManager * * @param area The parent area @@ -88,6 +86,10 @@ public class ContentLayoutManager implements InlineLevelLayoutManager { fillArea(lm); } + public void initialize() { + // Empty + } + public void fillArea(LayoutManager curLM) { int ipd = 1000000; @@ -311,5 +313,45 @@ public class ContentLayoutManager implements InlineLevelLayoutManager { public PageSequenceLayoutManager getPSLM() { return parentLM.getPSLM(); } + + // --------- Property Resolution related functions --------- // + + /** + * Returns the IPD of the content area + * @return the IPD of the content area + */ + public int getContentAreaIPD() { + return holder.getIPD(); + } + + /** + * Returns the BPD of the content area + * @return the BPD of the content area + */ + public int getContentAreaBPD() { + return holder.getBPD(); + } + + /** + * @see org.apache.fop.layoutmgr.LayoutManager#getGeneratesReferenceArea + */ + public boolean getGeneratesReferenceArea() { + return false; + } + + /** + * @see org.apache.fop.layoutmgr.LayoutManager#getGeneratesBlockArea + */ + public boolean getGeneratesBlockArea() { + return getGeneratesLineArea() || holder instanceof Block; + } + + /** + * @see org.apache.fop.layoutmgr.LayoutManager#getGeneratesLineArea + */ + public boolean getGeneratesLineArea() { + return holder instanceof LineArea; + } + } diff --git a/src/java/org/apache/fop/layoutmgr/inline/ExternalGraphicLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/ExternalGraphicLayoutManager.java index cc5dd8ca7..b31b5ea04 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/ExternalGraphicLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/ExternalGraphicLayoutManager.java @@ -20,14 +20,18 @@ package org.apache.fop.layoutmgr.inline; // Java import java.awt.geom.Rectangle2D; +import java.util.LinkedList; // FOP import org.apache.fop.area.inline.Image; import org.apache.fop.area.inline.InlineArea; import org.apache.fop.area.inline.Viewport; import org.apache.fop.datatypes.Length; +import org.apache.fop.datatypes.LengthBase; +import org.apache.fop.fo.FObj; import org.apache.fop.fo.flow.ExternalGraphic; import org.apache.fop.fo.properties.CommonBorderPaddingBackground; +import org.apache.fop.layoutmgr.LayoutContext; import org.apache.fop.layoutmgr.TraitSetter; /** @@ -57,11 +61,6 @@ public class ExternalGraphicLayoutManager extends LeafNodeLayoutManager { public ExternalGraphicLayoutManager(ExternalGraphic node) { super(node); fobj = node; - setup(); - InlineArea area = getExternalGraphicInlineArea(); - setCurrentArea(area); - setAlignment(fobj.getVerticalAlign()); - setLead(viewHeight); } /** @@ -71,22 +70,22 @@ public class ExternalGraphicLayoutManager extends LeafNodeLayoutManager { */ private void setup() { // assume lr-tb for now and just use the .optimum value of the range - Length ipd = fobj.getInlineProgressionDimension().getOptimum().getLength(); + Length ipd = fobj.getInlineProgressionDimension().getOptimum(this).getLength(); if (ipd.getEnum() != EN_AUTO) { - viewWidth = ipd.getValue(); + viewWidth = ipd.getValue(this); } else { ipd = fobj.getWidth(); if (ipd.getEnum() != EN_AUTO) { - viewWidth = ipd.getValue(); + viewWidth = ipd.getValue(this); } } - Length bpd = fobj.getBlockProgressionDimension().getOptimum().getLength(); + Length bpd = fobj.getBlockProgressionDimension().getOptimum(this).getLength(); if (bpd.getEnum() != EN_AUTO) { - viewHeight = bpd.getValue(); + viewHeight = bpd.getValue(this); } else { bpd = fobj.getHeight(); if (bpd.getEnum() != EN_AUTO) { - viewHeight = bpd.getValue(); + viewHeight = bpd.getValue(this); } } @@ -99,7 +98,7 @@ public class ExternalGraphicLayoutManager extends LeafNodeLayoutManager { cheight = viewHeight; } } else { - cheight = ch.getValue(); + cheight = ch.getValue(this); } } Length cw = fobj.getContentWidth(); @@ -109,7 +108,7 @@ public class ExternalGraphicLayoutManager extends LeafNodeLayoutManager { cwidth = viewWidth; } } else { - cwidth = cw.getValue(); + cwidth = cw.getValue(this); } } @@ -189,10 +188,10 @@ public class ExternalGraphicLayoutManager extends LeafNodeLayoutManager { CommonBorderPaddingBackground borderProps = fobj.getCommonBorderPaddingBackground(); //Determine extra BPD from borders etc. - int beforeBPD = borderProps.getPadding(CommonBorderPaddingBackground.BEFORE, false); + int beforeBPD = borderProps.getPadding(CommonBorderPaddingBackground.BEFORE, false, this); beforeBPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.BEFORE, false); - int afterBPD = borderProps.getPadding(CommonBorderPaddingBackground.AFTER, false); + int afterBPD = borderProps.getPadding(CommonBorderPaddingBackground.AFTER, false, this); afterBPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.AFTER, false); yoffset += beforeBPD; @@ -201,10 +200,10 @@ public class ExternalGraphicLayoutManager extends LeafNodeLayoutManager { //Determine extra IPD from borders etc. int startIPD = borderProps.getPadding(CommonBorderPaddingBackground.START, - false/*bNotFirst*/); + false/*bNotFirst*/, this); startIPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.START, false/*bNotFirst*/); - int endIPD = borderProps.getPadding(CommonBorderPaddingBackground.END, false/*bNotLast*/); + int endIPD = borderProps.getPadding(CommonBorderPaddingBackground.END, false/*bNotLast*/, this); endIPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.END, false/*bNotLast*/); xoffset += startIPD; @@ -214,6 +213,19 @@ public class ExternalGraphicLayoutManager extends LeafNodeLayoutManager { placement = new Rectangle2D.Float(xoffset, yoffset, cwidth, cheight); } + /** + * @see org.apache.fop.layoutmgr.LayoutManager#getNextKnuthElements(LayoutContext, int) + */ + public LinkedList getNextKnuthElements(LayoutContext context, + int alignment) { + setup(); + InlineArea area = getExternalGraphicInlineArea(); + setCurrentArea(area); + setAlignment(fobj.getVerticalAlign()); + setLead(viewHeight); + return super.getNextKnuthElements(context, alignment); + } + /** * Get the inline area for this external grpahic. * This creates the image area and puts it inside a viewport. @@ -232,8 +244,8 @@ public class ExternalGraphicLayoutManager extends LeafNodeLayoutManager { vp.setOffset(0); // Common Border, Padding, and Background Properties - TraitSetter.addBorders(vp, fobj.getCommonBorderPaddingBackground()); - TraitSetter.addBackground(vp, fobj.getCommonBorderPaddingBackground()); + TraitSetter.addBorders(vp, fobj.getCommonBorderPaddingBackground(), this); + TraitSetter.addBackground(vp, fobj.getCommonBorderPaddingBackground(), this); return vp; } @@ -242,5 +254,38 @@ public class ExternalGraphicLayoutManager extends LeafNodeLayoutManager { protected void addId() { getPSLM().addIDToPage(fobj.getId()); } + + // --------- Property Resolution related functions --------- // + + /** + * @see org.apache.fop.datatypes.PercentBaseContext#getBaseLength(int, FObj) + */ + public int getBaseLength(int lengthBase, FObj fobj) { + switch (lengthBase) { + case LengthBase.IMAGE_INTRINSIC_WIDTH: + return getIntrinsicWidth(); + case LengthBase.IMAGE_INTRINSIC_HEIGHT: + return getIntrinsicHeight(); + default: // Delegate to super class + return super.getBaseLength(lengthBase, fobj); + } + } + + /** + * Returns the intrinsic width of the e-g. + * @return the width of the element + */ + protected int getIntrinsicWidth() { + return fobj.getIntrinsicWidth(); + } + + /** + * Returns the intrinsic height of the e-g. + * @return the height of the element + */ + protected int getIntrinsicHeight() { + return fobj.getIntrinsicHeight(); + } + } diff --git a/src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.java index 21267f7c5..44d8fc8ed 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/FootnoteLayoutManager.java @@ -44,7 +44,9 @@ public class FootnoteLayoutManager extends AbstractLayoutManager public FootnoteLayoutManager(Footnote node) { super(node); footnote = node; - + } + + public void initialize() { // create an InlineStackingLM handling the fo:inline child of fo:footnote citationLM = new InlineLayoutManager(footnote.getFootnoteCitation()); @@ -61,7 +63,9 @@ public class FootnoteLayoutManager extends AbstractLayoutManager // set the citationLM parent to be this LM's parent citationLM.setParent(getParent()); + citationLM.initialize(); bodyLM.setParent(this); + bodyLM.initialize(); // get Knuth elements representing the footnote citation LinkedList returnedList = new LinkedList(); diff --git a/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java index 72b8c7bad..3463e3883 100755 --- a/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java @@ -67,31 +67,30 @@ public class InlineLayoutManager extends InlineStackingLayoutManager public InlineLayoutManager(InlineLevel node) { super(node); fobj = node; - initialize(); } private Inline getInlineFO() { return (Inline)fobj; } - private void initialize() { + public void initialize() { inlineProps = fobj.getCommonMarginInline(); borderProps = fobj.getCommonBorderPaddingBackground(); - int iPad = borderProps.getPadding(CommonBorderPaddingBackground.BEFORE, false); + int iPad = borderProps.getPadding(CommonBorderPaddingBackground.BEFORE, false, this); iPad += borderProps.getBorderWidth(CommonBorderPaddingBackground.BEFORE, false); - iPad += borderProps.getPadding(CommonBorderPaddingBackground.AFTER, false); + iPad += borderProps.getPadding(CommonBorderPaddingBackground.AFTER, false, this); iPad += borderProps.getBorderWidth(CommonBorderPaddingBackground.AFTER, false); extraBPD = new MinOptMax(iPad); } protected MinOptMax getExtraIPD(boolean bNotFirst, boolean bNotLast) { int iBP = borderProps.getPadding(CommonBorderPaddingBackground.START, - bNotFirst); + bNotFirst, this); iBP += borderProps.getBorderWidth(CommonBorderPaddingBackground.START, bNotFirst); - iBP += borderProps.getPadding(CommonBorderPaddingBackground.END, bNotLast); + iBP += borderProps.getPadding(CommonBorderPaddingBackground.END, bNotLast, this); iBP += borderProps.getBorderWidth(CommonBorderPaddingBackground.END, bNotLast); return new MinOptMax(iBP); } @@ -99,14 +98,14 @@ public class InlineLayoutManager extends InlineStackingLayoutManager protected boolean hasLeadingFence(boolean bNotFirst) { int iBP = borderProps.getPadding(CommonBorderPaddingBackground.START, - bNotFirst); + bNotFirst, this); iBP += borderProps.getBorderWidth(CommonBorderPaddingBackground.START, bNotFirst); return (iBP > 0); } protected boolean hasTrailingFence(boolean bNotLast) { - int iBP = borderProps.getPadding(CommonBorderPaddingBackground.END, bNotLast); + int iBP = borderProps.getPadding(CommonBorderPaddingBackground.END, bNotLast, this); iBP += borderProps.getBorderWidth(CommonBorderPaddingBackground.END, bNotLast); return (iBP > 0); } @@ -138,11 +137,11 @@ public class InlineLayoutManager extends InlineStackingLayoutManager // Add border and padding to current area and set flags (FIRST, LAST ...) TraitSetter.setBorderPaddingTraits(getCurrentArea(), - borderProps, bNotFirst, bNotLast); + borderProps, bNotFirst, bNotLast, this); if (borderProps != null) { - TraitSetter.addBorders(getCurrentArea(), borderProps); - TraitSetter.addBackground(getCurrentArea(), borderProps); + TraitSetter.addBorders(getCurrentArea(), borderProps, this); + TraitSetter.addBackground(getCurrentArea(), borderProps, this); } } @@ -166,7 +165,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager // not be the first area created by this inline childLC = new LayoutContext(lc); if (getSpaceStart() != null) { - lc.getLeadingSpace().addSpace(new SpaceVal(getSpaceStart())); + lc.getLeadingSpace().addSpace(new SpaceVal(getSpaceStart(), this)); } // Check for "fence" @@ -308,8 +307,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager * * @param parentIter Iterator over Position information returned * by this LayoutManager. - * @param dSpaceAdjust Factor controlling how much extra space to add - * in order to justify the line. + * @param context layout context. */ public void addAreas(PositionIterator parentIter, LayoutContext context) { @@ -331,7 +329,7 @@ public class InlineLayoutManager extends InlineStackingLayoutManager } if (getSpaceStart() != null) { - context.getLeadingSpace().addSpace(new SpaceVal(getSpaceStart())); + context.getLeadingSpace().addSpace(new SpaceVal(getSpaceStart(), this)); } // "unwrap" the NonLeafPositions stored in parentIter @@ -391,11 +389,12 @@ public class InlineLayoutManager extends InlineStackingLayoutManager } // Add own trailing space to parent context (or set on area?) if (context.getTrailingSpace() != null && getSpaceEnd() != null) { - context.getTrailingSpace().addSpace(new SpaceVal(getSpaceEnd())); + context.getTrailingSpace().addSpace(new SpaceVal(getSpaceEnd(), this)); } - setTraits(bAreaCreated, !bIsLast); parentLM.addChildArea(getCurrentArea()); + setTraits(bAreaCreated, !bIsLast); + context.setFlags(LayoutContext.LAST_AREA, bIsLast); bAreaCreated = true; } diff --git a/src/java/org/apache/fop/layoutmgr/inline/InstreamForeignObjectLM.java b/src/java/org/apache/fop/layoutmgr/inline/InstreamForeignObjectLM.java index e0d06dcb5..c7dea09c8 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/InstreamForeignObjectLM.java +++ b/src/java/org/apache/fop/layoutmgr/inline/InstreamForeignObjectLM.java @@ -20,15 +20,19 @@ package org.apache.fop.layoutmgr.inline; // Java import java.awt.geom.Rectangle2D; +import java.util.LinkedList; // FOP import org.apache.fop.datatypes.Length; +import org.apache.fop.datatypes.LengthBase; import org.apache.fop.fo.XMLObj; import org.apache.fop.fo.flow.InstreamForeignObject; import org.apache.fop.fo.properties.CommonBorderPaddingBackground; import org.apache.fop.layoutmgr.TraitSetter; import org.apache.fop.area.inline.ForeignObject; import org.apache.fop.area.inline.Viewport; +import org.apache.fop.fo.FObj; +import org.apache.fop.layoutmgr.LayoutContext; /** * LayoutManager for the fo:instream-foreign-object formatting object @@ -40,14 +44,11 @@ public class InstreamForeignObjectLM extends LeafNodeLayoutManager { /** * Constructor * @param node the formatting object that creates this area + * @param parent the parent layout manager */ public InstreamForeignObjectLM(InstreamForeignObject node) { super(node); fobj = node; - Viewport areaCurrent = getInlineArea(); - setCurrentArea(areaCurrent); - setAlignment(node.getVerticalAlign()); - setLead(areaCurrent.getBPD()); } /** @@ -73,29 +74,29 @@ public class InstreamForeignObjectLM extends LeafNodeLayoutManager { int ipd = -1; boolean bpdauto = false; if (hasLH) { - bpd = fobj.getLineHeight().getValue(); + bpd = fobj.getLineHeight().getValue(this); } else { // this property does not apply when the line-height applies // isn't the block-progression-dimension always in the same // direction as the line height? - len = fobj.getBlockProgressionDimension().getOptimum().getLength(); + len = fobj.getBlockProgressionDimension().getOptimum(this).getLength(); if (len.getEnum() != EN_AUTO) { - bpd = len.getValue(); + bpd = len.getValue(this); } else { len = fobj.getHeight(); if (len.getEnum() != EN_AUTO) { - bpd = len.getValue(); + bpd = len.getValue(this); } } } - len = fobj.getInlineProgressionDimension().getOptimum().getLength(); + len = fobj.getInlineProgressionDimension().getOptimum(this).getLength(); if (len.getEnum() != EN_AUTO) { - ipd = len.getValue(); + ipd = len.getValue(this); } else { len = fobj.getWidth(); if (len.getEnum() != EN_AUTO) { - ipd = len.getValue(); + ipd = len.getValue(this); } } @@ -110,7 +111,7 @@ public class InstreamForeignObjectLM extends LeafNodeLayoutManager { cwidth = ipd; } } else { - cwidth = len.getValue(); + cwidth = len.getValue(this); } } len = fobj.getContentHeight(); @@ -120,7 +121,7 @@ public class InstreamForeignObjectLM extends LeafNodeLayoutManager { cwidth = bpd; } } else { - cheight = len.getValue(); + cheight = len.getValue(this); } } @@ -172,10 +173,10 @@ public class InstreamForeignObjectLM extends LeafNodeLayoutManager { CommonBorderPaddingBackground borderProps = fobj.getCommonBorderPaddingBackground(); //Determine extra BPD from borders etc. - int beforeBPD = borderProps.getPadding(CommonBorderPaddingBackground.BEFORE, false); + int beforeBPD = borderProps.getPadding(CommonBorderPaddingBackground.BEFORE, false, this); beforeBPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.BEFORE, false); - int afterBPD = borderProps.getPadding(CommonBorderPaddingBackground.AFTER, false); + int afterBPD = borderProps.getPadding(CommonBorderPaddingBackground.AFTER, false, this); afterBPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.AFTER, false); yoffset += beforeBPD; @@ -184,10 +185,10 @@ public class InstreamForeignObjectLM extends LeafNodeLayoutManager { //Determine extra IPD from borders etc. int startIPD = borderProps.getPadding(CommonBorderPaddingBackground.START, - false/*bNotFirst*/); + false/*bNotFirst*/, this); startIPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.START, false/*bNotFirst*/); - int endIPD = borderProps.getPadding(CommonBorderPaddingBackground.END, false/*bNotLast*/); + int endIPD = borderProps.getPadding(CommonBorderPaddingBackground.END, false/*bNotLast*/, this); endIPD += borderProps.getBorderWidth(CommonBorderPaddingBackground.END, false/*bNotLast*/); xoffset += startIPD; @@ -212,17 +213,62 @@ public class InstreamForeignObjectLM extends LeafNodeLayoutManager { vp.setOffset(0); // Common Border, Padding, and Background Properties - TraitSetter.addBorders(vp, fobj.getCommonBorderPaddingBackground()); - TraitSetter.addBackground(vp, fobj.getCommonBorderPaddingBackground()); + TraitSetter.addBorders(vp, fobj.getCommonBorderPaddingBackground(), this); + TraitSetter.addBackground(vp, fobj.getCommonBorderPaddingBackground(), this); return vp; } /** + * @see org.apache.fop.layoutmgr.LayoutManager#getNextKnuthElements(LayoutContext, int) + */ + public LinkedList getNextKnuthElements(LayoutContext context, + int alignment) { + Viewport areaCurrent = getInlineArea(); + setCurrentArea(areaCurrent); + setAlignment(fobj.getVerticalAlign()); + setLead(areaCurrent.getBPD()); + return super.getNextKnuthElements(context, alignment); + } + + /** * @see org.apache.fop.layoutmgr.inline.LeafNodeLayoutManager#addId() */ protected void addId() { getPSLM().addIDToPage(fobj.getId()); } + + // --------- Property Resolution related functions --------- // + + /** + * @see org.apache.fop.datatypes.PercentBaseContext#getBaseLength(int, FObj) + */ + public int getBaseLength(int lengthBase, FObj fobj) { + switch (lengthBase) { + case LengthBase.IMAGE_INTRINSIC_WIDTH: + return getIntrinsicWidth(); + case LengthBase.IMAGE_INTRINSIC_HEIGHT: + return getIntrinsicHeight(); + default: // Delegate to super class + return super.getBaseLength(lengthBase, fobj); + } + } + + /** + * Returns the intrinsic width of the e-g. + * @return the width of the element + */ + protected int getIntrinsicWidth() { + return fobj.getIntrinsicWidth(); + } + + /** + * Returns the intrinsic height of the e-g. + * @return the height of the element + */ + protected int getIntrinsicHeight() { + return fobj.getIntrinsicHeight(); + } + } diff --git a/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java index 7d87ea8fd..26a58bf68 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java @@ -23,7 +23,6 @@ import org.apache.fop.area.inline.FilledArea; import org.apache.fop.area.inline.InlineArea; import org.apache.fop.area.inline.Space; import org.apache.fop.area.inline.TextArea; -import org.apache.fop.datatypes.PercentBase; import org.apache.fop.fo.flow.Leader; import org.apache.fop.fonts.Font; import org.apache.fop.layoutmgr.KnuthElement; @@ -40,6 +39,8 @@ import org.apache.fop.traits.MinOptMax; import java.util.List; import java.util.LinkedList; +import org.apache.fop.fo.FObj; +import org.apache.fop.layoutmgr.inline.LeafNodeLayoutManager.AreaInfo; /** * LayoutManager for the fo:leader formatting object @@ -50,6 +51,8 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager { private LinkedList contentList = null; private ContentLayoutManager clm = null; + + private int contentAreaIPD = 0; /** * Constructor @@ -60,7 +63,10 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager { public LeaderLayoutManager(Leader node) { super(node); fobj = node; - font = fobj.getCommonFont().getFontState(fobj.getFOEventHandler().getFontInfo()); + } + + public void initialize() { + font = fobj.getCommonFont().getFontState(fobj.getFOEventHandler().getFontInfo(), this); // the property leader-alignment does not affect vertical positioning // (see section 7.21.1 in the XSL Recommendation) // setAlignment(node.getLeaderAlignment()); @@ -77,10 +83,10 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager { private MinOptMax getLeaderAllocIPD(int ipd) { // length of the leader - fobj.setLayoutDimension(PercentBase.BLOCK_IPD, ipd); - int opt = fobj.getLeaderLength().getOptimum().getLength().getValue(); - int min = fobj.getLeaderLength().getMinimum().getLength().getValue(); - int max = fobj.getLeaderLength().getMaximum().getLength().getValue(); + setContentAreaIPD(ipd); + int opt = fobj.getLeaderLength().getOptimum(this).getLength().getValue(this); + int min = fobj.getLeaderLength().getMinimum(this).getLength().getValue(this); + int max = fobj.getLeaderLength().getMaximum(this).getLength().getValue(this); return new MinOptMax(min, opt, max); } @@ -91,10 +97,12 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager { org.apache.fop.area.inline.Leader leader = new org.apache.fop.area.inline.Leader(); leader.setRuleStyle(fobj.getRuleStyle()); - leader.setRuleThickness(fobj.getRuleThickness().getValue()); + leader.setRuleThickness(fobj.getRuleThickness().getValue(this)); + leader.setBPD(fobj.getRuleThickness().getValue(this)); leaderArea = leader; } else if (fobj.getLeaderPattern() == EN_SPACE) { leaderArea = new Space(); + leaderArea.setBPD(font.getAscender()); } else if (fobj.getLeaderPattern() == EN_DOTS) { TextArea t = new TextArea(); char dot = '.'; // userAgent.getLeaderDotCharacter(); @@ -105,10 +113,10 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager { t.addTrait(Trait.FONT_SIZE, new Integer(font.getFontSize())); int width = font.getCharWidth(dot); Space spacer = null; - if (fobj.getLeaderPatternWidth().getValue() > width) { + if (fobj.getLeaderPatternWidth().getValue(this) > width) { spacer = new Space(); - spacer.setIPD(fobj.getLeaderPatternWidth().getValue() - width); - width = fobj.getLeaderPatternWidth().getValue(); + spacer.setIPD(fobj.getLeaderPatternWidth().getValue(this) - width); + width = fobj.getLeaderPatternWidth().getValue(this); } FilledArea fa = new FilledArea(); fa.setUnitWidth(width); @@ -142,10 +150,10 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager { contentList = clm.getNextKnuthElements(new LayoutContext(0), 0); int width = clm.getStackingSize(); Space spacer = null; - if (fobj.getLeaderPatternWidth().getValue() > width) { + if (fobj.getLeaderPatternWidth().getValue(this) > width) { spacer = new Space(); - spacer.setIPD(fobj.getLeaderPatternWidth().getValue() - width); - width = fobj.getLeaderPatternWidth().getValue(); + spacer.setIPD(fobj.getLeaderPatternWidth().getValue(this) - width); + width = fobj.getLeaderPatternWidth().getValue(this); } fa.setUnitWidth(width); if (spacer != null) { @@ -334,4 +342,24 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager { protected void addId() { getPSLM().addIDToPage(fobj.getId()); } + + /** + * @see org.apache.fop.datatypes.PercentBaseContext#getBaseLength(int, FObj) + */ + public int getBaseLength(int lengthBase, FObj fobj) { + return getParent().getBaseLength(lengthBase, getParent().getFObj()); + } + + /** + * Returns the IPD of the content area + * @return the IPD of the content area + */ + public int getContentAreaIPD() { + return contentAreaIPD; + } + + private void setContentAreaIPD(int contentAreaIPD) { + this.contentAreaIPD = contentAreaIPD; + } + } diff --git a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java index eb669be69..c58d9ce7c 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java @@ -68,7 +68,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager private Block fobj; - private void initialize() { + public void initialize() { bTextAlignment = fobj.getTextAlign(); bTextAlignmentLast = fobj.getTextAlignLast(); textIndent = fobj.getTextIndent(); @@ -139,7 +139,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager private CommonHyphenation hyphProps; //private LayoutProps layoutProps; - private int lineHeight; + private Length lineHeight; private int lead; private int follow; // offset of the middle baseline with respect to the main baseline @@ -222,8 +222,8 @@ public class LineLayoutManager extends InlineStackingLayoutManager // add the element representing text indentation // at the beginning of the first paragraph if (knuthParagraphs.size() == 0 - && fobj.getTextIndent().getValue() != 0) { - this.add(new KnuthInlineBox(fobj.getTextIndent().getValue(), 0, 0, 0, + && fobj.getTextIndent().getValue(layoutManager) != 0) { + this.add(new KnuthInlineBox(fobj.getTextIndent().getValue(layoutManager), 0, 0, 0, null, false)); ignoreAtStart ++; } @@ -575,7 +575,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager * @param l the default lead, from top to baseline * @param f the default follow, from baseline to bottom */ - public LineLayoutManager(Block block, int lh, int l, int f, int ms) { + public LineLayoutManager(Block block, Length lh, int l, int f, int ms) { super(block); fobj = block; // the child FObj are owned by the parent BlockLM @@ -585,7 +585,6 @@ public class LineLayoutManager extends InlineStackingLayoutManager lead = l; follow = f; middleShift = ms; - initialize(); // Normally done when started by parent! } /** @see org.apache.fop.layoutmgr.LayoutManager */ @@ -601,7 +600,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager int iPrevLineEnd = vecInlineBreaks.size(); if (iPrevLineEnd == 0 && bTextAlignment == EN_START) { - availIPD.subtract(new MinOptMax(textIndent.getValue())); + availIPD.subtract(new MinOptMax(textIndent.getValue(this))); } //PHASE 1: Create Knuth elements @@ -741,7 +740,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager if (lastPar == null) { lastPar = new Paragraph(this, bTextAlignment, bTextAlignmentLast, - textIndent.getValue()); + textIndent.getValue(this)); lastPar.startParagraph(availIPD.opt); if (log.isTraceEnabled()) { trace.append(" ["); @@ -881,7 +880,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager ? difference / 2 : (textAlign == EN_END) ? difference : 0; indent += (line == 1 && knuthParagraphs.indexOf(par) == 0) - ? textIndent.getValue() : 0; + ? textIndent.getValue(this) : 0; double ratio = (textAlign == EN_JUSTIFY) ? knuthPara.getAdjustRatio(i) : 0; @@ -1012,8 +1011,8 @@ public class LineLayoutManager extends InlineStackingLayoutManager int iBPcount = 0; LineBreakingAlgorithm alg = new LineBreakingAlgorithm(alignment, bTextAlignment, bTextAlignmentLast, - textIndent.getValue(), currPar.lineFiller.opt, - lineHeight, lead, follow, middleShift, + textIndent.getValue(this), currPar.lineFiller.opt, + lineHeight.getValue(this), lead, follow, middleShift, (knuthParagraphs.indexOf(currPar) == 0), this); @@ -1324,6 +1323,9 @@ public class LineLayoutManager extends InlineStackingLayoutManager return false; } + /** + * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#negotiateBPDAdjustment(int, org.apache.fop.layoutmgr.KnuthElement) + */ public int negotiateBPDAdjustment(int adj, KnuthElement lastElement) { LeafPosition pos = (LeafPosition)lastElement.getPosition(); int totalAdj = adj; @@ -1774,5 +1776,21 @@ public class LineLayoutManager extends InlineStackingLayoutManager } } + // --------- Property Resolution related functions --------- // + + /** + * @see org.apache.fop.layoutmgr.LayoutManager#getGeneratesBlockArea + */ + public boolean getGeneratesBlockArea() { + return true; + } + + /** + * @see org.apache.fop.layoutmgr.LayoutManager#getGeneratesLineArea + */ + public boolean getGeneratesLineArea() { + return true; + } + } diff --git a/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java index bd075f45d..7ed3cf8f7 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java @@ -51,7 +51,10 @@ public class PageNumberCitationLayoutManager extends LeafNodeLayoutManager { public PageNumberCitationLayoutManager(PageNumberCitation node) { super(node); fobj = node; - font = fobj.getCommonFont().getFontState(fobj.getFOEventHandler().getFontInfo()); + } + + public void initialize() { + font = fobj.getCommonFont().getFontState(fobj.getFOEventHandler().getFontInfo(), this); } public InlineArea get(LayoutContext context) { diff --git a/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java index 17c40aece..2a89d4ab5 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java @@ -43,7 +43,10 @@ public class PageNumberLayoutManager extends LeafNodeLayoutManager { public PageNumberLayoutManager(PageNumber node) { super(node); fobj = node; - font = fobj.getCommonFont().getFontState(fobj.getFOEventHandler().getFontInfo()); + } + + public void initialize() { + font = fobj.getCommonFont().getFontState(fobj.getFOEventHandler().getFontInfo(), this); } public InlineArea get(LayoutContext context) { diff --git a/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java index 77d560df1..adf4514d8 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java @@ -132,7 +132,6 @@ public class TextLayoutManager extends LeafNodeLayoutManager { private int total = 0; private int middle = 0; private int verticalAlignment = EN_BASELINE; - /** * Create a Text layout manager. * @@ -147,8 +146,10 @@ public class TextLayoutManager extends LeafNodeLayoutManager { node.endIndex - node.startIndex); vecAreaInfo = new java.util.ArrayList(); - - fs = foText.getCommonFont().getFontState(foText.getFOEventHandler().getFontInfo()); + } + + public void initialize() { + fs = foText.getCommonFont().getFontState(foText.getFOEventHandler().getFontInfo(), this); // With CID fonts, space isn't neccesary currentFontState.width(32) spaceCharIPD = fs.getCharWidth(' '); diff --git a/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java index fedc04f2e..f3f37d6e3 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java @@ -1,55 +1,56 @@ -/*
- * Copyright 2005 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.inline;
-
-import org.apache.fop.area.inline.InlineArea;
-import org.apache.fop.fo.flow.Wrapper;
-import org.apache.fop.layoutmgr.LayoutContext;
-
-/**
- * This is the layout manager for the fo:wrapper formatting object.
- */
-public class WrapperLayoutManager extends LeafNodeLayoutManager {
-
- private Wrapper fobj;
-
- /**
- * Creates a new LM for fo:wrapper.
- * @param node the fo:wrapper
- */
- public WrapperLayoutManager(Wrapper node) {
- super(node);
- fobj = node;
- }
-
- /** @see org.apache.fop.layoutmgr.inline.LeafNodeLayoutManager */
- public InlineArea get(LayoutContext context) {
- //Create a zero-width, zero-height dummy area so this node can
- //participate in the ID handling. Otherwise, addId() wouldn't
- //be called.
- InlineArea area = new InlineArea();
- return area;
- }
-
- /** @see org.apache.fop.layoutmgr.inline.LeafNodeLayoutManager#addId() */
- protected void addId() {
- getPSLM().addIDToPage(fobj.getId());
- }
-
-}
+/* + * Copyright 2005 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.inline; + +import org.apache.fop.area.inline.InlineArea; +import org.apache.fop.fo.flow.Wrapper; +import org.apache.fop.layoutmgr.LayoutContext; +import org.apache.fop.layoutmgr.LayoutManager; + +/** + * This is the layout manager for the fo:wrapper formatting object. + */ +public class WrapperLayoutManager extends LeafNodeLayoutManager { + + private Wrapper fobj; + + /** + * Creates a new LM for fo:wrapper. + * @param node the fo:wrapper + */ + public WrapperLayoutManager(Wrapper node) { + super(node); + fobj = node; + } + + /** @see org.apache.fop.layoutmgr.inline.LeafNodeLayoutManager */ + public InlineArea get(LayoutContext context) { + //Create a zero-width, zero-height dummy area so this node can + //participate in the ID handling. Otherwise, addId() wouldn't + //be called. + InlineArea area = new InlineArea(); + return area; + } + + /** @see org.apache.fop.layoutmgr.inline.LeafNodeLayoutManager#addId() */ + protected void addId() { + getPSLM().addIDToPage(fobj.getId()); + } + +} diff --git a/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java index 4c1048241..f21275acf 100644 --- a/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java @@ -42,6 +42,7 @@ import java.util.List; * the list block area.. */ public class ListBlockLayoutManager extends BlockStackingLayoutManager { + private Block curBlockArea; //TODO space-before|after: handle space-resolution rules @@ -72,10 +73,10 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager { /** * Create a new list block layout manager. * @param node list-block to create the layout manager for + * @param parent the parent layout manager */ public ListBlockLayoutManager(ListBlock node) { super(node); - initialize(); } /** @@ -86,15 +87,15 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager { return (ListBlock)fobj; } - private void initialize() { - foSpaceBefore = new SpaceVal(getListBlockFO().getCommonMarginBlock().spaceBefore).getSpace(); - foSpaceAfter = new SpaceVal(getListBlockFO().getCommonMarginBlock().spaceAfter).getSpace(); + public void initialize() { + foSpaceBefore = new SpaceVal(getListBlockFO().getCommonMarginBlock().spaceBefore, this).getSpace(); + foSpaceAfter = new SpaceVal(getListBlockFO().getCommonMarginBlock().spaceAfter, this).getSpace(); } private int getIPIndents() { int iIndents = 0; - iIndents += getListBlockFO().getCommonMarginBlock().startIndent.getValue(); - iIndents += getListBlockFO().getCommonMarginBlock().endIndent.getValue(); + iIndents += getListBlockFO().getCommonMarginBlock().startIndent.getValue(this); + iIndents += getListBlockFO().getCommonMarginBlock().endIndent.getValue(this); return iIndents; } @@ -180,6 +181,11 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager { getCurrentPV().addMarkers(markers, false, isFirst(firstPos), isLast(lastPos)); } + // We are done with this area add the background + TraitSetter.addBackground(curBlockArea, + getListBlockFO().getCommonBorderPaddingBackground(), + this); + flush(); // if adjusted space after @@ -212,18 +218,17 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager { // set traits TraitSetter.setProducerID(curBlockArea, getListBlockFO().getId()); TraitSetter.addBorders(curBlockArea, - getListBlockFO().getCommonBorderPaddingBackground()); + getListBlockFO().getCommonBorderPaddingBackground(), this); TraitSetter.addMargins(curBlockArea, getListBlockFO().getCommonBorderPaddingBackground(), - getListBlockFO().getCommonMarginBlock()); + getListBlockFO().getCommonMarginBlock(), + this); TraitSetter.addBreaks(curBlockArea, getListBlockFO().getBreakBefore(), getListBlockFO().getBreakAfter()); int contentIPD = referenceIPD - getIPIndents(); curBlockArea.setIPD(contentIPD); - TraitSetter.addBackground(curBlockArea, - getListBlockFO().getCommonBorderPaddingBackground()); setCurrentArea(curBlockArea); } diff --git a/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java index e0ea656dd..f8408807a 100644 --- a/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java @@ -57,7 +57,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager { private LinkedList bodyList = null; private int listItemHeight; - + //TODO space-before|after: handle space-resolution rules private boolean keepWithNextPendingOnLabel; @@ -122,7 +122,6 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager { super(node); setLabel(node.getLabel()); setBody(node.getBody()); - initialize(); } /** @@ -151,15 +150,15 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager { body.setParent(this); } - private void initialize() { - foSpaceBefore = new SpaceVal(getListItemFO().getCommonMarginBlock().spaceBefore).getSpace(); - foSpaceAfter = new SpaceVal(getListItemFO().getCommonMarginBlock().spaceAfter).getSpace(); + public void initialize() { + foSpaceBefore = new SpaceVal(getListItemFO().getCommonMarginBlock().spaceBefore, this).getSpace(); + foSpaceAfter = new SpaceVal(getListItemFO().getCommonMarginBlock().spaceAfter, this).getSpace(); } private int getIPIndents() { int iIndents = 0; - iIndents += getListItemFO().getCommonMarginBlock().startIndent.getValue(); - iIndents += getListItemFO().getCommonMarginBlock().endIndent.getValue(); + iIndents += getListItemFO().getCommonMarginBlock().startIndent.getValue(this); + iIndents += getListItemFO().getCommonMarginBlock().endIndent.getValue(this); return iIndents; } @@ -178,6 +177,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager { // label childLC = new LayoutContext(0); childLC.setRefIPD(context.getRefIPD()); + label.initialize(); labelList = label.getNextKnuthElements(childLC, alignment); if (childLC.isKeepWithPreviousPending()) { context.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING); @@ -187,6 +187,7 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager { // body childLC = new LayoutContext(0); childLC.setRefIPD(context.getRefIPD()); + body.initialize(); bodyList = body.getNextKnuthElements(childLC, alignment); if (childLC.isKeepWithPreviousPending()) { context.setFlags(LayoutContext.KEEP_WITH_PREVIOUS_PENDING); @@ -504,6 +505,11 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager { getCurrentPV().addMarkers(markers, false, isFirst(firstPos), isLast(lastPos)); } + // We are done with this area add the background + TraitSetter.addBackground(curBlockArea, + getListItemFO().getCommonBorderPaddingBackground(), + this); + flush(); // if adjusted space after @@ -545,12 +551,10 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager { // set traits TraitSetter.setProducerID(curBlockArea, getListItemFO().getId()); TraitSetter.addBorders(curBlockArea, - getListItemFO().getCommonBorderPaddingBackground()); - TraitSetter.addBackground(curBlockArea, - getListItemFO().getCommonBorderPaddingBackground()); + getListItemFO().getCommonBorderPaddingBackground(), this); TraitSetter.addMargins(curBlockArea, getListItemFO().getCommonBorderPaddingBackground(), - getListItemFO().getCommonMarginBlock()); + getListItemFO().getCommonMarginBlock(), this); TraitSetter.addBreaks(curBlockArea, getListItemFO().getBreakBefore(), getListItemFO().getBreakAfter()); diff --git a/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java b/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java index c732763e7..188b9f6ab 100644 --- a/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java +++ b/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java @@ -24,6 +24,7 @@ import java.util.ListIterator; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.fop.datatypes.PercentBaseContext; import org.apache.fop.fo.flow.Table; import org.apache.fop.fo.flow.TableColumn; @@ -127,12 +128,13 @@ public class ColumnSetup { /** * @param col column index (1 is first column) + * @param context the context for percentage based calculations * @return the X offset of the requested column */ - public int getXOffset(int col) { + public int getXOffset(int col, PercentBaseContext context) { int xoffset = 0; for (int i = 1; i < col; i++) { - xoffset += getColumn(i).getColumnWidth().getValue(); + xoffset += getColumn(i).getColumnWidth().getValue(context); } return xoffset; } diff --git a/src/java/org/apache/fop/layoutmgr/table/GridUnit.java b/src/java/org/apache/fop/layoutmgr/table/GridUnit.java index db381bf87..48aeeae17 100644 --- a/src/java/org/apache/fop/layoutmgr/table/GridUnit.java +++ b/src/java/org/apache/fop/layoutmgr/table/GridUnit.java @@ -245,6 +245,9 @@ public class GridUnit { this.effBorders.setBorderInfo( borderModel.determineWinner(this, other, side, resFlags), side); + if (cell != null) { + this.effBorders.setPadding(this.cell.getCommonBorderPaddingBackground()); + } } /** diff --git a/src/java/org/apache/fop/layoutmgr/table/PrimaryGridUnit.java b/src/java/org/apache/fop/layoutmgr/table/PrimaryGridUnit.java index 21d042b8e..9caba174d 100644 --- a/src/java/org/apache/fop/layoutmgr/table/PrimaryGridUnit.java +++ b/src/java/org/apache/fop/layoutmgr/table/PrimaryGridUnit.java @@ -23,6 +23,7 @@ import java.util.List; import org.apache.fop.fo.flow.TableCell; import org.apache.fop.fo.flow.TableColumn; +import org.apache.fop.layoutmgr.LayoutManager; /** * This class represents a primary grid unit of a spanned cell. @@ -131,11 +132,11 @@ public class PrimaryGridUnit extends GridUnit { /** @return true if cell/row has an explicit BPD/height */ public boolean hasBPD() { - if (!getCell().getBlockProgressionDimension().getOptimum().isAuto()) { + if (!getCell().getBlockProgressionDimension().getOptimum(null).isAuto()) { return true; } if (getRow() != null - && !getRow().getBlockProgressionDimension().getOptimum().isAuto()) { + && !getRow().getBlockProgressionDimension().getOptimum(null).isAuto()) { return true; } return false; diff --git a/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java index a304a0dd4..4fda7ab98 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java @@ -37,6 +37,7 @@ import org.apache.fop.layoutmgr.TraitSetter; import org.apache.fop.area.Area; import org.apache.fop.area.Block; import org.apache.fop.area.Trait; +import org.apache.fop.layoutmgr.LayoutManager; import org.apache.fop.traits.MinOptMax; /** @@ -71,11 +72,10 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager implement super(node); fobj = node; this.gridUnit = pgu; - initialize(); } /** @return the table-cell FO */ - public TableCell getFObj() { + public TableCell getTableCell() { return this.fobj; } @@ -83,15 +83,15 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager implement return fobj.isSeparateBorderModel(); } - private void initialize() { + public void initialize() { borderAndPaddingBPD = 0; borderAndPaddingBPD += fobj.getCommonBorderPaddingBackground().getBorderBeforeWidth(false); borderAndPaddingBPD += fobj.getCommonBorderPaddingBackground().getBorderAfterWidth(false); if (!isSeparateBorderModel()) { borderAndPaddingBPD /= 2; } - borderAndPaddingBPD += fobj.getCommonBorderPaddingBackground().getPaddingBefore(false); - borderAndPaddingBPD += fobj.getCommonBorderPaddingBackground().getPaddingAfter(false); + borderAndPaddingBPD += fobj.getCommonBorderPaddingBackground().getPaddingBefore(false, this); + borderAndPaddingBPD += fobj.getCommonBorderPaddingBackground().getPaddingAfter(false, this); } /** @@ -116,8 +116,8 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager implement if (!isSeparateBorderModel()) { iIndents /= 2; } - iIndents += fobj.getCommonBorderPaddingBackground().getPaddingStart(false); - iIndents += fobj.getCommonBorderPaddingBackground().getPaddingEnd(false); + iIndents += fobj.getCommonBorderPaddingBackground().getPaddingStart(false, this); + iIndents += fobj.getCommonBorderPaddingBackground().getPaddingEnd(false, this); return iIndents; } @@ -132,7 +132,7 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager implement cellIPD -= getIPIndents(); if (isSeparateBorderModel()) { int borderSep = fobj.getBorderSeparation().getLengthPair() - .getIPD().getLength().getValue(); + .getIPD().getLength().getValue(this); cellIPD -= borderSep; } @@ -298,8 +298,8 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager implement } CommonBorderPaddingBackground cbpb = gu.getCell().getCommonBorderPaddingBackground(); - bpd -= cbpb.getPaddingBefore(false); - bpd -= cbpb.getPaddingAfter(false); + bpd -= cbpb.getPaddingBefore(false, this); + bpd -= cbpb.getPaddingAfter(false, this); return bpd; } @@ -317,7 +317,11 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager implement getPSLM().addIDToPage(fobj.getId()); - if (!isSeparateBorderModel()) { + if (isSeparateBorderModel()) { + if (!emptyCell || fobj.showEmptyCells()) { + TraitSetter.addBorders(curBlockArea, fobj.getCommonBorderPaddingBackground(), this); + } + } else { boolean[] outer = new boolean[] { gridUnit.getFlag(GridUnit.FIRST_IN_TABLE), gridUnit.getFlag(GridUnit.LAST_IN_TABLE), @@ -326,7 +330,7 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager implement if (!gridUnit.hasSpanning()) { //Can set the borders directly if there's no span TraitSetter.addCollapsingBorders(curBlockArea, - gridUnit.getBorders(), outer); + gridUnit.getBorders(), outer, this); } else { int dy = yoffset; for (int y = 0; y < gridUnit.getRows().size(); y++) { @@ -356,7 +360,7 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager implement } block.setBPD(bpd); lastRowHeight = rowHeight; - int ipd = gu.getColumn().getColumnWidth().getValue(); + int ipd = gu.getColumn().getColumnWidth().getValue(this); int borderStartWidth = gu.getBorders().getBorderStartWidth(false) / 2; ipd -= borderStartWidth; ipd -= gu.getBorders().getBorderEndWidth(false) / 2; @@ -368,9 +372,9 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager implement += gu.getBorders().getBorderBeforeWidth(false) / 2; } block.setYOffset(dy - halfCollapsingBorderHeight); - TraitSetter.addCollapsingBorders(block, gu.getBorders(), outer); + TraitSetter.addCollapsingBorders(block, gu.getBorders(), outer, this); parentLM.addChildArea(block); - dx += gu.getColumn().getColumnWidth().getValue(); + dx += gu.getColumn().getColumnWidth().getValue(this); } dy += lastRowHeight; } @@ -396,13 +400,17 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager implement curBlockArea.setBPD(contentBPD); + // Add background after we know the BPD if (isSeparateBorderModel()) { if (!emptyCell || fobj.showEmptyCells()) { - TraitSetter.addBorders(curBlockArea, fobj.getCommonBorderPaddingBackground()); - TraitSetter.addBackground(curBlockArea, fobj.getCommonBorderPaddingBackground()); + TraitSetter.addBackground(curBlockArea, + fobj.getCommonBorderPaddingBackground(), + this); } } else { - TraitSetter.addBackground(curBlockArea, fobj.getCommonBorderPaddingBackground()); + TraitSetter.addBackground(curBlockArea, + fobj.getCommonBorderPaddingBackground(), + this); } flush(); @@ -434,12 +442,12 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager implement if (!isSeparateBorderModel()) { indent /= 2; } - indent += fobj.getCommonBorderPaddingBackground().getPaddingStart(false); + indent += fobj.getCommonBorderPaddingBackground().getPaddingStart(false, this); // set position int halfBorderSep = 0; if (isSeparateBorderModel()) { halfBorderSep = fobj.getBorderSeparation().getLengthPair() - .getIPD().getLength().getValue() / 2; + .getIPD().getLength().getValue(this) / 2; } int borderAdjust = 0; if (!isSeparateBorderModel()) { @@ -534,6 +542,43 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager implement || !fobj.getKeepWithNext().getWithinColumn().isAuto(); */ } + + // --------- Property Resolution related functions --------- // + + /** + * Returns the IPD of the content area + * @return the IPD of the content area + */ + public int getContentAreaIPD() { + return cellIPD; + } + + /** + * Returns the BPD of the content area + * @return the BPD of the content area + */ + public int getContentAreaBPD() { + if (curBlockArea != null) { + return curBlockArea.getBPD(); + } else { + log.error("getContentAreaBPD called on unknown BPD"); + return -1; + } + } + + /** + * @see org.apache.fop.layoutmgr.LayoutManager#getGeneratesReferenceArea + */ + public boolean getGeneratesReferenceArea() { + return true; + } + + /** + * @see org.apache.fop.layoutmgr.LayoutManager#getGeneratesBlockArea + */ + public boolean getGeneratesBlockArea() { + return true; + } } diff --git a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java index df32b143b..529ec8e41 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java @@ -28,7 +28,9 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.apache.fop.area.Block; import org.apache.fop.area.Trait; +import org.apache.fop.datatypes.PercentBaseContext; import org.apache.fop.fo.Constants; +import org.apache.fop.fo.FObj; import org.apache.fop.fo.flow.Table; import org.apache.fop.fo.flow.TableBody; import org.apache.fop.fo.flow.TableRow; @@ -51,7 +53,7 @@ import org.apache.fop.traits.MinOptMax; /** * Layout manager for table contents, particularly managing the creation of combined element lists. */ -public class TableContentLayoutManager { +public class TableContentLayoutManager implements PercentBaseContext { /** Logger **/ private static Log log = LogFactory.getLog(TableContentLayoutManager.class); @@ -415,7 +417,7 @@ public class TableContentLayoutManager { PrimaryGridUnit primary = gu.getPrimary(); if (gu.isPrimary()) { - primary.getCellLM().setParent(tableLM); + primary.getCellLM().setParent(getTableLM()); //Determine the table-row if any if (tableRow == null && primary.getRow() != null) { @@ -423,11 +425,11 @@ public class TableContentLayoutManager { //Check for bpd on row, see CSS21, 17.5.3 Table height algorithms LengthRangeProperty bpd = tableRow.getBlockProgressionDimension(); - if (!bpd.getMinimum().isAuto()) { + if (!bpd.getMinimum(getTableLM()).isAuto()) { minContentHeight = Math.max(minContentHeight, - bpd.getMinimum().getLength().getValue()); + bpd.getMinimum(getTableLM()).getLength().getValue(getTableLM())); } - MinOptMaxUtil.restrict(explicitRowHeights[rgi], bpd); + MinOptMaxUtil.restrict(explicitRowHeights[rgi], bpd, getTableLM()); } @@ -438,7 +440,7 @@ public class TableContentLayoutManager { + primary.getCell().getNumberColumnsSpanned(); i++) { spanWidth += getTableLM().getColumns().getColumn(i + 1) - .getColumnWidth().getValue(); + .getColumnWidth().getValue(getTableLM()); } LayoutContext childLC = new LayoutContext(0); childLC.setStackLimit(context.getStackLimit()); //necessary? @@ -487,17 +489,17 @@ public class TableContentLayoutManager { if (gu.isLastGridUnitRowSpan()) { int effCellContentHeight = minContentHeight; LengthRangeProperty bpd = primary.getCell().getBlockProgressionDimension(); - if (!bpd.getMinimum().isAuto()) { + if (!bpd.getMinimum(getTableLM()).isAuto()) { effCellContentHeight = Math.max(effCellContentHeight, - bpd.getMinimum().getLength().getValue()); + bpd.getMinimum(getTableLM()).getLength().getValue(getTableLM())); } - if (!bpd.getOptimum().isAuto()) { + if (!bpd.getOptimum(getTableLM()).isAuto()) { effCellContentHeight = Math.max(effCellContentHeight, - bpd.getOptimum().getLength().getValue()); + bpd.getOptimum(getTableLM()).getLength().getValue(getTableLM())); } if (gu.getRowSpanIndex() == 0) { //TODO ATM only non-row-spanned cells are taken for this - MinOptMaxUtil.restrict(explicitRowHeights[rgi], bpd); + MinOptMaxUtil.restrict(explicitRowHeights[rgi], bpd, tableLM); } effCellContentHeight = Math.max(effCellContentHeight, primary.getContentLength()); @@ -514,8 +516,8 @@ public class TableContentLayoutManager { effCellContentHeight); CommonBorderPaddingBackground cbpb = primary.getCell().getCommonBorderPaddingBackground(); - padding += cbpb.getPaddingBefore(false); - padding += cbpb.getPaddingAfter(false); + padding += cbpb.getPaddingBefore(false, primary.getCellLM()); + padding += cbpb.getPaddingAfter(false, primary.getCellLM()); int effRowHeight = effCellContentHeight + padding + borderWidths; for (int previous = 0; previous < gu.getRowSpanIndex(); previous++) { effRowHeight -= rowHeights[rgi - previous - 1].opt; @@ -566,7 +568,7 @@ public class TableContentLayoutManager { */ protected int getXOffsetOfGridUnit(GridUnit gu) { int col = gu.getStartCol(); - return startXOffset + getTableLM().getColumns().getXOffset(col + 1); + return startXOffset + getTableLM().getColumns().getXOffset(col + 1, getTableLM()); } /** @@ -792,36 +794,41 @@ public class TableContentLayoutManager { gridUnits[i].getElements(), start[i], end[i]); partLength[i] = len; log.debug("len of part: " + len); + if (start[i] == 0) { LengthRangeProperty bpd = gridUnits[i].getCell() .getBlockProgressionDimension(); - if (!bpd.getMinimum().isAuto()) { - if (bpd.getMinimum().getLength().getValue() > 0) { - len = Math.max(len, bpd.getMinimum().getLength().getValue()); + if (!bpd.getMinimum(getTableLM()).isAuto()) { + if (bpd.getMinimum(getTableLM()).getLength().getValue(getTableLM()) > 0) { + len = Math.max(len, bpd.getMinimum(getTableLM()).getLength().getValue(getTableLM())); } } - if (!bpd.getOptimum().isAuto()) { - if (bpd.getOptimum().getLength().getValue() > 0) { - len = Math.max(len, bpd.getOptimum().getLength().getValue()); + if (!bpd.getOptimum(getTableLM()).isAuto()) { + if (bpd.getOptimum(getTableLM()).getLength().getValue(getTableLM()) > 0) { + len = Math.max(len, bpd.getOptimum(getTableLM()).getLength().getValue(getTableLM())); } } if (gridUnits[i].getRow() != null) { bpd = gridUnits[i].getRow().getBlockProgressionDimension(); - if (!bpd.getMinimum().isAuto()) { - if (bpd.getMinimum().getLength().getValue() > 0) { - len = Math.max(len, bpd.getMinimum().getLength().getValue()); + if (!bpd.getMinimum(getTableLM()).isAuto()) { + if (bpd.getMinimum(getTableLM()).getLength().getValue(getTableLM()) > 0) { + len = Math.max(len, bpd.getMinimum(getTableLM()).getLength().getValue(getTableLM())); } } } } + // Add the padding if any + len += gridUnits[i].getBorders() + .getPaddingBefore(false, gridUnits[i].getCellLM()); + len += gridUnits[i].getBorders() + .getPaddingAfter(false, gridUnits[i].getCellLM()); + //Now add the borders to the contentLength if (isSeparateBorderModel()) { len += gridUnits[i].getBorders().getBorderBeforeWidth(false); len += gridUnits[i].getBorders().getBorderAfterWidth(false); } - len += gridUnits[i].getBorders().getPaddingBefore(false); - len += gridUnits[i].getBorders().getPaddingAfter(false); int startRow = Math.max(gridUnits[i].getStartRow(), firstRow[bt]); Integer storedOffset = (Integer)rowOffsets[bt].get(new Integer(startRow)); int effYOffset; @@ -906,7 +913,6 @@ public class TableContentLayoutManager { Block block = new Block(); block.addTrait(Trait.IS_REFERENCE_AREA, Boolean.TRUE); block.setPositioning(Block.ABSOLUTE); - TraitSetter.addBackground(block, row.getCommonBorderPaddingBackground()); return block; } } @@ -927,6 +933,7 @@ public class TableContentLayoutManager { rowBackground.setXOffset(this.startXOffset); rowBackground.setYOffset(yoffset); getTableLM().addChildArea(rowBackground); + TraitSetter.addBackground(rowBackground, row.getCommonBorderPaddingBackground(), getTableLM()); } } @@ -1125,4 +1132,13 @@ public class TableContentLayoutManager { } } + // --------- Property Resolution related functions --------- // + + /** + * @see org.apache.fop.datatypes.PercentBaseContext#getBaseLength(int, fobj) + */ + public int getBaseLength(int lengthBase, FObj fobj) { + return tableLM.getBaseLength(lengthBase, fobj); + } + } diff --git a/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java index ee3a5bdba..713d0179a 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java @@ -39,6 +39,8 @@ import org.apache.fop.traits.SpaceVal; import java.util.Iterator; import java.util.LinkedList; +import org.apache.fop.datatypes.LengthBase; +import org.apache.fop.fo.FObj; /** * LayoutManager for a table FO. @@ -58,13 +60,13 @@ public class TableLayoutManager extends BlockStackingLayoutManager private Block curBlockArea; private int referenceIPD; + private int referenceBPD; private boolean autoLayout = true; //TODO space-before|after: handle space-resolution rules private MinOptMax spaceBefore; private MinOptMax spaceAfter; - /** * Create a new table layout manager. * @param node the table FO @@ -73,7 +75,6 @@ public class TableLayoutManager extends BlockStackingLayoutManager super(node); fobj = node; this.columns = new ColumnSetup(node); - initialize(); } /** @return the table FO */ @@ -88,20 +89,20 @@ public class TableLayoutManager extends BlockStackingLayoutManager return this.columns; } - private void initialize() { - spaceBefore = new SpaceVal(fobj.getCommonMarginBlock().spaceBefore).getSpace(); - spaceAfter = new SpaceVal(fobj.getCommonMarginBlock().spaceAfter).getSpace(); + public void initialize() { + spaceBefore = new SpaceVal(fobj.getCommonMarginBlock().spaceBefore, this).getSpace(); + spaceAfter = new SpaceVal(fobj.getCommonMarginBlock().spaceAfter, this).getSpace(); if (!fobj.isAutoLayout() - && fobj.getInlineProgressionDimension().getOptimum().getEnum() != EN_AUTO) { + && fobj.getInlineProgressionDimension().getOptimum(this).getEnum() != EN_AUTO) { autoLayout = false; } } private int getIPIndents() { int iIndents = 0; - iIndents += fobj.getCommonMarginBlock().startIndent.getValue(); - iIndents += fobj.getCommonMarginBlock().endIndent.getValue(); + iIndents += fobj.getCommonMarginBlock().startIndent.getValue(this); + iIndents += fobj.getCommonMarginBlock().endIndent.getValue(this); return iIndents; } @@ -120,9 +121,11 @@ public class TableLayoutManager extends BlockStackingLayoutManager } } + referenceBPD = context.getStackLimit().opt; referenceIPD = context.getRefIPD(); - if (fobj.getInlineProgressionDimension().getOptimum().getEnum() != EN_AUTO) { - referenceIPD = fobj.getInlineProgressionDimension().getOptimum().getLength().getValue(); + + if (fobj.getInlineProgressionDimension().getOptimum(this).getEnum() != EN_AUTO) { + referenceIPD = fobj.getInlineProgressionDimension().getOptimum(this).getLength().getValue(this); } else if( !fobj.isAutoLayout() ) { log.info("table-layout=\"fixed\" and width=\"auto\", but auto-layout not supported " + "=> assuming width=\"100%\""); @@ -141,11 +144,6 @@ public class TableLayoutManager extends BlockStackingLayoutManager stackSize.add(spaceBefore); } - fobj.setLayoutDimension(PercentBase.BLOCK_IPD, referenceIPD); - fobj.setLayoutDimension(PercentBase.BLOCK_BPD, context.getStackLimit().opt); - fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_IPD, referenceIPD); - fobj.setLayoutDimension(PercentBase.REFERENCE_AREA_BPD, context.getStackLimit().opt); - // either works out table of column widths or if proportional-column-width function // is used works out total factor, so that value of single unit can be computed. int sumCols = 0; @@ -153,7 +151,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager for (Iterator i = columns.iterator(); i.hasNext(); ) { TableColumn column = (TableColumn) i.next(); Length width = column.getColumnWidth(); - sumCols += width.getValue(); + sumCols += width.getValue(this); if (width instanceof TableColLength) { factors += ((TableColLength) width).getTableUnits(); } @@ -284,7 +282,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager addBlockSpacing(adjust, spaceBefore); spaceBefore = null; - int startXOffset = fobj.getCommonMarginBlock().startIndent.getValue(); + int startXOffset = fobj.getCommonMarginBlock().startIndent.getValue(this); // add column, body then row areas @@ -301,12 +299,15 @@ public class TableLayoutManager extends BlockStackingLayoutManager curBlockArea.setBPD(tableHeight); if (fobj.isSeparateBorderModel()) { - TraitSetter.addBorders(curBlockArea, fobj.getCommonBorderPaddingBackground()); + TraitSetter.addBorders(curBlockArea, fobj.getCommonBorderPaddingBackground(), this); } - TraitSetter.addBackground(curBlockArea, fobj.getCommonBorderPaddingBackground()); + TraitSetter.addBackground(curBlockArea, + fobj.getCommonBorderPaddingBackground(), + this); TraitSetter.addMargins(curBlockArea, fobj.getCommonBorderPaddingBackground(), - fobj.getCommonMarginBlock()); + fobj.getCommonMarginBlock(), + this); TraitSetter.addBreaks(curBlockArea, fobj.getBreakBefore(), fobj.getBreakAfter()); @@ -413,5 +414,41 @@ public class TableLayoutManager extends BlockStackingLayoutManager || !fobj.getKeepWithNext().getWithinColumn().isAuto(); } + // --------- Property Resolution related functions --------- // + + /** + * @see org.apache.fop.datatypes.PercentBaseContext#getBaseLength(int, FObj) + */ + public int getBaseLength(int lengthBase, FObj fobj) { + // Special handler for TableColumn width specifications + if (fobj instanceof TableColumn && fobj.getParent() == getFObj()) { + switch (lengthBase) { + case LengthBase.CONTAINING_BLOCK_WIDTH: + return getContentAreaIPD(); + default: + log.error("Unknown base type for LengthBase."); + return 0; + } + } else { + return super.getBaseLength(lengthBase, fobj); + } + } + + /** + * Returns the IPD of the content area + * @return the IPD of the content area + */ + public int getContentAreaIPD() { + return referenceIPD; + } + + /** + * Returns the BPD of the content area + * @return the BPD of the content area + */ + public int getContentAreaBPD() { + return referenceBPD; + } + } diff --git a/src/java/org/apache/fop/layoutmgr/table/TableStepper.java b/src/java/org/apache/fop/layoutmgr/table/TableStepper.java index 272afdf18..f7a381a3e 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableStepper.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableStepper.java @@ -202,8 +202,8 @@ public class TableStepper { } else { borderBefore[column] = pgu.getBorders().getBorderBeforeWidth(false) / 2; } - paddingBefore[column] = pgu.getBorders().getPaddingBefore(false); - paddingAfter[column] = pgu.getBorders().getPaddingAfter(false); + paddingBefore[column] = pgu.getBorders().getPaddingBefore(false, pgu.getCellLM()); + paddingAfter[column] = pgu.getBorders().getPaddingAfter(false, pgu.getCellLM()); start[column] = 0; end[column] = -1; widths[column] = 0; @@ -301,8 +301,8 @@ public class TableStepper { = getTableLM().getTable().getCommonBorderPaddingBackground(); effPenaltyLen += borders.getBorderBeforeWidth(false); effPenaltyLen += borders.getBorderAfterWidth(false); - effPenaltyLen += borders.getPaddingBefore(false); - effPenaltyLen += borders.getPaddingAfter(false); + effPenaltyLen += borders.getPaddingBefore(false, getTableLM()); + effPenaltyLen += borders.getPaddingAfter(false, getTableLM()); } TableContentPosition tcpos = new TableContentPosition(getTableLM(), gridUnitParts, getActiveRow()); diff --git a/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java b/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java index 0f1a92a17..68d1a6871 100644 --- a/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java +++ b/src/java/org/apache/fop/render/rtf/TableAttributesConverter.java @@ -142,34 +142,34 @@ public class TableAttributesConverter { //TODO Make this configurable if (reproduceMSWordBug) { //MS Word has a bug where padding left and top are exchanged - padding = border.getPaddingStart(false); + padding = border.getPaddingStart(false, null); // TODO do we need a real context here? if (padding != 0) { attrib.setTwips(ITableAttributes.ATTR_CELL_PADDING_TOP, padding); attrib.set(ITableAttributes.ATTR_CELL_U_PADDING_TOP, 3 /*=twips*/); } - padding = border.getPaddingBefore(false); + padding = border.getPaddingBefore(false, null); // TODO do we need a real context here? if (padding != 0) { attrib.setTwips(ITableAttributes.ATTR_CELL_PADDING_LEFT, padding); attrib.set(ITableAttributes.ATTR_CELL_U_PADDING_LEFT, 3 /*=twips*/); } } else { - padding = border.getPaddingStart(false); + padding = border.getPaddingStart(false, null); // TODO do we need a real context here? if (padding != 0) { attrib.setTwips(ITableAttributes.ATTR_CELL_PADDING_LEFT, padding); attrib.set(ITableAttributes.ATTR_CELL_U_PADDING_LEFT, 3 /*=twips*/); } - padding = border.getPaddingBefore(false); + padding = border.getPaddingBefore(false, null); // TODO do we need a real context here? if (padding != 0) { attrib.setTwips(ITableAttributes.ATTR_CELL_PADDING_TOP, padding); attrib.set(ITableAttributes.ATTR_CELL_U_PADDING_TOP, 3 /*=twips*/); } } - padding = border.getPaddingEnd(false); + padding = border.getPaddingEnd(false, null); // TODO do we need a real context here? if (padding != 0) { attrib.setTwips(ITableAttributes.ATTR_CELL_PADDING_RIGHT, padding); attrib.set(ITableAttributes.ATTR_CELL_U_PADDING_RIGHT, 3 /*=twips*/); } - padding = border.getPaddingAfter(false); + padding = border.getPaddingAfter(false, null); // TODO do we need a real context here? if (padding != 0) { attrib.setTwips(ITableAttributes.ATTR_CELL_PADDING_BOTTOM, padding); attrib.set(ITableAttributes.ATTR_CELL_U_PADDING_BOTTOM, 3 /*=twips*/); diff --git a/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java b/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java index 7de406c15..39a91ef91 100644 --- a/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java +++ b/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java @@ -186,9 +186,9 @@ class TextAttributesConverter { private static void attrBlockMargin(CommonMarginBlock cmb, FOPRtfAttributes rtfAttr) { rtfAttr.setTwips(RtfText.SPACE_BEFORE, - cmb.spaceBefore.getOptimum().getLength()); + cmb.spaceBefore.getOptimum(null).getLength()); rtfAttr.setTwips(RtfText.SPACE_AFTER, - cmb.spaceAfter.getOptimum().getLength()); + cmb.spaceAfter.getOptimum(null).getLength()); rtfAttr.setTwips(RtfText.LEFT_INDENT_BODY, cmb.marginLeft); rtfAttr.setTwips(RtfText.RIGHT_INDENT_BODY, cmb.marginRight); } diff --git a/src/java/org/apache/fop/traits/SpaceVal.java b/src/java/org/apache/fop/traits/SpaceVal.java index 5dfbab90f..4c9cdf5bc 100644 --- a/src/java/org/apache/fop/traits/SpaceVal.java +++ b/src/java/org/apache/fop/traits/SpaceVal.java @@ -1,5 +1,5 @@ /* - * Copyright 1999-2004 The Apache Software Foundation. + * Copyright 1999-2005 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. @@ -18,6 +18,7 @@ package org.apache.fop.traits; +import org.apache.fop.datatypes.PercentBaseContext; import org.apache.fop.fo.Constants; import org.apache.fop.fo.properties.Property; import org.apache.fop.fo.properties.SpaceProperty; @@ -37,11 +38,12 @@ public class SpaceVal { /** * Constructor for SpaceVal objects based on Space objects. * @param spaceprop Space object to use + * @param context Percentage evaluation context */ - public SpaceVal(SpaceProperty spaceprop) { - space = new MinOptMax(spaceprop.getMinimum().getLength().getValue(), - spaceprop.getOptimum().getLength().getValue(), - spaceprop.getMaximum().getLength().getValue()); + public SpaceVal(SpaceProperty spaceprop, PercentBaseContext context) { + space = new MinOptMax(spaceprop.getMinimum(context).getLength().getValue(context), + spaceprop.getOptimum(context).getLength().getValue(context), + spaceprop.getMaximum(context).getLength().getValue(context)); bConditional = (spaceprop.getConditionality().getEnum() == Constants.EN_DISCARD); Property precProp = spaceprop.getPrecedence(); @@ -69,7 +71,9 @@ public class SpaceVal { this.iPrecedence = iPrecedence; } - static public SpaceVal makeWordSpacing(Property wordSpacing, SpaceVal letterSpacing, Font fs) { + static public SpaceVal makeWordSpacing(Property wordSpacing, + SpaceVal letterSpacing, + Font fs) { if (wordSpacing.getEnum() == Constants.EN_NORMAL) { // give word spaces the possibility to shrink by a third, // and stretch by a half; @@ -80,7 +84,7 @@ public class SpaceVal { (space, MinOptMax.multiply(letterSpacing.getSpace(), 2)), true, true, 0); } else { - return new SpaceVal(wordSpacing.getSpace()); + return new SpaceVal(wordSpacing.getSpace(), null); } } @@ -89,7 +93,7 @@ public class SpaceVal { // letter spaces are set to zero (or use different values?) return new SpaceVal(new MinOptMax(0), true, true, 0); } else { - return new SpaceVal(letterSpacing.getSpace()); + return new SpaceVal(letterSpacing.getSpace(), null); } } |