--- a/src/codegen/fo/foproperties.xml +++ a/src/codegen/fo/foproperties.xml @@ -2054,10 +2054,17 @@ + visibility - false - ToBeImplemented + true visible + Enum + + visible + hidden + collapse + inherit + z-index --- a/src/java/org/apache/fop/area/Trait.java +++ a/src/java/org/apache/fop/area/Trait.java @@ -26,6 +26,7 @@ import org.apache.xmlgraphics.image.loader.ImageInfo; import org.apache.fop.fonts.FontTriplet; import org.apache.fop.traits.BorderProps; +import org.apache.fop.traits.Visibility; import org.apache.fop.util.ColorUtil; import static org.apache.fop.fo.Constants.EN_REPEAT; @@ -156,8 +157,11 @@ public final class Trait implements Serializable { /** The ptr trait. Used for accessibility */ public static final Integer PTR = 37; + /** Used to disable the rendering of a Block http://www.w3.org/TR/xsl/#rend-vis */ + public static final Integer VISIBILITY = 38; + /** Maximum value used by trait keys */ - public static final int MAX_TRAIT_KEY = 37; + public static final int MAX_TRAIT_KEY = 38; private static final TraitInfo[] TRAIT_INFO = new TraitInfo[MAX_TRAIT_KEY + 1]; @@ -221,6 +225,7 @@ public final class Trait implements Serializable { put(SPACE_AFTER, new TraitInfo("space-after", Integer.class)); put(IS_REFERENCE_AREA, new TraitInfo("is-reference-area", Boolean.class)); put(IS_VIEWPORT_AREA, new TraitInfo("is-viewport-area", Boolean.class)); + put(VISIBILITY, new TraitInfo("visibility", Visibility.class)); } --- a/src/java/org/apache/fop/fo/flow/Block.java +++ a/src/java/org/apache/fop/fo/flow/Block.java @@ -83,12 +83,12 @@ public class Block extends FObjMixed implements BreakPropertySet, StructurePoint private Numeric widows; private int wrapOption; private int disableColumnBalancing; + private int visibility; // Unused but valid items, commented out for performance: // private CommonAccessibility commonAccessibility; // private CommonAural commonAural; // private Length textDepth; // private Length textAltitude; - // private int visibility; // End of property values /** @@ -135,6 +135,7 @@ public class Block extends FObjMixed implements BreakPropertySet, StructurePoint widows = pList.get(PR_WIDOWS).getNumeric(); wrapOption = pList.get(PR_WRAP_OPTION).getEnum(); disableColumnBalancing = pList.get(PR_X_DISABLE_COLUMN_BALANCING).getEnum(); + visibility = pList.get(PR_VISIBILITY).getEnum(); } /** {@inheritDoc} */ @@ -356,4 +357,7 @@ public class Block extends FObjMixed implements BreakPropertySet, StructurePoint return FO_BLOCK; } + public int getVisibility() { + return visibility; + } } --- a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java +++ a/src/java/org/apache/fop/layoutmgr/BlockLayoutManager.java @@ -332,6 +332,7 @@ public class BlockLayoutManager extends BlockStackingLayoutManager TraitSetter.addPtr(curBlockArea, getBlockFO().getPtr()); // used for accessibility TraitSetter.addSpaceBeforeAfter(curBlockArea, layoutContext.getSpaceAdjust(), effSpaceBefore, effSpaceAfter); + TraitSetter.setVisibility(curBlockArea, getBlockFO().getVisibility()); flush(); curBlockArea = null; --- a/src/java/org/apache/fop/layoutmgr/TraitSetter.java +++ a/src/java/org/apache/fop/layoutmgr/TraitSetter.java @@ -35,6 +35,7 @@ import org.apache.fop.fo.properties.CommonBorderPaddingBackground.BorderInfo; import org.apache.fop.fonts.Font; import org.apache.fop.traits.BorderProps; import org.apache.fop.traits.MinOptMax; +import org.apache.fop.traits.Visibility; /** * This is a helper class used for setting common traits on areas. @@ -612,4 +613,19 @@ public final class TraitSetter { area.addTrait(Trait.PROD_ID, id); } } + + public static void setVisibility(Area area, int visibility) { + Visibility v; + switch (visibility) { + case Constants.EN_COLLAPSE: + v = Visibility.COLLAPSE; + break; + case Constants.EN_HIDDEN: + v = Visibility.HIDDEN; + break; + default: + v = Visibility.VISIBLE; + } + area.addTrait(Trait.VISIBILITY, v); + } } --- a/src/java/org/apache/fop/render/AbstractRenderer.java +++ a/src/java/org/apache/fop/render/AbstractRenderer.java @@ -69,6 +69,7 @@ import org.apache.fop.area.inline.InlineViewport; import org.apache.fop.area.inline.WordArea; import org.apache.fop.fo.Constants; import org.apache.fop.fonts.FontInfo; +import org.apache.fop.traits.Visibility; /** * Abstract base class for all renderers. The Abstract renderer does all the @@ -579,7 +580,8 @@ public abstract class AbstractRenderer handleBlockTraits(block); - if (children != null) { + if (children != null && block.getTrait(Trait.VISIBILITY) != Visibility.HIDDEN) + { renderBlocks(block, children); } --- a/src/java/org/apache/fop/traits/Visibility.java +++ a/src/java/org/apache/fop/traits/Visibility.java @@ -0,0 +1,24 @@ +/* + * 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. + */ + +package org.apache.fop.traits; + +/** + * http://www.w3.org/TR/xsl/#visibility + * @author Jerome Robert + */ +public enum Visibility { VISIBLE, HIDDEN, COLLAPSE }