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 je...@apache.org on 2005/05/23 09:43:05 UTC

cvs commit: xml-fop/src/java/org/apache/fop/layoutmgr/table TableLayoutManager.java TableStepper.java TableContentLayoutManager.java

jeremias    2005/05/23 00:43:05

  Modified:    src/java/org/apache/fop/layoutmgr/table
                        TableLayoutManager.java TableStepper.java
                        TableContentLayoutManager.java
  Log:
  Fixes for a few minor problems in certain special cases.
  
  Revision  Changes    Path
  1.23      +46 -50    xml-fop/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java
  
  Index: TableLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java,v
  retrieving revision 1.22
  retrieving revision 1.23
  diff -u -r1.22 -r1.23
  --- TableLayoutManager.java	13 May 2005 19:16:53 -0000	1.22
  +++ TableLayoutManager.java	23 May 2005 07:43:05 -0000	1.23
  @@ -184,56 +184,52 @@
           returnedList = contentLM.getNextKnuthElements(childLC, alignment);
           log.debug(returnedList);
           
  -            if (returnedList.size() == 1
  -                    && ((KnuthElement) returnedList.getFirst()).isPenalty()
  -                    && ((KnuthPenalty) returnedList.getFirst()).getP() == -KnuthElement.INFINITE) {
  -                // a descendant of this block has break-before
  -                if (returnList.size() == 0) {
  -                    // the first child (or its first child ...) has
  -                    // break-before;
  -                    // all this block, including space before, will be put in
  -                    // the
  -                    // following page
  -                    //FIX ME
  -                    //bSpaceBeforeServed = false;
  +        if (returnedList.size() == 1
  +                && ((KnuthElement) returnedList.getFirst()).isPenalty()
  +                && ((KnuthPenalty) returnedList.getFirst()).getP() == -KnuthElement.INFINITE) {
  +            // a descendant of this block has break-before
  +            if (returnList.size() == 0) {
  +                // the first child (or its first child ...) has
  +                // break-before;
  +                // all this block, including space before, will be put in
  +                // the
  +                // following page
  +                //FIX ME
  +                //bSpaceBeforeServed = false;
  +            }
  +            contentList.addAll(returnedList);
  +
  +            // "wrap" the Position inside each element
  +            // moving the elements from contentList to returnList
  +            returnedList = new LinkedList();
  +            wrapPositionElements(contentList, returnList);
  +
  +            return returnList;
  +        } else {
  +            /*
  +            if (prevLM != null) {
  +                // there is a block handled by prevLM
  +                // before the one handled by curLM
  +                if (mustKeepTogether() 
  +                        || prevLM.mustKeepWithNext()
  +                        || curLM.mustKeepWithPrevious()) {
  +                    // add an infinite penalty to forbid a break between
  +                    // blocks
  +                    contentList.add(new KnuthPenalty(0,
  +                            KnuthElement.INFINITE, false,
  +                            new Position(this), false));
  +                } else if (!((KnuthElement) contentList.getLast()).isGlue()) {
  +                    // add a null penalty to allow a break between blocks
  +                    contentList.add(new KnuthPenalty(0, 0, false,
  +                            new Position(this), false));
  +                } else {
  +                    // the last element in contentList is a glue;
  +                    // it is a feasible breakpoint, there is no need to add
  +                    // a penalty
                   }
  -                contentList.addAll(returnedList);
  -
  -                // "wrap" the Position inside each element
  -                // moving the elements from contentList to returnList
  -                returnedList = new LinkedList();
  -                wrapPositionElements(contentList, returnList);
  -
  -                return returnList;
  -            } else {
  -                /*
  -                if (prevLM != null) {
  -                    // there is a block handled by prevLM
  -                    // before the one handled by curLM
  -                    if (mustKeepTogether() 
  -                            || prevLM.mustKeepWithNext()
  -                            || curLM.mustKeepWithPrevious()) {
  -                        // add an infinite penalty to forbid a break between
  -                        // blocks
  -                        contentList.add(new KnuthPenalty(0,
  -                                KnuthElement.INFINITE, false,
  -                                new Position(this), false));
  -                    } else if (!((KnuthElement) contentList.getLast()).isGlue()) {
  -                        // add a null penalty to allow a break between blocks
  -                        contentList.add(new KnuthPenalty(0, 0, false,
  -                                new Position(this), false));
  -                    } else {
  -                        // the last element in contentList is a glue;
  -                        // it is a feasible breakpoint, there is no need to add
  -                        // a penalty
  -                    }
  -                }*/
  -                contentList.addAll(returnedList);
  -                /*
  -                if (returnedList.size() == 0) {
  -                    //Avoid NoSuchElementException below (happens with empty blocks)
  -                    continue;
  -                }*/
  +            }*/
  +            contentList.addAll(returnedList);
  +            if (returnedList.size() > 0) {
                   if (((KnuthElement) returnedList.getLast()).isPenalty()
                           && ((KnuthPenalty) returnedList.getLast()).getP() == -KnuthElement.INFINITE) {
                       // a descendant of this block has break-after
  @@ -248,7 +244,7 @@
   
                       return returnList;
                   }
  -            
  +            }
           }
           wrapPositionElements(contentList, returnList);
           setFinished(true);
  
  
  
  1.3       +3 -3      xml-fop/src/java/org/apache/fop/layoutmgr/table/TableStepper.java
  
  Index: TableStepper.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/table/TableStepper.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- TableStepper.java	13 May 2005 19:16:53 -0000	1.2
  +++ TableStepper.java	23 May 2005 07:43:05 -0000	1.3
  @@ -185,7 +185,7 @@
           int step;
           int addedBoxLen = 0;
           LinkedList returnList = new LinkedList();
  -        while ((step = getNextStep(laststep)) > 0) {
  +        while ((step = getNextStep(laststep)) >= 0) {
               if (rowBacktrackForLastStep) {
                   //Even though we've already switched to the next row, we have to 
                   //calculate as if we were still on the previous row
  @@ -340,7 +340,7 @@
               log.debug("borders before=" + borderBefore[i] + " after=" + borderAfter[i]);
           }
           if (seqCount == 0) {
  -            return 0;
  +            return -1;
           }
   
           //Determine smallest possible step
  
  
  
  1.6       +7 -5      xml-fop/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java
  
  Index: TableContentLayoutManager.java
  ===================================================================
  RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TableContentLayoutManager.java	18 May 2005 16:47:57 -0000	1.5
  +++ TableContentLayoutManager.java	23 May 2005 07:43:05 -0000	1.6
  @@ -196,10 +196,12 @@
                           returnList, rowGroup);
           }
           
  -        //Remove last penalty
  -        KnuthElement last = (KnuthElement)returnList.getLast();
  -        if (last.isPenalty() && last.getP() == 0) {
  -            returnList.removeLast();
  +        if (returnList.size() > 0) {
  +            //Remove last penalty
  +            KnuthElement last = (KnuthElement)returnList.getLast();
  +            if (last.isPenalty() && last.getP() == 0) {
  +                returnList.removeLast();
  +            }
           }
           return returnList;
       }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org