]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Apply's Christian Geisert's text decoration (underline) patch.
authorSteve Coffman <gears@apache.org>
Thu, 19 Oct 2000 17:00:18 +0000 (17:00 +0000)
committerSteve Coffman <gears@apache.org>
Thu, 19 Oct 2000 17:00:18 +0000 (17:00 +0000)
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

12 files changed:
docs/examples/build.xml
docs/examples/fo/readme.fo
src/codegen/properties.xml
src/org/apache/fop/fo/FOText.java
src/org/apache/fop/fo/StandardPropertyListMapping.java
src/org/apache/fop/fo/flow/Inline.java
src/org/apache/fop/fo/flow/PageNumber.java
src/org/apache/fop/fo/flow/PageNumberCitation.java
src/org/apache/fop/layout/BlockArea.java
src/org/apache/fop/layout/InlineArea.java
src/org/apache/fop/layout/LineArea.java
src/org/apache/fop/render/pdf/PDFRenderer.java

index 87678780ec897cc47612ef25ca2d6cae3bc0300a..1890466d34b54562d2e36a69b49fe5f356fb2dc6 100644 (file)
@@ -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>
 
 
index 6da46eab6e52ea93533522f3f2c44f413cc0a75e..9034b59ac31c5a5c264fe2a6f3710586f09670e7 100644 (file)
@@ -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>
index 846210245ffc89f18d73cefd206eb7e79e7bed43..3cb8f935dda2574ed8a0c7d3681eae985e5465c7 100644 (file)
     <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>
index c8add05622bc5b564965f45d08fa8bf5961796a0..904c315cbb8a17f65ad85687d74f5c5dc6828ce8 100644 (file)
@@ -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);
index c1d52d1419df1d12402bd4e4bb1b84a78ac94b29..f7866f1bd127c83041373e40e8b1b232f9990fc3 100644 (file)
@@ -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); 
     }
 }
index 6a168d93d534f28663efe2c54a1c09d1b41ccab6..efc831028273b94b5ead801c329d27560d426615 100644 (file)
@@ -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);
+  }
+
 }
index 95bebb67518e14eaf3675e751124fb3934a2e639..9e826791dc7631d05d2c71464e4ec3ef310a550b 100644 (file)
@@ -122,7 +122,8 @@ public class PageNumber extends FObj {
                                                 null,
                                                 whiteSpaceTreatment,
                                                 p.toCharArray(), 0,
-                                                p.length());
+                                                p.length(),
+                                                false);
        return new Status(Status.OK);
     }
 }
index c437ed334a1be16848b539951bffa46e0267407e..797c294cfa6a547fcacd0288305749376aff1279 100644 (file)
@@ -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);        
index af8f021345db8cfa3db33e40b1c097583ef2886d..3c6e40495c1fcbbb17c6d52238f2257008fe1035 100644 (file)
@@ -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;
     }
index f55c6b9fc09954311a5858bfc0c847ba01fee1e3..c445cd0e7cd6f7b00d30403adb5908c535e409ac 100644 (file)
@@ -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;
+    }
+
 }
index 223bb1326d58c0d635e5575029f69a270945987c..6ce891051e832241c02f4c58d6db7541be23b0b4 100644 (file)
@@ -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 =
index 15757e8c0c195515205fa8e5cb8b831b65deabce..b9a5e1eedca14dc8eeb67924950cdb38b3730304 100644 (file)
@@ -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();