Browse Source

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
tags/Root_Temp_KnuthStylePageBreaking
Jeremias Maerki 19 years ago
parent
commit
7abfc1a0a7

+ 8
- 4
src/java/org/apache/fop/fo/FOPropertyMapping.java View File

@@ -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);

+ 49
- 0
src/java/org/apache/fop/fo/properties/SpacePropertyMaker.java View File

@@ -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;
}
}

Loading…
Cancel
Save