svn commit: r1790795 - in /xmlgraphics/fop/trunk: fop-core/src/main/codegen/fo/ fop-core/src/main/java/org/apache/fop/area/ fop-core/src/main/java/org/apache/fop/fo/flow/ fop-core/src/main/java/org/apache/fop/layoutmgr/ fop-core/src/main/java/org/apach...

[email protected]
Newsgroups gmane.text.xml.fop.cvs
Message-ID <[email protected]>
Author: cbowditch
Date: Mon Apr 10 10:03:35 2017
New Revision: 1790795

URL: http://svn.apache.org/viewvc?rev=1790795&view=rev
Log:
FOP-616: "visibility" property is not implemented

Added:
    xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/traits/Visibility.java
    xmlgraphics/fop/trunk/fop/test/layoutengine/standard-testcases/block_hidden.xml
Modified:
    xmlgraphics/fop/trunk/fop-core/src/main/codegen/fo/foproperties.xml
    xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/area/AreaTreeParser.java
    xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/area/Trait.java
    xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/flow/Block.java
    xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
    xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/layoutmgr/TraitSetter.java
    xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/AbstractRenderer.java

Modified: xmlgraphics/fop/trunk/fop-core/src/main/codegen/fo/foproperties.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/codegen/fo/foproperties.xml?rev=1790795&r1=1790794&r2=1790795&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/fop-core/src/main/codegen/fo/foproperties.xml (original)
+++ xmlgraphics/fop/trunk/fop-core/src/main/codegen/fo/foproperties.xml Mon Apr 10 10:03:35 2017
@@ -2055,9 +2055,15 @@
   </property>
   <property>
     <name>visibility</name>
-    <inherited>false</inherited>
-    <datatype>ToBeImplemented</datatype>
+    <inherited>true</inherited>
     <default>visible</default>
+    <datatype>Enum</datatype>
+    <enumeration>
+      <value const="VISIBLE">visible</value>
+      <value const="HIDDEN">hidden</value>
+      <value const="COLLAPSE">collapse</value>
+      <value const="INHERIT">inherit</value>
+    </enumeration>
   </property>
   <property>
     <name>z-index</name>

Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/area/AreaTreeParser.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/area/AreaTreeParser.java?rev=1790795&r1=1790794&r2=1790795&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/area/AreaTreeParser.java (original)
+++ xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/area/AreaTreeParser.java Mon Apr 10 10:03:35 2017
@@ -80,6 +80,7 @@ import org.apache.fop.fo.extensions.Exte
 import org.apache.fop.fonts.Font;
 import org.apache.fop.fonts.FontInfo;
 import org.apache.fop.traits.BorderProps;
+import org.apache.fop.traits.Visibility;
 import org.apache.fop.util.ColorUtil;
 import org.apache.fop.util.ContentHandlerFactory;
 import org.apache.fop.util.ContentHandlerFactoryRegistry;
