You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-commits@xmlgraphics.apache.org by je...@apache.org on 2005/12/07 16:15:59 UTC

svn commit: r354763 - in /xmlgraphics/fop/trunk: src/documentation/content/xdocs/trunk/ src/java/org/apache/fop/apps/ src/java/org/apache/fop/fo/properties/ test/fotree/testcases/ test/java/org/apache/fop/fotreetest/

Author: jeremias
Date: Wed Dec  7 07:15:38 2005
New Revision: 354763

URL: http://svn.apache.org/viewcvs?rev=354763&view=rev
Log:
Alternative set of rules for text indent calculation (start-indent and end-indent) which tries to mimic many commercial FO implementation that have chosen to break the specification in this aspect. I think I have found the behaviour for most cases. But I'm operating in reverse-engineering mode here and not all FO implementations behave in the same way!
This is an optional feature that has to be explicitely enabled through the user agent. Otherwise, FOP will behave like before.
In the FO tree tests a processing instruction is used to enable the feature/bug ;-) in the user agent so I can test both cases.

Added:
    xmlgraphics/fop/trunk/test/fotree/testcases/indent-inheritance1.fo   (with props)
    xmlgraphics/fop/trunk/test/fotree/testcases/indent-inheritance2.fo   (with props)
    xmlgraphics/fop/trunk/test/fotree/testcases/indent-inheritance2a.fo   (with props)
Modified:
    xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/configuration.xml
    xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/embedding.xml
    xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FOUserAgent.java
    xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/IndentPropertyMaker.java
    xmlgraphics/fop/trunk/test/java/org/apache/fop/fotreetest/FOTreeTester.java

Modified: xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/configuration.xml
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/configuration.xml?rev=354763&r1=354762&r2=354763&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/configuration.xml (original)
+++ xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/configuration.xml Wed Dec  7 07:15:38 2005
@@ -76,6 +76,28 @@
         <td>Resolution in dpi (dots per inch) which is used internally.</td>
       </tr>
       <tr>
+        <td>strict-validation</td>
+        <td>Boolean (true, false)</td>
+        <td>
+          Setting this option to 'false' causes FOP to be more forgiving about XSL-FO validity, 
+          for example, you're allowed to specify a border on a region-body which is supported 
+          by some FO implementations but is non-standard. Note that such a border would 
+          currently have no effect in Apache FOP.</td>
+      </tr>
+      <tr>
+        <td>break-indent-inheritance</td>
+        <td>Boolean (true, false)</td>
+        <td>
+          Setting this option to 'true' causes FOP to use an alternative rule set to determine
+          text indents specified through margins, start-indent and end-indent. Many commercial
+          FO implementations have chosen to break the XSL specification in this aspect. This
+          option tries to mimic their behaviour. Please note that Apache FOP may still not
+          behave exactly like those implementations either because FOP has not fully matched
+          the desired behaviour and because the behaviour among the commercial implementations
+          varies. The default for this option (i.e. false) is to behave exactly like the 
+          specification describes.</td>
+      </tr>
+      <tr>
         <td>default-page-settings</td>
         <td>n/a</td>
         <td>

Modified: xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/embedding.xml
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/embedding.xml?rev=354763&r1=354762&r2=354763&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/embedding.xml (original)
+++ xmlgraphics/fop/trunk/src/documentation/content/xdocs/trunk/embedding.xml Wed Dec  7 07:15:38 2005
@@ -359,6 +359,15 @@
         </p>
         <source>userAgent.setPDFEncryptionParams(new PDFEncryptionParams(null, "owner", false, false, true, true));</source>
       </li>
+      <li>
+        <p>
+          Enable an <strong>alternative set of rules for text indents</strong> that tries to mimic the behaviour of many commercial 
+          FO implementations that chose to break the specification in this aspect. The default of this option is 
+          'false' which causes Apache FOP to behave exactly as describes in the specification. To enable the 
+          alternative behaviour, call:
+        </p>
+        <source>userAgent.setBreakIndentInheritanceOnReferenceAreaBoundary(true);</source>
+      </li>
     </ul>
     <note>
       You should not reuse an FOUserAgent instance between FOP rendering runs although you can. Especially

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FOUserAgent.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FOUserAgent.java?rev=354763&r1=354762&r2=354763&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FOUserAgent.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/apps/FOUserAgent.java Wed Dec  7 07:15:38 2005
@@ -111,6 +111,9 @@
      * ability for FOP to halt on all content model violations if desired.   
      */ 
     private boolean strictValidation = true;
