diff options
author | Jeremias Maerki <jeremias@apache.org> | 2008-08-12 12:36:18 +0000 |
---|---|---|
committer | Jeremias Maerki <jeremias@apache.org> | 2008-08-12 12:36:18 +0000 |
commit | 3a39c6dca832b0c3626af4a7d39eb80dcb07aabf (patch) | |
tree | 49a4c3bd87d1093230e58ed05606e0d131f3eb27 | |
parent | 95b2347224c4f3b7c3fcff3b2509a356b2b9869b (diff) | |
parent | ff243bf1dd6062bbe624391a9ef79fc26018a23f (diff) | |
download | xmlgraphics-fop-3a39c6dca832b0c3626af4a7d39eb80dcb07aabf.tar.gz xmlgraphics-fop-3a39c6dca832b0c3626af4a7d39eb80dcb07aabf.zip |
Merge from Trunk revisions 680381-685126.
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AreaTreeNewDesign@685132 13f79535-47bb-0310-9956-ffa450edef68
70 files changed, 1893 insertions, 887 deletions
@@ -90,11 +90,11 @@ http://xmlgraphics.apache.org/fop/stable/running.html RELEASE NOTES ============================================================================== -Version 0.95beta -================ +Version 0.95 +============ -This is a pre-version of the third production grade release of the new FOP -codebase. It contains many bug fixes and new features. See below for details. +This is a production grade release of Apache FOP. +It contains many bug fixes and new features. See below for details. Compliance ---------- @@ -128,6 +128,10 @@ http://xmlgraphics.apache.org/fop/0.95/changes_0.95.html. The long list of changes in this and earlier releases is available at http://xmlgraphics.apache.org/fop/changes.html. +Changes since Version 0.95beta +------------------------------ +Please refer to the list of changes on the web: +http://xmlgraphics.apache.org/fop/changes.html Version 0.94 @@ -67,6 +67,8 @@ list of possible build targets. <include name="KEYS"/> <include name="status.xml"/> <include name="fop.bat"/> + <include name="fop.cmd"/> + <include name="fop.js"/> <include name="fop"/> </fileset> <fileset dir="${basedir}" id="dist.bin.lib"> @@ -401,6 +403,7 @@ list of possible build targets. <include name="**/*.icm"/> <include name="**/*.xml"/> <include name="**/*.LICENSE.txt"/> + <include name="**/*.xsl"/> </fileset> <fileset dir="${build.gensrc.dir}"> <include name="**/*.xml"/> diff --git a/forrest.properties b/forrest.properties index add080783..62f777d63 100644 --- a/forrest.properties +++ b/forrest.properties @@ -66,7 +66,7 @@ project.knownissues=known-issues.xml # validation properties #forrest.validate=true -forrest.validate=false +#forrest.validate=false forrest.validate.xdocs=${forrest.validate} forrest.validate.skinconf=${forrest.validate} forrest.validate.sitemap=${forrest.validate} diff --git a/known-issues.xml b/known-issues.xml index 27ae55494..2ef4b7102 100644 --- a/known-issues.xml +++ b/known-issues.xml @@ -21,8 +21,9 @@ MIF and SVG output support have not been restored, yet. </known-issue> <known-issue> - Java2D/AWT support has been improved, but some problems remain, - for example with block-containers. + RTF output is inferior to other output formats supported by FOP. + For details, please see the "Output Targets" page of the release + you're using. </known-issue> <known-issue> Auto table layout is not implemented, yet. @@ -81,10 +82,6 @@ table-body, table-header, table-footer and table-row. </known-issue> <known-issue> - The backgrounds of table-body, table-header, table-footer and - table-column are not painted, yet. - </known-issue> - <known-issue> Border and padding conditionality are not supported on table-cells, yet. </known-issue> <known-issue> diff --git a/lib/avalon-framework-4.2.0.jar b/lib/avalon-framework-4.2.0.jar Binary files differindex b1aa6d7c9..22a7ab341 100644 --- a/lib/avalon-framework-4.2.0.jar +++ b/lib/avalon-framework-4.2.0.jar diff --git a/src/documentation/content/doap.rdf b/src/documentation/content/doap.rdf index c677ecbc8..734e8339b 100644 --- a/src/documentation/content/doap.rdf +++ b/src/documentation/content/doap.rdf @@ -77,22 +77,22 @@ <release> <Version> <name>Previous stable release</name> - <created>2007-01-02</created> - <revision>0.93</revision> + <created>2007-08-23</created> + <revision>0.94</revision> </Version> </release> <release> <Version> <name>Previous development release</name> - <created>2008-25-08</created> + <created>2008-03-26</created> <revision>0.95beta</revision> </Version> </release> <release> <Version> <name>Latest stable release</name> - <created>2007-08-23</created> - <revision>0.94</revision> + <created>2008-08-05</created> + <revision>0.95</revision> </Version> </release> <repository> diff --git a/src/documentation/content/xdocs/0.95/compiling.xml b/src/documentation/content/xdocs/0.95/compiling.xml index 57761429f..98a6dfb6d 100644 --- a/src/documentation/content/xdocs/0.95/compiling.xml +++ b/src/documentation/content/xdocs/0.95/compiling.xml @@ -66,7 +66,7 @@ <section id="env-ant"> <title>Apache Ant</title> <p> - <a href="ext:ant">Apache Ant</a> must be installed in order to + <a href="ext:ant">Apache Ant</a> (Version 1.7 or later) must be installed in order to build FOP. Following best practices we don't include Ant with FOP anymore. You can find the <a href="ext:ant/manual/">instructions to install Ant in the Ant manual</a> on the web. </p> diff --git a/src/documentation/content/xdocs/0.95/output.xml b/src/documentation/content/xdocs/0.95/output.xml index 628df1248..fbf277b90 100644 --- a/src/documentation/content/xdocs/0.95/output.xml +++ b/src/documentation/content/xdocs/0.95/output.xml @@ -703,6 +703,24 @@ out = proc.getOutputStream();]]></source> <note>RTF output is currently unmaintained and lacks many features compared to other output formats. Using other editable formats like Open Document Format, instead of producing XSL-FO then RTF through FOP, might give better results.</note> + <p> + These are some known restrictions compared to other supported output formats (not a complete list): + </p> + <ul> + <li> + Not supported/implemented: + <ul> + <li>break-before/after (supported by the RTF library but not tied into the RTFHandler)</li> + <li>fo:page-number-citation-last</li> + <li>keeps (supported by the RTF library but not tied into the RTFHandler)</li> + <li>region-start/end (RTF limitation)</li> + <li>multiple columns</li> + </ul> + </li> + <li>Only a single page-master is supported</li> + <li>Not all variations of fo:leader are supported (RTF limitation)</li> + <li>percentages are not supported everywhere</li> + </ul> </section> <section id="xml"> <title>XML (Area Tree XML)</title> @@ -735,6 +753,16 @@ out = proc.getOutputStream();]]></source> It is possible to directly print the document from the command line. This is done with the same code that renders to the Java2D/AWT renderer. </p> + <section id="print-issues"> + <title>Known issues</title> + <p> + If you run into the problem that the printed output is incomplete on Windows: + this often happens to users printing to a PCL printer. + There seems to be an incompatibility between Java and certain PCL printer drivers + on Windows. Since most network-enabled laser printers support PostScript, try + switching to the PostScript printer driver for that printer model. + </p> + </section> </section> <section id="bitmap"> <title>Bitmap (TIFF/PNG)</title> diff --git a/src/documentation/content/xdocs/compliance.ihtml b/src/documentation/content/xdocs/compliance.ihtml index 181f1fe1d..fc89d11d5 100644 --- a/src/documentation/content/xdocs/compliance.ihtml +++ b/src/documentation/content/xdocs/compliance.ihtml @@ -492,7 +492,7 @@ <th align="center">0.94 (stable)</th> - <th align="center">0.95 (beta)</th> + <th align="center">0.95 (stable)</th> <th align="center">develop- ment</th> </tr> diff --git a/src/documentation/content/xdocs/dev/release.xml b/src/documentation/content/xdocs/dev/release.xml index 641758d78..8cbdc0815 100644 --- a/src/documentation/content/xdocs/dev/release.xml +++ b/src/documentation/content/xdocs/dev/release.xml @@ -39,7 +39,7 @@ The purpose of documenting it here is to facilitate consistency, ensure that the <li>Commit any outstanding changes</li> <li>Create a branch called <code>branches/fop-v_vv</code></li> <li>Edit release notes (<code>README</code> and <code>status.xml</code> in the root).</li> - <li>Update the <code>index.xml</code> and <code>site.xml</code> for the new version.</li> + <li>Update the <code>index.xml</code>, <code>site.xml</code> and <code>download.xml</code> for the new version.</li> <li>Update the version numbers in the release column on the compliance page (<code>compliance.xml</code>); update the compliance in the release column to the current state (development column).</li> diff --git a/src/documentation/content/xdocs/download.xml b/src/documentation/content/xdocs/download.xml index f0a2a0a61..9f28efd00 100644 --- a/src/documentation/content/xdocs/download.xml +++ b/src/documentation/content/xdocs/download.xml @@ -89,35 +89,35 @@ <tr> <td>Repository URL</td> <td> - <link href="http://svn.apache.org/repos/asf/xmlgraphics/fop/tags/fop-0_94/"> - <code>http://svn.apache.org/repos/asf/xmlgraphics/fop/tags/fop-0_94/</code> + <link href="http://svn.apache.org/repos/asf/xmlgraphics/fop/tags/fop-0_95/"> + <code>http://svn.apache.org/repos/asf/xmlgraphics/fop/tags/fop-0_95/</code> </link> </td> </tr> <tr> <td>Web view</td> <td> - <link href="http://svn.apache.org/viewvc/xmlgraphics/fop/tags/fop-0_94/"> - <code>http://svn.apache.org/viewvc/xmlgraphics/fop/tags/fop-0_94/</code> + <link href="http://svn.apache.org/viewvc/xmlgraphics/fop/tags/fop-0_95/"> + <code>http://svn.apache.org/viewvc/xmlgraphics/fop/tags/fop-0_95/</code> </link> </td> </tr> <tr> - <th colspan="2">Latest Release</th> + <th colspan="2">Previous Stable Release</th> </tr> <tr> <td>Repository URL</td> <td> - <link href="http://svn.apache.org/repos/asf/xmlgraphics/fop/tags/fop-0_95beta/"> - <code>http://svn.apache.org/repos/asf/xmlgraphics/fop/tags/fop-0_95beta/</code> + <link href="http://svn.apache.org/repos/asf/xmlgraphics/fop/tags/fop-0_94/"> + <code>http://svn.apache.org/repos/asf/xmlgraphics/fop/tags/fop-0_94/</code> </link> </td> </tr> <tr> <td>Web view</td> <td> - <link href="http://svn.apache.org/viewvc/xmlgraphics/fop/tags/fop-0_95beta/"> - <code>http://svn.apache.org/viewvc/xmlgraphics/fop/tags/fop-0_95beta/</code> + <link href="http://svn.apache.org/viewvc/xmlgraphics/fop/tags/fop-0_94/"> + <code>http://svn.apache.org/viewvc/xmlgraphics/fop/tags/fop-0_94/</code> </link> </td> </tr> @@ -127,17 +127,30 @@ <tr> <td>Repository URL</td> <td> + Main Repository: <link href="http://svn.apache.org/repos/asf/xmlgraphics/fop/trunk/"> <code>http://svn.apache.org/repos/asf/xmlgraphics/fop/trunk/</code> </link> + <br/> + European Mirror: + <link href="http://svn.eu.apache.org/repos/asf/xmlgraphics/fop/trunk/"> + <code>http://svn.eu.apache.org/repos/asf/xmlgraphics/fop/trunk/</code> + </link> + </td> </tr> <tr> <td>Web view</td> <td> + Main Repository: <link href="http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/"> <code>http://svn.apache.org/viewvc/xmlgraphics/fop/trunk/</code> </link> + <br/> + European Mirror: + <link href="http://svn.eu.apache.org/viewvc/xmlgraphics/fop/trunk/"> + <code>http://svn.eu.apache.org/viewvc/xmlgraphics/fop/trunk/</code> + </link> </td> </tr> </table> @@ -146,7 +159,9 @@ build FOP from the source files. For details please see the "Build" page on the documentation tab for the version you've downloaded. </p> + <!-- No hopes to reenable them because of problems with long path names on Solaris <fixme author="jeremias">Reenable the link to the SVN snapshots once they are available.</fixme> + --> </section> <section id="archives"> <title>Archive Download</title> diff --git a/src/documentation/content/xdocs/knownissues.xml b/src/documentation/content/xdocs/knownissues.xml index caf96ceaa..ea39b2974 100644 --- a/src/documentation/content/xdocs/knownissues.xml +++ b/src/documentation/content/xdocs/knownissues.xml @@ -66,6 +66,7 @@ <section> <title>Other known issues</title> <p>This section lists other known issues.</p> + <!-- See <root>/known-issues.xml for the source document of this section! --> <xi:include href="cocoon://knownissues-raw-static.xml#xpointer(/document/body/*)"/> </section> </section> diff --git a/src/documentation/content/xdocs/news-data.xml b/src/documentation/content/xdocs/news-data.xml new file mode 100644 index 000000000..56ff61094 --- /dev/null +++ b/src/documentation/content/xdocs/news-data.xml @@ -0,0 +1,202 @@ +<?xml version="1.0" standalone="no"?> +<!-- + 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$ --> +<news> + <item date="2008-08-05" title="Apache FOP 0.95 Released"> + <p> + The Apache FOP team is delighted to present you a production grade + release of the new FOP codebase. This release + contains many bug fixes and new features. See the <a + href="0.95/releaseNotes_0.95.html">Release Notes</a> for a list of + the most important changes. + </p> + </item> + <item date="2008-03-16" title="Apache FOP 0.95beta Released"> + <p> + The Apache FOP team is delighted to present you a beta version of the + next production grade release of the new FOP codebase. This release + contains many bug fixes and new features. See the <a + href="0.95/releaseNotes_0.95beta.html">Release Notes</a> for a list of + the most important changes. + </p> + </item> + <item date="2007-10-30" title="New committer"> + <p>Welcome Max Berger!</p> + </item> + <item date="2007-10-15" title="New Committer"> + <p>Welcome Adrian Cumiskey!</p> + </item> + <item date="2007-08-24" title="Apache FOP 0.94 Released"> + <p>The Apache FOP team is pleased to present you the second production + grade release of the new FOP codebase. This release contains many bug + fixes and new features. See the <a + href="0.94/releaseNotes_0.94.html">Release Notes</a> for a list of + the most important changes.</p> + </item> + <item date="2007-01-26" title="New Committer"> + <p>Welcome Jay Bryant!</p> + </item> + <item date="2007-01-09" title="Apache FOP 0.93 released"> + <p> + The Apache FOP team is proud to present to you the first + production grade release of the new FOP codebase. This release + has the new API first introduced in release 0.92 beta. It + contains again many bug fixes and new features. + </p> + </item> + <item date="2006-10-16" title="New Committer"> + <p>Welcome Vincent Hennebert!</p> + </item> + <item date="2006-04-18" title="Apache FOP 0.92 beta released"> + <p> + A second "beta" grade release of the new FOP codebase with a modified and + now considered stable API. The release contains many bug fixes as well as + new features mainly related to even more extensive support of the XSL-FO + specification. This is expected to be the last "beta" release before we + go to a 1.0 release! + </p> + </item> + <item date="2005-12-23" title="Apache FOP 0.91 beta released"> + <p> + One month after the initial release we're happy present a "beta" grade + release of the new FOP codebase. It's mostly a bug fix release but also + contains a few new features. Thanks to all those who sent us feedback + on the initial release! + </p> + </item> + <item date="2005-11-22" title="Apache FOP 0.90 alpha 1 released"> + <p> + The Apache FOP team is proud to present to you the largely rewritten + codebase which is finally in a state where you can start to use it. + It has taken over three years to get this far and over two years + without a new release from the FOP project. + </p> + <p> + Please see also the + <a href="http://mail-archives.apache.org/mod_mbox/xmlgraphics-fop-users/200511.mbox/%3c20051123002157.0EB0.JEREMIAS@apache.org%3e">announcement</a>. + <!-- TODO re-enable and the <link href="relnotes.html#FOP+0.90+alpha+1">release notes</link>.--> + </p> + </item> + <item date="2005-09-08" title="New Committer"> + <p>Welcome Manuel Mall!</p> + </item> + <item date="2004-10-20" title="Creation of the Apache XML Graphics project"> + <p> + The Apache Board of Directors agreed to the creation of the + <a href="http://xmlgraphics.apache.org">Apache XML Graphics</a> + project which will be comprised of Batik and FOP. Both former + Apache XML subprojects are in this way complying with the Board's desire + to improve project oversight. Both project teams also see additional + benefits of working more closely together. + </p> + </item> + <item date="2004-10-08" title="New Committer"> + <p>Welcome Luca Furini!</p> + </item> + <item date="2004-04-24" title="New Committer"> + <p>Welcome Simon Pepping!</p> + </item> + <item date="2004-03-07" title="New Committer"> + <p>Welcome Web Maestro Clay Leeds!</p> + </item> + <item date="2004-01-10" title="New Committers"> + <p>Welcome Chris Bowditch and Andreas Delmelle!</p> + </item> + <item date="2004-01-04" title="New Committer"> + <p>Welcome Finn Bock!</p> + </item> + <item date="2003-11-29" title="New Committer"> + <p>Welcome Peter Herweg!</p> + </item> + <item date="2003-07-18" title="Apache FOP 0.20.5 released"> + <p>Changes since 0.20.4 include:</p> + <ul> + <li>Added support for PDF encryption</li> + <li>Perfomance tuning</li> + <li>Fixed link hotspot positioning</li> + <li>Fixed multi-threading issues</li> + <li>Added support for CCITT Group 4 encoded TIFF files</li> + <li>Dynamic JAI support</li> + <li>Added autoselecting portrait/landscape for PCL and PS Renderer</li> + <li>Added continued-label extension for tables</li> + <li>Improved AWT Font-measuring/rendering</li> + <li>Improved marker handling</li> + <li>Fixed problem with jpegs with icc profile and acrobat reader 5</li> + <li>Added a fontBaseDir property</li> + <li>TXTRenderer output encoding</li> + <li>border-spacing support</li> + <li>and a lot more bugfixes</li> + </ul> + <p> + See also the full text of the + <a href="http://mail-archives.apache.org/eyebrowse/ReadMsg?listName=fop-dev@xml.apache.org&msgNo=6067"> + announcement</a>. + <!-- TODO re-enable and the <link href="relnotes.html#FOP+0.20.5">release notes</link>.--> + </p> + </item> + <item date="2003-06-29" title="New Committer"> + <p>Welcome Glen Mazza!</p> + </item> + <item date="2003-05-23" title="Apache FOP 0.20.5 Release Candidate 3 available"> + <p> + See the full text of the <a + href="http://mail-archives.apache.org/eyebrowse/ReadMsg?listName=fop-dev@xml.apache.org&msgNo=5429">announcement</a>. + </p> + </item> + <item date="2003-02-18" title="Apache FOP 0.20.5 Release Candidate 2 available"> + <p> + See the full text of the <a + href="http://mail-archives.apache.org/eyebrowse/ReadMsg?listName=fop-dev@xml.apache.org&msgNo=4509">announcement</a>. + </p> + </item> + <item date="2003-02-02" title="New XML PMC"> + <p> + Jeremias Maerki and Peter B. West are now representing FOP on the XML PMC. + </p> + </item> + <item date="2003-01-28" title="FOP logo contest"> + <p>We are looking for a new logo. FOP logo + contest is started!</p> + </item> + <item date="2002-12-23" title="Official FOP Wiki"> + <p> + See <a href="http://wiki.apache.org/xmlgraphics-fop/FOPProjectPages" + >FOP project pages</a> at the ApacheWiki. + </p> + </item> + <item date="2002-12-10" title="FOP 0.20.5 Release Candidate available"> + <p> + See the full text of the <a + href="http://marc.theaimsgroup.com/?l=fop-user&m=103954279712704&w=2" + >announcement</a>. + </p> + </item> + <item date="2002-11-23" title="EXLSFO project has been created"> + <p> + The EXSLFO project is a community effort to define functional extensions + to thet XSL Formatting Objects specification. See the + <a href="http://exslfo.sourceforge.net">EXSLFO website</a> for details. + </p> + </item> + <item date="2002-11-22" title="New Committer"> + <p>Welcome Victor Mote!</p> + </item> + <item date="2002-11-09" title="New Committer"> + <p>Welcome Oleg Tkachenko!</p> + </item> +</news>
\ No newline at end of file diff --git a/src/documentation/content/xdocs/news.xml b/src/documentation/content/xdocs/news.xml index 1a5c178e2..29a1e3f98 100644 --- a/src/documentation/content/xdocs/news.xml +++ b/src/documentation/content/xdocs/news.xml @@ -23,207 +23,10 @@ <version>$Revision$</version> </header> <body> - <section> - <title>26th March 2007 - Apache FOP 0.95beta Released</title> - <p>The Apache FOP team is delighted to present you a beta version of the - next production grade release of the new FOP codebase. This release - contains many bug fixes and new features. See the <a - href="0.95/releaseNotes_0.95beta.html">Release Notes</a> for a list of - the most important changes.</p> - </section> - <section> - <title>30 October 2007 - New Committer</title> - <p>Welcome Max Berger!</p> - </section> - <section> - <title>15 October 2007 - New Committer</title> - <p>Welcome Adrian Cumiskey!</p> - </section> - <section> - <title>24th August 2007 - Apache FOP 0.94 Released</title> - <p>The Apache FOP team is pleased to present you the second production - grade release of the new FOP codebase. This release contains many bug - fixes and new features. See the <a - href="0.94/releaseNotes_0.94.html">Release Notes</a> for a list of - the most important changes.</p> - </section> - <section> - <title>26 January 2007 - New Committer</title> - <p>Welcome Jay Bryant!</p> - </section> - <section> - <title>9 January 2007 - Apache FOP 0.93 released</title> - <p> - The Apache FOP team is proud to present to you the first - production grade release of the new FOP codebase. This release - has the new API first introduced in release 0.92 beta. It - contains again many bug fixes and new features. - </p> - </section> - <section> - <title>16 October 2006 - New Committer</title> - <p>Welcome Vincent Hennebert!</p> - </section> - <section> - <title>18 April 2006 - Apache FOP 0.92 beta released</title> - <p> - A second "beta" grade release of the new FOP codebase with a modified and - now considered stable API. The release contains many bug fixes as well as - new features mainly related to even more extensive support of the XSL-FO - specification. This is expected to be the last "beta" release before we - go to a 1.0 release! - </p> - </section> - <section> - <title>23 December 2005 - Apache FOP 0.91 beta released</title> - <p> - One month after the initial release we're happy present a "beta" grade - release of the new FOP codebase. It's mostly a bug fix release but also - contains a few new features. Thanks to all those who sent us feedback - on the initial release! - </p> - </section> - <section> - <title>22 November 2005 - Apache FOP 0.90 alpha 1 released</title> - <p> - The Apache FOP team is proud to present to you the largely rewritten - codebase which is finally in a state where you can start to use it. - It has taken over three years to get this far and over two years - without a new release from the FOP project. - </p> - <p> - Please see also the - <a href="http://mail-archives.apache.org/mod_mbox/xmlgraphics-fop-users/200511.mbox/%3c20051123002157.0EB0.JEREMIAS@apache.org%3e">announcement</a>. - <!-- TODO re-enable and the <link href="relnotes.html#FOP+0.90+alpha+1">release notes</link>.--> - </p> - </section> - <section> - <title>8 September 2005 - New Committer</title> - <p>Welcome Manuel Mall!</p> - </section> - <section> - <title>20 October 2004 - Creation of the Apache XML Graphics project</title> - <p> - The Apache Board of Directors agreed to the creation of the - <a href="http://xmlgraphics.apache.org">Apache XML Graphics</a> - project which will be comprised of Batik and FOP. Both former - Apache XML subprojects are in this way complying with the Board's desire - to improve project oversight. Both project teams also see additional - benefits of working more closely together. - </p> - </section> - <section> - <title>8 October 2004 - New Committer</title> - <p>Welcome Luca Furini!</p> - </section> - <section> - <title>24 April 2004 - New Committer</title> - <p>Welcome Simon Pepping!</p> - </section> - <section> - <title>7 March 2004 - New Committer</title> - <p>Welcome Web Maestro Clay Leeds!</p> - </section> - <section> - <title>10 January 2004 - New Committers</title> - <p>Welcome Chris Bowditch and Andreas Delmelle!</p> - </section> - <section> - <title>4 January 2004 - New Committer</title> - <p>Welcome Finn Bock!</p> - </section> - <section> - <title>29 November 2003 - New Committer</title> - <p>Welcome Peter Herweg!</p> - </section> - <section> - <title>18 July 2003 FOP 0.20.5 released</title> - <p>Changes since 0.20.4 include:</p> - <ul> - <li>Added support for PDF encryption</li> - <li>Perfomance tuning</li> - <li>Fixed link hotspot positioning</li> - <li>Fixed multi-threading issues</li> - <li>Added support for CCITT Group 4 encoded TIFF files</li> - <li>Dynamic JAI support</li> - <li>Added autoselecting portrait/landscape for PCL and PS Renderer</li> - <li>Added continued-label extension for tables</li> - <li>Improved AWT Font-measuring/rendering</li> - <li>Improved marker handling</li> - <li>Fixed problem with jpegs with icc profile and acrobat reader 5</li> - <li>Added a fontBaseDir property</li> - <li>TXTRenderer output encoding</li> - <li>border-spacing support</li> - <li>and a lot more bugfixes</li> - </ul> - <p> - See also the full text of the - <a href="http://mail-archives.apache.org/eyebrowse/ReadMsg?listName=fop-dev@xml.apache.org&msgNo=6067"> - announcement</a>. - <!-- TODO re-enable and the <link href="relnotes.html#FOP+0.20.5">release notes</link>.--> - </p> - </section> - <section> - <title>29 June 2003 - New Committer</title> - <p>Welcome Glen Mazza!</p> - </section> - <section> - <title>23 May 2003 - FOP 0.20.5 Release Candidate 3 available</title> - <p> - See the full text of the <a - href="http://mail-archives.apache.org/eyebrowse/ReadMsg?listName=fop-dev@xml.apache.org&msgNo=5429">announcement</a>. - </p> - </section> - <section> - <title>18 February 2003 - FOP 0.20.5 Release Candidate 2 available</title> - <p> - See the full text of the <a - href="http://mail-archives.apache.org/eyebrowse/ReadMsg?listName=fop-dev@xml.apache.org&msgNo=4509">announcement</a>. - </p> - </section> - <section> - <title>2 February 2003 - New XML PMC</title> - <p> - Jeremias Maerki and Peter B. West are now representing FOP on the XML PMC. - </p> - </section> - <section> - <title>28 January 2003 - FOP logo contest</title> - <p>We are looking for a new logo. FOP logo - contest is started!</p> - </section> - <section> - <title>23 December 2002 - Official FOP Wiki</title> - <p> - See <a href="http://wiki.apache.org/xmlgraphics-fop/FOPProjectPages" - >FOP project pages</a> at the ApacheWiki. - </p> - </section> - <section> - <title>10 December 2002 - FOP 0.20.5 Release Candidate available</title> - <p> - See the full text of the <a - href="http://marc.theaimsgroup.com/?l=fop-user&m=103954279712704&w=2" - >announcement</a>. - </p> - </section> - <section> - <title>23 November 2002 - EXLSFO project has been created</title> - <p> - The EXSLFO project is a community effort to define functional extensions - to thet XSL Formatting Objects specification. See the - <a href="http://exslfo.sourceforge.net">EXSLFO website</a> for details. - </p> - </section> - <section> - <title>22 November 2002 - New Committer</title> - <p>Welcome Victor Mote!</p> - </section> - <section> - <title>9 November 2002 - New Committer</title> - <p>Welcome Oleg Tkachenko!</p> - </section> - + <p> + RSS Feed: <a href="subproject-news-feed.rss"><img src="feed-icon-14x14.png" alt="Subproject News Feed"/></a> + </p> + <xi:include href="cocoon://subproject-news-document.xml#xpointer(/document/body/*)" xmlns:xi="http://www.w3.org/2001/XInclude"/> </body> </document> diff --git a/src/documentation/content/xdocs/site.xml b/src/documentation/content/xdocs/site.xml index b0a3214e7..5ebdef322 100644 --- a/src/documentation/content/xdocs/site.xml +++ b/src/documentation/content/xdocs/site.xml @@ -96,10 +96,11 @@ <!-- BEGIN Version 0.95 documentation tab --> - <trunk label="FOP 0.95beta" href="0.95/" tab="stableversion"> + <trunk label="FOP 0.95" href="0.95/" tab="stableversion"> <about label="About" href="index.html"/> - <release label="Release Notes" href="releaseNotes_0.95beta.html"/> - <changes label="Changes" href="changes_0.95beta.html"/> + <release label="Release Notes" href="releaseNotes_0.95.html"/> + <changes label="Changes (0.95)" href="changes_0.95.html"/> + <changes-beta label="Changes (0.95beta)" href="changes_0.95beta.html"/> <knownissues label="Known Issues" href="knownissues_overview.html"/> <upgrading label="Upgrading" href="upgrading.html"/> diff --git a/src/documentation/content/xdocs/tabs.xml b/src/documentation/content/xdocs/tabs.xml index a42fc9bd7..3db01d4fa 100644 --- a/src/documentation/content/xdocs/tabs.xml +++ b/src/documentation/content/xdocs/tabs.xml @@ -22,7 +22,7 @@ <tabs software="FOP" title="FOP" copyright="@year@ The Apache Software Foundation" xmlns:xlink="http://www.w3.org/1999/xlink"> <tab label="Home" dir=""/> <tab label="Version 0.94" dir="0.94/"/> - <tab label="Version 0.95beta" dir="0.95/"/> + <tab label="Version 0.95" dir="0.95/"/> <tab label="FOP Trunk" dir="trunk/"/> <tab label="Development" dir="dev/"/> </tabs> diff --git a/src/documentation/content/xdocs/team.xml b/src/documentation/content/xdocs/team.xml index 084c54ba8..777881494 100644 --- a/src/documentation/content/xdocs/team.xml +++ b/src/documentation/content/xdocs/team.xml @@ -31,6 +31,11 @@ <title>Active Committers</title> <note label="Important">Please don't write to any developer directly if you need help on using FOP. Only if you submit questions to the <link href="maillist.html#fop-user">FOP User Mailing List</link> will other FOP users be able to profit from answers given to your question. Another point is that a developer may have gone inactive or is on holidays in which case you may not get an answer in time.</note> <ul> + <li id="mb"><link href="mailto:max AT berger DOT name">Max Berger</link> (MB) is currently a + PostDoc pursuing an academic career in computer science. His main interest in FOP is to + improve the DocBook to PDF tool-chain to produce high quality output, while still + conforming to given style-guides. See his <link href="http://max.berger.name">home + page</link> for more information.</li> <li id="cb"><link href="mailto:bowditch_chris@hotmail.com">Chris Bowditch</link> (CB) is a Java/VB Programmer from England.</li> <li id="jb"><link href="mailto:jay@bryantcs.com">Jay Bryant</link> (JB) is a @@ -73,11 +78,6 @@ from the TeX/LaTeX world. See his <fork href="http://www.leverkruid.eu">home page</fork> for some of his private projects.</li> <li id="jp"><link href="mailto:pietsch@apache.org">Jörg Pietschmann</link> (JP)</li> - <li id="mb"><link href="mailto:max AT berger DOT name">Max Berger</link> (MB) is currently a - PostDoc pursuing an academic career in computer science. His main interest in FOP is to - improve the DocBook to PDF tool-chain to produce high quality output, while still - conforming to given style-guides. See his <link href="http://max.berger.name">home - page</link> for more information.</li> </ul> </section> <section id="contribute-active"> @@ -126,206 +126,6 @@ <li id="pbw"><link href="mailto:pbwest@apache.org">Peter B. West</link></li> </ul> </section> - <section id="expertise"> - <title>Areas of Expertise</title> - <table> - <tr> - <th/> - <th>CG</th> - <th>FB</th> - <th>CL</th> - <th>JM</th> - <th>VH</th> - <th>PH</th> - <th>JP</th> - <th>SP</th> - <th>LF</th> - <th>JB</th> - </tr> - <tr> - <td>Release manager</td> - <td>X</td> - <td/> - <td/> - <td/> - <td/> - <td/> - <td/> - <td/> - <td/> - <td/> - </tr> - <tr> - <td>XSL-FO tree</td> - <td/> - <td>X</td> - <td/> - <td>X</td> - <td></td> - <td/> - <td/> - <td>X</td> - <td/> - <td/> - </tr> - <tr> - <td>Properties</td> - <td/> - <td>X</td> - <td/> - <td>X</td> - <td/> - <td/> - <td/> - <td>X</td> - <td/> - <td/> - </tr> - <tr> - <td>Layout</td> - <td/> - <td/> - <td/> - <td>X</td> - <td>X</td> - <td/> - <td>X</td> - <td>X</td> - <td>X</td> - <td/> - </tr> - <tr> - <td>Fonts</td> - <td/> - <td/> - <td/> - <td>X</td> - <td/> - <td/> - <td/> - <td/> - <td/> - <td/> - </tr> - <tr> - <td>SVG</td> - <td/> - <td/> - <td/> - <td>X</td> - <td/> - <td/> - <td/> - <td/> - <td/> - <td/> - </tr> - <tr> - <td>Java2D (AWT)</td> - <td/> - <td/> - <td/> - <td>X</td> - <td/> - <td/> - <td/> - <td/> - <td/> - <td/> - </tr> - <tr> - <td>PDF</td> - <td/> - <td/> - <td/> - <td>X</td> - <td/> - <td/> - <td/> - <td/> - <td/> - <td>X</td> - </tr> - <tr> - <td>PostScript</td> - <td/> - <td/> - <td/> - <td>X</td> - <td/> - <td/> - <td/> - <td/> - <td/> - <td/> - </tr> - <tr> - <td>PCL</td> - <td/> - <td/> - <td/> - <td>X</td> - <td/> - <td/> - <td/> - <td/> - <td/> - <td/> - </tr> - <tr> - <td>RTF</td> - <td/> - <td/> - <td/> - <td>X</td> - <td/> - <td>X</td> - <td/> - <td/> - <td/> - <td/> - </tr> - <tr> - <td>MIF</td> - <td/> - <td/> - <td/> - <td/> - <td/> - <td/> - <td/> - <td/> - <td/> - <td/> - </tr> - <tr> - <td>AFP</td> - <td/> - <td/> - <td/> - <td/> - <td/> - <td/> - <td/> - <td/> - <td/> - <td/> - </tr> - <tr> - <td>Forrest</td> - <td/> - <td/> - <td>X</td> - <td>X</td> - <td/> - <td/> - <td/> - <td/> - <td/> - <td/> - </tr> - </table> - </section> </body> </document> diff --git a/src/documentation/content/xdocs/trunk/compiling.xml b/src/documentation/content/xdocs/trunk/compiling.xml index 57761429f..98a6dfb6d 100644 --- a/src/documentation/content/xdocs/trunk/compiling.xml +++ b/src/documentation/content/xdocs/trunk/compiling.xml @@ -66,7 +66,7 @@ <section id="env-ant"> <title>Apache Ant</title> <p> - <a href="ext:ant">Apache Ant</a> must be installed in order to + <a href="ext:ant">Apache Ant</a> (Version 1.7 or later) must be installed in order to build FOP. Following best practices we don't include Ant with FOP anymore. You can find the <a href="ext:ant/manual/">instructions to install Ant in the Ant manual</a> on the web. </p> diff --git a/src/documentation/content/xdocs/trunk/output.xml b/src/documentation/content/xdocs/trunk/output.xml index 22d916d31..b9916e198 100644 --- a/src/documentation/content/xdocs/trunk/output.xml +++ b/src/documentation/content/xdocs/trunk/output.xml @@ -728,6 +728,24 @@ out = proc.getOutputStream();]]></source> <note>RTF output is currently unmaintained and lacks many features compared to other output formats. Using other editable formats like Open Document Format, instead of producing XSL-FO then RTF through FOP, might give better results.</note> + <p> + These are some known restrictions compared to other supported output formats (not a complete list): + </p> + <ul> + <li> + Not supported/implemented: + <ul> + <li>break-before/after (supported by the RTF library but not tied into the RTFHandler)</li> + <li>fo:page-number-citation-last</li> + <li>keeps (supported by the RTF library but not tied into the RTFHandler)</li> + <li>region-start/end (RTF limitation)</li> + <li>multiple columns</li> + </ul> + </li> + <li>Only a single page-master is supported</li> + <li>Not all variations of fo:leader are supported (RTF limitation)</li> + <li>percentages are not supported everywhere</li> + </ul> </section> <section id="xml"> <title>XML (Area Tree XML)</title> @@ -760,6 +778,16 @@ out = proc.getOutputStream();]]></source> It is possible to directly print the document from the command line. This is done with the same code that renders to the Java2D/AWT renderer. </p> + <section id="print-issues"> + <title>Known issues</title> + <p> + If you run into the problem that the printed output is incomplete on Windows: + this often happens to users printing to a PCL printer. + There seems to be an incompatibility between Java and certain PCL printer drivers + on Windows. Since most network-enabled laser printers support PostScript, try + switching to the PostScript printer driver for that printer model. + </p> + </section> </section> <section id="bitmap"> <title>Bitmap (TIFF/PNG)</title> @@ -911,3 +939,4 @@ out = proc.getOutputStream();]]></source> </document> + diff --git a/src/documentation/resources/images/feed-icon-14x14.png b/src/documentation/resources/images/feed-icon-14x14.png Binary files differnew file mode 100644 index 000000000..b3c949d22 --- /dev/null +++ b/src/documentation/resources/images/feed-icon-14x14.png diff --git a/src/documentation/resources/stylesheets/news2document.xsl b/src/documentation/resources/stylesheets/news2document.xsl new file mode 100644 index 000000000..dae1552bd --- /dev/null +++ b/src/documentation/resources/stylesheets/news2document.xsl @@ -0,0 +1,53 @@ +<?xml version="1.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$ --> +<xsl:stylesheet + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:date="http://exslt.org/dates-and-times" + extension-element-prefixes="date" + version="1.0"> + + <date:date-format lang="en" first-day-in-week="monday"/> + + <xsl:template match="news"> + <document> + <header> + <title>News</title> + </header> + <body> + <xsl:apply-templates select="item"/> + </body> + </document> + </xsl:template> + + <xsl:template match="item"> + <section id="news-{@date}"> + <title> + <xsl:value-of select="date:day-in-month(@date)"/> + <xsl:text> </xsl:text> + <xsl:value-of select="date:month-abbreviation(@date)"/> + <xsl:text> </xsl:text> + <xsl:value-of select="date:year(@date)"/> + <xsl:text>: </xsl:text> + <xsl:value-of select="@title"/> + </title> + <xsl:copy-of select="."/> + </section> + </xsl:template> + +</xsl:stylesheet> diff --git a/src/documentation/resources/stylesheets/news2rss.xsl b/src/documentation/resources/stylesheets/news2rss.xsl new file mode 100644 index 000000000..d629ba6f4 --- /dev/null +++ b/src/documentation/resources/stylesheets/news2rss.xsl @@ -0,0 +1,58 @@ +<?xml version="1.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$ --> +<xsl:stylesheet + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:date="http://exslt.org/dates-and-times" + extension-element-prefixes="date" + version="1.0"> + <xsl:param name="project-name" select="//skinconfig/project-name"/> + <xsl:param name="project-url" select="//skinconfig/project-url"/> + <xsl:template match="news"> + <rss version="2.0"> + <channel> + <title><xsl:value-of select="$project-name"/> News</title> + <link><xsl:value-of select="$project-url"/></link> + <description> + Subproject News for <xsl:value-of select="$project-name"/> + </description> + <language>en</language> + <xsl:apply-templates/> + </channel> + </rss> + </xsl:template> + <xsl:template match="item"> + <item> + <title> + <xsl:value-of select="date:day-in-month(@date)"/> + <xsl:text> </xsl:text> + <xsl:value-of select="date:month-abbreviation(@date)"/> + <xsl:text> </xsl:text> + <xsl:value-of select="date:year(@date)"/> + <xsl:text>: </xsl:text> + <xsl:value-of select="@title"/> + </title> + <guid>news-<xsl:value-of select="@date"/></guid> + <link><xsl:value-of select="$project-url"/>/index.html#news-<xsl:value-of select="@date"/></link> + <pubDate><xsl:value-of select="date:format-date(@date, 'EEE, d MMM yyyy HH:mm:ss Z')"/></pubDate> + <description> + <xsl:apply-templates/> + </description> + </item> + </xsl:template> +</xsl:stylesheet> diff --git a/src/documentation/sitemap.xmap b/src/documentation/sitemap.xmap index 470db0b7b..0e845d0bc 100644 --- a/src/documentation/sitemap.xmap +++ b/src/documentation/sitemap.xmap @@ -17,6 +17,9 @@ --> <map:sitemap xmlns:map="http://apache.org/cocoon/sitemap/1.0"> <map:components> + <map:serializers default="html"> + <map:serializer name="rss" mime-type="application/rss+xml" src="org.apache.cocoon.serialization.XMLSerializer"/> + </map:serializers> </map:components> <map:pipelines> @@ -69,6 +72,26 @@ <map:serialize type="xml-document"/> </map:match> </map:pipeline> - + + <!-- This is used by xinclude statements for News--> + <map:pipeline> + <map:match type="regexp" pattern="^(.*?)([^/]*)subproject-news-document.xml"> + <map:generate src="{properties:content.xdocs}{1}news-data.xml"/> + <map:transform src="resources/stylesheets/news2document.xsl" > + <map:parameter name="path" value="{1}{2}"/> + </map:transform> + <map:serialize type="xml"/> + </map:match> + <map:match type="regexp" pattern="^(.*?)([^/]*)subproject-news-feed.rss"> + <map:generate src="{properties:content.xdocs}{1}news-data.xml"/> + <map:transform src="resources/stylesheets/news2rss.xsl" > + <map:parameter name="path" value="{1}{2}"/> + <map:parameter name="project-name" value="{properties:projectInfo.project.fullname}"/> + <map:parameter name="project-url" value="{properties:projectInfo.project.url}"/> + </map:transform> + <map:serialize type="rss"/> + </map:match> + </map:pipeline> + </map:pipelines> </map:sitemap> diff --git a/src/java/org/apache/fop/apps/FOURIResolver.java b/src/java/org/apache/fop/apps/FOURIResolver.java index 9a49b28f1..1f4425a95 100644 --- a/src/java/org/apache/fop/apps/FOURIResolver.java +++ b/src/java/org/apache/fop/apps/FOURIResolver.java @@ -108,6 +108,8 @@ public class FOURIResolver implements javax.xml.transform.URIResolver { /** * Handles resolve exceptions appropriately. * + * @param e + * the exception * @param errorStr * error string * @param strict @@ -232,17 +234,16 @@ public class FOURIResolver implements javax.xml.transform.URIResolver { * The URL class does not implement this work around, so we * do. */ + assert (baseURL != null); String scheme = baseURL.getProtocol() + ":"; - if (href.startsWith(scheme)) { + if (href.startsWith(scheme) && "file:".equals(scheme)) { href = href.substring(scheme.length()); - if ("file:".equals(scheme)) { - int colonPos = href.indexOf(':'); - int slashPos = href.indexOf('/'); - if (slashPos >= 0 && colonPos >= 0 - && colonPos < slashPos) { - href = "/" + href; // Absolute file URL doesn't - // have a leading slash - } + int colonPos = href.indexOf(':'); + int slashPos = href.indexOf('/'); + if (slashPos >= 0 && colonPos >= 0 + && colonPos < slashPos) { + href = "/" + href; // Absolute file URL doesn't + // have a leading slash } } try { diff --git a/src/java/org/apache/fop/area/BookmarkData.java b/src/java/org/apache/fop/area/BookmarkData.java index d009cb425..28ee2c23e 100644 --- a/src/java/org/apache/fop/area/BookmarkData.java +++ b/src/java/org/apache/fop/area/BookmarkData.java @@ -218,25 +218,24 @@ public class BookmarkData extends AbstractOffDocumentItem implements Resolvable * id reference. * * {@inheritDoc} List) - * @todo check to make sure it works if multiple bookmark-items - * have the same idref */ public void resolveIDRef(String id, List pages) { - if (!id.equals(idRef)) { - Collection refs = (Collection)unresolvedIDRefs.get(id); - if (refs != null) { - Iterator iter = refs.iterator(); - while (iter.hasNext()) { - BookmarkData bd = (BookmarkData)iter.next(); - bd.resolveIDRef(id, pages); - } - unresolvedIDRefs.remove(id); - } - } else { + if (id.equals(idRef)) { + //Own ID has been resolved, so note the page pageRef = (PageViewport) pages.get(0); - // TODO get rect area of id on page - unresolvedIDRefs.remove(idRef); + //Note: Determining the placement inside the page is the renderer's job. + } + + //Notify all child bookmarks + Collection refs = (Collection)unresolvedIDRefs.get(id); + if (refs != null) { + Iterator iter = refs.iterator(); + while (iter.hasNext()) { + BookmarkData bd = (BookmarkData)iter.next(); + bd.resolveIDRef(id, pages); + } } + unresolvedIDRefs.remove(id); } /** diff --git a/src/java/org/apache/fop/fo/flow/Block.java b/src/java/org/apache/fop/fo/flow/Block.java index d1df9c21d..4645734b2 100644 --- a/src/java/org/apache/fop/fo/flow/Block.java +++ b/src/java/org/apache/fop/fo/flow/Block.java @@ -32,6 +32,7 @@ import org.apache.fop.fo.FObjMixed; import org.apache.fop.fo.NullCharIterator; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.ValidationException; +import org.apache.fop.fo.properties.BreakPropertySet; import org.apache.fop.fo.properties.CommonBorderPaddingBackground; import org.apache.fop.fo.properties.CommonFont; import org.apache.fop.fo.properties.CommonHyphenation; @@ -44,7 +45,7 @@ import org.apache.fop.fo.properties.SpaceProperty; * Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_block"> * <code>fo:block object</code></a>. */ -public class Block extends FObjMixed { +public class Block extends FObjMixed implements BreakPropertySet { // used for FO validation private boolean blockOrInlineItemFound = false; diff --git a/src/java/org/apache/fop/fo/flow/BlockContainer.java b/src/java/org/apache/fop/fo/flow/BlockContainer.java index 25b3f2a2a..b0bfb3a32 100644 --- a/src/java/org/apache/fop/fo/flow/BlockContainer.java +++ b/src/java/org/apache/fop/fo/flow/BlockContainer.java @@ -28,6 +28,7 @@ import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.ValidationException; +import org.apache.fop.fo.properties.BreakPropertySet; import org.apache.fop.fo.properties.CommonAbsolutePosition; import org.apache.fop.fo.properties.CommonBorderPaddingBackground; import org.apache.fop.fo.properties.CommonMarginBlock; @@ -38,7 +39,7 @@ import org.apache.fop.fo.properties.LengthRangeProperty; * Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_block-container"> * <code>fo:block-container</code></a> object. */ -public class BlockContainer extends FObj { +public class BlockContainer extends FObj implements BreakPropertySet { // The value of properties relevant for fo:block-container. private CommonAbsolutePosition commonAbsolutePosition; private CommonBorderPaddingBackground commonBorderPaddingBackground; diff --git a/src/java/org/apache/fop/fo/flow/ListBlock.java b/src/java/org/apache/fop/fo/flow/ListBlock.java index dfadc9c02..8f72ded67 100644 --- a/src/java/org/apache/fop/fo/flow/ListBlock.java +++ b/src/java/org/apache/fop/fo/flow/ListBlock.java @@ -27,6 +27,7 @@ import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.ValidationException; +import org.apache.fop.fo.properties.BreakPropertySet; import org.apache.fop.fo.properties.CommonBorderPaddingBackground; import org.apache.fop.fo.properties.CommonMarginBlock; import org.apache.fop.fo.properties.KeepProperty; @@ -35,7 +36,7 @@ import org.apache.fop.fo.properties.KeepProperty; * Class modelling the <a href=http://www.w3.org/TR/xsl/#fo_list-block"> * <code>fo:list-block</code></a> object. */ -public class ListBlock extends FObj { +public class ListBlock extends FObj implements BreakPropertySet { // The value of properties relevant for fo:list-block. private CommonBorderPaddingBackground commonBorderPaddingBackground; private CommonMarginBlock commonMarginBlock; diff --git a/src/java/org/apache/fop/fo/flow/ListItem.java b/src/java/org/apache/fop/fo/flow/ListItem.java index 95760c00b..f748bc15a 100644 --- a/src/java/org/apache/fop/fo/flow/ListItem.java +++ b/src/java/org/apache/fop/fo/flow/ListItem.java @@ -26,6 +26,7 @@ import org.apache.fop.fo.FONode; import org.apache.fop.fo.FObj; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.ValidationException; +import org.apache.fop.fo.properties.BreakPropertySet; import org.apache.fop.fo.properties.CommonBorderPaddingBackground; import org.apache.fop.fo.properties.CommonMarginBlock; import org.apache.fop.fo.properties.KeepProperty; @@ -34,7 +35,7 @@ import org.apache.fop.fo.properties.KeepProperty; * Class modelling the <a href=http://www.w3.org/TR/xsl/#fo_list-item"> * <code>fo:list-item</code></a> object. */ -public class ListItem extends FObj { +public class ListItem extends FObj implements BreakPropertySet { // The value of properties relevant for fo:list-item. private CommonBorderPaddingBackground commonBorderPaddingBackground; private CommonMarginBlock commonMarginBlock; diff --git a/src/java/org/apache/fop/fo/flow/table/Table.java b/src/java/org/apache/fop/fo/flow/table/Table.java index efd1f1c93..86196cb29 100644 --- a/src/java/org/apache/fop/fo/flow/table/Table.java +++ b/src/java/org/apache/fop/fo/flow/table/Table.java @@ -31,6 +31,7 @@ import org.apache.fop.fo.FONode; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.StaticPropertyList; import org.apache.fop.fo.ValidationException; +import org.apache.fop.fo.properties.BreakPropertySet; import org.apache.fop.fo.properties.CommonBorderPaddingBackground; import org.apache.fop.fo.properties.CommonMarginBlock; import org.apache.fop.fo.properties.KeepProperty; @@ -42,7 +43,7 @@ import org.apache.fop.fo.properties.TableColLength; * Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_table"> * <code>fo:table</code></a> object. */ -public class Table extends TableFObj implements ColumnNumberManagerHolder { +public class Table extends TableFObj implements ColumnNumberManagerHolder, BreakPropertySet { /** properties */ private CommonBorderPaddingBackground commonBorderPaddingBackground; diff --git a/src/java/org/apache/fop/fo/flow/table/TableAndCaption.java b/src/java/org/apache/fop/fo/flow/table/TableAndCaption.java index 548a9c4fa..919e73bfb 100644 --- a/src/java/org/apache/fop/fo/flow/table/TableAndCaption.java +++ b/src/java/org/apache/fop/fo/flow/table/TableAndCaption.java @@ -32,7 +32,7 @@ import org.apache.fop.fo.ValidationException; * <code>fo:table-and-caption</code></a> property. * @todo needs implementation */ -public class TableAndCaption extends FObj { +public class TableAndCaption extends FObj /*implements BreakPropertySet*/ { // The value of properties relevant for fo:table-and-caption. // Unused but valid items, commented out for performance: // private CommonAccessibility commonAccessibility; diff --git a/src/java/org/apache/fop/fo/flow/table/TableRow.java b/src/java/org/apache/fop/fo/flow/table/TableRow.java index 4d11f8780..a40b550bc 100644 --- a/src/java/org/apache/fop/fo/flow/table/TableRow.java +++ b/src/java/org/apache/fop/fo/flow/table/TableRow.java @@ -27,6 +27,7 @@ import org.apache.fop.datatypes.Length; import org.apache.fop.fo.FONode; import org.apache.fop.fo.PropertyList; import org.apache.fop.fo.ValidationException; +import org.apache.fop.fo.properties.BreakPropertySet; import org.apache.fop.fo.properties.CommonBorderPaddingBackground; import org.apache.fop.fo.properties.KeepProperty; import org.apache.fop.fo.properties.LengthRangeProperty; @@ -35,7 +36,7 @@ import org.apache.fop.fo.properties.LengthRangeProperty; * Class modelling the <a href="http://www.w3.org/TR/xsl/#fo_table-row"> * <code>fo:table-row</code></a> object. */ -public class TableRow extends TableCellContainer { +public class TableRow extends TableCellContainer implements BreakPropertySet { // The value of properties relevant for fo:table-row. private LengthRangeProperty blockProgressionDimension; private CommonBorderPaddingBackground commonBorderPaddingBackground; diff --git a/src/java/org/apache/fop/fo/properties/BreakPropertySet.java b/src/java/org/apache/fop/fo/properties/BreakPropertySet.java new file mode 100644 index 000000000..2babe0f19 --- /dev/null +++ b/src/java/org/apache/fop/fo/properties/BreakPropertySet.java @@ -0,0 +1,33 @@ +/* + * 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.properties; + +/** + * Defines property access methods for the break-before and break-after properties. + */ +public interface BreakPropertySet { + + /** @return the "break-after" property. */ + int getBreakAfter(); + + /** @return the "break-before" property. */ + int getBreakBefore(); + +} diff --git a/src/java/org/apache/fop/fonts/FontInfo.java b/src/java/org/apache/fop/fonts/FontInfo.java index f576c8208..2bcc6d7e1 100644 --- a/src/java/org/apache/fop/fonts/FontInfo.java +++ b/src/java/org/apache/fop/fonts/FontInfo.java @@ -436,7 +436,7 @@ public class FontInfo { FontTriplet key = null; String f = null; int newWeight = weight; - if (newWeight < 400) { + if (newWeight <= 400) { while (f == null && newWeight > 100) { newWeight -= 100; key = createFontKey(family, style, newWeight); diff --git a/src/java/org/apache/fop/fonts/MultiByteFont.java b/src/java/org/apache/fop/fonts/MultiByteFont.java index 4843b308a..f25ca4e7e 100644 --- a/src/java/org/apache/fop/fonts/MultiByteFont.java +++ b/src/java/org/apache/fop/fonts/MultiByteFont.java @@ -29,7 +29,6 @@ import java.util.Map; public class MultiByteFont extends CIDFont { private static int uniqueCounter = -1; - private static final DecimalFormat COUNTER_FORMAT = new DecimalFormat("00000"); private String ttcName = null; private String encoding = "Identity-H"; @@ -58,7 +57,8 @@ public class MultiByteFont extends CIDFont { uniqueCounter = 0; //We need maximum 5 character then we start again } } - String cntString = COUNTER_FORMAT.format(uniqueCounter); + DecimalFormat counterFormat = new DecimalFormat("00000"); + String cntString = counterFormat.format(uniqueCounter); //Subset prefix as described in chapter 5.5.3 of PDF 1.4 StringBuffer sb = new StringBuffer("E"); diff --git a/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java b/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java index 5438d3a42..981f3ad69 100644 --- a/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java +++ b/src/java/org/apache/fop/fonts/type1/Type1FontLoader.java @@ -100,6 +100,11 @@ public class Type1FontLoader extends FontLoader { try { pfm = new PFMFile(); pfm.load(pfmIn); + } catch (IOException ioe) { + if (afm == null) { + //Ignore the exception if we have a valid PFM. PFM is only the fallback. + throw ioe; + } } finally { IOUtils.closeQuietly(pfmIn); } diff --git a/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java b/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java index 6a8d76b13..b5d7511ca 100644 --- a/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java +++ b/src/java/org/apache/fop/image/loader/batik/ImageConverterSVG2G2D.java @@ -68,10 +68,10 @@ public class ImageConverterSVG2G2D extends AbstractImageConverter { } //Prepare - float pxToMillimeter = (float)UnitConv.mm2in(72); //default: 72dpi + float pxToMillimeter = UnitConv.IN2MM / 72; //default: 72dpi Number ptm = (Number)hints.get(ImageProcessingHints.SOURCE_RESOLUTION); if (ptm != null) { - pxToMillimeter = (float)UnitConv.mm2in(ptm.doubleValue()); + pxToMillimeter = (float)(UnitConv.IN2MM / ptm.doubleValue()); } UserAgent ua = createBatikUserAgent(pxToMillimeter); GVTBuilder builder = new GVTBuilder(); diff --git a/src/java/org/apache/fop/image/loader/batik/PreloaderSVG.java b/src/java/org/apache/fop/image/loader/batik/PreloaderSVG.java index 1c277c083..5e4e37345 100644 --- a/src/java/org/apache/fop/image/loader/batik/PreloaderSVG.java +++ b/src/java/org/apache/fop/image/loader/batik/PreloaderSVG.java @@ -45,6 +45,7 @@ import org.apache.xmlgraphics.image.loader.impl.AbstractImagePreloader; import org.apache.xmlgraphics.image.loader.impl.ImageXMLDOM; import org.apache.xmlgraphics.image.loader.util.ImageUtil; import org.apache.xmlgraphics.util.MimeConstants; +import org.apache.xmlgraphics.util.UnitConv; import org.apache.fop.svg.SimpleSVGUserAgent; import org.apache.fop.util.UnclosableInputStream; @@ -118,7 +119,7 @@ public class PreloaderSVG extends AbstractImagePreloader { in.mark(length + 1); SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory( getParserName()); - doc = (SVGDocument) factory.createSVGDocument(src.getSystemId(), in); + doc = factory.createSVGDocument(src.getSystemId(), in); } ImageInfo info = createImageInfo(uri, context, doc); @@ -153,7 +154,7 @@ public class PreloaderSVG extends AbstractImagePreloader { private ImageInfo createImageInfo(String uri, ImageContext context, SVGDocument doc) { Element e = doc.getRootElement(); - float pxUnitToMillimeter = 25.4f / context.getSourceResolution(); + float pxUnitToMillimeter = UnitConv.IN2MM / context.getSourceResolution(); UserAgent userAg = new SimpleSVGUserAgent(pxUnitToMillimeter, new AffineTransform()) { @@ -183,9 +184,12 @@ public class PreloaderSVG extends AbstractImagePreloader { float height = UnitProcessor.svgVerticalLengthToUserSpace( s, SVGOMDocument.SVG_HEIGHT_ATTRIBUTE, uctx); + int widthMpt = (int)Math.round(px2mpt(width, context.getSourceResolution())); + int heightMpt = (int)Math.round(px2mpt(height, context.getSourceResolution())); + ImageInfo info = new ImageInfo(uri, MimeConstants.MIME_SVG); ImageSize size = new ImageSize(); - size.setSizeInMillipoints(Math.round(width * 1000), Math.round(height * 1000)); + size.setSizeInMillipoints(widthMpt, heightMpt); //Set the resolution to that of the FOUserAgent size.setResolution(context.getSourceResolution()); size.calcPixelsFromSize(); @@ -209,4 +213,8 @@ public class PreloaderSVG extends AbstractImagePreloader { } + private static double px2mpt(double px, double resolution) { + return px * 1000 * UnitConv.IN2PT / resolution; + } + } diff --git a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java index 17eb44049..b6dd4d082 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockContainerLayoutManager.java @@ -251,12 +251,11 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager List returnList = new LinkedList(); if (!breakBeforeServed) { - try { + breakBeforeServed = true; + if (!context.suppressBreakBefore()) { if (addKnuthElementsForBreakBefore(returnList, context)) { return returnList; } - } finally { - breakBeforeServed = true; } } @@ -281,6 +280,10 @@ public class BlockContainerLayoutManager extends BlockStackingLayoutManager childLC.setStackLimitBP(MinOptMax.subtract(context.getStackLimitBP(), stackLimit)); childLC.setRefIPD(relDims.ipd); childLC.setWritingMode(getBlockContainerFO().getWritingMode()); + if (curLM == this.childLMs.get(0)) { + childLC.setFlags(LayoutContext.SUPPRESS_BREAK_BEFORE); + //Handled already by the parent (break collapsing, see above) + } // get elements from curLM returnedList = curLM.getNextKnuthElements(childLC, alignment); diff --git a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java index 1d6662cb2..8837b1a0f 100644 --- a/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/BlockStackingLayoutManager.java @@ -31,11 +31,13 @@ import org.apache.fop.area.Area; import org.apache.fop.area.Block; import org.apache.fop.area.BlockParent; import org.apache.fop.fo.FObj; +import org.apache.fop.fo.properties.BreakPropertySet; import org.apache.fop.fo.properties.CommonBorderPaddingBackground; import org.apache.fop.fo.properties.SpaceProperty; import org.apache.fop.layoutmgr.inline.InlineLayoutManager; import org.apache.fop.layoutmgr.inline.LineLayoutManager; import org.apache.fop.traits.MinOptMax; +import org.apache.fop.util.BreakUtil; import org.apache.fop.util.ListUtil; /** @@ -255,12 +257,11 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager List returnList = new LinkedList(); if (!breakBeforeServed) { - try { + breakBeforeServed = true; + if (!context.suppressBreakBefore()) { if (addKnuthElementsForBreakBefore(returnList, context)) { return returnList; } - } finally { - breakBeforeServed = true; } } @@ -294,6 +295,10 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager childLC.setStackLimitBP(context.getStackLimitBP()); childLC.setRefIPD(referenceIPD); } + if (curLM == this.childLMs.get(0)) { + childLC.setFlags(LayoutContext.SUPPRESS_BREAK_BEFORE); + //Handled already by the parent (break collapsing, see above) + } // get elements from curLM returnedList = curLM.getNextKnuthElements(childLC, alignment); @@ -1004,18 +1009,7 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager */ protected boolean addKnuthElementsForBreakBefore(List returnList, LayoutContext context) { - int breakBefore = -1; - if (fobj instanceof org.apache.fop.fo.flow.Block) { - breakBefore = ((org.apache.fop.fo.flow.Block) fobj).getBreakBefore(); - } else if (fobj instanceof org.apache.fop.fo.flow.BlockContainer) { - breakBefore = ((org.apache.fop.fo.flow.BlockContainer) fobj).getBreakBefore(); - } else if (fobj instanceof org.apache.fop.fo.flow.ListBlock) { - breakBefore = ((org.apache.fop.fo.flow.ListBlock) fobj).getBreakBefore(); - } else if (fobj instanceof org.apache.fop.fo.flow.ListItem) { - breakBefore = ((org.apache.fop.fo.flow.ListItem) fobj).getBreakBefore(); - } else if (fobj instanceof org.apache.fop.fo.flow.table.Table) { - breakBefore = ((org.apache.fop.fo.flow.table.Table) fobj).getBreakBefore(); - } + int breakBefore = getBreakBefore(); if (breakBefore == EN_PAGE || breakBefore == EN_COLUMN || breakBefore == EN_EVEN_PAGE @@ -1030,6 +1024,27 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager } /** + * Returns the break-before value of the current formatting object. + * @return the break-before value (Constants.EN_*) + */ + private int getBreakBefore() { + int breakBefore = EN_AUTO; + if (fobj instanceof BreakPropertySet) { + breakBefore = ((BreakPropertySet)fobj).getBreakBefore(); + } + if (true /* uncomment to only partially merge: && breakBefore != EN_AUTO*/) { + LayoutManager lm = getChildLM(); + //It is assumed this is only called when the first LM is active. + if (lm instanceof BlockStackingLayoutManager) { + BlockStackingLayoutManager bslm = (BlockStackingLayoutManager)lm; + breakBefore = BreakUtil.compareBreakClasses( + breakBefore, bslm.getBreakBefore()); + } + } + return breakBefore; + } + + /** * Creates Knuth elements for break-after and adds them to the return list. * @param returnList return list to add the additional elements to * @param context the layout context @@ -1038,16 +1053,8 @@ public abstract class BlockStackingLayoutManager extends AbstractLayoutManager protected boolean addKnuthElementsForBreakAfter(List returnList, LayoutContext context) { int breakAfter = -1; - if (fobj instanceof org.apache.fop.fo.flow.Block) { - breakAfter = ((org.apache.fop.fo.flow.Block) fobj).getBreakAfter(); - } else if (fobj instanceof org.apache.fop.fo.flow.BlockContainer) { - breakAfter = ((org.apache.fop.fo.flow.BlockContainer) fobj).getBreakAfter(); - } else if (fobj instanceof org.apache.fop.fo.flow.ListBlock) { - breakAfter = ((org.apache.fop.fo.flow.ListBlock) fobj).getBreakAfter(); - } else if (fobj instanceof org.apache.fop.fo.flow.ListItem) { - breakAfter = ((org.apache.fop.fo.flow.ListItem) fobj).getBreakAfter(); - } else if (fobj instanceof org.apache.fop.fo.flow.table.Table) { - breakAfter = ((org.apache.fop.fo.flow.table.Table) fobj).getBreakAfter(); + if (fobj instanceof BreakPropertySet) { + breakAfter = ((BreakPropertySet)fobj).getBreakAfter(); } if (breakAfter == EN_PAGE || breakAfter == EN_COLUMN diff --git a/src/java/org/apache/fop/layoutmgr/LayoutContext.java b/src/java/org/apache/fop/layoutmgr/LayoutContext.java index 1be89304b..8b716dfde 100644 --- a/src/java/org/apache/fop/layoutmgr/LayoutContext.java +++ b/src/java/org/apache/fop/layoutmgr/LayoutContext.java @@ -47,12 +47,10 @@ public class LayoutContext { public static final int CHECK_REF_AREA = 0x08; /** - * If this flag is set, it indicates that any leading fo:character - * objects with suppress-at-line-break="suppress" should not generate - * areas. This is the case at the beginning of each new LineArea - * except the first. + * If this flag is set, it indicates that any break-before values other than "auto" should + * not cause a mandatory break as this break was already handled by a parent layout manager. */ - public static final int SUPPRESS_LEADING_SPACE = 0x10; + public static final int SUPPRESS_BREAK_BEFORE = 0x10; public static final int FIRST_AREA = 0x20; public static final int TRY_HYPHENATE = 0x40; public static final int LAST_AREA = 0x80; @@ -227,8 +225,8 @@ public class LayoutContext { return ((this.flags & LAST_AREA) != 0); } - public boolean suppressLeadingSpace() { - return ((this.flags & SUPPRESS_LEADING_SPACE) != 0); + public boolean suppressBreakBefore() { + return ((this.flags & SUPPRESS_BREAK_BEFORE) != 0); } /** @@ -655,7 +653,7 @@ public class LayoutContext { + "\nSpace Adjust: \t" + getSpaceAdjust() + "\nIPD Adjust: \t" + getIPDAdjust() + "\nResolve Leading Space: \t" + resolveLeadingSpace() - + "\nSuppress Leading Space: \t" + suppressLeadingSpace() + + "\nSuppress Break Before: \t" + suppressBreakBefore() + "\nIs First Area: \t" + isFirstArea() + "\nStarts New Area: \t" + startsNewArea() + "\nIs Last Area: \t" + isLastArea() diff --git a/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java b/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java index f027922f7..d83cca642 100644 --- a/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/list/ListItemLayoutManager.java @@ -197,12 +197,11 @@ public class ListItemLayoutManager extends BlockStackingLayoutManager List returnList = new LinkedList(); if (!breakBeforeServed) { - try { + breakBeforeServed = true; + if (!context.suppressBreakBefore()) { if (addKnuthElementsForBreakBefore(returnList, context)) { return returnList; } - } finally { - breakBeforeServed = true; } } diff --git a/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java b/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java index c32c6eb3d..c1fc19050 100644 --- a/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java +++ b/src/java/org/apache/fop/layoutmgr/table/ColumnSetup.java @@ -184,10 +184,22 @@ public class ColumnSetup { * @return the computed base unit (in millipoint) */ protected double computeTableUnit(TableLayoutManager tlm) { + return computeTableUnit(tlm, tlm.getContentAreaIPD()); + } + + /** + * Works out the base unit for resolving proportional-column-width() + * [p-c-w(x) = x * base_unit_ipd] + * + * @param percentBaseContext the percent base context for relative values + * @param contentAreaIPD the IPD of the available content area + * @return the computed base unit (in millipoints) + */ + public float computeTableUnit(PercentBaseContext percentBaseContext, int contentAreaIPD) { int sumCols = 0; float factors = 0; - double unit = 0; + float unit = 0; /* calculate the total width (specified absolute/percentages), * and work out the total number of factors to use to distribute @@ -196,7 +208,7 @@ public class ColumnSetup { for (Iterator i = colWidths.iterator(); i.hasNext();) { Length colWidth = (Length) i.next(); if (colWidth != null) { - sumCols += colWidth.getValue(tlm); + sumCols += colWidth.getValue(percentBaseContext); if (colWidth instanceof RelativeNumericProperty) { factors += ((RelativeNumericProperty) colWidth).getTableUnits(); } else if (colWidth instanceof TableColLength) { @@ -209,8 +221,8 @@ public class ColumnSetup { * factors (if any) */ if (factors > 0) { - if (sumCols < tlm.getContentAreaIPD()) { - unit = (tlm.getContentAreaIPD() - sumCols) / factors; + if (sumCols < contentAreaIPD) { + unit = (contentAreaIPD - sumCols) / factors; } else { log.warn("No space remaining to distribute over columns."); } diff --git a/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java b/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java index 143c63bb9..dc2b3cc46 100644 --- a/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/table/TableLayoutManager.java @@ -267,12 +267,14 @@ public class TableLayoutManager extends BlockStackingLayoutManager } addKnuthElementsForSpaceAfter(returnList, alignment); - //addKnuthElementsForBreakBefore(returnList, context); - int breakBefore = BreakUtil.compareBreakClasses(getTable().getBreakBefore(), - childLC.getBreakBefore()); - if (breakBefore != Constants.EN_AUTO) { - returnList.add(0, new BreakElement(getAuxiliaryPosition(), 0, - -KnuthElement.INFINITE, breakBefore, context)); + if (!context.suppressBreakBefore()) { + //addKnuthElementsForBreakBefore(returnList, context); + int breakBefore = BreakUtil.compareBreakClasses(getTable().getBreakBefore(), + childLC.getBreakBefore()); + if (breakBefore != Constants.EN_AUTO) { + returnList.add(0, new BreakElement(getAuxiliaryPosition(), 0, + -KnuthElement.INFINITE, breakBefore, context)); + } } //addKnuthElementsForBreakAfter(returnList, context); diff --git a/src/java/org/apache/fop/render/PrintRendererConfigurator.java b/src/java/org/apache/fop/render/PrintRendererConfigurator.java index 93c5353ba..001a99dca 100644 --- a/src/java/org/apache/fop/render/PrintRendererConfigurator.java +++ b/src/java/org/apache/fop/render/PrintRendererConfigurator.java @@ -43,6 +43,8 @@ import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.FopFactory; import org.apache.fop.fonts.EmbedFontInfo; import org.apache.fop.fonts.FontCache; +import org.apache.fop.fonts.FontEventAdapter; +import org.apache.fop.fonts.FontEventListener; import org.apache.fop.fonts.FontInfo; import org.apache.fop.fonts.FontManager; import org.apache.fop.fonts.FontResolver; @@ -107,8 +109,10 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator boolean strict = factory.validateUserConfigStrictly(); FontCache fontCache = fontManager.getFontCache(); + FontEventListener listener = new FontEventAdapter( + renderer.getUserAgent().getEventBroadcaster()); List/*<EmbedFontInfo>*/ embedFontInfoList = buildFontListFromConfiguration(cfg, - fontResolver, strict, fontManager); + fontResolver, strict, fontManager, listener); if (fontCache != null && fontCache.hasChanged()) { fontCache.save(); @@ -123,12 +127,14 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator * @param fontResolver the FontResolver to use * @param strict true if an Exception should be thrown if an error is found. * @param fontManager the font manager + * @param listener a font event listener * @return a List of EmbedFontInfo objects. * @throws FOPException If an error occurs while processing the configuration */ public static List/*<EmbedFontInfo>*/ buildFontListFromConfiguration(Configuration cfg, FontResolver fontResolver, - boolean strict, FontManager fontManager) throws FOPException { + boolean strict, FontManager fontManager, + FontEventListener listener) throws FOPException { FontCache fontCache = fontManager.getFontCache(); String fontBaseURL = fontManager.getFontBaseURL(); List/*<EmbedFontInfo>*/ fontInfoList @@ -157,7 +163,8 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator fontFileFinder.find(fontBase.getAbsolutePath()), fontInfoList, fontResolver, - fontCache + fontCache, + listener ); } } catch (IOException e) { @@ -171,7 +178,8 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator fontFileFinder.find(), fontInfoList, fontResolver, - fontCache + fontCache, + listener ); } catch (IOException e) { LogUtil.handleException(log, e, strict); @@ -180,12 +188,12 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator // load fonts from classpath addFontInfoListFromFileList(ClasspathResource.getInstance() .listResourcesOfMimeType("application/x-font"), - fontInfoList, fontResolver, fontCache); + fontInfoList, fontResolver, fontCache, listener); addFontInfoListFromFileList( ClasspathResource.getInstance() .listResourcesOfMimeType( "application/x-font-truetype"), - fontInfoList, fontResolver, fontCache); + fontInfoList, fontResolver, fontCache, listener); } // directory (multiple font) configuration @@ -210,7 +218,8 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator fontFileFinder.find(directory), fontInfoList, fontResolver, - fontCache + fontCache, + listener ); } catch (IOException e) { LogUtil.handleException(log, e, strict); @@ -221,7 +230,7 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator Configuration[] font = fonts.getChildren("font"); for (int i = 0; i < font.length; i++) { EmbedFontInfo embedFontInfo = getFontInfoFromConfiguration( - font[i], fontResolver, strict, fontCache); + font[i], fontResolver, strict, fontCache, listener); if (embedFontInfo != null) { fontInfoList.add(embedFontInfo); } @@ -265,11 +274,12 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator */ private static void addFontInfoListFromFileList( List fontFileList, List/*<EmbedFontInfo>*/ embedFontInfoList, - FontResolver resolver, FontCache fontCache) { + FontResolver resolver, FontCache fontCache, FontEventListener listener) { for (Iterator iter = fontFileList.iterator(); iter.hasNext();) { URL fontUrl = (URL)iter.next(); // parse font to ascertain font info FontInfoFinder finder = new FontInfoFinder(); + finder.setEventListener(listener); //EmbedFontInfo fontInfo = finder.find(fontUrl, resolver, fontCache); //List<EmbedFontInfo> embedFontInfoList = finder.find(fontUrl, resolver, fontCache); @@ -345,7 +355,8 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator * @throws FOPException if something's wrong with the config data */ private static EmbedFontInfo getFontInfoFromConfiguration( - Configuration fontCfg, FontResolver fontResolver, boolean strict, FontCache fontCache) + Configuration fontCfg, FontResolver fontResolver, boolean strict, + FontCache fontCache, FontEventListener listener) throws FOPException { String metricsUrl = fontCfg.getAttribute("metrics-url", null); String embedUrl = fontCfg.getAttribute("embed-url", null); @@ -397,6 +408,7 @@ public class PrintRendererConfigurator extends AbstractRendererConfigurator } if (fontFile != null) { FontInfoFinder finder = new FontInfoFinder(); + finder.setEventListener(listener); EmbedFontInfo[] infos = finder.find(fontUrl, fontResolver, fontCache); return infos[0]; //When subFont is set, only one font is returned } else { diff --git a/src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java b/src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java index 7c4d66689..e3f510853 100644 --- a/src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java +++ b/src/java/org/apache/fop/render/awt/viewer/PreviewDialog.java @@ -38,7 +38,6 @@ import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.print.PrinterException; import java.awt.print.PrinterJob; - import java.text.DecimalFormat; import java.text.DecimalFormatSymbols; import java.util.Locale; @@ -60,8 +59,8 @@ import javax.swing.JToolBar; import javax.swing.KeyStroke; import javax.swing.SwingUtilities; -import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.FOPException; +import org.apache.fop.apps.FOUserAgent; import org.apache.fop.render.awt.AWTRenderer; /** @@ -76,6 +75,8 @@ public class PreviewDialog extends JFrame implements StatusListener { protected AWTRenderer renderer; /** The FOUserAgent associated with this window */ protected FOUserAgent foUserAgent; + /** The originally configured target resolution */ + protected float configuredTargetResolution; /** * Renderable instance that can be used to reload and re-render a document after * modifications. @@ -107,6 +108,7 @@ public class PreviewDialog extends JFrame implements StatusListener { public PreviewDialog(FOUserAgent foUserAgent, Renderable renderable) { renderer = (AWTRenderer) foUserAgent.getRendererOverride(); this.foUserAgent = foUserAgent; + this.configuredTargetResolution = this.foUserAgent.getTargetResolution(); this.renderable = renderable; translator = new Translator(); @@ -551,23 +553,23 @@ public class PreviewDialog extends JFrame implements StatusListener { } private void scaleActionPerformed(ActionEvent e) { - try { - int index = scale.getSelectedIndex(); - if (index == 0) { - setScale(previewPanel.getScaleToFitWindow() * 100); - } else if (index == 1) { - setScale(previewPanel.getScaleToFitWidth() * 100); - } else { - String item = (String)scale.getSelectedItem(); - setScale(Double.parseDouble(item.substring(0, item.indexOf('%')))); - } - } catch (FOPException fopEx) { - fopEx.printStackTrace(); + int index = scale.getSelectedIndex(); + if (index == 0) { + setScaleToFitWindow(); + } else if (index == 1) { + setScaleToFitWidth(); + } else { + String item = (String)scale.getSelectedItem(); + setScale(Double.parseDouble(item.substring(0, item.indexOf('%')))); } } /** Prints the document */ public void startPrinterJob(boolean showDialog) { + //Restore originally configured target resolution + float saveResolution = foUserAgent.getTargetResolution(); + foUserAgent.setTargetResolution(this.configuredTargetResolution); + PrinterJob pj = PrinterJob.getPrinterJob(); pj.setPageable(renderer); if (!showDialog || pj.printDialog()) { @@ -577,6 +579,8 @@ public class PreviewDialog extends JFrame implements StatusListener { e.printStackTrace(); } } + + foUserAgent.setTargetResolution(saveResolution); } /** diff --git a/src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java b/src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java index 05e03fda0..f8152a978 100644 --- a/src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java +++ b/src/java/org/apache/fop/render/awt/viewer/PreviewPanel.java @@ -23,6 +23,7 @@ import java.awt.Color; import java.awt.Dimension; import java.awt.GridLayout; import java.awt.Point; +import java.awt.Toolkit; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; @@ -36,11 +37,12 @@ import javax.swing.JViewport; import javax.swing.SwingUtilities; import javax.swing.border.EmptyBorder; +import org.apache.xmlgraphics.util.UnitConv; + import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.apps.MimeConstants; import org.apache.fop.area.PageViewport; - import org.apache.fop.render.awt.AWTRenderer; @@ -155,6 +157,8 @@ public class PreviewPanel extends JPanel { this.renderable = renderable; this.renderer = renderer; this.foUserAgent = foUserAgent; + //Override target resolution for the computer screen + this.foUserAgent.setTargetResolution(Toolkit.getDefaultToolkit().getScreenResolution()); gridPanel = new JPanel(); gridPanel.setLayout(new GridLayout(0, 1)); // rows, cols @@ -393,8 +397,10 @@ public class PreviewPanel extends JPanel { public double getScaleToFit(double viewWidth, double viewHeight) throws FOPException { PageViewport pageViewport = renderer.getPageViewport(currentPage); Rectangle2D pageSize = pageViewport.getViewArea(); - double widthScale = viewWidth / (pageSize.getWidth() / 1000f); - double heightScale = viewHeight / (pageSize.getHeight() / 1000f); + float screenResolution = Toolkit.getDefaultToolkit().getScreenResolution(); + float screenFactor = screenResolution / UnitConv.IN2PT; + double widthScale = viewWidth / (pageSize.getWidth() / 1000f) / screenFactor; + double heightScale = viewHeight / (pageSize.getHeight() / 1000f) / screenFactor; return Math.min(displayMode == CONT_FACING ? widthScale / 2 : widthScale, heightScale); } diff --git a/src/java/org/apache/fop/render/rtf/BorderAttributesConverter.java b/src/java/org/apache/fop/render/rtf/BorderAttributesConverter.java index 216802c8f..10c4a9c92 100644 --- a/src/java/org/apache/fop/render/rtf/BorderAttributesConverter.java +++ b/src/java/org/apache/fop/render/rtf/BorderAttributesConverter.java @@ -75,10 +75,12 @@ public final class BorderAttributesConverter { // Add padding to corresponding space (space-before or space-after) // if side == START or END, do nothing - if (side == CommonBorderPaddingBackground.BEFORE) { - attributes.addIntegerValue(padding, RtfText.SPACE_BEFORE); - } else if (side == CommonBorderPaddingBackground.AFTER) { - attributes.addIntegerValue(padding, RtfText.SPACE_AFTER); + if (padding != 0) { + if (side == CommonBorderPaddingBackground.BEFORE) { + attributes.addIntegerValue(padding, RtfText.SPACE_BEFORE); + } else if (side == CommonBorderPaddingBackground.AFTER) { + attributes.addIntegerValue(padding, RtfText.SPACE_AFTER); + } } } } diff --git a/src/java/org/apache/fop/render/rtf/FoUnitsConverter.java b/src/java/org/apache/fop/render/rtf/FoUnitsConverter.java index caf11323f..33a2ff904 100644 --- a/src/java/org/apache/fop/render/rtf/FoUnitsConverter.java +++ b/src/java/org/apache/fop/render/rtf/FoUnitsConverter.java @@ -19,10 +19,9 @@ package org.apache.fop.render.rtf; -import java.util.Map; import java.util.HashMap; +import java.util.Map; -//FOP import org.apache.fop.apps.FOPException; import org.apache.fop.fo.properties.FixedLength; @@ -143,4 +142,8 @@ final class FoUnitsConverter { // RTF font size units are in half-points return (int)(result * 2.0); } + + public float convertMptToTwips(int width) { + return width * POINT_TO_TWIPS / 1000; + } } diff --git a/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java b/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java index c7f97ef4f..d50a81656 100644 --- a/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java +++ b/src/java/org/apache/fop/render/rtf/PageAttributesConverter.java @@ -21,6 +21,7 @@ package org.apache.fop.render.rtf; import org.apache.commons.logging.Log; import org.apache.commons.logging.impl.SimpleLog; + import org.apache.fop.datatypes.Length; import org.apache.fop.fo.Constants; import org.apache.fop.fo.expr.NumericOp; @@ -58,6 +59,8 @@ final class PageAttributesConverter { attrib.setTwips(RtfPage.PAGE_WIDTH, pagemaster.getPageWidth()); attrib.setTwips(RtfPage.PAGE_HEIGHT, pagemaster.getPageHeight()); + //Sets the document level property + attrib.set(RtfPage.ITAP, "0"); Object widthRaw = attrib.getValue(RtfPage.PAGE_WIDTH); Object heightRaw = attrib.getValue(RtfPage.PAGE_HEIGHT); @@ -102,7 +105,7 @@ final class PageAttributesConverter { if (after != null) { afterBottom = (Length) NumericOp.addition(pageBottom, after.getExtent()); } - attrib.setTwips(RtfPage.FOOTERY, beforeTop); + attrib.setTwips(RtfPage.FOOTERY, afterBottom); } catch (Exception e) { log.error("Exception in convertPageAttributes: " + e.getMessage() + "- page attributes ignored"); diff --git a/src/java/org/apache/fop/render/rtf/RTFHandler.java b/src/java/org/apache/fop/render/rtf/RTFHandler.java index 1adba9e2b..65c7bf681 100644 --- a/src/java/org/apache/fop/render/rtf/RTFHandler.java +++ b/src/java/org/apache/fop/render/rtf/RTFHandler.java @@ -20,6 +20,8 @@ package org.apache.fop.render.rtf; // Java +import java.awt.Dimension; +import java.awt.Rectangle; import java.awt.geom.Point2D; import java.io.FileNotFoundException; import java.io.IOException; @@ -51,12 +53,13 @@ import org.apache.xmlgraphics.image.loader.util.ImageUtil; import org.apache.fop.apps.FOPException; import org.apache.fop.apps.FOUserAgent; import org.apache.fop.datatypes.LengthBase; -import org.apache.fop.datatypes.SimplePercentBaseContext; +import org.apache.fop.datatypes.PercentBaseContext; import org.apache.fop.events.ResourceEventProducer; import org.apache.fop.fo.Constants; import org.apache.fop.fo.FOEventHandler; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FOText; +import org.apache.fop.fo.FObj; import org.apache.fop.fo.XMLObj; import org.apache.fop.fo.flow.AbstractGraphics; import org.apache.fop.fo.flow.BasicLink; @@ -74,6 +77,7 @@ import org.apache.fop.fo.flow.ListItem; import org.apache.fop.fo.flow.ListItemBody; import org.apache.fop.fo.flow.ListItemLabel; import org.apache.fop.fo.flow.PageNumber; +import org.apache.fop.fo.flow.PageNumberCitation; import org.apache.fop.fo.flow.table.Table; import org.apache.fop.fo.flow.table.TableBody; import org.apache.fop.fo.flow.table.TableFooter; @@ -89,8 +93,10 @@ import org.apache.fop.fo.pagination.Region; import org.apache.fop.fo.pagination.SimplePageMaster; import org.apache.fop.fo.pagination.StaticContent; import org.apache.fop.fo.properties.CommonBorderPaddingBackground; -import org.apache.fop.fo.properties.FixedLength; +import org.apache.fop.fo.properties.EnumLength; import org.apache.fop.fonts.FontSetup; +import org.apache.fop.layoutmgr.inline.ImageLayout; +import org.apache.fop.layoutmgr.table.ColumnSetup; import org.apache.fop.render.DefaultFontResolver; import org.apache.fop.render.RendererEventProducer; import org.apache.fop.render.rtf.rtflib.rtfdoc.IRtfAfterContainer; @@ -110,6 +116,7 @@ import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfFootnote; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfHyperLink; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfList; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfListItem; +import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfPage; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfSection; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTable; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableCell; @@ -117,6 +124,7 @@ import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTableRow; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfTextrun; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfListItem.RtfListItemLabel; import org.apache.fop.render.rtf.rtflib.tools.BuilderContext; +import org.apache.fop.render.rtf.rtflib.tools.PercentContext; import org.apache.fop.render.rtf.rtflib.tools.TableContext; /** @@ -150,6 +158,10 @@ public class RTFHandler extends FOEventHandler { private SimplePageMaster pagemaster; + private int nestedTableDepth = 1; + + private PercentContext percentManager = new PercentContext(); + /** * Creates a new RTF structure handler. * @param userAgent the FOUserAgent for this process @@ -173,9 +185,7 @@ public class RTFHandler extends FOEventHandler { eventProducer.ioError(this, ioe); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startDocument() throws SAXException { // TODO sections should be created try { @@ -187,9 +197,7 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endDocument() throws SAXException { try { rtfFile.flush(); @@ -199,9 +207,7 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startPageSequence(PageSequence pageSeq) { try { //This is needed for region handling @@ -240,6 +246,14 @@ public class RTFHandler extends FOEventHandler { builderContext.pushContainer(sect); + //Calculate usable page width for this flow + int useAblePageWidth = pagemaster.getPageWidth().getValue() + - pagemaster.getCommonMarginBlock().marginLeft.getValue() + - pagemaster.getCommonMarginBlock().marginRight.getValue() + - sect.getRtfAttributes().getValueAsInteger(RtfPage.MARGIN_LEFT).intValue() + - sect.getRtfAttributes().getValueAsInteger(RtfPage.MARGIN_RIGHT).intValue(); + percentManager.setDimension(pageSeq, useAblePageWidth); + bHeaderSpecified = false; bFooterSpecified = false; } catch (IOException ioe) { @@ -247,9 +261,7 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endPageSequence(PageSequence pageSeq) { if (bDefer) { //If endBlock was called while SAX parsing, and the passed FO is Block @@ -267,9 +279,7 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startFlow(Flow fl) { if (bDefer) { return; @@ -357,9 +367,7 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endFlow(Flow fl) { if (bDefer) { return; @@ -384,9 +392,7 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startBlock(Block bl) { if (bDefer) { return; @@ -414,10 +420,7 @@ public class RTFHandler extends FOEventHandler { } } - - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endBlock(Block bl) { if (bDefer) { @@ -443,9 +446,7 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startBlockContainer(BlockContainer blc) { if (bDefer) { return; @@ -472,9 +473,7 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endBlockContainer(BlockContainer bl) { if (bDefer) { return; @@ -499,9 +498,7 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startTable(Table tbl) { if (bDefer) { return; @@ -519,6 +516,8 @@ public class RTFHandler extends FOEventHandler { = TableAttributesConverter.convertTableAttributes(tbl); RtfTable table = tc.newTable(atts, tableContext); + table.setNestedTableDepth(nestedTableDepth); + nestedTableDepth++; CommonBorderPaddingBackground border = tbl.getCommonBorderPaddingBackground(); RtfAttributes borderAttributes = new RtfAttributes(); @@ -545,53 +544,32 @@ public class RTFHandler extends FOEventHandler { builderContext.pushTableContext(tableContext); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endTable(Table tbl) { if (bDefer) { return; } + nestedTableDepth--; builderContext.popTableContext(); builderContext.popContainer(); } - /** - * - * @param tc TableColumn that is starting; - */ - + /** {@inheritDoc} */ public void startColumn(TableColumn tc) { if (bDefer) { return; } try { - /** - * Pass a SimplePercentBaseContext to getValue in order to - * avoid a NullPointerException, which occurs when you use - * proportional-column-width function in column-width attribute. - * Of course the results won't be correct, but at least the - * rest of the document will be rendered. Usage of the - * TableLayoutManager is not welcome due to design reasons and - * it also does not provide the correct values. - * TODO: Make proportional-column-width working for rtf output - */ - SimplePercentBaseContext context - = new SimplePercentBaseContext(null, - LengthBase.TABLE_UNITS, - 100000); - - Integer iWidth - = new Integer(tc.getColumnWidth().getValue(context) / 1000); + int iWidth = tc.getColumnWidth().getValue(percentManager); + percentManager.setDimension(tc, iWidth); - String strWidth = iWidth.toString() + FixedLength.POINT; - Float width = new Float( - FoUnitsConverter.getInstance().convertToTwips(strWidth)); + //convert to twips + Float width = new Float(FoUnitsConverter.getInstance().convertMptToTwips(iWidth)); builderContext.getTableContext().setNextColumnWidth(width); builderContext.getTableContext().setNextColumnRowSpanning( - new Integer(0), null); + new Integer(0), null); builderContext.getTableContext().setNextFirstSpanningCol(false); } catch (Exception e) { log.error("startColumn: " + e.getMessage()); @@ -599,49 +577,34 @@ public class RTFHandler extends FOEventHandler { } } - /** - * - * @param tc TableColumn that is ending; - */ - + /** {@inheritDoc} */ public void endColumn(TableColumn tc) { if (bDefer) { return; } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startHeader(TableHeader header) { startPart(header); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endHeader(TableHeader header) { endPart(header); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startFooter(TableFooter footer) { startPart(footer); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endFooter(TableFooter footer) { endPart(footer); } - /** - * - * @param inl Inline that is starting. - */ + /** {@inheritDoc} */ public void startInline(Inline inl) { if (bDefer) { return; @@ -669,10 +632,7 @@ public class RTFHandler extends FOEventHandler { } } - /** - * - * @param inl Inline that is ending. - */ + /** {@inheritDoc} */ public void endInline(Inline inl) { if (bDefer) { return; @@ -735,10 +695,7 @@ public class RTFHandler extends FOEventHandler { startPart(body); } - - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endBody(TableBody body) { endPart(body); } @@ -775,9 +732,7 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endRow(TableRow tr) { if (bDefer) { return; @@ -814,9 +769,7 @@ public class RTFHandler extends FOEventHandler { builderContext.getTableContext().decreaseRowSpannings(); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startCell(TableCell tc) { if (bDefer) { return; @@ -868,7 +821,6 @@ public class RTFHandler extends FOEventHandler { //process number-columns-spanned attribute if (numberColumnsSpanned > 0) { // Get the number of columns spanned - RtfTable table = row.getTable(); tctx.setCurrentFirstSpanningCol(true); // We widthdraw one cell because the first cell is already created @@ -876,6 +828,8 @@ public class RTFHandler extends FOEventHandler { for (int i = 0; i < numberColumnsSpanned - 1; ++i) { tctx.selectNextColumn(); + //aggregate width for further elements + width += tctx.getColumnWidth(); tctx.setCurrentFirstSpanningCol(false); RtfTableCell hCell = row.newTableCellMergedHorizontally( 0, null); @@ -890,10 +844,12 @@ public class RTFHandler extends FOEventHandler { cell.getRtfAttributes()); } else { tctx.setCurrentColumnRowSpanning( - new Integer(numberRowsSpanned), null); + new Integer(numberRowsSpanned), cell.getRtfAttributes()); } } } + //save width of the cell, convert from twips to mpt + percentManager.setDimension(tc, (int)width * 50); builderContext.pushContainer(cell); } catch (IOException ioe) { @@ -904,9 +860,7 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endCell(TableCell tc) { if (bDefer) { return; @@ -917,9 +871,7 @@ public class RTFHandler extends FOEventHandler { } // Lists - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startList(ListBlock lb) { if (bDefer) { return; @@ -944,9 +896,7 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endList(ListBlock lb) { if (bDefer) { return; @@ -955,9 +905,7 @@ public class RTFHandler extends FOEventHandler { builderContext.popContainer(); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startListItem(ListItem li) { if (bDefer) { return; @@ -995,9 +943,7 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endListItem(ListItem li) { if (bDefer) { return; @@ -1006,9 +952,7 @@ public class RTFHandler extends FOEventHandler { builderContext.popContainer(); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startListLabel() { if (bDefer) { return; @@ -1028,9 +972,7 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endListLabel() { if (bDefer) { return; @@ -1039,46 +981,32 @@ public class RTFHandler extends FOEventHandler { builderContext.popContainer(); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startListBody() { } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endListBody() { } // Static Regions - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startStatic() { } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endStatic() { } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startMarkup() { } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endMarkup() { } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startLink(BasicLink basicLink) { if (bDefer) { return; @@ -1109,9 +1037,7 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endLink() { if (bDefer) { return; @@ -1120,9 +1046,7 @@ public class RTFHandler extends FOEventHandler { builderContext.popContainer(); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void image(ExternalGraphic eg) { if (bDefer) { return; @@ -1153,16 +1077,14 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void foreignObject(InstreamForeignObject ifo) { if (bDefer) { return; } try { - XMLObj child = (XMLObj) ifo.getChildXMLObj(); + XMLObj child = ifo.getChildXMLObj(); Document doc = child.getDOMDocument(); String ns = child.getNamespaceURI(); @@ -1191,7 +1113,8 @@ public class RTFHandler extends FOEventHandler { FOUserAgent userAgent = ifo.getUserAgent(); ImageManager manager = userAgent.getFactory().getImageManager(); - Image converted = manager.convertImage(image, FLAVORS); + Map hints = ImageUtil.getDefaultHints(ua.getImageSessionContext()); + Image converted = manager.convertImage(image, FLAVORS, hints); putGraphic(ifo, converted); } catch (ImageException ie) { @@ -1242,7 +1165,7 @@ public class RTFHandler extends FOEventHandler { throws IOException { byte[] rawData = null; - ImageInfo info = image.getInfo(); + final ImageInfo info = image.getInfo(); if (image instanceof ImageRawStream) { ImageRawStream rawImage = (ImageRawStream)image; @@ -1261,6 +1184,25 @@ public class RTFHandler extends FOEventHandler { return; } + //Set up percentage calculations + this.percentManager.setDimension(abstractGraphic); + PercentBaseContext pContext = new PercentBaseContext() { + + public int getBaseLength(int lengthBase, FObj fobj) { + switch (lengthBase) { + case LengthBase.IMAGE_INTRINSIC_WIDTH: + return info.getSize().getWidthMpt(); + case LengthBase.IMAGE_INTRINSIC_HEIGHT: + return info.getSize().getHeightMpt(); + default: + return percentManager.getBaseLength(lengthBase, fobj); + } + } + + }; + ImageLayout layout = new ImageLayout(abstractGraphic, pContext, + image.getInfo().getSize().getDimensionMpt()); + final IRtfTextrunContainer c = (IRtfTextrunContainer)builderContext.getContainer( IRtfTextrunContainer.class, true, this); @@ -1273,63 +1215,23 @@ public class RTFHandler extends FOEventHandler { } rtfGraphic.setImageData(rawData); - //set scaling - if (abstractGraphic.getScaling() == Constants.EN_UNIFORM) { - rtfGraphic.setScaling ("uniform"); - } - - //get width - int width = 0; - if (abstractGraphic.getWidth().getEnum() == Constants.EN_AUTO) { - width = info.getSize().getWidthMpt(); - } else { - width = abstractGraphic.getWidth().getValue(); - } - - //get height - int height = 0; - if (abstractGraphic.getWidth().getEnum() == Constants.EN_AUTO) { - height = info.getSize().getHeightMpt(); - } else { - height = abstractGraphic.getHeight().getValue(); - } - - //get content-width - int contentwidth = 0; - if (abstractGraphic.getContentWidth().getEnum() - == Constants.EN_AUTO) { - contentwidth = info.getSize().getWidthMpt(); - } else if (abstractGraphic.getContentWidth().getEnum() - == Constants.EN_SCALE_TO_FIT) { - contentwidth = width; - } else { - //TODO: check, if the value is a percent value - contentwidth = abstractGraphic.getContentWidth().getValue(); - } - - //get content-width - int contentheight = 0; - if (abstractGraphic.getContentHeight().getEnum() - == Constants.EN_AUTO) { - - contentheight = info.getSize().getHeightMpt(); - - } else if (abstractGraphic.getContentHeight().getEnum() - == Constants.EN_SCALE_TO_FIT) { - - contentheight = height; - } else { - //TODO: check, if the value is a percent value - contentheight = abstractGraphic.getContentHeight().getValue(); - } - - //set width in rtf - //newGraphic.setWidth((long) (contentwidth / 1000f) + FixedLength.POINT); - rtfGraphic.setWidth((long) (contentwidth / 50f) + "twips"); - - //set height in rtf - //newGraphic.setHeight((long) (contentheight / 1000f) + FixedLength.POINT); - rtfGraphic.setHeight((long) (contentheight / 50f) + "twips"); + FoUnitsConverter converter = FoUnitsConverter.getInstance(); + Dimension viewport = layout.getViewportSize(); + Rectangle placement = layout.getPlacement(); + int cropLeft = Math.round(converter.convertMptToTwips(-placement.x)); + int cropTop = Math.round(converter.convertMptToTwips(-placement.y)); + int cropRight = Math.round(converter.convertMptToTwips( + -1 * (viewport.width - placement.x - placement.width))); + int cropBottom = Math.round(converter.convertMptToTwips( + -1 * (viewport.height - placement.y - placement.height))); + rtfGraphic.setCropping(cropLeft, cropTop, cropRight, cropBottom); + + int width = Math.round(converter.convertMptToTwips(viewport.width)); + int height = Math.round(converter.convertMptToTwips(viewport.height)); + width += cropLeft + cropRight; + height += cropTop + cropBottom; + rtfGraphic.setWidthTwips(width); + rtfGraphic.setHeightTwips(height); //TODO: make this configurable: // int compression = m_context.m_options.getRtfExternalGraphicCompressionRate (); @@ -1342,15 +1244,11 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void pageRef() { } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startFootnote(Footnote footnote) { if (bDefer) { return; @@ -1375,9 +1273,7 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endFootnote(Footnote footnote) { if (bDefer) { return; @@ -1386,9 +1282,7 @@ public class RTFHandler extends FOEventHandler { builderContext.popContainer(); } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void startFootnoteBody(FootnoteBody body) { if (bDefer) { return; @@ -1409,9 +1303,7 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void endFootnoteBody(FootnoteBody body) { if (bDefer) { return; @@ -1432,10 +1324,28 @@ public class RTFHandler extends FOEventHandler { } } - /** - * {@inheritDoc} - */ + /** {@inheritDoc} */ public void leader(Leader l) { + if (bDefer) { + return; + } + + try { + percentManager.setDimension(l); + RtfAttributes rtfAttr = TextAttributesConverter.convertLeaderAttributes( + l, percentManager); + + IRtfTextrunContainer container + = (IRtfTextrunContainer)builderContext.getContainer( + IRtfTextrunContainer.class, true, this); + RtfTextrun textrun = container.getTextrun(); + + textrun.addLeader(rtfAttr); + + } catch (Exception e) { + log.error("startLeader: " + e.getMessage()); + throw new RuntimeException(e.getMessage()); + } } /** @@ -1469,10 +1379,7 @@ public class RTFHandler extends FOEventHandler { } } - /** - * - * @param pagenum PageNumber that is starting. - */ + /** {@inheritDoc} */ public void startPageNumber(PageNumber pagenum) { if (bDefer) { return; @@ -1497,16 +1404,64 @@ public class RTFHandler extends FOEventHandler { } } - /** - * - * @param pagenum PageNumber that is ending. - */ + /** {@inheritDoc} */ public void endPageNumber(PageNumber pagenum) { if (bDefer) { return; } } + /** {@inheritDoc} */ + public void startPageNumberCitation(PageNumberCitation l) { + if (bDefer) { + return; + } + try { + + IRtfTextrunContainer container + = (IRtfTextrunContainer)builderContext.getContainer( + IRtfTextrunContainer.class, true, this); + RtfTextrun textrun = container.getTextrun(); + + textrun.addPageNumberCitation(l.getRefId()); + + } catch (Exception e) { + log.error("startPageNumberCitation: " + e.getMessage()); + throw new RuntimeException(e.getMessage()); + } + } + + private void prepareTable(Table tab) { + // Allows to receive the available width of the table + percentManager.setDimension(tab); + + // Table gets expanded by half of the border on each side inside Word + // When using wide borders the table gets cut off + int tabDiff = tab.getCommonBorderPaddingBackground().getBorderStartWidth(false) / 2 + + tab.getCommonBorderPaddingBackground().getBorderEndWidth(false); + + // check for "auto" value + if (!(tab.getInlineProgressionDimension().getMaximum(null).getLength() + instanceof EnumLength)) { + // value specified + percentManager.setDimension(tab, + tab.getInlineProgressionDimension().getMaximum(null) + .getLength().getValue(percentManager) + - tabDiff); + } else { + // set table width again without border width + percentManager.setDimension(tab, percentManager.getBaseLength( + LengthBase.CONTAINING_BLOCK_WIDTH, tab) - tabDiff); + } + + ColumnSetup columnSetup = new ColumnSetup(tab); + //int sumOfColumns = columnSetup.getSumOfColumnWidths(percentManager); + float tableWidth = percentManager.getBaseLength(LengthBase.CONTAINING_BLOCK_WIDTH, tab); + float tableUnit = columnSetup.computeTableUnit(percentManager, Math.round(tableWidth)); + percentManager.setTableUnit(tab, Math.round(tableUnit)); + + } + /** * Calls the appropriate event handler for the passed FObj. * @@ -1659,6 +1614,16 @@ public class RTFHandler extends FOEventHandler { } else { endCell( (TableCell) foNode); } + } else if (foNode instanceof Leader) { + if (bStart) { + leader((Leader) foNode); + } + } else if (foNode instanceof PageNumberCitation) { + if (bStart) { + startPageNumberCitation((PageNumberCitation) foNode); + } else { + endPageNumberCitation((PageNumberCitation) foNode); + } } else { RTFEventProducer eventProducer = RTFEventProducer.Provider.get( getUserAgent().getEventBroadcaster()); @@ -1701,9 +1666,12 @@ public class RTFHandler extends FOEventHandler { //recurse all table-columns if (table.getColumns() != null) { - for (Iterator it = table.getColumns().iterator(); it.hasNext();) { - recurseFONode( (FONode) it.next() ); - } + //Calculation for column-widths which are not set + prepareTable(table); + + for (Iterator it = table.getColumns().iterator(); it.hasNext();) { + recurseFONode( (FONode) it.next() ); + } } else { //TODO Implement implicit column setup handling! RTFEventProducer eventProducer = RTFEventProducer.Provider.get( diff --git a/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java b/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java index 792193b15..63c470b5d 100644 --- a/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java +++ b/src/java/org/apache/fop/render/rtf/TextAttributesConverter.java @@ -21,25 +21,30 @@ package org.apache.fop.render.rtf; import java.awt.Color; -//FOP +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + import org.apache.fop.apps.FOPException; import org.apache.fop.datatypes.Length; +import org.apache.fop.datatypes.PercentBaseContext; import org.apache.fop.fo.Constants; import org.apache.fop.fo.FONode; import org.apache.fop.fo.FOText; import org.apache.fop.fo.flow.Block; import org.apache.fop.fo.flow.BlockContainer; import org.apache.fop.fo.flow.Inline; +import org.apache.fop.fo.flow.Leader; import org.apache.fop.fo.flow.PageNumber; import org.apache.fop.fo.properties.CommonBorderPaddingBackground; import org.apache.fop.fo.properties.CommonFont; import org.apache.fop.fo.properties.CommonMarginBlock; import org.apache.fop.fo.properties.CommonTextDecoration; -import org.apache.fop.render.rtf.BorderAttributesConverter; +import org.apache.fop.fo.properties.PercentLength; import org.apache.fop.render.rtf.rtflib.rtfdoc.IBorderAttributes; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfAttributes; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfColorTable; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfFontManager; +import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfLeader; import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfText; /** Converts FO properties to RtfAttributes @@ -53,6 +58,8 @@ import org.apache.fop.render.rtf.rtflib.rtfdoc.RtfText; */ final class TextAttributesConverter { + private static Log log = LogFactory.getLog(TextAttributesConverter.class); + /** * Constructor is private, because it's just a utility class. */ @@ -137,6 +144,131 @@ final class TextAttributesConverter { return attrib; } + + /** + * Converts FO properties used by RtfLeader to RtfAttributes. + * @param fobj Leader + * @param context PercentBaseContext + * @return RtfAttributes + * @throws FOPException + */ + public static RtfAttributes convertLeaderAttributes(Leader fobj, PercentBaseContext context) + throws FOPException { + boolean tab = false; + FOPRtfAttributes attrib = new FOPRtfAttributes(); + attrib.set(RtfText.ATTR_FONT_FAMILY, + RtfFontManager.getInstance().getFontNumber(fobj.getCommonFont().getFirstFontFamily())); + + if (fobj.getLeaderLength() != null) { + attrib.set(RtfLeader.LEADER_WIDTH, convertMptToTwips(fobj.getLeaderLength().getMaximum( + context).getLength().getValue(context))); + + if (fobj.getLeaderLength().getMaximum(context) instanceof PercentLength) { + if (((PercentLength)fobj.getLeaderLength().getMaximum(context)).getString().equals( + "100.0%")) { + // Use Tab instead of white spaces + attrib.set(RtfLeader.LEADER_USETAB, 1); + tab = true; + } + } + } + + attrFontColor(fobj.getColor(), attrib); + + if (fobj.getLeaderPatternWidth() != null) { + //TODO calculate pattern width not possible for white spaces, because its using + //underlines for tab it would work with LEADER_PATTERN_WIDTH (expndtw) + } + + switch(fobj.getLeaderPattern()) { + case Constants.EN_DOTS: + if (tab) { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_TAB_DOTTED); + } else { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_DOTTED); + } + break; + case Constants.EN_SPACE: + //nothing has to be set for spaces + break; + case Constants.EN_RULE: + //Things like start-indent, space-after, ... not supported? + //Leader class does not offer these properties + //TODO aggregate them with the leader width or + // create a second - blank leader - before + + if (fobj.getRuleThickness() != null) { + //TODO See inside RtfLeader, better calculation for + //white spaces would be necessary + //attrib.set(RtfLeader.LEADER_RULE_THICKNESS, + // fobj.getRuleThickness().getValue(context)); + log.warn("RTF: fo:leader rule-thickness not supported"); + } + + switch (fobj.getRuleStyle()) { + case Constants.EN_SOLID: + if (tab) { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_TAB_THICK); + } else { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_THICK); + } + break; + case Constants.EN_DASHED: + if (tab) { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_TAB_MIDDLEDOTTED); + } else { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_MIDDLEDOTTED); + } + break; + case Constants.EN_DOTTED: + if (tab) { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_TAB_DOTTED); + } else { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_DOTTED); + } + break; + case Constants.EN_DOUBLE: + if (tab) { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_TAB_EQUAL); + } else { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_EQUAL); + } + break; + case Constants.EN_GROOVE: + if (tab) { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_TAB_HYPHENS); + } else { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_HYPHENS); + } + break; + case Constants.EN_RIDGE: + if (tab) { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_TAB_UNDERLINE); + } else { + attrib.set(RtfLeader.LEADER_TABLEAD, RtfLeader.LEADER_UNDERLINE); + } + break; + default: + break; + } + break; + case Constants.EN_USECONTENT: + log.warn("RTF: fo:leader use-content not supported"); + break; + default: + break; + } + + if (fobj.getLeaderAlignment() == Constants.EN_REFERENCE_AREA) { + log.warn("RTF: fo:leader reference-area not supported"); + } + return attrib; + } + + private static int convertMptToTwips(int mpt) { + return Math.round(FoUnitsConverter.getInstance().convertMptToTwips(mpt)); + } + private static void attrFont(CommonFont font, FOPRtfAttributes rtfAttr) { rtfAttr.set(RtfText.ATTR_FONT_FAMILY, RtfFontManager.getInstance().getFontNumber(font.getFirstFontFamily())); diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAttributes.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAttributes.java index 2eb95b587..5ec5e907e 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAttributes.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfAttributes.java @@ -28,6 +28,7 @@ package org.apache.fop.render.rtf.rtflib.rtfdoc; import java.util.HashMap; import java.util.Iterator; + import org.xml.sax.Attributes; import org.xml.sax.helpers.AttributesImpl; @@ -164,6 +165,15 @@ implements java.lang.Cloneable { } /** + * Returns a value as an Integer. The value is simply cast to an Integer. + * @param name String containing attribute name + * @return the value of an attribute, null if not found + */ + public Integer getValueAsInteger(String name) { + return (Integer)values.get(name); + } + + /** * @param name String containing attribute name * @return true if given attribute is set */ diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java index 182894ea5..6123ac563 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfExternalGraphic.java @@ -269,6 +269,9 @@ public class RtfExternalGraphic extends RtfElement { */ protected boolean scaleUniform = false; + /** cropping on left/top/right/bottom edges for \piccrop*N */ + private int[] cropValues = new int[4]; + /** * Graphic compression rate */ @@ -406,6 +409,7 @@ public class RtfExternalGraphic extends RtfElement { computeImageSize(); writeSizeInfo(); + writeAttributes(getRtfAttributes(), null); for (int i = 0; i < imagedata.length; i++) { int iData = imagedata [i]; @@ -519,6 +523,19 @@ public class RtfExternalGraphic extends RtfElement { writeControlWord("picscaley" + widthDesired * 100 / width); } } + + if (this.cropValues[0] != 0) { + writeOneAttribute("piccropl", new Integer(this.cropValues[0])); + } + if (this.cropValues[1] != 0) { + writeOneAttribute("piccropt", new Integer(this.cropValues[1])); + } + if (this.cropValues[2] != 0) { + writeOneAttribute("piccropr", new Integer(this.cropValues[2])); + } + if (this.cropValues[3] != 0) { + writeOneAttribute("piccropb", new Integer(this.cropValues[3])); + } } ////////////////////////////////////////////////// @@ -546,6 +563,24 @@ public class RtfExternalGraphic extends RtfElement { } /** + * Sets the desired width of the image. + * @param twips The desired image width (in twips) + */ + public void setWidthTwips(int twips) { + this.widthDesired = twips; + this.perCentW = false; + } + + /** + * Sets the desired height of the image. + * @param twips The desired image height (in twips) + */ + public void setHeightTwips(int twips) { + this.heightDesired = twips; + this.perCentH = false; + } + + /** * Sets the flag whether the image size shall be adjusted. * * @param value @@ -553,9 +588,34 @@ public class RtfExternalGraphic extends RtfElement { * false no adjustment */ public void setScaling(String value) { - if (value.equalsIgnoreCase("uniform")) { - this.scaleUniform = true; - } + setUniformScaling("uniform".equalsIgnoreCase(value)); + } + + /** + * Sets the flag whether the image size shall be adjusted. + * + * @param uniform + * true image width or height shall be adjusted automatically\n + * false no adjustment + */ + public void setUniformScaling(boolean uniform) { + this.scaleUniform = uniform; + } + + /** + * Sets cropping values for all four edges for the \piccrop*N commands. + * A positive value crops toward the center of the picture; + * a negative value crops away from the center, adding a space border around the picture + * @param left left cropping value (in twips) + * @param top top cropping value (in twips) + * @param right right cropping value (in twips) + * @param bottom bottom cropping value (in twips) + */ + public void setCropping(int left, int top, int right, int bottom) { + this.cropValues[0] = left; + this.cropValues[1] = top; + this.cropValues[2] = right; + this.cropValues[3] = bottom; } /** diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFontManager.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFontManager.java index 06dbaccd5..6694f0a7d 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFontManager.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfFontManager.java @@ -144,21 +144,22 @@ public final class RtfFontManager { } header.newLine(); - header.writeGroupMark (true); - header.writeControlWord ("fonttbl;"); + header.writeGroupMark(true); + header.writeControlWord("fonttbl"); int len = fontTable.size (); for (int i = 0; i < len; i++) { - header.writeGroupMark (true); + header.writeGroupMark(true); header.newLine(); - header.write ("\\f" + i); - header.write (" " + (String) fontTable.elementAt (i)); - header.writeGroupMark (false); + header.write("\\f" + i); + header.write(" " + (String) fontTable.elementAt (i)); + header.write(";"); + header.writeGroupMark(false); } header.newLine(); - header.writeGroupMark (false); + header.writeGroupMark(false); } diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfLeader.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfLeader.java new file mode 100644 index 000000000..b3f11bc0a --- /dev/null +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfLeader.java @@ -0,0 +1,219 @@ +/* + * 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.render.rtf.rtflib.rtfdoc; + +import java.io.IOException; +import java.io.Writer; +import java.util.Iterator; + +/** + * Generates the leader in RTF. + */ +public class RtfLeader extends RtfContainer { + + /* + * Format : \tqr \style \tx## { \pard \format \tab } + * ## represents the width \style represents the style (tldot, tlth, ...) + * \format represents standard formats (color, fontsize, ...) + * + * + * \pard \zwnj {\fsxx <format> } \zwnj + * + * <format>: \\ulcN Underline color. \\uld Dotted underline. \\uldash Dashed + * underline. \\uldashd Dash-dotted underline. \\uldashdd Dash-dot-dotted + * underline. \\uldb Double underline. \\ulhwave Heavy wave underline. + * \\ulldash Long dashed underline. \\ulnone Stops all underlining. \\ulth + * Thick underline. \\ulthd Thick dotted underline. \\ulthdash Thick dashed + * underline. \\ulthdashd Thick dash-dotted underline. \\ulthdashdd Thick + * dash-dot-dotted underline. \\ulthldash Thick long dashed underline. + * \\ululdbwave Double wave underline. + */ + + private RtfAttributes attrs = null; + + /** Private attribute: tab style */ + public static final String LEADER_TABLEAD = "tablead"; + + /** Private attribute: tab usage indicator */ + public static final String LEADER_USETAB = "tabuse"; + + /** Private attribute: leader width */ + public static final String LEADER_WIDTH = "lwidth"; + + // +++++++++++++++ Styles Underline ++++++++++++++++++++++ + + /** Dotted underline */ + public static final String LEADER_DOTTED = "uld"; // dotted + + /** Dashed underline */ + public static final String LEADER_MIDDLEDOTTED = "uldash"; // dashed + + /** Heavy wave underline */ + public static final String LEADER_HYPHENS = "ulhwave"; // groove + + /** Dash-dot-dotted underline */ + public static final String LEADER_UNDERLINE = "ulthdashdd"; // ridge + + /** Double underline */ + public static final String LEADER_EQUAL = "uldb"; // double + + /** Thick underline */ + public static final String LEADER_THICK = "ulth"; // solid + + // +++++++++++++++ Styles Tabulator +++++++++++++++++++++++ + + /** Leader dots */ + public static final String LEADER_TAB_DOTTED = "tldot"; // dotted + + /** Leader middle dots */ + public static final String LEADER_TAB_MIDDLEDOTTED = "tlmdot"; // dashed + + /** Leader hyphens */ + public static final String LEADER_TAB_HYPHENS = "tlhyph"; // groove + + /** Leader underline */ + public static final String LEADER_TAB_UNDERLINE = "tlul"; // ridge + + /** Leader equal sign */ + public static final String LEADER_TAB_EQUAL = "tleq"; // double + + /** Leader thick line */ + public static final String LEADER_TAB_THICK = "tlth"; // solid + + // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + + /** Resets to default properties */ + public static final String LEADER_IGNORE_STYLE = "pard"; + + /** Font size determines rule thickness */ + public static final String LEADER_RULE_THICKNESS = "fs"; // thickness = fontsize + + /** Expansion or compression of the space between characters in twips */ + public static final String LEADER_PATTERN_WIDTH = "expndtw"; + + /** Zero-width break opportunity */ + public static final String LEADER_ZERO_WIDTH = "zwbo"; + + /** Standard leader width */ + public static final int LEADER_STANDARD_WIDTH = 30; + + /** Move up 4 half-points */ + public static final String LEADER_UP = "up4"; + + /** Negative expansion */ + public static final String LEADER_EXPAND = "expnd-2"; // negative value + // for compression + + /** Tab */ + public static final String LEADER_TAB_VALUE = "tab"; + + /** Right-aligned tab */ + public static final String LEADER_TAB_RIGHT = "tqr"; + + /** Tab width */ + public static final String LEADER_TAB_WIDTH = "tx"; + + RtfLeader(RtfContainer parent, Writer w, RtfAttributes attrs) throws IOException { + super(parent, w); + this.attrs = attrs; + } + + /** {@inheritDoc} */ + protected void writeRtfContent() throws IOException { + + int thickness = LEADER_STANDARD_WIDTH; + String tablead = null; + String tabwidth = null; + for (Iterator it = attrs.nameIterator(); it.hasNext();) { + final String name = (String)it.next(); + if (attrs.isSet(name)) { + if (name.equals(LEADER_TABLEAD)) { + tablead = attrs.getValue(LEADER_TABLEAD).toString(); + } else if (name.equals(LEADER_WIDTH)) { + tabwidth = attrs.getValue(LEADER_WIDTH).toString(); + } + } + } + + if (attrs.getValue(LEADER_RULE_THICKNESS) != null) { + thickness += Integer.parseInt(attrs.getValue(LEADER_RULE_THICKNESS).toString()) + / 1000 * 2; + attrs.unset(LEADER_RULE_THICKNESS); + } + + //Remove private attributes + attrs.unset(LEADER_WIDTH); + attrs.unset(LEADER_TABLEAD); + + // If leader is 100% we use a tabulator, because its more + // comfortable, specially for the table of content + if (attrs.getValue(LEADER_USETAB) != null) { + attrs.unset(LEADER_USETAB); + writeControlWord(LEADER_TAB_RIGHT); + + if (tablead != null) { + writeControlWord(tablead); + } + writeControlWord(LEADER_TAB_WIDTH + tabwidth); + + writeGroupMark(true); + + writeControlWord(LEADER_IGNORE_STYLE); + writeAttributes(attrs, null); + writeControlWord(LEADER_EXPAND); + writeControlWord(LEADER_TAB_VALUE); + + writeGroupMark(false); + + } + // Using white spaces with different underline formats + else { + writeControlWord(LEADER_IGNORE_STYLE); + writeControlWord(LEADER_ZERO_WIDTH); + writeGroupMark(true); + + writeControlWord(LEADER_RULE_THICKNESS + thickness); + + writeControlWord(LEADER_UP); + + super.writeAttributes(attrs, null); + if (tablead != null) { + writeControlWord(tablead); + } + + // Calculation for the necessary amount of white spaces + // Depending on font-size 15 -> 1cm = 7,5 spaces + // TODO for rule-thickness this has to be done better + + for (double d = (Integer.parseInt(tabwidth) / 560) * 7.5; d >= 1; d--) { + RtfStringConverter.getInstance().writeRtfString(writer, " "); + } + + writeGroupMark(false); + writeControlWord(LEADER_ZERO_WIDTH); + } + } + + /** {@inheritDoc} */ + public boolean isEmpty() { + return false; + } + +} diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPage.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPage.java index fb2df3fac..657900574 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPage.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPage.java @@ -60,11 +60,13 @@ extends RtfContainer { public static final String HEADERY = "headery"; /** constant for footer position */ public static final String FOOTERY = "footery"; - + /** constant for itap level */ + public static final String ITAP = "itap"; + /** String array of RtfPage attributes */ public static final String[] PAGE_ATTR = new String[]{ PAGE_WIDTH, PAGE_HEIGHT, LANDSCAPE, MARGIN_TOP, MARGIN_BOTTOM, - MARGIN_LEFT, MARGIN_RIGHT, HEADERY, FOOTERY + MARGIN_LEFT, MARGIN_RIGHT, HEADERY, FOOTERY, ITAP }; /** RtfPage creates new page attributes with the parent container, the writer diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPageNumberCitation.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPageNumberCitation.java index 92ba2bb7f..44c03c316 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPageNumberCitation.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfPageNumberCitation.java @@ -26,8 +26,8 @@ package org.apache.fop.render.rtf.rtflib.rtfdoc; * the FOP project. */ -import java.io.Writer; import java.io.IOException; +import java.io.Writer; /** * @author Christopher Scott, scottc@westinghouse.com @@ -50,9 +50,9 @@ public class RtfPageNumberCitation extends RtfContainer { private String id = null; /** Create an RTF page number citation as a child of given container with default attributes */ - RtfPageNumberCitation (IRtfPageNumberCitationContainer parent, Writer w, String id) + RtfPageNumberCitation (RtfContainer parent, Writer w, String id) throws IOException { - super((RtfContainer)parent, w); + super(parent, w); this.id = id; } @@ -92,7 +92,7 @@ public class RtfPageNumberCitation extends RtfContainer { writeStarControlWord(pageRef); writeGroupMark(false); writeGroupMark(true); - writeControlWord(RTF_FIELD_RESULT); + writeControlWord(RTF_FIELD_RESULT + '#'); //To see where the page-number would be writeGroupMark(false); writeGroupMark(false); } diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTable.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTable.java index eda5644a2..3747103d1 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTable.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTable.java @@ -26,8 +26,8 @@ package org.apache.fop.render.rtf.rtflib.rtfdoc; * the FOP project. */ -import java.io.Writer; import java.io.IOException; +import java.io.Writer; /** Container for RtfRow elements * @author Bertrand Delacretaz bdelacretaz@codeconsult.ch @@ -43,6 +43,9 @@ public class RtfTable extends RtfContainer { * number-columns-spanned attribute */ private ITableColumnsInfo tableContext; + /** Shows the table depth necessary for nested tables */ + private int nestedTableDepth = 0; + /** Create an RTF element as a child of given container */ RtfTable(IRtfTableContainer parent, Writer w, ITableColumnsInfo tc) throws IOException { @@ -213,6 +216,22 @@ public class RtfTable extends RtfContainer { } /** + * Sets the nested table depth. + * @param nestedTableDepth the nested table depth + */ + public void setNestedTableDepth(int nestedTableDepth) { + this.nestedTableDepth = nestedTableDepth; + } + + /** + * Returns the nested table depth. + * @return the nested table depth + */ + public int getNestedTableDepth() { + return this.nestedTableDepth; + } + + /** * Sets the RtfAttributes for the borders of the table. * @param attributes Border attributes of the table. */ diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java index fe936e3f5..f5e5978ec 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTableRow.java @@ -133,11 +133,11 @@ public class RtfTableRow extends RtfContainer implements ITableAttributes { * @throws IOException for I/O problems */ protected void writeRtfContent() throws IOException { - if (getTable().isNestedTable()) { //nested table writeControlWord("intbl"); - writeControlWord("itap2"); + //itap is the depth (level) of the current nested table + writeControlWord("itap" + getTable().getNestedTableDepth()); } else { //normal (not nested) table writeRowAndCellsDefintions(); diff --git a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java index e0703d7ba..a9ba432b1 100644 --- a/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java +++ b/src/java/org/apache/fop/render/rtf/rtflib/rtfdoc/RtfTextrun.java @@ -22,8 +22,8 @@ package org.apache.fop.render.rtf.rtflib.rtfdoc; // Java import java.io.IOException; import java.io.Writer; -import java.util.List; import java.util.Iterator; +import java.util.List; import java.util.ListIterator; // FOP @@ -176,6 +176,15 @@ public class RtfTextrun extends RtfContainer { } /** + * Inserts a page number citation. + * @param refId the identifier being referenced + * @throws IOException for I/O problems + */ + public void addPageNumberCitation(String refId) throws IOException { + RtfPageNumberCitation r = new RtfPageNumberCitation(this, writer, refId); + } + + /** * Pop inline attributes. * * @throws IOException for I/O problems @@ -243,6 +252,15 @@ public class RtfTextrun extends RtfContainer { } /** + * Inserts a leader. + * @param attrs Attributes for the leader + * @throws IOException for I/O problems + */ + public void addLeader(RtfAttributes attrs) throws IOException { + new RtfLeader(this, writer, attrs); + } + + /** * Inserts a page number. * @param attr Attributes for the page number to insert. * @throws IOException for I/O problems diff --git a/src/java/org/apache/fop/render/rtf/rtflib/tools/PercentContext.java b/src/java/org/apache/fop/render/rtf/rtflib/tools/PercentContext.java new file mode 100644 index 000000000..ef9b248f1 --- /dev/null +++ b/src/java/org/apache/fop/render/rtf/rtflib/tools/PercentContext.java @@ -0,0 +1,136 @@ +/* + * 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.render.rtf.rtflib.tools; + +import java.util.Map; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import org.apache.fop.datatypes.LengthBase; +import org.apache.fop.datatypes.PercentBaseContext; +import org.apache.fop.fo.FONode; +import org.apache.fop.fo.FObj; +import org.apache.fop.fo.flow.table.Table; +import org.apache.fop.fo.pagination.PageSequence; + +/** + * PercentBaseContext implementation to track base widths for percentage calculations. + */ +public class PercentContext implements PercentBaseContext { + private static Log log = LogFactory.getLog(PercentContext.class); + + /** Map containing the FObj and its width */ + private Map lengthMap = new java.util.HashMap(); + + /** Map containing the Tables and their table units */ + private Map tableUnitMap = new java.util.HashMap(); + + /** Variable to check if a base width is set */ + private boolean baseWidthSet = false; + + /** + * Returns the available width for a specific FObj + * + * @param lengthBase + * lengthBase not used + * @param fobj + * the FObj + * @return Available Width + */ + public int getBaseLength(int lengthBase, FObj fobj) { + if (fobj == null) { + return 0; + } + switch (lengthBase) { + case LengthBase.CONTAINING_BLOCK_WIDTH: + case LengthBase.PARENT_AREA_WIDTH: + case LengthBase.CONTAINING_REFAREA_WIDTH: + Object width = lengthMap.get(fobj); + if (width != null) { + return Integer.parseInt(width.toString()); + } else { + return -1; + } + case LengthBase.TABLE_UNITS: + Object unit = tableUnitMap.get(fobj); + return (unit != null) ? ((Integer)unit).intValue() : 0; + default: + log.error(new Exception("Unsupported base type for LengthBase:" + lengthBase)); + return 0; + } + } + + /** + * Elements having a width property can call this function if their width is + * calculated in RTFHandler + * + * @param fobj the FObj + * @param width width of the FObj (in millipoints) + */ + public void setDimension(FObj fobj, int width) { + // TODO ACCEPT only objects above for setting a width + if (fobj instanceof PageSequence) { + baseWidthSet = true; + } + // width in mpt + lengthMap.put(fobj, new Integer(width)); + } + + /** + * Records the calculated table unit for a given table. + * @param table the table for which the table unit is set + * @param tableUnit the table unit value (in millipoints) + */ + public void setTableUnit(Table table, int tableUnit) { + tableUnitMap.put(table, new Integer(tableUnit)); + } + + /** + * Searches for the parent object of fobj. + */ + private Integer findParent(FONode fobj) { + if (fobj.getRoot() != fobj) { + if (lengthMap.containsKey(fobj)) { + return new Integer(lengthMap.get(fobj).toString()); + } else { + return findParent(fobj.getParent()); + } + } else { + log.error("Base Value for element " + fobj.getName() + " not found"); + return new Integer(-1); + } + } + + /** + * Elements willing to use this context have to register themselves by + * calling this function. + * + * @param fobj the FObj + */ + public void setDimension(FObj fobj) { + if (baseWidthSet) { + Integer width = findParent(fobj.getParent()); + if (width.intValue() != -1) { + lengthMap.put(fobj, width); + } + } + } +} diff --git a/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java b/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java index 2d1c9279c..03ad4ee71 100644 --- a/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java +++ b/src/java/org/apache/fop/svg/PDFDocumentGraphics2DConfigurator.java @@ -63,7 +63,8 @@ public class PDFDocumentGraphics2DConfigurator { List/*<EmbedFontInfo>*/ embedFontInfoList = PrintRendererConfigurator.buildFontListFromConfiguration( - cfg, fontResolver, false, fontManager); + cfg, fontResolver, false, fontManager, null); + //TODO Wire in the FontEventListener if (fontManager.useCache()) { fontManager.getFontCache().save(); } diff --git a/src/java/org/apache/fop/util/BreakUtil.java b/src/java/org/apache/fop/util/BreakUtil.java index 0e419016e..7302f270c 100644 --- a/src/java/org/apache/fop/util/BreakUtil.java +++ b/src/java/org/apache/fop/util/BreakUtil.java @@ -36,7 +36,8 @@ public final class BreakUtil { case Constants.EN_PAGE: return 2; case Constants.EN_EVEN_PAGE: return 3; case Constants.EN_ODD_PAGE: return 3; - default: throw new IllegalArgumentException(); + default: throw new IllegalArgumentException( + "Illegal value for breakClass: " + breakClass); } } diff --git a/status.xml b/status.xml index 3e37d89a0..a43ebf5e6 100644 --- a/status.xml +++ b/status.xml @@ -50,9 +50,19 @@ <context id="Extensions" title="Changes to the Bundled Extensions"/> <context id="Images" title="Changes to the Image Support"/> </contexts> - + <changes> <release version="FOP Trunk" date="TBD"> + <action context="Renderers" dev="JM" type="fix" fixes-bug="45606" due-to="Pavel Kysilka"> + Fixed generation of "fonttbl" for RTF output to fix loading problem with AbiWord. + </action> + <action context="Layout" dev="JM" type="fix"> + Fixed ID resolution for nested bookmarks with duplicated IDs. + </action> + <action context="Code" dev="AD" type="fix" fixes-bug="45490" due-to="Thomas Stieler"> + Fixed a slight error when resolving non-file URLs: avoid + altering the original 'href' if the protocol is other than 'file:' + </action> <action context="Layout" dev="JM" type="fix" fixes-bug="45470"> Added LayoutManagerMapping.registerMaker() to make registration of custom layout managers easier. @@ -74,10 +84,10 @@ when the page bpd is not the same for all pages. </action> <action context="Code" dev="AD" type="update" importance="high"> - Changed FONode.addCharacters() parameter to closer match the signature of + Changed FONode.addCharacters() parameter to closer match the signature of the standard SAX characters() event (reduces confusion and computations). - <em>!! Implementors of extensions that subclass FONode directly, and - offer an implementation for addCharacters() should take care to make + <em>!! Implementors of extensions that subclass FONode directly, and + offer an implementation for addCharacters() should take care to make similar modifications in their code !!</em> </action> <!-- change reverted, to be added back later @@ -85,7 +95,7 @@ Added SVG support for AFP (GOCA). </action --> <action context="Renderers" dev="JM" type="add" fixes-bug="45115" due-to="Martin Edge"> - Added a PCL-specific extension attribute on simple-page-master for controlling + Added a PCL-specific extension attribute on simple-page-master for controlling the simplex/duplex mode. </action> <action context="Code" dev="AD" type="fix" fixes-bug="45097"> @@ -99,7 +109,7 @@ Support character-by-character font-selection strategy on fo:character element. </action> <action context="Layout" dev="AD" type="fix" fixes-bug="44794"> - Added support for page-number-citation and page-number-citation-last + Added support for page-number-citation and page-number-citation-last of fo:inline. Corrected behavior for page-number-citation-last of fo:block: forward references now properly resolved. </action> @@ -171,13 +181,118 @@ in the font's primary encoding. </action> </release> - <release version="0.95" date="TBD"> + <release version="0.95" date="05 August 2008"> + <notes> + <section> + <title>Notes</title> + <p> + Besides the important changes listed below, the most important areas with + improvements in this release are: + </p> + <ul> + <li> + Many bugfixes in tables, plus some new features (full support for keeps and + breaks, border conditionality, background on columns and header/footer/body) + </li> + <li> + Improvements and bugfixes for font handling and font + auto-detection/-registration. + </li> + <li> + Performance improvements and memory optimizations for the property handling + in the FO tree. + </li> + </ul> + <p> + Please note that with this release, we've dropped support for Java 1.3. + FOP will, from now on, <strong>require at least Java 1.4</strong>. + </p> + <p> + There have been a few changes in tables that make FOP both more strict and more + compliant to the Recommendation: + <ul> + <li>XSL-FO 1.1 explicitly states that a row-spanning fo:table-cell element is not + allowed to span further than its enclosing fo:table-header/footer/body element + (see bottom of <link href="http://www.w3.org/TR/xsl11/#fo_table">section + 6.7.3</link>). From now on FOP will give a validation error if a document + contains such an erroneous cell. + </li> + <li> + <p>If an fo:table element contains explicit fo:table-column children, then those + elements set the total number of columns in the table. This means that a + validation error will now occur if a row contains more cells than available + columns. This change allows to improve performance, since the rendering of the + table may start as soon as the table-column elements have been parsed.</p> + <p>If more flexibility is needed, then the fo:table-column elements may be just + omitted. The final number of columns will then be set by the row that has the + most cells.</p> + </li> + </ul> + </p> + <p> + The image libraries Jimi and JAI are no longer needed (and used) for image loading. + Instead we rely completely on the Image I/O API that has been introduced with + Java 1.4. If you still need support for bitmap image formats that do not work + out-of-the-box, we recommend adding + <link href="http://jai-imageio.dev.java.net/">JAI Image I/O Tools</link> + (an Image I/O compatible image codec package) to the classpath. JAI is still required + for building the FOP distribution but it is optional for normal builds and at run-time. + </p> + <note> + This final 0.95 release also includes all of the + <a href="changes_0.95beta.html">changes made for Apache FOP 0.95beta</a>. + </note> + </section> + </notes> <action context="Renderers" dev="JM" type="fix"> - Fixed positioning of absolutely positioned block-containers in multi-column documents. + Fixed a color selection problem which occurred after an image has been painted + through the Graphics2DAdapter in PDF output. + </action> + <action context="Renderers" dev="JM" type="fix" fixes-bug="41306"> + Fixed page ordering problem with AWTRenderer. + </action> + <action context="Renderers" dev="JM" type="fix" fixes-bug="39980"> + Fixed image scaling for RTF output. + </action> + <action context="API" dev="JM" type="fix"> + Fixed the -imagein command-line option. + </action> + <action context="Renderers" dev="JM" type="add" fixes-bug="43825" due-to="Maximilian Aster"> + Added support for fo:leader for RTF output (no full support!). Fixes problems with empty leaders + being used to force empty lines among other issues. + </action> + <action context="Renderers" dev="JM" type="add" fixes-bug="43824" due-to="Maximilian Aster"> + Added support for page-number-citation for RTF output. + </action> + <action context="Renderers" dev="JM" type="fix" fixes-bug="43606" due-to="Maximilian Aster"> + Fixed handling of proportional-column-width() and percentages for table column in RTF + output. + </action> + <action context="Layout" dev="AD" type="fix" fixes-bug="45295"> + Fixed NullPointerException when page-number-citations are used inside a marker. + </action> + <action context="Images" dev="JM" type="fix"> + Fixed two bugs concerning resolution handling with SVG images and their + conversion to bitmaps for RTF output. + </action> + <action context="Code" dev="JM" type="fix" fixes-bug="44887" importance="high"> + Fixed potential multi-threading problem concerning the use of DecimalFormat. + </action> + <action context="Layout" dev="JM" type="fix" fixes-bug="44412"> + Regression bugfix: Multiple collapsible breaks don't cause empty pages anymore. </action> <action context="Renderers" dev="JM" type="fix"> + Fixed resolution handling inside AWT preview dialog. + </action> + <action context="Renderers" dev="JM" type="fix" importance="high"> + Fixed positioning of absolutely positioned block-containers in multi-column documents. + </action> + <action context="Renderers" dev="JM" type="fix" importance="high"> Fixed rendering of fixed block-containers in AFP output. </action> + <action context="Layout" dev="VH" type="fix" fixes-bug="44621" importance="high"> + Various bugfixes for table layout. + </action> <action context="Renderers" dev="JM" type="fix"> Fixed regression causing bad positioning of block-containers if used as descendant of a table-cell. @@ -393,7 +508,7 @@ will make up an entire page. See the documentation for details. </action> <action context="Layout" dev="JM" type="add"> - Added minimal support for the .minimum/.maximum components of block/inline-progression-dimension + Added minimal support for the .minimum/.maximum components of block/inline-progression-dimension on fo:external-graphic and fo:instream-foreign-object. </action> <action context="Layout" dev="JM" type="add" importance="high"> @@ -522,7 +637,7 @@ Fix to avoid a ClassCastException in renderer configuration. </action> <action context="Renderers" dev="JM" type="fix" fixes-bug="43439" due-to="Adrian Cumiskey"> - Fixed the restoration of the TLE values from the intermediate format + Fixed the restoration of the TLE values from the intermediate format for the AFP extension elements. </action> <action context="Renderers" dev="JM" type="add" fixes-bug="43041" due-to="Adrian Cumiskey"> @@ -538,9 +653,9 @@ <action context="Layout" dev="AD" type="update"> PropertyCache phase 2:<br/> • improvement of the PropertyCache itself should now guarantee acceptable - performance of the static caches in multi-session environments, which is + performance of the static caches in multi-session environments, which is a possible problem with synchronizedMap.<br/> - • changed CommonFont to use the cache: + • changed CommonFont to use the cache: added CachedCommonFont to contain the properties that are always cacheable CommonFont itself is only cached if the remaining properties are absolutes.<br/> • changed CommonHyphenation, KeepProperty, ColorProperty and FontFamilyProperty to use the cache.<br/> @@ -555,7 +670,7 @@ <action context="Layout" dev="AD" type="fix" fixes-bug="43274" due-to="ckohrn.at.tng.de"> Fixed erroneous usage of inherited color-values in SVG. </action> - </release> + </release> <release version="0.94" date="24th August 2007"> <action context="Code" dev="JM" type="fix"> AFP Renderer: Bugfix for 1 bit images where the width is not a multiple of 8. @@ -588,7 +703,7 @@ -> changed implementations of FObj.addChildNode(), .removeChild() and .getChildNodes() </action> <action context="Code" dev="AD" type="update" fixes-bug="42089" due-to="Adrian Cumiskey"> - Code cleanup and restructuring: + Code cleanup and restructuring: Refactoring of PageSequenceLayoutManager and provide common FObj id property use </action> <action context="Code" dev="AD" type="add"> @@ -677,7 +792,7 @@ the available ipd, causing a restart. </action> <action context="Code" dev="JM" type="fix"> - Fix for PDF corruption when a TrueType font with spaces in its name is embedded and no + Fix for PDF corruption when a TrueType font with spaces in its name is embedded and no XML font metrics file for that font is used. </action> <action context="Code" dev="JM" type="fix" fixes-bug="41426" due-to="Adrian Cumiskey"> @@ -700,7 +815,7 @@ <action context="Code" dev="MM" type="add" importance="high"> Added support for UAX#14 type line breaking. Support does not extend across nested fo:inline elements. </action> - </release> + </release> <release version="0.93" date="9 January 2007"> <notes> <section> @@ -741,10 +856,10 @@ Enabled Copy/Paste from PDF content in Acrobat Reader for text using embedded TrueType fonts. </action> <action context="Code" dev="SP" type="update" fixes-bug="41044" due-to="Richard Wheeldon"> - Commented out unused properties, in order to minimize memory usage. + Commented out unused properties, in order to minimize memory usage. </action> <action context="Code" dev="SP" type="update" fixes-bug="41009" due-to="Richard Wheeldon"> - Removed unused attributes from TableCell. + Removed unused attributes from TableCell. </action> <action context="Code" dev="JM" type="add"> Added initial support for loading fonts without a pre-created XML font metric @@ -752,7 +867,7 @@ </action> <action context="Code" dev="JM" type="add" fixes-bug="40729" due-to="Peter Coppens" importance="high"> Support for the rgb-icc() function and for a proprietary cmyk() function (for device CMYK - colors only through the PDF renderer so far). + colors only through the PDF renderer so far). </action> <action context="Code" dev="JM" type="update" fixes-bug="40813" due-to="Richard Wheeldon"> Minor fixes and improvements for the AWT Preview (keyboard shortcuts, scrolling, windows @@ -782,7 +897,7 @@ white background in order to produce bitmap output with transparency. </action> <action context="Code" dev="AD" type="fix" fixes-bug="39414"> - Split up FOText instances larger than 32K characters to avoid + Split up FOText instances larger than 32K characters to avoid integer overflow during layout. </action> <action context="Code" dev="JM" type="fix"> @@ -800,7 +915,7 @@ Added relaxed validation for empty list-item-*, as suggested by Gary Reed. </action> <action context="Code" dev="AD" type="update"> - Modified proportional-column-width() function to log an error if used + Modified proportional-column-width() function to log an error if used with table-layout=auto </action> <action context="Code" dev="AD" type="fix"> @@ -820,7 +935,7 @@ Bugfix: Table headers and footers were swallowed when a table was nested in a list-block. </action> <action context="Code" dev="JM" type="fix"> - Fixed a bug with indent handling when margins are used on a surrounding block and + Fixed a bug with indent handling when margins are used on a surrounding block and not start/end-indent. </action> <action context="Code" dev="JM" type="fix" fixes-bug="40106" due-to="Jeroen Meijer"> @@ -843,7 +958,7 @@ (Note: the use of pixels in XSL-FO is discouraged!) </action> <action context="Code" dev="JM" type="fix"> - Bugfix: Potential multi-threading issue (ConcurrentModificationException) + Bugfix: Potential multi-threading issue (ConcurrentModificationException) eliminated for ElementMapping classes. </action> <action context="Code" dev="JM" type="fix"> @@ -891,7 +1006,7 @@ Bugfix: All fonts names were converted unnecessarily to lower case in RTF output. </action> <action context="Code" dev="JM" type="fix"> - Bugfix: The combination of hyphenation and kerning resulted in slightly ragged + Bugfix: The combination of hyphenation and kerning resulted in slightly ragged right ends for right-aligned and justified text. </action> <action context="Code" dev="JM" type="fix"> @@ -903,7 +1018,7 @@ table-columns. </action> <action context="Code" dev="JM" type="fix" fixes-bug="39607" due-to="Julien Aymé"> - Bugfix: NullPointerException in RTF library when there are no borders on + Bugfix: NullPointerException in RTF library when there are no borders on the parent table. </action> <action context="Code" dev="JM" type="add" importance="high"> @@ -942,7 +1057,7 @@ in a block-container. </action> <action context="Code" dev="JM" type="fix"> - Bugfix: basic-links with internal destinations in documents with multiple + Bugfix: basic-links with internal destinations in documents with multiple page-sequences sometimes pointed at the wrong page. </action> <action context="Code" dev="JM" type="fix"> @@ -954,14 +1069,14 @@ Bugfix: Fixed OutOfMemoryException with long data URLs (RFC 2397). </action> <action context="Code" dev="JM" type="add" fixes-bug="39118" due-to="Pierre-Henri Kraus"> - Initial support for page-number-citation-last (XSL 1.1). Works without problems + Initial support for page-number-citation-last (XSL 1.1). Works without problems only for page-sequence so far. </action> </release> <release version="0.92beta" date="18 Apr 2006"> <action context="Code" dev="JM" type="fix"> Bugfix: The generation of the PDF "d" (setdash) command was assuming that - only integer values can be used but that isn't the case. Dash patterns + only integer values can be used but that isn't the case. Dash patterns PDFGraphics2D would be wrong in the process. </action> <action context="Code" dev="JM" type="fix"> @@ -995,7 +1110,7 @@ FOP 0.20.5. (See "hyphenation-base" option in the user configuration) </action> <action context="Code" dev="JM" type="fix"> - Bugfix: Certain filter combinations in PDF could lead to invalid PDFs. + Bugfix: Certain filter combinations in PDF could lead to invalid PDFs. DecodeParams were not properly handled. </action> <action context="Code" dev="JM" type="fix"> @@ -1061,19 +1176,19 @@ Added support for the from-table-column() function. </action> <action context="Code" dev="JM" type="fix" fixes-bug="38397"> - Bugfix: Spanned cells could lead to an false error message about overlapping + Bugfix: Spanned cells could lead to an false error message about overlapping cells and ultimately a NullPointerException. </action> <action context="Code" dev="JM" type="fix"> - Bugfix: Regions with non-standard names got ignored in RTF output leading to + Bugfix: Regions with non-standard names got ignored in RTF output leading to missing headers and footers. </action> <action context="Code" dev="JM" type="fix"> - The RTF output now properly generates the "\landscape" flag for documents in + The RTF output now properly generates the "\landscape" flag for documents in landscape orientation. </action> <action context="Code" dev="JM" type="fix"> - Following a clarification by the XSL FO SG, space traits are only set on the + Following a clarification by the XSL FO SG, space traits are only set on the first and last area generated by an FO, and not on every area anymore. </action> <action context="Code" dev="JM" type="add"> @@ -1184,7 +1299,7 @@ was not rendered at all. </action> <action context="Code" dev="JM" type="fix"> - Fixed a bug where the area for a finished cell that is broken over pages was + Fixed a bug where the area for a finished cell that is broken over pages was created once for each row it was spanned over instead of only once. </action> <action context="Code" dev="JM" type="add"> @@ -1235,7 +1350,7 @@ <action context="Code" dev="JM" type="add"> Added an alternative set of rules for calculating text indents which tries to mimic the behaviour of many commercial FO implementations that chose to break the rules - in the FO specification in order to better meet the natural expectations of + in the FO specification in order to better meet the natural expectations of inexperienced FO users. </action> <action context="Code" dev="JM" type="fix" fixes-bug="37815" due-to="Tom Craddock"> @@ -1255,14 +1370,14 @@ </action> <action context="Code" dev="JM" type="add"> font-family list still not fully supported but a comma-separated list is now properly tokenized. - FOP will now go through all fonts in the list to find one that is available, but it doesn't - do so per character, yet. + FOP will now go through all fonts in the list to find one that is available, but it doesn't + do so per character, yet. </action> <action context="Code" dev="JM" type="add"> Implemented "Overconstrained Geometry" rules (5.3.4, XSL 1.0) for the most important cases. </action> <action context="Code" dev="JM" type="fix"> - Bugfix: Relatively positioned BlockViewports (from block-containers) caused the paint + Bugfix: Relatively positioned BlockViewports (from block-containers) caused the paint cursor not be be properly advanced when space-before or space-after were present. </action> <action context="Code" dev="JM" type="fix"> @@ -1270,12 +1385,12 @@ didn't get removed. </action> <action context="Code" dev="JM" type="fix"> - The validation check for non-zero borders and padding on a region-* and for empty static-content - elements is now turned off when relaxed validation is active to improve compatibility with + The validation check for non-zero borders and padding on a region-* and for empty static-content + elements is now turned off when relaxed validation is active to improve compatibility with FO documents written for other FO implementations. </action> <action context="Code" dev="JM" type="fix"> - Bugfix for "/ by zero" ArithmeticExceptions when an URL to a non-existing image is used + Bugfix for "/ by zero" ArithmeticExceptions when an URL to a non-existing image is used and content-width and/or content-height is used. </action> <action context="Code" dev="JM" type="fix"> @@ -1298,15 +1413,15 @@ </release> <release version="0.90alpha1" date="22 Nov 2005"> <action context="Code" dev="all" type="update"> - <strong>Complete redesign of the FOP codebase</strong> in the period between Dec 2001 and Nov 2005. - There are just too many changes to list here. If you like to know details, run + <strong>Complete redesign of the FOP codebase</strong> in the period between Dec 2001 and Nov 2005. + There are just too many changes to list here. If you like to know details, run <code>"svn log --verbose http://svn.apache.org/repos/asf/xmlgraphics/fop/trunk/"</code>. </action> </release> <release version="0.20.5" date="18 July 2003"> <action context="Code" dev="all" type="update"> - For the change log for the maintenance branch - (where FOP 0.20.5 came from), please see the "CHANGES" file in the distribution, or + For the change log for the maintenance branch + (where FOP 0.20.5 came from), please see the "CHANGES" file in the distribution, or <link href="http://svn.apache.org/viewcvs.cgi/xmlgraphics/fop/branches/fop-0_20_2-maintain/CHANGES?view=markup">the CHANGES file in the SVN repository</link>. </action> </release> @@ -1320,5 +1435,5 @@ </action> </actions> </todo> - + </status> diff --git a/test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java b/test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java index c6c4015cc..457aa91d4 100644 --- a/test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java +++ b/test/java/org/apache/fop/image/loader/batik/ImageLoaderTestCase.java @@ -88,6 +88,51 @@ public class ImageLoaderTestCase extends TestCase { assertEquals(16000, info.getSize().getHeightMpt()); } + public void testSVGNoViewbox() throws Exception { + String uri = "test/resources/images/circles.svg"; + + FopFactory ff = FopFactory.newInstance(); + ff.setSourceResolution(96); + ff.setTargetResolution(300); + + FOUserAgent userAgent = ff.newFOUserAgent(); + + ImageManager manager = ff.getImageManager(); + ImageInfo info = manager.preloadImage(uri, userAgent.getImageSessionContext()); + assertNotNull("ImageInfo must not be null", info); + + Image img = manager.getImage(info, ImageFlavor.XML_DOM, + userAgent.getImageSessionContext()); + assertNotNull("Image must not be null", img); + assertEquals(ImageFlavor.XML_DOM, img.getFlavor()); + ImageXMLDOM imgDom = (ImageXMLDOM)img; + assertNotNull(imgDom.getDocument()); + assertEquals("http://www.w3.org/2000/svg", imgDom.getRootNamespace()); + info = imgDom.getInfo(); //Switch to the ImageInfo returned by the image + assertEquals(96, info.getSize().getDpiHorizontal(), 0); + assertEquals(340158, info.getSize().getWidthMpt()); + assertEquals(340158, info.getSize().getHeightMpt()); + assertEquals(454, info.getSize().getWidthPx()); + assertEquals(454, info.getSize().getHeightPx()); + + img = manager.getImage(info, ImageFlavor.RENDERED_IMAGE, + userAgent.getImageSessionContext()); + assertNotNull("Image must not be null", img); + assertEquals(ImageFlavor.RENDERED_IMAGE, img.getFlavor()); + ImageRendered imgRed = (ImageRendered)img; + assertNotNull(imgRed.getRenderedImage()); + if (DEBUG_TARGET_DIR != null) { + ImageWriterUtil.saveAsPNG(imgRed.getRenderedImage(), + (int)userAgent.getTargetResolution(), + new File(DEBUG_TARGET_DIR, "circles.svg.png")); + } + assertEquals(1418, imgRed.getRenderedImage().getWidth()); + assertEquals(1418, imgRed.getRenderedImage().getHeight()); + info = imgRed.getInfo(); //Switch to the ImageInfo returned by the image + assertEquals(340158, info.getSize().getWidthMpt()); + assertEquals(340158, info.getSize().getHeightMpt()); + } + public void testWMF() throws Exception { String uri = "test/resources/images/testChart.wmf"; diff --git a/test/layoutengine/standard-testcases/block_break-before_bug44412.xml b/test/layoutengine/standard-testcases/block_break-before_bug44412.xml index 9ef4150b5..cc5bcd3c8 100644 --- a/test/layoutengine/standard-testcases/block_break-before_bug44412.xml +++ b/test/layoutengine/standard-testcases/block_break-before_bug44412.xml @@ -20,8 +20,7 @@ <info> <p> This test checks Bugzilla #44412 where a break-before on the first child of an otherwise - empty block is set. It is expected that the parent block creates two areas, the first with - only border-before on the first page and zero bpd. + empty block is set. </p> </info> <fo> @@ -44,20 +43,12 @@ </fo:root> </fo> <checks> - <eval expected="2" xpath="count(//block[@prod-id = 'b1'])"/> - <eval expected="4000 4000 4000 0" xpath="(//block[@prod-id = 'b1'])[1]/@bap"/> - <eval expected="4000 4000 0 4000" xpath="(//block[@prod-id = 'b1'])[2]/@bap"/> - <eval expected="0" xpath="(//block[@prod-id = 'b1'])[1]/@bpd"/> - <eval expected="43200" xpath="(//block[@prod-id = 'b1'])[2]/@bpd"/> + <eval expected="1" xpath="count(//block[@prod-id = 'b1'])"/> + <eval expected="4000 4000 4000 4000" xpath="(//block[@prod-id = 'b1'])[1]/@bap"/> + <eval expected="43200" xpath="(//block[@prod-id = 'b1'])[1]/@bpd"/> <element-list category="breaker" index="0"> <box w="14400"/> - <penalty w="0" p="0"/> - <box w="0" aux="true"/> - <penalty w="0" p="INF"/> - <glue w="4000"/> <!-- border-before --> - <box w="0"/> <!-- first block area of the "b1" block with zero bpd --> - <skip>3</skip> </element-list> </checks> diff --git a/test/layoutengine/standard-testcases/block_break-before_bug44412_2.xml b/test/layoutengine/standard-testcases/block_break-before_bug44412_2.xml new file mode 100644 index 000000000..3f54f809a --- /dev/null +++ b/test/layoutengine/standard-testcases/block_break-before_bug44412_2.xml @@ -0,0 +1,151 @@ +<?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> + This test checks for the correct behaviour of multiple breaks at the same break possibility. + </p> + </info> + <fo> + <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format"> + <fo:layout-master-set> + <fo:simple-page-master master-name="page" page-height="5in" page-width="5in" margin="20pt"> + <fo:region-body/> + <fo:region-after extent="1.2em"/> + </fo:simple-page-master> + </fo:layout-master-set> + <fo:page-sequence master-reference="page" id="ps1" initial-page-number="1" force-page-count="no-force"> + <fo:static-content flow-name="xsl-region-after"> + <fo:block>page: <fo:page-number/></fo:block> + </fo:static-content> + <fo:flow flow-name="xsl-region-body"> + <fo:block id="b1">Before the break</fo:block> + <fo:block break-before="page" break-after="column"> + <fo:block id="b2" break-before="page"> + This text should be on page 2. + </fo:block> + <fo:block> + <fo:block id="b3" break-after="page"> + Inner block with break-after. + </fo:block> + </fo:block> + </fo:block> + <fo:block id="b4">This text should be on page 3.</fo:block> + </fo:flow> + </fo:page-sequence> + <fo:page-sequence master-reference="page" id="ps2" initial-page-number="1" force-page-count="no-force"> + <fo:static-content flow-name="xsl-region-after"> + <fo:block>page: <fo:page-number/></fo:block> + </fo:static-content> + <fo:flow flow-name="xsl-region-body"> + <fo:block id="b11">Before the break</fo:block> + <fo:block-container break-before="page" break-after="column"> + <fo:block-container break-before="page"> + <fo:block id="b12">This text should be on page 2.</fo:block> + </fo:block-container> + <fo:block> + <fo:block id="b13" break-after="page"> + Inner block with break-after. + </fo:block> + </fo:block> + </fo:block-container> + <fo:block id="b14">This text should be on page 3.</fo:block> + </fo:flow> + </fo:page-sequence> + <fo:page-sequence master-reference="page" id="ps3" initial-page-number="1" force-page-count="no-force"> + <fo:static-content flow-name="xsl-region-after"> + <fo:block>page: <fo:page-number/></fo:block> + </fo:static-content> + <fo:flow flow-name="xsl-region-body"> + <fo:block id="b21">Before the break</fo:block> + <fo:block break-before="page" break-after="column"> + <fo:table table-layout="fixed" width="100%" break-before="page"> + <fo:table-column column-width="proportional-column-width(1)"/> + <fo:table-body> + <fo:table-row> + <fo:table-cell> + <fo:block id="b22">This text should be on page 2.</fo:block> + </fo:table-cell> + </fo:table-row> + </fo:table-body> + </fo:table> + <fo:block> + <fo:table table-layout="fixed" width="100%" break-after="page"> + <fo:table-column column-width="proportional-column-width(1)"/> + <fo:table-body> + <fo:table-row> + <fo:table-cell> + <fo:block id="b23">Inner block in table with break-after.</fo:block> + </fo:table-cell> + </fo:table-row> + </fo:table-body> + </fo:table> + </fo:block> + </fo:block> + <fo:block id="b24">This text should be on page 3.</fo:block> + </fo:flow> + </fo:page-sequence> + <fo:page-sequence master-reference="page" id="ps4" initial-page-number="1" force-page-count="no-force"> + <fo:static-content flow-name="xsl-region-after"> + <fo:block>page: <fo:page-number/></fo:block> + </fo:static-content> + <fo:flow flow-name="xsl-region-body"> + <fo:block id="b31">Before the break</fo:block> + <fo:block break-before="page" break-after="column"> + <fo:list-block break-before="page"> + <fo:list-item> + <fo:list-item-label end-indent="label-end()"> + <fo:block>+</fo:block> + </fo:list-item-label> + <fo:list-item-body start-indent="body-start()"> + <fo:block id="b32">This text should be on page 2.</fo:block> + </fo:list-item-body> + </fo:list-item> + <fo:list-item break-after="page"> + <fo:list-item-label end-indent="label-end()"> + <fo:block>+</fo:block> + </fo:list-item-label> + <fo:list-item-body start-indent="body-start()"> + <fo:block id="b33">Inner block in list-item with break-after.</fo:block> + </fo:list-item-body> + </fo:list-item> + </fo:list-block> + </fo:block> + <fo:block id="b34">This text should be on page 3.</fo:block> + </fo:flow> + </fo:page-sequence> + </fo:root> + </fo> + <checks> + <eval expected="1" xpath="//block[@prod-id = 'b1']/ancestor::pageViewport/@nr"/> + <eval expected="2" xpath="//block[@prod-id = 'b2']/ancestor::pageViewport/@nr"/> + <eval expected="2" xpath="//block[@prod-id = 'b3']/ancestor::pageViewport/@nr"/> + <eval expected="3" xpath="//block[@prod-id = 'b4']/ancestor::pageViewport/@nr"/> + + <eval expected="1" xpath="//block[@prod-id = 'b11']/ancestor::pageViewport/@nr"/> + <eval expected="2" xpath="//block[@prod-id = 'b12']/ancestor::pageViewport/@nr"/> + <eval expected="2" xpath="//block[@prod-id = 'b13']/ancestor::pageViewport/@nr"/> + <eval expected="3" xpath="//block[@prod-id = 'b14']/ancestor::pageViewport/@nr"/> + + <eval expected="1" xpath="//block[@prod-id = 'b21']/ancestor::pageViewport/@nr"/> + <eval expected="2" xpath="//block[@prod-id = 'b22']/ancestor::pageViewport/@nr"/> + <eval expected="2" xpath="//block[@prod-id = 'b23']/ancestor::pageViewport/@nr"/> + <eval expected="3" xpath="//block[@prod-id = 'b24']/ancestor::pageViewport/@nr"/> + </checks> +</testcase> diff --git a/test/layoutengine/standard-testcases/bookmarks_2.xml b/test/layoutengine/standard-testcases/bookmarks_2.xml index b66b27bcf..90a801412 100644 --- a/test/layoutengine/standard-testcases/bookmarks_2.xml +++ b/test/layoutengine/standard-testcases/bookmarks_2.xml @@ -34,10 +34,16 @@ <fo:bookmark-tree> <fo:bookmark internal-destination="chapter1"> <fo:bookmark-title>Chapter 1</fo:bookmark-title> + <fo:bookmark internal-destination="chapter1"> + <fo:bookmark-title>Nested Chapter 1</fo:bookmark-title> + </fo:bookmark> </fo:bookmark> <fo:bookmark internal-destination="chapter1" starting-state="hide"> <fo:bookmark-title>Again Chapter 1</fo:bookmark-title> </fo:bookmark> + <fo:bookmark internal-destination="chapter2"> + <fo:bookmark-title>Chapter 2</fo:bookmark-title> + </fo:bookmark> </fo:bookmark-tree> <fo:page-sequence id="page-sequence" master-reference="normal"> <fo:flow flow-name="xsl-region-body"> @@ -58,10 +64,13 @@ <eval expected="Chapter 1" xpath="//bookmarkTree/bookmark[1]/@title"/> <eval expected="true" xpath="//bookmarkTree/bookmark[1]/@show-children"/> + <eval expected="Nested Chapter 1" xpath="//bookmarkTree/bookmark[1]/bookmark[1]/@title"/> + <eval expected="true" xpath="//bookmarkTree/bookmark[1]/bookmark[1]/@show-children"/> <eval expected="Again Chapter 1" xpath="//bookmarkTree/bookmark[2]/@title"/> <eval expected="false" xpath="//bookmarkTree/bookmark[2]/@show-children"/> <eval expected="(P1,chapter1)" xpath="//bookmarkTree/bookmark[1]/@internal-link"/> + <eval expected="(P1,chapter1)" xpath="//bookmarkTree/bookmark[1]/bookmark[1]/@internal-link"/> <eval expected="(P1,chapter1)" xpath="//bookmarkTree/bookmark[2]/@internal-link"/> </checks> diff --git a/test/resources/images/circles.svg b/test/resources/images/circles.svg new file mode 100644 index 000000000..8b71e8224 --- /dev/null +++ b/test/resources/images/circles.svg @@ -0,0 +1,8 @@ +<?xml version="1.0" encoding="UTF-8"?> +<svg xmlns="http://www.w3.org/2000/svg" width="12cm" height="12cm"> + <g style="fill-opacity:0.7; stroke:black; stroke-width:0.1cm;"> + <circle cx="6cm" cy="2cm" r="100" style="fill:red;" transform="translate(0,50)" /> + <circle cx="6cm" cy="2cm" r="100" style="fill:blue;" transform="translate(70,150)" /> + <circle cx="6cm" cy="2cm" r="100" style="fill:green;" transform="translate(-70,150)"/> + </g> +</svg>
\ No newline at end of file |