aboutsummaryrefslogtreecommitdiffstats
path: root/src/java/org
diff options
context:
space:
mode:
authorManuel Mall <manuel@apache.org>2005-10-10 10:22:05 +0000
committerManuel Mall <manuel@apache.org>2005-10-10 10:22:05 +0000
commit179d10f032a58cd67f188ec63698273a18173176 (patch)
treef3d4ad1fa9c1d7a4b2e143025b07386383485f07 /src/java/org
parent19ac0323da85dc9b1c8e4be8e8cf2f7a89d45563 (diff)
downloadxmlgraphics-fop-179d10f032a58cd67f188ec63698273a18173176.tar.gz
xmlgraphics-fop-179d10f032a58cd67f188ec63698273a18173176.zip
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
Diffstat (limited to 'src/java/org')
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/AlignmentContext.java2
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java22
-rwxr-xr-xsrc/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java8
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java10
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java8
5 files changed, 35 insertions, 15 deletions
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);
}
}