From cede15f773855ab8e6feb9338e05b38fee77dc4f Mon Sep 17 00:00:00 2001 From: Keiron Liddle Date: Wed, 9 Jan 2002 11:32:57 +0000 Subject: [PATCH] adds inheritance for the text-decoration property from parent inline or block elements and fixes a bug with non-breaking spaces (but not all) Submitted by: Christian Geisert git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/fop-0_20_2-maintain@194620 13f79535-47bb-0310-9956-ffa450edef68 --- docs/examples/fo/textdeko.fo | 32 ++++++++++++-- src/org/apache/fop/fo/FObjMixed.java | 4 ++ src/org/apache/fop/fo/PropertyManager.java | 44 ++++++++++++++++---- src/org/apache/fop/fo/flow/Block.java | 2 +- src/org/apache/fop/fo/flow/Inline.java | 2 +- src/org/apache/fop/render/PrintRenderer.java | 4 ++ 6 files changed, 74 insertions(+), 14 deletions(-) diff --git a/docs/examples/fo/textdeko.fo b/docs/examples/fo/textdeko.fo index 3e8fba45b..36cd28fda 100644 --- a/docs/examples/fo/textdeko.fo +++ b/docs/examples/fo/textdeko.fo @@ -59,7 +59,7 @@ The "text-decoration"-property describes decorations that are added to the text of an element. If the property is specified for a block-level element, it should affect all inline-level descendants - of the element (does not work yet!). + of the element. If it is specified for (or affects) an inline-level element, it affects all boxes generated by the element. @@ -246,12 +246,38 @@ What about underlining of whitespace only ? - A whole block should work now. - And again some more Text to get at least two lines. + And again some more text to get at least two lines. + + + + + + + Let's see if all inline-areas are affected ... + + + + + + This is a workaround for + + the combination of + different text-decoration values... + + + + + + + Enter your name here: + _        +               +               + diff --git a/src/org/apache/fop/fo/FObjMixed.java b/src/org/apache/fop/fo/FObjMixed.java index ef0b4e691..e34f7cca3 100644 --- a/src/org/apache/fop/fo/FObjMixed.java +++ b/src/org/apache/fop/fo/FObjMixed.java @@ -36,6 +36,10 @@ public class FObjMixed extends FObj { super(parent, propertyList); } + public TextState getTextState() { + return ts; + } + protected void addCharacters(char data[], int start, int length) { // addChild(new FOText(data, start, length, this)); FOText ft = new FOText(data, start, length, this); diff --git a/src/org/apache/fop/fo/PropertyManager.java b/src/org/apache/fop/fo/PropertyManager.java index 300f10546..f2d5a3705 100644 --- a/src/org/apache/fop/fo/PropertyManager.java +++ b/src/org/apache/fop/fo/PropertyManager.java @@ -250,24 +250,50 @@ public class PropertyManager { return props; } - public TextState getTextDecoration() throws FOPException { + public TextState getTextDecoration(FObj parent) throws FOPException { + + // TextState from parent Block/Inline + TextState tsp = null; + boolean found = false; + + do { + String fname = parent.getName(); + if (fname.equals("fo:flow") || fname.equals("fo:static-content")) { + found = true; + } else if (fname.equals("fo:block") || fname.equals("fo:inline")) { + FObjMixed fom = (FObjMixed) parent; + tsp = fom.getTextState(); + found = true; + } + parent = parent.getParent(); + } while (!found); + TextState ts = new TextState(); + if (tsp != null) { + ts.setUnderlined(tsp.getUnderlined()); + ts.setOverlined(tsp.getOverlined()); + ts.setLineThrough(tsp.getLineThrough()); + } + int textDecoration = this.properties.get("text-decoration").getEnum(); - switch (textDecoration) { - case TextDecoration.UNDERLINE: + if (textDecoration == TextDecoration.UNDERLINE) { ts.setUnderlined(true); - break; - case TextDecoration.OVERLINE: + } + if (textDecoration == TextDecoration.OVERLINE) { ts.setOverlined(true); - break; - case TextDecoration.LINE_THROUGH: + } + if (textDecoration == TextDecoration.LINE_THROUGH) { ts.setLineThrough(true); - break; - case TextDecoration.NONE: + } + if (textDecoration == TextDecoration.NO_UNDERLINE) { ts.setUnderlined(false); + } + if (textDecoration == TextDecoration.NO_OVERLINE) { ts.setOverlined(false); + } + if (textDecoration == TextDecoration.NO_LINE_THROUGH) { ts.setLineThrough(false); } diff --git a/src/org/apache/fop/fo/flow/Block.java b/src/org/apache/fop/fo/flow/Block.java index 1edbed351..f126193fb 100644 --- a/src/org/apache/fop/fo/flow/Block.java +++ b/src/org/apache/fop/fo/flow/Block.java @@ -72,7 +72,7 @@ public class Block extends FObjMixed { super(parent, propertyList); this.name = "fo:block"; this.span = this.properties.get("span").getEnum(); - ts = propMgr.getTextDecoration(); + ts = propMgr.getTextDecoration(parent); } public Status layout(Area area) throws FOPException { diff --git a/src/org/apache/fop/fo/flow/Inline.java b/src/org/apache/fop/fo/flow/Inline.java index cfa1f1c79..d21c815b4 100644 --- a/src/org/apache/fop/fo/flow/Inline.java +++ b/src/org/apache/fop/fo/flow/Inline.java @@ -74,7 +74,7 @@ public class Inline extends FObjMixed { // this.properties.get("z-index"); // Text Decoration Properties - ts = propMgr.getTextDecoration(); + ts = propMgr.getTextDecoration(parent); } diff --git a/src/org/apache/fop/render/PrintRenderer.java b/src/org/apache/fop/render/PrintRenderer.java index e6f4c6101..b3294bb25 100644 --- a/src/org/apache/fop/render/PrintRenderer.java +++ b/src/org/apache/fop/render/PrintRenderer.java @@ -332,6 +332,8 @@ public abstract class PrintRenderer extends AbstractRenderer { prevUnderlineXEndPos + space.getSize(), prevUnderlineYEndPos, prevUnderlineSize, prevUnderlineColor); + // save position for a following InlineSpace + prevUnderlineXEndPos = prevUnderlineXEndPos + space.getSize(); } } if (space.getOverlined()) { @@ -340,6 +342,7 @@ public abstract class PrintRenderer extends AbstractRenderer { prevOverlineXEndPos + space.getSize(), prevOverlineYEndPos, prevOverlineSize, prevOverlineColor); + prevOverlineXEndPos = prevOverlineXEndPos + space.getSize(); } } if (space.getLineThrough()) { @@ -348,6 +351,7 @@ public abstract class PrintRenderer extends AbstractRenderer { prevLineThroughXEndPos + space.getSize(), prevLineThroughYEndPos, prevLineThroughSize, prevLineThroughColor); + prevLineThroughXEndPos = prevLineThroughXEndPos + space.getSize(); } } } -- 2.39.5