Browse Source

Fixed basic-link horizontal position with justification turned on.

PR: 953
Obtained from:
Submitted by:
Reviewed by:


git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194179 13f79535-47bb-0310-9956-ffa450edef68
tags/fop-0_18_1
Kelly Campbell 23 years ago
parent
commit
4805c63fb1

+ 2
- 0
docs/examples/build.xml View File

@@ -46,6 +46,7 @@
<fop fofile="${foDir}/table.fo" pdffile="${testDir}/table.pdf"/>
<fop fofile="${foDir}/list.fo" pdffile="${testDir}/list.pdf"/>
<fop fofile="${foDir}/link.fo" pdffile="${testDir}/link.pdf"/>
<fop fofile="${foDir}/newlinktest.fo" pdffile="${testDir}/newlinktest.pdf"/>
<fop fofile="${foDir}/border.fo" pdffile="${testDir}/border.pdf"/>
<fop fofile="${foDir}/extensive.fo" pdffile="${testDir}/extensive.pdf"/>
<fop fofile="${foDir}/images.fo" pdffile="${testDir}/images.pdf"/>
@@ -85,6 +86,7 @@
<fop fofile="${foDir}/table.fo" pdffile="${referenceDir}/table.pdf"/>
<fop fofile="${foDir}/list.fo" pdffile="${referenceDir}/list.pdf"/>
<fop fofile="${foDir}/link.fo" pdffile="${referenceDir}/link.pdf"/>
<fop fofile="${foDir}/newlinktest.fo" pdffile="${referenceDir}/newlinktest.pdf"/>
<fop fofile="${foDir}/border.fo" pdffile="${referenceDir}/border.pdf"/>
<fop fofile="${foDir}/extensive.fo" pdffile="${referenceDir}/extensive.pdf"/>
<fop fofile="${foDir}/images.fo" pdffile="${referenceDir}/images.pdf"/>

+ 114
- 0
docs/examples/fo/newlinktest.fo View File

@@ -0,0 +1,114 @@
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format">
<fo:layout-master-set>

<!-- layout for the first page -->
<fo:simple-page-master master-name="first"
margin-top="1in"
margin-bottom="1in"
margin-left="1in"
margin-right="1in">
<fo:region-body/>
</fo:simple-page-master>


</fo:layout-master-set>
<!-- end: defines page layout -->

<!-- actual layout -->
<fo:page-sequence master-name="first">




<fo:flow flow-name="xsl-region-body">

<fo:block space-after.optimum="3pt" font-family="serif" id="block1">
FOP is the world's first print formatter driven by XSL formatting
objects. It is a Java 1.1 application that reads a formatting object
tree and then turns it into a PDF document. The formatting object
tree, can be in the form of an XML document (output by an XSLT engine
like XT or Xalan) or can be passed in memory as a DOM Document or (in
the case of XT) SAX events.
</fo:block>

<fo:block space-after.optimum="12pt" font-family="serif">FOP is part of Apache's XML project. The homepage of FOP is
<fo:inline font-style="italic" font-family="serif"><fo:basic-link color="blue" external-destination="http://xml.apache.org/fop">http://xml.apache.org/fop</fo:basic-link></fo:inline>
</fo:block>

<fo:block space-after.optimum="12pt" font-family="serif" font-weight="bold" text-align="center">
align="start"
</fo:block>

<fo:block space-after.optimum="12pt" font-family="serif" text-align="start">
Apache FOP is the world's first print formatter driven by XSL formatting
objects. It is a Java 1.1 application that reads a <fo:basic-link internal-destination="block1" color="blue">formatting object</fo:basic-link>
tree and then turns it into a <fo:basic-link internal-destination="block1" color="blue">PDF document</fo:basic-link>. The formatting object
tree, can be in the form of an XML <fo:basic-link internal-destination="block1" color="blue">document</fo:basic-link> (output by an XSLT engine
like XT or Xalan) or can be passed in memory as a DOM Document or (in
the case of XT) SAX events.

</fo:block>

<fo:block space-after.optimum="12pt" font-family="serif" font-weight="bold" text-align="center">
align="center"
</fo:block>