+    
+    /** @see #setBreakIndentInheritanceOnReferenceAreaBoundary(boolean) */
+    private boolean breakIndentInheritanceOnReferenceAreaBoundary = false;
 
     /* Additional fo.ElementMapping subclasses set by user */
     private List additionalElementMappings = null;
@@ -208,6 +211,31 @@
     }
 
     /**
+     * @return true if the indent inheritance should be broken when crossing reference area 
+     *         boundaries (for more info, see the javadoc for the relative member variable)
+     */
+    public boolean isBreakIndentInheritanceOnReferenceAreaBoundary() {
+        return breakIndentInheritanceOnReferenceAreaBoundary;
+    }
+
+    /**
+     * Controls whether to enable a feature that breaks indent inheritance when crossing
+     * reference area boundaries.
+     * <p>
+     * This flag controls whether FOP will enable special code that breaks property
+     * inheritance for start-indent and end-indent when the evaluation of the inherited
+     * value would cross a reference area. This is described under
+     * http://wiki.apache.org/xmlgraphics-fop/IndentInheritance as is intended to
+     * improve interoperability with commercial FO implementations and to produce
+     * results that are more in line with the expectation of unexperienced FO users.
+     * Note: Enabling this features violates the XSL specification!
+     * @param value true to enable the feature
+     */
+    public void setBreakIndentInheritanceOnReferenceAreaBoundary(boolean value) {
+        this.breakIndentInheritanceOnReferenceAreaBoundary = value;
+    }
+    
+    /**
      * Sets an explicit LayoutManagerMaker instance which overrides the one
      * defined by the AreaTreeHandler.
      * @param lmMaker the LayoutManagerMaker instance
@@ -394,6 +422,13 @@
             log.info("resolution set to: " + resolution 
                     + "dpi (px2mm=" + getPixelUnitToMillimeter() + ")");
         }
+        if (userConfig.getChild("strict-validation", false) != null) {
+            this.strictValidation = userConfig.getChild("strict-validation").getValueAsBoolean();
+        }
+        if (userConfig.getChild("break-indent-inheritance", false) != null) {
+            this.breakIndentInheritanceOnReferenceAreaBoundary 
+                = userConfig.getChild("break-indent-inheritance").getValueAsBoolean();
+        }
         Configuration pageConfig = userConfig.getChild("default-page-settings");
         if (pageConfig.getAttribute("height", null) != null) {
             setPageHeight(pageConfig.getAttribute("height"));
@@ -615,7 +650,6 @@
     public XMLHandlerRegistry getXMLHandlerRegistry() {
         return this.xmlHandlers;
     }
-    
     
 }
 

Modified: xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/IndentPropertyMaker.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/IndentPropertyMaker.java?rev=354763&r1=354762&r2=354763&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/IndentPropertyMaker.java (original)
+++ xmlgraphics/fop/trunk/src/java/org/apache/fop/fo/properties/IndentPropertyMaker.java Wed Dec  7 07:15:38 2005
@@ -19,6 +19,8 @@
 package org.apache.fop.fo.properties;
 
 import org.apache.fop.datatypes.Numeric;
+import org.apache.fop.fo.FONode;
+import org.apache.fop.fo.FObj;
 import org.apache.fop.fo.PropertyList;
 import org.apache.fop.fo.expr.NumericOp;
 import org.apache.fop.fo.expr.PropertyException;
@@ -68,6 +70,19 @@
      * @see CorrespondingPropertyMaker#compute(PropertyList)
      */
     public Property compute(PropertyList propertyList) throws PropertyException {
+        if (propertyList.getFObj().getUserAgent()
+                    .isBreakIndentInheritanceOnReferenceAreaBoundary()) {
+            return computeAlternativeRuleset(propertyList);
+        } else {
+            return computeConforming(propertyList);
+        }
+    }
+    
+    /**
+     * Calculate the corresponding value for start-indent and end-indent.  
+     * @see CorrespondingPropertyMaker#compute(PropertyList)
+     */
+    public Property computeConforming(PropertyList propertyList) throws PropertyException {
         PropertyList pList = getWMPropertyList(propertyList);
         if (pList == null) {
             return null;
@@ -97,6 +112,79 @@
         
         Numeric v = new FixedLength(0);
         if (!propertyList.getFObj().generatesReferenceAreas()) {
+            // The inherited_value_of([start|end]-indent)
+            v = NumericOp.addition(v, propertyList.getInherited(baseMaker.propId).getNumeric());
+        }
+        // The corresponding absolute margin-[right|left}.
+        v = NumericOp.addition(v, margin);
+        v = NumericOp.addition(v, padding);
+        v = NumericOp.addition(v, border);
+        return (Property) v;
+    }
+    
+    private boolean isInherited(PropertyList pList) {
+        if (pList.getFObj().getUserAgent().isBreakIndentInheritanceOnReferenceAreaBoundary()) {
+            FONode nd = pList.getFObj().getParent(); 
+            return !((nd instanceof FObj) && ((FObj)nd).generatesReferenceAreas());
+        } else {
+            return true;
+        }
+    }
+    
+    /**
+     * Calculate the corresponding value for start-indent and end-indent.
+     * This method calculates indent following an alternative rule set that
+     * tries to mimic many commercial solutions that chose to violate the
+     * XSL specification.  
+     * @see CorrespondingPropertyMaker#compute(PropertyList)
+     */
+    public Property computeAlternativeRuleset(PropertyList propertyList) throws PropertyException {
+        PropertyList pList = getWMPropertyList(propertyList);
+        if (pList == null) {
+            return null;
+        }
+
+        // Calculate the values as described in 5.3.2.
+
+        Numeric padding = getCorresponding(paddingCorresponding, propertyList).getNumeric();
+        Numeric border = getCorresponding(borderWidthCorresponding, propertyList).getNumeric();
+        
+        int marginProp = pList.getWritingMode(lr_tb, rl_tb, tb_rl);
+
+        //Determine whether the nearest anscestor indent was specified through 
+        //start-indent|end-indent or through a margin property.
+        boolean marginNearest = false;
+        PropertyList pl = propertyList.getParentPropertyList();
+        while (pl != null) {
+            if (pl.getExplicit(baseMaker.propId) != null) {
+                break;
+            } else if (pl.getExplicitOrShorthand(marginProp) != null) {
+                marginNearest = true;
+                break;
+            }
+            pl = pl.getParentPropertyList();
+        }
+        
+        Numeric margin;
+        // Calculate the absolute margin.
+        if (propertyList.getExplicitOrShorthand(marginProp) == null) {
+            Property indent = propertyList.getExplicit(baseMaker.propId);
+            if (indent == null) {
+                //Neither start-indent nor margin is specified, use inherited
+                if (isInherited(propertyList) || !marginNearest) {
+                    return null;
+                } else {
+                    return new FixedLength(0);
+                }
+            } else {
+                return indent;
+            }
+        } else {
+            margin = propertyList.get(marginProp).getNumeric();
+        }
+        
+        Numeric v = new FixedLength(0);
+        if (isInherited(propertyList)) {
             // The inherited_value_of([start|end]-indent)
             v = NumericOp.addition(v, propertyList.getInherited(baseMaker.propId).getNumeric());
         }

Added: xmlgraphics/fop/trunk/test/fotree/testcases/indent-inheritance1.fo
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/test/fotree/testcases/indent-inheritance1.fo?rev=354763&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/test/fotree/testcases/indent-inheritance1.fo (added)
+++ xmlgraphics/fop/trunk/test/fotree/testcases/indent-inheritance1.fo Wed Dec  7 07:15:38 2005
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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$ -->
+<!-- This test verifies basic start-indent and end-indent inheritance. -->
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:test="http://xmlgraphics.apache.org/fop/test">
+  <fo:layout-master-set>
+    <fo:simple-page-master master-name="A4" page-height="29.7cm" page-width="21cm" margin="2cm">
+      <fo:region-body/>
+    </fo:simple-page-master>
+  </fo:layout-master-set>
+  <fo:page-sequence master-reference="A4">
+    <fo:flow flow-name="xsl-region-body">
+      <fo:block>Hello World!
+        <test:assert property="start-indent" expected="0mpt"/>
+        <test:assert property="end-indent" expected="0mpt"/>
+      </fo:block>
+      <fo:block start-indent="10pt" end-indent="15pt">Hello World!
+        <test:assert property="start-indent" expected="10000mpt"/>
+        <test:assert property="end-indent" expected="15000mpt"/>
+        <fo:block>nested
+          <test:assert property="start-indent" expected="10000mpt"/>
+          <test:assert property="end-indent" expected="15000mpt"/>
+        </fo:block>
+        <fo:block-container>
+          <test:assert property="start-indent" expected="10000mpt"/>
+          <test:assert property="end-indent" expected="15000mpt"/>
+          <fo:block>nested in b-c
+            <test:assert property="start-indent" expected="10000mpt"/>
+            <test:assert property="end-indent" expected="15000mpt"/>
+            <fo:block>nested2 in b-c
+              <test:assert property="start-indent" expected="10000mpt"/>
+              <test:assert property="end-indent" expected="15000mpt"/>
+            </fo:block>
+          </fo:block>
+        </fo:block-container>
+      </fo:block>
+    </fo:flow>
+  </fo:page-sequence>
+</fo:root>

Propchange: xmlgraphics/fop/trunk/test/fotree/testcases/indent-inheritance1.fo
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/test/fotree/testcases/indent-inheritance1.fo
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/trunk/test/fotree/testcases/indent-inheritance2.fo
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/test/fotree/testcases/indent-inheritance2.fo?rev=354763&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/test/fotree/testcases/indent-inheritance2.fo (added)
+++ xmlgraphics/fop/trunk/test/fotree/testcases/indent-inheritance2.fo Wed Dec  7 07:15:38 2005
@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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$ -->
+<!-- This test verifies basic start-indent and end-indent inheritance. -->
+<?fop-useragent-break-indent-inheritance false?>
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:test="http://xmlgraphics.apache.org/fop/test">
+  <fo:layout-master-set>
+    <fo:simple-page-master master-name="A4" page-height="29.7cm" page-width="21cm" margin="2cm">
+      <fo:region-body background-color="lightgrey"/>
+    </fo:simple-page-master>
+  </fo:layout-master-set>
+  <fo:page-sequence master-reference="A4">
+    <fo:flow flow-name="xsl-region-body">
+      <fo:block font-style="italic">start-indent specified on outer block</fo:block>
+      <fo:block background-color="#FFFFCC">unindented
+        <test:assert property="start-indent" expected="0mpt"/>
+        <test:assert property="end-indent" expected="0mpt"/>
+      </fo:block>
+      <fo:block background-color="yellow" start-indent="10pt">fo:block
+        <test:assert property="start-indent" expected="10000mpt"/>
+        <test:assert property="end-indent" expected="0mpt"/>
+        <fo:block background-color="orange">fo:block|fo:block
+          <test:assert property="start-indent" expected="10000mpt"/>
+          <test:assert property="end-indent" expected="0mpt"/>
+        </fo:block>
+        <fo:block-container>
+          <test:assert property="start-indent" expected="10000mpt"/>
+          <test:assert property="end-indent" expected="0mpt"/>
+          <fo:block background-color="red">fo:block|fo:block-container|fo:block
+            <test:assert property="start-indent" expected="10000mpt"/>
+            <test:assert property="end-indent" expected="0mpt"/>
+          </fo:block>
+        </fo:block-container>
+      </fo:block>
+      <fo:block space-before="10pt" font-style="italic">start-indent specified on outer block (reset to 0pt on inner block and the block-container)</fo:block>
+      <fo:block background-color="#FFFFCC">unindented</fo:block>
+      <fo:block background-color="yellow" start-indent="10pt">fo:block
+        <test:assert property="start-indent" expected="10000mpt"/>
+        <test:assert property="end-indent" expected="0mpt"/>
+        <fo:block start-indent="0pt" background-color="orange">fo:block|fo:block
+          <test:assert property="start-indent" expected="0mpt"/>
+          <test:assert property="end-indent" expected="0mpt"/>
+        </fo:block>
+        <fo:block-container start-indent="0pt">
+          <test:assert property="start-indent" expected="0mpt"/>
+          <test:assert property="end-indent" expected="0mpt"/>
+          <fo:block background-color="red">fo:block|fo:block-container|fo:block
+            <test:assert property="start-indent" expected="0mpt"/>
+            <test:assert property="end-indent" expected="0mpt"/>
+          </fo:block>
+        </fo:block-container>
+      </fo:block>
+      <fo:block space-before="10pt" font-style="italic">start-indent specified on outer block (reset to 0pt on nested block in the block-container)</fo:block>
+      <fo:block background-color="#FFFFCC">unindented</fo:block>
+      <fo:block background-color="yellow" start-indent="10pt">fo:block
+        <test:assert property="start-indent" expected="10000mpt"/>
+        <test:assert property="end-indent" expected="0mpt"/>
+        <fo:block-container>
+          <test:assert property="start-indent" expected="10000mpt"/>
+          <test:assert property="end-indent" expected="0mpt"/>
+          <fo:block start-indent="0pt" background-color="red">fo:block|fo:block-container|fo:block
+            <test:assert property="start-indent" expected="0mpt"/>
+            <test:assert property="end-indent" expected="0mpt"/>
+          </fo:block>
+        </fo:block-container>
+      </fo:block>
+      <fo:block space-before="10pt" font-style="italic">margin-left specified on outer block</fo:block>
+      <fo:block background-color="#FFFFCC">unindented</fo:block>
+      <fo:block background-color="yellow" margin-left="10pt">fo:block
+        <test:assert property="start-indent" expected="10000mpt"/>
+        <test:assert property="end-indent" expected="0mpt"/>
+        <fo:block background-color="orange">fo:block|fo:block
+          <test:assert property="start-indent" expected="10000mpt"/>
+          <test:assert property="end-indent" expected="0mpt"/>
+        </fo:block>
+        <fo:block-container>
+          <test:assert property="start-indent" expected="10000mpt"/>
+          <test:assert property="end-indent" expected="0mpt"/>
+          <fo:block background-color="red">fo:block|fo:block-container|fo:block
+            <test:assert property="start-indent" expected="10000mpt"/>
+            <test:assert property="end-indent" expected="0mpt"/>
+          </fo:block>
+        </fo:block-container>
+      </fo:block>
+      <fo:block space-before="10pt" font-style="italic">margin-left specified on outer block (set to 0pt on inner block and the block-container)</fo:block>
+      <fo:block background-color="#FFFFCC">unindented</fo:block>
+      <fo:block background-color="yellow" margin-left="10pt">fo:block
+        <test:assert property="start-indent" expected="10000mpt"/>
+        <test:assert property="end-indent" expected="0mpt"/>
+        <fo:block  margin-left="0pt" background-color="orange">fo:block|fo:block
+          <test:assert property="start-indent" expected="10000mpt"/>
+          <test:assert property="end-indent" expected="0mpt"/>
+        </fo:block>
+        <fo:block-container margin-left="0pt">
+          <test:assert property="start-indent" expected="0mpt"/>
+          <test:assert property="end-indent" expected="0mpt"/>
+          <fo:block background-color="red">fo:block|fo:block-container|fo:block
+            <test:assert property="start-indent" expected="0mpt"/>
+            <test:assert property="end-indent" expected="0mpt"/>
+          </fo:block>
+        </fo:block-container>
+      </fo:block>
+      <fo:block space-before="10pt" font-style="italic">margin-left specified on outer block (reset to 0pt on nested block in the block-container)</fo:block>
+      <fo:block background-color="#FFFFCC">unindented</fo:block>
+      <fo:block background-color="yellow" margin-left="10pt">fo:block
+        <test:assert property="start-indent" expected="10000mpt"/>
+        <test:assert property="end-indent" expected="0mpt"/>
+        <fo:block-container>
+          <test:assert property="start-indent" expected="10000mpt"/>
+          <test:assert property="end-indent" expected="0mpt"/>
+          <fo:block margin-left="0pt" background-color="red">fo:block|fo:block-container|fo:block
+            <test:assert property="start-indent" expected="10000mpt"/>
+            <test:assert property="end-indent" expected="0mpt"/>
+          </fo:block>
+        </fo:block-container>
+      </fo:block>
+    </fo:flow>
+  </fo:page-sequence>
+</fo:root>

Propchange: xmlgraphics/fop/trunk/test/fotree/testcases/indent-inheritance2.fo
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/test/fotree/testcases/indent-inheritance2.fo
------------------------------------------------------------------------------
    svn:keywords = Id

Added: xmlgraphics/fop/trunk/test/fotree/testcases/indent-inheritance2a.fo
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/test/fotree/testcases/indent-inheritance2a.fo?rev=354763&view=auto
==============================================================================
--- xmlgraphics/fop/trunk/test/fotree/testcases/indent-inheritance2a.fo (added)
+++ xmlgraphics/fop/trunk/test/fotree/testcases/indent-inheritance2a.fo Wed Dec  7 07:15:38 2005
@@ -0,0 +1,163 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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$ -->
+<!-- This test verifies basic start-indent and end-indent inheritance with broken indent inheritance enabled. -->
+<?fop-useragent-break-indent-inheritance true?>
+<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:test="http://xmlgraphics.apache.org/fop/test">
+  <fo:layout-master-set>
+    <fo:simple-page-master master-name="A4" page-height="29.7cm" page-width="21cm" margin="2cm">
+      <fo:region-body background-color="lightgrey"/>
+    </fo:simple-page-master>
+  </fo:layout-master-set>
+  <fo:page-sequence master-reference="A4">
+    <fo:flow flow-name="xsl-region-body">
+      <fo:block font-style="italic">start-indent specified on outer block</fo:block>
+      <fo:block background-color="#FFFFCC">unindented
+        <test:assert property="start-indent" expected="0mpt"/>
+        <test:assert property="end-indent" expected="0mpt"/>
+      </fo:block>
+      <fo:block background-color="yellow" start-indent="10pt">fo:block
+        <test:assert property="start-indent" expected="10000mpt"/>
+        <test:assert property="end-indent" expected="0mpt"/>
+        <fo:block background-color="orange">fo:block|fo:block
+          <test:assert property="start-indent" expected="10000mpt"/>
+          <test:assert property="end-indent" expected="0mpt"/>
+        </fo:block>
+        <fo:block-container>
+          <test:assert property="start-indent" expected="10000mpt"/>
+          <test:assert property="end-indent" expected="0mpt"/>
+          <fo:block background-color="red">fo:block|fo:block-container|fo:block
+            <test:assert property="start-indent" expected="10000mpt"/>
+            <test:assert property="end-indent" expected="0mpt"/>
+          </fo:block>
+        </fo:block-container>
+      </fo:block>
+      <fo:block space-before="10pt" font-style="italic">start-indent specified on outer block (reset to 0pt on inner block and the block-container)</fo:block>
+      <fo:block background-color="#FFFFCC">unindented</fo:block>
+      <fo:block background-color="yellow" start-indent="10pt">fo:block
+        <test:assert property="start-indent" expected="10000mpt"/>
+        <test:assert property="end-indent" expected="0mpt"/>
+        <fo:block start-indent="0pt" background-color="orange">fo:block|fo:block
+          <test:assert property="start-indent" expected="0mpt"/>
+          <test:assert property="end-indent" expected="0mpt"/>
+        </fo:block>
+        <fo:block-container start-indent="0pt">
+          <test:assert property="start-indent" expected="0mpt"/>
+          <test:assert property="end-indent" expected="0mpt"/>
+          <fo:block background-color="red">fo:block|fo:block-container|fo:block
+            <test:assert property="start-indent" expected="0mpt"/>
+            <test:assert property="end-indent" expected="0mpt"/>
+          </fo:block>
+        </fo:block-container>
+      </fo:block>
+      <fo:block space-before="10pt" font-style="italic">start-indent specified on outer block (reset to 0pt on nested block in the block-container)</fo:block>
+      <fo:block background-color="#FFFFCC">unindented</fo:block>
+      <fo:block background-color="yellow" start-indent="10pt">fo:block
+        <test:assert property="start-indent" expected="10000mpt"/>
+        <test:assert property="end-indent" expected="0mpt"/>
+        <fo:block-container>
+          <test:assert property="start-indent" expected="10000mpt"/>
+          <test:assert property="end-indent" expected="0mpt"/>
+          <fo:block start-indent="0pt" background-color="red">fo:block|fo:block-container|fo:block
+            <test:assert property="start-indent" expected="0mpt"/>
+            <test:assert property="end-indent" expected="0mpt"/>
+          </fo:block>
+        </fo:block-container>
+      </fo:block>
+      <fo:block space-before="10pt" font-style="italic">margin-left specified on outer block</fo:block>
+      <fo:block background-color="#FFFFCC">unindented</fo:block>
+      <fo:block background-color="yellow" margin-left="10pt">fo:block
+        <test:assert property="start-indent" expected="10000mpt"/>
+        <test:assert property="end-indent" expected="0mpt"/>
+        <fo:block background-color="orange">fo:block|fo:block
+          <test:assert property="start-indent" expected="10000mpt"/>
+          <test:assert property="end-indent" expected="0mpt"/>
+        </fo:block>
+        <fo:block margin-left="5pt" background-color="orange">fo:block|fo:block (further indented using margin-left)
+          <test:assert property="start-indent" expected="15000mpt"/>
+          <test:assert property="end-indent" expected="0mpt"/>
+        </fo:block>
+        <fo:block-container>
+          <test:assert property="start-indent" expected="10000mpt"/>
+          <test:assert property="end-indent" expected="0mpt"/>
+          <fo:block background-color="red">fo:block|fo:block-container|fo:block
+            <test:assert property="start-indent" expected="0mpt"/>
+            <test:assert property="end-indent" expected="0mpt"/>
+          </fo:block>
+        </fo:block-container>
+      </fo:block>
+      <fo:block space-before="10pt" font-style="italic">margin-left specified on outer block (set to 0pt on inner block and the block-container)</fo:block>
+      <fo:block background-color="#FFFFCC">unindented</fo:block>
+      <fo:block background-color="yellow" margin-left="10pt">fo:block
+        <test:assert property="start-indent" expected="10000mpt"/>
+        <test:assert property="end-indent" expected="0mpt"/>
+        <fo:block margin-left="0pt" background-color="orange">fo:block|fo:block
+          <test:assert property="start-indent" expected="10000mpt"/>
+          <test:assert property="end-indent" expected="0mpt"/>
+        </fo:block>
+        <fo:block-container margin-left="0pt">
+          <test:assert property="start-indent" expected="10000mpt"/>
+          <test:assert property="end-indent" expected="0mpt"/>
+          <fo:block background-color="red">fo:block|fo:block-container|fo:block
+            <test:assert property="start-indent" expected="0mpt"/>
+            <test:assert property="end-indent" expected="0mpt"/>
+          </fo:block>
+        </fo:block-container>
+      </fo:block>
+      <fo:block space-before="10pt" font-style="italic">margin-left specified on outer block (reset to 0pt on nested block in the block-container)</fo:block>
+      <fo:block background-color="#FFFFCC">unindented</fo:block>
+      <fo:block background-color="yellow" margin-left="10pt">fo:block
+        <test:assert property="start-indent" expected="10000mpt"/>
+        <test:assert property="end-indent" expected="0mpt"/>
+        <fo:block-container>
+          <test:assert property="start-indent" expected="10000mpt"/>
+          <test:assert property="end-indent" expected="0mpt"/>
+          <fo:block margin-left="0pt" background-color="red">fo:block|fo:block-container|fo:block
+            <test:assert property="start-indent" expected="0mpt"/>
+            <test:assert property="end-indent" expected="0mpt"/>
+          </fo:block>
+        </fo:block-container>
+      </fo:block>
+      <fo:block space-before="10pt" font-style="italic">margin-left specified on outer block and start-indent on nested elements</fo:block>
+      <fo:block background-color="#FFFFCC">unindented</fo:block>
+      <fo:block background-color="yellow" margin-left="10pt">fo:block
+        <test:assert property="start-indent" expected="10000mpt"/>
+        <test:assert property="end-indent" expected="0mpt"/>
+        <fo:block start-indent="30pt" background-color="orange">fo:block|fo:block
+          <test:assert property="start-indent" expected="30000mpt"/>
+          <test:assert property="end-indent" expected="0mpt"/>
+        </fo:block>
+        <fo:block-container start-indent="30pt" background-color="gray">
+          <test:assert property="start-indent" expected="30000mpt"/>
+          <test:assert property="end-indent" expected="0mpt"/>
+          <fo:block background-color="red">fo:block|fo:block-container|fo:block
+            <test:assert property="start-indent" expected="30000mpt"/>
+            <test:assert property="end-indent" expected="0mpt"/>
+          </fo:block>
+          <fo:block start-indent="0pt" background-color="red">fo:block|fo:block-container|fo:block
+            <test:assert property="start-indent" expected="0mpt"/>
+            <test:assert property="end-indent" expected="0mpt"/>
+          </fo:block>
+          <fo:block margin-left="0pt" background-color="red">fo:block|fo:block-container|fo:block
+            <test:assert property="start-indent" expected="0mpt"/>
+            <test:assert property="end-indent" expected="0mpt"/>
+          </fo:block>
+        </fo:block-container>
+      </fo:block>
+    </fo:flow>
+  </fo:page-sequence>
+</fo:root>

Propchange: xmlgraphics/fop/trunk/test/fotree/testcases/indent-inheritance2a.fo
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: xmlgraphics/fop/trunk/test/fotree/testcases/indent-inheritance2a.fo
------------------------------------------------------------------------------
    svn:keywords = Id

Modified: xmlgraphics/fop/trunk/test/java/org/apache/fop/fotreetest/FOTreeTester.java
URL: http://svn.apache.org/viewcvs/xmlgraphics/fop/trunk/test/java/org/apache/fop/fotreetest/FOTreeTester.java?rev=354763&r1=354762&r2=354763&view=diff
==============================================================================
--- xmlgraphics/fop/trunk/test/java/org/apache/fop/fotreetest/FOTreeTester.java (original)
+++ xmlgraphics/fop/trunk/test/java/org/apache/fop/fotreetest/FOTreeTester.java Wed Dec  7 07:15:38 2005
@@ -21,6 +21,8 @@
 import java.io.File;
 import java.util.List;
 
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
 import javax.xml.transform.Source;
 import javax.xml.transform.Transformer;
 import javax.xml.transform.sax.SAXResult;
@@ -32,6 +34,10 @@
 import org.apache.fop.apps.MimeConstants;
 
 import org.apache.fop.fotreetest.ext.TestElementMapping;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLFilterImpl;
 
 /**
  * Test driver class for FO tree tests.
@@ -50,19 +56,28 @@
         ResultCollector collector = ResultCollector.getInstance();
         collector.reset();
         
-        //Setup identity Transformer 
-        Transformer transformer = tfactory.newTransformer();
-        Source src = new StreamSource(testFile);
+        SAXParserFactory spf = SAXParserFactory.newInstance();
+        spf.setNamespaceAware(true);
+        spf.setValidating(false);
+        SAXParser parser = spf.newSAXParser();
+        XMLReader reader = parser.getXMLReader();
         
         //Setup FOP for area tree rendering
         FOUserAgent ua = new FOUserAgent();
         ua.setBaseURL(testFile.getParentFile().toURL().toString());
         ua.setFOEventHandlerOverride(new DummyFOEventHandler(ua));
         ua.addElementMapping(new TestElementMapping());
+
+        //Used to set values in the user agent through processing instructions
+        reader = new PIListener(reader, ua);
+        
         Fop fop = new Fop(MimeConstants.MIME_FOP_AREA_TREE, ua);
         
-        SAXResult fores = new SAXResult(fop.getDefaultHandler());
-        transformer.transform(src, fores);
+        reader.setContentHandler(fop.getDefaultHandler());
+        reader.setDTDHandler(fop.getDefaultHandler());
+        reader.setErrorHandler(fop.getDefaultHandler());
+        reader.setEntityResolver(fop.getDefaultHandler());
+        reader.parse(testFile.toURL().toExternalForm());
         
         List results = collector.getResults();
         if (results.size() > 0) {
@@ -73,4 +88,24 @@
         }
     }
 
+    private class PIListener extends XMLFilterImpl {
+        
+        private FOUserAgent userAgent;
+        
+        public PIListener(XMLReader parent, FOUserAgent userAgent) {
+            super(parent);
+            this.userAgent = userAgent;
+        }
+
+        /** @see org.xml.sax.helpers.XMLFilterImpl */
+        public void processingInstruction(String target, String data) throws SAXException {
+            if ("fop-useragent-break-indent-inheritance".equals(target)) {
+                userAgent.setBreakIndentInheritanceOnReferenceAreaBoundary(
+                        Boolean.valueOf(data).booleanValue());
+            }
+            super.processingInstruction(target, data);
+        }
+        
+    }
+    
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: fop-commits-unsubscribe@xmlgraphics.apache.org
For additional commands, e-mail: fop-commits-help@xmlgraphics.apache.org