aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2005-03-11 13:33:32 +0000
committerJeremias Maerki <jeremias@apache.org>2005-03-11 13:33:32 +0000
commit7abfc1a0a7b1b85366468cb2b41f4469eb1b830b (patch)
tree17242c4ca0a1c9cc8fcdcb6da10e968f669071c2
parentb23a3cab041d6ba0f093fb4e8efad55c1bee8c37 (diff)
downloadxmlgraphics-fop-7abfc1a0a7b1b85366468cb2b41f4469eb1b830b.tar.gz
xmlgraphics-fop-7abfc1a0a7b1b85366468cb2b41f4469eb1b830b.zip
SpacePropertyMaker to handle conditionality as defined by the spec:
"The .conditionality component of any space-before or space-after determined from a margin property is set to "retain"." git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@198480 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/java/org/apache/fop/fo/FOPropertyMapping.java12
-rw-r--r--src/java/org/apache/fop/fo/properties/SpacePropertyMaker.java49
2 files changed, 57 insertions, 4 deletions
diff --git a/src/java/org/apache/fop/fo/FOPropertyMapping.java b/src/java/org/apache/fop/fo/FOPropertyMapping.java
index b7ebace99..a1328b9bf 100644
--- a/src/java/org/apache/fop/fo/FOPropertyMapping.java
+++ b/src/java/org/apache/fop/fo/FOPropertyMapping.java
@@ -45,6 +45,7 @@ import org.apache.fop.fo.properties.PositionShorthandParser;
import org.apache.fop.fo.properties.Property;
import org.apache.fop.fo.properties.PropertyMaker;
import org.apache.fop.fo.properties.SpaceProperty;
+import org.apache.fop.fo.properties.SpacePropertyMaker;
import org.apache.fop.fo.properties.SpacingPropertyMaker;
import org.apache.fop.fo.properties.StringProperty;
import org.apache.fop.fo.properties.TextDecorationProperty;
@@ -52,7 +53,9 @@ import org.apache.fop.fo.properties.ToBeImplementedProperty;
/**
* This class creates and returns an array of Property.Maker instances
- * indexed by the PR_* propId from Constants.java.
+ * indexed by the PR_* propId from Constants.java.
+ *
+ * @todo Check multi-threading safety of the statics below
*/
public class FOPropertyMapping implements Constants {
private static Map s_htPropNames = new HashMap();
@@ -383,8 +386,9 @@ public class FOPropertyMapping implements Constants {
}
/**
- * Return a (possible cached) enum property based in the enum value.
+ * Return a (possibly cached) enum property based in the enum value.
* @param enum A enum value from Constants.java.
+ * @param text the text value by which this enum property is known
* @return An EnumProperty instance.
*/
private Property getEnumProperty(int enumValue, String text) {
@@ -1216,7 +1220,7 @@ public class FOPropertyMapping implements Constants {
// space-before
m = new SpaceProperty.Maker(PR_SPACE_BEFORE);
m.useGeneric(genericSpace);
- corr = new CorrespondingPropertyMaker(m);
+ corr = new SpacePropertyMaker(m);
corr.setCorresponding(PR_MARGIN_TOP, PR_MARGIN_TOP, PR_MARGIN_RIGHT);
corr.setUseParent(true);
corr.setRelative(true);
@@ -1225,7 +1229,7 @@ public class FOPropertyMapping implements Constants {
// space-after
m = new SpaceProperty.Maker(PR_SPACE_AFTER);
m.useGeneric(genericSpace);
- corr = new CorrespondingPropertyMaker(m);
+ corr = new SpacePropertyMaker(m);
corr.setCorresponding(PR_MARGIN_BOTTOM, PR_MARGIN_BOTTOM, PR_MARGIN_LEFT);
corr.setUseParent(true);
corr.setRelative(true);
diff --git a/src/java/org/apache/fop/fo/properties/SpacePropertyMaker.java b/src/java/org/apache/fop/fo/properties/SpacePropertyMaker.java
new file mode 100644
index 000000000..9cc79f261
--- /dev/null
+++ b/src/java/org/apache/fop/fo/properties/SpacePropertyMaker.java
@@ -0,0 +1,49 @@
+/*
+ * 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$ */
+
+package org.apache.fop.fo.properties;
+
+import org.apache.fop.fo.Constants;
+import org.apache.fop.fo.PropertyList;
+import org.apache.fop.fo.expr.PropertyException;
+
+/**
+ * Special CorrespondingPropertyMaker that sets the conditionality subproperty
+ * correctly for space-* properties.
+ */
+public class SpacePropertyMaker extends CorrespondingPropertyMaker {
+
+ /**
+ * @param baseMaker base property maker
+ */
+ public SpacePropertyMaker(PropertyMaker baseMaker) {
+ super(baseMaker);
+ }
+
+ /**
+ * @see org.apache.fop.fo.properties.CorrespondingPropertyMaker#compute(org.apache.fop.fo.PropertyList)
+ */
+ public Property compute(PropertyList propertyList) throws PropertyException {
+ Property prop = super.compute(propertyList);
+ if (prop != null && prop instanceof SpaceProperty) {
+ ((SpaceProperty)prop).setConditionality(
+ new EnumProperty(Constants.EN_RETAIN, "RETAIN"), false);
+ }
+ return prop;
+ }
+}