View | Details | Raw Unified | Return to bug 47027
Collapse All | Expand All

(-)src/java/org/apache/fop/fo/expr/PropertyParser.java (-6 / +9 lines)
Lines 19-24 Link Here
19
19
20
package org.apache.fop.fo.expr;
20
package org.apache.fop.fo.expr;
21
21
22
import java.util.HashMap;
23
import java.util.LinkedList;
24
import java.util.List;
25
26
import org.apache.xmlgraphics.util.UnitConv;
27
22
import org.apache.fop.datatypes.Length;
28
import org.apache.fop.datatypes.Length;
23
import org.apache.fop.datatypes.LengthBase;
29
import org.apache.fop.datatypes.LengthBase;
24
import org.apache.fop.datatypes.Numeric;
30
import org.apache.fop.datatypes.Numeric;
Lines 31-40 Link Here
31
import org.apache.fop.fo.properties.Property;
37
import org.apache.fop.fo.properties.Property;
32
import org.apache.fop.fo.properties.StringProperty;
38
import org.apache.fop.fo.properties.StringProperty;
33
39
34
import java.util.HashMap;
35
import java.util.LinkedList;
36
import java.util.List;
37
38
/**
40
/**
39
 * Class to parse XSL-FO property expressions.
41
 * Class to parse XSL-FO property expressions.
40
 * This class is heavily based on the epxression parser in James Clark's
42
 * This class is heavily based on the epxression parser in James Clark's
Lines 312-321 Link Here
312
                if ("px".equals(unitPart)) {
314
                if ("px".equals(unitPart)) {
313
                    //pass the ratio between target-resolution and
315
                    //pass the ratio between target-resolution and
314
                    //the default resolution of 72dpi
316
                    //the default resolution of 72dpi
317
                    float resolution = propInfo.getPropertyList().getFObj()
318
                            .getUserAgent().getSourceResolution();
315
                    prop = FixedLength.getInstance(
319
                    prop = FixedLength.getInstance(
316
                            numPart, unitPart,
320
                            numPart, unitPart,
317
                            propInfo.getPropertyList().getFObj()
321
                             UnitConv.IN2PT / resolution);
318
                                    .getUserAgent().getTargetResolution() / 72.0f);
319
                } else {
322
                } else {
320
                    //use default resolution of 72dpi
323
                    //use default resolution of 72dpi
321
                    prop = FixedLength.getInstance(numPart, unitPart);
324
                    prop = FixedLength.getInstance(numPart, unitPart);
(-)src/java/org/apache/fop/fo/properties/LengthProperty.java (-1 / +4 lines)
Lines 19-24 Link Here
19
19
20
package org.apache.fop.fo.properties;
20
package org.apache.fop.fo.properties;
21
21
22
import org.apache.xmlgraphics.util.UnitConv;
23
22
import org.apache.fop.datatypes.Length;
24
import org.apache.fop.datatypes.Length;
23
import org.apache.fop.datatypes.Numeric;
25
import org.apache.fop.datatypes.Numeric;
24
import org.apache.fop.fo.FObj;
26
import org.apache.fop.fo.FObj;
Lines 57-65 Link Here
57
            }
59
            }
58
            if (p instanceof NumberProperty) {
60
            if (p instanceof NumberProperty) {
59
                //Assume pixels (like in HTML) when there's no unit
61
                //Assume pixels (like in HTML) when there's no unit
62
                float resolution = propertyList.getFObj().getUserAgent().getSourceResolution();
60
                return FixedLength.getInstance(
63
                return FixedLength.getInstance(
61
                        p.getNumeric().getNumericValue(), "px",
64
                        p.getNumeric().getNumericValue(), "px",
62
                        propertyList.getFObj().getUserAgent().getTargetResolution() / 72.0f);
65
                        UnitConv.IN2PT / resolution);
63
            }
66
            }
64
            Length val = p.getLength();
67
            Length val = p.getLength();
65
            if (val != null) {
68
            if (val != null) {
(-)test/fotree/testcases/pixel_length_96dpi.fo (+34 lines)
Line 0 Link Here
1
<?xml version="1.0" encoding="UTF-8"?>
2
<!--
3
  Licensed to the Apache Software Foundation (ASF) under one or more
4
  contributor license agreements.  See the NOTICE file distributed with
5
  this work for additional information regarding copyright ownership.
6
  The ASF licenses this file to You under the Apache License, Version 2.0
7
  (the "License"); you may not use this file except in compliance with
8
  the License.  You may obtain a copy of the License at
9
10
       http://www.apache.org/licenses/LICENSE-2.0
11
12
  Unless required by applicable law or agreed to in writing, software
13
  distributed under the License is distributed on an "AS IS" BASIS,
14
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
  See the License for the specific language governing permissions and
16
  limitations under the License.
17
-->
18
<!-- $Id$ -->
19
<?fop-source-resolution 144?>
20
<fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:test="http://xmlgraphics.apache.org/fop/test">
21
  <fo:layout-master-set>
22
    <fo:simple-page-master master-name="normal" page-width="5in" page-height="5in">
23
      <fo:region-body/>
24
    </fo:simple-page-master>
25
  </fo:layout-master-set>
26
  <fo:page-sequence master-reference="normal">
27
    <fo:flow flow-name="xsl-region-body">
28
      <fo:block-container inline-progression-dimension="144px">
29
        <test:assert property="inline-progression-dimension.optimum" expected="72000mpt" />
30
        <fo:block>Block 1</fo:block>
31
      </fo:block-container>
32
    </fo:flow>
33
  </fo:page-sequence>
34
</fo:root>
0
  + Id
35
  + Id
1
  + native
36
  + native
(-)test/java/org/apache/fop/fotreetest/FOTreeTester.java (-4 / +17 lines)
Lines 32-37 Link Here
32
import org.apache.fop.apps.FOUserAgent;
32
import org.apache.fop.apps.FOUserAgent;
33
import org.apache.fop.apps.Fop;
33
import org.apache.fop.apps.Fop;
34
import org.apache.fop.apps.FopFactory;
34
import org.apache.fop.apps.FopFactory;
35
import org.apache.fop.apps.FopFactoryConfigurator;
35
import org.apache.fop.fotreetest.ext.TestElementMapping;
36
import org.apache.fop.fotreetest.ext.TestElementMapping;
36
import org.apache.fop.util.ConsoleEventListenerForTests;
37
import org.apache.fop.util.ConsoleEventListenerForTests;
37
38
Lines 64-71 Link Here
64
        SAXParser parser = spf.newSAXParser();
65
        SAXParser parser = spf.newSAXParser();
65
        XMLReader reader = parser.getXMLReader();
66
        XMLReader reader = parser.getXMLReader();
66
67
68
        //Resetting values modified by processing instructions
69
        fopFactory.setBreakIndentInheritanceOnReferenceAreaBoundary(
70
                FopFactoryConfigurator.DEFAULT_BREAK_INDENT_INHERITANCE);
71
        fopFactory.setSourceResolution(FopFactoryConfigurator.DEFAULT_SOURCE_RESOLUTION);
72
67
        FOUserAgent ua = fopFactory.newFOUserAgent();
73
        FOUserAgent ua = fopFactory.newFOUserAgent();
68
        ua.setBaseURL(testFile.getParentFile().toURL().toString());
74
        ua.setBaseURL(testFile.getParentFile().toURI().toURL().toString());
69
        ua.setFOEventHandlerOverride(new DummyFOEventHandler(ua));
75
        ua.setFOEventHandlerOverride(new DummyFOEventHandler(ua));
70
        ua.getEventBroadcaster().addEventListener(
76
        ua.getEventBroadcaster().addEventListener(
71
                new ConsoleEventListenerForTests(testFile.getName()));
77
                new ConsoleEventListenerForTests(testFile.getName()));
Lines 79-92 Link Here
79
        reader.setDTDHandler(fop.getDefaultHandler());
85
        reader.setDTDHandler(fop.getDefaultHandler());
80
        reader.setErrorHandler(fop.getDefaultHandler());
86
        reader.setErrorHandler(fop.getDefaultHandler());
81
        reader.setEntityResolver(fop.getDefaultHandler());
87
        reader.setEntityResolver(fop.getDefaultHandler());
82
        reader.parse(testFile.toURL().toExternalForm());
88
        try {
89
            reader.parse(testFile.toURI().toURL().toExternalForm());
90
        } catch (Exception e) {
91
            collector.notifyError(e.getLocalizedMessage());
92
            throw e;
93
        }
83
94
84
        List results = collector.getResults();
95
        List results = collector.getResults();
85
        if (results.size() > 0) {
96
        if (results.size() > 0) {
86
            for (int i = 0; i < results.size(); i++) {
97
            for (int i = 0; i < results.size(); i++) {
87
                System.out.println(((Exception)results.get(i)).getMessage());
98
                System.out.println((String)results.get(i));
88
            }
99
            }
89
            throw (Exception)results.get(0);
100
            throw new IllegalStateException((String)results.get(0));
90
        }
101
        }
91
    }
102
    }
92
103
Lines 104-109 Link Here
104
            if ("fop-useragent-break-indent-inheritance".equals(target)) {
115
            if ("fop-useragent-break-indent-inheritance".equals(target)) {
105
                userAgent.getFactory().setBreakIndentInheritanceOnReferenceAreaBoundary(
116
                userAgent.getFactory().setBreakIndentInheritanceOnReferenceAreaBoundary(
106
                        Boolean.valueOf(data).booleanValue());
117
                        Boolean.valueOf(data).booleanValue());
118
            } else if ("fop-source-resolution".equals(target)) {
119
                userAgent.getFactory().setSourceResolution(Float.parseFloat(data));
107
            }
120
            }
108
            super.processingInstruction(target, data);
121
            super.processingInstruction(target, data);
109
        }
122
        }
(-)test/java/org/apache/fop/fotreetest/ResultCollector.java (-7 / +18 lines)
Lines 23-29 Link Here
23
import java.util.List;
23
import java.util.List;
24
24
25
/**
25
/**
26
 * This class collects the results from assertions injected into the FO stream.
26
 * This class collects failures for assertions injected into the FO stream.
27
 */