<fo:block space-after.optimum="12pt" font-family="serif" text-align="center">
Apache FOP is the world's first print formatter driven by XSL formatting
objects. It is a Java 1.1 application that reads a <fo:basic-link internal-destination="block1" color="blue">formatting object</fo:basic-link>
tree and then turns it into a <fo:basic-link internal-destination="block1" color="blue">PDF document</fo:basic-link>. The formatting object
tree, can be in the form of an XML <fo:basic-link internal-destination="block1" color="blue">document</fo:basic-link> (output by an XSLT engine
like XT or Xalan) or can be passed in memory as a DOM Document or (in
the case of XT) SAX events.

</fo:block>

<fo:block space-after.optimum="12pt" font-family="serif" font-weight="bold" text-align="center">
align="justify"
</fo:block>

<fo:block space-after.optimum="12pt" font-family="serif" text-align="justify">
Apache FOP is the world's first print formatter driven by XSL formatting
objects. It is a Java 1.1 application that reads a <fo:basic-link internal-destination="block1" color="blue">formatting object</fo:basic-link>
tree and then turns it into a <fo:basic-link internal-destination="block1" color="blue">PDF document</fo:basic-link>. The formatting object
tree, can be in the form of an XML <fo:basic-link internal-destination="block1" color="blue">document</fo:basic-link> (output by an XSLT engine
like XT or Xalan) or can be passed in memory as a DOM Document or (in
the case of XT) SAX events.

</fo:block>

<!-- table start -->
<fo:table>
<fo:table-column column-width="50mm"/>
<fo:table-column column-width="50mm"/>
<fo:table-column column-width="50mm"/>
<fo:table-body>
<fo:table-row>
<fo:table-cell ><fo:block>good</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>bad</fo:block></fo:table-cell>
<fo:table-cell ><fo:block><fo:basic-link internal-destination="block1" color="blue">ugly</fo:basic-link></fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell ><fo:block>nice</fo:block></fo:table-cell>
<fo:table-cell ><fo:block><fo:basic-link internal-destination="block1" color="blue">dice</fo:basic-link></fo:block></fo:table-cell>
<fo:table-cell ><fo:block>vice</fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell ><fo:block>literature</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>music</fo:block></fo:table-cell>
<fo:table-cell ><fo:block><fo:basic-link internal-destination="block1" color="blue">art</fo:basic-link></fo:block></fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell ><fo:block><fo:basic-link internal-destination="block1" color="blue">java</fo:basic-link></fo:block></fo:table-cell>
<fo:table-cell ><fo:block>perl</fo:block></fo:table-cell>
<fo:table-cell ><fo:block>python</fo:block></fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
<!-- table end -->


</fo:flow>

</fo:page-sequence>
</fo:root>

+ 20
- 11
src/org/apache/fop/layout/LineArea.java View File

@@ -244,7 +244,7 @@ public class LineArea extends Area {
((InlineArea) box).
getContentWidth(),
fontState.getFontSize());
ls.addRect(lr, this);
ls.addRect(lr, this, (InlineArea)box);
}
}
addChild(box);
@@ -277,7 +277,7 @@ public class LineArea extends Area {
Rectangle lr = new Rectangle(finalWidth, 0,
ia.getContentWidth(),
fontState.getFontSize());
ls.addRect(lr, this);
ls.addRect(lr, this, ia);
}
finalWidth += wordWidth;

@@ -419,7 +419,7 @@ public class LineArea extends Area {
Rectangle lr = new Rectangle(finalWidth + spaceWidth +
embeddedLinkStart, spaceWidth,
pia.getContentWidth(), fontState.getFontSize());
ls.addRect(lr, this);
ls.addRect(lr, this, pia);
}

