svn commit: r1891499 - in /xmlgraphics/fop/trunk/fop-core/src: main/java/org/apache/fop/fo/ main/java/org/apache/fop/fo/properties/ test/java/org/apache/fop/fo/properties/
[email protected] Tue, 13 Jul 2021 06:47:09 -0000
| Newsgroups | gmane.text.xml.fop.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: ssteiner
Date: Tue Jul 13 06:47:09 2021
New Revision: 1891499
URL: http://svn.apache.org/viewvc?rev=1891499&view=rev
Log:
FOP-3021: Improve validation of border property
Added:
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/BorderShorthandParser.java (with props)
xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fo/properties/GenericShorthandParserTestCase.java (with props)
Modified:
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/FOPropertyMapping.java
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/properties/GenericShorthandParser.java
xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/properties/PropertyMaker.java
Added: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/BorderShorthandParser.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/BorderShorthandParser.java?rev=1891499&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/BorderShorthandParser.java (added)
+++ xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/BorderShorthandParser.java Tue Jul 13 06:47:09 2021
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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$ */
+package org.apache.fop.fo;
+
+import org.apache.fop.fo.properties.GenericShorthandParser;
+import org.apache.fop.fo.properties.Property;
+
+class BorderShorthandParser extends GenericShorthandParser {
+ private FOPropertyMapping propertyMapping;
+
+ BorderShorthandParser(FOPropertyMapping propertyMapping) {
+ this.propertyMapping = propertyMapping;
+ }
+
+ protected void validate(PropertyList propertyList, String propertyString, Property prop, Property property) {
+ if (propertyMapping.genericBorderWidth.checkValueKeywords(propertyString).equals(propertyString)) {
+ propertyList.validatePropertyValue(propertyString, prop, property);
+ }
+ }
+}
Propchange: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/BorderShorthandParser.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/FOPropertyMapping.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/FOPropertyMapping.java?rev=1891499&r1=1891498&r2=1891499&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/FOPropertyMapping.java (original)
+++ xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/FOPropertyMapping.java Tue Jul 13 06:47:09 2021
@@ -99,7 +99,7 @@ public final class FOPropertyMapping imp
private PropertyMaker genericCondPadding;
private PropertyMaker genericPadding;
private PropertyMaker genericCondBorderWidth;
- private PropertyMaker genericBorderWidth;
+ PropertyMaker genericBorderWidth;
private PropertyMaker genericBorderStyle;
private PropertyMaker genericCondCornerRadius;
private PropertyMaker genericBreak;
@@ -2849,7 +2849,7 @@ public final class FOPropertyMapping imp
m = new ListProperty.Maker(PR_BORDER_BOTTOM);
m.setInherited(false);
m.setDefault("");
- m.setDatatypeParser(new GenericShorthandParser());
+ m.setDatatypeParser(new BorderShorthandParser(this));
addPropertyMaker("border-bottom", m);
// border-color
@@ -2863,14 +2863,14 @@ public final class FOPropertyMapping imp
m = new ListProperty.Maker(PR_BORDER_LEFT);
m.setInherited(false);
m.setDefault("");
- m.setDatatypeParser(new GenericShorthandParser());
+ m.setDatatypeParser(new BorderShorthandParser(this));
addPropertyMaker("border-left", m);
// border-right
m = new ListProperty.Maker(PR_BORDER_RIGHT);
m.setInherited(false);
m.setDefault("");
- m.setDatatypeParser(new GenericShorthandParser());
+ m.setDatatypeParser(new BorderShorthandParser(this));
addPropertyMaker("border-right", m);
// border-style
@@ -2891,7 +2891,7 @@ public final class FOPropertyMapping imp
m = new ListProperty.Maker(PR_BORDER_TOP);
m.setInherited(false);
m.setDefault("");
- m.setDatatypeParser(new GenericShorthandParser());
+ m.setDatatypeParser(new BorderShorthandParser(this));
addPropertyMaker("border-top", m);
// border-width
Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/properties/GenericShorthandParser.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/properties/GenericShorthandParser.java?rev=1891499&r1=1891498&r2=1891499&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/properties/GenericShorthandParser.java (original)
+++ xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/properties/GenericShorthandParser.java Tue Jul 13 06:47:09 2021
@@ -96,9 +96,12 @@ public class GenericShorthandParser impl
}
prop = maker.convertShorthandProperty(propertyList, p, null);
}
- propertyList.validatePropertyValue(vProperty.toString(), prop, property);
+ validate(propertyList, vProperty.toString(), prop, property);
return prop;
}
+ protected void validate(PropertyList propertyList, String propertyString, Property prop, Property property) {
+ propertyList.validatePropertyValue(propertyString, prop, property);
+ }
}
Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/properties/PropertyMaker.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/properties/PropertyMaker.java?rev=1891499&r1=1891498&r2=1891499&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/properties/PropertyMaker.java (original)
+++ xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/properties/PropertyMaker.java Tue Jul 13 06:47:09 2021
@@ -539,7 +539,7 @@ public class PropertyMaker implements Cl
* @return a String containing a parseable equivalent or null if
* the passed value isn't a keyword initializer for this Property
*/
- protected String checkValueKeywords(String keyword) {
+ public String checkValueKeywords(String keyword) {
if (keywords != null) {
String value = (String)keywords.get(keyword);
if (value != null) {
Added: xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fo/properties/GenericShorthandParserTestCase.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fo/properties/GenericShorthandParserTestCase.java?rev=1891499&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fo/properties/GenericShorthandParserTestCase.java (added)
+++ xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fo/properties/GenericShorthandParserTestCase.java Tue Jul 13 06:47:09 2021
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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$ */
+package org.apache.fop.fo.properties;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import org.apache.fop.fo.Constants;
+import org.apache.fop.fo.FOPropertyMapping;
+import org.apache.fop.fo.StaticPropertyList;
+import org.apache.fop.fo.expr.NCnameProperty;
+import org.apache.fop.fo.expr.PropertyException;
+
+public class GenericShorthandParserTestCase {
+ @Test
+ public void testPropertyValidation() throws PropertyException {
+ StaticPropertyList propertyList = new StaticPropertyList(null, null);
+ ListProperty listProperty = new ListProperty(new NCnameProperty("thin"));
+ listProperty.addProperty(new NCnameProperty("solid"));
+ EnumProperty.Maker maker = new EnumProperty.Maker(0);
+ maker.addEnum("solid", EnumProperty.getInstance(0, "solid"));
+ new GenericShorthandParser().convertValueForProperty(0, listProperty, maker, propertyList);
+ Assert.assertTrue(propertyList.getUnknownPropertyValues().isEmpty());
+ }
+
+ @Test
+ public void testPropertyValidationJustThin() throws PropertyException {
+ StaticPropertyList propertyList = new StaticPropertyList(null, null);
+ ListProperty listProperty = new ListProperty(new NCnameProperty("thin"));
+ propertyList.putExplicit(Constants.PR_BORDER_LEFT, listProperty);
+ PropertyMaker borderLeftStyle = FOPropertyMapping.getGenericMappings()[Constants.PR_BORDER_LEFT_STYLE];
+ borderLeftStyle.getShorthand(propertyList);
+ Assert.assertTrue(propertyList.getUnknownPropertyValues().isEmpty());
+ }
+}
Propchange: xmlgraphics/fop/trunk/fop-core/src/test/java/org/apache/fop/fo/properties/GenericShorthandParserTestCase.java
------------------------------------------------------------------------------
svn:eol-style = native