blockArea.setBorderColor(borderColor, borderColor, borderColor, borderColor);
blockArea.start();
+ blockArea.setAbsoluteHeight(area.getAbsoluteHeight());
+
+ blockArea.setTableCellXOffset(area.getTableCellXOffset());
int numChildren = this.children.size();
for (int i = this.marker; i < numChildren; i++) {
FONode fo = (FONode) children.elementAt(i);
//blockArea.end();
area.addChild(blockArea);
area.increaseHeight(blockArea.getHeight());
+ area.setAbsoluteHeight(blockArea.getAbsoluteHeight());
anythingLaidOut = true;
return status;
}
/* should this be combined into above? */
area.increaseHeight(blockArea.getHeight());
+
+ area.setAbsoluteHeight(blockArea.getAbsoluteHeight());
if (spaceAfter != 0) {
area.addDisplaySpace(spaceAfter);
blockArea.setPage(area.getPage());
blockArea.setBackgroundColor(backgroundColor);
blockArea.start();
+
+ blockArea.setAbsoluteHeight(area.getAbsoluteHeight());
int numChildren = this.children.size();
for (int i = this.marker; i < numChildren; i++) {
blockArea.end();
area.addChild(blockArea);
area.increaseHeight(blockArea.getHeight());
+ area.setAbsoluteHeight(blockArea.getAbsoluteHeight());
return status;
}
}
blockArea.end();
area.addChild(blockArea);
area.increaseHeight(blockArea.getHeight());
+ area.setAbsoluteHeight(blockArea.getAbsoluteHeight());
if (spaceAfter != 0) {
area.addDisplaySpace(spaceAfter);
blockArea.setPage(area.getPage());
blockArea.start();
+ blockArea.setAbsoluteHeight(area.getAbsoluteHeight());
+
int numChildren = this.children.size();
if (numChildren != 2) {
throw new FOPException("list-item must have exactly two children");
blockArea.end();
area.addChild(blockArea);
area.increaseHeight(blockArea.getHeight());
+ area.setAbsoluteHeight(blockArea.getAbsoluteHeight());
this.marker = 1;
return status;
}
blockArea.end();
area.addChild(blockArea);
area.increaseHeight(blockArea.getHeight());
+ area.setAbsoluteHeight(blockArea.getAbsoluteHeight());
if (spaceAfter != 0) {
area.addDisplaySpace(spaceAfter);
}
}
- ls.applyAreaContainerOffsets(ac);
+ ls.applyAreaContainerOffsets(ac, area);
// pass on command line
String mergeLinks = System.getProperty( "links.merge" );
areaContainer.setBorderColor(borderColor, borderColor, borderColor, borderColor);
areaContainer.start();
+ areaContainer.setAbsoluteHeight(area.getAbsoluteHeight());
+
// added by Eric Schaeffer
currentColumnNumber = 0;
int offset = 0;
//areaContainer.end();
area.addChild(areaContainer);
area.increaseHeight(areaContainer.getHeight());
+ area.setAbsoluteHeight(areaContainer.getAbsoluteHeight());
return status;
}
}
/* should this be combined into above? */
area.increaseHeight(areaContainer.getHeight());
+ area.setAbsoluteHeight(areaContainer.getAbsoluteHeight());
+
if (spaceAfter != 0) {
area.addDisplaySpace(spaceAfter);
}
areaContainer.setBackgroundColor(backgroundColor);
areaContainer.start();
+ areaContainer.setAbsoluteHeight(area.getAbsoluteHeight());
+
int numChildren = this.children.size();
for (int i = this.marker; i < numChildren; i++) {
TableRow row = (TableRow) children.elementAt(i);
}
area.addChild(areaContainer);
//areaContainer.end();
+
area.increaseHeight(areaContainer.getHeight());
+ area.setAbsoluteHeight(areaContainer.getAbsoluteHeight());
return status;
}
}
/* should this be combined into above? */
area.increaseHeight(areaContainer.getHeight());
+ area.setAbsoluteHeight(areaContainer.getAbsoluteHeight());
+
if (spaceAfter != 0) {
area.addDisplaySpace(spaceAfter);
}
areaContainer.setBorderColor(borderColor, borderColor, borderColor, borderColor);
areaContainer.start();
+ areaContainer.setAbsoluteHeight(area.getAbsoluteHeight());
+ areaContainer.setTableCellXOffset(startOffset);
int numChildren = this.children.size();
for (int i = this.marker; i < numChildren; i++) {
FObj fo = (FObj) children.elementAt(i);
areaContainer.setBorderColor(borderColor, borderColor, borderColor, borderColor);
areaContainer.start();
+ areaContainer.setAbsoluteHeight(area.getAbsoluteHeight());
+
int numChildren = this.children.size();
if (numChildren != columns.size()) {
System.err.println("WARNING: Number of children under table-row not equal to number of table-columns");
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;
public void addDisplaySpace(int size) {
this.addChild(new DisplaySpace(size));
+ this.absoluteHeight += size;
this.currentHeight += size;
}
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);
}
public void setHeight(int height) {
if (height > currentHeight)
currentHeight = height;
+ absoluteHeight = height;
if (currentHeight > getMaxHeight())
currentHeight = getMaxHeight();
+ absoluteHeight = getMaxHeight();
}
public void setMaxHeight(int height) {
return xPosition + this.paddingLeft + this.borderWidthLeft;
}
+ public void setXPosition(int value)
+ {
+ xPosition=value;
+ }
+
public int getYPosition() {
return yPosition + this.paddingTop + this.borderWidthTop;
}
protected int halfLeading;
+
/* text-align of all but the last line */
protected int align;
public int spaceLeft() {
return maxHeight - currentHeight;
}
+
+ public int getHalfLeading()
+ {
+ return halfLeading;
+ }
+
}
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;
finalWidth,
0,
inlineArea.getContentWidth(),
- lineHeight);
+ fontState.getFontSize());
ls.addRect(lr, this);
}
finalWidth,
0,
ia.getContentWidth(),
- lineHeight);
+ fontState.getFontSize());
ls.addRect(lr, this);
}
finalWidth += wordWidth;
// word we just added
prev = WHITESPACE;
+
+ embeddedLinkStart=0; //reset embeddedLinkStart since a space was encountered
if (this.whiteSpaceTreatment ==
WhiteSpaceTreatment.IGNORE) {
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;
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;
LinkedRectangle linkedRectangle =
new LinkedRectangle(r, lineArea);
linkedRectangle.setY(this.yoffset);
+ if(this.yoffset>maxY)
+ {
+ maxY=this.yoffset;
+ }
rects.addElement(linkedRectangle);
}
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
package org.apache.fop.pdf;
/**
- * class representing a /Action object.
+ * class representing an action object.
*/
-public class PDFAction extends PDFObject {
-
- /** the file specification */
- protected PDFFileSpec fileSpec;
+public abstract class PDFAction extends PDFObject {
+
/**
- * create an /Action object.
+ * create an Action object.
+ * this constructor is used for passing on the object number to the PDFObject
*
- * @param number the object's number
- * @param fileSpec the fileSpec associated with the action
+ * @param number the object's number
*/
- public PDFAction(int number, PDFFileSpec fileSpec) {
+ public PDFAction(int number) {
/* generic creation of object */
- super(number);
-
- this.fileSpec = fileSpec;
+ super(number);
+ }
+
+ /**
+ * empty constructor for PDFAction.
+ * this constructor is used when there is no additional object being created
+ *
+ */
+ public PDFAction()
+ {
}
+ /**
+ * represent the action to call
+ * this method should be implemented to return the action which gets
+ * called by the Link Object. This could be a reference to another object
+ * or the specific destination of the link
+ *
+ * @return the action to place next to /A within a Link
+ */
+ abstract public String getAction();
+
+
/**
* represent the object in PDF
+ * this method should be implemented to return the PDF which is to be
+ * generated by the Action object
*
* @return the PDF string
*/
- public String toPDF() {
- String p = new String(this.number + " " + this.generation +
- " obj\n" +
- "<<\n/S /GoToR\n" +
- "/F " + fileSpec.referencePDF() + "\n" +
- "/D [ 0 /XYZ null null null ]" +
- " \n>>\nendobj\n");
- return p;
- }
+ abstract public String toPDF();
- /* example
- 28 0 obj
- <<
- /S /GoToR
- /F 29 0 R
- /D [ 0 /XYZ -6 797 null ]
- >>
- endobj
- */
-}
+ }
*/
public PDFLink makeLink(Rectangle rect, String destination) {
- PDFLink link = new PDFLink(++this.objectcount, rect);
- this.objects.addElement(link);
-
- PDFFileSpec fileSpec = new PDFFileSpec(++this.objectcount,
- destination);
- this.objects.addElement(fileSpec);
-
- PDFAction action = new PDFAction(++this.objectcount,
- fileSpec);
- this.objects.addElement(action);
- link.setAction(action);
-
- return link;
- }
+ PDFLink linkObject;
+ PDFAction action;
+
+ PDFLink link = new PDFLink(++this.objectcount, rect);
+ this.objects.addElement(link);
+
+ //check destination
+ if ( destination.endsWith(".pdf") ) //FileSpec
+ {
+ PDFFileSpec fileSpec = new PDFFileSpec(++this.objectcount,destination);
+ this.objects.addElement(fileSpec);
+ action = new PDFGoToRemote(++this.objectcount,fileSpec);
+ this.objects.addElement(action);
+ link.setAction(action);
+ }
+ else //URI
+ {
+ PDFUri uri = new PDFUri(destination);
+ link.setAction(uri);
+ }
+
+ return link;
+ }
/**
* make a stream object
(brx/1000f) + " " + (bry/1000f) + " ]\n"
+ "/C [ " + this.color + " ]\n" +
"/Border [ 0 0 0 ]\n" +
- "/A " + this.action.referencePDF() + "\n" +
+ "/A " + this.action.getAction() + "\n" +
"/H /I\n>>\nendobj\n";
return p;
}