]> source.dussan.org Git - xmlgraphics-fop.git/commitdiff
Bugzilla 41500:
authorAndreas L. Delmelle <adelmelle@apache.org>
Wed, 7 May 2008 14:04:17 +0000 (14:04 +0000)
committerAndreas L. Delmelle <adelmelle@apache.org>
Wed, 7 May 2008 14:04:17 +0000 (14:04 +0000)
Fixed a ClassCastException when fo:wrapper was used as a child of an fo:block-container.
Bugzilla 42423:
Added support for the "id" attribute on fo:wrappers that are children of the fo:flow.

git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@654111 13f79535-47bb-0310-9956-ffa450edef68

src/java/org/apache/fop/events/EventFormatter.xml
src/java/org/apache/fop/fo/flow/Wrapper.java
src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java
src/java/org/apache/fop/layoutmgr/FlowLayoutManager.java
src/java/org/apache/fop/layoutmgr/inline/WrapperLayoutManager.java
status.xml
test/layoutengine/disabled-testcases.xml

index 74e12040721b8f02f58e470be9841a49f22e6f89..4bff75f85dc3f38c8fa932973efab3411c1a923f 100644 (file)
   <message key="rule.childOfSPM">The element must be a child of fo:simple-page-master.</message>
   <message key="rule.childOfDeclarations">The element must be a child of fo:declarations.</message>
   <message key="rule.childOfSPMorDeclarations">The element must be a child of fo:declarations or fo:simple-page-master.</message>
+  <message key="rule.wrapperInvalidChildForParent">An fo:wrapper is only permitted to have children that would be permitted for its parent.</message>
   <message key="org.apache.fop.fo.FOValidationEventProducer.tooManyNodes">For "{elementName}", only one "{offendingNode}" may be declared.{{locator}}</message>
   <message key="org.apache.fop.fo.FOValidationEventProducer.nodeOutOfOrder">For "{elementName}", "{tooLateNode}" must be declared before "{tooEarlyNode}"!{{locator}}</message>
-  <message key="org.apache.fop.fo.FOValidationEventProducer.invalidChild">"{offendingNode}" is not a valid child element of "{elementName}"![ {ruleViolated,lookup}]{{locator}}</message>
+  <message key="org.apache.fop.fo.FOValidationEventProducer.invalidChild">"{offendingNode}" is not a valid child of "{elementName}"![ {ruleViolated,lookup}]{{locator}}</message>
   <message key="org.apache.fop.fo.FOValidationEventProducer.missingChildElement">"{elementName}" is missing child elements.[
 Required content model: {contentModel}]{{locator}}</message>
   <message key="org.apache.fop.fo.FOValidationEventProducer.missingProperty">Element "{elementName}" is missing required property "{propertyName}"!{{locator}}</message>
index 4b1cfeeac624a8bc17f1ee40332afa88bfe60ec8..dfe837315d7cd9a6011d344afb934fa347f8b2a2 100644 (file)
@@ -22,9 +22,10 @@ package org.apache.fop.fo.flow;
 import org.xml.sax.Locator;
 
 import org.apache.fop.apps.FOPException;
+import org.apache.fop.fo.Constants;
 import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.FOText;
 import org.apache.fop.fo.FObjMixed;
