Bug 33808 - problem with large number-rows-spanned
Summary: problem with large number-rows-spanned
Status: CLOSED FIXED
Alias: None
Product: Fop - Now in Jira
Classification: Unclassified
Component: pdf (show other bugs)
Version: 0.20.5
Hardware: PC Linux
: P2 normal
Target Milestone: ---
Assignee: fop-dev
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-03-02 14:24 UTC by vitus
Modified: 2012-04-01 07:13 UTC (History)
0 users



Attachments
path for use greater number-rows-spanned (4.16 KB, patch)
2005-03-26 07:42 UTC, vitus
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description vitus 2005-03-02 14:24:38 UTC
I am experiencing trouble when trying to create a table with FOP.

My first table column has a number-rows-spanned that is larger than the
number of rows fitting on a page. This leads to several problems:

1. The cell border is drawn across the page footer (does not end with the
last table-row on the page, but is drawn into nowhere if you have even more
rows).
2. The cell border for the (continued) first cell on the next page is
missing completely.

3. An extra page is being added at the beginning of my document. (?!)

Whether there is a patch correcting this mistake ?
Comment 1 vitus 2005-03-26 07:42:57 UTC
Created attachment 14566 [details]
path for use greater number-rows-spanned

I have written a patch which allows to use greater number-rows-spanned. I think
it's dirty hack if someone knows more elegant the decision you are welcome =).
(sorry for english).
Comment 2 vitus 2005-04-05 06:28:09 UTC
Comment on attachment 14566 [details]
path for use greater number-rows-spanned

diff -Nur fop-0.20.5-dist/src/org/apache/fop/fo/flow/AbstractTableBody.java
fop-0.20.5/src/org/apache/fop/fo/flow/AbstractTableBody.java
--- fop-0.20.5-dist/src/org/apache/fop/fo/flow/AbstractTableBody.java  
2005-02-07 19:44:05.000000000 +0600
+++ fop-0.20.5/src/org/apache/fop/fo/flow/AbstractTableBody.java       
2005-04-05 11:21:12.246807323 +0700
@@ -106,17 +106,17 @@
	 if (this.marker == START) {

	     // Common Accessibility Properties
-	     AccessibilityProps mAccProps = propMgr.getAccessibilityProps();
+//	       AccessibilityProps mAccProps = propMgr.getAccessibilityProps();

	     // Common Aural Properties
-	     AuralProps mAurProps = propMgr.getAuralProps();
+//	       AuralProps mAurProps = propMgr.getAuralProps();

	     // Common Border, Padding, and Background Properties
-	     BorderAndPadding bap = propMgr.getBorderAndPadding();
-	     BackgroundProps bProps = propMgr.getBackgroundProps();
+//	       BorderAndPadding bap = propMgr.getBorderAndPadding();
+//	       BackgroundProps bProps = propMgr.getBackgroundProps();

	     // Common Relative Position Properties
-	     RelativePositionProps mRelProps =
propMgr.getRelativePositionProps();
+//	       RelativePositionProps mRelProps =
propMgr.getRelativePositionProps();

	     // this.properties.get("id");

diff -Nur fop-0.20.5-dist/src/org/apache/fop/fo/flow/Block.java
fop-0.20.5/src/org/apache/fop/fo/flow/Block.java
--- fop-0.20.5-dist/src/org/apache/fop/fo/flow/Block.java	2005-02-07
19:44:05.000000000 +0600
+++ fop-0.20.5/src/org/apache/fop/fo/flow/Block.java	2005-04-01
11:50:48.000000000 +0700
@@ -153,26 +153,26 @@
	     noLayoutCount=0; // Reset the "loop counter".

	     // Common Accessibility Properties
-	     AccessibilityProps mAccProps = propMgr.getAccessibilityProps();
+//	       AccessibilityProps mAccProps = propMgr.getAccessibilityProps();

	     // Common Aural Properties
-	     AuralProps mAurProps = propMgr.getAuralProps();
+//	       AuralProps mAurProps = propMgr.getAuralProps();

	     // Common Border, Padding, and Background Properties
-	     BorderAndPadding bap = propMgr.getBorderAndPadding();
-	     BackgroundProps bProps = propMgr.getBackgroundProps();
+//	       BorderAndPadding bap = propMgr.getBorderAndPadding();
+//	       BackgroundProps bProps = propMgr.getBackgroundProps();

	     // Common Font Properties
	     //this.fontState = propMgr.getFontState(area.getFontInfo());

	     // Common Hyphenation Properties
-	     HyphenationProps mHyphProps = propMgr.getHyphenationProps();
+//	       HyphenationProps mHyphProps = propMgr.getHyphenationProps();

	     // Common Margin Properties-Block
-	     MarginProps mProps = propMgr.getMarginProps();
+//	       MarginProps mProps = propMgr.getMarginProps();

	     // Common Relative Position Properties
-	     RelativePositionProps mRelProps =
propMgr.getRelativePositionProps();
+//	       RelativePositionProps mRelProps =
propMgr.getRelativePositionProps();

	     this.align = this.properties.get("text-align").getEnum();
	     this.alignLast = this.properties.get("text-align-last").getEnum();
diff -Nur fop-0.20.5-dist/src/org/apache/fop/fo/flow/RowSpanMgr.java
fop-0.20.5/src/org/apache/fop/fo/flow/RowSpanMgr.java
--- fop-0.20.5-dist/src/org/apache/fop/fo/flow/RowSpanMgr.java	2005-02-07
19:44:05.000000000 +0600
+++ fop-0.20.5/src/org/apache/fop/fo/flow/RowSpanMgr.java	2005-04-01
12:48:16.000000000 +0700
@@ -77,9 +77,9 @@
	     return (rowsRemaining == 1);
	 }

