diff options
author | Adrian Cumiskey <acumiskey@apache.org> | 2008-06-09 11:24:36 +0000 |
---|---|---|
committer | Adrian Cumiskey <acumiskey@apache.org> | 2008-06-09 11:24:36 +0000 |
commit | 7d7910f72b18167d0f5cbc441a99aeeaa97e0838 (patch) | |
tree | f694df94a60f6f5de5448238060e48fbf0364f51 /src/java/org/apache/fop/layoutmgr | |
parent | 1dbe17e5b2edc0639f92cbb7644107dae8f6ad7e (diff) | |
download | xmlgraphics-fop-7d7910f72b18167d0f5cbc441a99aeeaa97e0838.tar.gz xmlgraphics-fop-7d7910f72b18167d0f5cbc441a99aeeaa97e0838.zip |
Merged revisions 662417,662807,662991,663045,663493,664347,664349-664350 via svnmerge from
https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk
........
r662417 | jeremias | 2008-06-02 13:50:55 +0100 (Mon, 02 Jun 2008) | 1 line
Integer keeps inside multi-line blocks and in between block-paragraphs.
........
r662807 | jeremias | 2008-06-03 15:13:27 +0100 (Tue, 03 Jun 2008) | 3 lines
Bugzilla #45115:
Added a PCL-specific extension attribute on simple-page-master for controlling the simplex/duplex mode.
Submitted by: Martin Edge <Martin.Edge.at.asmorphic.net.au>
........
r662991 | jeremias | 2008-06-04 07:10:37 +0100 (Wed, 04 Jun 2008) | 1 line
ApacheCon EU 2008 is long over.
........
r663045 | adelmelle | 2008-06-04 10:53:15 +0100 (Wed, 04 Jun 2008) | 1 line
Minor cleanup: remove spurious white-space
........
r663493 | jeremias | 2008-06-05 08:41:06 +0100 (Thu, 05 Jun 2008) | 1 line
Restored lost overflow warning in static-content.
........
r664347 | adelmelle | 2008-06-07 15:49:42 +0100 (Sat, 07 Jun 2008) | 5 lines
Extended behavior of preserved linefeeds to codepoints representing mandatory breaks in Unicode UAX#14:
- NEXT LINE (U+0085)
- LINE SEPARATOR (U+2028)
- PARAGRAPH SEPARATOR (U+2029)
........
r664349 | adelmelle | 2008-06-07 15:54:13 +0100 (Sat, 07 Jun 2008) | 1 line
Minor cleanup: remove unneeded constant
........
r664350 | adelmelle | 2008-06-07 16:09:42 +0100 (Sat, 07 Jun 2008) | 1 line
Improve code-readability; add some clarifying comments
........
git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/branches/Temp_AFPGOCAResources@664680 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/java/org/apache/fop/layoutmgr')
3 files changed, 39 insertions, 29 deletions
diff --git a/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java b/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java index 42ddcc220..8065f9aad 100644 --- a/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/StaticContentLayoutManager.java @@ -364,6 +364,12 @@ public class StaticContentLayoutManager extends BlockStackingLayoutManager { protected void doPhase3(PageBreakingAlgorithm alg, int partCount, BlockSequence originalList, BlockSequence effectiveList) { + if (partCount > 1) { + PageBreakPosition pos = (PageBreakPosition)alg.getPageBreaks().getFirst(); + int firstPartLength = ElementListUtils.calcContentLength(effectiveList, + effectiveList.ignoreAtStart, pos.getLeafPos()); + overflow += alg.totalWidth - firstPartLength; + } //Rendering all parts (not just the first) at once for the case where the parts that //overflow should be visible. alg.removeAllPageBreaks(); diff --git a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java index 8c46796eb..c9f72e64f 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/LineLayoutManager.java @@ -46,6 +46,7 @@ import org.apache.fop.layoutmgr.BreakElement; import org.apache.fop.layoutmgr.BreakingAlgorithm; import org.apache.fop.layoutmgr.ElementListObserver; import org.apache.fop.layoutmgr.InlineKnuthSequence; +import org.apache.fop.layoutmgr.KeepUtil; import org.apache.fop.layoutmgr.KnuthBlockBox; import org.apache.fop.layoutmgr.KnuthBox; import org.apache.fop.layoutmgr.KnuthElement; @@ -1052,11 +1053,14 @@ public class LineLayoutManager extends InlineStackingLayoutManager LinkedList returnList = new LinkedList(); for (int p = 0; p < knuthParagraphs.size(); p++) { - // null penalty between paragraphs - if (p > 0 && !((BlockLevelLayoutManager) parentLM).mustKeepTogether()) { - returnList.add(new BreakElement( - new Position(this), 0, context)); - //returnList.add(new KnuthPenalty(0, 0, false, new Position(this), false)); + // penalty between paragraphs + if (p > 0) { + int strength = getKeepTogetherStrength(); + int penalty = KeepUtil.getPenaltyForKeep(strength); + if (penalty < KnuthElement.INFINITE) { + returnList.add(new BreakElement( + new Position(this), penalty, context)); + } } LineLayoutPossibilities llPoss; @@ -1090,14 +1094,17 @@ public class LineLayoutManager extends InlineStackingLayoutManager for (int i = 0; i < llPoss.getChosenLineCount(); i++) { - if (!((BlockLevelLayoutManager) parentLM).mustKeepTogether() + if (returnList.size() > 0 + && i > 0 //if i==0 break generated above already && i >= fobj.getOrphans() - && i <= llPoss.getChosenLineCount() - fobj.getWidows() - && returnList.size() > 0) { - // null penalty allowing a page break between lines - returnList.add(new BreakElement( - returnPosition, 0, context)); - //returnList.add(new KnuthPenalty(0, 0, false, returnPosition, false)); + && i <= llPoss.getChosenLineCount() - fobj.getWidows()) { + // penalty allowing a page break between lines + int strength = getKeepTogetherStrength(); + int penalty = KeepUtil.getPenaltyForKeep(strength); + if (penalty < KnuthElement.INFINITE) { + returnList.add(new BreakElement( + returnPosition, penalty, context)); + } } int endIndex = ((LineBreakPosition) llPoss.getChosenPosition(i)).getLeafPos(); diff --git a/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java b/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java index 6ae909cd7..903ec84ae 100644 --- a/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java +++ b/src/java/org/apache/fop/layoutmgr/inline/TextLayoutManager.java @@ -139,8 +139,6 @@ public class TextLayoutManager extends LeafNodeLayoutManager { */ private final MinOptMax[] letterAdjustArray; //size = textArray.length + 1 - private static final char NEWLINE = '\n'; - /** Font used for the space between words. */ private Font spaceFont = null; /** Start index of next TextArea */ @@ -523,7 +521,7 @@ public class TextLayoutManager extends LeafNodeLayoutManager { || CharUtilities.isNonBreakableSpace(ch) || CharUtilities.isFixedWidthSpace(ch); } - + /** {@inheritDoc} */ public LinkedList getNextKnuthElements(final LayoutContext context, final int alignment) { this.lineStartBAP = context.getLineStartBorderAndPaddingWidth(); @@ -561,8 +559,9 @@ public class TextLayoutManager extends LeafNodeLayoutManager { TextLayoutManager.LOG.error("Unexpected breakAction: " + breakAction); } if (inWord) { - if (breakOpportunity || TextLayoutManager.isSpace(ch) - || ch == TextLayoutManager.NEWLINE) { + if (breakOpportunity + || TextLayoutManager.isSpace(ch) + || CharUtilities.isExplicitBreak(ch)) { // this.textArray[lastIndex] == CharUtilities.SOFT_HYPHEN prevAi = this.processWord(alignment, sequence, prevAi, ch, breakOpportunity, true); @@ -601,12 +600,13 @@ public class TextLayoutManager extends LeafNodeLayoutManager { (short) 0, (short) 0, ipd, false, true, breakOpportunity, font); this.thisStart = (short) (this.nextStart + 1); - } else if (ch == TextLayoutManager.NEWLINE) { - // linefeed; this can happen when linefeed-treatment="preserve" + } else if (CharUtilities.isExplicitBreak(ch)) { + //mandatory break-character: only advance index this.thisStart = (short) (this.nextStart + 1); } + inWord = !TextLayoutManager.isSpace(ch) - && ch != TextLayoutManager.NEWLINE; + && !CharUtilities.isExplicitBreak(ch); inWhitespace = ch == CharUtilities.SPACE && this.foText.getWhitespaceTreatment() != Constants.EN_PRESERVE; this.nextStart++; @@ -620,7 +620,7 @@ public class TextLayoutManager extends LeafNodeLayoutManager { } else if (ai != null) { ai = this.processLeftoverAi(alignment, sequence, ai, ch, ch == CharUtilities.ZERO_WIDTH_SPACE); - } else if (ch == TextLayoutManager.NEWLINE) { + } else if (CharUtilities.isExplicitBreak(ch)) { sequence = this.processLinebreak(returnList, sequence); } @@ -628,6 +628,7 @@ public class TextLayoutManager extends LeafNodeLayoutManager { //Remove an empty sequence because of a trailing newline returnList.removeLast(); } + this.setFinished(true); if (returnList.isEmpty()) { return null; @@ -1000,14 +1001,12 @@ public class TextLayoutManager extends LeafNodeLayoutManager { if (this.textArray[ai.startIndex] != CharUtilities.SPACE || this.foText.getWhitespaceTreatment() == Constants.EN_PRESERVE) { // a breaking space that needs to be preserved - this - .addElementsForBreakingSpace(baseList, alignment, ai, + this.addElementsForBreakingSpace(baseList, alignment, ai, this.auxiliaryPosition, 0, mainPosition, ai.areaIPD.opt, true); } else { // a (possible block) of breaking spaces - this - .addElementsForBreakingSpace(baseList, alignment, ai, + this.addElementsForBreakingSpace(baseList, alignment, ai, mainPosition, ai.areaIPD.opt, this.auxiliaryPosition, 0, false); } @@ -1048,8 +1047,7 @@ public class TextLayoutManager extends LeafNodeLayoutManager { 3 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0, this.auxiliaryPosition, false)); baseList.add(this.makeZeroWidthPenalty(0)); - baseList - .add(new KnuthGlue(p2WidthOffset + baseList.add(new KnuthGlue(p2WidthOffset - (this.lineStartBAP + this.lineEndBAP), -3 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0, pos2, false)); @@ -1062,8 +1060,7 @@ public class TextLayoutManager extends LeafNodeLayoutManager { 3 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0, this.auxiliaryPosition, false)); baseList.add(this.makeZeroWidthPenalty(0)); - baseList - .add(new KnuthGlue(ai.areaIPD.opt, -3 + baseList.add(new KnuthGlue(ai.areaIPD.opt, -3 * LineLayoutManager.DEFAULT_SPACE_WIDTH, 0, pos2, false)); } |