ASF Bugzilla – Attachment 23506 Details for
Bug 47027
[PATCH] Proposed correction for resolution handling
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
same patch, but including another change in FOTreeTester
b47027.diff (text/plain), 9.13 KB, created by
Andreas L. Delmelle
on 2009-04-17 09:27:47 UTC
(
hide
)
Description:
same patch, but including another change in FOTreeTester
Filename:
MIME Type:
Creator:
Andreas L. Delmelle
Created:
2009-04-17 09:27:47 UTC
Size:
9.13 KB
patch
obsolete
>Index: src/java/org/apache/fop/fo/expr/PropertyParser.java >=================================================================== >--- src/java/org/apache/fop/fo/expr/PropertyParser.java (revision 764988) >+++ src/java/org/apache/fop/fo/expr/PropertyParser.java (working copy) >@@ -19,6 +19,12 @@ > > package org.apache.fop.fo.expr; > >+import java.util.HashMap; >+import java.util.LinkedList; >+import java.util.List; >+ >+import org.apache.xmlgraphics.util.UnitConv; >+ > import org.apache.fop.datatypes.Length; > import org.apache.fop.datatypes.LengthBase; > import org.apache.fop.datatypes.Numeric; >@@ -31,10 +37,6 @@ > import org.apache.fop.fo.properties.Property; > import org.apache.fop.fo.properties.StringProperty; > >-import java.util.HashMap; >-import java.util.LinkedList; >-import java.util.List; >- > /** > * Class to parse XSL-FO property expressions. > * This class is heavily based on the epxression parser in James Clark's >@@ -312,10 +314,11 @@ > if ("px".equals(unitPart)) { > //pass the ratio between target-resolution and > //the default resolution of 72dpi >+ float resolution = propInfo.getPropertyList().getFObj() >+ .getUserAgent().getSourceResolution(); > prop = FixedLength.getInstance( > numPart, unitPart, >- propInfo.getPropertyList().getFObj() >- .getUserAgent().getTargetResolution() / 72.0f); >+ UnitConv.IN2PT / resolution); > } else { > //use default resolution of 72dpi > prop = FixedLength.getInstance(numPart, unitPart); >Index: src/java/org/apache/fop/fo/properties/LengthProperty.java >=================================================================== >--- src/java/org/apache/fop/fo/properties/LengthProperty.java (revision 764988) >+++ src/java/org/apache/fop/fo/properties/LengthProperty.java (working copy) >@@ -19,6 +19,8 @@ > > package org.apache.fop.fo.properties; > >+import org.apache.xmlgraphics.util.UnitConv; >+ > import org.apache.fop.datatypes.Length; > import org.apache.fop.datatypes.Numeric; > import org.apache.fop.fo.FObj; >@@ -57,9 +59,10 @@ > } > if (p instanceof NumberProperty) { > //Assume pixels (like in HTML) when there's no unit >+ float resolution = propertyList.getFObj().getUserAgent().getSourceResolution(); > return FixedLength.getInstance( > p.getNumeric().getNumericValue(), "px", >- propertyList.getFObj().getUserAgent().getTargetResolution() / 72.0f); >+ UnitConv.IN2PT / resolution); > } > Length val = p.getLength(); > if (val != null) { >Index: test/fotree/testcases/pixel_length_96dpi.fo >=================================================================== >--- test/fotree/testcases/pixel_length_96dpi.fo (revision 0) >+++ test/fotree/testcases/pixel_length_96dpi.fo (revision 0) >@@ -0,0 +1,34 @@ >+<?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$ --> >+<?fop-source-resolution 144?> >+<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="normal" page-width="5in" page-height="5in"> >+ <fo:region-body/> >+ </fo:simple-page-master> >+ </fo:layout-master-set> >+ <fo:page-sequence master-reference="normal"> >+ <fo:flow flow-name="xsl-region-body"> >+ <fo:block-container inline-progression-dimension="144px"> >+ <test:assert property="inline-progression-dimension.optimum" expected="72000mpt" /> >+ <fo:block>Block 1</fo:block> >+ </fo:block-container> >+ </fo:flow> >+ </fo:page-sequence> >+</fo:root> > >Property changes on: test/fotree/testcases/pixel_length_96dpi.fo >___________________________________________________________________ >Name: svn:keywords > + Id >Name: svn:eol-style > + native > >Index: test/java/org/apache/fop/fotreetest/FOTreeTester.java >=================================================================== >--- test/java/org/apache/fop/fotreetest/FOTreeTester.java (revision 764988) >+++ test/java/org/apache/fop/fotreetest/FOTreeTester.java (working copy) >@@ -32,6 +32,7 @@ > import org.apache.fop.apps.FOUserAgent; > import org.apache.fop.apps.Fop; > import org.apache.fop.apps.FopFactory; >+import org.apache.fop.apps.FopFactoryConfigurator; > import org.apache.fop.fotreetest.ext.TestElementMapping; > import org.apache.fop.util.ConsoleEventListenerForTests; > >@@ -64,8 +65,13 @@ > SAXParser parser = spf.newSAXParser(); > XMLReader reader = parser.getXMLReader(); > >+ //Resetting values modified by processing instructions >+ fopFactory.setBreakIndentInheritanceOnReferenceAreaBoundary( >+ FopFactoryConfigurator.DEFAULT_BREAK_INDENT_INHERITANCE); >+ fopFactory.setSourceResolution(FopFactoryConfigurator.DEFAULT_SOURCE_RESOLUTION); >+ > FOUserAgent ua = fopFactory.newFOUserAgent(); >- ua.setBaseURL(testFile.getParentFile().toURL().toString()); >+ ua.setBaseURL(testFile.getParentFile().toURI().toURL().toString()); > ua.setFOEventHandlerOverride(new DummyFOEventHandler(ua)); > ua.getEventBroadcaster().addEventListener( > new ConsoleEventListenerForTests(testFile.getName())); >@@ -79,14 +85,19 @@ > reader.setDTDHandler(fop.getDefaultHandler()); > reader.setErrorHandler(fop.getDefaultHandler()); > reader.setEntityResolver(fop.getDefaultHandler()); >- reader.parse(testFile.toURL().toExternalForm()); >+ try { >+ reader.parse(testFile.toURI().toURL().toExternalForm()); >+ } catch (Exception e) { >+ collector.notifyError(e.getLocalizedMessage()); >+ throw e; >+ } > > List results = collector.getResults(); > if (results.size() > 0) { > for (int i = 0; i < results.size(); i++) { >- System.out.println(((Exception)results.get(i)).getMessage()); >+ System.out.println((String)results.get(i)); > } >- throw (Exception)results.get(0); >+ throw new IllegalStateException((String)results.get(0)); > } > } > >@@ -104,6 +115,8 @@ > if ("fop-useragent-break-indent-inheritance".equals(target)) { > userAgent.getFactory().setBreakIndentInheritanceOnReferenceAreaBoundary( > Boolean.valueOf(data).booleanValue()); >+ } else if ("fop-source-resolution".equals(target)) { >+ userAgent.getFactory().setSourceResolution(Float.parseFloat(data)); > } > super.processingInstruction(target, data); > } >Index: test/java/org/apache/fop/fotreetest/ResultCollector.java >=================================================================== >--- test/java/org/apache/fop/fotreetest/ResultCollector.java (revision 764988) >+++ test/java/org/apache/fop/fotreetest/ResultCollector.java (working copy) >@@ -23,7 +23,7 @@ > import java.util.List; > > /** >- * This class collects the results from assertions injected into the FO stream. >+ * This class collects failures for assertions injected into the FO stream. > */ > public class ResultCollector { > >@@ -31,7 +31,7 @@ > > private List results = new java.util.ArrayList(); > >- /** @return the ResultColletor singleton */ >+ /** @return the ResultCollector singleton */ > public static ResultCollector getInstance() { > if (instance == null) { > instance = new ResultCollector(); >@@ -45,14 +45,25 @@ > } > > /** >- * This notifies the ResultCollector about an Exception. >- * @param e the exception >+ * This notifies the ResultCollector about an assertion failure. >+ * >+ * @param message the message containing the details > */ >- public void notifyException(Exception e) { >- System.out.println(e.getMessage()); >- results.add(e); >+ public void notifyAssertionFailure(String message) { >+ System.out.println(message); >+ results.add(message); > } > >+ /** >+ * This notifies the ResultCollector about a testcase that ended >+ * with a fatal error >+ * >+ * @param message the message containing the details >+ */ >+ public void notifyError(String message) { >+ results.add(message); >+ } >+ > /** Resets the result list. */ > public void reset() { > results.clear();
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 47027
:
23489
|
23506
|
23507