embeddedLinkStart += wordWidth;
@@ -606,8 +606,7 @@ public class LineArea extends Area {
endIndent += padding;
break;
case TextAlign.JUSTIFY: // justify
Vector spaceList = new Vector();

// first pass - count the spaces
int spaceCount = 0;
Enumeration e = children.elements();
while (e.hasMoreElements()) {
@@ -615,7 +614,6 @@ public class LineArea extends Area {
if (b instanceof InlineSpace) {
InlineSpace space = (InlineSpace) b;
if (space.getResizeable()) {
spaceList.addElement(space);
spaceCount++;
}
}
@@ -626,11 +624,22 @@ public class LineArea extends Area {
} else { // no spaces
padding = 0;
}
Enumeration f = spaceList.elements();
while (f.hasMoreElements()) {
InlineSpace space2 = (InlineSpace) f.nextElement();
int i = space2.getSize();
space2.setSize(i + padding);
// second pass - add additional space
spaceCount = 0;
e = children.elements();
while (e.hasMoreElements()) {
Box b = (Box) e.nextElement();
if (b instanceof InlineSpace) {
InlineSpace space = (InlineSpace) b;
if (space.getResizeable()) {
space.setSize(space.getSize() + padding);
spaceCount++;
}
}
else if (b instanceof InlineArea) {
((InlineArea)b).setXOffset(spaceCount * padding);
}
}
}
}

+ 7
- 3
src/org/apache/fop/layout/LinkSet.java View File

@@ -59,6 +59,8 @@ import java.util.Vector;
import java.util.Enumeration;
import java.awt.Rectangle;

import org.apache.fop.layout.inline.InlineArea;

import org.apache.fop.fo.properties.WrapOption; // for enumerated
// values
// import org.apache.fop.fo.properties.WhiteSpaceCollapse; // for
@@ -105,8 +107,8 @@ public class LinkSet {
this.linkType = linkType;
}

public void addRect(Rectangle r, LineArea lineArea) {
LinkedRectangle linkedRectangle = new LinkedRectangle(r, lineArea);
public void addRect(Rectangle r, LineArea lineArea, InlineArea inlineArea) {
LinkedRectangle linkedRectangle = new LinkedRectangle(r, lineArea, inlineArea);
linkedRectangle.setY(this.yoffset);
if (this.yoffset > maxY) {
maxY = this.yoffset;
@@ -171,7 +173,9 @@ public class LinkSet {
Enumeration re = rects.elements();
while (re.hasMoreElements()) {
LinkedRectangle r = (LinkedRectangle) re.nextElement();
r.setX(r.getX() + r.getLineArea().getStartIndent());
r.setX(r.getX() +
r.getLineArea().getStartIndent() +
r.getInlineArea().getXOffset());
}
}


+ 17
- 2
src/org/apache/fop/layout/LinkedRectangle.java View File

@@ -57,6 +57,8 @@ package org.apache.fop.layout;
// Java
import java.awt.Rectangle;

import org.apache.fop.layout.inline.InlineArea;

/**
* an object that stores a rectangle that is linked, and the LineArea
* that it is logically associated with
@@ -69,14 +71,19 @@ public class LinkedRectangle {
/** the associated LineArea */
protected LineArea lineArea;

public LinkedRectangle(Rectangle link, LineArea lineArea) {
/** the associated InlineArea */
protected InlineArea inlineArea;

public LinkedRectangle(Rectangle link, LineArea lineArea, InlineArea inlineArea) {
this.link = link;
this.lineArea = lineArea;
this.inlineArea = inlineArea;
}
public LinkedRectangle(LinkedRectangle lr) {
this.link = new Rectangle( lr.getRectangle() );
this.lineArea = lr.getLineArea();
this.inlineArea = lr.getInlineArea();
}

public void setRectangle(Rectangle link) {
@@ -91,9 +98,17 @@ public class LinkedRectangle {
return this.lineArea;
}
public void setLineArea() {
public void setLineArea(LineArea lineArea) {
this.lineArea = lineArea;
}

public InlineArea getInlineArea() {
return this.inlineArea;
}
public void setLineArea(InlineArea inlineArea) {
this.inlineArea = inlineArea;
}
public void setX(int x) {
this.link.x = x;

+ 11
- 0
src/org/apache/fop/layout/inline/InlineArea.java View File

@@ -58,6 +58,9 @@ import org.apache.fop.layout.*;
public abstract class InlineArea extends Area {

private int yOffset = 0;

/** amount of space added since the original layout - needed by links */
private int xOffset = 0;
protected int height = 0;
private int verticalAlign = 0;
protected String pageNumberId = null;
@@ -114,6 +117,14 @@ public abstract class InlineArea extends Area {
return this.yOffset;
}

public void setXOffset(int xOffset) {
this.xOffset = xOffset;
}

public int getXOffset() {
return this.xOffset;
}

public String getPageNumberID() {
return pageNumberId;
}

Loading…
Cancel
Save