inlineLM.removeWordSpace(removedElements);
}
}
-
+
+ /**
+ * @return true if the sequence contains a box
+ */
+ public boolean containsBox() {
+ for (int i = 0; i < this.size(); i++) {
+ KnuthElement el = (KnuthElement)this.get(i);
+ if (el.isBox()) {
+ return true;
+ }
+ }
+ return false;
+ }
}
private class LineBreakingAlgorithm extends BreakingAlgorithm {
== -KnuthPenalty.INFINITE) {
// a penalty item whose value is -inf
// represents a preserved linefeed,
- // wich forces a line break
+ // which forces a line break
lastPar.removeLast();
- if (lastPar.size() == 0) {
+ if (!lastPar.containsBox()) {
//only a forced linefeed on this line
//-> compensate with a zero width box
lastPar.add(new KnuthInlineBox(0, null, null, false));
}
log.trace(trace);
}
-
+
/**
* Find a set of breaking points.
* This method is called only once by getNextBreakPoss, and it
correctly. Zero width space characters are not handled
correctly.</description>
</testcase>
- <testcase>
- <name>linefeed treatment 2</name>
- <file>block_linefeed-treatment_2.xml</file>
- <description>This test checks linefeed preservation between and at
- the start of fo:inline elements.</description>
- <reference>http://marc.theaimsgroup.com/?t=113525808000001</reference>
- </testcase>
<testcase>
<name>Empty blocks produce fences</name>
<file>block_space-before_space-after_8.xml</file>
</fo:layout-master-set>
<fo:page-sequence master-reference="master">
<fo:flow flow-name="xsl-region-body">
- <fo:block linefeed-treatment="preserve" text-align="center">
+ <fo:block background-color="silver"
+ linefeed-treatment="preserve" text-align="center"
+ margin-top="10pt" margin-bottom="10pt">
<fo:inline font-weight="bold">Leasing a ...</fo:inline>
+
<fo:inline>Contrat Nr.: W-113283...</fo:inline>
</fo:block>
- <fo:block linefeed-treatment="preserve" text-align="center">
+ <fo:block background-color="yellow"
+ linefeed-treatment="preserve" text-align="center"
+ margin-top="10pt" margin-bottom="10pt">
<fo:inline font-weight="bold">Leasing a ...</fo:inline>
<fo:inline> Contrat Nr.: W-113283...</fo:inline>
</fo:block>
- <fo:block linefeed-treatment="preserve">
+ <fo:block background-color="silver"
+ linefeed-treatment="preserve"
+ margin-top="10pt" margin-bottom="10pt">
<fo:inline font-weight="bold">Leasing a ...</fo:inline>
+
<fo:inline>Contrat Nr.: W-113283...</fo:inline>
</fo:block>
- <fo:block linefeed-treatment="preserve">
+ <fo:block background-color="yellow"
+ linefeed-treatment="preserve"
+ margin-top="10pt" margin-bottom="10pt">
<fo:inline font-weight="bold">Leasing a ...</fo:inline>
<fo:inline> Contrat Nr.: W-113283...</fo:inline>
</fo:block>
The result:
Leasing a ...
+
Contract Nr.: W-...
Leasing a ...
+
Contract Nr.: W-...
Leasing a ...
+
Contract Nr.: W-...
Leasing a ...
the fo:inline. The results for the first and second cases are lacking
the linefeed before the first line.
-->
- <eval expected="3" xpath="count(//flow/block[1]/lineArea)"/>
+ <eval expected="4" xpath="count(//flow/block[1]/lineArea)"/>
<eval expected="4" xpath="count(//flow/block[2]/lineArea)"/>
- <eval expected="3" xpath="count(//flow/block[3]/lineArea)"/>
+ <eval expected="4" xpath="count(//flow/block[3]/lineArea)"/>
<eval expected="4" xpath="count(//flow/block[4]/lineArea)"/>
</checks>
</testcase>