Selaa lähdekoodia

Apply's Christian Geisert's text decoration (underline) patch.

I updated the readme.fo so it reports the latest released version of fop
as 0.14, rather than 12.0(????). I fixed the build.xml so it will build
reference PDFs for the last two added examples. I added Christian's
textdeko.fo example file as one of the examples.


git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@193730 13f79535-47bb-0310-9956-ffa450edef68
tags/pre-columns
Steve Coffman 23 vuotta sitten
vanhempi
commit
a5fe0cc78f

+ 3
- 0
docs/examples/build.xml Näytä tiedosto

@@ -52,6 +52,7 @@
<fop fofile="${foDir}/readme.fo" pdffile="${testDir}/readme.pdf"/>
<fop fofile="${foDir}/fonts.fo" pdffile="${testDir}/fonts.pdf"/>
<fop fofile="${foDir}/leader.fo" pdffile="${testDir}/leader.pdf"/>
<fop fofile="${foDir}/textdeko.fo" pdffile="${testDir}/textdeko.pdf"/>
</target>


@@ -81,6 +82,8 @@
<fop fofile="${foDir}/images.fo" pdffile="${referenceDir}/images.pdf"/>
<fop fofile="${foDir}/readme.fo" pdffile="${referenceDir}/readme.pdf"/>
<fop fofile="${foDir}/fonts.fo" pdffile="${referenceDir}/fonts.pdf"/>
<fop fofile="${foDir}/leader.fo" pdffile="${referenceDir}/leader.pdf"/>
<fop fofile="${foDir}/textdeko.fo" pdffile="${referenceDir}/textdeko.pdf"/>
</target>



+ 3
- 3
docs/examples/fo/readme.fo Näytä tiedosto

@@ -89,8 +89,8 @@ This is not the latest Fop documentation, but just an fo example. FOP - p. <fo:p

<fo:block id="sec2" font-size="18pt" font-family="serif" line-height="20pt" space-before.optimum="20pt" space-after.optimum="14pt" >B)
Downloading FOP</fo:block>
<fo:block space-after.optimum="3pt" font-family="serif">The latest release version is <fo:inline font-style="italic" font-family="serif">FOP 12.0</fo:inline>
<fo:inline font-family="serif">
<fo:block space-after.optimum="3pt" font-family="serif">The latest release version is <fo:inline font-style="italic" font-family="serif">FOP
0.14</fo:inline> <fo:inline font-family="serif">
()
</fo:inline>. </fo:block>
<fo:block space-after.optimum="3pt" font-family="serif">NOTE: you do not have to unjar or unzip this jar file.</fo:block>
@@ -105,7 +105,7 @@ This is not the latest Fop documentation, but just an fo example. FOP - p. <fo:p
<fo:block space-after.optimum="3pt" font-family="serif">To run FOP from the command line, see Running FOP. If you are interested in
embedding FOP in a Java application of your own, see Embedding FOP.
</fo:block>
<fo:block space-after.optimum="3pt" font-family="serif">You can also download the <fo:inline font-style="italic" font-family="serif">source code v. 12.0</fo:inline>
<fo:block space-after.optimum="3pt" font-family="serif">You can also download the <fo:inline font-style="italic" font-family="serif">source code v. 0.14</fo:inline>
<fo:inline font-family="serif">
()
</fo:inline> as jar file</fo:block>

+ 15
- 0
src/codegen/properties.xml Näytä tiedosto

@@ -960,6 +960,21 @@
<default>auto</default>
</property>

<property>
<name>text-decoration</name>
<class-name>TextDecoration</class-name>
<inherited>false</inherited>
<datatype>
<enumeration>
<value const="NONE">none</value>
<value const="UNDERLINE">underline</value>
<value const="OVERLINE">overline</value>
<value const="LINE_THROUGH">line-through</value>
</enumeration>
</datatype>
<default>none</default>
</property>

<!-- svg properties, or should these be in another file -->
<property>
<name>requiredFeatures</name>

+ 13
- 2
src/org/apache/fop/fo/FOText.java Näytä tiedosto

