]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Factorize in a method the code handling TableContentPosition elements, in TableConten...
authorVincent Hennebert <vhennebert@apache.org>
Tue, 27 Mar 2007 13:46:22 +0000 (13:46 +0000)
committerVincent Hennebert <vhennebert@apache.org>
Tue, 27 Mar 2007 13:46:22 +0000 (13:46 +0000)
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@522908 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/layoutmgr/table/TableContentLayoutManager.java

index f9d7c639784968fe20f39ed98da570c7204ecf5d..914f134af13080486f5f4bc7e029b3e2a81c828f 100644 (file)
@@ -701,15 +701,16 @@ public class TableContentLayoutManager implements PercentBaseContext {
     }
 
     /**
-     * Iterates over a part of the table and paints the related elements.
+     * Iterates over a part of the table (header, footer, body) and paints the related
+     * elements.
      * 
-     * @param iterator iterator over the table's header, body or footer elements
+     * @param iterator iterator over Position elements. Those positions correspond to the
+     * elements of the table present on the current page
      * @param painter
      */
     private void iterateAndPaintPositions(Iterator iterator, RowPainter painter) {
         List lst = new java.util.ArrayList();
         boolean firstPos = false;
-        boolean lastPos = false;
         TableBody body = null;
         while (iterator.hasNext()) {
             Position pos = (Position)iterator.next();
@@ -728,18 +729,9 @@ public class TableContentLayoutManager implements PercentBaseContext {
                 if (tcpos.getFlag(TableContentPosition.LAST_IN_ROWGROUP) 
                         && tcpos.row.getFlag(EffRow.LAST_IN_PART)) {
                     log.trace("LAST_IN_ROWGROUP + LAST_IN_PART");
-                    lastPos = true;
-                    getTableLM().getCurrentPV().addMarkers(body.getMarkers(), 
-                            true, firstPos, lastPos);
-                    int size = lst.size();
-                    for (int i = 0; i < size; i++) {
-                        painter.handleTableContentPosition((TableContentPosition)lst.get(i));
-                    }
-                    getTableLM().getCurrentPV().addMarkers(body.getMarkers(), 
-                            false, firstPos, lastPos);
+                    handleMarkersAndPositions(lst, body, firstPos, true, painter);
                     //reset
                     firstPos = false;
-                    lastPos = false;
                     body = null;
                     lst.clear();
                 }
@@ -750,18 +742,26 @@ public class TableContentLayoutManager implements PercentBaseContext {
             }
         }
         if (body != null) {
-            getTableLM().getCurrentPV().addMarkers(body.getMarkers(), 
-                    true, firstPos, lastPos);
-            int size = lst.size();
-            for (int i = 0; i < size; i++) {
-                painter.handleTableContentPosition((TableContentPosition)lst.get(i));
-            }
-            getTableLM().getCurrentPV().addMarkers(body.getMarkers(), 
-                    false, firstPos, lastPos);
+            // Entering this block means that the end of the current table-part hasn't
+            // been reached (otherwise it would have been caught by the test above). So
+            // lastPos is necessarily false
+            handleMarkersAndPositions(lst, body, firstPos, false, painter);
         }
         painter.addAreasAndFlushRow(true);
     }
-   
+
+    private void handleMarkersAndPositions(List positions, TableBody body, boolean firstPos,
+            boolean lastPos, RowPainter painter) {
+        getTableLM().getCurrentPV().addMarkers(body.getMarkers(), 
+                true, firstPos, lastPos);
+        int size = positions.size();
+        for (int i = 0; i < size; i++) {
+            painter.handleTableContentPosition((TableContentPosition)positions.get(i));
+        }
+        getTableLM().getCurrentPV().addMarkers(body.getMarkers(), 
+                false, firstPos, lastPos);
+    }
+
     /**
      * Get the area for a row for background.
      * @param row the table-row object or null