]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Added support for leader with pattern "use-content" and recovered a previously lost...
authorManuel Mall <manuel@apache.org>
Mon, 10 Oct 2005 10:22:05 +0000 (10:22 +0000)
committerManuel Mall <manuel@apache.org>
Mon, 10 Oct 2005 10:22:05 +0000 (10:22 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@312604 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/layoutmgr/inline/AlignmentContext.java
src/java/org/apache/fop/layoutmgr/inline/ContentLayoutManager.java
src/java/org/apache/fop/layoutmgr/inline/InlineLayoutManager.java
src/java/org/apache/fop/layoutmgr/inline/LeaderLayoutManager.java
src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
test/layoutengine/disabled-testcases.txt
test/layoutengine/testcases/block_line-height.xml
test/layoutengine/testcases/leader_leader-pattern_use-content.xml

index 82cf7fbbf1eacb4da8089b3a776c2b0807e6cfd5..ae294c44f8d03e83e822fba37fc1d144300be4bb 100644 (file)
@@ -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) {
index d3abee08fe62cdd9f818867d152c4871ee4553a4..fe0bc34f6ece2d51bed51880277d160d4aafa945 100644 (file)
@@ -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);
+                    }
                 }
             }
         }
index 6819cf408fec4cd79fe93e579d74e4bc14487941..cd7d962c8f7445de33618d1be32289bdc3b47a80 100755 (executable)
@@ -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());
+        }
     }
     
 }
index 185ab68f23f108dd970259a3c80dbc3427c83814..c853bf76e6945b25812e6de33af302326479eb4f 100644 (file)
@@ -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);
 
index 532b6f8759561deaeb1f64b1355bfbb937401f7b..652b585c4e502add78380aa4b3c2559b4c598143 100644 (file)
@@ -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);
             }
         }
index dfb38521ec169d7efcf2c27eae8601ac9e2b6a95..c0df6b35afba17a5895ac7428783e66768a44472 100644 (file)
@@ -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
index 03bec53cc60ae1c417b9da77c1486c42c4562e9d..65a27ed618062ad727e87bccfb99d7aaf8e5f450 100644 (file)
@@ -60,9 +60,9 @@
     <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"/>
@@ -73,9 +73,9 @@
     <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"/>
@@ -86,9 +86,9 @@
     <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"/>
@@ -99,9 +99,9 @@
     <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"/>
index 0a297ee3a7496b85e7a0b0a9328eb4d01b98ee9d..11287f0586ab0edc72bca1196bc3a1e7245f9e53 100644 (file)
             <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>