@@ -76,7 +76,13 @@ public class FOText extends FONode {
int wrapOption;
int whiteSpaceTreatment;

protected FOText(char[] chars, int s, int e, FObj parent) {
// Textdecoration
protected boolean underlined = false;
protected boolean overlined = false;
protected boolean lineThrough = false;


public FOText(char[] chars, int s, int e, FObj parent) {
super(parent);
this.start = 0;
this.ca = new char[e - s];
@@ -85,6 +91,10 @@ public class FOText extends FONode {
this.length = e - s;
}

public void setUnderlined(boolean ul) {
this.underlined = ul;
}

public Status layout(Area area) throws FOPException {
if (!(area instanceof BlockArea)) {
MessageHandler.errorln("WARNING: text outside block area" + new String(ca, start, length));
@@ -121,7 +131,8 @@ public class FOText extends FONode {
wrapOption,
this.getLinkSet(),
whiteSpaceTreatment,
ca, this.marker, length);
ca, this.marker, length,
underlined);
if (this.marker == -1) {
this.marker = 0;
return new Status(Status.OK);

+ 1
- 0
src/org/apache/fop/fo/StandardPropertyListMapping.java Näytä tiedosto

@@ -165,6 +165,7 @@ public class StandardPropertyListMapping implements PropertyListMapping {
propertyTable.put("scaling",Scaling.maker());
propertyTable.put("vertical-align",VerticalAlign.maker());
propertyTable.put("overflow",Overflow.maker());
propertyTable.put("text-decoration",TextDecoration.maker());
builder.addPropertyList(uri, propertyTable);
}
}

+ 23
- 1
src/org/apache/fop/fo/flow/Inline.java Näytä tiedosto

@@ -55,6 +55,7 @@ package org.apache.fop.fo.flow;
import org.apache.fop.fo.*;
import org.apache.fop.layout.Area;
import org.apache.fop.apps.FOPException;
import org.apache.fop.fo.properties.*;

// Java
import java.util.Enumeration;
@@ -71,15 +72,36 @@ public class Inline extends FObjMixed {
public static FObj.Maker maker() {
return new Inline.Maker();
}

// Textdecoration
protected boolean underlined = false;
protected boolean overlined = false;
protected boolean lineThrough = false;

public Inline(FObj parent, PropertyList propertyList)
throws FOPException {
super(parent, propertyList);
this.name = "fo:inline";

int textDecoration =
this.properties.get("text-decoration").getEnum();

if (textDecoration == TextDecoration.UNDERLINE) {
this.underlined = true;
}

if (parent.getName().equals("fo:flow")) {
throw new FOPException("fo:inline can't be directly"
+ " under flow");
}

}

protected void addCharacters(char data[], int start, int length) {
FOText ft = new FOText(data,start,length, this);
ft.setUnderlined(underlined);
children.addElement(ft);
}

}

+ 2
- 1
src/org/apache/fop/fo/flow/PageNumber.java Näytä tiedosto

@@ -122,7 +122,8 @@ public class PageNumber extends FObj {
null,
whiteSpaceTreatment,
p.toCharArray(), 0,
p.length());
p.length(),
false);
return new Status(Status.OK);
}
}

+ 1
- 1
src/org/apache/fop/fo/flow/PageNumberCitation.java Näytä tiedosto

@@ -194,7 +194,7 @@ public class PageNumberCitation extends FObj {
pageNumber=idReferences.getPageNumber(refId);

if ( pageNumber!=null ) { // if we already know the page number
this.marker = ((BlockArea) area).addText(fs, red, green, blue, wrapOption, null, whiteSpaceTreatment, pageNumber.toCharArray(), 0, pageNumber.length());
this.marker = ((BlockArea) area).addText(fs, red, green, blue, wrapOption, null, whiteSpaceTreatment, pageNumber.toCharArray(), 0, pageNumber.length(), false);
}
else { // add pageNumberCitation to area to be resolved during rendering
this.marker = ((BlockArea) area).addPageNumberCitation(fs, red, green, blue, wrapOption, null, whiteSpaceTreatment, refId);

+ 3
- 3
src/org/apache/fop/layout/BlockArea.java Näytä tiedosto

@@ -139,7 +139,7 @@ public class BlockArea extends Area {
public int addText(FontState fontState, float red, float green,
float blue, int wrapOption, LinkSet ls,
int whiteSpaceTreatment, char data[],
int start, int end) {
int start, int end, boolean ul) {
int ts, te;
char[] ca;
@@ -161,7 +161,7 @@ public class BlockArea extends Area {
ls.setYOffset(currentHeight);
}

ts = this.currentLineArea.addText(ca, ts, te, ls);
ts = this.currentLineArea.addText(ca, ts, te, ls, ul);
this.hasLines = true;
while (ts != -1) {
@@ -182,7 +182,7 @@ public class BlockArea extends Area {
ls.setYOffset(currentHeight);
}

ts = this.currentLineArea.addText(ca, ts, te, ls);
ts = this.currentLineArea.addText(ca, ts, te, ls, ul);
}
return -1;
}

+ 15
- 0
src/org/apache/fop/layout/InlineArea.java Näytä tiedosto

@@ -58,6 +58,12 @@ public class InlineArea extends Area {
protected String pageNumberId=null;
private float red, green, blue;

// Textdecoration
protected boolean underlined = false;
protected boolean overlined = false;
protected boolean lineThrough = false;


public InlineArea(FontState fontState, float red, float green, float blue, String text, int width) {
super(fontState);
this.red = red;
@@ -90,4 +96,13 @@ public class InlineArea extends Area {
public String getPageNumberID() {
return pageNumberId;
}

public void setUnderlined(boolean ul) {
this.underlined = ul;
}

public boolean getUnderlined() {
return this.underlined;
}

}

+ 4
- 1
src/org/apache/fop/layout/LineArea.java Näytä tiedosto

@@ -175,7 +175,7 @@ public class LineArea extends Area {
}


public int addText(char odata[], int start, int end, LinkSet ls) {
public int addText(char odata[], int start, int end, LinkSet ls, boolean ul) {
boolean overrun = false;

wordStart = start;
@@ -274,6 +274,7 @@ public class LineArea extends Area {
String(data, wordStart,
wordLength),
wordWidth);
ia.setUnderlined(ul);
addChild(ia);
if (ls != null) {
Rectangle lr =
@@ -381,6 +382,8 @@ public class LineArea extends Area {
this.green, this.blue, new
String(data, wordStart,
wordLength), wordWidth);

pia.setUnderlined(ul);
if (ls != null) {
Rectangle lr =

+ 5
- 0
src/org/apache/fop/render/pdf/PDFRenderer.java Näytä tiedosto

@@ -541,6 +541,11 @@ public class PDFRenderer implements Renderer {
}
pdf = pdf.append(") Tj\n");

if (area.getUnderlined()) {
addLine(rx, bl - size/10, rx + area.getContentWidth(),
bl - size/10, size/14, theAreaColor);
}

currentStream.add(pdf.toString());

this.currentXPosition += area.getContentWidth();

Loading…
Peruuta
Tallenna