diff options
author | Simon Pepping <spepping@apache.org> | 2011-01-21 11:36:16 +0000 |
---|---|---|
committer | Simon Pepping <spepping@apache.org> | 2011-01-21 11:36:16 +0000 |
commit | 626b241fd07c97cc5ea1731faebe682b706a7a33 (patch) | |
tree | 965a971b2e635d82cefc5ac877768c216ca35393 | |
parent | a50b48be71854349896e3c1ec8357d51554fe219 (diff) | |
parent | a712bc8cdc1bbbcc3e7ee1ac79c0e887b79e8b9d (diff) | |
download | xmlgraphics-fop-626b241fd07c97cc5ea1731faebe682b706a7a33.tar.gz xmlgraphics-fop-626b241fd07c97cc5ea1731faebe682b706a7a33.zip |
Merged /xmlgraphics/fop/trunk:r1053043-1061681
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_ComplexScripts@1061759 13f79535-47bb-0310-9956-ffa450edef68
74 files changed, 723 insertions, 722 deletions
@@ -85,11 +85,11 @@ list of possible build targets. </patternset> </fileset> <patternset id="dist.src.lib.tools"> - <include name="lib/build/asm*"/> - <include name="lib/build/backport-util-concurrent*"/> - <include name="lib/build/jaxen*"/> - <include name="lib/build/pmd*"/> - <include name="lib/build/qdox*"/> + <include name="lib/build/asm*"/> + <include name="lib/build/backport-util-concurrent*"/> + <include name="lib/build/jaxen*"/> + <include name="lib/build/pmd*"/> + <include name="lib/build/qdox*"/> <include name="lib/build/xmlunit*"/> </patternset> <fileset dir="${basedir}" id="dist.src"> @@ -98,7 +98,7 @@ list of possible build targets. <include name="hyph/hyphenation.dtd"/> <include name="hyph/readme"/> <patternset refid="dist.lib"/> - <patternset refid="dist.src.lib.tools"/> + <patternset refid="dist.src.lib.tools"/> <include name="lib/servlet*"/> <include name="test/**"/> <include name="examples/**"/> @@ -207,8 +207,24 @@ list of possible build targets. <property environment="env"/> <property name="forrest.home" value="${env.FORREST_HOME}"/> <import file="${env.FORREST_HOME}/main/forrest.build.xml" optional="true"/> - --> -<!-- =================================================================== --> +--> + + <presetdef name="javac"> + <javac fork="${javac.fork}" + debug="${javac.debug}" + deprecation="${javac.deprecation}" + optimize="${javac.optimize}" + source="${javac.source}" target="${javac.target}"/> + </presetdef> + + <presetdef name="junit"> + <junit haltonfailure="${junit.haltonfailure}" + fork="${junit.fork}" + printsummary="${junit.printsummary}" + maxmemory="256m"/> + </presetdef> + + <!-- =================================================================== --> <!-- Initialization target --> <!-- =================================================================== --> <target name="init" depends="init-avail"> @@ -334,7 +350,7 @@ list of possible build targets. <target name="compile-java" depends="init, codegen"> <!-- create directories --> <mkdir dir="${build.classes.dir}"/> - <javac destdir="${build.classes.dir}" fork="${javac.fork}" debug="${javac.debug}" deprecation="${javac.deprecation}" optimize="${javac.optimize}" source="${javac.source}" target="${javac.target}" includeAntRuntime="true"> + <javac destdir="${build.classes.dir}" includeAntRuntime="true"> <src path="${build.gensrc.dir}"/> <src path="${src.java.dir}"/> <patternset includes="**/*.java"/> @@ -343,7 +359,7 @@ list of possible build targets. <classpath refid="libs-build-classpath"/> </javac> <mkdir dir="${build.sandbox-classes.dir}"/> - <javac destdir="${build.sandbox-classes.dir}" fork="${javac.fork}" debug="${javac.debug}" deprecation="${javac.deprecation}" optimize="${javac.optimize}" source="${javac.source}" target="${javac.target}" includeAntRuntime="true"> + <javac destdir="${build.sandbox-classes.dir}" includeAntRuntime="true"> <src path="${src.sandbox.dir}"/> <patternset includes="**/*.java"/> <patternset refid="exclude-jai"/> @@ -355,7 +371,7 @@ list of possible build targets. </target> <target name="resourcegen" depends="compile-java"> <mkdir dir="${build.codegen-classes.dir}"/> - <javac destdir="${build.codegen-classes.dir}" fork="${javac.fork}" debug="${javac.debug}" deprecation="${javac.deprecation}" optimize="${javac.optimize}" source="${javac.source}" target="${javac.target}" includeAntRuntime="true"> + <javac destdir="${build.codegen-classes.dir}" includeAntRuntime="true"> <src path="${src.codegen.dir}/java"/> <patternset includes="**/*.java"/> <classpath> @@ -419,21 +435,21 @@ list of possible build targets. <!-- (src/java/org/apache/fop/hyphenation/classes.xml). --> <!-- =================================================================== --> <target name="codegen-hyphenation-classes"> - <javac destdir="${build.codegen-classes.dir}" fork="${javac.fork}" debug="${javac.debug}" deprecation="${javac.deprecation}" optimize="${javac.optimize}" source="${javac.source}" target="${javac.target}"> + <javac destdir="${build.codegen-classes.dir}"> <src path="${src.codegen.dir}/unicode/java"/> </javac> - <java classname="org.apache.fop.hyphenation.UnicodeClasses" resultproperty="classes.result" classpath="${build.codegen-classes.dir}"> + <java classname="org.apache.fop.hyphenation.UnicodeClasses" resultproperty="classes.result" classpath="${build.codegen-classes.dir}"> <arg value="${src.dir}/java/org/apache/fop/hyphenation/classes.xml"/> - </java> - <condition property="classes.result.message" value="Generation of classes successful"> - <not> - <isfailure code="${classes.result}"/> - </not> - </condition> - <condition property="classes.result.message" value="Generation of classes failed"> - <isfailure code="${classes.result}"/> - </condition> - <echo message="${classes.result.message}"/> + </java> + <condition property="classes.result.message" value="Generation of classes successful"> + <not> + <isfailure code="${classes.result}"/> + </not> + </condition> + <condition property="classes.result.message" value="Generation of classes failed"> + <isfailure code="${classes.result}"/> + </condition> + <echo message="${classes.result.message}"/> </target> <!-- =================================================================== --> <!-- compiles hyphenation patterns --> @@ -444,20 +460,20 @@ list of possible build targets. <pathelement location="${build.classes.dir}"/> </path> <mkdir dir="${build.classes.dir}/hyph"/> - <java classname="org.apache.fop.hyphenation.SerializeHyphPattern" fork="true" resultproperty="hyph.result" classpathref="hyph-classpath"> - <arg value="${user.hyph.dir}"/> - <arg value="${build.classes.dir}/hyph"/> - <jvmarg value="-Xss${hyph.stacksize}"/> - </java> - <condition property="hyph.result.message" value="Hyphenation successful"> - <not> - <isfailure code="${hyph.result}"/> - </not> - </condition> - <condition property="hyph.result.message" value="Hyphenation failed"> - <isfailure code="${hyph.result}"/> - </condition> - <echo message="${hyph.result.message}"/> + <java classname="org.apache.fop.hyphenation.SerializeHyphPattern" fork="true" resultproperty="hyph.result" classpathref="hyph-classpath"> + <arg value="${user.hyph.dir}"/> + <arg value="${build.classes.dir}/hyph"/> + <jvmarg value="-Xss${hyph.stacksize}"/> + </java> + <condition property="hyph.result.message" value="Hyphenation successful"> + <not> + <isfailure code="${hyph.result}"/> + </not> + </condition> + <condition property="hyph.result.message" value="Hyphenation failed"> + <isfailure code="${hyph.result}"/> + </condition> + <echo message="${hyph.result.message}"/> </target> <target name="uptodate-jar-hyphenation" depends="compile-hyphenation"> <uptodate property="jar.hyphenation.uptodate" targetfile="${build.dir}/fop-hyph.jar"> @@ -704,7 +720,7 @@ list of possible build targets. <mkdir dir="${build.dir}/test-classes"/> <mkdir dir="${build.dir}/test-gensrc"/> <mkdir dir="${junit.reports.dir}"/> - <javac destdir="${build.dir}/test-classes" fork="${javac.fork}" debug="${javac.debug}" deprecation="${javac.deprecation}" optimize="${javac.optimize}" source="${javac.source}" target="${javac.target}" includeAntRuntime="true"> + <javac destdir="${build.dir}/test-classes" includeAntRuntime="true"> <src path="${test.dir}/java"/> <patternset refid="test-sources"/> <classpath> @@ -740,8 +756,7 @@ list of possible build targets. <target name="junit-compile" depends="junit-compile-java, junit-compile-copy-resources" description="Compiles FOP's JUnit tests" if="junit.present"/> <target name="junit-transcoder" depends="junit-compile" description="Runs FOP's JUnit transcoder tests" if="junit.present"> <echo message="Running basic functionality tests for fop-transcoder.jar"/> - <junit dir="${basedir}" haltonfailure="${junit.haltonfailure}" fork="${junit.fork}" printsummary="${junit.printsummary}"> - <jvmarg value="-Xmx1024m"/> + <junit dir="${basedir}"> <sysproperty key="basedir" value="${basedir}"/> <sysproperty key="jawa.awt.headless" value="true"/> <formatter type="brief" usefile="false" if="junit.formatter.brief.use"/> @@ -763,7 +778,7 @@ list of possible build targets. previous test block succeeded it indicates that the packaging of the allinone JAR needs to be updated. --> - <junit dir="${basedir}" haltonfailure="${junit.haltonfailure}" fork="${junit.fork}" errorproperty="fop.junit.error" failureproperty="fop.junit.failure" printsummary="${junit.printsummary}"> + <junit dir="${basedir}" errorproperty="fop.junit.error" failureproperty="fop.junit.failure"> <sysproperty key="basedir" value="${basedir}"/> <sysproperty key="jawa.awt.headless" value="true"/> <formatter type="brief" usefile="false" if="junit.formatter.brief.use"/> @@ -786,8 +801,7 @@ list of possible build targets. </target> <target name="junit-userconfig" depends="junit-compile" if="junit.present" description="Runs FOP's user config JUnit tests"> <echo message="Running user config tests"/> - <junit dir="${basedir}" haltonfailure="${junit.haltonfailure}" fork="${junit.fork}" errorproperty="fop.junit.error" failureproperty="fop.junit.failure" printsummary="${junit.printsummary}"> - <jvmarg value="-Xmx1024m"/> + <junit dir="${basedir}" errorproperty="fop.junit.error" failureproperty="fop.junit.failure"> <sysproperty key="basedir" value="${basedir}"/> <sysproperty key="jawa.awt.headless" value="true"/> <sysproperty key="fop.layoutengine.disabled" value="${layoutengine.disabled}"/> @@ -804,7 +818,7 @@ list of possible build targets. </target> <target name="junit-basic" depends="junit-compile" description="Runs FOP's JUnit basic tests" if="junit.present"> <echo message="Running basic functionality tests for fop.jar"/> - <junit dir="${basedir}" haltonfailure="${junit.haltonfailure}" fork="${junit.fork}" errorproperty="fop.junit.error" failureproperty="fop.junit.failure" printsummary="${junit.printsummary}"> + <junit dir="${basedir}" errorproperty="fop.junit.error" failureproperty="fop.junit.failure"> <sysproperty key="basedir" value="${basedir}"/> <sysproperty key="jawa.awt.headless" value="true"/> <formatter type="brief" usefile="false" if="junit.formatter.brief.use"/> @@ -840,7 +854,7 @@ list of possible build targets. </target> <target name="junit-layout-standard" depends="junit-compile, junit-fotree" if="junit.present" description="Runs FOP's standard JUnit layout tests"> <echo message="Running standard layout engine tests"/> - <junit dir="${basedir}" haltonfailure="${junit.haltonfailure}" fork="${junit.fork}" errorproperty="fop.junit.error" failureproperty="fop.junit.failure" printsummary="${junit.printsummary}"> + <junit dir="${basedir}" errorproperty="fop.junit.error" failureproperty="fop.junit.failure"> <sysproperty key="basedir" value="${basedir}"/> <sysproperty key="jawa.awt.headless" value="true"/> <sysproperty key="fop.layoutengine.disabled" value="${layoutengine.disabled}"/> @@ -857,7 +871,7 @@ list of possible build targets. </target> <target name="junit-layout-hyphenation" depends="hyphenation-present, junit-compile" if="hyphenation.present" description="Runs FOP's JUnit hyphenation layout tests"> <echo message="Running hyphenation layout engine tests"/> - <junit dir="${basedir}" haltonfailure="${junit.haltonfailure}" fork="${junit.fork}" errorproperty="fop.junit.error" failureproperty="fop.junit.failure" printsummary="${junit.printsummary}"> + <junit dir="${basedir}" errorproperty="fop.junit.error" failureproperty="fop.junit.failure"> <sysproperty key="basedir" value="${basedir}"/> <sysproperty key="jawa.awt.headless" value="true"/> <sysproperty key="fop.layoutengine.disabled" value="${layoutengine.disabled}"/> @@ -875,7 +889,7 @@ list of possible build targets. <target name="junit-layout" depends="junit-layout-standard, junit-layout-hyphenation" description="Runs all FOP's JUnit layout tests"/> <target name="junit-fotree" depends="junit-compile" description="Runs FOP's FO tree JUnit tests" if="junit.present"> <echo message="Running fo tree tests"/> - <junit dir="${basedir}" haltonfailure="${junit.haltonfailure}" fork="${junit.fork}" errorproperty="fop.junit.error" failureproperty="fop.junit.failure" printsummary="${junit.printsummary}"> + <junit dir="${basedir}" errorproperty="fop.junit.error" failureproperty="fop.junit.failure"> <sysproperty key="basedir" value="${basedir}"/> <sysproperty key="jawa.awt.headless" value="true"/> <sysproperty key="fop.layoutengine.disabled" value="${fotree.disabled}"/> @@ -899,7 +913,7 @@ list of possible build targets. <attribute name="outfile"/> <sequential> <echo message="Running @{title} tests..."/> - <junit dir="${basedir}" haltonfailure="${junit.haltonfailure}" fork="${junit.fork}" errorproperty="fop.junit.error" failureproperty="fop.junit.failure" printsummary="${junit.printsummary}"> + <junit dir="${basedir}" errorproperty="fop.junit.error" failureproperty="fop.junit.failure"> <sysproperty key="basedir" value="${basedir}/@{basedir}"/> <sysproperty key="jawa.awt.headless" value="true"/> <sysproperty key="fop.layoutengine.disabled" value="${layoutengine.disabled}"/> @@ -936,7 +950,7 @@ list of possible build targets. </target> <target name="junit-text-linebreak" depends="junit-compile" description="Runs FOP's JUnit unicode linebreak tests" if="junit.present"> <echo message="Running tests for Unicode UAX#14 support"/> - <junit dir="${basedir}" haltonfailure="${junit.haltonfailure}" fork="${junit.fork}" errorproperty="fop.junit.error" failureproperty="fop.junit.failure" printsummary="${junit.printsummary}"> + <junit dir="${basedir}" errorproperty="fop.junit.error" failureproperty="fop.junit.failure"> <sysproperty key="basedir" value="${basedir}"/> <sysproperty key="jawa.awt.headless" value="true"/> <formatter type="brief" usefile="false" if="junit.formatter.brief.use"/> @@ -1104,7 +1118,7 @@ NOTE: <!-- =================================================================== --> <property name="checkstyle.noframes.xslt" value="${basedir}/checkstyle-noframes.xsl" /> <condition property="checkstyle.avail"> - <and> + <and> <available classname="com.puppycrawl.tools.checkstyle.CheckStyleTask"> <classpath> <path refid="libs-tools-build-classpath"/> @@ -1339,11 +1353,11 @@ NOTE: <!-- Nightly builds --> <!-- =================================================================== --> <target name="junit-nightly-build" depends="junit-userconfig,junit-text-linebreak,junit-fotree"> - <fail> - <condition> - <or> - <isset property="fop.junit.error"/> - <isset property="fop.junit.failure"/> + <fail> + <condition> + <or> + <isset property="fop.junit.error"/> + <isset property="fop.junit.failure"/> </or> </condition> NOTE: @@ -1425,7 +1439,7 @@ NOTE: <!-- =================================================================== --> <target name="codegen-unicode" depends="compile-java"> <mkdir dir="${build.codegen-classes.dir}"/> - <javac destdir="${build.codegen-classes.dir}" fork="${javac.fork}" debug="${javac.debug}" deprecation="${javac.deprecation}" optimize="${javac.optimize}" source="${javac.source}" target="${javac.target}"> + <javac destdir="${build.codegen-classes.dir}"> <src path="${src.codegen.dir}/unicode/java"/> <classpath> <path refid="libs-build-classpath"/> @@ -1456,7 +1470,7 @@ NOTE: <delete> <fileset dir="${basedir}" includes="${name}-*.tar.gz"/> <fileset dir="${basedir}" includes="${name}-*.zip"/> - <fileset dir="${basedir}" includes="${name}-bundle.jar"/> + <fileset dir="${basedir}" includes="${name}-bundle.jar"/> </delete> </target> <target name="validate-xdocs" description="Validate the xdocs. Point schemas.dir to Forrest's 'schemas' directory."> diff --git a/examples/plan/src/org/apache/fop/plan/PlanElementMapping.java b/examples/plan/src/org/apache/fop/plan/PlanElementMapping.java index 781fd8371..5b8a0b5bb 100644 --- a/examples/plan/src/org/apache/fop/plan/PlanElementMapping.java +++ b/examples/plan/src/org/apache/fop/plan/PlanElementMapping.java @@ -45,7 +45,7 @@ public class PlanElementMapping extends ElementMapping { /** {@inheritDoc} */ protected void initialize() { if (foObjs == null) { - foObjs = new java.util.HashMap(); + foObjs = new java.util.HashMap<String, Maker>(); foObjs.put("plan", new PE()); foObjs.put(DEFAULT, new PlanMaker()); } @@ -19,7 +19,7 @@ SETLOCAL ENABLEDELAYEDEXPANSION rem %~dp0 is the expanded pathname of the current script under NT
set LOCAL_FOP_HOME=
-if "%OS%"=="Windows_NT" set LOCAL_FOP_HOME=%~dp0
+if "%OS%"=="Windows_NT" set LOCAL_FOP_HOME="%~dp0"
rem Code from Apache Ant project
rem Slurp the command line arguments. This loop allows for an unlimited number
@@ -223,7 +223,7 @@ function fop_exec() { + (config.Exists("JAVA_OPTS")?config.Item("JAVA_OPTS") + " ":"")
+ (config.Exists("LOGCHOICE")?config.Item("LOGCHOICE") + " ":"")
+ (config.Exists("LOGLEVEL")?config.Item("LOGLEVEL") + " ":"")
- "-classpath \"" + local_classpath + "\" "
+ + "-classpath \"" + local_classpath + "\" "
+ (config.Exists("FOP_OPTS")?config.Item("FOP_OPTS"):"")
+ "org.apache.fop.cli.Main " + fop_exec_args;
if (debug || fop_exec_debug) {
diff --git a/lib/xmlgraphics-commons-1.5svn.jar b/lib/xmlgraphics-commons-1.5svn.jar Binary files differindex c152d2d5b..b11bfd2d2 100644 --- a/lib/xmlgraphics-commons-1.5svn.jar +++ b/lib/xmlgraphics-commons-1.5svn.jar diff --git a/src/documentation/content/xdocs/trunk/configuration.xml b/src/documentation/content/xdocs/trunk/configuration.xml index 3ef8795b7..26707edbf 100644 --- a/src/documentation/content/xdocs/trunk/configuration.xml +++ b/src/documentation/content/xdocs/trunk/configuration.xml @@ -90,6 +90,9 @@ <td>disabled</td> </tr> <tr> + <td colspan="4">Relative URIs for the above three properties are evaluated relative to the base URI of the configuration file. If the configuration is provided programmatically, the base URI can be set with <code>FopFactory.setUserConfigBaseURI</code>; default is the current working directory.</td> + </tr> + <tr> <td>hyphenation-pattern</td> <td>String, attribute lang, attribute country (optional)</td> <td>Register a file name for the hyphenation pattern for the mentioned language and country. Language ll and country CC must both consist of two letters.</td> diff --git a/src/java/org/apache/fop/apps/FopFactory.java b/src/java/org/apache/fop/apps/FopFactory.java index b86c52cf6..181bc85da 100644 --- a/src/java/org/apache/fop/apps/FopFactory.java +++ b/src/java/org/apache/fop/apps/FopFactory.java @@ -24,6 +24,7 @@ import java.io.File; import java.io.IOException; import java.io.OutputStream; import java.net.MalformedURLException; +import java.net.URI; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -701,6 +702,15 @@ public class FopFactory implements ImageContext { } /** + * Set the base URI for the user configuration + * Useful for programmatic configurations + * @param baseURI the base URI + */ + public void setUserConfigBaseURI(URI baseURI) { + config.setBaseURI(baseURI); + } + + /** * Get the user configuration. * @return the user configuration */ diff --git a/src/java/org/apache/fop/apps/FopFactoryConfigurator.java b/src/java/org/apache/fop/apps/FopFactoryConfigurator.java index 161bd4a8f..9097f23e3 100644 --- a/src/java/org/apache/fop/apps/FopFactoryConfigurator.java +++ b/src/java/org/apache/fop/apps/FopFactoryConfigurator.java @@ -22,6 +22,8 @@ package org.apache.fop.apps; import java.io.File; import java.io.IOException; import java.net.MalformedURLException; +import java.net.URI; +import java.net.URISyntaxException; import java.util.HashMap; import java.util.Map; @@ -78,6 +80,9 @@ public class FopFactoryConfigurator { /** Fop factory configuration */ private Configuration cfg = null; + /** The base URI of the configuration file **/ + private URI baseURI = null; + /** * Default constructor * @param factory fop factory @@ -130,17 +135,23 @@ public class FopFactoryConfigurator { // base definitions for relative path resolution if (cfg.getChild("base", false) != null) { + String path = cfg.getChild("base").getValue(null); + if (baseURI != null) { + path = baseURI.resolve(path).normalize().toString(); + } try { - factory.setBaseURL( - cfg.getChild("base").getValue(null)); + factory.setBaseURL(path); } catch (MalformedURLException mfue) { LogUtil.handleException(log, mfue, strict); } } if (cfg.getChild("hyphenation-base", false) != null) { + String path = cfg.getChild("hyphenation-base").getValue(null); + if (baseURI != null) { + path = baseURI.resolve(path).normalize().toString(); + } try { - factory.setHyphenBaseURL( - cfg.getChild("hyphenation-base").getValue(null)); + factory.setHyphenBaseURL(path); } catch (MalformedURLException mfue) { LogUtil.handleException(log, mfue, strict); } @@ -259,7 +270,7 @@ public class FopFactoryConfigurator { } // configure font manager - new FontManagerConfigurator(cfg).configure(factory.getFontManager(), strict); + new FontManagerConfigurator(cfg, baseURI).configure(factory.getFontManager(), strict); // configure image loader framework configureImageLoading(cfg.getChild("image-loading", false), strict); @@ -339,6 +350,7 @@ public class FopFactoryConfigurator { */ public void setUserConfig(Configuration cfg) throws FOPException { this.cfg = cfg; + setBaseURI(); configure(this.factory); } @@ -349,4 +361,34 @@ public class FopFactoryConfigurator { public Configuration getUserConfig() { return this.cfg; } + + /** + * @return the baseURI + */ + public URI getBaseURI() { + return baseURI; + } + + /** + * @param baseURI the baseURI to set + */ + public void setBaseURI(URI baseURI) { + this.baseURI = baseURI; + } + + private void setBaseURI() throws FOPException { + String loc = cfg.getLocation(); + try { + if (loc != null && loc.startsWith("file:")) { + baseURI = new URI(loc); + baseURI = baseURI.resolve(".").normalize(); + } + if (baseURI == null) { + baseURI = new File(System.getProperty("user.dir")).toURI(); + } + } catch (URISyntaxException e) { + throw new FOPException(e); + } + } + } diff --git a/src/java/org/apache/fop/area/AreaTreeHandler.java b/src/java/org/apache/fop/area/AreaTreeHandler.java index 298cf263b..87c681ed6 100644 --- a/src/java/org/apache/fop/area/AreaTreeHandler.java +++ b/src/java/org/apache/fop/area/AreaTreeHandler.java @@ -305,6 +305,7 @@ public class AreaTreeHandler extends FOEventHandler { model.handleOffDocumentItem(data); } } + idTracker.signalIDProcessed(rootFObj.getId()); } model.endDocument(); diff --git a/src/java/org/apache/fop/area/Block.java b/src/java/org/apache/fop/area/Block.java index 60977f91d..7e5520ae3 100644 --- a/src/java/org/apache/fop/area/Block.java +++ b/src/java/org/apache/fop/area/Block.java @@ -129,7 +129,7 @@ public class Block extends BlockParent { */ public int getStartIndent() { Integer startIndent = (Integer)getTrait(Trait.START_INDENT); - return (startIndent != null ? startIndent.intValue() : 0); + return (startIndent != null ? startIndent : 0); } } diff --git a/src/java/org/apache/fop/area/Page.java b/src/java/org/apache/fop/area/Page.java index 242123baa..715bcfe85 100644 --- a/src/java/org/apache/fop/area/Page.java +++ b/src/java/org/apache/fop/area/Page.java @@ -123,7 +123,7 @@ public class Page extends AreaTreeObject implements Serializable, Cloneable { for (Iterator regenum = spm.getRegions().values().iterator(); regenum.hasNext();) { Region r = (Region)regenum.next(); - RegionViewport rvp = makeRegionViewport(r, reldims, pageCTM, spm); + RegionViewport rvp = makeRegionViewport(r, reldims, pageCTM); if (r.getNameId() == Constants.FO_REGION_BODY) { rr = new BodyRegion((RegionBody) r, rvp); } else { @@ -138,7 +138,7 @@ public class Page extends AreaTreeObject implements Serializable, Cloneable { setRegionReferencePosition(rr, r, rvp.getViewArea()); rvp.setRegionReference(rr); setRegionViewport(r.getNameId(), rvp); - } + } } /** @@ -153,12 +153,10 @@ public class Page extends AreaTreeObject implements Serializable, Cloneable { * @param r the region the viewport is to be created for * @param reldims relative dimensions * @param pageCTM page coordinate transformation matrix - * @param spm the simple-page-master for this page * @return the new region viewport */ - private RegionViewport makeRegionViewport(Region r, FODimension reldims, CTM pageCTM, - SimplePageMaster spm) { - Rectangle2D relRegionRect = r.getViewportRectangle(reldims, spm); + private RegionViewport makeRegionViewport(Region r, FODimension reldims, CTM pageCTM) { + Rectangle2D relRegionRect = r.getViewportRectangle(reldims); Rectangle2D absRegionRect = pageCTM.transform(relRegionRect); // Get the region viewport rectangle in absolute coords by // transforming it using the page CTM diff --git a/src/java/org/apache/fop/area/RegionReference.java b/src/java/org/apache/fop/area/RegionReference.java index 0aec7a395..a727f9029 100644 --- a/src/java/org/apache/fop/area/RegionReference.java +++ b/src/java/org/apache/fop/area/RegionReference.java @@ -33,8 +33,6 @@ public class RegionReference extends Area implements Cloneable { private static final long serialVersionUID = -298980963268244238L; - /** Reference to the region FO. */ - //protected Region regionFO; private int regionClass; private String regionName; private CTM ctm; @@ -42,7 +40,7 @@ public class RegionReference extends Area implements Cloneable { // the list of block areas from the static flow private ArrayList blocks = new ArrayList(); - /** the parent RegionViewport for this object */ + /** the parent {@link RegionViewport} for this object */ protected RegionViewport regionViewport; /** diff --git a/src/java/org/apache/fop/area/Trait.java b/src/java/org/apache/fop/area/Trait.java index 0adc23cf3..70827760a 100644 --- a/src/java/org/apache/fop/area/Trait.java +++ b/src/java/org/apache/fop/area/Trait.java @@ -43,167 +43,114 @@ public final class Trait implements Serializable { private Trait() { } - /** - * Id reference line, not resolved. - * not sure if this is needed. - */ + /** Id reference line, not resolved. (not sure if this is needed.) */ //public static final Integer ID_LINK = new Integer(0); /** * Internal link trait. * Contains the PageViewport key and the PROD_ID of the target area */ - public static final Integer INTERNAL_LINK = new Integer(1); + public static final Integer INTERNAL_LINK = 1; - /** - * External link. A URL link to an external resource. - */ - public static final Integer EXTERNAL_LINK = new Integer(2); + /** * External link. A URL link to an external resource. */ + public static final Integer EXTERNAL_LINK = 2; - /** - * The font triplet for the current font. - */ - public static final Integer FONT = new Integer(3); + /** The font triplet for the current font. */ + public static final Integer FONT = 3; - /** - * Font size for the current font. - */ - public static final Integer FONT_SIZE = new Integer(4); + /** Font size for the current font. */ + public static final Integer FONT_SIZE = 4; - /** - * The current color. - */ - public static final Integer COLOR = new Integer(7); + /** The current color. */ + public static final Integer COLOR = 7; - /** - * The ID of the FO that produced an area. - */ - public static final Integer PROD_ID = new Integer(8); + /** The ID of the FO that produced an area. */ + public static final Integer PROD_ID = 8; - /** - * Background trait for an area. - */ - public static final Integer BACKGROUND = new Integer(9); + /** Background trait for an area. */ + public static final Integer BACKGROUND = 9; - /** - * Underline trait used when rendering inline parent. - */ - public static final Integer UNDERLINE = new Integer(10); + /** Underline trait used when rendering inline parent. */ + public static final Integer UNDERLINE = 10; - /** - * Overline trait used when rendering inline parent. - */ - public static final Integer OVERLINE = new Integer(11); + /** Overline trait used when rendering inline parent. */ + public static final Integer OVERLINE = 11; - /** - * Linethrough trait used when rendering inline parent. - */ - public static final Integer LINETHROUGH = new Integer(12); + /** Linethrough trait used when rendering inline parent. */ + public static final Integer LINETHROUGH = 12; - /** - * Shadow offset. - */ + /** Shadow offset. */ //public static final Integer OFFSET = new Integer(13); - /** - * The shadow for text. - */ + /** The shadow for text. */ //public static final Integer SHADOW = new Integer(14); - /** - * The border start. - */ - public static final Integer BORDER_START = new Integer(15); + /** The border start. */ + public static final Integer BORDER_START = 15; - /** - * The border end. - */ - public static final Integer BORDER_END = new Integer(16); + /** The border end. */ + public static final Integer BORDER_END = 16; - /** - * The border before. - */ - public static final Integer BORDER_BEFORE = new Integer(17); + /** The border before. */ + public static final Integer BORDER_BEFORE = 17; - /** - * The border after. - */ - public static final Integer BORDER_AFTER = new Integer(18); + /** The border after. */ + public static final Integer BORDER_AFTER = 18; - /** - * The padding start. - */ - public static final Integer PADDING_START = new Integer(19); + /** The padding start. */ + public static final Integer PADDING_START = 19; - /** - * The padding end. - */ - public static final Integer PADDING_END = new Integer(20); + /** The padding end. */ + public static final Integer PADDING_END = 20; - /** - * The padding before. - */ - public static final Integer PADDING_BEFORE = new Integer(21); + /** The padding before. */ + public static final Integer PADDING_BEFORE = 21; - /** - * The padding after. - */ - public static final Integer PADDING_AFTER = new Integer(22); + /** The padding after. */ + public static final Integer PADDING_AFTER = 22; - /** - * The space start. - */ - public static final Integer SPACE_START = new Integer(23); + /** The space start. */ + public static final Integer SPACE_START = 23; - /** - * The space end. - */ - public static final Integer SPACE_END = new Integer(24); + /** The space end. */ + public static final Integer SPACE_END = 24; - /** - * break before - */ + /** break before */ //public static final Integer BREAK_BEFORE = new Integer(25); - /** - * break after - */ + /** break after */ //public static final Integer BREAK_AFTER = new Integer(26); - /** - * The start-indent trait. - */ - public static final Integer START_INDENT = new Integer(27); + /** The start-indent trait. */ + public static final Integer START_INDENT = 27; - /** - * The end-indent trait. - */ - public static final Integer END_INDENT = new Integer(28); + /** The end-indent trait. */ + public static final Integer END_INDENT = 28; /** The space-before trait. */ - public static final Integer SPACE_BEFORE = new Integer(29); + public static final Integer SPACE_BEFORE = 29; /** The space-after trait. */ - public static final Integer SPACE_AFTER = new Integer(30); + public static final Integer SPACE_AFTER = 30; /** The is-reference-area trait. */ - public static final Integer IS_REFERENCE_AREA = new Integer(31); + public static final Integer IS_REFERENCE_AREA = 31; /** The is-viewport-area trait. */ - public static final Integer IS_VIEWPORT_AREA = new Integer(32); + public static final Integer IS_VIEWPORT_AREA = 32; /** Blinking trait used when rendering inline parent. */ - public static final Integer BLINK = new Integer(33); + public static final Integer BLINK = 33; /** Trait for color of underline decorations when rendering inline parent. */ - public static final Integer UNDERLINE_COLOR = new Integer(34); + public static final Integer UNDERLINE_COLOR = 34; /** Trait for color of overline decorations when rendering inline parent. */ - public static final Integer OVERLINE_COLOR = new Integer(35); + public static final Integer OVERLINE_COLOR = 35; /** Trait for color of linethrough decorations when rendering inline parent. */ - public static final Integer LINETHROUGH_COLOR = new Integer(36); + public static final Integer LINETHROUGH_COLOR = 36; /** The ptr trait. Used for accessibility */ - public static final Integer PTR = new Integer(37); + public static final Integer PTR = 37; /** writing mode trait */ public static final Integer WRITING_MODE = new Integer(38); @@ -238,65 +185,47 @@ public final class Trait implements Serializable { } private static void put(Integer key, TraitInfo info) { - TRAIT_INFO[key.intValue()] = info; + TRAIT_INFO[key] = info; } static { // Create a hashmap mapping trait code to name for external representation //put(ID_LINK, new TraitInfo("id-link", String.class)); - put(PTR, new TraitInfo("ptr", String.class)); - put(INTERNAL_LINK, new TraitInfo("internal-link", InternalLink.class)); - put(EXTERNAL_LINK, new TraitInfo("external-link", ExternalLink.class)); - put(FONT, new TraitInfo("font", FontTriplet.class)); - put(FONT_SIZE, new TraitInfo("font-size", Integer.class)); - put(COLOR, new TraitInfo("color", Color.class)); - put(PROD_ID, new TraitInfo("prod-id", String.class)); - put(BACKGROUND, new TraitInfo("background", Background.class)); - put(UNDERLINE, new TraitInfo("underline-score", Boolean.class)); + put(PTR, new TraitInfo("ptr", String.class)); + put(INTERNAL_LINK, new TraitInfo("internal-link", InternalLink.class)); + put(EXTERNAL_LINK, new TraitInfo("external-link", ExternalLink.class)); + put(FONT, new TraitInfo("font", FontTriplet.class)); + put(FONT_SIZE, new TraitInfo("font-size", Integer.class)); + put(COLOR, new TraitInfo("color", Color.class)); + put(PROD_ID, new TraitInfo("prod-id", String.class)); + put(BACKGROUND, new TraitInfo("background", Background.class)); + put(UNDERLINE, new TraitInfo("underline-score", Boolean.class)); put(UNDERLINE_COLOR, new TraitInfo("underline-score-color", Color.class)); - put(OVERLINE, new TraitInfo("overline-score", Boolean.class)); + put(OVERLINE, new TraitInfo("overline-score", Boolean.class)); put(OVERLINE_COLOR, new TraitInfo("overline-score-color", Color.class)); - put(LINETHROUGH, new TraitInfo("through-score", Boolean.class)); + put(LINETHROUGH, new TraitInfo("through-score", Boolean.class)); put(LINETHROUGH_COLOR, new TraitInfo("through-score-color", Color.class)); - put(BLINK, new TraitInfo("blink", Boolean.class)); - //put(OFFSET, new TraitInfo("offset", Integer.class)); - //put(SHADOW, new TraitInfo("shadow", Integer.class)); - put(BORDER_START, - new TraitInfo("border-start", BorderProps.class)); - put(BORDER_END, - new TraitInfo("border-end", BorderProps.class)); - put(BORDER_BEFORE, - new TraitInfo("border-before", BorderProps.class)); - put(BORDER_AFTER, - new TraitInfo("border-after", BorderProps.class)); - put(PADDING_START, - new TraitInfo("padding-start", Integer.class)); - put(PADDING_END, - new TraitInfo("padding-end", Integer.class)); - put(PADDING_BEFORE, - new TraitInfo("padding-before", Integer.class)); - put(PADDING_AFTER, - new TraitInfo("padding-after", Integer.class)); - put(SPACE_START, - new TraitInfo("space-start", Integer.class)); - put(SPACE_END, - new TraitInfo("space-end", Integer.class)); - //put(BREAK_BEFORE, - // new TraitInfo("break-before", Integer.class)); - //put(BREAK_AFTER, - // new TraitInfo("break-after", Integer.class)); - put(START_INDENT, - new TraitInfo("start-indent", Integer.class)); - put(END_INDENT, - new TraitInfo("end-indent", Integer.class)); - put(SPACE_BEFORE, - new TraitInfo("space-before", Integer.class)); - put(SPACE_AFTER, - new TraitInfo("space-after", Integer.class)); - put(IS_REFERENCE_AREA, - new TraitInfo("is-reference-area", Boolean.class)); - put(IS_VIEWPORT_AREA, - new TraitInfo("is-viewport-area", Boolean.class)); + put(BLINK, new TraitInfo("blink", Boolean.class)); + //put(OFFSET, new TraitInfo("offset", Integer.class)); + //put(SHADOW, new TraitInfo("shadow", Integer.class)); + put(BORDER_START, new TraitInfo("border-start", BorderProps.class)); + put(BORDER_END, new TraitInfo("border-end", BorderProps.class)); + put(BORDER_BEFORE, new TraitInfo("border-before", BorderProps.class)); + put(BORDER_AFTER, new TraitInfo("border-after", BorderProps.class)); + put(PADDING_START, new TraitInfo("padding-start", Integer.class)); + put(PADDING_END, new TraitInfo("padding-end", Integer.class)); + put(PADDING_BEFORE, new TraitInfo("padding-before", Integer.class)); + put(PADDING_AFTER, new TraitInfo("padding-after", Integer.class)); + put(SPACE_START, new TraitInfo("space-start", Integer.class)); + put(SPACE_END, new TraitInfo("space-end", Integer.class)); + //put(BREAK_BEFORE, new TraitInfo("break-before", Integer.class)); + //put(BREAK_AFTER, new TraitInfo("break-after", Integer.class)); + put(START_INDENT, new TraitInfo("start-indent", Integer.class)); + put(END_INDENT, new TraitInfo("end-indent", Integer.class)); + put(SPACE_BEFORE, new TraitInfo("space-before", Integer.class)); + put(SPACE_AFTER, new TraitInfo("space-after", Integer.class)); + put(IS_REFERENCE_AREA, new TraitInfo("is-reference-area", Boolean.class)); + put(IS_VIEWPORT_AREA, new TraitInfo("is-viewport-area", Boolean.class)); put(WRITING_MODE, new TraitInfo("writing-mode", WritingMode.class)); put(INLINE_PROGRESSION_DIRECTION, @@ -315,7 +244,7 @@ public final class Trait implements Serializable { * @return the trait name */ public static String getTraitName(Object traitCode) { - return TRAIT_INFO[((Integer)traitCode).intValue()].getName(); + return TRAIT_INFO[(Integer)traitCode].getName(); } /** @@ -325,7 +254,7 @@ public final class Trait implements Serializable { * @return the class type for the trait */ public static Class getTraitClass(Object traitCode) { - return TRAIT_INFO[((Integer)traitCode).intValue()].getClazz(); + return TRAIT_INFO[(Integer)traitCode].getClazz(); } /** @@ -501,7 +430,7 @@ public final class Trait implements Serializable { if (v.startsWith("dest=")) { dest = v.substring(5); } else if (v.startsWith("newWindow=")) { - newWindow = Boolean.valueOf(v.substring(10)).booleanValue(); + newWindow = Boolean.valueOf(v.substring(10)); } else { throw new IllegalArgumentException( "Malformed trait value for Trait.ExternalLink: " + traitValue); diff --git a/src/java/org/apache/fop/area/inline/InlineParent.java b/src/java/org/apache/fop/area/inline/InlineParent.java index 9e69e00a7..f2d218dae 100644 --- a/src/java/org/apache/fop/area/inline/InlineParent.java +++ b/src/java/org/apache/fop/area/inline/InlineParent.java @@ -87,18 +87,18 @@ public class InlineParent extends InlineArea { @Override public boolean applyVariationFactor(double variationFactor, int lineStretch, int lineShrink) { - boolean bUnresolvedAreasPresent = false; + boolean hasUnresolvedAreas = false; int cumulativeIPD = 0; // recursively apply variation factor to descendant areas for (int i = 0, len = inlines.size(); i < len; i++) { InlineArea inline = inlines.get(i); - bUnresolvedAreasPresent |= inline.applyVariationFactor( + hasUnresolvedAreas |= inline.applyVariationFactor( variationFactor, lineStretch, lineShrink); cumulativeIPD += inline.getIPD(); //Update this area's IPD based on changes to children } setIPD(cumulativeIPD); - return bUnresolvedAreasPresent; + return hasUnresolvedAreas; } /** diff --git a/src/java/org/apache/fop/area/inline/SpaceArea.java b/src/java/org/apache/fop/area/inline/SpaceArea.java index 6b0ba96ce..d62455b86 100644 --- a/src/java/org/apache/fop/area/inline/SpaceArea.java +++ b/src/java/org/apache/fop/area/inline/SpaceArea.java @@ -29,7 +29,7 @@ public class SpaceArea extends InlineArea { /** * The space for this space area */ - protected String space; + protected char space; /** * Is this space adjustable? @@ -45,7 +45,7 @@ public class SpaceArea extends InlineArea { */ public SpaceArea(int blockProgressionOffset, int bidiLevel, char space, boolean adjustable) { super ( blockProgressionOffset, bidiLevel ); - this.space = new String ( new char[] {space} ); + this.space = space; this.isAdjustable = adjustable; } @@ -53,7 +53,7 @@ public class SpaceArea extends InlineArea { * @return Returns the space. */ public String getSpace() { - return space; + return String.valueOf(space); } /** @return true if the space is adjustable (WRT word-space processing) */ diff --git a/src/java/org/apache/fop/events/Event.java b/src/java/org/apache/fop/events/Event.java index c48530c1c..ffec9473e 100644 --- a/src/java/org/apache/fop/events/Event.java +++ b/src/java/org/apache/fop/events/Event.java @@ -38,7 +38,7 @@ public class Event extends EventObject { private String eventKey; private EventSeverity severity; - private Map params; + private Map<String, Object> params; /** * Creates a new Event. @@ -47,7 +47,8 @@ public class Event extends EventObject { * @param severity the severity level * @param params the event parameters (a map of name/value pairs) */ - public Event(Object source, String eventID, EventSeverity severity, Map params) { + public Event(Object source, String eventID, EventSeverity severity, Map<String, Object> params) + { super(source); int pos = eventID.lastIndexOf('.'); if (pos < 0 || pos == eventID.length() - 1) { @@ -122,7 +123,7 @@ public class Event extends EventObject { * Returns an unmodifiable {@link java.util.Map} with all event parameters. * @return the parameter map */ - public Map getParams() { + public Map<String, Object> getParams() { return Collections.unmodifiableMap(this.params); } @@ -138,7 +139,7 @@ public class Event extends EventObject { * This class is a fluent builder class for building up the parameter map. */ public static class ParamsBuilder { - private Map params; + private Map<String, Object> params; /** * Adds a new parameter (a name/value pair). @@ -148,7 +149,7 @@ public class Event extends EventObject { */ public ParamsBuilder param(String name, Object value) { if (this.params == null) { - this.params = new java.util.HashMap(); + this.params = new java.util.HashMap<String, Object>(); } this.params.put(name, value); return this; @@ -158,7 +159,7 @@ public class Event extends EventObject { * Returns the accumulated parameter map. * @return the accumulated parameter map */ - public Map build() { + public Map<String, Object> build() { return this.params; } } diff --git a/src/java/org/apache/fop/events/EventExceptionManager.java b/src/java/org/apache/fop/events/EventExceptionManager.java index f7d679282..3494dc560 100644 --- a/src/java/org/apache/fop/events/EventExceptionManager.java +++ b/src/java/org/apache/fop/events/EventExceptionManager.java @@ -32,11 +32,12 @@ public final class EventExceptionManager { private EventExceptionManager() { } - private static final Map EXCEPTION_FACTORIES = new java.util.HashMap(); + private static final Map<String, ExceptionFactory> EXCEPTION_FACTORIES + = new java.util.HashMap<String, ExceptionFactory>(); static { - Iterator iter; - iter = Service.providers(ExceptionFactory.class, true); + Iterator<Object> iter; + iter = Service.providers(ExceptionFactory.class); while (iter.hasNext()) { ExceptionFactory factory = (ExceptionFactory)iter.next(); EXCEPTION_FACTORIES.put(factory.getExceptionClass().getName(), factory); @@ -63,7 +64,7 @@ public final class EventExceptionManager { String msg = EventFormatter.format(event); //Get original exception as cause if it is given as one of the parameters Throwable t = null; - Iterator iter = event.getParams().values().iterator(); + Iterator<Object> iter = event.getParams().values().iterator(); while (iter.hasNext()) { Object o = iter.next(); if (o instanceof Throwable) { @@ -96,6 +97,6 @@ public final class EventExceptionManager { * Returns the {@link Exception} class created by this factory. * @return the exception class */ - Class getExceptionClass(); + Class<? extends Exception> getExceptionClass(); } } diff --git a/src/java/org/apache/fop/events/PropertyExceptionFactory.java b/src/java/org/apache/fop/events/PropertyExceptionFactory.java index 753019b31..d8c7f39fb 100644 --- a/src/java/org/apache/fop/events/PropertyExceptionFactory.java +++ b/src/java/org/apache/fop/events/PropertyExceptionFactory.java @@ -40,7 +40,7 @@ public class PropertyExceptionFactory implements ExceptionFactory { } /** {@inheritDoc} */ - public Class getExceptionClass() { + public Class<PropertyException> getExceptionClass() { return PropertyException.class; } diff --git a/src/java/org/apache/fop/events/UnsupportedOperationExceptionFactory.java b/src/java/org/apache/fop/events/UnsupportedOperationExceptionFactory.java index 7ec9d19b2..570fcbd64 100644 --- a/src/java/org/apache/fop/events/UnsupportedOperationExceptionFactory.java +++ b/src/java/org/apache/fop/events/UnsupportedOperationExceptionFactory.java @@ -36,7 +36,7 @@ public class UnsupportedOperationExceptionFactory implements ExceptionFactory { } /** {@inheritDoc} */ - public Class getExceptionClass() { + public Class<UnsupportedOperationException> getExceptionClass() { return UnsupportedOperationException.class; } diff --git a/src/java/org/apache/fop/events/ValidationExceptionFactory.java b/src/java/org/apache/fop/events/ValidationExceptionFactory.java index 760c4ec58..2c7c69ce9 100644 --- a/src/java/org/apache/fop/events/ValidationExceptionFactory.java +++ b/src/java/org/apache/fop/events/ValidationExceptionFactory.java @@ -43,7 +43,7 @@ public class ValidationExceptionFactory implements ExceptionFactory { } /** {@inheritDoc} */ - public Class getExceptionClass() { + public Class<ValidationException> getExceptionClass() { return ValidationException.class; } diff --git a/src/java/org/apache/fop/fo/ElementMapping.java b/src/java/org/apache/fop/fo/ElementMapping.java index 1651f23a6..befb65eff 100644 --- a/src/java/org/apache/fop/fo/ElementMapping.java +++ b/src/java/org/apache/fop/fo/ElementMapping.java @@ -30,7 +30,7 @@ import org.apache.xmlgraphics.util.QName; /** * Abstract base class for Element Mappings (including FO Element Mappings) - * which provide the framework of valid elements and attibutes for a given + * which provide the framework of valid elements and attributes for a given * namespace. */ public abstract class ElementMapping { @@ -38,7 +38,7 @@ public abstract class ElementMapping { public static final String DEFAULT = "<default>"; /** The HashMap table of formatting objects defined by the ElementMapping */ - protected HashMap foObjs = null; + protected HashMap<String, Maker> foObjs = null; //Please don't change that to java.util.Map as that can break extensions. /** The namespace for the ElementMapping */ @@ -49,7 +49,7 @@ public abstract class ElementMapping { * * @return Table of Maker objects for this ElementMapping */ - public HashMap getTable() { + public HashMap<String, Maker> getTable() { if (foObjs == null) { initialize(); } diff --git a/src/java/org/apache/fop/fo/ElementMappingRegistry.java b/src/java/org/apache/fop/fo/ElementMappingRegistry.java index 4a6904f73..cf14fa281 100644 --- a/src/java/org/apache/fop/fo/ElementMappingRegistry.java +++ b/src/java/org/apache/fop/fo/ElementMappingRegistry.java @@ -48,12 +48,14 @@ public class ElementMappingRegistry { * Table mapping element names to the makers of objects * representing formatting objects. */ - protected Map fobjTable = new java.util.HashMap(); + protected Map<String, Map<String, Maker>> fobjTable + = new java.util.HashMap<String, Map<String, Maker>>(); /** * Map of mapped namespaces and their associated ElementMapping instances. */ - protected Map namespaces = new java.util.HashMap(); + protected Map<String, ElementMapping> namespaces + = new java.util.HashMap<String, ElementMapping>(); /** * Main constructor. Adds all default element mapping as well as detects ElementMapping @@ -70,10 +72,10 @@ public class ElementMappingRegistry { */ private void setupDefaultMappings() { // add mappings from available services - Iterator providers = Service.providers(ElementMapping.class, false); + Iterator<String> providers = Service.providerNames(ElementMapping.class); if (providers != null) { while (providers.hasNext()) { - String mapping = (String)providers.next(); + String mapping = providers.next(); try { addElementMapping(mapping); } catch (IllegalArgumentException e) { @@ -129,13 +131,13 @@ public class ElementMappingRegistry { */ public Maker findFOMaker(String namespaceURI, String localName, Locator locator) throws FOPException { - Map table = (Map)fobjTable.get(namespaceURI); + Map<String, Maker> table = fobjTable.get(namespaceURI); Maker fobjMaker = null; if (table != null) { - fobjMaker = (Maker)table.get(localName); + fobjMaker = table.get(localName); // try default if (fobjMaker == null) { - fobjMaker = (Maker)table.get(ElementMapping.DEFAULT); + fobjMaker = table.get(ElementMapping.DEFAULT); } } diff --git a/src/java/org/apache/fop/fo/FOElementMapping.java b/src/java/org/apache/fop/fo/FOElementMapping.java index 0a7e40955..8069880c6 100644 --- a/src/java/org/apache/fop/fo/FOElementMapping.java +++ b/src/java/org/apache/fop/fo/FOElementMapping.java @@ -44,7 +44,7 @@ public class FOElementMapping extends ElementMapping { */ protected void initialize() { if (foObjs == null) { - foObjs = new HashMap(); + foObjs = new HashMap<String, Maker>(); // Declarations and Pagination and Layout Formatting Objects foObjs.put("root", new RootMaker()); diff --git a/src/java/org/apache/fop/fo/InlineCharIterator.java b/src/java/org/apache/fop/fo/InlineCharIterator.java deleted file mode 100644 index f71753dde..000000000 --- a/src/java/org/apache/fop/fo/InlineCharIterator.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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$ */ - -package org.apache.fop.fo; - -import org.apache.fop.fo.properties.CommonBorderPaddingBackground; -import org.apache.fop.util.CharUtilities; -import java.util.NoSuchElementException; - -/** - * A recursive char iterator that indicates boundaries by returning - * an EOT char. - */ -public class InlineCharIterator extends RecursiveCharIterator { - private boolean startBoundary = false; - private boolean endBoundary = false; - - /** - * @param fobj the object for whose character contents and for whose - * descendant's character contents should be iterated - * @param bpb the CommonBorderPaddingBackground properties to be applied - */ - public InlineCharIterator(FObj fobj, CommonBorderPaddingBackground bpb) { - super(fobj); - checkBoundaries(bpb); - } - - - private void checkBoundaries(CommonBorderPaddingBackground bpb) { - /* Current understanding is that an <fo:inline> is always a boundary for - * whitespace collapse if it has a border or not - startBoundary = (bpb.getBorderStartWidth(false) > 0 - || bpb.getPaddingStart(false, null) > 0); // TODO do we need context here? - endBoundary = (bpb.getBorderEndWidth(false) > 0 - || bpb.getPaddingEnd(false, null) > 0); // TODO do we need context here? - */ - startBoundary = true; - endBoundary = true; - } - - /** - * @return true if there are more characters - */ - public boolean hasNext() { - if (startBoundary) { - return true; - } - return (super.hasNext() || endBoundary); - /* If super.hasNext() returns false, - * we return true if we are going to return a "boundary" signal - * else false. - */ - } - - /** - * @return the next character - * @throws NoSuchElementException if there are no more characters - */ - public char nextChar() throws NoSuchElementException { - if (startBoundary) { - startBoundary = false; - return CharUtilities.CODE_EOT; - } - try { - return super.nextChar(); - } catch (NoSuchElementException e) { - // Underlying has nothing more to return - // Check end boundary char - if (endBoundary) { - endBoundary = false; - return CharUtilities.CODE_EOT; - } else { - throw e; - } - } - } -} - diff --git a/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java b/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java index a12bed0fa..80a569c90 100644 --- a/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java +++ b/src/java/org/apache/fop/fo/extensions/ExtensionElementMapping.java @@ -37,8 +37,8 @@ public class ExtensionElementMapping extends ElementMapping { /** The FOP extension namespace URI */ public static final String URI = "http://xmlgraphics.apache.org/fop/extensions"; - private static final Set PROPERTY_ATTRIBUTES - = new java.util.HashSet(); + private static final Set<String> PROPERTY_ATTRIBUTES + = new java.util.HashSet<String>(); static { //These are FOP's standard extension properties (fox:*) @@ -63,7 +63,7 @@ public class ExtensionElementMapping extends ElementMapping { */ protected void initialize() { if (foObjs == null) { - foObjs = new HashMap(); + foObjs = new HashMap<String, Maker>(); foObjs.put("outline", new UnknownXMLObj.Maker(URI)); foObjs.put("label", new UnknownXMLObj.Maker(URI)); foObjs.put("destination", new DestinationMaker()); diff --git a/src/java/org/apache/fop/fo/extensions/InternalElementMapping.java b/src/java/org/apache/fop/fo/extensions/InternalElementMapping.java index 7704c8de7..4798f5500 100644 --- a/src/java/org/apache/fop/fo/extensions/InternalElementMapping.java +++ b/src/java/org/apache/fop/fo/extensions/InternalElementMapping.java @@ -34,7 +34,7 @@ public class InternalElementMapping extends ElementMapping { /** The FOP extension namespace URI */ public static final String URI = "http://xmlgraphics.apache.org/fop/internal"; - private static final Set PROPERTY_ATTRIBUTES = new java.util.HashSet(); + private static final Set<String> PROPERTY_ATTRIBUTES = new java.util.HashSet<String>(); static { //These are FOP's extension properties for accessibility @@ -53,7 +53,7 @@ public class InternalElementMapping extends ElementMapping { */ protected void initialize() { if (foObjs == null) { - foObjs = new HashMap(); + foObjs = new HashMap<String, Maker>(); } } diff --git a/src/java/org/apache/fop/fo/extensions/OldExtensionElementMapping.java b/src/java/org/apache/fop/fo/extensions/OldExtensionElementMapping.java index e5ab93c35..d1c671dbe 100644 --- a/src/java/org/apache/fop/fo/extensions/OldExtensionElementMapping.java +++ b/src/java/org/apache/fop/fo/extensions/OldExtensionElementMapping.java @@ -44,7 +44,7 @@ public class OldExtensionElementMapping extends ElementMapping { */ protected void initialize() { if (foObjs == null) { - foObjs = new HashMap(); + foObjs = new HashMap<String, Maker>(); foObjs.put("outline", new UnknownXMLObj.Maker(URI)); foObjs.put("label", new UnknownXMLObj.Maker(URI)); } diff --git a/src/java/org/apache/fop/fo/extensions/svg/BatikExtensionElementMapping.java b/src/java/org/apache/fop/fo/extensions/svg/BatikExtensionElementMapping.java index 449258525..6103345cf 100644 --- a/src/java/org/apache/fop/fo/extensions/svg/BatikExtensionElementMapping.java +++ b/src/java/org/apache/fop/fo/extensions/svg/BatikExtensionElementMapping.java @@ -73,7 +73,7 @@ public class BatikExtensionElementMapping extends ElementMapping { XMLResourceDescriptor.setXMLParserClassName( getAParserClassName()); - foObjs = new HashMap(); + foObjs = new HashMap<String, Maker>(); foObjs.put("batik", new SE()); foObjs.put(DEFAULT, new SVGMaker()); } catch (Throwable t) { diff --git a/src/java/org/apache/fop/fo/extensions/svg/SVGElementMapping.java b/src/java/org/apache/fop/fo/extensions/svg/SVGElementMapping.java index 167baf723..7120dbb59 100644 --- a/src/java/org/apache/fop/fo/extensions/svg/SVGElementMapping.java +++ b/src/java/org/apache/fop/fo/extensions/svg/SVGElementMapping.java @@ -80,7 +80,7 @@ public class SVGElementMapping extends ElementMapping { XMLResourceDescriptor.setXMLParserClassName( getAParserClassName()); - foObjs = new HashMap(); + foObjs = new HashMap<String, Maker>(); foObjs.put("svg", new SE()); foObjs.put(DEFAULT, new SVGMaker()); } catch (Throwable t) { diff --git a/src/java/org/apache/fop/fo/extensions/xmp/RDFElementMapping.java b/src/java/org/apache/fop/fo/extensions/xmp/RDFElementMapping.java index ff84ee11f..a6befd710 100644 --- a/src/java/org/apache/fop/fo/extensions/xmp/RDFElementMapping.java +++ b/src/java/org/apache/fop/fo/extensions/xmp/RDFElementMapping.java @@ -45,7 +45,7 @@ public class RDFElementMapping extends ElementMapping { /** {@inheritDoc} */ protected void initialize() { if (foObjs == null) { - foObjs = new HashMap(); + foObjs = new HashMap<String, Maker>(); foObjs.put("RDF", new RDFElementMaker()); } } diff --git a/src/java/org/apache/fop/fo/extensions/xmp/XMPElementMapping.java b/src/java/org/apache/fop/fo/extensions/xmp/XMPElementMapping.java index b2b3570f2..d934dc2b1 100644 --- a/src/java/org/apache/fop/fo/extensions/xmp/XMPElementMapping.java +++ b/src/java/org/apache/fop/fo/extensions/xmp/XMPElementMapping.java @@ -45,7 +45,7 @@ public class XMPElementMapping extends ElementMapping { /** {@inheritDoc} */ protected void initialize() { if (foObjs == null) { - foObjs = new HashMap(); + foObjs = new HashMap<String, Maker>(); foObjs.put("xmpmeta", new XMPMetaElementMaker()); } } diff --git a/src/java/org/apache/fop/fo/pagination/Declarations.java b/src/java/org/apache/fop/fo/pagination/Declarations.java index 1385bccc9..9c68043ff 100644 --- a/src/java/org/apache/fop/fo/pagination/Declarations.java +++ b/src/java/org/apache/fop/fo/pagination/Declarations.java @@ -41,7 +41,7 @@ import org.apache.fop.fo.ValidationException; */ public class Declarations extends FObj { - private Map colorProfiles = null; + private Map<String, ColorProfile> colorProfiles = null; /** * @param parent FONode that is the parent of this object @@ -98,7 +98,7 @@ public class Declarations extends FObj { private void addColorProfile(ColorProfile cp) { if (colorProfiles == null) { - colorProfiles = new java.util.HashMap(); + colorProfiles = new java.util.HashMap<String, ColorProfile>(); } if (colorProfiles.get(cp.getColorProfileName()) != null) { // duplicate names @@ -132,7 +132,7 @@ public class Declarations extends FObj { public ColorProfile getColorProfile(String cpName) { ColorProfile profile = null; if (this.colorProfiles != null) { - profile = (ColorProfile)this.colorProfiles.get(cpName); + profile = this.colorProfiles.get(cpName); } return profile; } diff --git a/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java b/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java index 482ec83c4..c4189d0c4 100644 --- a/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java +++ b/src/java/org/apache/fop/fo/pagination/LayoutMasterSet.java @@ -44,8 +44,8 @@ import org.apache.fop.fo.ValidationException; */ public class LayoutMasterSet extends FObj { - private Map simplePageMasters; - private Map pageSequenceMasters; + private Map<String, SimplePageMaster> simplePageMasters; + private Map<String, PageSequenceMaster> pageSequenceMasters; /** * Create a LayoutMasterSet instance that is a child of the given @@ -65,8 +65,8 @@ public class LayoutMasterSet extends FObj { /** {@inheritDoc} */ protected void startOfNode() throws FOPException { getRoot().setLayoutMasterSet(this); - simplePageMasters = new java.util.HashMap(); - pageSequenceMasters = new java.util.HashMap(); + simplePageMasters = new java.util.HashMap<String, SimplePageMaster>(); + pageSequenceMasters = new java.util.HashMap<String, PageSequenceMaster>(); } /** {@inheritDoc} */ @@ -98,18 +98,13 @@ public class LayoutMasterSet extends FObj { */ private void checkRegionNames() throws ValidationException { // (user-entered) region-name to default region map. - Map allRegions = new java.util.HashMap(); - for (Iterator spm = simplePageMasters.values().iterator(); - spm.hasNext();) { - SimplePageMaster simplePageMaster - = (SimplePageMaster)spm.next(); - Map spmRegions = simplePageMaster.getRegions(); - for (Iterator e = spmRegions.values().iterator(); - e.hasNext();) { - Region region = (Region) e.next(); + Map<String, String> allRegions = new java.util.HashMap<String, String>(); + for (SimplePageMaster simplePageMaster : simplePageMasters.values()) { + Map<String, Region> spmRegions = simplePageMaster.getRegions(); + for (Region region : spmRegions.values()) { if (allRegions.containsKey(region.getRegionName())) { String defaultRegionName - = (String) allRegions.get(region.getRegionName()); + = allRegions.get(region.getRegionName()); if (!defaultRegionName.equals(region.getDefaultRegionName())) { getFOValidationEventProducer().regionNameMappedToMultipleRegionClasses(this, region.getRegionName(), @@ -118,7 +113,7 @@ public class LayoutMasterSet extends FObj { } } allRegions.put(region.getRegionName(), - region.getDefaultRegionName()); + region.getDefaultRegionName()); } } } @@ -155,7 +150,7 @@ public class LayoutMasterSet extends FObj { * @return the requested simple-page-master */ public SimplePageMaster getSimplePageMaster(String masterName) { - return (SimplePageMaster)this.simplePageMasters.get(masterName); + return this.simplePageMasters.get(masterName); } /** @@ -185,7 +180,7 @@ public class LayoutMasterSet extends FObj { * @return the requested PageSequenceMaster instance */ public PageSequenceMaster getPageSequenceMaster(String masterName) { - return (PageSequenceMaster)this.pageSequenceMasters.get(masterName); + return this.pageSequenceMasters.get(masterName); } /** @@ -194,9 +189,8 @@ public class LayoutMasterSet extends FObj { * @return true when the region name specified has a region in this LayoutMasterSet */ public boolean regionNameExists(String regionName) { - for (Iterator e = simplePageMasters.values().iterator(); - e.hasNext();) { - if (((SimplePageMaster)e.next()).regionNameExists(regionName)) { + for (SimplePageMaster spm : simplePageMasters.values()) { + if (spm.regionNameExists(regionName)) { return true; } } diff --git a/src/java/org/apache/fop/fo/pagination/PageProductionException.java b/src/java/org/apache/fop/fo/pagination/PageProductionException.java index bb09db6f4..39060f3d4 100644 --- a/src/java/org/apache/fop/fo/pagination/PageProductionException.java +++ b/src/java/org/apache/fop/fo/pagination/PageProductionException.java @@ -98,7 +98,7 @@ public class PageProductionException extends RuntimeException { } /** {@inheritDoc} */ - public Class getExceptionClass() { + public Class<PageProductionException> getExceptionClass() { return PageProductionException.class; } diff --git a/src/java/org/apache/fop/fo/pagination/PageSequence.java b/src/java/org/apache/fop/fo/pagination/PageSequence.java index 88b3f29d1..6d01a7da4 100644 --- a/src/java/org/apache/fop/fo/pagination/PageSequence.java +++ b/src/java/org/apache/fop/fo/pagination/PageSequence.java @@ -54,7 +54,7 @@ public class PageSequence extends AbstractPageSequence implements WritingModeTra // the set of flows includes StaticContent flows also /** Map of flows to their flow name (flow-name, Flow) */ - private Map/*<String, Flow>*/ flowMap; + private Map<String, Flow> flowMap; /** * The currentSimplePageMaster is either the page master for the @@ -103,7 +103,7 @@ public class PageSequence extends AbstractPageSequence implements WritingModeTra /** {@inheritDoc} */ protected void startOfNode() throws FOPException { super.startOfNode(); - flowMap = new java.util.HashMap/*<String, Flow>*/(); + flowMap = new java.util.HashMap<String, Flow>(); this.simplePageMaster = getRoot().getLayoutMasterSet().getSimplePageMaster(masterReference); @@ -174,7 +174,7 @@ public class PageSequence extends AbstractPageSequence implements WritingModeTra break; case FO_STATIC_CONTENT: addFlow((StaticContent)child); - flowMap.put(((StaticContent)child).getFlowName(), child); + flowMap.put(((Flow)child).getFlowName(), (Flow)child); break; default: super.addChildNode(child); @@ -246,7 +246,7 @@ public class PageSequence extends AbstractPageSequence implements WritingModeTra } /** @return the flow map for this page-sequence */ - public Map getFlowMap() { + public Map<String, Flow> getFlowMap() { return this.flowMap; } diff --git a/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java b/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java index 705b955e9..5b71525d3 100644 --- a/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java +++ b/src/java/org/apache/fop/fo/pagination/PageSequenceMaster.java @@ -44,7 +44,7 @@ public class PageSequenceMaster extends FObj { // End of property values private LayoutMasterSet layoutMasterSet; - private List subSequenceSpecifiers; + private List<SubSequenceSpecifier> subSequenceSpecifiers; private SubSequenceSpecifier currentSubSequence; private int currentSubSequenceNumber = -1; @@ -76,7 +76,7 @@ public class PageSequenceMaster extends FObj { /** {@inheritDoc} */ protected void startOfNode() throws FOPException { - subSequenceSpecifiers = new java.util.ArrayList(); + subSequenceSpecifiers = new java.util.ArrayList<SubSequenceSpecifier>(); layoutMasterSet = parent.getRoot().getLayoutMasterSet(); layoutMasterSet.addPageSequenceMaster(masterName, this); } @@ -121,8 +121,7 @@ public class PageSequenceMaster extends FObj { currentSubSequenceNumber++; if (currentSubSequenceNumber >= 0 && currentSubSequenceNumber < subSequenceSpecifiers.size()) { - return (SubSequenceSpecifier)subSequenceSpecifiers - .get(currentSubSequenceNumber); + return subSequenceSpecifiers.get(currentSubSequenceNumber); } return null; } @@ -134,8 +133,8 @@ public class PageSequenceMaster extends FObj { currentSubSequenceNumber = -1; currentSubSequence = null; if (subSequenceSpecifiers != null) { - for (int i = 0; i < subSequenceSpecifiers.size(); i++) { - ((SubSequenceSpecifier)subSequenceSpecifiers.get(i)).reset(); + for (SubSequenceSpecifier subSequenceSpecifier : subSequenceSpecifiers) { + subSequenceSpecifier.reset(); } } } @@ -150,7 +149,7 @@ public class PageSequenceMaster extends FObj { if (!success) { if (currentSubSequenceNumber > 0) { currentSubSequenceNumber--; - currentSubSequence = (SubSequenceSpecifier)subSequenceSpecifiers + currentSubSequence = subSequenceSpecifiers .get(currentSubSequenceNumber); } else { currentSubSequence = null; diff --git a/src/java/org/apache/fop/fo/pagination/Region.java b/src/java/org/apache/fop/fo/pagination/Region.java index f3d7dcc66..16956b6dd 100644 --- a/src/java/org/apache/fop/fo/pagination/Region.java +++ b/src/java/org/apache/fop/fo/pagination/Region.java @@ -48,7 +48,8 @@ public abstract class Region extends FObj { private WritingMode writingMode; // End of FO trait values - private SimplePageMaster layoutMaster; + /** the parent {@link SimplePageMaster} */ + protected final SimplePageMaster layoutMaster; /** * Base constructor @@ -103,11 +104,9 @@ public abstract class Region extends FObj { /** * @param pageRefRect reference dimension of the page area. - * @param spm the simple page master this region belongs to. * @return the rectangle for the viewport area */ - public abstract Rectangle getViewportRectangle(FODimension pageRefRect - , SimplePageMaster spm); + public abstract Rectangle getViewportRectangle(FODimension pageRefRect); /** * Returns the default region name (xsl-region-before, xsl-region-start, diff --git a/src/java/org/apache/fop/fo/pagination/RegionAfter.java b/src/java/org/apache/fop/fo/pagination/RegionAfter.java index 3b9be0333..3541c54be 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionAfter.java +++ b/src/java/org/apache/fop/fo/pagination/RegionAfter.java @@ -45,7 +45,7 @@ public class RegionAfter extends RegionBA { } /** {@inheritDoc} */ - public Rectangle getViewportRectangle (FODimension reldims, SimplePageMaster spm) { + public Rectangle getViewportRectangle (FODimension reldims) { /* Special rules apply to resolving extent as values are resolved relative * to the page size and reference orientation. */ @@ -71,7 +71,7 @@ public class RegionAfter extends RegionBA { break; } if (getPrecedence() == EN_FALSE) { - adjustIPD(vpRect, spm.getWritingMode(), neighbourContext); + adjustIPD(vpRect, layoutMaster.getWritingMode(), neighbourContext); } return vpRect; } diff --git a/src/java/org/apache/fop/fo/pagination/RegionBefore.java b/src/java/org/apache/fop/fo/pagination/RegionBefore.java index 2b0fb43f4..295f6dc1c 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionBefore.java +++ b/src/java/org/apache/fop/fo/pagination/RegionBefore.java @@ -26,7 +26,7 @@ import java.awt.Rectangle; import org.apache.fop.fo.Constants; import org.apache.fop.datatypes.FODimension; import org.apache.fop.datatypes.LengthBase; -import org.apache.fop.datatypes.SimplePercentBaseContext; +import org.apache.fop.datatypes.PercentBaseContext; import org.apache.fop.fo.FONode; /** @@ -50,29 +50,13 @@ public class RegionBefore extends RegionBA { } /** {@inheritDoc} */ - public Rectangle getViewportRectangle (FODimension reldims, SimplePageMaster spm) { + public Rectangle getViewportRectangle (FODimension reldims) { /* Special rules apply to resolving extent as values are resolved relative * to the page size and reference orientation. */ - SimplePercentBaseContext pageWidthContext; - SimplePercentBaseContext pageHeightContext; - if (spm.getReferenceOrientation() % 180 == 0) { - pageWidthContext = new SimplePercentBaseContext(null, - LengthBase.CUSTOM_BASE, - spm.getPageWidth().getValue()); - pageHeightContext = new SimplePercentBaseContext(null, - LengthBase.CUSTOM_BASE, - spm.getPageHeight().getValue()); - } else { - // invert width and height since top left are rotated by 90 (cl or ccl) - pageWidthContext = new SimplePercentBaseContext(null, - LengthBase.CUSTOM_BASE, - spm.getPageHeight().getValue()); - pageHeightContext = new SimplePercentBaseContext(null, - LengthBase.CUSTOM_BASE, - spm.getPageWidth().getValue()); - } - SimplePercentBaseContext neighbourContext; + PercentBaseContext pageWidthContext = getPageWidthContext(LengthBase.CUSTOM_BASE); + PercentBaseContext pageHeightContext = getPageHeightContext(LengthBase.CUSTOM_BASE); + PercentBaseContext neighbourContext; Rectangle vpRect; // [TBD] WRITING MODE ALERT switch ( getWritingMode().getEnumValue() ) { @@ -89,7 +73,7 @@ public class RegionBefore extends RegionBA { break; } if (getPrecedence() == EN_FALSE) { - adjustIPD(vpRect, spm.getWritingMode(), neighbourContext); + adjustIPD(vpRect, layoutMaster.getWritingMode(), neighbourContext); } return vpRect; } diff --git a/src/java/org/apache/fop/fo/pagination/RegionBody.java b/src/java/org/apache/fop/fo/pagination/RegionBody.java index a3d556f3c..9e6392337 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionBody.java +++ b/src/java/org/apache/fop/fo/pagination/RegionBody.java @@ -98,7 +98,7 @@ public class RegionBody extends Region { } /** {@inheritDoc} */ - public Rectangle getViewportRectangle (FODimension reldims, SimplePageMaster spm) { + public Rectangle getViewportRectangle (FODimension reldims) { /* Special rules apply to resolving margins in the page context. * Contrary to normal margins in this case top and bottom margin * are resolved relative to the height. In the property subsystem diff --git a/src/java/org/apache/fop/fo/pagination/RegionEnd.java b/src/java/org/apache/fop/fo/pagination/RegionEnd.java index afeccb182..6385c986b 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionEnd.java +++ b/src/java/org/apache/fop/fo/pagination/RegionEnd.java @@ -45,7 +45,7 @@ public class RegionEnd extends RegionSE { } /** {@inheritDoc} */ - public Rectangle getViewportRectangle (FODimension reldims, SimplePageMaster spm) { + public Rectangle getViewportRectangle (FODimension reldims) { /* Special rules apply to resolving extent as values are resolved relative * to the page size and reference orientation. */ diff --git a/src/java/org/apache/fop/fo/pagination/RegionStart.java b/src/java/org/apache/fop/fo/pagination/RegionStart.java index a62744bae..16bcb23ff 100644 --- a/src/java/org/apache/fop/fo/pagination/RegionStart.java +++ b/src/java/org/apache/fop/fo/pagination/RegionStart.java @@ -45,7 +45,7 @@ public class RegionStart extends RegionSE { } /** {@inheritDoc} */ - public Rectangle getViewportRectangle (FODimension reldims, SimplePageMaster spm) { + public Rectangle getViewportRectangle (FODimension reldims) { /* Special rules apply to resolving extent as values are resolved relative * to the page size and reference orientation. */ @@ -67,7 +67,7 @@ public class RegionStart extends RegionSE { vpRect = new Rectangle(0, 0, reldims.bpd, getExtent().getValue(pageHeightContext)); break; } - adjustIPD(vpRect, spm.getWritingMode(), neighbourContext); + adjustIPD(vpRect, layoutMaster.getWritingMode(), neighbourContext); return vpRect; } diff --git a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java index 9b4c6544f..629d7d59d 100644 --- a/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java +++ b/src/java/org/apache/fop/fo/pagination/RepeatablePageMasterAlternatives.java @@ -48,7 +48,7 @@ public class RepeatablePageMasterAlternatives extends FObj private int numberConsumed = 0; - private List conditionalPageMasterRefs; + private List<ConditionalPageMasterReference> conditionalPageMasterRefs; private boolean hasPagePositionLast = false; private boolean hasPagePositionOnly = false; @@ -68,7 +68,7 @@ public class RepeatablePageMasterAlternatives extends FObj /** {@inheritDoc} */ protected void startOfNode() throws FOPException { - conditionalPageMasterRefs = new java.util.ArrayList(); + conditionalPageMasterRefs = new java.util.ArrayList<ConditionalPageMasterReference>(); assert parent.getName().equals("fo:page-sequence-master"); //Validation by the parent PageSequenceMaster pageSequenceMaster = (PageSequenceMaster)parent; @@ -128,9 +128,7 @@ public class RepeatablePageMasterAlternatives extends FObj numberConsumed++; } - for (int i = 0; i < conditionalPageMasterRefs.size(); i++) { - ConditionalPageMasterReference cpmr - = (ConditionalPageMasterReference)conditionalPageMasterRefs.get(i); + for (ConditionalPageMasterReference cpmr : conditionalPageMasterRefs) { if (cpmr.isValid(isOddPage, isFirstPage, isLastPage, isBlankPage)) { return cpmr.getMasterReference(); } diff --git a/src/java/org/apache/fop/fo/pagination/Root.java b/src/java/org/apache/fop/fo/pagination/Root.java index 8f8e0a509..fb69dc2f1 100644 --- a/src/java/org/apache/fop/fo/pagination/Root.java +++ b/src/java/org/apache/fop/fo/pagination/Root.java @@ -47,8 +47,8 @@ public class Root extends FObj { private LayoutMasterSet layoutMasterSet; private Declarations declarations; private BookmarkTree bookmarkTree = null; - private List destinationList; - private List pageSequences; + private List<Destination> destinationList; + private List<PageSequence> pageSequences; // temporary until above list populated private boolean pageSequenceFound = false; @@ -77,11 +77,12 @@ public class Root extends FObj { */ public Root(FONode parent) { super(parent); - pageSequences = new java.util.ArrayList(); + pageSequences = new java.util.ArrayList<PageSequence>(); } /** {@inheritDoc} */ public void bind(PropertyList pList) throws FOPException { + super.bind(pList); mediaUsage = pList.get(PR_MEDIA_USAGE).getEnum(); } @@ -243,7 +244,7 @@ public class Root extends FObj { return null; } if (currentIndex < (pageSequences.size() - 1)) { - return (PageSequence)pageSequences.get(currentIndex + 1); + return pageSequences.get(currentIndex + 1); } else { return null; } @@ -295,7 +296,7 @@ public class Root extends FObj { */ public void addDestination(Destination destination) { if (destinationList == null) { - destinationList = new java.util.ArrayList(); + destinationList = new java.util.ArrayList<Destination>(); } destinationList.add(destination); } diff --git a/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java b/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java index a144fa33f..0ccbe6ebd 100644 --- a/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java +++ b/src/java/org/apache/fop/fo/pagination/SimplePageMaster.java @@ -57,7 +57,7 @@ public class SimplePageMaster extends FObj { /** * Page regions (regionClass, Region) */ - private Map regions; + private Map<String, Region> regions; // used for node validation private boolean hasRegionBody = false; @@ -100,7 +100,7 @@ public class SimplePageMaster extends FObj { } //Well, there are only 5 regions so we can save a bit of memory here - regions = new HashMap(5); + regions = new HashMap<String, Region>(5); } /** {@inheritDoc} */ @@ -136,7 +136,7 @@ public class SimplePageMaster extends FObj { } else if (hasRegionEnd) { nodesOutOfOrderError(loc, "fo:region-before", "fo:region-end"); } else { - hasRegionBody = true; + hasRegionBefore = true; } } else if (localName.equals("region-after")) { if (!hasRegionBody) { @@ -193,8 +193,7 @@ public class SimplePageMaster extends FObj { * @param region region to add */ protected void addRegion(Region region) { - String key = String.valueOf(region.getNameId()); - regions.put(key, region); + regions.put(String.valueOf(region.getNameId()), region); } /** @@ -241,14 +240,14 @@ public class SimplePageMaster extends FObj { * @return the region, null if it doesn't exist */ public Region getRegion(int regionId) { - return (Region) regions.get(String.valueOf(regionId)); + return regions.get(String.valueOf(regionId)); } /** * Returns a Map of regions associated with this simple-page-master * @return the regions */ - public Map getRegions() { + public Map<String, Region> getRegions() { return regions; } @@ -259,9 +258,7 @@ public class SimplePageMaster extends FObj { * @return True if a region with this name exists */ protected boolean regionNameExists(String regionName) { - for (Iterator regenum = regions.values().iterator(); - regenum.hasNext();) { - Region r = (Region) regenum.next(); + for (Region r : regions.values()) { if (r.getRegionName().equals(regionName)) { return true; } diff --git a/src/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java b/src/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java index aa2c2bb8b..2bb891cd9 100644 --- a/src/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java +++ b/src/java/org/apache/fop/fo/pagination/SubSequenceSpecifier.java @@ -28,6 +28,7 @@ public interface SubSequenceSpecifier { /** * Returns the name of the next page master. + * * @param isOddPage True if the next page number is odd * @param isFirstPage True if the next page is the first * @param isLastPage True if the next page is the last diff --git a/src/java/org/apache/fop/fonts/FontManagerConfigurator.java b/src/java/org/apache/fop/fonts/FontManagerConfigurator.java index 852a0ca57..40e163d42 100644 --- a/src/java/org/apache/fop/fonts/FontManagerConfigurator.java +++ b/src/java/org/apache/fop/fonts/FontManagerConfigurator.java @@ -21,6 +21,7 @@ package org.apache.fop.fonts; import java.io.File; import java.net.MalformedURLException; +import java.net.URI; import java.util.List; import java.util.regex.Pattern; @@ -43,6 +44,8 @@ public class FontManagerConfigurator { private final Configuration cfg; + private URI baseURI = null; + /** * Main constructor * @param cfg the font manager configuration object @@ -52,6 +55,16 @@ public class FontManagerConfigurator { } /** + * Main constructor + * @param cfg the font manager configuration object + * @param baseURI the base URI of the configuration + */ + public FontManagerConfigurator(Configuration cfg, URI baseURI) { + this.cfg = cfg; + this.baseURI = baseURI; + } + + /** * Initializes font settings from the user configuration * @param fontManager a font manager * @param strict true if strict checking of the configuration is enabled @@ -74,8 +87,12 @@ public class FontManagerConfigurator { } } if (cfg.getChild("font-base", false) != null) { + String path = cfg.getChild("font-base").getValue(null); + if (baseURI != null) { + path = baseURI.resolve(path).normalize().toString(); + } try { - fontManager.setFontBaseURL(cfg.getChild("font-base").getValue(null)); + fontManager.setFontBaseURL(path); } catch (MalformedURLException mfue) { LogUtil.handleException(log, mfue, true); } diff --git a/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java b/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java index 76616bfb5..402161a92 100644 --- a/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java +++ b/src/java/org/apache/fop/layoutmgr/AbstractBreaker.java @@ -199,10 +199,10 @@ public abstract class AbstractBreaker { } - /** blockListIndex of the current BlockSequence in blockLists */ - private int blockListIndex = 0; + // used by doLayout and getNextBlockList* + private List<BlockSequence> blockLists; - private List blockLists = null; + private boolean empty = true; /** desired text alignment */ protected int alignment; @@ -277,7 +277,8 @@ public abstract class AbstractBreaker { * @param alignment the desired text alignment * @return the list of KnuthElements */ - protected abstract List getNextKnuthElements(LayoutContext context, int alignment); + protected abstract List<KnuthElement> getNextKnuthElements(LayoutContext context, + int alignment); /** * Get a sequence of KnuthElements representing the content @@ -290,14 +291,14 @@ public abstract class AbstractBreaker { * change occurs between two LMs * @return the list of KnuthElements */ - protected List getNextKnuthElements(LayoutContext context, int alignment, + protected List<KnuthElement> getNextKnuthElements(LayoutContext context, int alignment, Position positionAtIPDChange, LayoutManager restartAtLM) { throw new UnsupportedOperationException("TODO: implement acceptable fallback"); } /** @return true if there's no content that could be handled. */ public boolean isEmpty() { - return (this.blockLists.isEmpty()); + return empty; } /** @@ -374,21 +375,22 @@ public abstract class AbstractBreaker { childLC.setBPAlignment(alignment); BlockSequence blockList; - this.blockLists = new java.util.ArrayList(); + blockLists = new java.util.ArrayList<BlockSequence>(); log.debug("PLM> flow BPD =" + flowBPD); - //*** Phase 1: Get Knuth elements *** int nextSequenceStartsOn = Constants.EN_ANY; while (hasMoreContent()) { blockLists.clear(); + //*** Phase 1: Get Knuth elements *** nextSequenceStartsOn = getNextBlockList(childLC, nextSequenceStartsOn); + empty = empty && blockLists.size() == 0; - //*** Phase 2: Alignment and breaking *** + //*** Phases 2 and 3 *** log.debug("PLM> blockLists.size() = " + blockLists.size()); - for (blockListIndex = 0; blockListIndex < blockLists.size(); blockListIndex++) { - blockList = (BlockSequence) blockLists.get(blockListIndex); + for (int blockListIndex = 0; blockListIndex < blockLists.size(); blockListIndex++) { + blockList = blockLists.get(blockListIndex); //debug code start if (log.isDebugEnabled()) { @@ -398,12 +400,13 @@ public abstract class AbstractBreaker { observeElementList(blockList); //debug code end + //*** Phase 2: Alignment and breaking *** log.debug("PLM> start of algorithm (" + this.getClass().getName() + "), flow BPD =" + flowBPD); PageBreakingAlgorithm alg = new PageBreakingAlgorithm(getTopLevelLM(), - getPageProvider(), createLayoutListener(), - alignment, alignmentLast, footnoteSeparatorLength, - isPartOverflowRecoveryActivated(), autoHeight, isSinglePartFavored()); + getPageProvider(), createLayoutListener(), + alignment, alignmentLast, footnoteSeparatorLength, + isPartOverflowRecoveryActivated(), autoHeight, isSinglePartFavored()); BlockSequence effectiveList; if (getCurrentDisplayAlign() == Constants.EN_X_FILL) { @@ -418,89 +421,25 @@ public abstract class AbstractBreaker { int optimalPageCount = alg.findBreakingPoints(effectiveList, 1, true, BreakingAlgorithm.ALL_BREAKS); if (alg.getIPDdifference() != 0) { - KnuthNode optimalBreak = alg.getBestNodeBeforeIPDChange(); - int positionIndex = optimalBreak.position; - KnuthElement elementAtBreak = alg.getElement(positionIndex); - Position positionAtBreak = elementAtBreak.getPosition(); - if (!(positionAtBreak instanceof SpaceResolver.SpaceHandlingBreakPosition)) { - throw new UnsupportedOperationException( - "Don't know how to restart at position" + positionAtBreak); - } - /* Retrieve the original position wrapped into this space position */ - positionAtBreak = positionAtBreak.getPosition(); - LayoutManager restartAtLM = null; - List firstElements = Collections.EMPTY_LIST; - if (containsNonRestartableLM(positionAtBreak)) { - if (alg.getIPDdifference() > 0) { - EventBroadcaster eventBroadcaster = getCurrentChildLM().getFObj() - .getUserAgent().getEventBroadcaster(); - BlockLevelEventProducer eventProducer - = BlockLevelEventProducer.Provider.get(eventBroadcaster); - eventProducer.nonRestartableContentFlowingToNarrowerPage(this); - } - firstElements = new LinkedList(); - boolean boxFound = false; - Iterator iter = effectiveList.listIterator(positionIndex + 1); - Position position = null; - while (iter.hasNext() - && (position == null || containsNonRestartableLM(position))) { - positionIndex++; - KnuthElement element = (KnuthElement) iter.next(); - position = element.getPosition(); - if (element.isBox()) { - boxFound = true; - firstElements.add(element); - } else if (boxFound) { - firstElements.add(element); - } - } - if (position instanceof SpaceResolver.SpaceHandlingBreakPosition) { - /* Retrieve the original position wrapped into this space position */ - positionAtBreak = position.getPosition(); - } else { - positionAtBreak = null; - } - } - if (positionAtBreak != null && positionAtBreak.getIndex() == -1) { - /* - * This is an indication that we are between two blocks - * (possibly surrounded by another block), not inside a - * paragraph. - */ - Position position; - Iterator iter = effectiveList.listIterator(positionIndex + 1); - do { - KnuthElement nextElement = (KnuthElement) iter.next(); - position = nextElement.getPosition(); - } while (position == null - || position instanceof SpaceResolver.SpaceHandlingPosition - || position instanceof SpaceResolver.SpaceHandlingBreakPosition - && position.getPosition().getIndex() == -1); - LayoutManager surroundingLM = positionAtBreak.getLM(); - while (position.getLM() != surroundingLM) { - position = position.getPosition(); - } - restartAtLM = position.getPosition().getLM(); - } - log.trace("IPD changes after page " + optimalPageCount + " at index " - + optimalBreak.position); addAreas(alg, optimalPageCount, blockList, effectiveList); - + // *** redo Phase 1 *** + log.trace("IPD changes after page " + optimalPageCount); blockLists.clear(); + nextSequenceStartsOn = getNextBlockListChangedIPD(childLC, alg, + effectiveList); blockListIndex = -1; - nextSequenceStartsOn = getNextBlockList(childLC, Constants.EN_COLUMN, - positionAtBreak, restartAtLM, firstElements); } else { log.debug("PLM> iOptPageCount= " + optimalPageCount + " pageBreaks.size()= " + alg.getPageBreaks().size()); - //*** Phase 3: Add areas *** doPhase3(alg, optimalPageCount, blockList, effectiveList); } } } + // done + blockLists = null; } /** @@ -558,7 +497,6 @@ public abstract class AbstractBreaker { BlockSequence originalList, BlockSequence effectiveList) { LayoutContext childLC; // add areas - ListIterator effectiveListIterator = effectiveList.listIterator(); int startElementIndex = 0; int endElementIndex = 0; int lastBreak = -1; @@ -616,11 +554,10 @@ public abstract class AbstractBreaker { // ignore KnuthGlue and KnuthPenalty objects // at the beginning of the line - effectiveListIterator = effectiveList - .listIterator(startElementIndex); + ListIterator<KnuthElement> effectiveListIterator + = effectiveList.listIterator(startElementIndex); while (effectiveListIterator.hasNext() - && !((KnuthElement) effectiveListIterator.next()) - .isBox()) { + && !(effectiveListIterator.next()).isBox()) { startElementIndex++; } @@ -643,10 +580,9 @@ public abstract class AbstractBreaker { && p < (partCount - 1)) { // count the boxes whose width is not 0 int boxCount = 0; - effectiveListIterator = effectiveList - .listIterator(startElementIndex); + effectiveListIterator = effectiveList.listIterator(startElementIndex); while (effectiveListIterator.nextIndex() <= endElementIndex) { - KnuthElement tempEl = (KnuthElement)effectiveListIterator.next(); + KnuthElement tempEl = effectiveListIterator.next(); if (tempEl.isBox() && tempEl.getWidth() > 0) { boxCount++; } @@ -710,8 +646,7 @@ public abstract class AbstractBreaker { * @param nextSequenceStartsOn indicates on what page the next sequence should start * @return the page on which the next content should appear after a hard break */ - protected int getNextBlockList(LayoutContext childLC, - int nextSequenceStartsOn) { + protected int getNextBlockList(LayoutContext childLC, int nextSequenceStartsOn) { return getNextBlockList(childLC, nextSequenceStartsOn, null, null, null); } @@ -730,13 +665,14 @@ public abstract class AbstractBreaker { * break */ protected int getNextBlockList(LayoutContext childLC, int nextSequenceStartsOn, - Position positionAtIPDChange, LayoutManager restartAtLM, List firstElements) { + Position positionAtIPDChange, LayoutManager restartAtLM, + List<KnuthElement> firstElements) { updateLayoutContext(childLC); //Make sure the span change signal is reset childLC.signalSpanChange(Constants.NOT_SET); BlockSequence blockList; - List returnedList; + List<KnuthElement> returnedList; if (firstElements == null) { returnedList = getNextKnuthElements(childLC, alignment); } else if (positionAtIPDChange == null) { @@ -798,9 +734,89 @@ public abstract class AbstractBreaker { BlockSequence seq; seq = blockList.endBlockSequence(breakPosition); if (seq != null) { - this.blockLists.add(seq); + blockLists.add(seq); + } + } + return nextSequenceStartsOn; + } + + /** + * @param childLC LayoutContext to use + * @param alg the pagebreaking algorithm + * @param effectiveList the list of Knuth elements to be reused + * @return the page on which the next content should appear after a hard break + */ + private int getNextBlockListChangedIPD(LayoutContext childLC, PageBreakingAlgorithm alg, + BlockSequence effectiveList) { + int nextSequenceStartsOn; + KnuthNode optimalBreak = alg.getBestNodeBeforeIPDChange(); + int positionIndex = optimalBreak.position; + log.trace("IPD changes at index " + positionIndex); + KnuthElement elementAtBreak = alg.getElement(positionIndex); + Position positionAtBreak = elementAtBreak.getPosition(); + if (!(positionAtBreak instanceof SpaceResolver.SpaceHandlingBreakPosition)) { + throw new UnsupportedOperationException( + "Don't know how to restart at position" + positionAtBreak); + } + /* Retrieve the original position wrapped into this space position */ + positionAtBreak = positionAtBreak.getPosition(); + LayoutManager restartAtLM = null; + List<KnuthElement> firstElements = Collections.EMPTY_LIST; + if (containsNonRestartableLM(positionAtBreak)) { + if (alg.getIPDdifference() > 0) { + EventBroadcaster eventBroadcaster = getCurrentChildLM().getFObj() + .getUserAgent().getEventBroadcaster(); + BlockLevelEventProducer eventProducer + = BlockLevelEventProducer.Provider.get(eventBroadcaster); + eventProducer.nonRestartableContentFlowingToNarrowerPage(this); + } + firstElements = new LinkedList<KnuthElement>(); + boolean boxFound = false; + Iterator<KnuthElement> iter = effectiveList.listIterator(positionIndex + 1); + Position position = null; + while (iter.hasNext() + && (position == null || containsNonRestartableLM(position))) { + positionIndex++; + KnuthElement element = iter.next(); + position = element.getPosition(); + if (element.isBox()) { + boxFound = true; + firstElements.add(element); + } else if (boxFound) { + firstElements.add(element); + } + } + if (position instanceof SpaceResolver.SpaceHandlingBreakPosition) { + /* Retrieve the original position wrapped into this space position */ + positionAtBreak = position.getPosition(); + } else { + positionAtBreak = null; } } + if (positionAtBreak != null && positionAtBreak.getIndex() == -1) { + /* + * This is an indication that we are between two blocks + * (possibly surrounded by another block), not inside a + * paragraph. + */ + Position position; + Iterator<KnuthElement> iter = effectiveList.listIterator(positionIndex + 1); + do { + KnuthElement nextElement = iter.next(); + position = nextElement.getPosition(); + } while (position == null + || position instanceof SpaceResolver.SpaceHandlingPosition + || position instanceof SpaceResolver.SpaceHandlingBreakPosition + && position.getPosition().getIndex() == -1); + LayoutManager surroundingLM = positionAtBreak.getLM(); + while (position.getLM() != surroundingLM) { + position = position.getPosition(); + } + restartAtLM = position.getPosition().getLM(); + } + + nextSequenceStartsOn = getNextBlockList(childLC, Constants.EN_COLUMN, + positionAtBreak, restartAtLM, firstElements); return nextSequenceStartsOn; } @@ -813,15 +829,14 @@ public abstract class AbstractBreaker { */ private int optimizeLineLength(KnuthSequence effectiveList, int startElementIndex, int endElementIndex) { - ListIterator effectiveListIterator; + ListIterator<KnuthElement> effectiveListIterator; // optimize line length int boxCount = 0; int accumulatedLineLength = 0; int greatestMinimumLength = 0; - effectiveListIterator = effectiveList - .listIterator(startElementIndex); + effectiveListIterator = effectiveList.listIterator(startElementIndex); while (effectiveListIterator.nextIndex() <= endElementIndex) { - KnuthElement tempEl = (KnuthElement) effectiveListIterator + KnuthElement tempEl = effectiveListIterator .next(); if (tempEl instanceof KnuthBlockBox) { KnuthBlockBox blockBox = (KnuthBlockBox) tempEl; @@ -867,23 +882,20 @@ public abstract class AbstractBreaker { log.debug("PLM> iOptPageNumber= " + iOptPageNumber); // - ListIterator sequenceIterator = blockList.listIterator(); - ListIterator breakIterator = alg.getPageBreaks().listIterator(); + ListIterator<KnuthElement> sequenceIterator = blockList.listIterator(); + ListIterator<PageBreakPosition> breakIterator = alg.getPageBreaks().listIterator(); KnuthElement thisElement = null; PageBreakPosition thisBreak; - int accumulatedS; // accumulated stretch or shrink int adjustedDiff; // difference already adjusted - int firstElementIndex; while (breakIterator.hasNext()) { - thisBreak = (PageBreakPosition) breakIterator.next(); + thisBreak = breakIterator.next(); if (log.isDebugEnabled()) { log.debug("| first page: break= " + thisBreak.getLeafPos() + " difference= " + thisBreak.difference + " ratio= " + thisBreak.bpdAdjust); } - accumulatedS = 0; adjustedDiff = 0; // glue and penalty items at the beginning of the page must @@ -893,7 +905,7 @@ public abstract class AbstractBreaker { // while loop must be a box KnuthElement firstElement; while ( sequenceIterator.hasNext() ) { - firstElement = (KnuthElement) sequenceIterator.next(); + firstElement = sequenceIterator.next(); if ( !firstElement.isBox() ) { log.debug("PLM> ignoring glue or penalty element " + "at the beginning of the sequence"); @@ -906,41 +918,39 @@ public abstract class AbstractBreaker { break; } } - firstElementIndex = sequenceIterator.previousIndex(); sequenceIterator.previous(); // scan the sub-sequence representing a page, // collecting information about potential adjustments MinOptMax lineNumberMaxAdjustment = MinOptMax.ZERO; MinOptMax spaceMaxAdjustment = MinOptMax.ZERO; - double spaceAdjustmentRatio = 0.0; - LinkedList blockSpacesList = new LinkedList(); - LinkedList unconfirmedList = new LinkedList(); - LinkedList adjustableLinesList = new LinkedList(); + LinkedList<KnuthGlue> blockSpacesList = new LinkedList<KnuthGlue>(); + LinkedList<KnuthGlue> unconfirmedList = new LinkedList<KnuthGlue>(); + LinkedList<KnuthGlue> adjustableLinesList = new LinkedList<KnuthGlue>(); boolean bBoxSeen = false; while (sequenceIterator.hasNext() - && sequenceIterator.nextIndex() <= thisBreak - .getLeafPos()) { - thisElement = (KnuthElement) sequenceIterator.next(); + && sequenceIterator.nextIndex() <= thisBreak.getLeafPos()) { + thisElement = sequenceIterator.next(); if (thisElement.isGlue()) { // glue elements are used to represent adjustable // lines // and adjustable spaces between blocks - Adjustment adjustment = ((KnuthGlue) thisElement).getAdjustmentClass(); + KnuthGlue thisGlue = (KnuthGlue) thisElement; + Adjustment adjustment = thisGlue.getAdjustmentClass(); if (adjustment.equals(Adjustment.SPACE_BEFORE_ADJUSTMENT) || adjustment.equals(Adjustment.SPACE_AFTER_ADJUSTMENT)) { // potential space adjustment // glue items before the first box or after the // last one // must be ignored - unconfirmedList.add(thisElement); + unconfirmedList.add(thisGlue); } else if (adjustment.equals(Adjustment.LINE_NUMBER_ADJUSTMENT)) { // potential line number adjustment lineNumberMaxAdjustment = lineNumberMaxAdjustment.plusMax(thisElement.getStretch()); lineNumberMaxAdjustment = lineNumberMaxAdjustment.minusMin(thisElement.getShrink()); - adjustableLinesList.add(thisElement); + adjustableLinesList.add(thisGlue); } else if (adjustment.equals(Adjustment.LINE_HEIGHT_ADJUSTMENT)) { // potential line height adjustment } @@ -954,8 +964,7 @@ public abstract class AbstractBreaker { // the last box // in this page; they must be added to // blockSpaceList - KnuthGlue blockSpace = (KnuthGlue) unconfirmedList - .removeFirst(); + KnuthGlue blockSpace = unconfirmedList.removeFirst(); spaceMaxAdjustment = spaceMaxAdjustment.plusMax(blockSpace.getStretch()); spaceMaxAdjustment @@ -983,9 +992,6 @@ public abstract class AbstractBreaker { || (thisBreak.difference < 0 && thisBreak.difference >= spaceMaxAdjustment .getMin())) { // modify only the spaces between blocks - spaceAdjustmentRatio = ((double) thisBreak.difference / (thisBreak.difference > 0 - ? spaceMaxAdjustment.getMax() - : spaceMaxAdjustment.getMin())); adjustedDiff += adjustBlockSpaces( blockSpacesList, thisBreak.difference, @@ -1032,16 +1038,16 @@ public abstract class AbstractBreaker { return effectiveList; } - private int adjustBlockSpaces(LinkedList spaceList, int difference, int total) { + private int adjustBlockSpaces(LinkedList<KnuthGlue> spaceList, int difference, int total) { if (log.isDebugEnabled()) { log.debug("AdjustBlockSpaces: difference " + difference + " / " + total + " on " + spaceList.size() + " spaces in block"); } - ListIterator spaceListIterator = spaceList.listIterator(); + ListIterator<KnuthGlue> spaceListIterator = spaceList.listIterator(); int adjustedDiff = 0; int partial = 0; while (spaceListIterator.hasNext()) { - KnuthGlue blockSpace = (KnuthGlue)spaceListIterator.next(); + KnuthGlue blockSpace = spaceListIterator.next(); partial += (difference > 0 ? blockSpace.getStretch() : blockSpace.getShrink()); if (log.isDebugEnabled()) { log.debug("available = " + partial + " / " + total); @@ -1057,7 +1063,7 @@ public abstract class AbstractBreaker { return adjustedDiff; } - private int adjustLineNumbers(LinkedList lineList, int difference, int total) { + private int adjustLineNumbers(LinkedList<KnuthGlue> lineList, int difference, int total) { if (log.isDebugEnabled()) { log.debug("AdjustLineNumbers: difference " + difference @@ -1068,11 +1074,11 @@ public abstract class AbstractBreaker { + " elements"); } - ListIterator lineListIterator = lineList.listIterator(); + ListIterator<KnuthGlue> lineListIterator = lineList.listIterator(); int adjustedDiff = 0; int partial = 0; while (lineListIterator.hasNext()) { - KnuthGlue line = (KnuthGlue)lineListIterator.next(); + KnuthGlue line = lineListIterator.next(); partial += (difference > 0 ? line.getStretch() : line.getShrink()); int newAdjust = ((BlockLevelLayoutManager) line.getLayoutManager()) .negotiateBPDAdjustment diff --git a/src/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java b/src/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java index f5c9d0779..fba571df3 100644 --- a/src/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/AbstractPageSequenceLayoutManager.java @@ -293,6 +293,7 @@ public abstract class AbstractPageSequenceLayoutManager extends AbstractLayoutMa + (isBlank ? "*" : "") + "]"); } + addIDToPage(pageSeq.getRoot().getId()); addIDToPage(pageSeq.getId()); return curPage; } diff --git a/src/java/org/apache/fop/layoutmgr/ElementListUtils.java b/src/java/org/apache/fop/layoutmgr/ElementListUtils.java index 6a843ac63..2bd6f429a 100644 --- a/src/java/org/apache/fop/layoutmgr/ElementListUtils.java +++ b/src/java/org/apache/fop/layoutmgr/ElementListUtils.java @@ -55,43 +55,7 @@ public final class ElementListUtils { * @return true if the constraint is bigger than the list contents */ public static boolean removeLegalBreaks(List elements, int constraint) { - int len = 0; - ListIterator iter = elements.listIterator(); - while (iter.hasNext()) { - ListElement el = (ListElement)iter.next(); - if (el.isPenalty()) { - KnuthPenalty penalty = (KnuthPenalty)el; - //Convert all penalties to break inhibitors - if (penalty.getPenalty() < KnuthPenalty.INFINITE) { - iter.set(new KnuthPenalty(penalty.getWidth(), KnuthPenalty.INFINITE, - penalty.isPenaltyFlagged(), penalty.getPosition(), - penalty.isAuxiliary())); - } - } else if (el.isGlue()) { - KnuthGlue glue = (KnuthGlue)el; - len += glue.getWidth(); - iter.previous(); - el = (ListElement)iter.previous(); - iter.next(); - if (el.isBox()) { - iter.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false, - null, false)); - } - iter.next(); - } else if (el instanceof BreakElement) { - BreakElement breakEl = (BreakElement)el; - if (breakEl.getPenaltyValue() < KnuthPenalty.INFINITE) { - breakEl.setPenaltyValue(KnuthPenalty.INFINITE); - } - } else { - KnuthElement kel = (KnuthElement)el; - len += kel.getWidth(); - } - if (len >= constraint) { - return false; - } - } - return true; + return removeLegalBreaks(elements, constraint, false); } /** @@ -103,27 +67,48 @@ public final class ElementListUtils { * @return true if the constraint is bigger than the list contents */ public static boolean removeLegalBreaksFromEnd(List elements, int constraint) { + return removeLegalBreaks(elements, constraint, true); + } + + private static boolean removeLegalBreaks(List elements, int constraint, boolean fromEnd) { + int len = 0; - ListIterator i = elements.listIterator(elements.size()); - while (i.hasPrevious()) { - ListElement el = (ListElement)i.previous(); + ListElement el; + + for (ListIterator iter = elements.listIterator(fromEnd ? elements.size() : 0); + (fromEnd ? iter.hasPrevious() : iter.hasNext());) { + + if (fromEnd) { + el = (ListElement) iter.previous(); + } else { + el = (ListElement) iter.next(); + } + if (el.isPenalty()) { KnuthPenalty penalty = (KnuthPenalty)el; - //Convert all penalties to break inhibitors + //Convert penalty to break inhibitor if (penalty.getPenalty() < KnuthPenalty.INFINITE) { - i.set(new KnuthPenalty(penalty.getWidth(), KnuthPenalty.INFINITE, + iter.set(new KnuthPenalty(penalty.getWidth(), KnuthPenalty.INFINITE, penalty.isPenaltyFlagged(), penalty.getPosition(), penalty.isAuxiliary())); } } else if (el.isGlue()) { KnuthGlue glue = (KnuthGlue)el; len += glue.getWidth(); - el = (ListElement)i.previous(); - i.next(); + //check if previous is a box + if (!fromEnd) { + iter.previous(); + } + el = (ListElement)iter.previous(); + iter.next(); if (el.isBox()) { - i.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false, + //add break inhibitor + iter.add(new KnuthPenalty(0, KnuthPenalty.INFINITE, false, null, false)); } + if (!fromEnd) { + iter.next(); + } } else if (el.isUnresolvedElement()) { if (el instanceof BreakElement) { BreakElement breakEl = (BreakElement)el; @@ -138,10 +123,12 @@ public final class ElementListUtils { KnuthElement kel = (KnuthElement)el; len += kel.getWidth(); } + if (len >= constraint) { return false; } } + return true; } @@ -191,8 +178,7 @@ public final class ElementListUtils { * @return true if the list ends with a forced break */ public static boolean endsWithForcedBreak(List elems) { - ListElement last = (ListElement) ListUtil.getLast(elems); - return last.isForcedBreak(); + return ((ListElement) ListUtil.getLast(elems)).isForcedBreak(); } /** diff --git a/src/java/org/apache/fop/layoutmgr/LayoutException.java b/src/java/org/apache/fop/layoutmgr/LayoutException.java index 2638d0210..f22d34bd8 100644 --- a/src/java/org/apache/fop/layoutmgr/LayoutException.java +++ b/src/java/org/apache/fop/layoutmgr/LayoutException.java @@ -97,7 +97,7 @@ public class LayoutException extends RuntimeException { } /** {@inheritDoc} */ - public Class getExceptionClass() { + public Class<LayoutException> getExceptionClass() { return LayoutException.class; } diff --git a/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java index 7fdacb6fa..d174ff0c1 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java @@ -839,7 +839,7 @@ public class TextLayoutManager extends LeafNodeLayoutManager { if (inWord) { processWord(alignment, sequence, prevAreaInfo, ch, false, false, prevLevel); } else if (inWhitespace) { - processWhitespace(alignment, sequence, true); + processWhitespace(alignment, sequence, !keepTogether); } else if (areaInfo != null) { processLeftoverAreaInfo(alignment, sequence, areaInfo, ch == CharUtilities.ZERO_WIDTH_SPACE); diff --git a/src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java b/src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java index f5a51b058..913a72b0d 100644 --- a/src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java +++ b/src/java/org/apache/fop/render/AbstractGraphics2DAdapter.java @@ -148,7 +148,10 @@ public abstract class AbstractGraphics2DAdapter implements Graphics2DAdapter { RenderingHints.VALUE_TEXT_ANTIALIAS_OFF); } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + * @deprecated + */ public void paintImage(Graphics2DImagePainter painter, RendererContext context, int x, int y, int width, int height) throws IOException { diff --git a/src/java/org/apache/fop/render/AbstractRenderer.java b/src/java/org/apache/fop/render/AbstractRenderer.java index 36b329cbf..5660b7ec4 100644 --- a/src/java/org/apache/fop/render/AbstractRenderer.java +++ b/src/java/org/apache/fop/render/AbstractRenderer.java @@ -208,15 +208,17 @@ public abstract class AbstractRenderer return sb.toString(); } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + * @deprecated + */ public void startPageSequence(LineArea seqTitle) { //do nothing } /** {@inheritDoc} */ public void startPageSequence(PageSequence pageSequence) { - //TODO Discuss removing old deprecated method startPageSequence(LineArea) - startPageSequence(pageSequence.getTitle()); + // do nothing } // normally this would be overriden to create a page in the diff --git a/src/java/org/apache/fop/render/XMLHandlerRegistry.java b/src/java/org/apache/fop/render/XMLHandlerRegistry.java index 81d9fcc93..cad09bff9 100644 --- a/src/java/org/apache/fop/render/XMLHandlerRegistry.java +++ b/src/java/org/apache/fop/render/XMLHandlerRegistry.java @@ -39,7 +39,8 @@ public class XMLHandlerRegistry { private static Log log = LogFactory.getLog(XMLHandlerRegistry.class); /** Map containing XML handlers for various document types */ - private Map handlers = new java.util.HashMap(); + private Map<String, List<XMLHandler>> handlers + = new java.util.HashMap<String, List<XMLHandler>>(); /** * Default constructor. @@ -98,11 +99,10 @@ public class XMLHandlerRegistry { * @param ns Namespace URI * @param handler XMLHandler to use */ - private void addXMLHandler(String ns, - XMLHandler handler) { - List lst = (List)handlers.get(ns); + private void addXMLHandler(String ns, XMLHandler handler) { + List<XMLHandler> lst = handlers.get(ns); if (lst == null) { - lst = new java.util.ArrayList(); + lst = new java.util.ArrayList<XMLHandler>(); handlers.put(ns, lst); } lst.add(handler); @@ -118,21 +118,21 @@ public class XMLHandlerRegistry { public XMLHandler getXMLHandler(Renderer renderer, String ns) { XMLHandler handler; - List lst = (List)handlers.get(ns); + List<XMLHandler> lst = handlers.get(ns); handler = getXMLHandler(renderer, lst); if (handler == null) { - lst = (List)handlers.get(XMLHandler.HANDLE_ALL); + lst = handlers.get(XMLHandler.HANDLE_ALL); handler = getXMLHandler(renderer, lst); } return handler; } - private XMLHandler getXMLHandler(Renderer renderer, List lst) { + private XMLHandler getXMLHandler(Renderer renderer, List<XMLHandler> lst) { XMLHandler handler; if (lst != null) { for (int i = 0, c = lst.size(); i < c; i++) { //TODO Maybe add priorities later - handler = (XMLHandler)lst.get(i); + handler = lst.get(i); if (handler.supportsRenderer(renderer)) { return handler; } @@ -147,7 +147,7 @@ public class XMLHandlerRegistry { */ private void discoverXMLHandlers() { // add mappings from available services - Iterator providers = Service.providers(XMLHandler.class); + Iterator<Object> providers = Service.providers(XMLHandler.class); if (providers != null) { while (providers.hasNext()) { XMLHandler handler = (XMLHandler)providers.next(); diff --git a/src/java/org/apache/fop/render/afp/extensions/AFPElementMapping.java b/src/java/org/apache/fop/render/afp/extensions/AFPElementMapping.java index 580e9f800..4e4100bc7 100644 --- a/src/java/org/apache/fop/render/afp/extensions/AFPElementMapping.java +++ b/src/java/org/apache/fop/render/afp/extensions/AFPElementMapping.java @@ -73,7 +73,7 @@ public class AFPElementMapping extends ElementMapping { protected void initialize() { if (foObjs == null) { - super.foObjs = new java.util.HashMap(); + super.foObjs = new java.util.HashMap<String, Maker>(); foObjs.put( TAG_LOGICAL_ELEMENT, new AFPTagLogicalElementMaker()); diff --git a/src/java/org/apache/fop/render/pcl/extensions/PCLElementMapping.java b/src/java/org/apache/fop/render/pcl/extensions/PCLElementMapping.java index 700a95c65..08f3a5f44 100644 --- a/src/java/org/apache/fop/render/pcl/extensions/PCLElementMapping.java +++ b/src/java/org/apache/fop/render/pcl/extensions/PCLElementMapping.java @@ -57,7 +57,7 @@ public class PCLElementMapping extends ElementMapping { protected void initialize() { if (foObjs == null) { - foObjs = new HashMap(); + foObjs = new HashMap<String, Maker>(); //No extension elements, yet, only attributes } diff --git a/src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java b/src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java index 770798967..c1d959dd1 100644 --- a/src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java +++ b/src/java/org/apache/fop/render/pdf/PDFDocumentHandler.java @@ -93,7 +93,7 @@ public class PDFDocumentHandler extends AbstractBinaryWritingIFDocumentHandler { /** Used for bookmarks/outlines. */ protected Map<Integer, PageReference> pageReferences - = new java.util.HashMap<Integer, PageReference>(); + = new java.util.HashMap<Integer, PageReference>(); private final PDFDocumentNavigationHandler documentNavigationHandler = new PDFDocumentNavigationHandler(this); diff --git a/src/java/org/apache/fop/render/pdf/extensions/PDFElementMapping.java b/src/java/org/apache/fop/render/pdf/extensions/PDFElementMapping.java index 55795f4fa..c70ed3635 100644 --- a/src/java/org/apache/fop/render/pdf/extensions/PDFElementMapping.java +++ b/src/java/org/apache/fop/render/pdf/extensions/PDFElementMapping.java @@ -38,7 +38,7 @@ public class PDFElementMapping extends ElementMapping { /** {@inheritDoc} */ protected void initialize() { if (foObjs == null) { - foObjs = new java.util.HashMap(); + foObjs = new java.util.HashMap<String, Maker>(); foObjs.put(PDFEmbeddedFileElement.ELEMENT, new PDFEmbeddedFileMaker()); } } diff --git a/src/java/org/apache/fop/render/ps/extensions/PSExtensionElementMapping.java b/src/java/org/apache/fop/render/ps/extensions/PSExtensionElementMapping.java index 2044385a8..54806d047 100644 --- a/src/java/org/apache/fop/render/ps/extensions/PSExtensionElementMapping.java +++ b/src/java/org/apache/fop/render/ps/extensions/PSExtensionElementMapping.java @@ -38,7 +38,7 @@ public class PSExtensionElementMapping extends ElementMapping { /** {@inheritDoc} */ protected void initialize() { if (foObjs == null) { - foObjs = new java.util.HashMap(); + foObjs = new java.util.HashMap<String, Maker>(); foObjs.put(PSSetupCodeElement.ELEMENT, new PSSetupCodeMaker()); foObjs.put(PSPageSetupCodeElement.ELEMENT, new PSPageSetupCodeMaker()); foObjs.put(PSSetPageDeviceElement.ELEMENT, new PSSetPageDeviceMaker()); diff --git a/src/java/org/apache/fop/text/linebreak/LineBreakStatus.java b/src/java/org/apache/fop/text/linebreak/LineBreakStatus.java index df5027373..157a480cc 100644 --- a/src/java/org/apache/fop/text/linebreak/LineBreakStatus.java +++ b/src/java/org/apache/fop/text/linebreak/LineBreakStatus.java @@ -87,6 +87,7 @@ public class LineBreakStatus { /* Initial conversions */ switch (currentClass) { + case 0: // Unassigned codepoint: same treatment as AI case LineBreakUtils.LINE_BREAK_PROPERTY_AI: case LineBreakUtils.LINE_BREAK_PROPERTY_SG: case LineBreakUtils.LINE_BREAK_PROPERTY_XX: diff --git a/src/java/org/apache/fop/util/ColorUtil.java b/src/java/org/apache/fop/util/ColorUtil.java index 21277d60a..674079369 100644 --- a/src/java/org/apache/fop/util/ColorUtil.java +++ b/src/java/org/apache/fop/util/ColorUtil.java @@ -27,6 +27,7 @@ import java.util.Map; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.apache.xmlgraphics.java2d.color.ColorSpaces; import org.apache.xmlgraphics.java2d.color.DeviceCMYKColorSpace; import org.apache.fop.apps.FOUserAgent; @@ -50,7 +51,7 @@ public final class ColorUtil { * This map is used to predefine given colors, as well as speeding up * parsing of already parsed colors. */ - private static Map colorMap = null; + private static Map<String, Color> colorMap = null; /** Logger instance */ protected static final Log log = LogFactory.getLog(ColorUtil.class); @@ -328,7 +329,7 @@ public final class ColorUtil { String iccProfileSrc = null; if (isPseudoProfile(iccProfileName)) { if (CMYK_PSEUDO_PROFILE.equalsIgnoreCase(iccProfileName)) { - colorSpace = DeviceCMYKColorSpace.getInstance(); + colorSpace = ColorSpaces.getDeviceCMYKColorSpace(); } else { assert false : "Incomplete implementation"; } @@ -453,7 +454,7 @@ public final class ColorUtil { + "Arguments to cmyk() must be in the range [0%-100%] or [0.0-1.0]"); } float[] cmyk = new float[] {cyan, magenta, yellow, black}; - DeviceCMYKColorSpace cmykCs = DeviceCMYKColorSpace.getInstance(); + DeviceCMYKColorSpace cmykCs = ColorSpaces.getDeviceCMYKColorSpace(); float[] rgb = cmykCs.toRGB(cmyk); parsedColor = ColorExt.createFromFoRgbIcc(rgb[0], rgb[1], rgb[2], CMYK_PSEUDO_PROFILE, null, cmykCs, cmyk); @@ -521,7 +522,7 @@ public final class ColorUtil { * Initializes the colorMap with some predefined values. */ private static void initializeColorMap() { // CSOK: MethodLength - colorMap = Collections.synchronizedMap(new java.util.HashMap()); + colorMap = Collections.synchronizedMap(new java.util.HashMap<String, Color>()); colorMap.put("aliceblue", new Color(240, 248, 255)); colorMap.put("antiquewhite", new Color(250, 235, 215)); @@ -710,7 +711,7 @@ public final class ColorUtil { */ public static Color toCMYKGrayColor(float black) { float[] cmyk = new float[] {0f, 0f, 0f, 1.0f - black}; - DeviceCMYKColorSpace cmykCs = DeviceCMYKColorSpace.getInstance(); + DeviceCMYKColorSpace cmykCs = ColorSpaces.getDeviceCMYKColorSpace(); float[] rgb = cmykCs.toRGB(cmyk); return ColorExt.createFromFoRgbIcc(rgb[0], rgb[1], rgb[2], CMYK_PSEUDO_PROFILE, null, cmykCs, cmyk); diff --git a/src/java/org/apache/fop/util/text/AdvancedMessageFormat.java b/src/java/org/apache/fop/util/text/AdvancedMessageFormat.java index 002b3f95c..41b70046c 100644 --- a/src/java/org/apache/fop/util/text/AdvancedMessageFormat.java +++ b/src/java/org/apache/fop/util/text/AdvancedMessageFormat.java @@ -46,24 +46,27 @@ public class AdvancedMessageFormat { /** Regex that matches "," but not "\," (escaped comma) */ static final Pattern COMMA_SEPARATOR_REGEX = Pattern.compile("(?<!\\\\),"); - private static final Map PART_FACTORIES = new java.util.HashMap(); - private static final List OBJECT_FORMATTERS = new java.util.ArrayList(); - private static final Map FUNCTIONS = new java.util.HashMap(); + private static final Map<String, PartFactory> PART_FACTORIES + = new java.util.HashMap<String, PartFactory>(); + private static final List<ObjectFormatter> OBJECT_FORMATTERS + = new java.util.ArrayList<ObjectFormatter>(); + private static final Map<Object, Function> FUNCTIONS + = new java.util.HashMap<Object, Function>(); private CompositePart rootPart; static { - Iterator iter; - iter = Service.providers(PartFactory.class, true); + Iterator<Object> iter; + iter = Service.providers(PartFactory.class); while (iter.hasNext()) { PartFactory factory = (PartFactory)iter.next(); PART_FACTORIES.put(factory.getFormat(), factory); } - iter = Service.providers(ObjectFormatter.class, true); + iter = Service.providers(ObjectFormatter.class); while (iter.hasNext()) { OBJECT_FORMATTERS.add((ObjectFormatter)iter.next()); } - iter = Service.providers(Function.class, true); + iter = Service.providers(Function.class); while (iter.hasNext()) { Function function = (Function)iter.next(); FUNCTIONS.put(function.getName(), function); @@ -189,7 +192,7 @@ public class AdvancedMessageFormat { * @param params a Map of named parameters (Contents: <String, Object>) * @return the formatted message */ - public String format(Map params) { + public String format(Map<String, Object> params) { StringBuffer sb = new StringBuffer(); format(params, sb); return sb.toString(); @@ -200,7 +203,7 @@ public class AdvancedMessageFormat { * @param params a Map of named parameters (Contents: <String, Object>) * @param target the target StringBuffer to write the formatted message to */ - public void format(Map params, StringBuffer target) { + public void format(Map<String, Object> params, StringBuffer target) { rootPart.write(target, params); } @@ -215,14 +218,14 @@ public class AdvancedMessageFormat { * @param sb the target string buffer * @param params the parameters to work with */ - void write(StringBuffer sb, Map params); + void write(StringBuffer sb, Map<String, Object> params); /** * Indicates whether there is any content that is generated by this message part. * @param params the parameters to work with * @return true if the part has content */ - boolean isGenerated(Map params); + boolean isGenerated(Map<String, Object> params); } /** @@ -277,7 +280,7 @@ public class AdvancedMessageFormat { * @param params the message parameters * @return the function result */ - Object evaluate(Map params); + Object evaluate(Map<String, Object> params); /** * Returns the name of the function. @@ -294,11 +297,11 @@ public class AdvancedMessageFormat { this.text = text; } - public void write(StringBuffer sb, Map params) { + public void write(StringBuffer sb, Map<String, Object> params) { sb.append(text); } - public boolean isGenerated(Map params) { + public boolean isGenerated(Map<String, Object> params) { return true; } @@ -316,7 +319,7 @@ public class AdvancedMessageFormat { this.fieldName = fieldName; } - public void write(StringBuffer sb, Map params) { + public void write(StringBuffer sb, Map<String, Object> params) { if (!params.containsKey(fieldName)) { throw new IllegalArgumentException( "Message pattern contains unsupported field name: " + fieldName); @@ -325,7 +328,7 @@ public class AdvancedMessageFormat { formatObject(obj, sb); } - public boolean isGenerated(Map params) { + public boolean isGenerated(Map<String, Object> params) { Object obj = params.get(fieldName); return obj != null; } @@ -349,9 +352,9 @@ public class AdvancedMessageFormat { target.append(obj); } else { boolean handled = false; - Iterator iter = OBJECT_FORMATTERS.iterator(); + Iterator<ObjectFormatter> iter = OBJECT_FORMATTERS.iterator(); while (iter.hasNext()) { - ObjectFormatter formatter = (ObjectFormatter)iter.next(); + ObjectFormatter formatter = iter.next(); if (formatter.supportsObject(obj)) { formatter.format(target, obj); handled = true; @@ -375,12 +378,12 @@ public class AdvancedMessageFormat { } } - public void write(StringBuffer sb, Map params) { + public void write(StringBuffer sb, Map<String, Object> params) { Object obj = this.function.evaluate(params); formatObject(obj, sb); } - public boolean isGenerated(Map params) { + public boolean isGenerated(Map<String, Object> params) { Object obj = this.function.evaluate(params); return obj != null; } @@ -393,7 +396,7 @@ public class AdvancedMessageFormat { private static class CompositePart implements Part { - protected List parts = new java.util.ArrayList(); + protected List<Part> parts = new java.util.ArrayList<Part>(); private boolean conditional; private boolean hasSections = false; @@ -401,7 +404,7 @@ public class AdvancedMessageFormat { this.conditional = conditional; } - private CompositePart(List parts) { + private CompositePart(List<Part> parts) { this.parts.addAll(parts); this.conditional = true; } @@ -411,7 +414,7 @@ public class AdvancedMessageFormat { throw new NullPointerException("part must not be null"); } if (hasSections) { - CompositePart composite = (CompositePart)this.parts.get(this.parts.size() - 1); + CompositePart composite = (CompositePart) this.parts.get(this.parts.size() - 1); composite.addChild(part); } else { this.parts.add(part); @@ -420,20 +423,20 @@ public class AdvancedMessageFormat { public void newSection() { if (!hasSections) { - List p = this.parts; + List<Part> p = this.parts; //Dropping into a different mode... - this.parts = new java.util.ArrayList(); + this.parts = new java.util.ArrayList<Part>(); this.parts.add(new CompositePart(p)); hasSections = true; } this.parts.add(new CompositePart(true)); } - public void write(StringBuffer sb, Map params) { + public void write(StringBuffer sb, Map<String, Object> params) { if (hasSections) { - Iterator iter = this.parts.iterator(); + Iterator<Part> iter = this.parts.iterator(); while (iter.hasNext()) { - CompositePart part = (CompositePart)iter.next(); + Part part = iter.next(); if (part.isGenerated(params)) { part.write(sb, params); break; @@ -441,20 +444,20 @@ public class AdvancedMessageFormat { } } else { if (isGenerated(params)) { - Iterator iter = this.parts.iterator(); + Iterator<Part> iter = this.parts.iterator(); while (iter.hasNext()) { - Part part = (Part)iter.next(); + Part part = iter.next(); part.write(sb, params); } } } } - public boolean isGenerated(Map params) { + public boolean isGenerated(Map<String, Object> params) { if (hasSections) { - Iterator iter = this.parts.iterator(); + Iterator<Part> iter = this.parts.iterator(); while (iter.hasNext()) { - Part part = (Part)iter.next(); + Part part = iter.next(); if (part.isGenerated(params)) { return true; } @@ -462,9 +465,9 @@ public class AdvancedMessageFormat { return false; } else { if (conditional) { - Iterator iter = this.parts.iterator(); + Iterator<Part> iter = this.parts.iterator(); while (iter.hasNext()) { - Part part = (Part)iter.next(); + Part part = iter.next(); if (!part.isGenerated(params)) { return false; } diff --git a/status.xml b/status.xml index 2f2608cfd..c80ba0668 100644 --- a/status.xml +++ b/status.xml @@ -49,6 +49,7 @@ <context id="API" title="Changes to the End-User API"/> <context id="Extensions" title="Changes to the Bundled Extensions"/> <context id="Images" title="Changes to the Image Support"/> + <context id="Config" title="Changes to the User Configuration"/> </contexts> <changes> @@ -58,6 +59,18 @@ documents. Example: the fix of marks layering will be such a case when it's done. --> <release version="FOP Trunk" date="TBD"> + <action context="Config" dev="SP" type="fix"> + Bugfix: relative URIs in the configuration file (base, font-base, hyphenation-base) are evaluated relative to the base URI of the configuration file. + </action> + <action context="Layout" dev="AD" type="fix" fixes-bug="49848"> + Bugfix: correct behavior of keep-together.within-line in case there are nested inlines + </action> + <action context="Code" dev="AD" type="fix" fixes-bug="50471"> + Bugfix: avoid ArrayIndexOutOfBoundsException for codepoints without a linebreak class + </action> + <action context="Layout" dev="AD" type="fix" fixes-bug="48380"> + Bugfix: avoid ClassCastException when using fox:widow-content-limit + </action> <action context="Layout" dev="VH" type="fix" fixes-bug="50089"> Bugfix: content after forced break in block-container is not rendered. </action> diff --git a/test/java/org/apache/fop/fotreetest/ext/TestElementMapping.java b/test/java/org/apache/fop/fotreetest/ext/TestElementMapping.java index 1d9127d0c..eee0efac4 100644 --- a/test/java/org/apache/fop/fotreetest/ext/TestElementMapping.java +++ b/test/java/org/apache/fop/fotreetest/ext/TestElementMapping.java @@ -40,7 +40,7 @@ public class TestElementMapping extends ElementMapping { /** @see org.apache.fop.fo.ElementMapping#initialize() */ protected void initialize() { if (foObjs == null) { - foObjs = new java.util.HashMap(); + foObjs = new java.util.HashMap<String, Maker>(); foObjs.put("assert", new AssertMaker()); } } diff --git a/test/java/org/apache/fop/text/linebreak/LineBreakStatusTest.java b/test/java/org/apache/fop/text/linebreak/LineBreakStatusTest.java index 8d2936127..e9b2ff90d 100644 --- a/test/java/org/apache/fop/text/linebreak/LineBreakStatusTest.java +++ b/test/java/org/apache/fop/text/linebreak/LineBreakStatusTest.java @@ -320,6 +320,12 @@ public class LineBreakStatusTest extends TestCase { "^^^^^^" + "^" + "_^^^^" )); + // Unassigned codepoint: should yield same result as AL + assertTrue(testBreak( + "No" + "\u1F7E" + "break", + "^^" + "^" + "^^^^^" + )); + } /** diff --git a/test/java/org/apache/fop/text/linebreak/LineBreakUtilsTest.java b/test/java/org/apache/fop/text/linebreak/LineBreakUtilsTest.java index 31ad950c7..bb6d209c2 100644 --- a/test/java/org/apache/fop/text/linebreak/LineBreakUtilsTest.java +++ b/test/java/org/apache/fop/text/linebreak/LineBreakUtilsTest.java @@ -41,6 +41,7 @@ public class LineBreakUtilsTest extends TestCase { assertEquals(LineBreakUtils.getLineBreakProperty('\n'), LineBreakUtils.LINE_BREAK_PROPERTY_LF); assertEquals(LineBreakUtils.getLineBreakProperty('\r'), LineBreakUtils.LINE_BREAK_PROPERTY_CR); assertEquals(LineBreakUtils.getLineBreakProperty('('), LineBreakUtils.LINE_BREAK_PROPERTY_OP); + assertEquals(LineBreakUtils.getLineBreakProperty('\u1F7E'), 0); } public void testLineBreakPair() { diff --git a/test/java/org/apache/fop/traits/BorderPropsTestCase.java b/test/java/org/apache/fop/traits/BorderPropsTestCase.java index be7714ba2..e142a4358 100644 --- a/test/java/org/apache/fop/traits/BorderPropsTestCase.java +++ b/test/java/org/apache/fop/traits/BorderPropsTestCase.java @@ -23,6 +23,7 @@ import java.awt.Color; import junit.framework.TestCase; +import org.apache.xmlgraphics.java2d.color.ColorSpaces; import org.apache.xmlgraphics.java2d.color.DeviceCMYKColorSpace; import org.apache.fop.fo.Constants; @@ -50,7 +51,7 @@ public class BorderPropsTestCase extends TestCase { assertEquals(b1, b2); float[] cmyk = new float[] {1.0f, 1.0f, 0.5f, 1.0f}; - DeviceCMYKColorSpace cmykCs = DeviceCMYKColorSpace.getInstance(); + DeviceCMYKColorSpace cmykCs = ColorSpaces.getDeviceCMYKColorSpace(); float[] rgb = cmykCs.toRGB(cmyk); col = ColorExt.createFromFoRgbIcc(rgb[0], rgb[1], rgb[2], "#CMYK", null, cmykCs, cmyk); diff --git a/test/java/org/apache/fop/util/ColorUtilTestCase.java b/test/java/org/apache/fop/util/ColorUtilTestCase.java index aefd2a76a..c2fb0fbc9 100644 --- a/test/java/org/apache/fop/util/ColorUtilTestCase.java +++ b/test/java/org/apache/fop/util/ColorUtilTestCase.java @@ -24,7 +24,7 @@ import java.awt.color.ColorSpace; import junit.framework.TestCase; -import org.apache.xmlgraphics.java2d.color.DeviceCMYKColorSpace; +import org.apache.xmlgraphics.java2d.color.ColorSpaces; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.FopFactory; @@ -156,7 +156,7 @@ public class ColorUtilTestCase extends TestCase { assertEquals(255, colActual.getRed()); assertEquals(255, colActual.getGreen()); assertEquals(0, colActual.getBlue()); - assertEquals(DeviceCMYKColorSpace.getInstance(), colActual.getColorSpace()); + assertEquals(ColorSpaces.getDeviceCMYKColorSpace(), colActual.getColorSpace()); float[] comps = colActual.getColorComponents(null); assertEquals(4, comps.length); assertEquals(0f, comps[0], 0); @@ -171,7 +171,7 @@ public class ColorUtilTestCase extends TestCase { assertEquals(248, colActual.getRed()); assertEquals(199, colActual.getGreen()); assertEquals(172, colActual.getBlue()); - assertEquals(DeviceCMYKColorSpace.getInstance(), colActual.getColorSpace()); + assertEquals(ColorSpaces.getDeviceCMYKColorSpace(), colActual.getColorSpace()); comps = colActual.getColorComponents(null); assertEquals(0.0274f, comps[0], 0.001); assertEquals(0.2196f, comps[1], 0.001); @@ -185,7 +185,7 @@ public class ColorUtilTestCase extends TestCase { assertEquals(255, colActual.getRed()); assertEquals(255, colActual.getGreen()); assertEquals(0, colActual.getBlue()); - assertEquals(DeviceCMYKColorSpace.getInstance(), colActual.getColorSpace()); + assertEquals(ColorSpaces.getDeviceCMYKColorSpace(), colActual.getColorSpace()); comps = colActual.getColorComponents(null); assertEquals(4, comps.length); assertEquals(0f, comps[0], 0); @@ -200,7 +200,7 @@ public class ColorUtilTestCase extends TestCase { assertEquals(127, colActual.getRed()); assertEquals(127, colActual.getGreen()); assertEquals(127, colActual.getBlue()); - assertEquals(DeviceCMYKColorSpace.getInstance(), colActual.getColorSpace()); + assertEquals(ColorSpaces.getDeviceCMYKColorSpace(), colActual.getColorSpace()); comps = colActual.getColorComponents(null); assertEquals(4, comps.length); assertEquals(0f, comps[0], 0); diff --git a/test/layoutengine/standard-testcases/inline_hyphenation_border.xml b/test/layoutengine/hyphenation-testcases/inline_hyphenation_border.xml index f3c133e6e..f3c133e6e 100644 --- a/test/layoutengine/standard-testcases/inline_hyphenation_border.xml +++ b/test/layoutengine/hyphenation-testcases/inline_hyphenation_border.xml diff --git a/test/layoutengine/standard-testcases/fox_widow-content-limit_bug48380.xml b/test/layoutengine/standard-testcases/fox_widow-content-limit_bug48380.xml new file mode 100644 index 000000000..83d5bd499 --- /dev/null +++ b/test/layoutengine/standard-testcases/fox_widow-content-limit_bug48380.xml @@ -0,0 +1,61 @@ +<?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$ --> +<testcase> + <info> + <p> + Check for bug 48380: ClassCastException when using fox:widow-content-limit. + </p> + </info> + <fo> + <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:fox="http://xmlgraphics.apache.org/fop/extensions"> + <fo:layout-master-set> + <fo:simple-page-master master-name="normal" page-width="210mm" page-height="297mm"> + <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:table fox:orphan-content-limit="4em" fox:widow-content-limit="4em" table-layout="fixed" width="100%"> + <fo:table-body> + <fo:table-row> + <fo:table-cell> + <fo:block> + <fo:list-block space-after="6pt"> + <fo:list-item> + <fo:list-item-label> + <fo:block>.</fo:block> + </fo:list-item-label> + <fo:list-item-body> + <fo:block start-indent="1cm">test</fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + </fo:block> + </fo:table-cell> + </fo:table-row> + </fo:table-body> + </fo:table> + </fo:flow> + </fo:page-sequence> + </fo:root> + </fo> + <checks> + <!-- Run only basic checks; should not throw a ClassCastException --> + </checks> +</testcase>
\ No newline at end of file diff --git a/test/layoutengine/standard-testcases/inline_keep-together.xml b/test/layoutengine/standard-testcases/inline_keep-together.xml index 6ec4ce603..0c6ae682a 100644 --- a/test/layoutengine/standard-testcases/inline_keep-together.xml +++ b/test/layoutengine/standard-testcases/inline_keep-together.xml @@ -38,6 +38,22 @@ <fo:block keep-together.within-line="always">This is Blah blah blah blah!</fo:block> <fo:block>This is <fo:inline keep-together.within-line="always">Blah blah blah blah!</fo:inline></fo:block> <fo:block>This is <fo:wrapper keep-together.within-line="always">Blah blah blah blah!</fo:wrapper></fo:block> + <fo:block> + <fo:inline keep-together.within-line="always"> + This<fo:inline> entire</fo:inline> sentence + <fo:inline>should be </fo:inline>kept + <fo:inline>together + <fo:inline>on + <fo:inline>one + <fo:inline>very, + <fo:inline>very,</fo:inline> + <fo:inline>very,</fo:inline> + <fo:inline>very,</fo:inline> + <fo:inline>long</fo:inline> + </fo:inline></fo:inline></fo:inline>line + </fo:inline> + </fo:inline> + </fo:block> </fo:block-container> </fo:flow> </fo:page-sequence> @@ -54,6 +70,9 @@ <!-- The layout engine should warn the user about the overflow in this case. --> <eval expected="This is" xpath="//flow/block[1]/block[1]/block[3]/lineArea[1]"/> <eval expected="Blah blah blah blah!" xpath="//flow/block[1]/block[1]/block[3]/lineArea[2]"/> + + <!-- check effect of nested inlines (see Bugzilla #49848) --> + <eval expected="1" xpath="count(//flow/block[1]/block[1]/block[4]/lineArea)" /> </checks> </testcase> diff --git a/test/layoutengine/standard-testcases/page-number-citation-last_complex.xml b/test/layoutengine/standard-testcases/page-number-citation-last_complex.xml index 38728606c..a3f9256dc 100644 --- a/test/layoutengine/standard-testcases/page-number-citation-last_complex.xml +++ b/test/layoutengine/standard-testcases/page-number-citation-last_complex.xml @@ -28,7 +28,7 @@ </p> </info> <fo> - <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg"> + <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg" id="root"> <fo:layout-master-set> <fo:simple-page-master master-name="normal" page-width="5in" page-height="5in" margin="20pt"> @@ -79,6 +79,7 @@ </fo:page-sequence> <fo:page-sequence master-reference="normal"> <fo:flow flow-name="xsl-region-body" font-size="8pt"> + <fo:block>root= <fo:page-number-citation-last ref-id="root"/></fo:block> <fo:block>page-sequence= <fo:page-number-citation-last ref-id="page-sequence1"/></fo:block> <fo:block>block= <fo:page-number-citation-last ref-id="block1"/></fo:block> <fo:block>list= <fo:page-number-citation-last ref-id="list1"/></fo:block> @@ -97,18 +98,19 @@ </fo:root> </fo> <checks> - <true fail-msg="no ID for page-sequence" xpath="'page-sequence= 1' = //pageViewport[@nr=2]/page/regionViewport/regionBody/mainReference/span/flow/block[1]"/> - <true fail-msg="no ID for block" xpath="'block= 1' = //pageViewport[@nr=2]/page/regionViewport/regionBody/mainReference/span/flow/block[2]"/> - <true fail-msg="no ID for list-block" xpath="'list= 1' = //pageViewport[@nr=2]/page/regionViewport/regionBody/mainReference/span/flow/block[3]"/> - <true fail-msg="no ID for list-item" xpath="'item= 1' = //pageViewport[@nr=2]/page/regionViewport/regionBody/mainReference/span/flow/block[4]"/> - <true fail-msg="no ID for list-item-label" xpath="'item-label= 1' = //pageViewport[@nr=2]/page/regionViewport/regionBody/mainReference/span/flow/block[5]"/> - <true fail-msg="no ID for list-item-body" xpath="'item-body= 1' = //pageViewport[@nr=2]/page/regionViewport/regionBody/mainReference/span/flow/block[6]"/> - <true fail-msg="no ID for table" xpath="'table= 1' = //pageViewport[@nr=2]/page/regionViewport/regionBody/mainReference/span/flow/block[7]"/> - <!-- <true fail-msg="no ID for table-header" xpath="'table-header= 1' = //pageViewport[@nr=2]/page/regionViewport/regionBody/mainReference/span/flow/block[8]"/> - <true fail-msg="no ID for table-footer" xpath="'table-footer= 1' = //pageViewport[@nr=2]/page/regionViewport/regionBody/mainReference/span/flow/block[9]"/> - <true fail-msg="no ID for table-body" xpath="'table-body= 1' = //pageViewport[@nr=2]/page/regionViewport/regionBody/mainReference/span/flow/block[10]"/> - <true fail-msg="no ID for table-row" xpath="'table-row= 1' = //pageViewport[@nr=2]/page/regionViewport/regionBody/mainReference/span/flow/block[11]"/>--> - <true fail-msg="no ID for table-cell" xpath="'table-cell= 1' = //pageViewport[@nr=2]/page/regionViewport/regionBody/mainReference/span/flow/block[12]"/> - <true fail-msg="no ID for block-container" xpath="'block-container= 1' = //pageViewport[@nr=2]/page/regionViewport/regionBody/mainReference/span/flow/block[13]"/> + <true fail-msg="no ID for root" xpath="'root= 2' = //pageViewport[@nr=2]/page/regionViewport/regionBody/mainReference/span/flow/block[1]"/> + <true fail-msg="no ID for page-sequence" xpath="'page-sequence= 1' = //pageViewport[@nr=2]/page/regionViewport/regionBody/mainReference/span/flow/block[2]"/> + <true fail-msg="no ID for block" xpath="'block= 1' = //pageViewport[@nr=2]/page/regionViewport/regionBody/mainReference/span/flow/block[3]"/> + <true fail-msg="no ID for list-block" xpath="'list= 1' = //pageViewport[@nr=2]/page/regionViewport/regionBody/mainReference/span/flow/block[4]"/> + <true fail-msg="no ID for list-item" xpath="'item= 1' = //pageViewport[@nr=2]/page/regionViewport/regionBody/mainReference/span/flow/block[5]"/> + <true fail-msg="no ID for list-item-label" xpath="'item-label= 1' = //pageViewport[@nr=2]/page/regionViewport/regionBody/mainReference/span/flow/block[6]"/> + <true fail-msg="no ID for list-item-body" xpath="'item-body= 1' = //pageViewport[@nr=2]/page/regionViewport/regionBody/mainReference/span/flow/block[7]"/> + <true fail-msg="no ID for table" xpath="'table= 1' = //pageViewport[@nr=2]/page/regionViewport/regionBody/mainReference/span/flow/block[8]"/> + <!-- <true fail-msg="no ID for table-header" xpath="'table-header= 1' = //pageViewport[@nr=2]/page/regionViewport/regionBody/mainReference/span/flow/block[9]"/> + <true fail-msg="no ID for table-footer" xpath="'table-footer= 1' = //pageViewport[@nr=2]/page/regionViewport/regionBody/mainReference/span/flow/block[10]"/> + <true fail-msg="no ID for table-body" xpath="'table-body= 1' = //pageViewport[@nr=2]/page/regionViewport/regionBody/mainReference/span/flow/block[11]"/> + <true fail-msg="no ID for table-row" xpath="'table-row= 1' = //pageViewport[@nr=2]/page/regionViewport/regionBody/mainReference/span/flow/block[12]"/>--> + <true fail-msg="no ID for table-cell" xpath="'table-cell= 1' = //pageViewport[@nr=2]/page/regionViewport/regionBody/mainReference/span/flow/block[13]"/> + <true fail-msg="no ID for block-container" xpath="'block-container= 1' = //pageViewport[@nr=2]/page/regionViewport/regionBody/mainReference/span/flow/block[14]"/> </checks> </testcase> diff --git a/test/test-no-xml-metrics.xconf b/test/test-no-xml-metrics.xconf index beb24c0ef..6005eac94 100644 --- a/test/test-no-xml-metrics.xconf +++ b/test/test-no-xml-metrics.xconf @@ -7,7 +7,7 @@ <base>./</base> <!-- Font Base URL for resolving relative font URLs --> - <font-base>./test/resources/fonts</font-base> + <font-base>./resources/fonts</font-base> <renderers> <renderer mime="application/pdf"> |