From 6e65f409038594b64900780044fc5e94a84504e3 Mon Sep 17 00:00:00 2001 From: Vincent Hennebert Date: Thu, 7 Nov 2013 12:29:17 +0000 Subject: [PATCH] Added support for alignment-baseline on fo:inline-container git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_InlineContainer@1539611 13f79535-47bb-0310-9956-ffa450edef68 --- .../inline/InlineContainerLayoutManager.java | 20 +++-- .../inline-container_alignment-baseline.xml | 74 +++++++++++++++++++ 2 files changed, 86 insertions(+), 8 deletions(-) create mode 100644 test/layoutengine/standard-testcases/inline-container_alignment-baseline.xml diff --git a/src/java/org/apache/fop/layoutmgr/inline/InlineContainerLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/InlineContainerLayoutManager.java index 626ce8209..b043268bd 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/InlineContainerLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/InlineContainerLayoutManager.java @@ -57,7 +57,6 @@ import org.apache.fop.layoutmgr.TraitSetter; public class InlineContainerLayoutManager extends AbstractLayoutManager implements InlineLevelLayoutManager { private CommonBorderPaddingBackground borderProps; - private int alignmentBaseline = EN_BASELINE; private int contentAreaIPD; private int contentAreaBPD; @@ -77,6 +76,11 @@ public class InlineContainerLayoutManager extends AbstractLayoutManager implemen borderProps = node.getCommonBorderPaddingBackground(); } + private InlineContainer getInlineContainer() { + assert fobj instanceof InlineContainer; + return (InlineContainer) fobj; + } + @Override public List getNextKnuthElements(LayoutContext context, int alignment) { determineIPD(context); @@ -95,7 +99,7 @@ public class InlineContainerLayoutManager extends AbstractLayoutManager implemen } private void determineIPD(LayoutContext layoutContext) { - LengthRangeProperty ipd = ((InlineContainer) fobj).getInlineProgressionDimension(); + LengthRangeProperty ipd = getInlineContainer().getInlineProgressionDimension(); Property optimum = ipd.getOptimum(this); if (optimum.isAuto()) { contentAreaIPD = layoutContext.getRefIPD(); @@ -114,7 +118,7 @@ public class InlineContainerLayoutManager extends AbstractLayoutManager implemen LayoutContext childLC = LayoutContext.offspringOf(layoutContext); // TODO copyOf? newInstance? childLC.setRefIPD(layoutContext.getRefIPD()); @SuppressWarnings("unchecked") - List childElements = childLM.getNextKnuthElements(childLC, alignmentBaseline); + List childElements = childLM.getNextKnuthElements(childLC, alignment); allChildElements.addAll(childElements); // TODO breaks, keeps, empty content } @@ -127,7 +131,7 @@ public class InlineContainerLayoutManager extends AbstractLayoutManager implemen } private void determineBPD() { - LengthRangeProperty bpd = ((InlineContainer) fobj).getBlockProgressionDimension(); + LengthRangeProperty bpd = getInlineContainer().getBlockProgressionDimension(); Property optimum = bpd.getOptimum(this); int actualBPD = ElementListUtils.calcContentLength(childElements); if (optimum.isAuto()) { @@ -181,15 +185,15 @@ public class InlineContainerLayoutManager extends AbstractLayoutManager implemen } private boolean canRecoverFromOverflow() { - return ((InlineContainer) fobj).getOverflow() != EN_ERROR_IF_OVERFLOW; + return getInlineContainer().getOverflow() != EN_ERROR_IF_OVERFLOW; } private int getAlignmentPoint() { - Length alignmentAdjust = ((InlineContainer) fobj).getAlignmentAdjust(); + Length alignmentAdjust = getInlineContainer().getAlignmentAdjust(); int baseline = alignmentAdjust.getEnum(); if (baseline == Constants.EN_AUTO || baseline == Constants.EN_BASELINE) { - return getInlineContainerBaselineOffset(alignmentBaseline); + return getInlineContainerBaselineOffset(getInlineContainer().getAlignmentBaseline()); } else if (baseline != 0) { return getInlineContainerBaselineOffset(baseline); } else { @@ -294,7 +298,7 @@ public class InlineContainerLayoutManager extends AbstractLayoutManager implemen } private boolean needClip() { - int overflow = ((InlineContainer) fobj).getOverflow(); + int overflow = getInlineContainer().getOverflow(); return (overflow == EN_HIDDEN || overflow == EN_ERROR_IF_OVERFLOW); } diff --git a/test/layoutengine/standard-testcases/inline-container_alignment-baseline.xml b/test/layoutengine/standard-testcases/inline-container_alignment-baseline.xml new file mode 100644 index 000000000..53b9be0a9 --- /dev/null +++ b/test/layoutengine/standard-testcases/inline-container_alignment-baseline.xml @@ -0,0 +1,74 @@ + + + + + +

+ Checks that the alignment-baseline property on inline-container behaves properly. +

+
+ + + + + + + + + + + alignment-baseline="before-edge": + The line before. The line before. Before: + Inside the inline-container. + After the inline-container. + + + + + + alignment-baseline="central": + The line before. The line before. Before: + Inside the inline-container. + After the inline-container. + + + + + + + + + + + + + + + + + + + + + + + +
-- 2.39.5