@@ -663,6 +664,10 @@ public class AreaTreeParser {
                 if (attributes.getValue("top-offset") != null) {
                     block.setYOffset(XMLUtil.getAttributeAsInt(attributes, "top-offset", 0));
                 }
+                if (attributes.getValue("visibility") != null) {
+                    block.addTrait(Trait.VISIBILITY, Visibility.valueOf(attributes.getValue("visibility")));
+                }
+
                 transferForeignObjects(attributes, block);
                 setAreaAttributes(attributes, block);
                 setTraits(attributes, block, SUBSET_COMMON);

Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/area/Trait.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/area/Trait.java?rev=1790795&r1=1790794&r2=1790795&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/area/Trait.java (original)
+++ xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/area/Trait.java Mon Apr 10 10:03:35 2017
@@ -27,6 +27,7 @@ import org.apache.xmlgraphics.image.load
 import org.apache.fop.fonts.FontTriplet;
 import org.apache.fop.traits.BorderProps;
 import org.apache.fop.traits.Direction;
+import org.apache.fop.traits.Visibility;
 import org.apache.fop.traits.WritingMode;
 import org.apache.fop.util.ColorUtil;
 
@@ -172,8 +173,11 @@ public final class Trait implements Seri
     /** For optional content groups. */
     public static final Integer LAYER = 43;
 
+    /** Used to disable the rendering of a Block http://www.w3.org/TR/xsl/#rend-vis */
+    public static final Integer VISIBILITY = 44;
+
     /** Maximum value used by trait keys */
-    public static final int MAX_TRAIT_KEY = 43;
+    public static final int MAX_TRAIT_KEY = 44;
 
     private static final TraitInfo[] TRAIT_INFO = new TraitInfo[MAX_TRAIT_KEY + 1];
 
@@ -246,7 +250,7 @@ public final class Trait implements Seri
         put(SHIFT_DIRECTION,
                 new TraitInfo("shift-direction", Direction.class));
         put(LAYER, new TraitInfo("layer", String.class));
-
+        put(VISIBILITY, new TraitInfo("visibility", Visibility.class));
     }
 
     /**

Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/flow/Block.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/flow/Block.java?rev=1790795&r1=1790794&r2=1790795&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/flow/Block.java (original)
+++ xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/fo/flow/Block.java Mon Apr 10 10:03:35 2017
@@ -85,12 +85,12 @@ public class Block extends FObjMixed imp
     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 FO trait values
 
     /**
@@ -137,6 +137,7 @@ public class Block extends FObjMixed imp
         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} */
@@ -358,4 +359,7 @@ public class Block extends FObjMixed imp
         return FO_BLOCK;
     }
 
+     public int getVisibility() {
+         return visibility;
+     }
 }

Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/layoutmgr/BlockLayoutManager.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/layoutmgr/BlockLayoutManager.java?rev=1790795&r1=1790794&r2=1790795&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/layoutmgr/BlockLayoutManager.java (original)
+++ xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/layoutmgr/BlockLayoutManager.java Mon Apr 10 10:03:35 2017
@@ -331,6 +331,7 @@ public class BlockLayoutManager extends
 
         TraitSetter.addSpaceBeforeAfter(curBlockArea, layoutContext.getSpaceAdjust(),
                 effSpaceBefore, effSpaceAfter);
+        TraitSetter.setVisibility(curBlockArea, getBlockFO().getVisibility());
         flush();
 
         curBlockArea = null;

Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/layoutmgr/TraitSetter.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/layoutmgr/TraitSetter.java?rev=1790795&r1=1790794&r2=1790795&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/layoutmgr/TraitSetter.java (original)
+++ xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/layoutmgr/TraitSetter.java Mon Apr 10 10:03:35 2017
@@ -36,6 +36,7 @@ import org.apache.fop.fo.properties.Comm
 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.
@@ -599,6 +600,21 @@ public final class TraitSetter {
         }
     }
 
