aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/java/org/apache/fop/apps/MimeConstants.java7
-rw-r--r--src/java/org/apache/fop/cli/CommandLineOptions.java13
-rw-r--r--src/java/org/apache/fop/image/AbstractFopImage.java4
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java2
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java2
-rw-r--r--src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java10
-rw-r--r--src/java/org/apache/fop/render/pdf/FopPDFImage.java6
-rwxr-xr-xtest/layoutengine/disabled-testcases.xml6
-rwxr-xr-xtest/layoutengine/standard-testcases/block_white-space_2.xml14
-rwxr-xr-xtest/layoutengine/standard-testcases/block_white-space_2a.xml57
10 files changed, 107 insertions, 14 deletions
diff --git a/src/java/org/apache/fop/apps/MimeConstants.java b/src/java/org/apache/fop/apps/MimeConstants.java
index f33ddf70f..3b5805dce 100644
--- a/src/java/org/apache/fop/apps/MimeConstants.java
+++ b/src/java/org/apache/fop/apps/MimeConstants.java
@@ -33,6 +33,11 @@ public interface MimeConstants {
/** HP's PCL (alternative MIME type) */
String MIME_PCL_ALT = "application/vnd.hp-PCL";
+ /** IBM's AFP */
+ String MIME_AFP = "application/x-afp";
+ /** IBM's AFP (alternative MIME type) */
+ String MIME_AFP_ALT = "application/vnd.ibm.modcap";
+
/** Plain text */
String MIME_PLAIN_TEXT = "text/plain";
@@ -49,6 +54,8 @@ public interface MimeConstants {
/** Structured Vector Graphics */
String MIME_SVG = "image/svg+xml";
+ /** GIF images */
+ String MIME_GIF = "image/gif";
/** PNG images */
String MIME_PNG = "image/png";
/** JPEG images */
diff --git a/src/java/org/apache/fop/cli/CommandLineOptions.java b/src/java/org/apache/fop/cli/CommandLineOptions.java
index b7553a6ad..c1c069b39 100644
--- a/src/java/org/apache/fop/cli/CommandLineOptions.java
+++ b/src/java/org/apache/fop/cli/CommandLineOptions.java
@@ -226,6 +226,8 @@ public class CommandLineOptions implements Constants {
i = i + parseTextOutputOption(args, i);
} else if (args[i].equals("-svg")) {
i = i + parseSVGOutputOption(args, i);
+ } else if (args[i].equals("-afp")) {
+ i = i + parseAFPOutputOption(args, i);
} else if (args[i].equals("-foout")) {
i = i + parseFOOutputOption(args, i);
} else if (args[i].equals("-out")) {
@@ -440,6 +442,17 @@ public class CommandLineOptions implements Constants {
}
}
+ private int parseAFPOutputOption(String[] args, int i) throws FOPException {
+ setOutputMode(MimeConstants.MIME_AFP);
+ if ((i + 1 == args.length)
+ || (args[i + 1].charAt(0) == '-')) {
+ throw new FOPException("you must specify the AFP output file");
+ } else {
+ outfile = new File(args[i + 1]);
+ return 1;
+ }
+ }
+
private int parseFOOutputOption(String[] args, int i) throws FOPException {
setOutputMode(MimeConstants.MIME_XSL_FO);
if ((i + 1 == args.length)
diff --git a/src/java/org/apache/fop/image/AbstractFopImage.java b/src/java/org/apache/fop/image/AbstractFopImage.java
index e8189c95c..f64fdfb72 100644
--- a/src/java/org/apache/fop/image/AbstractFopImage.java
+++ b/src/java/org/apache/fop/image/AbstractFopImage.java
@@ -20,6 +20,7 @@ package org.apache.fop.image;
// Java
import java.awt.color.ColorSpace;
+import java.awt.color.ICC_ColorSpace;
import java.awt.color.ICC_Profile;
import java.io.InputStream;
import java.awt.Color;
@@ -271,6 +272,9 @@ public abstract class AbstractFopImage implements FopImage {
* @return the icc profile or null if not applicable
*/
public ICC_Profile getICCProfile() {
+ if (this.colorSpace != null && this.colorSpace instanceof ICC_ColorSpace) {
+ return ((ICC_ColorSpace)this.colorSpace).getProfile();
+ }
return null;
}
diff --git a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
index 4eaf30088..fa266b6ba 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
@@ -780,7 +780,7 @@ public class LineLayoutManager extends InlineStackingLayoutManager
"Sequence was empty! lastElement is null");
}
}
- bPrevWasKnuthBox = lastElement.isBox();
+ bPrevWasKnuthBox = lastElement.isBox() && lastElement.getW() != 0;
// if last paragraph is open, add the new elements to the paragraph
// else this is the last paragraph
diff --git a/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
index 3e40dc31f..fedb3d10e 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java
@@ -950,7 +950,7 @@ public class TextLayoutManager extends LeafNodeLayoutManager {
if (textArray[ai.iStartIndex] == NBSPACE) {
spaceElements.add
(new KnuthInlineBox(0, null,
- notifyPos(new LeafPosition(this, -1)), false));
+ notifyPos(new LeafPosition(this, -1)), true));
}
return spaceElements;
}
diff --git a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
index ae87009c8..5821c96a6 100644
--- a/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
+++ b/src/java/org/apache/fop/render/AbstractPathOrientedRenderer.java
@@ -36,7 +36,7 @@ import org.apache.fop.area.inline.Space;
import org.apache.fop.area.inline.Viewport;
import org.apache.fop.datatypes.ColorType;
import org.apache.fop.fo.Constants;
-import org.apache.fop.fonts.Typeface;
+import org.apache.fop.fonts.FontMetrics;
import org.apache.fop.image.FopImage;
import org.apache.fop.traits.BorderProps;
@@ -581,21 +581,21 @@ public abstract class AbstractPathOrientedRenderer extends PrintRenderer {
/**
* Paints the text decoration marks.
- * @param tf Current typeface
+ * @param fm Current typeface
* @param fontsize Current font size
* @param inline inline area to paint the marks for
* @param baseline position of the baseline
* @param startx start IPD
*/
- protected void renderTextDecoration(Typeface tf, int fontsize, InlineArea inline,
+ protected void renderTextDecoration(FontMetrics fm, int fontsize, InlineArea inline,
int baseline, int startx) {
boolean hasTextDeco = inline.hasUnderline()
|| inline.hasOverline()
|| inline.hasLineThrough();
if (hasTextDeco) {
endTextObject();
- float descender = tf.getDescender(fontsize) / 1000f;
- float capHeight = tf.getCapHeight(fontsize) / 1000f;
+ float descender = fm.getDescender(fontsize) / 1000f;
+ float capHeight = fm.getCapHeight(fontsize) / 1000f;
float halfLineWidth = (descender / -8f) / 2f;
float endx = (startx + inline.getIPD()) / 1000f;
if (inline.hasUnderline()) {
diff --git a/src/java/org/apache/fop/render/pdf/FopPDFImage.java b/src/java/org/apache/fop/render/pdf/FopPDFImage.java
index 97fee08f9..e709b26ad 100644
--- a/src/java/org/apache/fop/render/pdf/FopPDFImage.java
+++ b/src/java/org/apache/fop/render/pdf/FopPDFImage.java
@@ -29,7 +29,6 @@ import org.apache.fop.pdf.PDFXObject;
import org.apache.fop.pdf.BitmapImage;
import org.apache.fop.image.FopImage;
-import org.apache.fop.image.JpegImage;
import org.apache.fop.image.EPSImage;
import org.apache.fop.image.TIFFImage;
@@ -82,9 +81,8 @@ public class FopPDFImage implements PDFImage {
pdfFilter.setApplied(true);
isDCT = true;
- JpegImage jpegimage = (JpegImage) fopImage;
- ICC_Profile prof = jpegimage.getICCProfile();
- PDFColorSpace pdfCS = toPDFColorSpace(jpegimage.getColorSpace());
+ ICC_Profile prof = fopImage.getICCProfile();
+ PDFColorSpace pdfCS = toPDFColorSpace(fopImage.getColorSpace());
if (prof != null) {
pdfICCStream = doc.getFactory().makePDFICCStream();
pdfICCStream.setColorSpace(prof, pdfCS);
diff --git a/test/layoutengine/disabled-testcases.xml b/test/layoutengine/disabled-testcases.xml
index 26c0cd63b..412755447 100755
--- a/test/layoutengine/disabled-testcases.xml
+++ b/test/layoutengine/disabled-testcases.xml
@@ -56,6 +56,12 @@
stacking constraints which it shouldn't.</description>
</testcase>
<testcase>
+ <name>Non breaking space removal</name>
+ <file>block_white-space_2.xml</file>
+ <description>A non breaking space is incorrectly
+ removed from the start of a line.</description>
+ </testcase>
+ <testcase>
<name>block white-space-collapse 2</name>
<file>block_white-space-collapse_2.xml</file>
</testcase>
diff --git a/test/layoutengine/standard-testcases/block_white-space_2.xml b/test/layoutengine/standard-testcases/block_white-space_2.xml
index 28fba5721..e1dfa24c0 100755
--- a/test/layoutengine/standard-testcases/block_white-space_2.xml
+++ b/test/layoutengine/standard-testcases/block_white-space_2.xml
@@ -18,7 +18,12 @@
<testcase>
<info>
<p>
- This test checks an empty block
+ This test checks non breaking white space.
+ Note: This test currently fails because the first non breaking space on
+ each line is incorrectly removed. There is a duplicate test
+ block_white-space_2a.xml whose checks have been adjusted to cater for
+ this defect. Once the problem is fixed block_white-space_2a.xml should
+ be removed from the test suite.
</p>
</info>
<fo>
@@ -30,16 +35,19 @@
</fo:layout-master-set>
<fo:page-sequence master-reference="normal" white-space-collapse="true">
<fo:flow flow-name="xsl-region-body">
- <fo:block background-color="silver">before empty line</fo:block>
+ <fo:block background-color="silver">&#160;single&#160;nbsp&#160;around&#160;</fo:block>
<fo:block background-color="red">&#160;</fo:block>
- <fo:block background-color="silver">after empty line</fo:block>
+ <fo:block background-color="silver">&#160;&#160;after&#160;&#160;empty&#160;&#160;line&#160;&#160;</fo:block>
</fo:flow>
</fo:page-sequence>
</fo:root>
</fo>
<checks>
<eval expected="11100" xpath="//flow/block[1]/lineArea/@bpd"/>
+ <eval expected="4" xpath="count(//flow/block[1]/lineArea/text/space)"/>
<eval expected="11100" xpath="//flow/block[2]/lineArea/@bpd"/>
+ <eval expected="1" xpath="count(//flow/block[2]/lineArea/text/space)"/>
<eval expected="11100" xpath="//flow/block[3]/lineArea/@bpd"/>
+ <eval expected="8" xpath="count(//flow/block[3]/lineArea/text/space)"/>
</checks>
</testcase>
diff --git a/test/layoutengine/standard-testcases/block_white-space_2a.xml b/test/layoutengine/standard-testcases/block_white-space_2a.xml
new file mode 100755
index 000000000..c14b0a32f
--- /dev/null
+++ b/test/layoutengine/standard-testcases/block_white-space_2a.xml
@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright 2005 The Apache Software Foundation
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<!-- $Id$ -->
+<testcase>
+ <info>
+ <p>
+ This test checks non breaking white space.
+ Note: This test should fail because the first nb space in each line is
+ incorrectly removed. However, the checks below have been adjusted to
+ cater for this defect so this test passes. This has been done to have some
+ test cases which are being run in the test suite for non breaking spaces.
+ This test is otherwise identical to block_white-space_2.xml. Once the problem
+ is fixed this file can be deleted from the test suite.
+ </p>
+ </info>
+ <fo>
+ <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" xmlns:svg="http://www.w3.org/2000/svg">
+ <fo:layout-master-set>
+ <fo:simple-page-master master-name="normal" page-width="5in" page-height="5in">
+ <fo:region-body/>
+ </fo:simple-page-master>
+ </fo:layout-master-set>
+ <fo:page-sequence master-reference="normal" white-space-collapse="true">
+ <fo:flow flow-name="xsl-region-body">
+ <fo:block background-color="silver">&#160;single&#160;nbsp&#160;around&#160;</fo:block>
+ <fo:block background-color="red">&#160;</fo:block>
+ <fo:block background-color="silver">&#160;&#160;after&#160;&#160;empty&#160;&#160;line&#160;&#160;</fo:block>
+ </fo:flow>
+ </fo:page-sequence>
+ </fo:root>
+ </fo>
+ <checks>
+ <eval expected="11100" xpath="//flow/block[1]/lineArea/@bpd"/>
+ <!--<eval expected="4" xpath="count(//flow/block[1]/lineArea/text/space)"/>-->
+ <eval expected="3" xpath="count(//flow/block[1]/lineArea/text/space)"/>
+ <eval expected="11100" xpath="//flow/block[2]/lineArea/@bpd"/>
+ <!--<eval expected="1" xpath="count(//flow/block[2]/lineArea/text/space)"/>-->
+ <eval expected="0" xpath="count(//flow/block[2]/lineArea/text/space)"/>
+ <eval expected="11100" xpath="//flow/block[3]/lineArea/@bpd"/>
+ <!--<eval expected="8" xpath="count(//flow/block[3]/lineArea/text/space)"/>-->
+ <eval expected="7" xpath="count(//flow/block[3]/lineArea/text/space)"/>
+ </checks>
+</testcase>