From 9ded99b802da5240a8c69066b019cb2d9dc99a73 Mon Sep 17 00:00:00 2001 From: Jeremias Maerki Date: Tue, 24 Jan 2006 13:45:56 +0000 Subject: [PATCH] Bugfix: LineArea used a private field instead of the start-indent trait which caused problems for centered and right-aligned text when rendering is done from the intermediate format. The AreaTreeParser parses and sets the trait but not the startIndent field on LineArea, so I removed the startIndent field. git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@371912 13f79535-47bb-0310-9956-ffa450edef68 --- src/java/org/apache/fop/area/LineArea.java | 29 +++++-------------- .../layoutmgr/inline/LineLayoutManager.java | 8 ++--- 2 files changed, 11 insertions(+), 26 deletions(-) diff --git a/src/java/org/apache/fop/area/LineArea.java b/src/java/org/apache/fop/area/LineArea.java index e19e71374..eb2343565 100644 --- a/src/java/org/apache/fop/area/LineArea.java +++ b/src/java/org/apache/fop/area/LineArea.java @@ -57,14 +57,6 @@ public class LineArea extends Area { private LineAdjustingInfo adjustingInfo = null; - //private int stacking = LR; - // contains inline areas - // has start indent and length, dominant baseline, height - private int startIndent; - - // this is the offset for the dominant baseline - //private int baseLine; - // this class can contain the dominant char styling info // this means that many renderers can optimise a bit @@ -121,17 +113,6 @@ public class LineArea extends Area { return inlineAreas; } - /** - * Set the start indent of this line area. - * The start indent is used for offsetting the start of - * the inline areas for alignment or other indents. - * - * @param si the start indent value - */ - public void setStartIndent(int si) { - startIndent = si; - } - /** * Get the start indent of this line area. * The start indent is used for offsetting the start of @@ -140,7 +121,11 @@ public class LineArea extends Area { * @return the start indent value */ public int getStartIndent() { - return startIndent; + if (hasTrait(Trait.START_INDENT)) { + return getTraitAsInteger(Trait.START_INDENT); + } else { + return 0; + } } /** @@ -179,11 +164,11 @@ public class LineArea extends Area { break; case Constants.EN_CENTER: // re-compute indent - startIndent -= ipdVariation / 2; + addTrait(Trait.START_INDENT, new Integer(getStartIndent() - ipdVariation / 2)); break; case Constants.EN_END: // re-compute indent - startIndent -= ipdVariation; + addTrait(Trait.START_INDENT, new Integer(getStartIndent() - ipdVariation)); break; case Constants.EN_JUSTIFY: // compute variation factor diff --git a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java index e3ea55669..c5d322a82 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java @@ -14,7 +14,7 @@ * limitations under the License. */ -/* $Id: LineLayoutManager.java,v 1.17 2004/04/02 10:38:29 cbowditch Exp $ */ +/* $Id$ */ package org.apache.fop.layoutmgr.inline; @@ -1664,7 +1664,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager = new LineArea((lbp.getLeafPos() < seq.size() - 1 ? textAlignment : textAlignmentLast), lbp.difference, lbp.availableStretch, lbp.availableShrink); - lineArea.setStartIndent(lbp.startIndent); + lineArea.addTrait(Trait.START_INDENT, new Integer(lbp.startIndent)); lineArea.setBPD(lbp.lineHeight); lineArea.setIPD(lbp.lineWidth); lineArea.addTrait(Trait.SPACE_BEFORE, new Integer(lbp.spaceBefore)); @@ -1745,12 +1745,12 @@ public class LineLayoutManager extends InlineStackingLayoutManager // re-compute indent int updatedIndent = lbp.startIndent + (context.getStackLimit().opt - lbp.lineWidth) / 2; - lineArea.setStartIndent(updatedIndent); + lineArea.addTrait(Trait.START_INDENT, new Integer(updatedIndent)); } else if (false && textAlignment == EN_END) { // re-compute indent int updatedIndent = lbp.startIndent + (context.getStackLimit().opt - lbp.lineWidth); - lineArea.setStartIndent(updatedIndent); + lineArea.addTrait(Trait.START_INDENT, new Integer(updatedIndent)); } setCurrentArea(lineArea); -- 2.39.5