+    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);
+    }
+
     /**
      * Sets the structure tree element associated to the given area.
      *

Modified: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/AbstractRenderer.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/AbstractRenderer.java?rev=1790795&r1=1790794&r2=1790795&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/AbstractRenderer.java (original)
+++ xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/render/AbstractRenderer.java Mon Apr 10 10:03:35 2017
@@ -71,6 +71,7 @@ import org.apache.fop.area.inline.TextAr
 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
@@ -609,7 +610,8 @@ public abstract class AbstractRenderer
 
             handleBlockTraits(block);
 
-            if (children != null) {
+            if (children != null && block.getTrait(Trait.VISIBILITY) != Visibility.HIDDEN)
+            {
                 renderBlocks(block, children);
             }
 

Added: xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/traits/Visibility.java
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/traits/Visibility.java?rev=1790795&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/traits/Visibility.java (added)
+++ xmlgraphics/fop/trunk/fop-core/src/main/java/org/apache/fop/traits/Visibility.java Mon Apr 10 10:03:35 2017
@@ -0,0 +1,70 @@
+/*
+ * 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;
+
+import java.io.ObjectStreamException;
+
+import org.apache.fop.fo.Constants;
+
+
+public final class Visibility extends TraitEnum {
+    private static final long serialVersionUID = 1L;
+
+    private static final String[] VISIBILITY_NAMES = new String[]
+            {"visible", "hidden", "collapse"};
+
+    private static final int[] VISIBILITY_VALUES = new int[]
+            {Constants.EN_VISIBLE, Constants.EN_HIDDEN, Constants.EN_COLLAPSE};
+
+    /** border-style: none */
+    public static final Visibility VISIBLE = new Visibility(0);
+    /** border-style: hidden */
+    public static final Visibility HIDDEN = new Visibility(1);
+    /** border-style: dotted */
+    public static final Visibility COLLAPSE = new Visibility(2);
+
+    private static final Visibility[] VISIBILITIES = new Visibility[] {
+            VISIBLE, HIDDEN, COLLAPSE};
+
+
+    private Visibility(int index) {
+        super(VISIBILITY_NAMES[index], VISIBILITY_VALUES[index]);
+    }
+
+    /**
+     * Returns the enumeration/singleton object based on its name.
+     * @param name the name of the enumeration value
+     * @return the enumeration object
+     */
+    public static Visibility valueOf(String name) {
+        for (Visibility v : VISIBILITIES) {
+            if (v.getName().equalsIgnoreCase(name)) {
+                return v;
+            }
+        }
+        throw new IllegalArgumentException("Illegal visibility value: " + name);
+    }
+
+    private Object readResolve() throws ObjectStreamException {
+        return valueOf(getName());
+    }
+
+    public String toString() {
+        return getName();
+    }
+}

Added: xmlgraphics/fop/trunk/fop/test/layoutengine/standard-testcases/block_hidden.xml
URL: http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/fop/test/layoutengine/standard-testcases/block_hidden.xml?rev=1790795&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/fop/test/layoutengine/standard-testcases/block_hidden.xml (added)
+++ xmlgraphics/fop/trunk/fop/test/layoutengine/standard-testcases/block_hidden.xml Mon Apr 10 10:03:35 2017
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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: block_basic_1.xml 627324 2008-02-13 09:35:01Z maxberger $ -->
+<testcase>
+  <info>
+    <p>
+      This test checks the visibility trait.
+    </p>
+  </info>
+  <fo>
+    <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
+      <fo:layout-master-set>
+        <fo:simple-page-master master-name="normal" page-width="5in" page-height="5in">
+          <fo:region-body/>
+        </fo:simple-page-master>
+      </fo:layout-master-set>
+      <fo:page-sequence master-reference="normal" white-space-collapse="true">
+        <fo:flow flow-name="xsl-region-body">
+          <fo:block>test1</fo:block>
+          <fo:block visibility="hidden">hidden</fo:block>
+        </fo:flow>
+      </fo:page-sequence>
+    </fo:root>
+  </fo>
+  <checks>
+    <!-- Check for first paragraph -->
+    <eval expected="360000" xpath="/areaTree/pageSequence/pageViewport/page[1]/regionViewport/regionBody/mainReference/span/flow/block[1]/@ipd"/>
+    <eval expected="14400" xpath="/areaTree/pageSequence/pageViewport/page[1]/regionViewport/regionBody/mainReference/span/flow/block[1]/@bpd"/>
+	<eval expected="visible" xpath="/areaTree/pageSequence/pageViewport/page[1]/regionViewport/regionBody/mainReference/span/flow/block[1]/@visibility"/>
+    <!-- Check for second paragraph -->
+    <eval expected="360000" xpath="/areaTree/pageSequence/pageViewport/page[1]/regionViewport/regionBody/mainReference/span/flow/block[2]/@ipd"/>
+    <eval expected="14400" xpath="/areaTree/pageSequence/pageViewport/page[1]/regionViewport/regionBody/mainReference/span/flow/block[2]/@bpd"/>
+	<eval expected="hidden" xpath="/areaTree/pageSequence/pageViewport/page[1]/regionViewport/regionBody/mainReference/span/flow/block[2]/@visibility"/>
+	<eval expected="0" xpath="count(/areaTree/pageSequence/pageViewport/page[1]/regionViewport/regionBody/mainReference/span/flow/block[2]/*)"/>
+  </checks>
+</testcase>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.