You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by ma...@apache.org on 2005/10/07 10:57:05 UTC
svn commit: r307055 [3/9] - in /xmlgraphics/fop/trunk:
src/java/org/apache/fop/area/ src/java/org/apache/fop/area/inline/
src/java/org/apache/fop/datatypes/ src/java/org/apache/fop/fo/
src/java/org/apache/fop/fo/flow/ src/java/org/apache/fop/fo/propert...
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/KnuthInlineBox.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/KnuthInlineBox.java?rev=307055&r1=307054&r2=307055&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/KnuthInlineBox.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/KnuthInlineBox.java Fri Oct 7 01:55:22 2005
@@ -18,53 +18,34 @@
package org.apache.fop.layoutmgr.inline;
+import org.apache.fop.layoutmgr.inline.AlignmentContext;
import org.apache.fop.layoutmgr.FootnoteBodyLayoutManager;
import org.apache.fop.layoutmgr.KnuthBox;
import org.apache.fop.layoutmgr.Position;
public class KnuthInlineBox extends KnuthBox {
- private int lead;
- private int total;
- private int middle;
private FootnoteBodyLayoutManager footnoteBodyLM = null;
+ private AlignmentContext alignmentContext = null;
/**
* Create a new KnuthBox.
*
* @param w the width of this box
- * @param l the height of this box above the main baseline
- * @param t the total height of this box
- * @param m the height of this box above and below the middle baseline
+ * @param alignmentContext the alignmentContext for this box
* @param pos the Position stored in this box
* @param bAux is this box auxiliary?
*/
- public KnuthInlineBox(int w, int l, int t, int m, Position pos, boolean bAux) {
+ public KnuthInlineBox(int w, AlignmentContext alignmentContext, Position pos, boolean bAux) {
super(w, pos, bAux);
- lead = l;
- total = t;
- middle = m;
+ this.alignmentContext = alignmentContext;
}
/**
- * @return the height of this box above the main baseline.
+ * @return the alignment context.
*/
- public int getLead() {
- return lead;
- }
-
- /**
- * @return the total height of this box.
- */
- public int getTotal() {
- return total;
- }
-
- /**
- * @return the height of this box above and below the middle baseline.
- */
- public int getMiddle() {
- return middle;
+ public AlignmentContext getAlignmentContext() {
+ return alignmentContext;
}
/**
@@ -92,9 +73,6 @@
/** @see java.lang.Object#toString() */
public String toString() {
StringBuffer sb = new StringBuffer(super.toString());
- sb.append(" lead=").append(lead);
- sb.append(" total=").append(total);
- sb.append(" middle=").append(middle);
return sb.toString();
}
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java?rev=307055&r1=307054&r2=307055&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java Fri Oct 7 01:55:22 2005
@@ -46,7 +46,7 @@
*/
public class LeaderLayoutManager extends LeafNodeLayoutManager {
private Leader fobj;
- Font font = null;
+ private Font font = null;
private LinkedList contentList = null;
private ContentLayoutManager clm = null;
@@ -57,35 +57,52 @@
* Constructor
*
* @param node the formatting object that creates this area
- * @todo better null checking of font object
*/
public LeaderLayoutManager(Leader node) {
super(node);
fobj = node;
}
+ /** @see LayoutManager#initialize */
public void initialize() {
font = fobj.getCommonFont().getFontState(fobj.getFOEventHandler().getFontInfo(), this);
// the property leader-alignment does not affect vertical positioning
// (see section 7.21.1 in the XSL Recommendation)
// setAlignment(node.getLeaderAlignment());
- setAlignment(fobj.getVerticalAlign());
+ setCommonBorderPaddingBackground(fobj.getCommonBorderPaddingBackground());
}
+ /**
+ * Return the inline area for this leader.
+ * @param context the layout context
+ * @return the inline area
+ */
public InlineArea get(LayoutContext context) {
return getLeaderInlineArea();
}
+ /**
+ * Return the allocated IPD for this area.
+ * @param refIPD the IPD of the reference area
+ * @return the allocated IPD
+ */
protected MinOptMax getAllocationIPD(int refIPD) {
return getLeaderAllocIPD(refIPD);
}
private MinOptMax getLeaderAllocIPD(int ipd) {
// length of the leader
- setContentAreaIPD(ipd);
- int opt = fobj.getLeaderLength().getOptimum(this).getLength().getValue(this);
- int min = fobj.getLeaderLength().getMinimum(this).getLength().getValue(this);
- int max = fobj.getLeaderLength().getMaximum(this).getLength().getValue(this);
+ int borderPaddingWidth = 0;
+ if (commonBorderPaddingBackground != null) {
+ borderPaddingWidth = commonBorderPaddingBackground.getIPPaddingAndBorder(false, this);
+ }
+ setContentAreaIPD(ipd - borderPaddingWidth);
+ int opt = fobj.getLeaderLength().getOptimum(this).getLength().getValue(this)
+ - borderPaddingWidth;
+ int min = fobj.getLeaderLength().getMinimum(this).getLength().getValue(this)
+ - borderPaddingWidth;
+ int max = fobj.getLeaderLength().getMaximum(this).getLength().getValue(this)
+ - borderPaddingWidth;
return new MinOptMax(min, opt, max);
}
@@ -93,24 +110,31 @@
InlineArea leaderArea = null;
if (fobj.getLeaderPattern() == EN_RULE) {
- org.apache.fop.area.inline.Leader leader =
- new org.apache.fop.area.inline.Leader();
- leader.setRuleStyle(fobj.getRuleStyle());
- leader.setRuleThickness(fobj.getRuleThickness().getValue(this));
- leader.setBPD(fobj.getRuleThickness().getValue(this));
- leaderArea = leader;
+ if (fobj.getRuleStyle() != EN_NONE) {
+ org.apache.fop.area.inline.Leader leader
+ = new org.apache.fop.area.inline.Leader();
+ leader.setRuleStyle(fobj.getRuleStyle());
+ leader.setRuleThickness(fobj.getRuleThickness().getValue(this));
+ leader.setBPD(fobj.getRuleThickness().getValue(this));
+ leaderArea = leader;
+ } else {
+ leaderArea = new Space();
+ leaderArea.setBPD(1);
+ }
} else if (fobj.getLeaderPattern() == EN_SPACE) {
leaderArea = new Space();
- leaderArea.setBPD(font.getAscender());
+ leaderArea.setBPD(1);
} else if (fobj.getLeaderPattern() == EN_DOTS) {
TextArea t = new TextArea();
char dot = '.'; // userAgent.getLeaderDotCharacter();
+ int width = font.getCharWidth(dot);
t.setTextArea("" + dot);
- t.setIPD(font.getCharWidth(dot));
+ t.setIPD(width);
+ t.setBPD(width);
+ t.setBaselineOffset(width);
t.addTrait(Trait.FONT_NAME, font.getFontName());
t.addTrait(Trait.FONT_SIZE, new Integer(font.getFontSize()));
- int width = font.getCharWidth(dot);
Space spacer = null;
if (fobj.getLeaderPatternWidth().getValue(this) > width) {
spacer = new Space();
@@ -123,7 +147,7 @@
if (spacer != null) {
fa.addChildArea(spacer);
}
- fa.setBPD(font.getAscender());
+ fa.setBPD(t.getBPD());
leaderArea = fa;
} else if (fobj.getLeaderPattern() == EN_USECONTENT) {
@@ -163,68 +187,7 @@
return leaderArea;
}
- protected void offsetArea(InlineArea area, LayoutContext context) {
- int pattern = fobj.getLeaderPattern();
- int bpd = area.getBPD();
-
- switch (pattern) {
- case EN_RULE:
- switch (verticalAlignment) {
- case EN_TOP:
- area.setOffset(0);
- break;
- case EN_MIDDLE:
- area.setOffset(context.getMiddleBaseline() - bpd / 2);
- break;
- case EN_BOTTOM:
- area.setOffset(context.getLineHeight() - bpd);
- break;
- case EN_BASELINE: // fall through
- default:
- area.setOffset(context.getBaseline() - bpd);
- break;
- }
- break;
- case EN_DOTS:
- switch (verticalAlignment) {
- case EN_TOP:
- area.setOffset(0);
- break;
- case EN_MIDDLE:
- area.setOffset(context.getMiddleBaseline());
- break;
- case EN_BOTTOM:
- area.setOffset(context.getLineHeight() - bpd + font.getAscender());
- break;
- case EN_BASELINE: // fall through
- default:
- area.setOffset(context.getBaseline());
- break;
- }
- break;
- case EN_SPACE:
- // nothing to do
- break;
- case EN_USECONTENT:
- switch (verticalAlignment) {
- case EN_TOP:
- area.setOffset(0);
- break;
- case EN_MIDDLE:
- area.setOffset(context.getMiddleBaseline());
- break;
- case EN_BOTTOM:
- area.setOffset(context.getLineHeight() - bpd);
- break;
- case EN_BASELINE: // fall through
- default:
- area.setOffset(context.getBaseline());
- break;
- }
- break;
- }
- }
-
+ /** @see LeafNodeLayoutManager#addAreas(PositionIterator, LayoutContext) */
public void addAreas(PositionIterator posIter, LayoutContext context) {
if (fobj.getLeaderPattern() != EN_USECONTENT) {
// use LeafNodeLayoutManager.addAreas()
@@ -247,6 +210,7 @@
}
}
+ /** @see LayoutManager#getNextKnuthElements(LayoutContext, int) */
public LinkedList getNextKnuthElements(LayoutContext context,
int alignment) {
MinOptMax ipd;
@@ -258,30 +222,22 @@
return null;
}
- ipd = getAllocationIPD(context.getRefIPD());
+ alignmentContext = new AlignmentContext(curArea.getBPD()
+ , fobj.getAlignmentAdjust()
+ , fobj.getAlignmentBaseline()
+ , fobj.getBaselineShift()
+ , fobj.getDominantBaseline()
+ , context.getAlignmentContext());
- int bpd = curArea.getBPD();
- int lead = 0;
- int total = 0;
- int middle = 0;
- switch (verticalAlignment) {
- case EN_MIDDLE : middle = bpd / 2 ;
- break;
- case EN_TOP : // fall through
- case EN_BOTTOM : total = bpd;
- break;
- case EN_BASELINE: // fall through
- default: lead = bpd;
- break;
- }
+ ipd = getAllocationIPD(context.getRefIPD());
// create the AreaInfo object to store the computed values
- areaInfo = new AreaInfo((short) 0, ipd, false,
- lead, total, middle);
+ areaInfo = new AreaInfo((short) 0, ipd, false, context.getAlignmentContext());
+ addKnuthElementsForBorderPaddingStart(seq);
+
// node is a fo:Leader
- seq.add(new KnuthInlineBox(0, areaInfo.lead, areaInfo.total,
- areaInfo.middle,
+ seq.add(new KnuthInlineBox(0, alignmentContext,
new LeafPosition(this, -1), true));
seq.add(new KnuthPenalty(0, KnuthElement.INFINITE, false,
new LeafPosition(this, -1), true));
@@ -290,28 +246,31 @@
areaInfo.ipdArea.max - areaInfo.ipdArea.opt,
areaInfo.ipdArea.opt - areaInfo.ipdArea.min,
new LeafPosition(this, 0), false));
- seq.add(new KnuthInlineBox(0, areaInfo.lead, areaInfo.total,
- areaInfo.middle,
+ seq.add(new KnuthInlineBox(0, alignmentContext,
new LeafPosition(this, -1), true));
+ addKnuthElementsForBorderPaddingEnd(seq);
+
LinkedList returnList = new LinkedList();
returnList.add(seq);
setFinished(true);
return returnList;
}
+ /** @see InlineLevelLayoutManager#hyphenate(Position, HyphContext) */
public void hyphenate(Position pos, HyphContext hc) {
// use the AbstractLayoutManager.hyphenate() null implementation
super.hyphenate(pos, hc);
}
+ /** @see InlineLevelLayoutManager#applyChanges(list) */
public boolean applyChanges(List oldList) {
setFinished(false);
return false;
}
+ /** @see LayoutManager#getNextKnuthElements(LayoutContext, int) */
public LinkedList getChangedKnuthElements(List oldList,
- int flaggedPenalty,
int alignment) {
if (isFinished()) {
return null;
@@ -319,8 +278,9 @@
LinkedList returnList = new LinkedList();
- returnList.add(new KnuthInlineBox(0, areaInfo.lead, areaInfo.total,
- areaInfo.middle,
+ addKnuthElementsForBorderPaddingStart(returnList);
+
+ returnList.add(new KnuthInlineBox(0, areaInfo.alignmentContext,
new LeafPosition(this, -1), true));
returnList.add(new KnuthPenalty(0, KnuthElement.INFINITE, false,
new LeafPosition(this, -1), true));
@@ -329,14 +289,16 @@
areaInfo.ipdArea.max - areaInfo.ipdArea.opt,
areaInfo.ipdArea.opt - areaInfo.ipdArea.min,
new LeafPosition(this, 0), false));
- returnList.add(new KnuthInlineBox(0, areaInfo.lead, areaInfo.total,
- areaInfo.middle,
+ returnList.add(new KnuthInlineBox(0, areaInfo.alignmentContext,
new LeafPosition(this, -1), true));
+ addKnuthElementsForBorderPaddingEnd(returnList);
+
setFinished(true);
return returnList;
}
+ /** @see LeafNodeLayoutManager#addId */
protected void addId() {
getPSLM().addIDToPage(fobj.getId());
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java?rev=307055&r1=307054&r2=307055&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LeafNodeLayoutManager.java Fri Oct 7 01:55:22 2005
@@ -18,19 +18,24 @@
package org.apache.fop.layoutmgr.inline;
+import java.util.LinkedList;
+import java.util.List;
+
import org.apache.fop.area.Area;
import org.apache.fop.area.inline.InlineArea;
import org.apache.fop.fo.FObj;
+import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
import org.apache.fop.layoutmgr.AbstractLayoutManager;
+import org.apache.fop.layoutmgr.KnuthGlue;
+import org.apache.fop.layoutmgr.KnuthPenalty;
import org.apache.fop.layoutmgr.KnuthSequence;
import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.LeafPosition;
import org.apache.fop.layoutmgr.Position;
import org.apache.fop.layoutmgr.PositionIterator;
+import org.apache.fop.layoutmgr.TraitSetter;
import org.apache.fop.traits.MinOptMax;
-import java.util.List;
-import java.util.LinkedList;
/**
* Base LayoutManager for leaf-node FObj, ie: ones which have no children.
@@ -45,11 +50,16 @@
* The inline area that this leafnode will add.
*/
protected InlineArea curArea = null;
- protected int verticalAlignment;
- private int lead;
+ /** Any border, padding and background properties applying to this area */
+ protected CommonBorderPaddingBackground commonBorderPaddingBackground = null;
+ /** The alignment context applying to this area */
+ protected AlignmentContext alignmentContext = null;
+
private MinOptMax ipd;
- protected boolean bSomethingChanged = false;
+ /** Flag to indicate if something was changed as part of the getChangeKnuthElements sequence */
+ protected boolean isSomethingChanged = false;
+ /** Our area info for the Knuth elements */
protected AreaInfo areaInfo = null;
/**
@@ -59,19 +69,16 @@
protected short iLScount;
protected MinOptMax ipdArea;
protected boolean bHyphenated;
- protected int lead;
- protected int total;
- protected int middle;
+ protected AlignmentContext alignmentContext;
public AreaInfo(short iLS, MinOptMax ipd, boolean bHyph,
- int l, int t, int m) {
+ AlignmentContext alignmentContext) {
iLScount = iLS;
ipdArea = ipd;
bHyphenated = bHyph;
- lead = l;
- total = t;
- middle = m;
+ this.alignmentContext = alignmentContext;
}
+
}
@@ -117,29 +124,6 @@
}
/**
- * Set the alignment of the inline area.
- * @param al the vertical alignment positioning
- */
- public void setAlignment(int al) {
- verticalAlignment = al;
- }
-
- /**
- * Set the lead for this inline area.
- * The lead is the distance from the top of the object
- * to the baseline.
- * @param l the lead value
- */
- public void setLead(int l) {
- lead = l;
- }
-
- /** @return the lead value (distance from the top of the object to the baseline) */
- public int getLead() {
- return this.lead;
- }
-
- /**
* This is a leaf-node, so this method is never called.
* @param childArea the childArea to add
*/
@@ -156,6 +140,15 @@
}
/**
+ * Set the border and padding properties of the inline area.
+ * @param commonBorderPaddingBackground the alignment adjust property
+ */
+ protected void setCommonBorderPaddingBackground(
+ CommonBorderPaddingBackground commonBorderPaddingBackground) {
+ this.commonBorderPaddingBackground = commonBorderPaddingBackground;
+ }
+
+ /**
* Get the allocation ipd of the inline area.
* This method may be overridden to handle percentage values.
* @param refIPD the ipd of the parent reference area
@@ -178,6 +171,13 @@
if (area.getAllocIPD() > 0 || area.getAllocBPD() > 0) {
offsetArea(area, context);
widthAdjustArea(area, context);
+ if (commonBorderPaddingBackground != null) {
+ // Add border and padding to area
+ TraitSetter.setBorderPaddingTraits(area,
+ commonBorderPaddingBackground,
+ false, false, this);
+ TraitSetter.addBackground(area, commonBorderPaddingBackground, this);
+ }
parentLM.addChildArea(area);
}
@@ -212,22 +212,19 @@
* @param context the layout context used for adding the area
*/
protected void offsetArea(InlineArea area, LayoutContext context) {
- int bpd = area.getBPD();
- switch (verticalAlignment) {
- case EN_MIDDLE:
- area.setOffset(context.getMiddleBaseline() - bpd / 2);
- break;
- case EN_TOP:
- area.setOffset(context.getTopBaseline());
- break;
- case EN_BOTTOM:
- area.setOffset(context.getBottomBaseline() - bpd);
- break;
- case EN_BASELINE:
- default:
- area.setOffset(context.getBaseline() - bpd);
- break;
- }
+ area.setOffset(alignmentContext.getOffset());
+ }
+
+ /**
+ * Creates a new alignment context or returns the current
+ * alignment context.
+ * This is used for vertical alignment.
+ * Subclasses should override this if necessary.
+ * @param context the layout context used
+ * @return the appropriate alignment context
+ */
+ protected AlignmentContext makeAlignmentContext(LayoutContext context) {
+ return context.getAlignmentContext();
}
/**
@@ -249,54 +246,42 @@
}
area.setIPD(width);
}
-
- public LinkedList getNextKnuthElements(LayoutContext context,
- int alignment) {
- MinOptMax ipd;
+
+ /** @see LayoutManager#getNextKnuthElements(LayoutContext, int) */
+ public LinkedList getNextKnuthElements(LayoutContext context, int alignment) {
curArea = get(context);
-
+
if (curArea == null) {
setFinished(true);
return null;
}
- ipd = getAllocationIPD(context.getRefIPD());
- int bpd = curArea.getBPD();
- int lead = 0;
- int total = 0;
- int middle = 0;
- switch (verticalAlignment) {
- case EN_MIDDLE : middle = bpd / 2 ;
- lead = bpd / 2 ;
- break;
- case EN_TOP : total = bpd;
- break;
- case EN_BOTTOM : total = bpd;
- break;
- case EN_BASELINE:
- default:
- //lead = bpd;
- lead = getLead();
- total = bpd;
- break;
- }
+ alignmentContext = makeAlignmentContext(context);
+
+ MinOptMax ipd = getAllocationIPD(context.getRefIPD());
// create the AreaInfo object to store the computed values
- areaInfo = new AreaInfo((short) 0, ipd, false,
- lead, total, middle);
+ areaInfo = new AreaInfo((short) 0, ipd, false, alignmentContext);
// node is a fo:ExternalGraphic, fo:InstreamForeignObject,
// fo:PageNumber or fo:PageNumberCitation
KnuthSequence seq = new KnuthSequence(true);
- seq.add(new KnuthInlineBox(areaInfo.ipdArea.opt, areaInfo.lead,
- areaInfo.total, areaInfo.middle,
- new LeafPosition(this, 0), false));
+
+ addKnuthElementsForBorderPaddingStart(seq);
+
+ seq.add(new KnuthInlineBox(areaInfo.ipdArea.opt, alignmentContext,
+ notifyPos(new LeafPosition(this, 0)), false));
+
+ addKnuthElementsForBorderPaddingEnd(seq);
+
LinkedList returnList = new LinkedList();
+
returnList.add(seq);
setFinished(true);
return returnList;
}
+ /** @see InlineLevelLayoutManager#addALetterSpaceTo(List) */
public List addALetterSpaceTo(List oldList) {
// return the unchanged elements
return oldList;
@@ -312,19 +297,22 @@
log.warn(this.getClass().getName() + " should not receive a call to removeWordSpace(list)");
}
+ /** @see InlineLevelLayoutManager#getWordChars(StringBuffer, Position) */
public void getWordChars(StringBuffer sbChars, Position pos) {
}
+ /** @see InlineLevelLayoutManager#hyphenate(Position, HyphContext) */
public void hyphenate(Position pos, HyphContext hc) {
}
+ /** @see InlineLevelLayoutManager#applyChanges(List) */
public boolean applyChanges(List oldList) {
setFinished(false);
return false;
}
+ /** @see LayoutManager#getChangedKnuthElements(List, int) */
public LinkedList getChangedKnuthElements(List oldList,
- /*int flaggedPenalty,*/
int alignment) {
if (isFinished()) {
return null;
@@ -332,14 +320,54 @@
LinkedList returnList = new LinkedList();
+ addKnuthElementsForBorderPaddingStart(returnList);
+
// fobj is a fo:ExternalGraphic, fo:InstreamForeignObject,
// fo:PageNumber or fo:PageNumberCitation
- returnList.add(new KnuthInlineBox(areaInfo.ipdArea.opt, areaInfo.lead,
- areaInfo.total, areaInfo.middle,
- new LeafPosition(this, 0), true));
+ returnList.add(new KnuthInlineBox(areaInfo.ipdArea.opt, areaInfo.alignmentContext,
+ notifyPos(new LeafPosition(this, 0)), true));
+ addKnuthElementsForBorderPaddingEnd(returnList);
+
setFinished(true);
return returnList;
}
+
+ /**
+ * Creates Knuth elements for start border padding and adds them to the return list.
+ * @param returnList return list to add the additional elements to
+ */
+ protected void addKnuthElementsForBorderPaddingStart(List returnList) {
+ //Border and Padding (start)
+ if (commonBorderPaddingBackground != null) {
+ int ipStart = commonBorderPaddingBackground.getBorderStartWidth(false)
+ + commonBorderPaddingBackground.getPaddingStart(false, this);
+ if (ipStart > 0) {
+ // Add a non breakable glue
+ returnList.add(new KnuthPenalty(0, KnuthPenalty.INFINITE,
+ false, new LeafPosition(this, -1), true));
+ returnList.add(new KnuthGlue(ipStart, 0, 0, new LeafPosition(this, -1), true));
+ }
+ }
+ }
+
+ /**
+ * Creates Knuth elements for end border padding and adds them to the return list.
+ * @param returnList return list to add the additional elements to
+ */
+ protected void addKnuthElementsForBorderPaddingEnd(List returnList) {
+ //Border and Padding (after)
+ if (commonBorderPaddingBackground != null) {
+ int ipEnd = commonBorderPaddingBackground.getBorderEndWidth(false)
+ + commonBorderPaddingBackground.getPaddingEnd(false, this);
+ if (ipEnd > 0) {
+ // Add a non breakable glue
+ returnList.add(new KnuthPenalty(0, KnuthPenalty.INFINITE,
+ false, new LeafPosition(this, -1), true));
+ returnList.add(new KnuthGlue(ipEnd, 0, 0, new LeafPosition(this, -1), true));
+ }
+ }
+ }
+
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java?rev=307055&r1=307054&r2=307055&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java Fri Oct 7 01:55:22 2005
@@ -49,6 +49,10 @@
import java.util.List;
import java.util.ArrayList;
import java.util.LinkedList;
+import org.apache.fop.area.Trait;
+import org.apache.fop.fonts.Font;
+import org.apache.fop.layoutmgr.BreakingAlgorithm.KnuthNode;
+import org.apache.fop.layoutmgr.inline.InlineStackingLayoutManager.StackingIter;
import org.apache.fop.traits.MinOptMax;
@@ -102,14 +106,14 @@
private int startIndent;
private int lineHeight;
private int lineWidth;
+ private int spaceBefore;
+ private int spaceAfter;
private int baseline;
- private int topShift;
- private int bottomShift;
LineBreakPosition(LayoutManager lm, int index, int iBreakIndex,
int shrink, int stretch, int diff,
double ipdA, double adjust, int ind,
- int lh, int lw, int bl, int ts, int bs) {
+ int lh, int lw, int sb, int sa, int bl) {
super(lm, iBreakIndex);
availableShrink = shrink;
availableStretch = stretch;
@@ -120,9 +124,9 @@
startIndent = ind;
lineHeight = lh;
lineWidth = lw;
+ spaceBefore = sb;
+ spaceAfter = sa;
baseline = bl;
- topShift = ts;
- bottomShift = bs;
}
}
@@ -141,8 +145,7 @@
private Length lineHeight;
private int lead;
private int follow;
- // offset of the middle baseline with respect to the main baseline
- private int middleShift;
+ private AlignmentContext alignmentContext = null;
private List knuthParagraphs = null;
private int iReturnedLBP = 0;
@@ -157,16 +160,20 @@
private List lineLayoutsList;
private int iLineWidth = 0;
- // this constant is used to create elements when text-align is center:
- // every TextLM descendant of LineLM must use the same value,
- // otherwise the line breaking algorithm does not find the right
- // break point
+ /**
+ * this constant is used to create elements when text-align is center:
+ * every TextLM descendant of LineLM must use the same value,
+ * otherwise the line breaking algorithm does not find the right
+ * break point
+ */
public static final int DEFAULT_SPACE_WIDTH = 3336;
- // this class is used to remember
- // which was the first element in the paragraph
- // returned by each LM
+ /**
+ * This class is used to remember
+ * which was the first element in the paragraph
+ * returned by each LM.
+ */
private class Update {
private InlineLevelLayoutManager inlineLM;
private int iFirstIndex;
@@ -217,16 +224,16 @@
if (textAlignment == EN_CENTER && textAlignmentLast != EN_JUSTIFY) {
this.add(new KnuthGlue(0, 3 * DEFAULT_SPACE_WIDTH, 0,
null, false));
- ignoreAtStart ++;
+ ignoreAtStart++;
}
// add the element representing text indentation
// at the beginning of the first paragraph
if (knuthParagraphs.size() == 0
&& fobj.getTextIndent().getValue(layoutManager) != 0) {
- this.add(new KnuthInlineBox(fobj.getTextIndent().getValue(layoutManager), 0, 0, 0,
+ this.add(new KnuthInlineBox(fobj.getTextIndent().getValue(layoutManager), null,
null, false));
- ignoreAtStart ++;
+ ignoreAtStart++;
}
}
@@ -364,14 +371,13 @@
private int lineHeight;
private int lead;
private int follow;
- private int middleshift;
private int maxDiff;
private static final double MAX_DEMERITS = 10e6;
public LineBreakingAlgorithm (int pageAlign,
int textAlign, int textAlignLast,
int indent, int fillerWidth,
- int lh, int ld, int fl, int ms, boolean first,
+ int lh, int ld, int fl, boolean first,
LineLayoutManager llm) {
super(textAlign, textAlignLast, first, false);
pageAlignment = pageAlign;
@@ -380,7 +386,6 @@
lineHeight = lh;
lead = ld;
follow = fl;
- middleshift = ms;
thisLLM = llm;
activePossibility = -1;
maxDiff = fobj.getWidows() >= fobj.getOrphans()
@@ -402,13 +407,11 @@
int difference = bestActiveNode.difference;
int textAlign = (bestActiveNode.line < total) ? alignment : alignmentLast;
indent += (textAlign == Constants.EN_CENTER) ?
- difference / 2 :
- (textAlign == Constants.EN_END) ? difference : 0;
- indent += (bestActiveNode.line == 1 && bFirst) ?
- textIndent : 0;
+ difference / 2 : (textAlign == Constants.EN_END) ? difference : 0;
+ indent += (bestActiveNode.line == 1 && bFirst) ? textIndent : 0;
double ratio = (textAlign == Constants.EN_JUSTIFY
- || difference < 0 && -difference <= bestActiveNode.availableShrink) ?
- bestActiveNode.adjustRatio : 0;
+ || difference < 0 && -difference <= bestActiveNode.availableShrink)
+ ? bestActiveNode.adjustRatio : 0;
// add nodes at the beginning of the list, as they are found
// backwards, from the last one to the first one
@@ -420,7 +423,7 @@
}
if (addedPositions == lineLayouts.getLineCount(activePossibility)) {
- activePossibility ++;
+ activePossibility++;
addedPositions = 0;
//System.out.println(" ");
}
@@ -431,7 +434,7 @@
bestActiveNode.position,
bestActiveNode.availableShrink - (addedPositions > 0 ? 0 : ((Paragraph)par).lineFiller.opt - ((Paragraph)par).lineFiller.min), bestActiveNode.availableStretch, difference, ratio, indent),
activePossibility);
- addedPositions ++;
+ addedPositions++;
}
/* reset activePossibility, as if breakpoints have not yet been computed
@@ -447,14 +450,11 @@
double ratio,
int indent) {
// line height calculation
-
int halfLeading = (lineHeight - lead - follow) / 2;
// height before the main baseline
int lineLead = lead;
- // maximum size of top and bottom alignment
- int maxtb = follow;
- // max size of middle alignment before and after the middle baseline
- int middlefollow = maxtb;
+ // maximum follow
+ int lineFollow = follow;
// true if this line contains only zero-height, auxiliary boxes
// and the actual line width is 0; in this case, the line "collapses"
// i.e. the line area will have bpd = 0
@@ -465,57 +465,60 @@
if (fobj.getLineStackingStrategy() != EN_FONT_HEIGHT) {
ListIterator inlineIterator
= par.listIterator(firstElementIndex);
+ AlignmentContext lastAC = null;
+ int maxIgnoredHeight = 0; // See spec 7.13
for (int j = firstElementIndex;
j <= lastElementIndex;
j++) {
KnuthElement element = (KnuthElement) inlineIterator.next();
- if (element.isBox()) {
- if (((KnuthInlineBox) element).getLead() > lineLead) {
- lineLead = ((KnuthInlineBox) element).getLead();
- }
- if (((KnuthInlineBox) element).getTotal() > maxtb) {
- maxtb = ((KnuthInlineBox) element).getTotal();
- }
- if (((KnuthInlineBox) element).getMiddle() > lineLead + middleShift) {
- lineLead += ((KnuthInlineBox) element).getMiddle()
- - lineLead - middleShift;
- }
- if (((KnuthInlineBox) element).getMiddle() > middlefollow - middleShift) {
- middlefollow += ((KnuthInlineBox) element).getMiddle()
- - middlefollow + middleShift;
+ if (element instanceof KnuthInlineBox ) {
+ AlignmentContext ac = ((KnuthInlineBox) element).getAlignmentContext();
+ if (ac != null && lastAC != ac) {
+ if (!ac.usesInitialBaselineTable()
+ || ac.getAlignmentBaselineIdentifier() != EN_BEFORE_EDGE
+ && ac.getAlignmentBaselineIdentifier() != EN_AFTER_EDGE) {
+ int alignmentOffset = ac.getTotalAlignmentBaselineOffset();
+ if (alignmentOffset + ac.getAltitude() > lineLead) {
+ lineLead = alignmentOffset + ac.getAltitude();
+ }
+ if (ac.getDepth() - alignmentOffset > lineFollow) {
+ lineFollow = ac.getDepth() - alignmentOffset;
+ }
+ } else {
+ if (ac.getHeight() > maxIgnoredHeight) {
+ maxIgnoredHeight = ac.getHeight();
+ }
+ }
+ lastAC = ac;
}
if (bZeroHeightLine
- && (!element.isAuxiliary()
- || ((KnuthInlineBox) element).getTotal() > 0
- || ((KnuthInlineBox) element).getLead() > 0
- || ((KnuthInlineBox) element).getMiddle() > 0)) {
+ && (!element.isAuxiliary() || ac != null && ac.getHeight() > 0)) {
bZeroHeightLine = false;
}
}
}
- if (maxtb - lineLead > middlefollow) {
- middlefollow = maxtb - lineLead;
+ if (lineFollow < maxIgnoredHeight - lineLead) {
+ lineFollow = maxIgnoredHeight - lineLead;
}
}
- constantLineHeight = lineLead + middlefollow + (lineHeight - lead - follow);
+ constantLineHeight = lineLead + lineFollow;
if (bZeroHeightLine) {
return new LineBreakPosition(thisLLM,
knuthParagraphs.indexOf(par),
lastElementIndex,
availableShrink, availableStretch, difference, ratio, 0, indent,
- 0, iLineWidth,
- 0, 0, 0);
+ 0, iLineWidth, 0, 0, 0);
} else {
return new LineBreakPosition(thisLLM,
knuthParagraphs.indexOf(par),
lastElementIndex,
availableShrink, availableStretch, difference, ratio, 0, indent,
- lineLead + middlefollow + (lineHeight - lead - follow), iLineWidth,
- lineLead + halfLeading,
- - lineLead, middlefollow);
+ lineLead + lineFollow,
+ iLineWidth, halfLeading, halfLeading,
+ lineLead);
}
}
@@ -577,12 +580,12 @@
* Create a new Line Layout Manager.
* This is used by the block layout manager to create
* line managers for handling inline areas flowing into line areas.
- *
+ * @param block the block formatting object
* @param lh the default line height
* @param l the default lead, from top to baseline
* @param f the default follow, from baseline to bottom
*/
- public LineLayoutManager(Block block, Length lh, int l, int f, int ms) {
+ public LineLayoutManager(Block block, Length lh, int l, int f) {
super(block);
fobj = block;
// the child FObj are owned by the parent BlockLM
@@ -591,14 +594,16 @@
lineHeight = lh;
lead = l;
follow = f;
- middleShift = ms;
}
/** @see org.apache.fop.layoutmgr.LayoutManager */
public LinkedList getNextKnuthElements(LayoutContext context, int alignment) {
+ Font fs = fobj.getCommonFont().getFontState(fobj.getFOEventHandler().getFontInfo(), this);
+ alignmentContext = new AlignmentContext(fs, lineHeight.getValue(this), context.getWritingMode());
+ context.setAlignmentContext(alignmentContext);
// Get a break from currently active child LM
// Set up constraints for inline level managers
- InlineLevelLayoutManager curLM ; // currently active LM
+ InlineLevelLayoutManager curLM; // currently active LM
// IPD remaining in line
MinOptMax availIPD = context.getStackLimit();
@@ -775,8 +780,7 @@
if (lastPar.size() == 0) {
//only a forced linefeed on this line
//-> compensate with a zero width box
- lastPar.add(new KnuthInlineBox(0, 0, 0, 0,
- null, false));
+ lastPar.add(new KnuthInlineBox(0, null, null, false));
}
lastPar.endParagraph();
ElementListObserver.observe(lastPar, "line", null);
@@ -905,9 +909,7 @@
// height above the main baseline
int lineLead = lead + halfLeading;
// maximum size of top and bottom alignment
- int maxtb = follow + halfLeading;
- // max size of middle alignment above and below the middle baseline
- int middlefollow = maxtb;
+ int lineFollow = follow + halfLeading;
ListIterator inlineIterator
= par.listIterator(firstElementIndex);
@@ -920,8 +922,8 @@
if (box.getLead() > lineLead) {
lineLead = box.getLead();
}
- if (box.getTotal() > maxtb) {
- maxtb = box.getTotal();
+ if (box.getTotal() > lineFollow) {
+ lineFollow = box.getTotal();
}
if (box.getMiddle() > lineLead + middleShift) {
lineLead += box.getMiddle()
@@ -934,8 +936,8 @@
}
}
- if (maxtb - lineLead > middlefollow) {
- middlefollow = maxtb - lineLead;
+ if (lineFollow - lineLead > middlefollow) {
+ middlefollow = lineFollow - lineLead;
}
breakpoints.add(insertIndex,
@@ -985,7 +987,7 @@
//TODO Should this really create only a single LineBreakPosition???
//This creates an implicit keep-together on the nested block-level FOs.
lineLayouts = new LineLayoutPossibilities();
- lineLayouts.addPossibility(1,0);
+ lineLayouts.addPossibility(1, 0);
int lineHeight = 0, lineStretch = 0, lineShrink = 0;
ListIterator seqIterator = seq.listIterator();
while (seqIterator.hasNext()) {
@@ -1015,9 +1017,9 @@
double maxAdjustment = 1;
int iBPcount = 0;
LineBreakingAlgorithm alg = new LineBreakingAlgorithm(alignment,
- textAlignment, textAlignmentLast,
+ textAlignment, textAlignmentLast,
textIndent.getValue(this), currPar.lineFiller.opt,
- lineHeight.getValue(this), lead, follow, middleShift,
+ lineHeight.getValue(this), lead, follow,
(knuthParagraphs.indexOf(currPar) == 0),
this);
@@ -1121,7 +1123,7 @@
LinkedList returnList = new LinkedList();
- for (int p = 0; p < knuthParagraphs.size(); p ++) {
+ for (int p = 0; p < knuthParagraphs.size(); p++) {
// null penalty between paragraphs
if (p > 0
&& !((BlockLevelLayoutManager) parentLM).mustKeepTogether()) {
@@ -1138,8 +1140,8 @@
KnuthElement tempElement;
tempElement = (KnuthElement) listIter.next();
if (tempElement.getLayoutManager() != this) {
- tempElement.setPosition(new NonLeafPosition(this,
- tempElement.getPosition()));
+ tempElement.setPosition(notifyPos(new NonLeafPosition(this,
+ tempElement.getPosition())));
}
targetList.add(tempElement);
}
@@ -1181,7 +1183,8 @@
}
startIndex = endIndex + 1;
LineBreakPosition lbp = (LineBreakPosition) lineLayouts.getChosenPosition(i);
- returnList.add(new KnuthBlockBox(lbp.lineHeight, footnoteList, lbp, false));
+ returnList.add(new KnuthBlockBox(lbp.lineHeight + lbp.spaceBefore + lbp.spaceAfter
+ , footnoteList, lbp, false));
/* // add stretch and shrink to the returnlist
if (!seq.isInlineSequence()
&& lbp.availableStretch != 0 || lbp.availableShrink != 0) {
@@ -1322,14 +1325,23 @@
}
}
+ /**
+ * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#mustKeepTogether
+ */
public boolean mustKeepTogether() {
return false;
}
+ /**
+ * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#mustKeepWithPrevious
+ */
public boolean mustKeepWithPrevious() {
return false;
}
+ /**
+ * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#mustKeepWithNext
+ */
public boolean mustKeepWithNext() {
return false;
}
@@ -1351,19 +1363,21 @@
return lineNumberDifference * constantLineHeight;
}
+ /**
+ * @see org.apache.fop.layoutmgr.BlockLevelLayoutManager#discardSpace(KnuthGlue)
+ */
public void discardSpace(KnuthGlue spaceGlue) {
}
+ /**
+ * @see org.apache.fop.layoutmgr.LayoutManager#getChangedKnuthElements(List, int)
+ */
public LinkedList getChangedKnuthElements(List oldList, int alignment) {
LinkedList returnList = new LinkedList();
- for (int p = 0;
- p < knuthParagraphs.size();
- p ++) {
+ for (int p = 0; p < knuthParagraphs.size(); p++) {
lineLayouts = (LineLayoutPossibilities)lineLayoutsList.get(p);
//System.out.println("demerits of the chosen layout: " + lineLayouts.getChosenDemerits());
- for (int i = 0;
- i < lineLayouts.getChosenLineCount();
- i ++) {
+ for (int i = 0; i < lineLayouts.getChosenLineCount(); i++) {
if (!((BlockLevelLayoutManager) parentLM).mustKeepTogether()
&& i >= fobj.getOrphans()
&& i <= lineLayouts.getChosenLineCount() - fobj.getWidows()) {
@@ -1401,7 +1415,7 @@
* find hyphenation points for every word int the current paragraph
* @ param currPar the paragraph whose words will be hyphenated
*/
- private void findHyphenationPoints(Paragraph currPar){
+ private void findHyphenationPoints(Paragraph currPar) {
// hyphenate every word
ListIterator currParIterator
= currPar.listIterator(currPar.ignoreAtStart);
@@ -1447,7 +1461,7 @@
updateList.add(new Update(currLM, currParIterator.previousIndex()));
}
// append text to recreate the whole word
- boxCount ++;
+ boxCount++;
currLM.getWordChars(sbChars, nextElement.getPosition());
} else if (!nextElement.isAuxiliary()) {
// a non-auxiliary non-box KnuthElement: stop
@@ -1455,8 +1469,12 @@
currParIterator.previous();
break;
} else {
+ if (currLM != nextElement.getLayoutManager()) {
+ currLM = (InlineLevelLayoutManager) nextElement.getLayoutManager();
+ updateList.add(new Update(currLM, currParIterator.previousIndex()));
+ }
// an auxiliary KnuthElement: simply ignore it
- auxCount ++;
+ auxCount++;
}
}
log.trace(" Word to hyphenate: " + sbChars.toString());
@@ -1528,13 +1546,21 @@
updateList.clear();
}
- /** Line area is always considered to act as a fence. */
- protected boolean hasLeadingFence(boolean bNotFirst) {
+ /**
+ * Line area is always considered to act as a fence.
+ * @param isNotFirst ignored
+ * @return always true
+ */
+ protected boolean hasLeadingFence(boolean isNotFirst) {
return true;
}
- /** Line area is always considered to act as a fence. */
- protected boolean hasTrailingFence(boolean bNotLast) {
+ /**
+ * Line area is always considered to act as a fence.
+ * @param isNotLast ignored
+ * @return always true
+ */
+ protected boolean hasTrailingFence(boolean isNotLast) {
return true;
}
@@ -1607,6 +1633,7 @@
LayoutContext context) {
LayoutManager childLM;
LayoutContext lc = new LayoutContext(0);
+ lc.setAlignmentContext(alignmentContext);
int iCurrParIndex;
while (parentIter.hasNext()) {
Position pos = (Position) parentIter.next();
@@ -1626,11 +1653,9 @@
lineArea.setStartIndent(lbp.startIndent);
lineArea.setBPD(lbp.lineHeight);
lineArea.setIPD(lbp.lineWidth);
- lc.setBaseline(lbp.baseline);
- lc.setLineHeight(lbp.lineHeight);
- lc.setMiddleShift(middleShift);
- lc.setTopShift(lbp.topShift);
- lc.setBottomShift(lbp.bottomShift);
+ lineArea.addTrait(Trait.SPACE_BEFORE, new Integer(lbp.spaceBefore));
+ lineArea.addTrait(Trait.SPACE_AFTER, new Integer(lbp.spaceAfter));
+ alignmentContext.resizeLine(lbp.lineHeight, lbp.baseline);
if (seq instanceof Paragraph) {
Paragraph currPar = (Paragraph) seq;
@@ -1650,7 +1675,7 @@
seqIterator = seq.listIterator(iEndElement);
tempElement = (KnuthElement) seqIterator.next();
if (tempElement.isGlue()) {
- iEndElement --;
+ iEndElement--;
// this returns the same KnuthElement
seqIterator.previous();
tempElement = (KnuthElement) seqIterator.previous();
@@ -1663,7 +1688,7 @@
tempElement = (KnuthElement) seqIterator.next();
while (!tempElement.isBox() && seqIterator.hasNext()) {
tempElement = (KnuthElement) seqIterator.next();
- iStartElement ++;
+ iStartElement++;
}
// Add the inline areas to lineArea
@@ -1700,11 +1725,13 @@
//System.out.println(" old ratio = " + lbp.ipdAdjust + " new ratio = " + updatedRatio);
} else if (false && textAlignment == EN_CENTER) {
// re-compute indent
- int updatedIndent = lbp.startIndent + (context.getStackLimit().opt - lbp.lineWidth) / 2;
+ int updatedIndent = lbp.startIndent
+ + (context.getStackLimit().opt - lbp.lineWidth) / 2;
lineArea.setStartIndent(updatedIndent);
} else if (false && textAlignment == EN_END) {
// re-compute indent
- int updatedIndent = lbp.startIndent + (context.getStackLimit().opt - lbp.lineWidth);
+ int updatedIndent = lbp.startIndent
+ + (context.getStackLimit().opt - lbp.lineWidth);
lineArea.setStartIndent(updatedIndent);
}
@@ -1780,6 +1807,9 @@
setCurrentArea(null); // ?? necessary
}
+ /**
+ * @see org.apache.fop.layoutmgr.LayoutManager#addChildArea(Area)
+ */
public void addChildArea(Area childArea) {
// Make sure childArea is inline area
if (childArea instanceof InlineArea) {
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java?rev=307055&r1=307054&r2=307055&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/PageNumberCitationLayoutManager.java Fri Oct 7 01:55:22 2005
@@ -25,6 +25,7 @@
import org.apache.fop.area.inline.InlineArea;
import org.apache.fop.area.inline.UnresolvedPageNumber;
import org.apache.fop.area.inline.TextArea;
+import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
import org.apache.fop.fonts.Font;
import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.LayoutManager;
@@ -53,15 +54,37 @@
fobj = node;
}
+ /** @see org.apache.fop.layoutmgr.LayoutManager#initialize */
public void initialize() {
font = fobj.getCommonFont().getFontState(fobj.getFOEventHandler().getFontInfo(), this);
+ setCommonBorderPaddingBackground(fobj.getCommonBorderPaddingBackground());
}
+ /**
+ * @see LeafNodeLayoutManager.makeAlignmentContext(LayoutContext)
+ */
+ protected AlignmentContext makeAlignmentContext(LayoutContext context) {
+ return new AlignmentContext(
+ font
+ , fobj.getLineHeight().getOptimum(this).getLength().getValue(this)
+ , fobj.getAlignmentAdjust()
+ , fobj.getAlignmentBaseline()
+ , fobj.getBaselineShift()
+ , fobj.getDominantBaseline()
+ , context.getAlignmentContext()
+ );
+ }
+
+ /** @see org.apache.fop.layoutmgr.inline.LeafNodeLayoutManager#get(LayoutContext) */
public InlineArea get(LayoutContext context) {
curArea = getPageNumberCitationInlineArea(parentLM);
return curArea;
}
+ /**
+ * @see org.apache.fop.layoutmgr.inline.LeafNodeLayoutManager#addAreas(PositionIterator
+ * , LayoutContext)
+ */
public void addAreas(PositionIterator posIter, LayoutContext context) {
super.addAreas(posIter, context);
if (!resolved) {
@@ -74,17 +97,13 @@
return font.getAscender();
}
- protected void offsetArea(InlineArea area, LayoutContext context) {
- area.setOffset(context.getBaseline());
- }
-
/**
* if id can be resolved then simply return a word, otherwise
* return a resolvable area
*/
private InlineArea getPageNumberCitationInlineArea(LayoutManager parentLM) {
PageViewport page = getPSLM().getFirstPVWithID(fobj.getRefId());
- InlineArea inline = null;
+ TextArea inline = null;
if (page != null) {
String str = page.getPageNumberString();
// get page string from parent, build area
@@ -105,7 +124,7 @@
}
TraitSetter.setProducerID(inline, fobj.getId());
inline.setBPD(font.getAscender() - font.getDescender());
- inline.setOffset(font.getAscender());
+ inline.setBaselineOffset(font.getAscender());
inline.addTrait(Trait.FONT_NAME, font.getFontName());
inline.addTrait(Trait.FONT_SIZE, new Integer(font.getFontSize()));
inline.addTrait(Trait.COLOR, fobj.getColor());
@@ -125,7 +144,8 @@
}
return width;
}
-
+
+ /** @see org.apache.fop.layoutmgr.inline.LeafLayoutManager#addId */
protected void addId() {
getPSLM().addIDToPage(fobj.getId());
}
Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java?rev=307055&r1=307054&r2=307055&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/PageNumberLayoutManager.java Fri Oct 7 01:55:22 2005
@@ -22,6 +22,7 @@
import org.apache.fop.area.inline.InlineArea;
import org.apache.fop.area.inline.TextArea;
import org.apache.fop.area.Trait;
+import org.apache.fop.fo.properties.CommonBorderPaddingBackground;
import org.apache.fop.fonts.Font;
import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.TraitSetter;
@@ -46,10 +47,29 @@
fobj = node;
}
+ /** @see org.apache.fop.layoutmgr.inline.LeafNodeLayoutManager#get(LayoutContext) */
public void initialize() {
font = fobj.getCommonFont().getFontState(fobj.getFOEventHandler().getFontInfo(), this);
+ setCommonBorderPaddingBackground(fobj.getCommonBorderPaddingBackground());
}
+ /**
+ * @see org.apache.fop.layoutmgr.inline.LeafNodeLayoutManager
+ * #makeAlignmentContext(LayoutContext)
+ */
+ protected AlignmentContext makeAlignmentContext(LayoutContext context) {
+ return new AlignmentContext(
+ font
+ , fobj.getLineHeight().getOptimum(this).getLength().getValue(this)
+ , fobj.getAlignmentAdjust()
+ , fobj.getAlignmentBaseline()
+ , fobj.getBaselineShift()
+ , fobj.getDominantBaseline()
+ , context.getAlignmentContext()
+ );
+ }
+
+ /** @see org.apache.fop.layoutmgr.inline.LeafNodeLayoutManager#get(LayoutContext) */
public InlineArea get(LayoutContext context) {
// get page string from parent, build area
TextArea text = new TextArea();
@@ -58,7 +78,7 @@
text.setTextArea(str);
text.setIPD(width);
text.setBPD(font.getAscender() - font.getDescender());
- text.setOffset(font.getAscender());
+ text.setBaselineOffset(font.getAscender());
text.addTrait(Trait.FONT_NAME, font.getFontName());
text.addTrait(Trait.FONT_SIZE,
new Integer(font.getFontSize()));
@@ -69,16 +89,12 @@
return text;
}
-
/** @see org.apache.fop.layoutmgr.inline.LeafNodeLayoutManager#getLead() */
public int getLead() {
return font.getAscender();
}
- protected void offsetArea(InlineArea area, LayoutContext context) {
- area.setOffset(context.getBaseline());
- }
-
+ /** @see org.apache.fop.layoutmgr.inline.LeafNodeLayoutManager#getEffectiveArea() */
protected InlineArea getEffectiveArea() {
TextArea baseArea = (TextArea)curArea;
//TODO Maybe replace that with a clone() call or better, a copy constructor
@@ -89,6 +105,7 @@
ta.setIPD(baseArea.getIPD());
ta.setBPD(baseArea.getBPD());
ta.setOffset(baseArea.getOffset());
+ ta.setBaselineOffset(baseArea.getBaselineOffset());
ta.addTrait(Trait.FONT_NAME, font.getFontName()); //only to initialize the trait map
ta.getTraits().putAll(baseArea.getTraits());
updateContent(ta);
@@ -116,6 +133,7 @@
return width;
}
+ /** @see org.apache.fop.layoutmgr.inline.LeafLayoutManager#addId */
protected void addId() {
getPSLM().addIDToPage(fobj.getId());
}
Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTable.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTable.java?rev=307055&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTable.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTable.java Fri Oct 7 01:55:22 2005
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.layoutmgr.inline;
+
+import org.apache.fop.datatypes.Length;
+
+/**
+ * The FOP specific incarnation of the XSL-FO scaled baseline table.
+ * All baseline tables are scaled to the font size of the font they
+ * apply to. This interface uses a coordinate system with its origin
+ * where the dominant baseline intersects the start edge of the box.
+ * All measurements are in mpt.
+ */
+public interface ScaledBaselineTable {
+
+ /**
+ * Return the dominant baseline identifer for this alignment context.
+ * @return the dominant baseline identifier
+ */
+ int getDominantBaselineIdentifier();
+
+ /**
+ * Return the writing mode for this aligment context.
+ * @return the writing mode
+ */
+ int getWritingMode();
+
+ /**
+ * Return the offset measured from the dominant
+ * baseline for the given baseline identifier.
+ * @param baselineIdentifier the baseline identifier
+ * @return the baseline offset
+ */
+ int getBaseline(int baselineIdentifier);
+
+ /**
+ * Sets the position of the before and after baselines.
+ * This is usually only done for line areas. For other
+ * areas the position of the before and after baselines
+ * are fixed when the table is constructed.
+ * @param beforeBaseline the offset of the before-edge baseline from the dominant baseline
+ * @param afterBaseline the offset of the after-edge baseline from the dominant baseline
+ */
+ void setBeforeAndAfterBaselines(int beforeBaseline, int afterBaseline);
+
+ /**
+ * Return a new baseline table for the given baseline based
+ * on the current baseline table.
+ * @param baselineIdentifier the baseline identifer
+ * @return a new baseline with the new baseline
+ */
+ ScaledBaselineTable deriveScaledBaselineTable(int baselineIdentifier);
+
+}
Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTable.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTable.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTableFactory.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTableFactory.java?rev=307055&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTableFactory.java (added)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTableFactory.java Fri Oct 7 01:55:22 2005
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* $Id$ */
+
+package org.apache.fop.layoutmgr.inline;
+
+import org.apache.fop.fo.Constants;
+import org.apache.fop.fonts.Font;
+
+
+/**
+ * A factory class for making alignment contexts.
+ * Currently supports alignment contexts for basic fonts
+ * and graphic inlines.
+ */
+public class ScaledBaselineTableFactory implements Constants {
+
+ /**
+ * Creates a new instance of BasicScaledBaselineTable for the given
+ * font, baseline and writingmode.
+ * @param font the font for which a baseline table is requested
+ * @param dominantBaselineIdentifier the dominant baseline given as an integer constant
+ * @param writingMode the writing mode given as an integer constant
+ * @return a scaled baseline table for the given font
+ */
+ public static ScaledBaselineTable makeFontScaledBaselineTable(Font font
+ , int dominantBaselineIdentifier
+ , int writingMode) {
+ return new BasicScaledBaselineTable(font.getAscender(), font.getDescender()
+ , font.getXHeight(), dominantBaselineIdentifier, writingMode);
+ }
+
+ /**
+ * Creates a new instance of BasicScaledBaselineTable for the given
+ * font and writingmode. It assumes an alphabetic baseline.
+ * @param font the font for which a baseline table is requested
+ * @param writingMode the writing mode given as an integer constant
+ * @return a scaled baseline table for the given font
+ */
+ public static ScaledBaselineTable makeFontScaledBaselineTable(Font font, int writingMode) {
+ return makeFontScaledBaselineTable(font, EN_ALPHABETIC, writingMode);
+ }
+
+ /**
+ * Creates a new instance of BasicScaledBaselineTable for the given
+ * height, baseline and writingmode. This is used for non font based areas like
+ * external graphic or inline foreign object.
+ * @param height the height for which a baseline table is requested
+ * @param dominantBaselineIdentifier the dominant baseline given as an integer constant
+ * @param writingMode the writing mode given as an integer constant
+ * @return a scaled baseline table for the given dimensions
+ */
+ public static ScaledBaselineTable makeGraphicsScaledBaselineTable(int height
+ , int dominantBaselineIdentifier
+ , int writingMode) {
+ return new BasicScaledBaselineTable(height, 0, height
+ , dominantBaselineIdentifier, writingMode);
+ }
+
+}
Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTableFactory.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: xmlgraphics/fop/trunk/src/java/org/apache/fop/layoutmgr/inline/ScaledBaselineTableFactory.java
------------------------------------------------------------------------------
svn:keywords = Id
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org