From: Manuel Mall Date: Mon, 10 Oct 2005 10:22:05 +0000 (+0000) Subject: Added support for leader with pattern "use-content" and recovered a previously lost... X-Git-Tag: fop-0_90-alpha1~148 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=179d10f032a58cd67f188ec63698273a18173176;p=xmlgraphics-fop.git Added support for leader with pattern "use-content" and recovered a previously lost 1mpt due to rounding git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@312604 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/src/java/org/apache/fop/layoutmgr/inline/AlignmentContext.java b/src/java/org/apache/fop/layoutmgr/inline/AlignmentContext.java index 82cf7fbbf..ae294c44f 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/AlignmentContext.java +++ b/src/java/org/apache/fop/layoutmgr/inline/AlignmentContext.java @@ -167,7 +167,7 @@ public class AlignmentContext implements Constants { * 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) { diff --git a/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java index d3abee08f..fe0bc34f6 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java @@ -24,6 +24,7 @@ import org.apache.fop.fo.pagination.Title; 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; @@ -38,6 +39,7 @@ import java.util.LinkedList; 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; @@ -243,8 +245,7 @@ public class ContentLayoutManager extends AbstractBaseLayoutManager } } - public LinkedList getNextKnuthElements(LayoutContext context, - int alignment) { + public LinkedList getNextKnuthElements(LayoutContext context, int alignment) { LinkedList contentList = new LinkedList(); LinkedList returnedList; @@ -256,9 +257,20 @@ public class ContentLayoutManager extends AbstractBaseLayoutManager // 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); + } } } } diff --git a/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java index 6819cf408..cd7d962c8 100755 --- a/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java @@ -167,7 +167,9 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { } else { area = new InlineBlockParent(); } - TraitSetter.setProducerID(area, getInlineFO().getId()); + if (fobj instanceof Inline) { + TraitSetter.setProducerID(area, getInlineFO().getId()); + } return area; } @@ -551,7 +553,9 @@ public class InlineLayoutManager extends InlineStackingLayoutManager { /** @see org.apache.fop.layoutmgr.inline.LeafNodeLayoutManager#addId() */ protected void addId() { - getPSLM().addIDToPage(getInlineFO().getId()); + if (fobj instanceof Inline) { + getPSLM().addIDToPage(getInlineFO().getId()); + } } } diff --git a/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java index 185ab68f2..c853bf76e 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java @@ -78,7 +78,7 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager { * @return the inline area */ public InlineArea get(LayoutContext context) { - return getLeaderInlineArea(); + return getLeaderInlineArea(context); } /** @@ -106,7 +106,7 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager { return new MinOptMax(min, opt, max); } - private InlineArea getLeaderInlineArea() { + private InlineArea getLeaderInlineArea(LayoutContext context) { InlineArea leaderArea = null; if (fobj.getLeaderPattern() == EN_RULE) { @@ -168,8 +168,11 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager { 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) { @@ -200,7 +203,6 @@ public class LeaderLayoutManager extends LeafNodeLayoutManager { // add content areas KnuthPossPosIter contentIter = new KnuthPossPosIter(contentList, 0, contentList.size()); clm.addAreas(contentIter, context); - offsetArea(curArea, context); parentLM.addChildArea(curArea); diff --git a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java index 532b6f875..652b585c4 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java @@ -449,8 +449,10 @@ public class LineLayoutManager extends InlineStackingLayoutManager 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 @@ -517,7 +519,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager lastElementIndex, availableShrink, availableStretch, difference, ratio, 0, indent, lineLead + lineFollow, - iLineWidth, halfLeading, halfLeading, + iLineWidth, spaceBefore, spaceAfter, lineLead); } } diff --git a/test/layoutengine/disabled-testcases.txt b/test/layoutengine/disabled-testcases.txt index dfb38521e..c0df6b35a 100644 --- a/test/layoutengine/disabled-testcases.txt +++ b/test/layoutengine/disabled-testcases.txt @@ -16,7 +16,6 @@ inline_letter-spacing.xml 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 diff --git a/test/layoutengine/testcases/block_line-height.xml b/test/layoutengine/testcases/block_line-height.xml index 03bec53cc..65a27ed61 100644 --- a/test/layoutengine/testcases/block_line-height.xml +++ b/test/layoutengine/testcases/block_line-height.xml @@ -60,9 +60,9 @@ - + - + @@ -73,9 +73,9 @@ - + - + @@ -86,9 +86,9 @@ - + - + @@ -99,9 +99,9 @@ - + - + @@ -112,9 +112,9 @@ - + - + diff --git a/test/layoutengine/testcases/leader_leader-pattern_use-content.xml b/test/layoutengine/testcases/leader_leader-pattern_use-content.xml index 0a297ee3a..11287f058 100644 --- a/test/layoutengine/testcases/leader_leader-pattern_use-content.xml +++ b/test/layoutengine/testcases/leader_leader-pattern_use-content.xml @@ -38,10 +38,93 @@ => Content is "=>" with background + + ~ + Content is "~" with leader-pattern-width="12pt" + + + * + Content is "*" with leader-pattern-width="12pt" and border + + + ++ + Content is "++" with l-p-w="12pt" and border small font + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +