aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org/apache/fop
diff options
context:
space:
mode:
authorVincent Hennebert <vhennebert@apache.org>2013-11-07 12:27:22 +0000
committerVincent Hennebert <vhennebert@apache.org>2013-11-07 12:27:22 +0000
commit89b34550c9bb72ba8dcf01e09038ad11ec5757f6 (patch)
treec152b92d47bd95745353632f210c072a18ffb192 /src/java/org/apache/fop
parent3e04d9245827bc5bcbd320728fb14ec6f7613290 (diff)
downloadxmlgraphics-fop-89b34550c9bb72ba8dcf01e09038ad11ec5757f6.tar.gz
xmlgraphics-fop-89b34550c9bb72ba8dcf01e09038ad11ec5757f6.zip
Added support for non-default values of alignment-adjust
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_InlineContainer@1539610 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop')
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/InlineContainerLayoutManager.java43
1 files changed, 42 insertions, 1 deletions
diff --git a/src/java/org/apache/fop/layoutmgr/inline/InlineContainerLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/InlineContainerLayoutManager.java
index 9495e2c73..626ce8209 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/InlineContainerLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/InlineContainerLayoutManager.java
@@ -27,6 +27,8 @@ import org.apache.fop.area.Area;
import org.apache.fop.area.Trait;
import org.apache.fop.area.inline.Container;
import org.apache.fop.area.inline.InlineViewport;
+import org.apache.fop.datatypes.Length;
+import org.apache.fop.fo.Constants;
import org.apache.fop.fo.flow.InlineContainer;
import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
import org.apache.fop.fo.properties.LengthRangeProperty;
@@ -152,7 +154,7 @@ public class InlineContainerLayoutManager extends AbstractLayoutManager implemen
ic.getAlignmentAdjust(), ic.getAlignmentBaseline(),
ic.getBaselineShift(), ic.getDominantBaseline(),
context.getAlignmentContext());
- int baselineOffset = hasLineAreaDescendant() ? getBaselineOffset() : contentAreaBPD;
+ int baselineOffset = getAlignmentPoint();
ac.resizeLine(contentAreaBPD, baselineOffset);
return ac;
}
@@ -182,6 +184,45 @@ public class InlineContainerLayoutManager extends AbstractLayoutManager implemen
return ((InlineContainer) fobj).getOverflow() != EN_ERROR_IF_OVERFLOW;
}
+ private int getAlignmentPoint() {
+ Length alignmentAdjust = ((InlineContainer) fobj).getAlignmentAdjust();
+ int baseline = alignmentAdjust.getEnum();
+ if (baseline == Constants.EN_AUTO
+ || baseline == Constants.EN_BASELINE) {
+ return getInlineContainerBaselineOffset(alignmentBaseline);
+ } else if (baseline != 0) {
+ return getInlineContainerBaselineOffset(baseline);
+ } else {
+ return 0;
+ }
+ }
+
+ private int getInlineContainerBaselineOffset(int property) {
+ switch (property) {
+ case Constants.EN_BEFORE_EDGE:
+ case Constants.EN_TEXT_BEFORE_EDGE:
+ return 0;
+ case Constants.EN_AFTER_EDGE:
+ case Constants.EN_TEXT_AFTER_EDGE:
+ return contentAreaBPD;
+ case Constants.EN_MIDDLE:
+ case Constants.EN_CENTRAL:
+ case Constants.EN_MATHEMATICAL:
+ return contentAreaBPD / 2;
+ case Constants.EN_IDEOGRAPHIC:
+ return contentAreaBPD * 7 / 10;
+ case Constants.EN_ALPHABETIC:
+ return contentAreaBPD * 6 / 10;
+ case Constants.EN_HANGING:
+ return contentAreaBPD * 2 / 10;
+ case Constants.EN_AUTO:
+ case Constants.EN_BASELINE:
+ return hasLineAreaDescendant() ? getBaselineOffset() : contentAreaBPD;
+ default:
+ throw new AssertionError("Unknown baseline value: " + property);
+ }
+ }
+
@Override
public boolean getGeneratesReferenceArea() {
return true;