aboutsummaryrefslogtreecommitdiffstats
path: root/src/org/apache/fop/layout
diff options
context:
space:
mode:
Diffstat (limited to 'src/org/apache/fop/layout')
-rw-r--r--src/org/apache/fop/layout/Area.java36
-rw-r--r--src/org/apache/fop/layout/AreaContainer.java5
-rw-r--r--src/org/apache/fop/layout/BlockArea.java7
-rw-r--r--src/org/apache/fop/layout/LineArea.java14
-rw-r--r--src/org/apache/fop/layout/LinkSet.java21
5 files changed, 73 insertions, 10 deletions
diff --git a/src/org/apache/fop/layout/Area.java b/src/org/apache/fop/layout/Area.java
index fe445c47d..47166c855 100644
--- a/src/org/apache/fop/layout/Area.java
+++ b/src/org/apache/fop/layout/Area.java
@@ -69,6 +69,12 @@ abstract public class Area extends Box {
protected int maxHeight;
protected int currentHeight = 0;
+
+ // used to keep track of the current x position within a table. Required for drawing rectangle links.
+ protected int tableCellXOffset = 0;
+
+ // used to keep track of the absolute height on the page. Required for drawing rectangle links.
+ private int absoluteHeight = 0;
protected int contentRectangleWidth;
@@ -120,6 +126,7 @@ abstract public class Area extends Box {
public void addDisplaySpace(int size) {
this.addChild(new DisplaySpace(size));
+ this.absoluteHeight += size;
this.currentHeight += size;
}
@@ -182,12 +189,39 @@ abstract public class Area extends Box {
return this.paddingRight;
}
+ public int getTableCellXOffset()
+ {
+ return tableCellXOffset;
+ }
+
+ public void setTableCellXOffset(int offset)
+ {
+ tableCellXOffset=offset;
+ }
+
+ public int getAbsoluteHeight()
+ {
+ return absoluteHeight;
+ }
+
+ public void setAbsoluteHeight(int value)
+ {
+ absoluteHeight=value;
+ }
+
+ public void increaseAbsoluteHeight(int value)
+ {
+ absoluteHeight+=value;
+ }
+
public void increaseHeight(int amount) {
this.currentHeight += amount;
+ this.absoluteHeight += amount;
}
protected void removeChild(Area area) {
this.currentHeight -= area.getHeight();
+ this.absoluteHeight -= area.getHeight();
this.children.removeElement(area);
}
@@ -241,8 +275,10 @@ abstract public class Area extends Box {
public void setHeight(int height) {
if (height > currentHeight)
currentHeight = height;
+ absoluteHeight = height;
if (currentHeight > getMaxHeight())
currentHeight = getMaxHeight();
+ absoluteHeight = getMaxHeight();
}
public void setMaxHeight(int height) {
diff --git a/src/org/apache/fop/layout/AreaContainer.java b/src/org/apache/fop/layout/AreaContainer.java
index 45fedba8e..cdd66f62b 100644
--- a/src/org/apache/fop/layout/AreaContainer.java
+++ b/src/org/apache/fop/layout/AreaContainer.java
@@ -83,6 +83,11 @@ public class AreaContainer extends Area {
return xPosition + this.paddingLeft + this.borderWidthLeft;
}
+ public void setXPosition(int value)
+ {
+ xPosition=value;
+ }
+
public int getYPosition() {
return yPosition + this.paddingTop + this.borderWidthTop;
}
diff --git a/src/org/apache/fop/layout/BlockArea.java b/src/org/apache/fop/layout/BlockArea.java
index 79c170a1c..4831b0fea 100644
--- a/src/org/apache/fop/layout/BlockArea.java
+++ b/src/org/apache/fop/layout/BlockArea.java
@@ -70,6 +70,7 @@ public class BlockArea extends Area {
protected int halfLeading;
+
/* text-align of all but the last line */
protected int align;
@@ -197,4 +198,10 @@ public class BlockArea extends Area {
public int spaceLeft() {
return maxHeight - currentHeight;
}
+
+ public int getHalfLeading()
+ {
+ return halfLeading;
+ }
+
}
diff --git a/src/org/apache/fop/layout/LineArea.java b/src/org/apache/fop/layout/LineArea.java
index 1a34faf82..4c1c5a42d 100644
--- a/src/org/apache/fop/layout/LineArea.java
+++ b/src/org/apache/fop/layout/LineArea.java
@@ -89,6 +89,9 @@ public class LineArea extends Area {
area */
protected int finalWidth = 0;
+ /* the position to shift a link rectangle in order to compensate for links embedded within a word*/
+ protected int embeddedLinkStart=0;
+
/* the width of the current word so far */
protected int wordWidth = 0;
@@ -224,7 +227,7 @@ public class LineArea extends Area {
finalWidth,
0,
inlineArea.getContentWidth(),
- lineHeight);
+ fontState.getFontSize());
ls.addRect(lr, this);
}
@@ -252,7 +255,7 @@ public class LineArea extends Area {
finalWidth,
0,
ia.getContentWidth(),
- lineHeight);
+ fontState.getFontSize());
ls.addRect(lr, this);
}
finalWidth += wordWidth;
@@ -265,6 +268,8 @@ public class LineArea extends Area {
// word we just added
prev = WHITESPACE;
+
+ embeddedLinkStart=0; //reset embeddedLinkStart since a space was encountered
if (this.whiteSpaceTreatment ==
WhiteSpaceTreatment.IGNORE) {
@@ -354,13 +359,14 @@ public class LineArea extends Area {
if (ls != null) {
Rectangle lr =
- new Rectangle(startIndent + finalWidth + spaceWidth,
+ new Rectangle(startIndent + finalWidth + spaceWidth + embeddedLinkStart,
spaceWidth,
pia.getContentWidth(),
- lineHeight);
+ fontState.getFontSize());
ls.addRect(lr, this);
}
+ embeddedLinkStart += wordWidth;
pendingAreas.addElement(pia);
pendingWidth += wordWidth;
wordWidth = 0;
diff --git a/src/org/apache/fop/layout/LinkSet.java b/src/org/apache/fop/layout/LinkSet.java
index e69d572f6..32172bc7d 100644
--- a/src/org/apache/fop/layout/LinkSet.java
+++ b/src/org/apache/fop/layout/LinkSet.java
@@ -83,6 +83,9 @@ public class LinkSet {
private int xoffset = 0;
private int yoffset = 0;
+ /* the maximum Y offset value encountered for this LinkSet*/
+ private int maxY = 0;
+
protected int startIndent;
protected int endIndent;
@@ -100,6 +103,10 @@ public class LinkSet {
LinkedRectangle linkedRectangle =
new LinkedRectangle(r, lineArea);
linkedRectangle.setY(this.yoffset);
+ if(this.yoffset>maxY)
+ {
+ maxY=this.yoffset;
+ }
rects.addElement(linkedRectangle);
}
@@ -115,13 +122,15 @@ public class LinkSet {
this.contentRectangleWidth = contentRectangleWidth;
}
- public void applyAreaContainerOffsets(AreaContainer ac) {
- Enumeration re = rects.elements();
- while (re.hasMoreElements()) {
+ public void applyAreaContainerOffsets(AreaContainer ac, Area area) {
+ int height=area.getAbsoluteHeight();
+ BlockArea ba = (BlockArea)area;
+ Enumeration re = rects.elements();
+ while (re.hasMoreElements()) {
LinkedRectangle r = (LinkedRectangle)re.nextElement();
- r.setX( r.getX() + ac.getXPosition() );
- r.setY( ac.getYPosition() - ac.getHeight() - r.getY() );
- }
+ r.setX(r.getX() + ac.getXPosition() + area.getTableCellXOffset() - ba.startIndent);
+ r.setY( ac.getYPosition() - height +(maxY-r.getY()) - ba.getHalfLeading());
+ }
}
// intermediate implementation for joining all sublinks on same line