* Creates a new instance of AlignmentContext based simply
* on the font and the writing mode.
* @param font the font
- * @param lineHeight the omputed value of the lineHeight property
+ * @param lineHeight the computed value of the lineHeight property
* @param writingMode the current writing mode
*/
public AlignmentContext(Font font, int lineHeight, int writingMode) {
import org.apache.fop.layoutmgr.AbstractBaseLayoutManager;
import org.apache.fop.layoutmgr.KnuthElement;
import org.apache.fop.layoutmgr.KnuthPossPosIter;
+import org.apache.fop.layoutmgr.KnuthSequence;
import org.apache.fop.layoutmgr.LayoutContext;
import org.apache.fop.layoutmgr.LayoutManager;
import org.apache.fop.layoutmgr.PageSequenceLayoutManager;
import java.util.List;
import java.util.ListIterator;
import java.util.ArrayList;
+import java.util.Iterator;
import org.apache.fop.traits.MinOptMax;
import org.apache.fop.area.Block;
}
}
- public LinkedList getNextKnuthElements(LayoutContext context,
- int alignment) {
+ public LinkedList getNextKnuthElements(LayoutContext context, int alignment) {
LinkedList contentList = new LinkedList();
LinkedList returnedList;
// move elements to contentList, and accumulate their size
KnuthElement contentElement;
while (returnedList.size() > 0) {
- contentElement = (KnuthElement)returnedList.removeFirst();
- stackSize += contentElement.getW();
- contentList.add(contentElement);
+ Object obj = returnedList.removeFirst();
+ // Shit contentElement = (KnuthElement)returnedList.removeFirst();
+ if (obj instanceof KnuthSequence) {
+ KnuthSequence ks = (KnuthSequence)obj;
+ for (Iterator it = ks.iterator(); it.hasNext(); ) {
+ contentElement = (KnuthElement)it.next();
+ stackSize += contentElement.getW();
+ contentList.add(contentElement);
+ }
+ } else {
+ contentElement = (KnuthElement)obj;
+ stackSize += contentElement.getW();
+ contentList.add(contentElement);
+ }
}
}
}
} else {
area = new InlineBlockParent();
}
- TraitSetter.setProducerID(area, getInlineFO().getId());
+ if (fobj instanceof Inline) {
+ TraitSetter.setProducerID(area, getInlineFO().getId());
+ }
return area;
}
/** @see org.apache.fop.layoutmgr.inline.LeafNodeLayoutManager#addId() */
protected void addId() {
- getPSLM().addIDToPage(getInlineFO().getId());
+ if (fobj instanceof Inline) {
+ getPSLM().addIDToPage(getInlineFO().getId());
+ }
}
}
* @return the inline area
*/
public InlineArea get(LayoutContext context) {
- return getLeaderInlineArea();
+ return getLeaderInlineArea(context);
}
/**
return new MinOptMax(min, opt, max);
}
- private InlineArea getLeaderInlineArea() {
+ private InlineArea getLeaderInlineArea(LayoutContext context) {
InlineArea leaderArea = null;
if (fobj.getLeaderPattern() == EN_RULE) {
InlineLayoutManager lm;
lm = new InlineLayoutManager(fobj);
clm.addChildLM(lm);
+ lm.initialize();
- contentList = clm.getNextKnuthElements(new LayoutContext(0), 0);
+ LayoutContext childContext = new LayoutContext(0);
+ childContext.setAlignmentContext(context.getAlignmentContext());
+ contentList = clm.getNextKnuthElements(childContext, 0);
int width = clm.getStackingSize();
Space spacer = null;
if (fobj.getLeaderPatternWidth().getValue(this) > width) {
// add content areas
KnuthPossPosIter contentIter = new KnuthPossPosIter(contentList, 0, contentList.size());
clm.addAreas(contentIter, context);
- offsetArea(curArea, context);
parentLM.addChildArea(curArea);
int availableShrink, int availableStretch, int difference,
double ratio,
int indent) {
- // line height calculation
- int halfLeading = (lineHeight - lead - follow) / 2;
+ // line height calculation - spaceBefore may differ from spaceAfter
+ // by 1mpt due to rounding
+ int spaceBefore = (lineHeight - lead - follow) / 2;
+ int spaceAfter = lineHeight - lead - follow - spaceBefore;
// height before the main baseline
int lineLead = lead;
// maximum follow
lastElementIndex,
availableShrink, availableStretch, difference, ratio, 0, indent,
lineLead + lineFollow,
- iLineWidth, halfLeading, halfLeading,
+ iLineWidth, spaceBefore, spaceAfter,
lineLead);
}
}
inline_word-spacing.xml
inline_word-spacing_text-align_justify.xml
leader-alignment.xml
-leader_leader-pattern_use-content.xml
list-block_keep-with-previous.xml
list-item_block_keep-with-previous.xml
list-item_space-before_space-after_2.xml
<eval expected="1650" xpath="//flow/block[1]/lineArea/@space-before"/>
<eval expected="1650" xpath="//flow/block[1]/lineArea/@space-after"/>
<eval expected="13319" xpath="//flow/block[1]/block[1]/lineArea/@bpd"/>
- <eval expected="17279" xpath="//flow/block[1]/block[1]/lineArea/@bpda"/>
+ <eval expected="17280" xpath="//flow/block[1]/block[1]/lineArea/@bpda"/>
<eval expected="1980" xpath="//flow/block[1]/block[1]/lineArea/@space-before"/>
- <eval expected="1980" xpath="//flow/block[1]/block[1]/lineArea/@space-after"/>
+ <eval expected="1981" xpath="//flow/block[1]/block[1]/lineArea/@space-after"/>
<eval expected="9250" xpath="//flow/block[1]/block[2]/lineArea/@bpd"/>
<eval expected="12000" xpath="//flow/block[1]/block[2]/lineArea/@bpda"/>
<eval expected="1375" xpath="//flow/block[1]/block[2]/lineArea/@space-before"/>
<eval expected="3450" xpath="//flow/block[2]/lineArea/@space-before"/>
<eval expected="3450" xpath="//flow/block[2]/lineArea/@space-after"/>
<eval expected="13319" xpath="//flow/block[2]/block[1]/lineArea/@bpd"/>
- <eval expected="17999" xpath="//flow/block[2]/block[1]/lineArea/@bpda"/>
+ <eval expected="18000" xpath="//flow/block[2]/block[1]/lineArea/@bpda"/>
<eval expected="2340" xpath="//flow/block[2]/block[1]/lineArea/@space-before"/>
- <eval expected="2340" xpath="//flow/block[2]/block[1]/lineArea/@space-after"/>
+ <eval expected="2341" xpath="//flow/block[2]/block[1]/lineArea/@space-after"/>
<eval expected="9250" xpath="//flow/block[2]/block[2]/lineArea/@bpd"/>
<eval expected="18000" xpath="//flow/block[2]/block[2]/lineArea/@bpda"/>
<eval expected="4375" xpath="//flow/block[2]/block[2]/lineArea/@space-before"/>
<eval expected="4450" xpath="//flow/block[3]/lineArea/@space-before"/>
<eval expected="4450" xpath="//flow/block[3]/lineArea/@space-after"/>
<eval expected="13319" xpath="//flow/block[3]/block[1]/lineArea/@bpd"/>
- <eval expected="19999" xpath="//flow/block[3]/block[1]/lineArea/@bpda"/>
+ <eval expected="20000" xpath="//flow/block[3]/block[1]/lineArea/@bpda"/>
<eval expected="3340" xpath="//flow/block[3]/block[1]/lineArea/@space-before"/>
- <eval expected="3340" xpath="//flow/block[3]/block[1]/lineArea/@space-after"/>
+ <eval expected="3341" xpath="//flow/block[3]/block[1]/lineArea/@space-after"/>
<eval expected="9250" xpath="//flow/block[3]/block[2]/lineArea/@bpd"/>
<eval expected="20000" xpath="//flow/block[3]/block[2]/lineArea/@bpda"/>
<eval expected="5375" xpath="//flow/block[3]/block[2]/lineArea/@space-before"/>
<eval expected="3450" xpath="//flow/block[4]/lineArea/@space-before"/>
<eval expected="3450" xpath="//flow/block[4]/lineArea/@space-after"/>
<eval expected="13319" xpath="//flow/block[4]/block[1]/lineArea/@bpd"/>
- <eval expected="21599" xpath="//flow/block[4]/block[1]/lineArea/@bpda"/>
+ <eval expected="21600" xpath="//flow/block[4]/block[1]/lineArea/@bpda"/>
<eval expected="4140" xpath="//flow/block[4]/block[1]/lineArea/@space-before"/>
- <eval expected="4140" xpath="//flow/block[4]/block[1]/lineArea/@space-after"/>
+ <eval expected="4141" xpath="//flow/block[4]/block[1]/lineArea/@space-after"/>
<eval expected="9250" xpath="//flow/block[4]/block[2]/lineArea/@bpd"/>
<eval expected="15000" xpath="//flow/block[4]/block[2]/lineArea/@bpda"/>
<eval expected="2875" xpath="//flow/block[4]/block[2]/lineArea/@space-before"/>
<eval expected="950" xpath="//flow/block[5]/lineArea/@space-before"/>
<eval expected="950" xpath="//flow/block[5]/lineArea/@space-after"/>
<eval expected="13319" xpath="//flow/block[5]/block[1]/lineArea/@bpd"/>
- <eval expected="13001" xpath="//flow/block[5]/block[1]/lineArea/@bpda"/>
+ <eval expected="13000" xpath="//flow/block[5]/block[1]/lineArea/@bpda"/>
<eval expected="-159" xpath="//flow/block[5]/block[1]/lineArea/@space-before"/>
- <eval expected="-159" xpath="//flow/block[5]/block[1]/lineArea/@space-after"/>
+ <eval expected="-160" xpath="//flow/block[5]/block[1]/lineArea/@space-after"/>
<eval expected="9250" xpath="//flow/block[5]/block[2]/lineArea/@bpd"/>
<eval expected="13000" xpath="//flow/block[5]/block[2]/lineArea/@bpda"/>
<eval expected="1875" xpath="//flow/block[5]/block[2]/lineArea/@space-before"/>
<fo:leader leader-length="36pt" leader-pattern="use-content"><fo:inline background-color="yellow">=></fo:inline></fo:leader>
Content is "=>" with background
</fo:block>
+ <fo:block>
+ <fo:leader leader-length="36pt" leader-pattern="use-content" leader-pattern-width="12pt"><fo:inline background-color="orange">~</fo:inline></fo:leader>
+ Content is "~" with leader-pattern-width="12pt"
+ </fo:block>
+ <fo:block>
+ <fo:leader leader-length="36pt" leader-pattern="use-content" leader-pattern-width="12pt"><fo:inline border="solid 1pt red" background-color="yellow">*</fo:inline></fo:leader>
+ Content is "*" with leader-pattern-width="12pt" and border
+ </fo:block>
+ <fo:block>
+ <fo:leader leader-length="36pt" leader-pattern="use-content" leader-pattern-width="12pt"><fo:inline border="solid 1pt red" font-size="6pt" alignment-baseline="middle" background-color="yellow">++</fo:inline></fo:leader>
+ Content is "++" with l-p-w="12pt" and border small font
+ </fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</fo>
<checks>
+ <eval expected="11100" xpath="//flow/block[1]/lineArea/@bpd"/>
+ <eval expected="36000" xpath="//flow/block[1]/lineArea/inlineparent/@ipd"/>
+ <eval expected="0" xpath="//flow/block[1]/lineArea/inlineparent/@offset"/>
+ <eval expected="6000" xpath="//flow/block[1]/lineArea/inlineparent/inlineparent[1]/@ipd"/>
+ <eval expected="0" xpath="//flow/block[1]/lineArea/inlineparent/inlineparent[1]/@offset"/>
+ <eval expected="6000" xpath="//flow/block[1]/lineArea/inlineparent/inlineparent[2]/@ipd"/>
+ <eval expected="0" xpath="//flow/block[1]/lineArea/inlineparent/inlineparent[2]/@offset"/>
+ <eval expected="6000" xpath="//flow/block[1]/lineArea/inlineparent/inlineparent[3]/@ipd"/>
+ <eval expected="0" xpath="//flow/block[1]/lineArea/inlineparent/inlineparent[3]/@offset"/>
+ <eval expected="6000" xpath="//flow/block[1]/lineArea/inlineparent/inlineparent[4]/@ipd"/>
+ <eval expected="0" xpath="//flow/block[1]/lineArea/inlineparent/inlineparent[4]/@offset"/>
+ <eval expected="6000" xpath="//flow/block[1]/lineArea/inlineparent/inlineparent[5]/@ipd"/>
+ <eval expected="0" xpath="//flow/block[1]/lineArea/inlineparent/inlineparent[5]/@offset"/>
+ <eval expected="6000" xpath="//flow/block[1]/lineArea/inlineparent/inlineparent[6]/@ipd"/>
+ <eval expected="0" xpath="//flow/block[1]/lineArea/inlineparent/inlineparent[6]/@offset"/>
+
+ <eval expected="11100" xpath="//flow/block[2]/lineArea/@bpd"/>
+ <eval expected="36000" xpath="//flow/block[2]/lineArea/inlineparent/@ipd"/>
+ <eval expected="0" xpath="//flow/block[2]/lineArea/inlineparent/@offset"/>
+ <eval expected="14016" xpath="//flow/block[2]/lineArea/inlineparent/inlineparent[1]/@ipd"/>
+ <eval expected="0" xpath="//flow/block[2]/lineArea/inlineparent/inlineparent[1]/@offset"/>
+ <eval expected="14016" xpath="//flow/block[2]/lineArea/inlineparent/inlineparent[2]/@ipd"/>
+ <eval expected="0" xpath="//flow/block[2]/lineArea/inlineparent/inlineparent[2]/@offset"/>
+
+ <eval expected="11100" xpath="//flow/block[3]/lineArea/@bpd"/>
+ <eval expected="36000" xpath="//flow/block[3]/lineArea/inlineparent/@ipd"/>
+ <eval expected="0" xpath="//flow/block[3]/lineArea/inlineparent/@offset"/>
+ <eval expected="4992" xpath="//flow/block[3]/lineArea/inlineparent/space/@ipd"/>
+ <eval expected="7008" xpath="//flow/block[3]/lineArea/inlineparent/inlineparent[1]/@ipd"/>
+ <eval expected="0" xpath="//flow/block[3]/lineArea/inlineparent/inlineparent[1]/@offset"/>
+ <eval expected="4992" xpath="//flow/block[3]/lineArea/inlineparent/space/@ipd"/>
+ <eval expected="7008" xpath="//flow/block[3]/lineArea/inlineparent/inlineparent[2]/@ipd"/>
+ <eval expected="0" xpath="//flow/block[3]/lineArea/inlineparent/inlineparent[2]/@offset"/>
+ <eval expected="4992" xpath="//flow/block[3]/lineArea/inlineparent/space/@ipd"/>
+ <eval expected="7008" xpath="//flow/block[3]/lineArea/inlineparent/inlineparent[3]/@ipd"/>
+ <eval expected="0" xpath="//flow/block[3]/lineArea/inlineparent/inlineparent[3]/@offset"/>
+
+ <eval expected="11100" xpath="//flow/block[4]/lineArea/@bpd"/>
+ <eval expected="36000" xpath="//flow/block[4]/lineArea/inlineparent/@ipd"/>
+ <eval expected="0" xpath="//flow/block[4]/lineArea/inlineparent/@offset"/>
+ <eval expected="5332" xpath="//flow/block[4]/lineArea/inlineparent/space/@ipd"/>
+ <eval expected="6668" xpath="//flow/block[4]/lineArea/inlineparent/inlineparent[1]/@ipd"/>
+ <eval expected="0" xpath="//flow/block[4]/lineArea/inlineparent/inlineparent[1]/@offset"/>
+ <eval expected="1000 1000 1000 1000" xpath="//flow/block[4]/lineArea/inlineparent/inlineparent[1]/inlineparent/@bap"/>
+ <eval expected="5332" xpath="//flow/block[4]/lineArea/inlineparent/space/@ipd"/>
+ <eval expected="6668" xpath="//flow/block[4]/lineArea/inlineparent/inlineparent[2]/@ipd"/>
+ <eval expected="0" xpath="//flow/block[4]/lineArea/inlineparent/inlineparent[2]/@offset"/>
+ <eval expected="1000 1000 1000 1000" xpath="//flow/block[4]/lineArea/inlineparent/inlineparent[2]/inlineparent/@bap"/>
+ <eval expected="5332" xpath="//flow/block[4]/lineArea/inlineparent/space/@ipd"/>
+ <eval expected="6668" xpath="//flow/block[4]/lineArea/inlineparent/inlineparent[3]/@ipd"/>
+ <eval expected="0" xpath="//flow/block[4]/lineArea/inlineparent/inlineparent[3]/@offset"/>
+ <eval expected="1000 1000 1000 1000" xpath="//flow/block[4]/lineArea/inlineparent/inlineparent[3]/inlineparent/@bap"/>
+
+ <eval expected="11100" xpath="//flow/block[5]/lineArea/@bpd"/>
+ <eval expected="36000" xpath="//flow/block[5]/lineArea/inlineparent/@ipd"/>
+ <eval expected="0" xpath="//flow/block[5]/lineArea/inlineparent/@offset"/>
+ <eval expected="2992" xpath="//flow/block[5]/lineArea/inlineparent/space/@ipd"/>
+ <eval expected="9008" xpath="//flow/block[5]/lineArea/inlineparent/inlineparent[1]/@ipd"/>
+ <eval expected="0" xpath="//flow/block[5]/lineArea/inlineparent/inlineparent[1]/@offset"/>
+ <eval expected="2739" xpath="//flow/block[5]/lineArea/inlineparent/inlineparent[1]/inlineparent/@offset"/>
+ <eval expected="1000 1000 1000 1000" xpath="//flow/block[5]/lineArea/inlineparent/inlineparent[1]/inlineparent/@bap"/>
+ <eval expected="2992" xpath="//flow/block[5]/lineArea/inlineparent/space/@ipd"/>
+ <eval expected="9008" xpath="//flow/block[5]/lineArea/inlineparent/inlineparent[2]/@ipd"/>
+ <eval expected="0" xpath="//flow/block[5]/lineArea/inlineparent/inlineparent[2]/@offset"/>
+ <eval expected="2739" xpath="//flow/block[5]/lineArea/inlineparent/inlineparent[2]/inlineparent/@offset"/>
+ <eval expected="1000 1000 1000 1000" xpath="//flow/block[5]/lineArea/inlineparent/inlineparent[2]/inlineparent/@bap"/>
+ <eval expected="2992" xpath="//flow/block[5]/lineArea/inlineparent/space/@ipd"/>
+ <eval expected="9008" xpath="//flow/block[5]/lineArea/inlineparent/inlineparent[3]/@ipd"/>
+ <eval expected="0" xpath="//flow/block[5]/lineArea/inlineparent/inlineparent[3]/@offset"/>
+ <eval expected="2739" xpath="//flow/block[5]/lineArea/inlineparent/inlineparent[3]/inlineparent/@offset"/>
+ <eval expected="1000 1000 1000 1000" xpath="//flow/block[5]/lineArea/inlineparent/inlineparent[3]/inlineparent/@bap"/>
</checks>
</testcase>