From: Steve Coffman Date: Thu, 19 Oct 2000 17:00:18 +0000 (+0000) Subject: Apply's Christian Geisert's text decoration (underline) patch. X-Git-Tag: pre-columns~153 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=a5fe0cc78f714f538bbffe324708eae8f2fa588e;p=xmlgraphics-fop.git 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 --- diff --git a/docs/examples/build.xml b/docs/examples/build.xml index 87678780e..1890466d3 100644 --- a/docs/examples/build.xml +++ b/docs/examples/build.xml @@ -52,6 +52,7 @@ + @@ -81,6 +82,8 @@ + + diff --git a/docs/examples/fo/readme.fo b/docs/examples/fo/readme.fo index 6da46eab6..9034b59ac 100644 --- a/docs/examples/fo/readme.fo +++ b/docs/examples/fo/readme.fo @@ -89,8 +89,8 @@ This is not the latest Fop documentation, but just an fo example. FOP - p. B) Downloading FOP - The latest release version is FOP 12.0 - + The latest release version is FOP +0.14 () . NOTE: you do not have to unjar or unzip this jar file. @@ -105,7 +105,7 @@ This is not the latest Fop documentation, but just an fo example. FOP - p. 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. - You can also download the source code v. 12.0 + You can also download the source code v. 0.14 () as jar file diff --git a/src/codegen/properties.xml b/src/codegen/properties.xml index 846210245..3cb8f935d 100644 --- a/src/codegen/properties.xml +++ b/src/codegen/properties.xml @@ -960,6 +960,21 @@ auto + + text-decoration + TextDecoration + false + + + none + underline + overline + line-through + + + none + + requiredFeatures diff --git a/src/org/apache/fop/fo/FOText.java b/src/org/apache/fop/fo/FOText.java index c8add0562..904c315cb 100644 --- a/src/org/apache/fop/fo/FOText.java +++ b/src/org/apache/fop/fo/FOText.java @@ -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); diff --git a/src/org/apache/fop/fo/StandardPropertyListMapping.java b/src/org/apache/fop/fo/StandardPropertyListMapping.java index c1d52d141..f7866f1bd 100644 --- a/src/org/apache/fop/fo/StandardPropertyListMapping.java +++ b/src/org/apache/fop/fo/StandardPropertyListMapping.java @@ -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); } } diff --git a/src/org/apache/fop/fo/flow/Inline.java b/src/org/apache/fop/fo/flow/Inline.java index 6a168d93d..efc831028 100644 --- a/src/org/apache/fop/fo/flow/Inline.java +++ b/src/org/apache/fop/fo/flow/Inline.java @@ -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); + } + } diff --git a/src/org/apache/fop/fo/flow/PageNumber.java b/src/org/apache/fop/fo/flow/PageNumber.java index 95bebb675..9e826791d 100644 --- a/src/org/apache/fop/fo/flow/PageNumber.java +++ b/src/org/apache/fop/fo/flow/PageNumber.java @@ -122,7 +122,8 @@ public class PageNumber extends FObj { null, whiteSpaceTreatment, p.toCharArray(), 0, - p.length()); + p.length(), + false); return new Status(Status.OK); } } diff --git a/src/org/apache/fop/fo/flow/PageNumberCitation.java b/src/org/apache/fop/fo/flow/PageNumberCitation.java index c437ed334..797c294cf 100644 --- a/src/org/apache/fop/fo/flow/PageNumberCitation.java +++ b/src/org/apache/fop/fo/flow/PageNumberCitation.java @@ -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); diff --git a/src/org/apache/fop/layout/BlockArea.java b/src/org/apache/fop/layout/BlockArea.java index af8f02134..3c6e40495 100644 --- a/src/org/apache/fop/layout/BlockArea.java +++ b/src/org/apache/fop/layout/BlockArea.java @@ -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; } diff --git a/src/org/apache/fop/layout/InlineArea.java b/src/org/apache/fop/layout/InlineArea.java index f55c6b9fc..c445cd0e7 100644 --- a/src/org/apache/fop/layout/InlineArea.java +++ b/src/org/apache/fop/layout/InlineArea.java @@ -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; + } + } diff --git a/src/org/apache/fop/layout/LineArea.java b/src/org/apache/fop/layout/LineArea.java index 223bb1326..6ce891051 100644 --- a/src/org/apache/fop/layout/LineArea.java +++ b/src/org/apache/fop/layout/LineArea.java @@ -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 = diff --git a/src/org/apache/fop/render/pdf/PDFRenderer.java b/src/org/apache/fop/render/pdf/PDFRenderer.java index 15757e8c0..b9a5e1eed 100644 --- a/src/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/org/apache/fop/render/pdf/PDFRenderer.java @@ -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();