jeremias 2005/01/25 02:55:48 Modified: src/java/org/apache/fop/fo/flow PageNumber.java Character.java Inline.java PageNumberCitation.java src/java/org/apache/fop/fo/properties ListProperty.java GenericShorthandParser.java Property.java src/java/org/apache/fop/fo PropertyList.java FOPropertyMapping.java FOText.java src/java/org/apache/fop/layoutmgr TraitSetter.java CharacterLayoutManager.java TextLayoutManager.java PageNumberCitationLayoutManager.java PageNumberLayoutManager.java src/java/org/apache/fop/render/pdf PDFRenderer.java src/java/org/apache/fop/render/rtf TextAttributesConverter.java src/java/org/apache/fop/area/inline InlineArea.java Added: src/java/org/apache/fop/fo/properties TextDecorationProperty.java CommonTextDecoration.java Log: First version of text-decoration support (no colors, yet, PDF rendering may not be optimal, yet, but the rest seems to work) This change may kill what text-decoration support already was in the RTF renderer. This will need to be fixed later. Some javadoc and style touch-ups. Revision Changes Path 1.48 +12 -15 xml-fop/src/java/org/apache/fop/fo/flow/PageNumber.java Index: PageNumber.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/PageNumber.java,v retrieving revision 1.47 retrieving revision 1.48 diff -u -r1.47 -r1.48 --- PageNumber.java 24 Dec 2004 12:06:26 -0000 1.47 +++ PageNumber.java 25 Jan 2005 10:55:46 -0000 1.48 @@ -1,5 +1,5 @@ /* - * Copyright 1999-2004 The Apache Software Foundation. + * Copyright 1999-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,9 +18,6 @@ package org.apache.fop.fo.flow; -// Java -import java.util.List; - import org.xml.sax.Locator; import org.apache.fop.apps.FOPException; @@ -35,9 +32,9 @@ import org.apache.fop.fo.properties.CommonFont; import org.apache.fop.fo.properties.CommonMarginInline; import org.apache.fop.fo.properties.CommonRelativePosition; +import org.apache.fop.fo.properties.CommonTextDecoration; import org.apache.fop.fo.properties.KeepProperty; import org.apache.fop.fo.properties.SpaceProperty; -import org.apache.fop.layoutmgr.PageNumberLayoutManager; /** * Class modelling the fo:page-number object. @@ -61,7 +58,8 @@ private Length lineHeight; private int scoreSpaces; private Length textAltitude; - private int textDecoration; + /** Holds the text decoration values. May be null */ + private CommonTextDecoration textDecoration; private Length textDepth; // private ToBeImplementedProperty textShadow; private int textTransform; @@ -98,7 +96,7 @@ lineHeight = pList.get(PR_LINE_HEIGHT).getLength(); scoreSpaces = pList.get(PR_SCORE_SPACES).getEnum(); textAltitude = pList.get(PR_TEXT_ALTITUDE).getLength(); - textDecoration = pList.get(PR_TEXT_DECORATION).getEnum(); + textDecoration = pList.getTextDecorationProps(); textDepth = pList.get(PR_TEXT_DEPTH).getLength(); // textShadow = pList.get(PR_TEXT_SHADOW); textTransform = pList.get(PR_TEXT_TRANSFORM).getEnum(); @@ -146,20 +144,13 @@ } /** - * Return the "id" property. + * @return the "id" property. */ public String getId() { return id; } /** - * Return the "text-decoration" property. - */ - public int getTextDecoration() { - return textDecoration; - } - - /** * @see org.apache.fop.fo.FONode#getName() */ public String getName() { @@ -172,4 +163,10 @@ public int getNameId() { return FO_PAGE_NUMBER; } + + /** @return the "text-decoration" property. */ + public CommonTextDecoration getTextDecoration() { + return textDecoration; + } + } 1.32 +18 -21 xml-fop/src/java/org/apache/fop/fo/flow/Character.java Index: Character.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/Character.java,v retrieving revision 1.31 retrieving revision 1.32 diff -u -r1.31 -r1.32 --- Character.java 24 Dec 2004 12:06:26 -0000 1.31 +++ Character.java 25 Jan 2005 10:55:46 -0000 1.32 @@ -1,5 +1,5 @@ /* - * Copyright 1999-2004 The Apache Software Foundation. + * Copyright 1999-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,9 +18,6 @@ package org.apache.fop.fo.flow; -// Java -import java.util.List; - import org.xml.sax.Locator; import org.apache.fop.apps.FOPException; @@ -38,9 +35,9 @@ import org.apache.fop.fo.properties.CommonHyphenation; import org.apache.fop.fo.properties.CommonMarginInline; import org.apache.fop.fo.properties.CommonRelativePosition; +import org.apache.fop.fo.properties.CommonTextDecoration; import org.apache.fop.fo.properties.KeepProperty; import org.apache.fop.fo.properties.Property; -import org.apache.fop.layoutmgr.CharacterLayoutManager; /** * This class represents the flow object 'fo:character'. Its use is defined by @@ -81,7 +78,8 @@ private Length lineHeight; private int scoreSpaces; private int suppressAtLineBreak; - private int textDecoration; + /** Holds the text decoration values. May be null */ + private CommonTextDecoration textDecoration; // private ToBeImplementedProperty textShadow; private int textTransform; private int verticalAlign; @@ -130,7 +128,7 @@ lineHeight = pList.get(PR_LINE_HEIGHT).getLength(); scoreSpaces = pList.get(PR_SCORE_SPACES).getEnum(); suppressAtLineBreak = pList.get(PR_SUPPRESS_AT_LINE_BREAK).getEnum(); - textDecoration = pList.get(PR_TEXT_DECORATION).getEnum(); + textDecoration = pList.getTextDecorationProps(); // textShadow = pList.get(PR_TEXT_SHADOW); textTransform = pList.get(PR_TEXT_TRANSFORM).getEnum(); verticalAlign = pList.get(PR_VERTICAL_ALIGN).getEnum(); @@ -164,70 +162,68 @@ } /** - * Return the Common Border, Padding, and Background Properties. + * @return the Common Border, Padding, and Background Properties. */ public CommonBorderPaddingBackground getCommonBorderPaddingBackground() { return commonBorderPaddingBackground; } /** - * Return the Common Font Properties. + * @return the Common Font Properties. */ public CommonFont getCommonFont() { return commonFont; } /** - * Return the Common Hyphenation Properties. + * @return the Common Hyphenation Properties. */ public CommonHyphenation getCommonHyphenation() { return commonHyphenation; } /** - * Return the "character" property. + * @return the "character" property. */ public char getCharacter() { return character; } /** - * Return the "color" property. + * @return the "color" property. */ public ColorType getColor() { return color; } /** - * Return the "id" property. + * @return the "id" property. */ public String getId() { return id; } /** - * Return the "letter-spacing" property. + * @return the "letter-spacing" property. */ public Property getLetterSpacing() { return letterSpacing; } - /** - * Return the "text-decoration" property. - */ - public int getTextDecoration() { + /** @return the "text-decoration" property. */ + public CommonTextDecoration getTextDecoration() { return textDecoration; } - + /** - * Return the "word-spacing" property. + * @return the "word-spacing" property. */ public Property getWordSpacing() { return wordSpacing; } /** - * Return the "vertical-align" property. + * @return the "vertical-align" property. */ public int getVerticalAlign() { return verticalAlign; @@ -246,4 +242,5 @@ public int getNameId() { return FO_CHARACTER; } + } 1.38 +2 -13 xml-fop/src/java/org/apache/fop/fo/flow/Inline.java Index: Inline.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/Inline.java,v retrieving revision 1.37 retrieving revision 1.38 diff -u -r1.37 -r1.38 --- Inline.java 24 Dec 2004 12:06:26 -0000 1.37 +++ Inline.java 25 Jan 2005 10:55:46 -0000 1.38 @@ -1,5 +1,5 @@ /* - * Copyright 1999-2004 The Apache Software Foundation. + * Copyright 1999-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,8 +18,6 @@ package org.apache.fop.fo.flow; -import java.util.List; - import org.xml.sax.Locator; import org.apache.fop.apps.FOPException; @@ -30,9 +28,9 @@ import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.ValidationException; import org.apache.fop.fo.properties.CommonRelativePosition; +import org.apache.fop.fo.properties.CommonTextDecoration; import org.apache.fop.fo.properties.KeepProperty; import org.apache.fop.fo.properties.LengthRangeProperty; -import org.apache.fop.layoutmgr.InlineLayoutManager; /** * Class modelling the fo:inline formatting object. @@ -52,7 +50,6 @@ private KeepProperty keepTogether; private KeepProperty keepWithNext; private KeepProperty keepWithPrevious; - private int textDecoration; private int verticalAlign; private Length width; private int wrapOption; @@ -86,7 +83,6 @@ keepTogether = pList.get(PR_KEEP_TOGETHER).getKeep(); keepWithNext = pList.get(PR_KEEP_WITH_NEXT).getKeep(); keepWithPrevious = pList.get(PR_KEEP_WITH_PREVIOUS).getKeep(); - textDecoration = pList.get(PR_TEXT_DECORATION).getEnum(); verticalAlign = pList.get(PR_VERTICAL_ALIGN).getEnum(); width = pList.get(PR_WIDTH).getLength(); wrapOption = pList.get(PR_WRAP_OPTION).getEnum(); @@ -158,13 +154,6 @@ */ public String getId() { return id; - } - - /** - * Return the "text-decoration" property. - */ - public int getTextDecoration() { - return textDecoration; } /** 1.45 +10 -7 xml-fop/src/java/org/apache/fop/fo/flow/PageNumberCitation.java Index: PageNumberCitation.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/flow/PageNumberCitation.java,v retrieving revision 1.44 retrieving revision 1.45 diff -u -r1.44 -r1.45 --- PageNumberCitation.java 24 Dec 2004 12:06:26 -0000 1.44 +++ PageNumberCitation.java 25 Jan 2005 10:55:46 -0000 1.45 @@ -1,5 +1,5 @@ /* - * Copyright 1999-2004 The Apache Software Foundation. + * Copyright 1999-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,9 +18,6 @@ package org.apache.fop.fo.flow; -// Java -import java.util.List; - import org.xml.sax.Locator; import org.apache.fop.apps.FOPException; @@ -35,9 +32,9 @@ import org.apache.fop.fo.properties.CommonFont; import org.apache.fop.fo.properties.CommonMarginInline; import org.apache.fop.fo.properties.CommonRelativePosition; +import org.apache.fop.fo.properties.CommonTextDecoration; import org.apache.fop.fo.properties.KeepProperty; import org.apache.fop.fo.properties.SpaceProperty; -import org.apache.fop.layoutmgr.PageNumberCitationLayoutManager; /** * Class modelling the fo:page-number-citation object. @@ -65,7 +62,8 @@ private String refId; private int scoreSpaces; private Length textAltitude; - private int textDecoration; + /** Holds the text decoration values. May be null */ + private CommonTextDecoration textDecoration; private Length textDepth; // private ToBeImplementedProperty textShadow; private int textTransform; @@ -103,7 +101,7 @@ refId = pList.get(PR_REF_ID).getString(); scoreSpaces = pList.get(PR_SCORE_SPACES).getEnum(); textAltitude = pList.get(PR_TEXT_ALTITUDE).getLength(); - textDecoration = pList.get(PR_TEXT_DECORATION).getEnum(); + textDecoration = pList.getTextDecorationProps(); textDepth = pList.get(PR_TEXT_DEPTH).getLength(); // textShadow = pList.get(PR_TEXT_SHADOW); textTransform = pList.get(PR_TEXT_TRANSFORM).getEnum(); @@ -138,6 +136,11 @@ return commonFont; } + /** @return the "text-decoration" property. */ + public CommonTextDecoration getTextDecoration() { + return textDecoration; + } + /** * Return the "id" property. */ 1.4 +16 -9 xml-fop/src/java/org/apache/fop/fo/properties/ListProperty.java Index: ListProperty.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/properties/ListProperty.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- ListProperty.java 27 Feb 2004 17:45:45 -0000 1.3 +++ ListProperty.java 25 Jan 2005 10:55:46 -0000 1.4 @@ -1,5 +1,5 @@ /* - * Copyright 1999-2004 The Apache Software Foundation. + * Copyright 1999-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ package org.apache.fop.fo.properties; -import java.util.Vector; +import java.util.List; import org.apache.fop.fo.FObj; import org.apache.fop.fo.PropertyList; @@ -34,7 +34,7 @@ public static class Maker extends PropertyMaker { /** - * @param name name of property for which Maker should be created + * @param propId ID of the property for which Maker should be created */ public Maker(int propId) { super(propId); @@ -55,14 +55,21 @@ } /** Vector containing the list of sub-properties */ - protected Vector list; + protected List list = new java.util.Vector(); /** + * Simple constructor used by subclasses to do some special processing. + */ + protected ListProperty() { + //nop + } + + /** * @param prop the first Property to be added to the list */ public ListProperty(Property prop) { - list = new Vector(); - list.addElement(prop); + this(); + addProperty(prop); } /** @@ -70,13 +77,13 @@ * @param prop Property to be added to the list */ public void addProperty(Property prop) { - list.addElement(prop); + list.add(prop); } /** * @return this.list */ - public Vector getList() { + public List getList() { return list; } 1.4 +9 -12 xml-fop/src/java/org/apache/fop/fo/properties/GenericShorthandParser.java Index: GenericShorthandParser.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/properties/GenericShorthandParser.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -r1.3 -r1.4 --- GenericShorthandParser.java 28 Oct 2004 10:00:24 -0000 1.3 +++ GenericShorthandParser.java 25 Jan 2005 10:55:46 -0000 1.4 @@ -1,5 +1,5 @@ /* - * Copyright 1999-2004 The Apache Software Foundation. + * Copyright 1999-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ package org.apache.fop.fo.properties; -import java.util.Enumeration; +import java.util.Iterator; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.expr.PropertyException; @@ -37,7 +37,7 @@ */ protected Property getElement(Property list, int index) { if (list.getList().size() > index) { - return (Property) list.getList().elementAt(index); + return (Property) list.getList().get(index); } else { return null; } @@ -49,9 +49,7 @@ Property property, PropertyMaker maker, PropertyList propertyList) - throws PropertyException - { - Property prop = null; + throws PropertyException { // Check for keyword "inherit" if (property.getList().size() == 1) { String sval = getElement(property, 0).getString(); @@ -75,13 +73,12 @@ Property property, PropertyMaker maker, PropertyList propertyList) - throws PropertyException - { + throws PropertyException { Property prop = null; // Try each of the stored values in turn - Enumeration eprop = property.getList().elements(); - while (eprop.hasMoreElements() && prop == null) { - Property p = (Property) eprop.nextElement(); + Iterator iprop = property.getList().iterator(); + while (iprop.hasNext() && prop == null) { + Property p = (Property)iprop.next(); prop = maker.convertShorthandProperty(propertyList, p, null); } return prop; 1.7 +7 -8 xml-fop/src/java/org/apache/fop/fo/properties/Property.java Index: Property.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/properties/Property.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -r1.6 -r1.7 --- Property.java 28 Oct 2004 10:00:24 -0000 1.6 +++ Property.java 25 Jan 2005 10:55:46 -0000 1.7 @@ -1,5 +1,5 @@ /* - * Copyright 1999-2004 The Apache Software Foundation. + * Copyright 1999-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,7 @@ package org.apache.fop.fo.properties; -import java.util.Vector; +import java.util.List; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -31,6 +31,8 @@ * @author unascribed */ public class Property { + + /** Logger for all property classes */ protected static Log log = LogFactory.getLog(PropertyMaker.class); /** @@ -136,7 +138,7 @@ * This method expects to be overridden by subclasses * @return collection of other property (sub-property) objects */ - public Vector getList() { + public List getList() { return null; } @@ -180,10 +182,7 @@ return null; } - /** - * Return a string representation of the property value. Only used - * for debugging. - */ + /** @see java.lang.Object#toString() */ public String toString() { Object obj = getObject(); if (obj != this) { 1.1 xml-fop/src/java/org/apache/fop/fo/properties/TextDecorationProperty.java Index: TextDecorationProperty.java =================================================================== /* * Copyright 2004-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package org.apache.fop.fo.properties; import java.util.Iterator; import java.util.List; import org.apache.fop.fo.Constants; import org.apache.fop.fo.FObj; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.expr.NCnameProperty; import org.apache.fop.fo.expr.PropertyException; /** * Special list property for text-decoration. */ public class TextDecorationProperty extends ListProperty { /** * Inner class for creating instances of ListProperty */ public static class Maker extends PropertyMaker { /** * @param propId ID of the property for which Maker should be created */ public Maker(int propId) { super(propId); } /** * @see PropertyMaker#convertProperty */ public Property convertProperty(Property p, PropertyList propertyList, FObj fo) throws PropertyException { if (p instanceof TextDecorationProperty) { return p; } else { if (p instanceof ListProperty) { ListProperty lst = (ListProperty)p; lst = checkEnums(lst); return new TextDecorationProperty((ListProperty)p); } else if (p instanceof EnumProperty) { ListProperty lst = new ListProperty(p); return new TextDecorationProperty(lst); } else { throw new PropertyException("Cannot convert anything other " + "than a list property, got a " + p.getClass().getName()); } } } private ListProperty checkEnums(ListProperty lst) throws PropertyException { List l = lst.getList(); for (int i = 0; i < l.size(); i++) { Property prop = (Property)l.get(i); if (prop instanceof EnumProperty) { //skip } else if (prop instanceof NCnameProperty) { Property enum = checkEnumValues(((NCnameProperty)prop).getString()); if (enum == null) { throw new PropertyException("Illegal enum value: " + prop.getString()); } l.set(i, enum); } else { throw new PropertyException("Invalid content for text-decoration " + "property: " + prop); } } return lst; } } /** * Constructs a new instance by converting a ListProperty. * @param listProp the ListProperty to be converted * @throws PropertyException in case the conversion fails */ public TextDecorationProperty(ListProperty listProp) throws PropertyException { List lst = listProp.getList(); boolean none = false; boolean under = false; boolean over = false; boolean through = false; boolean blink = false; Iterator i = lst.iterator(); while (i.hasNext()) { Property prop = (Property)i.next(); switch (prop.getEnum()) { case Constants.EN_NONE: if (under | over | through | blink) { throw new PropertyException( "Invalid combination of values"); } none = true; break; case Constants.EN_UNDERLINE: case Constants.EN_NO_UNDERLINE: if (none) { throw new PropertyException("'none' specified, no additional values allowed"); } if (under) { throw new PropertyException("Invalid combination of values"); } under = true; break; case Constants.EN_OVERLINE: case Constants.EN_NO_OVERLINE: if (none) { throw new PropertyException("'none' specified, no additional values allowed"); } if (over) { throw new PropertyException("Invalid combination of values"); } over = true; break; case Constants.EN_LINE_THROUGH: case Constants.EN_NO_LINE_THROUGH: if (none) { throw new PropertyException("'none' specified, no additional values allowed"); } if (through) { throw new PropertyException("Invalid combination of values"); } through = true; break; case Constants.EN_BLINK: case Constants.EN_NO_BLINK: if (none) { throw new PropertyException("'none' specified, no additional values allowed"); } if (blink) { throw new PropertyException("Invalid combination of values"); } blink = true; break; default: throw new PropertyException("Invalid value specified: " + prop); } addProperty(prop); } } } 1.1 xml-fop/src/java/org/apache/fop/fo/properties/CommonTextDecoration.java Index: CommonTextDecoration.java =================================================================== /* * Copyright 2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ /* $Id: CommonTextDecoration.java,v 1.1 2005/01/25 10:55:46 jeremias Exp $ */ package org.apache.fop.fo.properties; import java.util.Iterator; import java.util.List; import org.apache.fop.datatypes.ColorType; import org.apache.fop.fo.Constants; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.expr.PropertyException; /** * Stores all information concerning text-decoration. */ public class CommonTextDecoration { //using a bit-mask here private static final int UNDERLINE = 1; private static final int OVERLINE = 2; private static final int LINE_THROUGH = 4; private static final int BLINK = 8; private int decoration; private ColorType underColor; private ColorType overColor; private ColorType throughColor; /** * Creates a new CommonTextDecoration object with default values. */ public CommonTextDecoration() { } /** * Creates a CommonTextDecoration object from a property list. * @param pList the property list to build the object for * @return a CommonTextDecoration object or null if the obj would only have default values * @throws PropertyException if there's a problem while processing the property */ public static CommonTextDecoration createFromPropertyList(PropertyList pList) throws PropertyException { return calcTextDecoration(pList); } private static CommonTextDecoration calcTextDecoration(PropertyList pList) throws PropertyException { CommonTextDecoration deco = null; PropertyList parentList = pList.getParentPropertyList(); if (parentList != null) { //Parent is checked first deco = calcTextDecoration(parentList); } List list = pList.get(Constants.PR_TEXT_DECORATION).getList(); Iterator i = list.iterator(); while (i.hasNext()) { Property prop = (Property)i.next(); int enum = prop.getEnum(); if (enum == Constants.EN_NONE) { if (deco != null) { deco.decoration = 0; } return deco; } else if (enum == Constants.EN_UNDERLINE) { if (deco == null) { deco = new CommonTextDecoration(); } deco.decoration |= UNDERLINE; } else if (enum == Constants.EN_NO_UNDERLINE) { if (deco != null) { deco.decoration &= OVERLINE | LINE_THROUGH | BLINK; } } else if (enum == Constants.EN_OVERLINE) { if (deco == null) { deco = new CommonTextDecoration(); } deco.decoration |= OVERLINE; } else if (enum == Constants.EN_NO_OVERLINE) { if (deco != null) { deco.decoration &= UNDERLINE | LINE_THROUGH | BLINK; } } else if (enum == Constants.EN_LINE_THROUGH) { if (deco == null) { deco = new CommonTextDecoration(); } deco.decoration |= LINE_THROUGH; } else if (enum == Constants.EN_NO_LINE_THROUGH) { if (deco != null) { deco.decoration &= UNDERLINE | OVERLINE | BLINK; } } else if (enum == Constants.EN_BLINK) { if (deco == null) { deco = new CommonTextDecoration(); } deco.decoration |= BLINK; } else if (enum == Constants.EN_NO_BLINK) { if (deco != null) { deco.decoration &= UNDERLINE | OVERLINE | LINE_THROUGH; } } else { throw new PropertyException("Illegal value encountered: " + prop.getString()); } } return deco; } /** @return true if underline is active */ public boolean hasUnderline() { return (this.decoration & UNDERLINE) != 0; } /** @return true if overline is active */ public boolean hasOverline() { return (this.decoration & OVERLINE) != 0; } /** @return true if line-through is active */ public boolean hasLineThrough() { return (this.decoration & LINE_THROUGH) != 0; } /** @return true if blink is active */ public boolean isBlinking() { return (this.decoration & BLINK) != 0; } } 1.44 +24 -5 xml-fop/src/java/org/apache/fop/fo/PropertyList.java Index: PropertyList.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/PropertyList.java,v retrieving revision 1.43 retrieving revision 1.44 diff -u -r1.43 -r1.44 --- PropertyList.java 24 Jan 2005 10:43:19 -0000 1.43 +++ PropertyList.java 25 Jan 2005 10:55:46 -0000 1.44 @@ -1,5 +1,5 @@ /* - * Copyright 1999-2004 The Apache Software Foundation. + * Copyright 1999-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -35,6 +35,7 @@ import org.apache.fop.fo.properties.CommonMarginBlock; import org.apache.fop.fo.properties.CommonMarginInline; import org.apache.fop.fo.properties.CommonRelativePosition; +import org.apache.fop.fo.properties.CommonTextDecoration; import org.apache.fop.fo.properties.Property; import org.apache.fop.fo.properties.PropertyMaker; @@ -396,6 +397,7 @@ /** * @param propId ID of property * @return new Property object + * @throws PropertyException if there's a problem while processing the property */ private Property getShorthand(int propId) throws PropertyException { PropertyMaker propertyMaker = findMaker(propId); @@ -411,7 +413,7 @@ /** * @param propID ID of property * @return new Property object - * @throws FOPException for errors in the input + * @throws PropertyException if there's a problem while processing the property */ private Property makeProperty(int propId) throws PropertyException { PropertyMaker propertyMaker = findMaker(propId); @@ -457,16 +459,17 @@ /** * Constructs a BorderAndPadding object. * @return a BorderAndPadding object + * @throws PropertyException if there's a problem while processing the properties */ - public CommonBorderPaddingBackground getBorderPaddingBackgroundProps() throws PropertyException { + public CommonBorderPaddingBackground getBorderPaddingBackgroundProps() + throws PropertyException { return new CommonBorderPaddingBackground(this, getFObj()); } - - /** * Constructs a HyphenationProps objects. * @return a HyphenationProps object + * @throws PropertyException if there's a problem while processing the properties */ public CommonHyphenation getHyphenationProps() throws PropertyException { return new CommonHyphenation(this); @@ -475,6 +478,7 @@ /** * Constructs a MarginProps objects. * @return a MarginProps object + * @throws PropertyException if there's a problem while processing the properties */ public CommonMarginBlock getMarginBlockProps() throws PropertyException { return new CommonMarginBlock(this); @@ -483,6 +487,7 @@ /** * Constructs a MarginInlineProps objects. * @return a MarginInlineProps object + * @throws PropertyException if there's a problem while processing the properties */ public CommonMarginInline getMarginInlineProps() throws PropertyException { return new CommonMarginInline(this); @@ -491,6 +496,7 @@ /** * Constructs a AccessibilityProps objects. * @return a AccessibilityProps object + * @throws PropertyException if there's a problem while processing the properties */ public CommonAccessibility getAccessibilityProps() throws PropertyException { return new CommonAccessibility(this); @@ -499,6 +505,7 @@ /** * Constructs a AuralProps objects. * @return a AuralProps object + * @throws PropertyException if there's a problem while processing the properties */ public CommonAural getAuralProps() throws PropertyException { CommonAural props = new CommonAural(this); @@ -508,6 +515,7 @@ /** * Constructs a RelativePositionProps objects. * @return a RelativePositionProps object + * @throws PropertyException if there's a problem while processing the properties */ public CommonRelativePosition getRelativePositionProps() throws PropertyException { return new CommonRelativePosition(this); @@ -516,6 +524,7 @@ /** * Constructs a AbsolutePositionProps objects. * @return a AbsolutePositionProps object + * @throws PropertyException if there's a problem while processing the properties */ public CommonAbsolutePosition getAbsolutePositionProps() throws PropertyException { return new CommonAbsolutePosition(this); @@ -525,9 +534,19 @@ /** * Constructs a CommonFont object. * @return A CommonFont object + * @throws PropertyException if there's a problem while processing the properties */ public CommonFont getFontProps() throws PropertyException { return new CommonFont(this); + } + + /** + * Constructs a CommonTextDecoration object. + * @return a CommonTextDecoration object + * @throws PropertyException if there's a problem while processing the properties + */ + public CommonTextDecoration getTextDecorationProps() throws PropertyException { + return CommonTextDecoration.createFromPropertyList(this); } } 1.41 +4 -2 xml-fop/src/java/org/apache/fop/fo/FOPropertyMapping.java Index: FOPropertyMapping.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FOPropertyMapping.java,v retrieving revision 1.40 retrieving revision 1.41 diff -u -r1.40 -r1.41 --- FOPropertyMapping.java 24 Jan 2005 09:14:36 -0000 1.40 +++ FOPropertyMapping.java 25 Jan 2005 10:55:46 -0000 1.41 @@ -46,6 +46,7 @@ import org.apache.fop.fo.properties.SpaceProperty; import org.apache.fop.fo.properties.SpacingPropertyMaker; import org.apache.fop.fo.properties.StringProperty; +import org.apache.fop.fo.properties.TextDecorationProperty; import org.apache.fop.fo.properties.ToBeImplementedProperty; /** @@ -1701,7 +1702,8 @@ addPropertyMaker("suppress-at-line-break", m); // text-decoration - m = new EnumProperty.Maker(PR_TEXT_DECORATION); + //m = new EnumProperty.Maker(PR_TEXT_DECORATION); + m = new TextDecorationProperty.Maker(PR_TEXT_DECORATION); m.setInherited(false); m.addEnum("none", getEnumProperty(EN_NONE, "NONE")); m.addEnum("underline", getEnumProperty(EN_UNDERLINE, "UNDERLINE")); 1.37 +20 -9 xml-fop/src/java/org/apache/fop/fo/FOText.java Index: FOText.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/fo/FOText.java,v retrieving revision 1.36 retrieving revision 1.37 diff -u -r1.36 -r1.37 --- FOText.java 24 Dec 2004 12:06:25 -0000 1.36 +++ FOText.java 25 Jan 2005 10:55:46 -0000 1.37 @@ -1,5 +1,5 @@ /* - * Copyright 1999-2004 The Apache Software Foundation. + * Copyright 1999-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,6 +29,7 @@ import org.apache.fop.fo.pagination.Root; import org.apache.fop.fo.properties.CommonFont; import org.apache.fop.fo.properties.CommonHyphenation; +import org.apache.fop.fo.properties.CommonTextDecoration; import org.apache.fop.fo.properties.Property; import org.apache.fop.fo.properties.SpaceProperty; import org.apache.fop.layoutmgr.TextLayoutManager; @@ -110,6 +111,9 @@ */ private Block ancestorBlock = null; + /** Holds the text decoration values. May be null */ + private CommonTextDecoration textDecoration; + private static final int IS_WORD_CHAR_FALSE = 0; private static final int IS_WORD_CHAR_TRUE = 1; private static final int IS_WORD_CHAR_MAYBE = 2; @@ -144,6 +148,7 @@ textTransform = pList.get(Constants.PR_TEXT_TRANSFORM).getEnum(); wordSpacing = pList.get(Constants.PR_WORD_SPACING); wrapOption = pList.get(Constants.PR_WRAP_OPTION).getEnum(); + textDecoration = pList.getTextDecorationProps(); } protected void startOfNode() { @@ -520,51 +525,57 @@ } /** - * Return the Common Font Properties. + * @return the Common Font Properties. */ public CommonFont getCommonFont() { return commonFont; } /** - * Return the Common Hyphenation Properties. + * @return the Common Hyphenation Properties. */ public CommonHyphenation getCommonHyphenation() { return commonHyphenation; } /** - * Return the "color" property. + * @return the "color" property. */ public ColorType getColor() { return color; } /** - * Return the "letter-spacing" property. + * @return the "letter-spacing" property. */ public Property getLetterSpacing() { return letterSpacing; } /** - * Return the "line-height" property. + * @return the "line-height" property. */ public SpaceProperty getLineHeight() { return lineHeight; } /** - * Return the "word-spacing" property. + * @return the "word-spacing" property. */ public Property getWordSpacing() { return wordSpacing; } /** - * Return the "wrap-option" property. + * @return the "wrap-option" property. */ public int getWrapOption() { return wrapOption; } -} + + /** @return the "text-decoration" property. */ + public CommonTextDecoration getTextDecoration() { + return textDecoration; + } + +} \ No newline at end of file 1.14 +24 -0 xml-fop/src/java/org/apache/fop/layoutmgr/TraitSetter.java Index: TraitSetter.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/TraitSetter.java,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- TraitSetter.java 24 Jan 2005 10:43:19 -0000 1.13 +++ TraitSetter.java 25 Jan 2005 10:55:47 -0000 1.14 @@ -26,6 +26,7 @@ import org.apache.fop.fo.Constants; import org.apache.fop.fo.properties.CommonMarginBlock; import org.apache.fop.fo.properties.CommonBorderPaddingBackground; +import org.apache.fop.fo.properties.CommonTextDecoration; import org.apache.fop.fo.properties.PercentLength; /** @@ -261,5 +262,28 @@ public static void addBreaks(Area area, int breakBefore, int breakAfter) { area.addTrait(Trait.BREAK_AFTER, new Integer(breakAfter)); area.addTrait(Trait.BREAK_BEFORE, new Integer(breakBefore)); + } + + /** + * Adds the text-decoration traits to the area. + * @param area the area to set the traits on + * @param deco the text decorations + */ + public static void addTextDecoration(Area area, CommonTextDecoration deco) { + //TODO Finish text-decoration + if (deco != null) { + if (deco.hasUnderline()) { + area.addTrait(Trait.UNDERLINE, Boolean.TRUE); + } + if (deco.hasOverline()) { + area.addTrait(Trait.OVERLINE, Boolean.TRUE); + } + if (deco.hasLineThrough()) { + area.addTrait(Trait.LINETHROUGH, Boolean.TRUE); + } + if (deco.isBlinking()) { + area.addTrait(Trait.BLINK, Boolean.TRUE); + } + } } } 1.10 +3 -2 xml-fop/src/java/org/apache/fop/layoutmgr/CharacterLayoutManager.java Index: CharacterLayoutManager.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/CharacterLayoutManager.java,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- CharacterLayoutManager.java 24 Nov 2004 21:07:30 -0000 1.9 +++ CharacterLayoutManager.java 25 Jan 2005 10:55:47 -0000 1.10 @@ -1,5 +1,5 @@ /* - * Copyright 1999-2004 The Apache Software Foundation. + * Copyright 1999-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -59,6 +59,7 @@ private InlineArea getCharacterInlineArea(Character node) { org.apache.fop.area.inline.Character ch = new org.apache.fop.area.inline.Character(node.getCharacter()); + TraitSetter.addTextDecoration(ch, fobj.getTextDecoration()); return ch; } 1.29 +5 -1 xml-fop/src/java/org/apache/fop/layoutmgr/TextLayoutManager.java Index: TextLayoutManager.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/TextLayoutManager.java,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- TextLayoutManager.java 6 Dec 2004 13:55:18 -0000 1.28 +++ TextLayoutManager.java 25 Jan 2005 10:55:47 -0000 1.29 @@ -1,5 +1,5 @@ /* - * Copyright 1999-2004 The Apache Software Foundation. + * Copyright 1999-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -619,6 +619,7 @@ t.setTextLetterSpaceAdjust(iLetterSpaceDim); t.setTextWordSpaceAdjust(iWordSpaceDim - spaceCharIPD - 2 * t.getTextLetterSpaceAdjust()); + word = t; if (word != null) { parentLM.addChild(word); @@ -659,6 +660,9 @@ textArea.addTrait(Trait.FONT_NAME, fs.getFontName()); textArea.addTrait(Trait.FONT_SIZE, new Integer(fs.getFontSize())); textArea.addTrait(Trait.COLOR, foText.getColor()); + + TraitSetter.addTextDecoration(textArea, foText.getTextDecoration()); + return textArea; } 1.11 +4 -2 xml-fop/src/java/org/apache/fop/layoutmgr/PageNumberCitationLayoutManager.java Index: PageNumberCitationLayoutManager.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/PageNumberCitationLayoutManager.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -r1.10 -r1.11 --- PageNumberCitationLayoutManager.java 24 Oct 2004 00:03:50 -0000 1.10 +++ PageNumberCitationLayoutManager.java 25 Jan 2005 10:55:47 -0000 1.11 @@ -1,5 +1,5 @@ /* - * Copyright 1999-2004 The Apache Software Foundation. + * Copyright 1999-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -100,6 +100,8 @@ inline.addTrait(Trait.FONT_NAME, font.getFontName()); inline.addTrait(Trait.FONT_SIZE, new Integer(font.getFontSize())); } + TraitSetter.addTextDecoration(inline, fobj.getTextDecoration()); + return inline; } 1.6 +4 -2 xml-fop/src/java/org/apache/fop/layoutmgr/PageNumberLayoutManager.java Index: PageNumberLayoutManager.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/layoutmgr/PageNumberLayoutManager.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- PageNumberLayoutManager.java 20 Oct 2004 21:07:02 -0000 1.5 +++ PageNumberLayoutManager.java 25 Jan 2005 10:55:47 -0000 1.6 @@ -1,5 +1,5 @@ /* - * Copyright 1999-2004 The Apache Software Foundation. + * Copyright 1999-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -58,6 +58,8 @@ inline.addTrait(Trait.FONT_NAME, font.getFontName()); inline.addTrait(Trait.FONT_SIZE, new Integer(font.getFontSize())); + + TraitSetter.addTextDecoration(inline, fobj.getTextDecoration()); return inline; } 1.76 +38 -1 xml-fop/src/java/org/apache/fop/render/pdf/PDFRenderer.java Index: PDFRenderer.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/pdf/PDFRenderer.java,v retrieving revision 1.75 retrieving revision 1.76 diff -u -r1.75 -r1.76 --- PDFRenderer.java 24 Jan 2005 10:43:19 -0000 1.75 +++ PDFRenderer.java 25 Jan 2005 10:55:47 -0000 1.76 @@ -50,6 +50,7 @@ import org.apache.fop.area.OffDocumentItem; import org.apache.fop.area.BookmarkData; import org.apache.fop.area.inline.Character; +import org.apache.fop.area.inline.InlineArea; import org.apache.fop.area.inline.TextArea; import org.apache.fop.area.inline.Viewport; import org.apache.fop.area.inline.ForeignObject; @@ -1041,6 +1042,8 @@ currentStream.add(pdf.toString()); + renderTextDecoration(fs, ch, bl, rx); + super.renderCharacter(ch); } @@ -1053,7 +1056,7 @@ String name = (String) text.getTrait(Trait.FONT_NAME); int size = ((Integer) text.getTrait(Trait.FONT_SIZE)).intValue(); - + // This assumes that *all* CIDFonts use a /ToUnicode mapping Typeface f = (Typeface) fontInfo.getFonts().get(name); boolean useMultiByte = f.isMultiByte(); @@ -1112,7 +1115,41 @@ currentStream.add(pdf.toString()); + renderTextDecoration(fs, text, bl, rx); + super.renderText(text); + } + + /** + * Paints the text decoration marks. + * @param fs Current font + * @param inline inline area to paint the marks for + * @param baseline position of the baseline + * @param startx start IPD + */ + protected void renderTextDecoration(Font fs, InlineArea inline, + int baseline, int startx) { + boolean hasTextDeco = inline.hasUnderline() + || inline.hasOverline() + || inline.hasLineThrough(); + if (hasTextDeco) { + endTextObject(); + updateLineStyle(Constants.EN_SOLID); + updateLineWidth(fs.getDescender() / -8 / 1000f); + float endx = (startx + inline.getIPD()) / 1000f; + if (inline.hasUnderline()) { + float y = baseline - fs.getDescender() / 2; + drawLine(startx / 1000f, y / 1000f, endx, y / 1000f); + } + if (inline.hasOverline()) { + float y = (float)(baseline - (1.1 * fs.getCapHeight())); + drawLine(startx / 1000f, y / 1000f, endx, y / 1000f); + } + if (inline.hasLineThrough()) { + float y = (float)(baseline - (0.45 * fs.getCapHeight())); + drawLine(startx / 1000f, y / 1000f, endx, y / 1000f); + } + } } /** 1.24 +7 -4 xml-fop/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java Index: TextAttributesConverter.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java,v retrieving revision 1.23 retrieving revision 1.24 diff -u -r1.23 -r1.24 --- TextAttributesConverter.java 24 Nov 2004 21:07:30 -0000 1.23 +++ TextAttributesConverter.java 25 Jan 2005 10:55:48 -0000 1.24 @@ -94,7 +94,8 @@ FOPRtfAttributes attrib = new FOPRtfAttributes(); attrFont(fobj.getCommonFont(), attrib); attrFontColor(fobj.getColor(), attrib); - attrTextDecoration(fobj.getTextDecoration(), attrib); + //TODO Fix text-decoration here! + //attrTextDecoration(fobj.getTextDecoration(), attrib); attrBackgroundColor(fobj.getCommonBorderPaddingBackground(), attrib); return attrib; @@ -109,7 +110,8 @@ FOPRtfAttributes attrib = new FOPRtfAttributes(); attrFont(fobj.getCommonFont(), attrib); - attrTextDecoration(fobj.getTextDecoration(), attrib); + //TODO Fix text-decoration here! + //attrTextDecoration(fobj.getTextDecoration(), attrib); attrBackgroundColor(fobj.getCommonBorderPaddingBackground(), attrib); return attrib; } @@ -124,7 +126,8 @@ FOPRtfAttributes attrib = new FOPRtfAttributes(); attrFont(fobj.getCommonFont(), attrib); attrFontColor(fobj.getColor(), attrib); - attrTextDecoration(fobj.getTextDecoration(), attrib); + //TODO Fix text-decoration here! + //attrTextDecoration(fobj.getTextDecoration(), attrib); attrBackgroundColor(fobj.getCommonBorderPaddingBackground(), attrib); return attrib; } 1.6 +19 -1 xml-fop/src/java/org/apache/fop/area/inline/InlineArea.java Index: InlineArea.java =================================================================== RCS file: /home/cvs/xml-fop/src/java/org/apache/fop/area/inline/InlineArea.java,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- InlineArea.java 22 Sep 2004 08:18:42 -0000 1.5 +++ InlineArea.java 25 Jan 2005 10:55:48 -0000 1.6 @@ -1,5 +1,5 @@ /* - * Copyright 1999-2004 The Apache Software Foundation. + * Copyright 1999-2005 The Apache Software Foundation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,6 +19,7 @@ package org.apache.fop.area.inline; import org.apache.fop.area.Area; +import org.apache.fop.area.Trait; /** * Inline Area @@ -65,5 +66,22 @@ public int getOffset() { return verticalPosition; } + + public boolean hasUnderline() { + return getBooleanTrait(Trait.UNDERLINE); + } + + public boolean hasOverline() { + return getBooleanTrait(Trait.OVERLINE); + } + + public boolean hasLineThrough() { + return getBooleanTrait(Trait.LINETHROUGH); + } + + public boolean isBlinking() { + return getBooleanTrait(Trait.BLINK); + } + }
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]