Hello,

here is a patch for the latest CVS, which corrects the calculation of borders.
The patch was made by Ivan Demakov for one of our projects.

If you need more info, like correct, and incorrect examples, please let me 
know.

----------  Forwarded Message  ----------
Subject: fop patch
Date: 08 Jun 2001 16:53:03 +0700
From: ivan demakov <[EMAIL PROTECTED]>
To: [EMAIL PROTECTED]


this patch calculate table cell content offset and table cell height
when fo:table border-collapse property is "separate"

cell border sizes got from properties specified directly on cell
(they should be combined with other cell borders or table borders)

-------------------------------------------------------



-- 
Sincerely Yours,
Denis Perchine

----------------------------------
E-Mail: [EMAIL PROTECTED]
HomePage: http://www.perchine.com/dyp/
FidoNet: 2:5000/120.5
----------------------------------
--- src/org/apache/fop/fo/flow/TableCell.java.orig	Wed Jun  6 15:04:12 2001
+++ src/org/apache/fop/fo/flow/TableCell.java	Wed Jun  6 16:12:32 2001
@@ -47,6 +47,9 @@
 		 */
 		protected int beforeOffset;
 
+		/* ivan demakov */
+		protected int borderHeight = 0;
+
 		protected int height = 0;
 		protected int top; // Ypos of cell ???
 		protected int verticalAlign ;
@@ -155,7 +158,7 @@
 				this.cellArea =
 						new AreaContainer(propMgr.getFontState(area.getFontInfo()),
 															startOffset, beforeOffset,
-															width, area.spaceLeft()- m_borderSeparation/2,
+															width, area.spaceLeft()- m_borderSeparation/2 + borderHeight/2,
 															Position.RELATIVE);
 
 				cellArea.foCreator=this;	// G Seshadri
@@ -215,7 +218,7 @@
 		// TableRow calls this. Anyone else?
 		public int getHeight() {
 				// return cellArea.getHeight() + spaceBefore + spaceAfter;
-				return cellArea.getHeight() + m_borderSeparation ;
+				return cellArea.getHeight() + m_borderSeparation - borderHeight / 2;
 		}
 
 		/** Called by TableRow to set final size of cell content rectangles and
@@ -230,7 +233,7 @@
 				//	cellArea.setMaxHeight(h);
 				// Increase content height by difference of row content height
 				// and current cell allocation height (includes borders & padding)
-				cellArea.increaseHeight(h - cellArea.getHeight());
+				cellArea.increaseHeight(h + borderHeight/2 - cellArea.getHeight());
 				if (bRelativeAlign) {
 						// Must get info for all cells starting in row!
 						// verticalAlign can be BEFORE or BASELINE
@@ -316,6 +319,19 @@
 							column. Look out for spanning columns.
 						*/
 
+						/* ivan demakov */
+						int borderStart  = bp.getBorderLeftWidth(false);
+						int borderEnd    = bp.getBorderRightWidth(false);
+						int borderBefore = bp.getBorderTopWidth(false);
+						int borderAfter  = bp.getBorderBottomWidth(false);
+
+						int contentOffset = borderStart/2 + bp.getPaddingLeft(false);
+
+						this.startOffset += contentOffset;
+						this.width -= (contentOffset + borderEnd/2 + bp.getPaddingRight(false));
+
+						this.beforeOffset = borderBefore/2 + bp.getPaddingTop(false);
+						this.borderHeight = borderBefore + borderAfter;
 				}
 		}
 }

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to