diff options
author | Manuel Mall <manuel@apache.org> | 2005-11-14 05:05:35 +0000 |
---|---|---|
committer | Manuel Mall <manuel@apache.org> | 2005-11-14 05:05:35 +0000 |
commit | 862f28b0608e4c669b19c0730b9f730cfdb69076 (patch) | |
tree | d7eaf88fce8870c085e9faab648435b138064ade /src/java | |
parent | 35f6e9d8d347d74de70a37a9ca5472275461c306 (diff) | |
download | xmlgraphics-fop-862f28b0608e4c669b19c0730b9f730cfdb69076.tar.gz xmlgraphics-fop-862f28b0608e4c669b19c0730b9f730cfdb69076.zip |
Correct a few more problems related to leaders: text-align was not handled correctly, use-content was drawing incorrect borders
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@344037 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java')
3 files changed, 83 insertions, 34 deletions
diff --git a/src/java/org/apache/fop/area/inline/FilledArea.java b/src/java/org/apache/fop/area/inline/FilledArea.java index 9c3bcf4ca..214e4110a 100644 --- a/src/java/org/apache/fop/area/inline/FilledArea.java +++ b/src/java/org/apache/fop/area/inline/FilledArea.java @@ -21,6 +21,7 @@ package org.apache.fop.area.inline; import java.util.List; import java.util.ListIterator; import java.util.ArrayList; +import java.util.Iterator; /** * Filled area. @@ -84,7 +85,21 @@ public class FilledArea extends InlineParent { } /** - * Get the child areas for this filed area. + * @see org.apache.fop.area.Area#getBPD + */ + public int getBPD() { + int bpd = 0; + for (Iterator childAreaIt = getChildAreas().iterator(); childAreaIt.hasNext();) { + InlineArea area = (InlineArea)childAreaIt.next(); + if (bpd < area.getBPD()) { + bpd = area.getBPD(); + } + } + return bpd; + } + + /** + * Get the child areas for this filled area. * This copies the references of the inline areas so that * it fills the total width of the area a whole number of times * for the unit width. diff --git a/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java index ea1eb11a0..c24245f79 100755 --- a/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java @@ -98,18 +98,13 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { /** @see LayoutManager#initialize */ public void initialize() { - inlineProps = fobj.getCommonMarginInline(); - borderProps = fobj.getCommonBorderPaddingBackground(); - - int padding = borderProps.getPadding(CommonBorderPaddingBackground.BEFORE, false, this); - padding += borderProps.getBorderWidth(CommonBorderPaddingBackground.BEFORE, - false); - padding += borderProps.getPadding(CommonBorderPaddingBackground.AFTER, false, this); - padding += borderProps.getBorderWidth(CommonBorderPaddingBackground.AFTER, false); - extraBPD = new MinOptMax(padding); + int padding = 0; font = fobj.getCommonFont().getFontState(fobj.getFOEventHandler().getFontInfo(), this); lineHeight = fobj.getLineHeight(); + if (fobj instanceof Inline) { + inlineProps = fobj.getCommonMarginInline(); + borderProps = fobj.getCommonBorderPaddingBackground(); alignmentAdjust = ((Inline)fobj).getAlignmentAdjust(); alignmentBaseline = ((Inline)fobj).getAlignmentBaseline(); baselineShift = ((Inline)fobj).getBaselineShift(); @@ -120,42 +115,57 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { baselineShift = ((Leader)fobj).getBaselineShift(); dominantBaseline = ((Leader)fobj).getDominantBaseline(); } + if (borderProps != null) { + padding = borderProps.getPadding(CommonBorderPaddingBackground.BEFORE, false, this); + padding += borderProps.getBorderWidth(CommonBorderPaddingBackground.BEFORE, + false); + padding += borderProps.getPadding(CommonBorderPaddingBackground.AFTER, false, this); + padding += borderProps.getBorderWidth(CommonBorderPaddingBackground.AFTER, false); + } + extraBPD = new MinOptMax(padding); } /** @see InlineStackingLayoutManager#getExtraIPD(boolean, boolean) */ protected MinOptMax getExtraIPD(boolean isNotFirst, boolean isNotLast) { - int borderAndPadding - = borderProps.getPadding(CommonBorderPaddingBackground.START, isNotFirst, this); - borderAndPadding - += borderProps.getBorderWidth(CommonBorderPaddingBackground.START, isNotFirst); - borderAndPadding - += borderProps.getPadding(CommonBorderPaddingBackground.END, isNotLast, this); - borderAndPadding - += borderProps.getBorderWidth(CommonBorderPaddingBackground.END, isNotLast); + int borderAndPadding = 0; + if (borderProps != null) { + borderAndPadding + = borderProps.getPadding(CommonBorderPaddingBackground.START, isNotFirst, this); + borderAndPadding + += borderProps.getBorderWidth(CommonBorderPaddingBackground.START, isNotFirst); + borderAndPadding + += borderProps.getPadding(CommonBorderPaddingBackground.END, isNotLast, this); + borderAndPadding + += borderProps.getBorderWidth(CommonBorderPaddingBackground.END, isNotLast); + } return new MinOptMax(borderAndPadding); } /** @see InlineStackingLayoutManager#hasLeadingFence(boolean) */ protected boolean hasLeadingFence(boolean isNotFirst) { - return borderProps.getPadding(CommonBorderPaddingBackground.START, isNotFirst, this) > 0 - || borderProps.getBorderWidth(CommonBorderPaddingBackground.START, isNotFirst) > 0; + return borderProps != null + && (borderProps.getPadding(CommonBorderPaddingBackground.START, isNotFirst, this) > 0 + || borderProps.getBorderWidth(CommonBorderPaddingBackground.START, isNotFirst) > 0 + ); } /** @see InlineStackingLayoutManager#hasTrailingFence(boolean) */ protected boolean hasTrailingFence(boolean isNotLast) { - return borderProps.getPadding(CommonBorderPaddingBackground.END, isNotLast, this) > 0 - || borderProps.getBorderWidth(CommonBorderPaddingBackground.END, isNotLast) > 0; + return borderProps != null + && (borderProps.getPadding(CommonBorderPaddingBackground.END, isNotLast, this) > 0 + || borderProps.getBorderWidth(CommonBorderPaddingBackground.END, isNotLast) > 0 + ); } /** @see InlineStackingLayoutManager#getSpaceStart */ protected SpaceProperty getSpaceStart() { - return inlineProps.spaceStart; + return inlineProps != null ? inlineProps.spaceStart : null; } /** @see InlineStackingLayoutManager#getSpaceEnd */ protected SpaceProperty getSpaceEnd() { - return inlineProps.spaceEnd; + return inlineProps != null ? inlineProps.spaceEnd : null; } /** @see org.apache.fop.layoutmgr.inline.InlineLayoutManager#createArea(boolean) */ diff --git a/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java index ede040d21..9731cc960 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java @@ -201,6 +201,14 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager { widthAdjustArea(curArea, context); + if (commonBorderPaddingBackground != null) { + // Add border and padding to area + TraitSetter.setBorderPaddingTraits(curArea, + commonBorderPaddingBackground, + false, false, this); + TraitSetter.addBackground(curArea, commonBorderPaddingBackground, this); + } + // add content areas KnuthPossPosIter contentIter = new KnuthPossPosIter(contentList, 0, contentList.size()); clm.addAreas(contentIter, context); @@ -251,11 +259,19 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager { new LeafPosition(this, -1), true)); seq.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, new LeafPosition(this, -1), true)); - seq.add - (new KnuthGlue(areaInfo.ipdArea.opt, - areaInfo.ipdArea.max - areaInfo.ipdArea.opt, - areaInfo.ipdArea.opt - areaInfo.ipdArea.min, - new LeafPosition(this, 0), false)); + if (alignment == EN_JUSTIFY || alignment == 0) { + seq.add + (new KnuthGlue(areaInfo.ipdArea.opt, + areaInfo.ipdArea.max - areaInfo.ipdArea.opt, + areaInfo.ipdArea.opt - areaInfo.ipdArea.min, + new LeafPosition(this, 0), false)); + } else { + seq.add + (new KnuthGlue(areaInfo.ipdArea.opt, + 0, + 0, + new LeafPosition(this, 0), false)); + } seq.add(new KnuthInlineBox(0, alignmentContext, new LeafPosition(this, -1), true)); @@ -294,11 +310,19 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager { new LeafPosition(this, -1), true)); returnList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false, new LeafPosition(this, -1), true)); - returnList.add - (new KnuthGlue(areaInfo.ipdArea.opt, - areaInfo.ipdArea.max - areaInfo.ipdArea.opt, - areaInfo.ipdArea.opt - areaInfo.ipdArea.min, - new LeafPosition(this, 0), false)); + if (alignment == EN_JUSTIFY || alignment == 0) { + returnList.add + (new KnuthGlue(areaInfo.ipdArea.opt, + areaInfo.ipdArea.max - areaInfo.ipdArea.opt, + areaInfo.ipdArea.opt - areaInfo.ipdArea.min, + new LeafPosition(this, 0), false)); + } else { + returnList.add + (new KnuthGlue(areaInfo.ipdArea.opt, + 0, + 0, + new LeafPosition(this, 0), false)); + } returnList.add(new KnuthInlineBox(0, areaInfo.alignmentContext, new LeafPosition(this, -1), true)); |