-import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.ValidationException;
 
 /**
@@ -39,25 +40,15 @@ public class Wrapper extends FObjMixed {
     
     // used for FO validation
     private boolean blockOrInlineItemFound = false;
-    private boolean inlineChildrenAllowed = false;
 
     /**
-     * Base constructor
+     * Create a Wrapper instance that is a child of the
+     * given {@link FONode}
      * 
      * @param parent {@link FONode} that is the parent of this object
      */
     public Wrapper(FONode parent) {
         super(parent);
-        /* Check if the fo:wrapper is a child of a FO that allows mixed content
-         * (or a descendant in nested fo:wrapper sequence, the first of which
-         *  is a child of a FO that allows mixed content) */
-        FONode ancestor = this.parent;
-        while (ancestor instanceof Wrapper) {
-            ancestor = ancestor.getParent();
-        }
-        if (ancestor instanceof FObjMixed ) {
-            inlineChildrenAllowed = true;
-        }
     }
 
     /**
@@ -66,7 +57,6 @@ public class Wrapper extends FObjMixed {
      * <br><i>Additionally (unimplemented): "An fo:wrapper that is a child of an 
      * fo:multi-properties is only permitted to have children that would 
      * be permitted in place of the fo:multi-properties."</i>
-     * 
      */
     protected void validateChildNode(Locator loc, String nsURI, String localName) 
         throws ValidationException {
@@ -77,8 +67,12 @@ public class Wrapper extends FObjMixed {
                         "(#PCDATA|%inline;|%block;)");
                 }
             } else if (isBlockOrInlineItem(nsURI, localName)) {
-                //delegate validation to parent
-                FONode.validateChildNode(this.parent, loc, nsURI, localName);
+                try {
+                    //delegate validation to parent
+                    FONode.validateChildNode(this.parent, loc, nsURI, localName);
+                } catch (ValidationException vex) {
+                    invalidChildError(loc, getName(), FO_URI, localName, "rule.wrapperInvalidChildForParent");
+                }
                 blockOrInlineItemFound = true;
             } else {
                 invalidChildError(loc, nsURI, localName);
@@ -87,15 +81,27 @@ public class Wrapper extends FObjMixed {
     }
 
     /** {@inheritDoc} */
-    protected void addCharacters(
-                char[] data, 
-                int start, 
-                int end, 
-                PropertyList pList, 
-                Locator locator) throws FOPException {
-        /* Only add text if the fo:wrapper's parent allows inline children */
-        if (this.inlineChildrenAllowed) {
-            super.addCharacters(data, start, end, pList, locator);
+    protected void addChildNode(FONode child) throws FOPException {
+        super.addChildNode(child);
+        /* If the child is a text node, and it generates areas
+         * (i.e. contains either non-white-space or preserved
+         * white-space), then check whether the nearest non-wrapper
+         * ancestor allows this.
+         */
+        if (child instanceof FOText
+                && ((FOText)child).willCreateArea()) {
+            FONode ancestor = parent;
+            while (ancestor.getNameId() == Constants.FO_WRAPPER) {
+                ancestor = ancestor.getParent();
+            }
+            if (!(ancestor instanceof FObjMixed)) {
+                invalidChildError(
+                        getLocator(),
+                        getLocalName(),
+                        FONode.FO_URI,
+                        "#PCDATA",
+                        "rule.wrapperInvalidChildForParent");
+            }
         }
     }
 
index e9d529ebe30770575f0e26ff038930a01a57f647..b208e4e9b33e4fc4d05b976ee26bc1e1f9322eb0 100644 (file)
@@ -1527,10 +1527,20 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager
     protected void wrapPositionElements(List sourceList, List targetList, boolean force) {
           
         ListIterator listIter = sourceList.listIterator();
+        Object tempElement;
         while (listIter.hasNext()) {
-            ListElement tempElement;
-            tempElement = (ListElement) listIter.next();
-            wrapPositionElement(tempElement, targetList, force);
+            tempElement = listIter.next();
+            if (tempElement instanceof ListElement) {
+                wrapPositionElement(
+                        (ListElement) tempElement,
+                        targetList,
+                        force);
+            } else if (tempElement instanceof List) {
+                wrapPositionElements(
+                        (List) tempElement, 
+                        targetList,
+                        force);
+            }
         }
     }
 
index c54f0ce121aebc321e221393e9ebfb32409700e6..9cd5c622d21c4613b1bccf15f1836dbc1af04cda 100644 (file)
@@ -30,6 +30,7 @@ import org.apache.fop.area.Area;
 import org.apache.fop.area.BlockParent;
 import org.apache.fop.fo.pagination.Flow;
 import org.apache.fop.layoutmgr.inline.InlineLevelLayoutManager;
+import org.apache.fop.layoutmgr.inline.WrapperLayoutManager;
 
 /**
  * LayoutManager for an fo:flow object.
@@ -75,7 +76,8 @@ public class FlowLayoutManager extends BlockStackingLayoutManager
         LinkedList returnList = new LinkedList();
 
         while ((curLM = getChildLM()) != null) {
-            if (curLM instanceof InlineLevelLayoutManager) {
+            if (!(curLM instanceof WrapperLayoutManager)
+                && curLM instanceof InlineLevelLayoutManager) {
                 log.error("inline area not allowed under flow - ignoring");
                 curLM.setFinished(true);
                 continue;
index 09e22d481f216feba7157b842951b8ec5106084c..8108bbf405bb9676cb968020dd26c5b855e75cfb 100644 (file)
 package org.apache.fop.layoutmgr.inline;
 
 import org.apache.fop.area.inline.InlineArea;
+import org.apache.fop.area.inline.InlineParent;
+import org.apache.fop.area.Block;
+import org.apache.fop.area.LineArea;
 import org.apache.fop.fo.flow.Wrapper;
+import org.apache.fop.layoutmgr.BlockLayoutManager;
+import org.apache.fop.layoutmgr.BlockStackingLayoutManager;
 import org.apache.fop.layoutmgr.LayoutContext;
 import org.apache.fop.layoutmgr.PositionIterator;
 import org.apache.fop.layoutmgr.TraitSetter;
@@ -66,7 +71,19 @@ public class WrapperLayoutManager extends LeafNodeLayoutManager {
         if (fobj.hasId()) {
             addId();
             InlineArea area = getEffectiveArea();
-            parentLM.addChildArea(area);
+            if (parentLM instanceof BlockStackingLayoutManager
+                    && !(parentLM instanceof BlockLayoutManager)) {
+                Block helperBlock = new Block();
+                LineArea helperLine = new LineArea();
+                InlineParent helperInline = new InlineParent();
+                helperInline.addChildArea(area);
+                helperLine.addInlineArea(helperInline);
+                helperLine.updateExtentsFromChildren();
+                helperBlock.addLineArea(helperLine);
+                parentLM.addChildArea(helperBlock);
+            } else {
+                parentLM.addChildArea(area);
+            }
         }
         while (posIter.hasNext()) {
             posIter.next();
index 90992bb56c83d5a4276e6df20c2eb8a0779ec14c..a48920e36510a9fa100f71d8f775959acc75cddf 100644 (file)
       <action context="Renderers" dev="AC" importance="high" type="add">
         Added SVG support for AFP (GOCA).
       </action -->
+      <action context="Code" dev="AD" type="fix" fixes-bug="42423">
+        Added support for the "id" attribute on fo:wrappers when used
+        as a child of the fo:flow.
+      </action>
+      <action context="Code" dev="AD" type="fix" fixes-bug="41500">
+        Fixed a ClassCastException when using an fo:wrapper as a child
+        of an fo:block-container.
+      </action>
       <action context="Fonts" dev="AC" type="add">
         Add support for font substitution.
       </action>
-      <action context="Code" dev="AD" type="fix" fixed-bug="44203">
       <action context="Renderers" dev="JM" type="fix" fixes-bug="43650">
         PCL Renderer: Improved page format selection so it doesn't interfere with
         duplex printing.
index 12d7ed1aad2f75b2dd86295173de21f360dd5073..c17457a3d92412a2f70b5f7d85206f6302356fe0 100644 (file)
     is probably not expressing the indended outcome according to the spec. The test
     case should be revisited.</description>
   </testcase>
-  <testcase>
-    <name>fo:wrapper around block-level content (with id)</name>
-    <file>wrapper_block_id.xml</file>
-    <description>"id" attributes on fo:wrapper around block-level content don't get
-    added to the area tree.</description>
-  </testcase>
   <testcase>
     <name>Soft hyphen with normal hyphenation enabled</name>
     <file>block_shy_linebreaking_hyph.xml</file>