27
 */
28
public class ResultCollector {
28
public class ResultCollector {
29
29
Lines 31-37 Link Here
31
31
32
    private List results = new java.util.ArrayList();
32
    private List results = new java.util.ArrayList();
33
33
34
    /** @return the ResultColletor singleton */
34
    /** @return the ResultCollector singleton */
35
    public static ResultCollector getInstance() {
35
    public static ResultCollector getInstance() {
36
        if (instance == null) {
36
        if (instance == null) {
37
            instance = new ResultCollector();
37
            instance = new ResultCollector();
Lines 45-58 Link Here
45
    }
45
    }
46
46
47
    /**
47
    /**
48
     * This notifies the ResultCollector about an Exception.
48
     * This notifies the ResultCollector about an assertion failure.
49
     * @param e the exception
49
     *
50
     * @param message   the message containing the details
50
     */
51
     */
51
    public void notifyException(Exception e) {
52
    public void notifyAssertionFailure(String message) {
52
        System.out.println(e.getMessage());
53
        System.out.println(message);
53
        results.add(e);
54
        results.add(message);
54
    }
55
    }
55
56
57
    /**
58
     * This notifies the ResultCollector about a testcase that ended
59
     * with a fatal error
60
     *
61
     * @param message   the message containing the details
62
     */
63
    public void notifyError(String message) {
64
        results.add(message);
65
    }
66
56
    /** Resets the result list. */
67
    /** Resets the result list. */
57
    public void reset() {
68
    public void reset() {
58
        results.clear();
69
        results.clear();

Return to bug 47027