diff options
-rw-r--r-- | STATUS | 3 | ||||
-rw-r--r-- | src/codegen/properties.xml | 7 | ||||
-rw-r--r-- | src/org/apache/fop/datatypes/ColorType.java | 14 | ||||
-rw-r--r-- | src/org/apache/fop/fo/PropertyListBuilder.java | 1 | ||||
-rw-r--r-- | src/org/apache/fop/fo/flow/Block.java | 9 | ||||
-rw-r--r-- | src/org/apache/fop/fo/flow/DisplayGraphic.java | 4 | ||||
-rw-r--r-- | src/org/apache/fop/fo/flow/DisplayRule.java | 17 | ||||
-rw-r--r-- | src/org/apache/fop/fo/flow/Table.java | 6 | ||||
-rw-r--r-- | src/org/apache/fop/fo/flow/TableBody.java | 6 | ||||
-rw-r--r-- | src/org/apache/fop/fo/flow/TableCell.java | 6 | ||||
-rw-r--r-- | src/org/apache/fop/fo/flow/TableRow.java | 6 | ||||
-rw-r--r-- | src/org/apache/fop/layout/Area.java | 13 | ||||
-rw-r--r-- | src/org/apache/fop/render/pdf/PDFRenderer.java | 13 |
13 files changed, 97 insertions, 8 deletions
@@ -12,7 +12,8 @@ Get images working [DONE]Incorporate Eric Schaeffer's fix to tables in static-content [DONE] Incorporate Kelly Campell's fixes to GifJpegImage [PARTIAL] Incorporate Eric Schaeffer's further table fixes -Incorporate Eric Schaeffer's background colour implementation +[DONE] Incorporate Eric Schaeffer's background colour implementation + (actually used different approach with background colour as trait) Other Bugs to fix: diff --git a/src/codegen/properties.xml b/src/codegen/properties.xml index 3c18505c0..647adf33b 100644 --- a/src/codegen/properties.xml +++ b/src/codegen/properties.xml @@ -323,5 +323,12 @@ </datatype> <default>false</default> </property> + <property> + <name>background-color</name> + <class-name>BackgroundColor</class-name> + <inherited>false</inherited> + <datatype>ColorType</datatype> + <default>transparent</default> + </property> </property-list> diff --git a/src/org/apache/fop/datatypes/ColorType.java b/src/org/apache/fop/datatypes/ColorType.java index 2049a8f7c..5c99d044a 100644 --- a/src/org/apache/fop/datatypes/ColorType.java +++ b/src/org/apache/fop/datatypes/ColorType.java @@ -22,7 +22,7 @@ Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. - 4. The names "Fop" and "Apache Software Foundation" must not be used to + 4. The names "FOP" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. @@ -64,6 +64,9 @@ public class ColorType { /** the blue component */ protected float blue; + /** the alpha component */ + protected float alpha = 0; + /** * set the colour given a particular String specifying either a * colour name or #RGB or #RRGGBB @@ -163,6 +166,11 @@ public class ColorType { this.red = 0.7f; this.green = 0.5f; this.blue = 0; + } else if (value.toLowerCase().equals("transparent")) { + this.red = 0; + this.green = 0; + this.blue = 0; + this.alpha = 1; } else { this.red = 0; this.green = 0; @@ -183,4 +191,8 @@ public class ColorType { public float red() { return this.red; } + + public float alpha() { + return this.alpha; + } } diff --git a/src/org/apache/fop/fo/PropertyListBuilder.java b/src/org/apache/fop/fo/PropertyListBuilder.java index df31a1767..1bd425ce7 100644 --- a/src/org/apache/fop/fo/PropertyListBuilder.java +++ b/src/org/apache/fop/fo/PropertyListBuilder.java @@ -104,6 +104,7 @@ public class PropertyListBuilder { propertyTable.put("href",HRef.maker()); propertyTable.put("column-width",ColumnWidth.maker()); propertyTable.put("keep-with-next",KeepWithNext.maker()); + propertyTable.put("background-color",BackgroundColor.maker()); propertyTable.put("height",SVGLength.maker()); propertyTable.put("width",SVGLength.maker()); diff --git a/src/org/apache/fop/fo/flow/Block.java b/src/org/apache/fop/fo/flow/Block.java index 6b22f17a7..8742b8fcf 100644 --- a/src/org/apache/fop/fo/flow/Block.java +++ b/src/org/apache/fop/fo/flow/Block.java @@ -55,6 +55,7 @@ package org.apache.fop.fo.flow; import org.apache.fop.fo.*; import org.apache.fop.fo.properties.*; import org.apache.fop.layout.*; +import org.apache.fop.datatypes.*; import org.apache.fop.apps.FOPException; public class Block extends FObjMixed { @@ -82,6 +83,7 @@ public class Block extends FObjMixed { int spaceAfter; int textIndent; int keepWithNext; + ColorType backgroundColor; BlockArea blockArea; @@ -133,6 +135,8 @@ public class Block extends FObjMixed { this.properties.get("text-indent").getLength().mvalue(); this.keepWithNext = this.properties.get("keep-with-next").getEnum(); + this.backgroundColor = + this.properties.get("background-color").getColorType(); if (area instanceof BlockArea) { area.end(); @@ -150,8 +154,8 @@ public class Block extends FObjMixed { if (this.isInTableCell) { startIndent += forcedStartOffset; - endIndent = area.getAllocationWidth() - startIndent - - forcedWidth; + endIndent = area.getAllocationWidth() - forcedWidth - + forcedStartOffset; } this.marker = 0; @@ -182,6 +186,7 @@ public class Block extends FObjMixed { area.spaceLeft(), startIndent, endIndent, textIndent, align, alignLast, lineHeight); blockArea.setPage(area.getPage()); + blockArea.setBackgroundColor(backgroundColor); blockArea.start(); int numChildren = this.children.size(); diff --git a/src/org/apache/fop/fo/flow/DisplayGraphic.java b/src/org/apache/fop/fo/flow/DisplayGraphic.java index 921eb99b3..0cacbfff3 100644 --- a/src/org/apache/fop/fo/flow/DisplayGraphic.java +++ b/src/org/apache/fop/fo/flow/DisplayGraphic.java @@ -144,8 +144,8 @@ public class DisplayGraphic extends FObj { if (this.isInTableCell) { startIndent += forcedStartOffset; - endIndent = area.getAllocationWidth() - startIndent - - forcedWidth; + endIndent = area.getAllocationWidth() - forcedWidth - + forcedStartOffset; } this.marker = 0; diff --git a/src/org/apache/fop/fo/flow/DisplayRule.java b/src/org/apache/fop/fo/flow/DisplayRule.java index fb8467b3c..383aed223 100644 --- a/src/org/apache/fop/fo/flow/DisplayRule.java +++ b/src/org/apache/fop/fo/flow/DisplayRule.java @@ -115,6 +115,23 @@ public class DisplayRule extends FObj { area.addDisplaySpace(spaceBefore); } + if (this.isInLabel) { + startIndent += bodyIndent; + endIndent += (area.getAllocationWidth() - + distanceBetweenStarts - startIndent) + + labelSeparation; + } + + if (this.isInListBody) { + startIndent += bodyIndent + distanceBetweenStarts; + } + + if (this.isInTableCell) { + startIndent += forcedStartOffset; + endIndent += area.getAllocationWidth() - forcedWidth - + forcedStartOffset; + } + RuleArea ruleArea = new RuleArea(fs, area.getAllocationWidth(), area.spaceLeft(), diff --git a/src/org/apache/fop/fo/flow/Table.java b/src/org/apache/fop/fo/flow/Table.java index 7853ea716..cca3e44d2 100644 --- a/src/org/apache/fop/fo/flow/Table.java +++ b/src/org/apache/fop/fo/flow/Table.java @@ -55,6 +55,7 @@ package org.apache.fop.fo.flow; import org.apache.fop.fo.*; import org.apache.fop.fo.properties.*; import org.apache.fop.layout.*; +import org.apache.fop.datatypes.*; import org.apache.fop.apps.FOPException; // Java @@ -80,6 +81,7 @@ public class Table extends FObj { int endIndent; int spaceBefore; int spaceAfter; + ColorType backgroundColor; Vector columns = new Vector(); int currentColumnNumber = 0; @@ -120,6 +122,9 @@ public class Table extends FObj { this.properties.get("space-before.optimum").getLength().mvalue(); this.spaceAfter = this.properties.get("space-after.optimum").getLength().mvalue(); + this.backgroundColor = + this.properties.get("background-color").getColorType(); + if (area instanceof BlockArea) { area.end(); } @@ -152,6 +157,7 @@ public class Table extends FObj { area.spaceLeft(), startIndent, endIndent, 0, 0, 0, 0); blockArea.setPage(area.getPage()); + blockArea.setBackgroundColor(backgroundColor); blockArea.start(); // added by Eric Schaeffer diff --git a/src/org/apache/fop/fo/flow/TableBody.java b/src/org/apache/fop/fo/flow/TableBody.java index 82d72f3c7..f7d64f8fe 100644 --- a/src/org/apache/fop/fo/flow/TableBody.java +++ b/src/org/apache/fop/fo/flow/TableBody.java @@ -54,6 +54,7 @@ package org.apache.fop.fo.flow; // FOP import org.apache.fop.fo.*; import org.apache.fop.fo.properties.*; +import org.apache.fop.datatypes.*; import org.apache.fop.layout.*; import org.apache.fop.apps.FOPException; @@ -78,6 +79,7 @@ public class TableBody extends FObj { int endIndent; int spaceBefore; int spaceAfter; + ColorType backgroundColor; Vector columns; @@ -117,6 +119,9 @@ public class TableBody extends FObj { this.properties.get("space-before.optimum").getLength().mvalue(); this.spaceAfter = this.properties.get("space-after.optimum").getLength().mvalue(); + this.backgroundColor = + this.properties.get("background-color").getColorType(); + if (area instanceof BlockArea) { area.end(); } @@ -138,6 +143,7 @@ public class TableBody extends FObj { area.spaceLeft(), startIndent, endIndent, 0, 0, 0, 0); blockArea.setPage(area.getPage()); + blockArea.setBackgroundColor(backgroundColor); blockArea.start(); int numChildren = this.children.size(); diff --git a/src/org/apache/fop/fo/flow/TableCell.java b/src/org/apache/fop/fo/flow/TableCell.java index 0a5f69b25..d40e2e92b 100644 --- a/src/org/apache/fop/fo/flow/TableCell.java +++ b/src/org/apache/fop/fo/flow/TableCell.java @@ -55,6 +55,7 @@ import org.apache.fop.fo.*; import org.apache.fop.fo.properties.*; import org.apache.fop.layout.*; import org.apache.fop.apps.FOPException; +import org.apache.fop.datatypes.*; public class TableCell extends FObj { @@ -74,6 +75,7 @@ public class TableCell extends FObj { int endIndent; int spaceBefore; int spaceAfter; + ColorType backgroundColor; protected int startOffset; protected int width; @@ -119,6 +121,9 @@ public class TableCell extends FObj { this.properties.get("space-before.optimum").getLength().mvalue(); this.spaceAfter = this.properties.get("space-after.optimum").getLength().mvalue(); + this.backgroundColor = + this.properties.get("background-color").getColorType(); + if (area instanceof BlockArea) { area.end(); } @@ -140,6 +145,7 @@ public class TableCell extends FObj { area.spaceLeft(), startIndent, endIndent, 0, 0, 0, 0); blockArea.setPage(area.getPage()); + blockArea.setBackgroundColor(backgroundColor); blockArea.start(); // added by Eric Schaeffer diff --git a/src/org/apache/fop/fo/flow/TableRow.java b/src/org/apache/fop/fo/flow/TableRow.java index bd015378c..3c8b53ce6 100644 --- a/src/org/apache/fop/fo/flow/TableRow.java +++ b/src/org/apache/fop/fo/flow/TableRow.java @@ -54,6 +54,7 @@ package org.apache.fop.fo.flow; // FOP import org.apache.fop.fo.*; import org.apache.fop.fo.properties.*; +import org.apache.fop.datatypes.*; import org.apache.fop.layout.*; import org.apache.fop.apps.FOPException; @@ -78,6 +79,7 @@ public class TableRow extends FObj { int endIndent; int spaceBefore; int spaceAfter; + ColorType backgroundColor; int widthOfCellsSoFar = 0; int largestCellHeight = 0; @@ -120,6 +122,9 @@ public class TableRow extends FObj { this.properties.get("space-before.optimum").getLength().mvalue(); this.spaceAfter = this.properties.get("space-after.optimum").getLength().mvalue(); + this.backgroundColor = + this.properties.get("background-color").getColorType(); + if (area instanceof BlockArea) { area.end(); } @@ -141,6 +146,7 @@ public class TableRow extends FObj { area.spaceLeft(), startIndent, endIndent, 0, 0, 0, 0); blockArea.setPage(area.getPage()); + blockArea.setBackgroundColor(backgroundColor); blockArea.start(); int numChildren = this.children.size(); diff --git a/src/org/apache/fop/layout/Area.java b/src/org/apache/fop/layout/Area.java index d76045a42..dff0fb5e7 100644 --- a/src/org/apache/fop/layout/Area.java +++ b/src/org/apache/fop/layout/Area.java @@ -51,6 +51,9 @@ package org.apache.fop.layout; +// FOP +import org.apache.fop.datatypes.*; + // Java import java.util.Vector; @@ -77,6 +80,8 @@ abstract public class Area extends Box { /* the page this area is on */ protected Page page; + protected ColorType backgroundColor; + public Area (FontState fontState) { this.fontState = fontState; } @@ -137,6 +142,10 @@ abstract public class Area extends Box { return this.page; } + public ColorType getBackgroundColor() { + return this.backgroundColor; + } + public void increaseHeight(int amount) { this.currentHeight += amount; } @@ -154,6 +163,10 @@ abstract public class Area extends Box { this.page = page; } + public void setBackgroundColor(ColorType bgColor) { + this.backgroundColor = bgColor; + } + public int spaceLeft() { return maxHeight - currentHeight; } diff --git a/src/org/apache/fop/render/pdf/PDFRenderer.java b/src/org/apache/fop/render/pdf/PDFRenderer.java index b6976fba3..e9ef2b6c8 100644 --- a/src/org/apache/fop/render/pdf/PDFRenderer.java +++ b/src/org/apache/fop/render/pdf/PDFRenderer.java @@ -22,7 +22,7 @@ Alternately, this acknowledgment may appear in the software itself, if and wherever such third-party acknowledgments normally appear. - 4. The names "Fop" and "Apache Software Foundation" must not be used to + 4. The names "FOP" and "Apache Software Foundation" must not be used to endorse or promote products derived from this software without prior written permission. For written permission, please contact apache@apache.org. @@ -48,6 +48,7 @@ Software Foundation, please see <http://www.apache.org/>. */ + package org.apache.fop.render.pdf; // FOP @@ -55,6 +56,7 @@ import org.apache.fop.render.Renderer; import org.apache.fop.image.ImageArea; import org.apache.fop.image.FopImage; import org.apache.fop.layout.*; +import org.apache.fop.datatypes.*; import org.apache.fop.svg.*; import org.apache.fop.pdf.*; @@ -123,7 +125,8 @@ public class PDFRenderer implements Renderer { * @param areaTree the laid-out area tree * @param writer the PrintWriter to write the PDF with */ - public void render(AreaTree areaTree, PrintWriter writer) throws IOException { + public void render(AreaTree areaTree, PrintWriter writer) + throws IOException { System.err.println("rendering areas to PDF"); this.pdfResources = this.pdfDoc.getResources(); Enumeration e = areaTree.getPages().elements(); @@ -233,6 +236,12 @@ public class PDFRenderer implements Renderer { int ry = this.currentYPosition; int w = area.getContentWidth(); int h = area.getHeight(); + ColorType bg = area.getBackgroundColor(); + if (bg.alpha() == 0) { + this.addRect(rx, ry, w, -h, + bg.red(), bg.green(), bg.blue(), + bg.red(), bg.green(), bg.blue()); + } Enumeration e = area.getChildren().elements(); while (e.hasMoreElements()) { Box b = (Box) e.nextElement(); |