Browse Source

Support for [letter|word]-spacing properties with a value of 'normal'.

The value returned will be an Constants.NORMAL enum.

PR:
Obtained from:
Submitted by:
Reviewed by:


git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@197868 13f79535-47bb-0310-9956-ffa450edef68
tags/Root_Temp_KnuthStylePageBreaking
Finn Bock 20 years ago
parent
commit
e5553e56be

+ 9
- 3
src/java/org/apache/fop/fo/FOPropertyMapping.java View File

@@ -40,6 +40,7 @@ import org.apache.fop.fo.properties.NumberProperty;
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.SpacingPropertyMaker;
import org.apache.fop.fo.properties.StringProperty;
import org.apache.fop.fo.properties.ToBeImplementedProperty;

@@ -1586,9 +1587,13 @@ public class FOPropertyMapping implements Constants {
addPropertyMaker("character", m);

// letter-spacing
m = new ToBeImplementedProperty.Maker(PR_LETTER_SPACING);
m = new SpacingPropertyMaker(PR_LETTER_SPACING);
m.useGeneric(genericSpace);
m.setInherited(true);
m.getSubpropMaker(CP_PRECEDENCE).setDefault("force");
m.getSubpropMaker(CP_CONDITIONALITY).setDefault("discard");
m.setDefault("normal");
m.addEnum("normal", makeEnumProperty(NORMAL));
addPropertyMaker("letter-spacing", m);

// suppress-at-line-break
@@ -1635,12 +1640,13 @@ public class FOPropertyMapping implements Constants {
addPropertyMaker("treat-as-word-space", m);

// word-spacing
m = new SpaceProperty.Maker(PR_WORD_SPACING);
m = new SpacingPropertyMaker(PR_WORD_SPACING);
m.useGeneric(genericSpace);
m.setInherited(true);
m.getSubpropMaker(CP_PRECEDENCE).setDefault("force");
m.getSubpropMaker(CP_CONDITIONALITY).setDefault("discard");
m.setDefault("0pt");
m.setDefault("normal");
m.addEnum("normal", makeEnumProperty(NORMAL));
addPropertyMaker("word-spacing", m);
}

+ 7
- 2
src/java/org/apache/fop/fo/PropertyManager.java View File

@@ -35,6 +35,7 @@ import org.apache.fop.traits.BlockProps;
import org.apache.fop.traits.InlineProps;
import org.apache.fop.traits.SpaceVal;
import org.apache.fop.traits.LayoutProps; // keep, break, span, space?
import org.apache.fop.traits.MinOptMax;
import org.apache.fop.fonts.FontMetrics;
import org.apache.fop.fo.properties.CommonHyphenation;
import org.xml.sax.Attributes;
@@ -472,8 +473,12 @@ public class PropertyManager implements Constants {
textInfo.wrapOption = propertyList.get(PR_WRAP_OPTION).getEnum();
textInfo.bWrap = (textInfo.wrapOption == Constants.WRAP);

textInfo.wordSpacing = new SpaceVal(
propertyList.get(PR_WORD_SPACING).getSpace());
Property wordSpacing = propertyList.get(PR_WORD_SPACING);
if (wordSpacing.getEnum() == NORMAL) {
textInfo.wordSpacing = new SpaceVal(new MinOptMax(0), true, true, 0);
} else {
textInfo.wordSpacing = new SpaceVal(wordSpacing.getSpace());
}

/* textInfo.letterSpacing =
new SpaceVal(propertyList.get("letter-spacing").getSpace());*/

+ 11
- 3
src/java/org/apache/fop/fo/properties/CompoundPropertyMaker.java View File

@@ -122,10 +122,14 @@ public class CompoundPropertyMaker extends PropertyMaker {
* input value
*/
protected Property checkEnumValues(String value) {
Property result = null;
if (shorthandMaker != null) {
return shorthandMaker.checkEnumValues(value);
result = shorthandMaker.checkEnumValues(value);
}
return null;
if (result == null) {
result = super.checkEnumValues(value);
}
return result;
}

/**
@@ -190,7 +194,11 @@ public class CompoundPropertyMaker extends PropertyMaker {
* @throws FOPException for invalid or inconsisten FO input
*/
public Property make(PropertyList propertyList) throws FOPException {
return makeCompound(propertyList, propertyList.getParentFObj());
if (defaultValue != null) {
return make(propertyList, defaultValue, propertyList.getParentFObj());
} else {
return makeCompound(propertyList, propertyList.getParentFObj());
}
}
/**

+ 52
- 0
src/java/org/apache/fop/fo/properties/SpacingPropertyMaker.java View File

@@ -0,0 +1,52 @@
/*
* Copyright 1999-2004 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.apps.FOPException;
import org.apache.fop.fo.Constants;
import org.apache.fop.fo.FObj;
import org.apache.fop.fo.PropertyList;

/**
* A maker which creates 'letter-spacing' and 'word-spacing' properties.
* These two properties properties are standard space properties with
* additinal support for the 'normal' enum value.
*/

public class SpacingPropertyMaker extends SpaceProperty.Maker {
/**
* Create a maker for [letter|word]-spacing.
* @param propId the id for property.
*/
public SpacingPropertyMaker(int propId) {
super(propId);
}

/**
* Support for the 'normal' value.
*/
public Property convertProperty(Property p,
PropertyList propertyList,
FObj fo) throws FOPException {
if (p.getEnum() == Constants.NORMAL) {
return p;
}
return super.convertProperty(p, propertyList, fo);
}
}

Loading…
Cancel
Save