-	 boolean finishRow(int rowHeight) {
+	 boolean finishRow(int rowHeight, boolean isFullRow) {
	     totalRowHeight += rowHeight;
-	     if (--rowsRemaining == 0) {
+	     if (isFullRow && --rowsRemaining == 0) {
		 if (cell != null) {
		     cell.setRowHeight(totalRowHeight);
		 }
@@ -131,6 +131,16 @@
	 return false;
     }

+    public void setForceFinishSpans(int rowHeight) {
+      for (int i = 0; i < spanInfo.length; i++) {
+	 if (spanInfo[i] != null && spanInfo[i].cell != null){
+	   spanInfo[i].cell.setRowHeight(spanInfo[i].totalRowHeight -
rowHeight);
+	   spanInfo[i].cell.setNumRowsSpanned(spanInfo[i].rowsRemaining);
+	 }
+	 spanInfo[i] = null;
+      }
+    }
+
     /**
      * Done with a row.
      * Any spans with only one row left are done
@@ -140,10 +150,11 @@
      * then remove the cell from the list of spanned cells. For other
      * spans, add the rowHeight to the spanHeight.
      */
-    public void finishRow(int rowHeight) {
+    public void finishRow(int rowHeight, boolean isFullRow) {
	 for (int i = 0; i < spanInfo.length; i++) {
-	     if (spanInfo[i] != null && spanInfo[i].finishRow(rowHeight))
+	     if (spanInfo[i] != null &&
spanInfo[i].finishRow(rowHeight,isFullRow)) {
		 spanInfo[i] = null;
+	     }
	 }
     }

diff -Nur fop-0.20.5-dist/src/org/apache/fop/fo/flow/TableCell.java
fop-0.20.5/src/org/apache/fop/fo/flow/TableCell.java
--- fop-0.20.5-dist/src/org/apache/fop/fo/flow/TableCell.java	2005-02-07
19:44:05.000000000 +0600
+++ fop-0.20.5/src/org/apache/fop/fo/flow/TableCell.java	2005-04-01
11:52:09.000000000 +0700
@@ -179,17 +179,17 @@
     public void doSetup()    // throws FOPException
      {
	 // Common Accessibility Properties
-	 AccessibilityProps mAccProps = propMgr.getAccessibilityProps();
+//	   AccessibilityProps mAccProps = propMgr.getAccessibilityProps();

	 // Common Aural Properties
-	 AuralProps mAurProps = propMgr.getAuralProps();
+//	   AuralProps mAurProps = propMgr.getAuralProps();

	 // Common Border, Padding, and Background Properties
-	 BorderAndPadding bap = propMgr.getBorderAndPadding();
-	 BackgroundProps bProps = propMgr.getBackgroundProps();
+//	   BorderAndPadding bap = propMgr.getBorderAndPadding();
+//	   BackgroundProps bProps = propMgr.getBackgroundProps();

	 // Common Relative Position Properties
-	 RelativePositionProps mRelProps = propMgr.getRelativePositionProps();
+//	   RelativePositionProps mRelProps =
propMgr.getRelativePositionProps();

	 // this.properties.get("border-after-precedence");
	 // this.properties.get("border-before-precendence");
@@ -246,7 +246,7 @@


     public int layout(Area area) throws FOPException {
-	 int originalAbsoluteHeight = area.getAbsoluteHeight();
+//	   int originalAbsoluteHeight = area.getAbsoluteHeight();
	 if (this.marker == BREAK_AFTER) {
	     return Status.OK;
	 }
@@ -530,6 +530,13 @@
	     this.borderHeight = (borderBefore + borderAfter) / 2;
	 }
     }
-

+    public void setNumRowsSpanned(int numRowsSpanned){
+	 this.numRowsSpanned = Math.max(1, numRowsSpanned);
+    }
+
+    public void resetMarker() {
+	 bDone = false;
+	 super.resetMarker();
+    }
 }
diff -Nur fop-0.20.5-dist/src/org/apache/fop/fo/flow/Table.java
fop-0.20.5/src/org/apache/fop/fo/flow/Table.java
--- fop-0.20.5-dist/src/org/apache/fop/fo/flow/Table.java	2005-02-07
19:44:05.000000000 +0600
+++ fop-0.20.5/src/org/apache/fop/fo/flow/Table.java	2005-04-01
11:54:19.000000000 +0700
@@ -117,20 +117,20 @@

	 if (this.marker == START) {
	     // Common Accessibility Properties
-	     AccessibilityProps mAccProps = propMgr.getAccessibilityProps();
+//	       AccessibilityProps mAccProps = propMgr.getAccessibilityProps();

	     // Common Aural Properties
-	     AuralProps mAurProps = propMgr.getAuralProps();
+//	       AuralProps mAurProps = propMgr.getAuralProps();

	     // Common Border, Padding, and Background Properties
-	     BorderAndPadding bap = propMgr.getBorderAndPadding();
-	     BackgroundProps bProps = propMgr.getBackgroundProps();
+//	       BorderAndPadding bap = propMgr.getBorderAndPadding();
+//	       BackgroundProps bProps = propMgr.getBackgroundProps();

	     // Common Margin Properties-Block
-	     MarginProps mProps = propMgr.getMarginProps();
+//	       MarginProps mProps = propMgr.getMarginProps();

	     // Common Relative Position Properties
-	     RelativePositionProps mRelProps =
propMgr.getRelativePositionProps();
+//	       RelativePositionProps mRelProps =
propMgr.getRelativePositionProps();

	     // this.properties.get("block-progression-dimension");
	     // this.properties.get("border-after-precendence");
@@ -447,7 +447,7 @@

     private int calcFixedColumnWidths(int maxAllocationWidth) {
	 int nextColumnNumber=1;
-	 int iEmptyCols=0;
+//	   int iEmptyCols=0;
	 double dTblUnits=0.0;
	 int iFixedWidth=0;
	 double dWidthFactor = 0.0;
@@ -459,7 +459,7 @@
		 log.warn("No table-column specification for column " +
			  nextColumnNumber);
		 // What about sizing issues?
-		 iEmptyCols++;
+//		   iEmptyCols++;
	     }
	     else {
		 Length colLength = c.getColumnWidthAsLength();
@@ -508,9 +508,9 @@
	     /* No proportional units. If minimum IPD is specified, check
	      * that sum of column widths > minIPD.
	      */
-	     int iTableWidth = iFixedWidth;
+//	       int iTableWidth = iFixedWidth;
	     if (this.minIPD > iFixedWidth) {
-		 iTableWidth = this.minIPD;
+//		   iTableWidth = this.minIPD;
		 // Add extra space to each column
		 dWidthFactor = (double)this.minIPD/(double)iFixedWidth;
	     }
diff -Nur fop-0.20.5-dist/src/org/apache/fop/fo/flow/TableRow.java
fop-0.20.5/src/org/apache/fop/fo/flow/TableRow.java
--- fop-0.20.5-dist/src/org/apache/fop/fo/flow/TableRow.java	2005-02-07
19:44:05.000000000 +0600
+++ fop-0.20.5/src/org/apache/fop/fo/flow/TableRow.java 2005-04-05
11:18:44.817271870 +0700
@@ -173,6 +173,13 @@
	     }
	     return rslt;
	 }
+
+      public void setForceCellsStart() {
+	   for (int i=0; i<states.length; i++){
+	     if (cells[i] != null)
+	       states[i] = CELLSTART;
+	   }
+      }
     }


@@ -202,21 +209,21 @@
     public void doSetup(Area area) throws FOPException {

	 // Common Accessibility Properties
-	 AccessibilityProps mAccProps = propMgr.getAccessibilityProps();
+//	   AccessibilityProps mAccProps = propMgr.getAccessibilityProps();

	 // this.properties.get("block-progression-dimension");

	 // Common Aural Properties
-	 AuralProps mAurProps = propMgr.getAuralProps();
+//	   AuralProps mAurProps = propMgr.getAuralProps();

	 // Common Border, Padding, and Background Properties
	 // only background apply, border apply if border-collapse
	 // is collapse.
-	 BorderAndPadding bap = propMgr.getBorderAndPadding();
-	 BackgroundProps bProps = propMgr.getBackgroundProps();
+//	   BorderAndPadding bap = propMgr.getBorderAndPadding();
+//	   BackgroundProps bProps = propMgr.getBackgroundProps();

	 // Common Relative Position Properties
-	 RelativePositionProps mRelProps = propMgr.getRelativePositionProps();
+//	   RelativePositionProps mRelProps =
propMgr.getRelativePositionProps();

	 // this.properties.get("break-before");
	 // this.properties.get("break-after");
@@ -233,7 +240,6 @@
	 this.keepWithNext = getKeepValue("keep-with-next.within-column");
	 this.keepWithPrevious =
	     getKeepValue("keep-with-previous.within-column");
-
	 this.id = this.properties.get("id").getString();
	 this.minHeight = this.properties.get("height").getLength().mvalue();
	 setup = true;
@@ -356,10 +362,15 @@


	     int rowSpan = cell.getNumRowsSpanned();
+	     if (rowSpan > 1)
+	       cell.resetMarker();
	     int status;
	     if (Status.isIncomplete((status = cell.layout(areaContainer)))) {
-		if ((keepTogether.getType() == KeepValue.KEEP_WITH_ALWAYS &&
bIgnoreKeepTogether==false)
-			 || (status == Status.AREA_FULL_NONE)
+		if (keepTogether.getType() == KeepValue.KEEP_WITH_ALWAYS &&
bIgnoreKeepTogether==false){
+		    this.resetMarker();
+		    this.removeID(area.getIDReferences());
+		    return Status.AREA_FULL_NONE;
+		} else if ((status == Status.AREA_FULL_NONE)
			 || rowSpan > 1) {
		     // We will put this row into the next column/page
		     // Note: the only time this shouldn't be honored is
@@ -367,14 +378,22 @@
		     // Remove spanning cells from RowSpanMgr?
		     this.resetMarker();
		     this.removeID(area.getIDReferences());
-		     return Status.AREA_FULL_NONE;
+		     rowSpanMgr.finishRow(largestCellHeight, false);
+		     rowSpanMgr.setForceFinishSpans(largestCellHeight);
+		     cellArray.setForceCellsStart();
+		     return Status.FORCE_PAGE_BREAK;
		 } else if (status == Status.AREA_FULL_SOME) {
		     /*
		      * Row is not keep-together, cell isn't spanning
		      * and part of it fits. We can break the cell and
		      * the row.
		      */
-		     someCellDidNotLayoutCompletely = true;
+		     this.resetMarker();
+		     this.removeID(area.getIDReferences());
+		     rowSpanMgr.finishRow(largestCellHeight, false);
+		     rowSpanMgr.setForceFinishSpans(largestCellHeight);
+		     cellArray.setForceCellsStart();
+		     return Status.FORCE_PAGE_BREAK;
		 }
	     }				  // else {
	      // layout was complete for a particular cell
@@ -404,7 +423,8 @@

	 // Adjust spanning row information
	 // ??? what if some cells are broken???
-	 rowSpanMgr.finishRow(largestCellHeight);
+	 rowSpanMgr.finishRow(largestCellHeight,
+			      !someCellDidNotLayoutCompletely );

	 area.addChild(areaContainer);
	 areaContainer.setHeight(largestCellHeight);
diff -Nur fop-0.20.5-dist/src/org/apache/fop/layout/BodyAreaContainer.java
fop-0.20.5/src/org/apache/fop/layout/BodyAreaContainer.java
--- fop-0.20.5-dist/src/org/apache/fop/layout/BodyAreaContainer.java   
2005-02-07 19:44:06.000000000 +0600
+++ fop-0.20.5/src/org/apache/fop/layout/BodyAreaContainer.java 2005-04-01
11:57:09.000000000 +0700
@@ -84,12 +84,12 @@
     private int mainRefAreaHeight;

     // reference area yPositions
-    private int mainYPosition;
-    private int beforeFloatYPosition;
-    private int footnoteYPosition;
+//    private int mainYPosition;
+//    private int beforeFloatYPosition;
+//    private int footnoteYPosition;

     // the start FO in case of rollback
-    private FObj startFO;
+//    private FObj startFO;
     private boolean isNewSpanArea;

     // keeps track of footnote state for multiple layouts
@@ -377,42 +377,42 @@
	 return footnoteState;
     }

-    public boolean needsFootnoteAdjusting() {
-	 footnoteYPosition = footnoteReferenceArea.getYPosition();
-	 switch (footnoteState) {
-	 case 0:
-	     resetHeights();
-	     if (footnoteReferenceArea.getHeight() > 0
-		     && mainYPosition + mainReferenceArea.getHeight()
-			> footnoteYPosition) {
-		 return true;
-	     }
-	 case 1:
-	     break;
-	 }
-	 return false;
-    }
-
-    public void adjustFootnoteArea() {
-	 footnoteState++;
-	 if (footnoteState == 1) {
-	    
mainReferenceArea.setMaxHeight(footnoteReferenceArea.getYPosition()
-					    - mainYPosition);
-	     footnoteYPosition = footnoteReferenceArea.getYPosition();
-	    
footnoteReferenceArea.setMaxHeight(footnoteReferenceArea.getHeight());
-
-	     ArrayList children = footnoteReferenceArea.getChildren();
-	     for (int i = 0; i < children.size(); i++) {
-		 Object obj = children.get(i);
-		 if (obj instanceof Area) {
-		     Area childArea = (Area)obj;
-		     footnoteReferenceArea.removeChild(childArea);
-		 }
-	     }
-
-	     getPage().setPendingFootnotes(null);
-	 }
-    }
+//    public boolean needsFootnoteAdjusting() {
+//	   footnoteYPosition = footnoteReferenceArea.getYPosition();
+//	   switch (footnoteState) {
+//	   case 0:
+//	       resetHeights();
+//	       if (footnoteReferenceArea.getHeight() > 0
+//		       && mainYPosition + mainReferenceArea.getHeight()
+//			  > footnoteYPosition) {
+//		   return true;
+//	       }
+//	   case 1:
+//	       break;
+//	   }
+//	   return false;
+//    }
+//
+//    public void adjustFootnoteArea() {
+//	   footnoteState++;
+//	   if (footnoteState == 1) {
+//	      
mainReferenceArea.setMaxHeight(footnoteReferenceArea.getYPosition()
+//					      - mainYPosition);
+//	       footnoteYPosition = footnoteReferenceArea.getYPosition();
+//	      
footnoteReferenceArea.setMaxHeight(footnoteReferenceArea.getHeight());
+//
+//	       ArrayList children = footnoteReferenceArea.getChildren();
+//	       for (int i = 0; i < children.size(); i++) {
+//		   Object obj = children.get(i);
+//		   if (obj instanceof Area) {
+//		       Area childArea = (Area)obj;
+//		       footnoteReferenceArea.removeChild(childArea);
+//		   }
+//	       }
+//
+//	       getPage().setPendingFootnotes(null);
+//	   }
+//    }

     protected static void resetMaxHeight(Area ar, int change) {
	 ar.setMaxHeight(change);
Comment 3 Pascal Sancho 2007-11-20 02:12:13 UTC
Fixed in FOP 0.94 and probably earlier versions
Comment 4 Vitali 2007-11-20 02:48:40 UTC
in 0.93 works fine.
with patch works on 0.20.5
Comment 5 Glenn Adams 2012-04-01 07:13:59 UTC
batch transition pre-FOP1.0 resolved+fixed bugs to closed+fixed