From 0169e567a969752cf36139831318187a1e63c8e9 Mon Sep 17 00:00:00 2001 From: Vincent Hennebert Date: Mon, 28 Oct 2013 17:15:35 +0000 Subject: [PATCH] Added support for percentage dimensions git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_InlineContainer@1536425 13f79535-47bb-0310-9956-ffa450edef68 --- .../inline/InlineContainerLayoutManager.java | 27 ++++---- ...-ipd.xml => inline-container_ipd-auto.xml} | 0 .../inline-container_ipd-percent.xml | 61 +++++++++++++++++++ 3 files changed, 77 insertions(+), 11 deletions(-) rename test/layoutengine/standard-testcases/{inline-container_auto-ipd.xml => inline-container_ipd-auto.xml} (100%) create mode 100644 test/layoutengine/standard-testcases/inline-container_ipd-percent.xml diff --git a/src/java/org/apache/fop/layoutmgr/inline/InlineContainerLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/InlineContainerLayoutManager.java index a51d64c2c..7e2b186be 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/InlineContainerLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/InlineContainerLayoutManager.java @@ -95,32 +95,37 @@ public class InlineContainerLayoutManager extends AbstractLayoutManager implemen private void determineIPD(LayoutContext layoutContext) { LengthRangeProperty ipd = ((InlineContainer) fobj).getInlineProgressionDimension(); - Property optimum = ipd.getOptimum(this); // TODO percent base context + Property optimum = ipd.getOptimum(this); if (optimum.isAuto()) { contentAreaIPD = layoutContext.getRefIPD(); InlineLevelEventProducer eventProducer = InlineLevelEventProducer.Provider.get( fobj.getUserAgent().getEventBroadcaster()); eventProducer.inlineContainerAutoIPDNotSupported(this, contentAreaIPD / 1000f); } else { - contentAreaIPD = optimum.getLength().getValue(this); // TODO percent base context + contentAreaIPD = optimum.getLength().getValue(this); } } private void determineBPD() { LengthRangeProperty bpd = ((InlineContainer) fobj).getBlockProgressionDimension(); - Property optimum = bpd.getOptimum(this); // TODO percent base context + Property optimum = bpd.getOptimum(this); int actualBPD = ElementListUtils.calcContentLength(childElements); if (optimum.isAuto()) { contentAreaBPD = actualBPD; } else { - contentAreaBPD = optimum.getLength().getValue(this); // TODO percent base context - if (contentAreaBPD < actualBPD) { - BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Provider.get( - fobj.getUserAgent().getEventBroadcaster()); - boolean canRecover = (((InlineContainer) fobj).getOverflow() != EN_ERROR_IF_OVERFLOW); - eventProducer.viewportBPDOverflow(this, fobj.getName(), - actualBPD - contentAreaBPD, needClip(), canRecover, - fobj.getLocator()); + double bpdValue = optimum.getLength().getNumericValue(this); + if (bpdValue < 0) { + contentAreaBPD = actualBPD; + } else { + contentAreaBPD = (int) Math.round(bpdValue); + if (contentAreaBPD < actualBPD) { + BlockLevelEventProducer eventProducer = BlockLevelEventProducer.Provider.get( + fobj.getUserAgent().getEventBroadcaster()); + boolean canRecover = (((InlineContainer) fobj).getOverflow() != EN_ERROR_IF_OVERFLOW); + eventProducer.viewportBPDOverflow(this, fobj.getName(), + actualBPD - contentAreaBPD, needClip(), canRecover, + fobj.getLocator()); + } } } } diff --git a/test/layoutengine/standard-testcases/inline-container_auto-ipd.xml b/test/layoutengine/standard-testcases/inline-container_ipd-auto.xml similarity index 100% rename from test/layoutengine/standard-testcases/inline-container_auto-ipd.xml rename to test/layoutengine/standard-testcases/inline-container_ipd-auto.xml diff --git a/test/layoutengine/standard-testcases/inline-container_ipd-percent.xml b/test/layoutengine/standard-testcases/inline-container_ipd-percent.xml new file mode 100644 index 000000000..aa681d134 --- /dev/null +++ b/test/layoutengine/standard-testcases/inline-container_ipd-percent.xml @@ -0,0 +1,61 @@ + + + + + +

+ Checks that percentage values for the dimensions of an fo:inline-container are resolved + properly. +

+
+ + + + + + + + + + Before: + Text inside inline-container. + After. + + + + + + + Before: + Inside the inline-container. + After. + + + + + + + + + + + + + +
-- 2.39.5