aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeremias Maerki <jeremias@apache.org>2005-12-14 16:57:16 +0000
committerJeremias Maerki <jeremias@apache.org>2005-12-14 16:57:16 +0000
commitd958ef6db38f3e80ebaeae60372716f09e51ae1e (patch)
treea3bc459493880dcc54d4a4ee86dc93ff8317a917
parentce832ae088ad9533b4e2ca2ba016fe1d3c954454 (diff)
downloadxmlgraphics-fop-d958ef6db38f3e80ebaeae60372716f09e51ae1e.tar.gz
xmlgraphics-fop-d958ef6db38f3e80ebaeae60372716f09e51ae1e.zip
Don't hyphenate when wrap is set to "no-wrap".
Hack: Work around an NPE in hyphenation when preserved line feeds are found. Documenting a bug where linefeeds are painted as "#" and content is painted multiple times when hyphenation is on and linefeed-treatment="preserve". git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@356804 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java6
-rwxr-xr-xtest/layoutengine/disabled-testcases.xml6
-rw-r--r--test/layoutengine/hyphenation-testcases/block_hyphenation_linefeed_preserve.xml50
-rw-r--r--test/layoutengine/hyphenation-testcases/block_hyphenation_no-wrap.xml48
4 files changed, 109 insertions, 1 deletions
diff --git a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
index dbf9290c2..3eea3b6af 100644
--- a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
+++ b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java
@@ -1064,7 +1064,8 @@ public class LineLayoutManager extends InlineStackingLayoutManager
0 : hyphenationLadderCount.getValue(),
this);
- if (hyphenationProperties.hyphenate == EN_TRUE) {
+ if (hyphenationProperties.hyphenate == EN_TRUE
+ && fobj.getWrapOption() != EN_NO_WRAP) {
findHyphenationPoints(currPar);
}
@@ -1487,7 +1488,10 @@ public class LineLayoutManager extends InlineStackingLayoutManager
} else {
break;
}
+ } else if (currLM == null) {
+ break;
}
+ //TODO Something's not right here. See block_hyphenation_linefeed_preserve.xml
// collect word fragments, ignoring auxiliary elements;
// each word fragment was created by a different TextLM
diff --git a/test/layoutengine/disabled-testcases.xml b/test/layoutengine/disabled-testcases.xml
index 33569e2f6..26c0cd63b 100755
--- a/test/layoutengine/disabled-testcases.xml
+++ b/test/layoutengine/disabled-testcases.xml
@@ -37,6 +37,12 @@
<description>Font-stretch is not implemented, yet.</description>
</testcase>
<testcase>
+ <name>Hyphenation with preserved linefeeds</name>
+ <file>block_hyphenation_linefeed_preserve.xml</file>
+ <description>When hyphenation is enabled and linefeeds are preserved linefeeds
+ are painted as '#' and the text is output multiple times.</description>
+ </testcase>
+ <testcase>
<name>linefeed-treatment</name>
<file>block_linefeed-treatment.xml</file>
<description>Preserved linefeeds in a fo:character are not handled
diff --git a/test/layoutengine/hyphenation-testcases/block_hyphenation_linefeed_preserve.xml b/test/layoutengine/hyphenation-testcases/block_hyphenation_linefeed_preserve.xml
new file mode 100644
index 000000000..3b1ff22df
--- /dev/null
+++ b/test/layoutengine/hyphenation-testcases/block_hyphenation_linefeed_preserve.xml
@@ -0,0 +1,50 @@
+<?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>
+ Regression check for an NPE in a block with no-wrap and hyphenation enabled.
+ </p>
+ </info>
+ <fo>
+ <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" language="en" hyphenate="true">
+ <fo:layout-master-set>
+ <fo:simple-page-master master-name="simple" page-height="5in" page-width="1in">
+ <fo:region-body/>
+ </fo:simple-page-master>
+ </fo:layout-master-set>
+ <fo:page-sequence master-reference="simple">
+ <fo:flow flow-name="xsl-region-body">
+ <fo:block line-height="10pt" background-color="orange"
+ white-space-collapse="false" white-space-treatment="preserve" linefeed-treatment="preserve">Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas semper. Proin at.</fo:block>
+ <fo:block line-height="10pt" background-color="orange"
+ white-space-collapse="false" white-space-treatment="preserve" linefeed-treatment="preserve">
+line1
+line2
+
+Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas semper. Proin at1.
+</fo:block>
+ </fo:flow>
+ </fo:page-sequence>
+ </fo:root>
+ </fo>
+ <checks>
+ <!-- Dummy check. We don't want an NPE. -->
+ <eval expected="2" xpath="count(//*[contains(text(), 'adipiscing')])"/>
+ </checks>
+</testcase>
diff --git a/test/layoutengine/hyphenation-testcases/block_hyphenation_no-wrap.xml b/test/layoutengine/hyphenation-testcases/block_hyphenation_no-wrap.xml
new file mode 100644
index 000000000..61609509f
--- /dev/null
+++ b/test/layoutengine/hyphenation-testcases/block_hyphenation_no-wrap.xml
@@ -0,0 +1,48 @@
+<?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>
+ Regression check for an NPE in a block with no-wrap and hyphenation enabled.
+ </p>
+ </info>
+ <fo>
+ <fo:root xmlns:fo="http://www.w3.org/1999/XSL/Format" language="en" hyphenate="true">
+ <fo:layout-master-set>
+ <fo:simple-page-master master-name="simple" page-height="5in" page-width="5in">
+ <fo:region-body/>
+ </fo:simple-page-master>
+ </fo:layout-master-set>
+ <fo:page-sequence master-reference="simple">
+ <fo:flow flow-name="xsl-region-body">
+ <fo:block line-height="10pt" background-color="orange"
+ white-space-collapse="false" white-space-treatment="preserve" linefeed-treatment="preserve" wrap-option="no-wrap">
+line1
+line2
+
+line3
+</fo:block>
+ </fo:flow>
+ </fo:page-sequence>
+ </fo:root>
+ </fo>
+ <checks>
+ <!-- Dummy check. We don't want an NPE. -->
+ <eval expected="1" xpath="count(//pageViewport)"/>
+ </checks>
+</testcase>