diff options
author | Jeremias Maerki <jeremias@apache.org> | 2005-12-02 09:52:38 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2005-12-02 09:52:38 +0000 |
commit | 56cfb0b22dac19a9112c74c6c9a31d5b3ca44437 (patch) | |
tree | 19bca7a2c5343c0976d5a828ace7767009032b21 /src/java/org/apache | |
parent | 704df31665917b2518434171c76eaab86d571145 (diff) | |
download | xmlgraphics-fop-56cfb0b22dac19a9112c74c6c9a31d5b3ca44437.tar.gz xmlgraphics-fop-56cfb0b22dac19a9112c74c6c9a31d5b3ca44437.zip |
Implemented 5.3.4 overconstrained geometry without handling the case when the content IPD is zero.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@351655 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache')
8 files changed, 102 insertions, 95 deletions
diff --git a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java index 5a53c7239..721ed7c8b 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java @@ -92,6 +92,8 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager .spaceBefore, this).getSpace(); foBlockSpaceAfter = new SpaceVal(getBlockContainerFO().getCommonMarginBlock() .spaceAfter, this).getSpace(); + startIndent = getBlockContainerFO().getCommonMarginBlock().startIndent.getValue(this); + endIndent = getBlockContainerFO().getCommonMarginBlock().endIndent.getValue(this); boolean rotated = (getBlockContainerFO().getReferenceOrientation() % 180 != 0); if (rotated) { @@ -154,13 +156,6 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager return indents; } - private int getIPIndents() { - int iIndents = 0; - iIndents += getBlockContainerFO().getCommonMarginBlock().startIndent.getValue(this); - iIndents += getBlockContainerFO().getCommonMarginBlock().endIndent.getValue(this); - return iIndents; - } - private boolean isAbsoluteOrFixed() { return (abProps.absolutePosition == EN_ABSOLUTE) || (abProps.absolutePosition == EN_FIXED); @@ -188,9 +183,8 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager autoHeight = false; //boolean rotated = (getBlockContainerFO().getReferenceOrientation() % 180 != 0); - referenceIPD = context.getRefIPD(); int maxbpd = context.getStackLimit().opt; - int allocBPD, allocIPD; + int allocBPD; if (height.getEnum() == EN_AUTO || (!height.isAbsolute() && getAncestorBlockAreaBPD() <= 0)) { //auto height when height="auto" or "if that dimension is not specified explicitly @@ -201,15 +195,15 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager allocBPD = height.getValue(this); //this is the content-height allocBPD += getBPIndents(); } + vpContentBPD = allocBPD - getBPIndents(); + + referenceIPD = context.getRefIPD(); if (width.getEnum() == EN_AUTO) { - allocIPD = referenceIPD; + updateContentAreaIPDwithOverconstrainedAdjust(); } else { - allocIPD = width.getValue(this); //this is the content-width - allocIPD += getIPIndents(); + int contentWidth = width.getValue(this); + updateContentAreaIPDwithOverconstrainedAdjust(contentWidth); } - - vpContentBPD = allocBPD - getBPIndents(); - setContentAreaIPD(allocIPD - getIPIndents()); double contentRectOffsetX = 0; contentRectOffsetX += getBlockContainerFO() @@ -869,7 +863,7 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager // this); TraitSetter.addMargins(viewportBlockArea, getBlockContainerFO().getCommonBorderPaddingBackground(), - getBlockContainerFO().getCommonMarginBlock(), + startIndent, endIndent, this); viewportBlockArea.setCTM(absoluteCTM); diff --git a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java index 1a5e796f6..e495b4062 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java @@ -68,6 +68,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager } public void initialize() { + super.initialize(); Font fs = getBlockFO().getCommonFont().getFontState( getBlockFO().getFOEventHandler().getFontInfo(), this); @@ -75,6 +76,8 @@ public class BlockLayoutManager extends BlockStackingLayoutManager follow = -fs.getDescender(); middleShift = -fs.getXHeight() / 2; lineHeight = getBlockFO().getLineHeight().getOptimum(this).getLength(); + startIndent = getBlockFO().getCommonMarginBlock().startIndent.getValue(this); + endIndent = getBlockFO().getCommonMarginBlock().endIndent.getValue(this); foSpaceBefore = new SpaceVal(getBlockFO().getCommonMarginBlock().spaceBefore, this) .getSpace(); foSpaceAfter = new SpaceVal(getBlockFO().getCommonMarginBlock().spaceAfter, this) @@ -191,13 +194,6 @@ public class BlockLayoutManager extends BlockStackingLayoutManager return llm; } - private int getIPIndents() { - int iIndents = 0; - iIndents += getBlockFO().getCommonMarginBlock().startIndent.getValue(this); - iIndents += getBlockFO().getCommonMarginBlock().endIndent.getValue(this); - return iIndents; - } - /** * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#mustKeepTogether() */ @@ -413,9 +409,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager if (curBlockArea == null) { curBlockArea = new Block(); - int contentIPD = referenceIPD - getIPIndents(); - - curBlockArea.setIPD(contentIPD/*parentwidth*/); + curBlockArea.setIPD(super.getContentAreaIPD()); TraitSetter.addBreaks(curBlockArea, getBlockFO().getBreakBefore(), getBlockFO().getBreakAfter()); @@ -434,7 +428,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager discardPaddingBefore, discardPaddingAfter, false, false, this); TraitSetter.addMargins(curBlockArea, getBlockFO().getCommonBorderPaddingBackground(), - getBlockFO().getCommonMarginBlock(), + startIndent, endIndent, this); setCurrentArea(curBlockArea); // ??? for generic operations diff --git a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java index a8561b752..494d732d7 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java @@ -59,6 +59,10 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager protected boolean firstVisibleMarkServed = false; /** Reference IPD available */ protected int referenceIPD = 0; + /** the effective start-indent value */ + protected int startIndent = 0; + /** the effective end-indent value */ + protected int endIndent = 0; /** * Holds the (one-time use) fo:block space-before * and -after properties. Large fo:blocks are split @@ -175,6 +179,41 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager } /** + * Determines and sets the content area IPD based on available reference area IPD, start- and + * end-indent properties. + * end-indent is adjusted based on overconstrained geometry rules, if necessary. + * @return the resulting content area IPD + */ + protected int updateContentAreaIPDwithOverconstrainedAdjust() { + int ipd = referenceIPD - (startIndent + endIndent); + if (ipd < 0) { + //5.3.4, XSL 1.0, Overconstrained Geometry + log.debug("Adjusting end-indent based on overconstrained geometry rules for " + fobj); + endIndent += ipd; + ipd = 0; + //TODO Should we skip layout for a block that has ipd=0? + } + setContentAreaIPD(ipd); + return ipd; + } + + /** + * Sets the content area IPD by directly supplying the value. + * end-indent is adjusted based on overconstrained geometry rules, if necessary. + * @return the resulting content area IPD + */ + protected int updateContentAreaIPDwithOverconstrainedAdjust(int contentIPD) { + int ipd = referenceIPD - (contentIPD + (startIndent + endIndent)); + if (ipd < 0) { + //5.3.4, XSL 1.0, Overconstrained Geometry + log.debug("Adjusting end-indent based on overconstrained geometry rules for " + fobj); + endIndent += ipd; + } + setContentAreaIPD(contentIPD); + return contentIPD; + } + + /** * @see LayoutManager#getNextKnuthElements(LayoutContext, int) */ public LinkedList getNextKnuthElements(LayoutContext context, int alignment) { @@ -189,20 +228,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager 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(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. - setContentAreaIPD(ipd); + updateContentAreaIPDwithOverconstrainedAdjust(); LinkedList returnedList = null; LinkedList contentList = new LinkedList(); @@ -231,12 +257,9 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager childLC.copyPendingMarksFrom(context); if (curLM instanceof LineLayoutManager) { // curLM is a LineLayoutManager - // set stackLimit for lines - childLC.setStackLimit(new MinOptMax(ipd/* - * - iIndents - - * iTextIndent - */)); - childLC.setRefIPD(ipd); + // set stackLimit for lines (stack limit is now i-p-direction, not b-p-direction!) + childLC.setStackLimit(new MinOptMax(getContentAreaIPD())); + childLC.setRefIPD(getContentAreaIPD()); } else { // curLM is a ? //childLC.setStackLimit(MinOptMax.subtract(context @@ -1443,6 +1466,11 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager } } + /** @return the sum of start-indent and end-indent */ + protected int getIPIndents() { + return startIndent + endIndent; + } + /** * Returns the IPD of the content area * @return the IPD of the content area diff --git a/src/java/org/apache/fop/layoutmgr/TraitSetter.java b/src/java/org/apache/fop/layoutmgr/TraitSetter.java index 89d03fff9..e67075976 100644 --- a/src/java/org/apache/fop/layoutmgr/TraitSetter.java +++ b/src/java/org/apache/fop/layoutmgr/TraitSetter.java @@ -358,30 +358,29 @@ public class TraitSetter { * outside of the border rectangle to the area. * @param area the area to set the traits on. * @param bpProps the border, padding and background properties - * @param marginProps the margin properties. + * @param startIndent the effective start-indent value + * @param endIndent the effective end-indent value * @param context the context for evaluation of percentages */ public static void addMargins(Area area, CommonBorderPaddingBackground bpProps, - CommonMarginBlock marginProps, + int startIndent, int endIndent, PercentBaseContext context) { - int startIndent = marginProps.startIndent.getValue(context); if (startIndent != 0) { area.addTrait(Trait.START_INDENT, new Integer(startIndent)); } - int spaceStart = marginProps.startIndent.getValue(context) + int spaceStart = startIndent - bpProps.getBorderStartWidth(false) - bpProps.getPaddingStart(false, context); if (spaceStart != 0) { area.addTrait(Trait.SPACE_START, new Integer(spaceStart)); } - int endIndent = marginProps.endIndent.getValue(context); if (endIndent != 0) { area.addTrait(Trait.END_INDENT, new Integer(endIndent)); } - int spaceEnd = marginProps.endIndent.getValue(context) + int spaceEnd = endIndent - bpProps.getBorderEndWidth(false) - bpProps.getPaddingEnd(false, context); if (spaceEnd != 0) { @@ -389,6 +388,24 @@ public class TraitSetter { } } + /** + * Add space to a block area. + * Layout managers that create block areas can use this to add space + * outside of the border rectangle to the area. + * @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, + PercentBaseContext context) { + int startIndent = marginProps.startIndent.getValue(context); + int endIndent = marginProps.endIndent.getValue(context); + addMargins(area, bpProps, startIndent, endIndent, context); + } + public static int getEffectiveSpace(double adjust, MinOptMax space) { if (space == null) { return 0; diff --git a/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java index d1f88c717..dcedfdbcb 100644 --- a/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/list/ListBlockLayoutManager.java @@ -100,6 +100,8 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager getListBlockFO().getCommonMarginBlock().spaceBefore, this).getSpace(); foSpaceAfter = new SpaceVal( getListBlockFO().getCommonMarginBlock().spaceAfter, this).getSpace(); + startIndent = getListBlockFO().getCommonMarginBlock().startIndent.getValue(this); + endIndent = getListBlockFO().getCommonMarginBlock().endIndent.getValue(this); } private void resetSpaces() { @@ -111,13 +113,6 @@ public class ListBlockLayoutManager extends BlockStackingLayoutManager this.effSpaceAfter = foSpaceAfter; } - private int getIPIndents() { - int iIndents = 0; - iIndents += getListBlockFO().getCommonMarginBlock().startIndent.getValue(this); - iIndents += getListBlockFO().getCommonMarginBlock().endIndent.getValue(this); - return iIndents; - } - /** @see org.apache.fop.layoutmgr.BlockStackingLayoutManager */ public LinkedList getNextKnuthElements(LayoutContext context, int alignment) { resetSpaces(); diff --git a/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java index 0ed202c6f..2dd7020a7 100644 --- a/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java @@ -159,6 +159,8 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager getListItemFO().getCommonMarginBlock().spaceBefore, this).getSpace(); foSpaceAfter = new SpaceVal( getListItemFO().getCommonMarginBlock().spaceAfter, this).getSpace(); + startIndent = getListItemFO().getCommonMarginBlock().startIndent.getValue(this); + endIndent = getListItemFO().getCommonMarginBlock().endIndent.getValue(this); } private void resetSpaces() { @@ -170,13 +172,6 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager this.effSpaceAfter = foSpaceAfter; } - private int getIPIndents() { - int iIndents = 0; - iIndents += getListItemFO().getCommonMarginBlock().startIndent.getValue(this); - iIndents += getListItemFO().getCommonMarginBlock().endIndent.getValue(this); - return iIndents; - } - /** @see org.apache.fop.layoutmgr.LayoutManager */ public LinkedList getNextKnuthElements(LayoutContext context, int alignment) { referenceIPD = context.getRefIPD(); diff --git a/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java index 547c941bf..ce37bf06c 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableCellLayoutManager.java @@ -112,7 +112,8 @@ public class TableCellLayoutManager extends BlockStackingLayoutManager } - private int getIPIndents() { + /** @see org.apache.fop.layoutmgr.BlockStackingLayoutManager#getIPIndents() */ + protected int getIPIndents() { int iIndents = 0; int[] startEndBorderWidths = gridUnit.getStartEndBorderWidths(); startBorderWidth += startEndBorderWidths[0]; diff --git a/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java index f1e1447c0..cd5201ca3 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java @@ -59,7 +59,6 @@ public class TableLayoutManager extends BlockStackingLayoutManager private Block curBlockArea; - private int contentIPD; private int referenceBPD; private double tableUnits; private boolean autoLayout = true; @@ -101,6 +100,8 @@ public class TableLayoutManager extends BlockStackingLayoutManager getTable().getCommonMarginBlock().spaceBefore, this).getSpace(); foSpaceAfter = new SpaceVal( getTable().getCommonMarginBlock().spaceAfter, this).getSpace(); + startIndent = getTable().getCommonMarginBlock().startIndent.getValue(this); + endIndent = getTable().getCommonMarginBlock().endIndent.getValue(this); if (getTable().isSeparateBorderModel()) { this.halfBorderSeparationBPD = getTable().getBorderSeparation().getBPD().getLength() @@ -128,13 +129,6 @@ public class TableLayoutManager extends BlockStackingLayoutManager this.effSpaceAfter = foSpaceAfter; } - private int getIPIndents() { - int iIndents = 0; - iIndents += getTable().getCommonMarginBlock().startIndent.getValue(this); - iIndents += getTable().getCommonMarginBlock().endIndent.getValue(this); - return iIndents; - } - /** @return half the value of border-separation.block-progression-dimension. */ public int getHalfBorderSeparationBPD() { return halfBorderSeparationBPD; @@ -164,19 +158,16 @@ public class TableLayoutManager extends BlockStackingLayoutManager referenceIPD = context.getRefIPD(); if (getTable().getInlineProgressionDimension().getOptimum(this).getEnum() != EN_AUTO) { - referenceIPD = getTable().getInlineProgressionDimension().getOptimum(this) + int contentIPD = getTable().getInlineProgressionDimension().getOptimum(this) .getLength().getValue(this); - contentIPD = referenceIPD; + updateContentAreaIPDwithOverconstrainedAdjust(contentIPD); } else { if (!getTable().isAutoLayout()) { log.info("table-layout=\"fixed\" and width=\"auto\", " + "but auto-layout not supported " + "=> assuming width=\"100%\""); } - contentIPD = referenceIPD - getIPIndents(); - } - if (referenceIPD > context.getRefIPD()) { - log.warn("Allocated IPD exceeds available reference IPD"); + updateContentAreaIPDwithOverconstrainedAdjust(); } // either works out table of column widths or if proportional-column-width function @@ -195,9 +186,9 @@ public class TableLayoutManager extends BlockStackingLayoutManager } // sets TABLE_UNITS in case where one or more oldColumns is defined using // proportional-column-width - if (sumCols < contentIPD) { + if (sumCols < getContentAreaIPD()) { if (tableUnits == 0.0) { - this.tableUnits = (contentIPD - sumCols) / factors; + this.tableUnits = (getContentAreaIPD() - sumCols) / factors; } } @@ -337,7 +328,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager LayoutContext lc = new LayoutContext(0); - lc.setRefIPD(contentIPD); + lc.setRefIPD(getContentAreaIPD()); contentLM.setStartXOffset(startXOffset); contentLM.addAreas(parentIter, lc); tableHeight += contentLM.getUsedBPD(); @@ -357,7 +348,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager this); TraitSetter.addMargins(curBlockArea, getTable().getCommonBorderPaddingBackground(), - getTable().getCommonMarginBlock(), + startIndent, endIndent, this); TraitSetter.addBreaks(curBlockArea, getTable().getBreakBefore(), getTable().getBreakAfter()); @@ -392,7 +383,7 @@ public class TableLayoutManager extends BlockStackingLayoutManager TraitSetter.setProducerID(curBlockArea, getTable().getId()); - curBlockArea.setIPD(contentIPD); + curBlockArea.setIPD(getContentAreaIPD()); setCurrentArea(curBlockArea); } @@ -485,14 +476,6 @@ public class TableLayoutManager extends BlockStackingLayoutManager } /** - * 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 */ |