diff options
-rw-r--r-- | src/java/org/apache/fop/fo/FOEventHandler.java | 13 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/FOPropertyMapping.java | 36 | ||||
-rw-r--r-- | src/java/org/apache/fop/fo/properties/StringProperty.java | 44 | ||||
-rw-r--r-- | test/fotree/testcases/id_auto.fo | 28 |
4 files changed, 19 insertions, 102 deletions
diff --git a/src/java/org/apache/fop/fo/FOEventHandler.java b/src/java/org/apache/fop/fo/FOEventHandler.java index 149e614d0..7521d398c 100644 --- a/src/java/org/apache/fop/fo/FOEventHandler.java +++ b/src/java/org/apache/fop/fo/FOEventHandler.java @@ -79,10 +79,6 @@ public abstract class FOEventHandler { * This is used so we know if the FO tree contains duplicates. */ private Set idReferences = new HashSet(); - /** - * Keeps track of the last automatically generated id in the current document - */ - private long lastGeneratedId = 1; /** * The property list maker. @@ -182,15 +178,6 @@ public abstract class FOEventHandler { } /** - * Return the next value for automatically generated ids - * - * @return the next value to append to automatically generated ids - */ - public long getNextId() { - return this.lastGeneratedId++; - } - - /** * This method is called to indicate the start of a new document run. * @throws SAXException In case of a problem */ diff --git a/src/java/org/apache/fop/fo/FOPropertyMapping.java b/src/java/org/apache/fop/fo/FOPropertyMapping.java index 96cbc5329..60317cf0d 100644 --- a/src/java/org/apache/fop/fo/FOPropertyMapping.java +++ b/src/java/org/apache/fop/fo/FOPropertyMapping.java @@ -601,8 +601,8 @@ public final class FOPropertyMapping implements Constants { // background-position-horizontal m = new LengthProperty.Maker(PR_BACKGROUND_POSITION_HORIZONTAL); m.setInherited(false); - m.setDefault("0%"); - m.addKeyword("left", "0%"); + m.setDefault("0pt"); + m.addKeyword("left", "0pt"); m.addKeyword("center", "50%"); m.addKeyword("right", "100%"); m.setPercentBase(LengthBase.IMAGE_BACKGROUND_POSITION_HORIZONTAL); @@ -612,8 +612,8 @@ public final class FOPropertyMapping implements Constants { // background-position-vertical m = new LengthProperty.Maker(PR_BACKGROUND_POSITION_VERTICAL); m.setInherited(false); - m.setDefault("0%"); - m.addKeyword("top", "0%"); + m.setDefault("0pt"); + m.addKeyword("top", "0pt"); m.addKeyword("center", "50%"); m.addKeyword("bottom", "100%"); m.setPercentBase(LengthBase.IMAGE_BACKGROUND_POSITION_VERTICAL); @@ -2503,7 +2503,7 @@ public final class FOPropertyMapping implements Constants { addPropertyMaker("content-type", m); // id - m = new StringProperty.IdMaker(PR_ID); + m = new StringProperty.Maker(PR_ID); m.setInherited(false); m.setDefault(""); addPropertyMaker("id", m); @@ -2568,29 +2568,29 @@ public final class FOPropertyMapping implements Constants { // background-position m = new BackgroundPositionShorthand.Maker(PR_BACKGROUND_POSITION); m.setInherited(false); - m.addKeyword("left", "0% 50%"); - m.addKeyword("left center", "0% 50%"); - m.addKeyword("center left", "0% 50%"); + m.addKeyword("left", "0pt 50%"); + m.addKeyword("left center", "0pt 50%"); + m.addKeyword("center left", "0pt 50%"); m.addKeyword("right", "100% 50%"); m.addKeyword("right center", "100% 50%"); m.addKeyword("center right", "100% 50%"); m.addKeyword("center", "50% 50%"); m.addKeyword("center center", "50% 50%"); - m.addKeyword("top", "50% 0%"); - m.addKeyword("top center", "50% 0%"); - m.addKeyword("center top", "50% 0%"); + m.addKeyword("top", "50% 0pt"); + m.addKeyword("top center", "50% 0pt"); + m.addKeyword("center top", "50% 0pt"); m.addKeyword("bottom", "50% 100%"); m.addKeyword("bottom center", "50% 100%"); m.addKeyword("center bottom", "50% 100%"); - m.addKeyword("top left", "0% 0%"); - m.addKeyword("left top", "0% 0%"); - m.addKeyword("top right", "100% 0%"); - m.addKeyword("right top", "100% 0%"); - m.addKeyword("bottom left", "0% 100%"); - m.addKeyword("left bottom", "0% 100%"); + m.addKeyword("top left", "0pt 0pt"); + m.addKeyword("left top", "0pt 0pt"); + m.addKeyword("top right", "100% 0pt"); + m.addKeyword("right top", "100% 0pt"); + m.addKeyword("bottom left", "0pt 100%"); + m.addKeyword("left bottom", "0pt 100%"); m.addKeyword("bottom right", "100% 100%"); m.addKeyword("right bottom", "100% 100%"); - m.setDefault("0% 0%"); + m.setDefault("0pt 0pt"); m.setPercentBase(LengthBase.CUSTOM_BASE); m.setDatatypeParser(new BackgroundPositionShorthand.Parser()); addPropertyMaker("background-position", m); diff --git a/src/java/org/apache/fop/fo/properties/StringProperty.java b/src/java/org/apache/fop/fo/properties/StringProperty.java index 8880921de..087feb350 100644 --- a/src/java/org/apache/fop/fo/properties/StringProperty.java +++ b/src/java/org/apache/fop/fo/properties/StringProperty.java @@ -81,49 +81,7 @@ public final class StringProperty extends Property { } } - - /** - * Inner class dedicated to the "id" property, which should provide a random - * unique identifier as an initial value. - * The values for "id" are never cached, as they're typically valid for one - * document. - */ - public static class IdMaker extends PropertyMaker { - - /** - * @param propId the id of the property for which the maker should be created - */ - public IdMaker(int propId) { - super(propId); - } - - /** {@inheritDoc} */ - public Property make(PropertyList propertyList) throws PropertyException { - String newId = "FO_"; - newId += propertyList.getFObj().getFOEventHandler().getNextId(); - return new StringProperty(newId); - } - - /** {@inheritDoc} */ - public Property make(PropertyList propertyList, - String value, - FObj fo) throws PropertyException { - - Property idProp; - - //no parsing necessary; just return a new StringProperty - //TODO: Should we move validation here? (see FObj#checkId()) - if ("".equals(value)) { - //if an empty string was specified, return the default - idProp = this.make(propertyList); - } else { - idProp = new StringProperty(value); - } - - return idProp; - } - } - + /** cache containing all canonical StringProperty instances */ private static final PropertyCache cache = new PropertyCache(StringProperty.class); diff --git a/test/fotree/testcases/id_auto.fo b/test/fotree/testcases/id_auto.fo deleted file mode 100644 index 8e8d03b7e..000000000 --- a/test/fotree/testcases/id_auto.fo +++ /dev/null @@ -1,28 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:test="http://xmlgraphics.apache.org/fop/test"> - <test:assert property="id" expected="FO_1" /> - <fo:layout-master-set> - <test:assert property="id" expected="FO_2" /> - <fo:simple-page-master master-name="simpleA4" page-height="29.7cm" page-width="21cm" margin-top="2cm" margin-bottom="2cm" margin-left="2cm" margin-right="2cm"> - <test:assert property="id" expected="FO_3" /> - <fo:region-body> - <test:assert property="id" expected="FO_4" /> - </fo:region-body> - </fo:simple-page-master> - </fo:layout-master-set> - <fo:page-sequence master-reference="simpleA4"> - <test:assert property="id" expected="FO_5" /> - <fo:flow flow-name="xsl-region-body"> - <test:assert property="id" expected="FO_6" /> - <fo:block font-size="14pt" id="block">Hello - <test:assert property="id" expected="block"/> - <fo:inline> World! - <test:assert property="id" expected="FO_7" /> - </fo:inline> - </fo:block> - <fo:block font-family="ZapfDingbats">઎ - <test:assert property="id" expected="FO_8" /> - </fo:block> - </fo:flow> - </fo:page-sequence> -</fo:root> |