From e8ebf0309db50be59038219c1b88d0c50d12621b Mon Sep 17 00:00:00 2001 From: Keiron Liddle Date: Tue, 25 Sep 2001 11:59:18 +0000 Subject: [PATCH] fixed some text wrapping problems and improved the wrapping test git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@194482 13f79535-47bb-0310-9956-ffa450edef68 --- src/org/apache/fop/layout/LineArea.java | 55 ++++++------ test/xml/bugtests/wrap.fo | 106 ++++++++++++++++++++++++ 2 files changed, 137 insertions(+), 24 deletions(-) diff --git a/src/org/apache/fop/layout/LineArea.java b/src/org/apache/fop/layout/LineArea.java index a3129feb5..1a424470f 100644 --- a/src/org/apache/fop/layout/LineArea.java +++ b/src/org/apache/fop/layout/LineArea.java @@ -432,42 +432,49 @@ public class LineArea extends Area { if (this.wrapOption == WrapOption.WRAP) { - int ret=wordStart; - if (hyphProps.hyphenate == Hyphenate.TRUE) { + int ret = wordStart; ret = this.doHyphenation(dataCopy, i, wordStart, this.getContentWidth() - (finalWidth + spaceWidth + pendingWidth)); + // current word couldn't be hypenated + // couldn't fit first word + // I am at the beginning of my line + if ((ret == wordStart) && + (wordStart == start) && + (finalWidth == 0)) { + + MessageHandler.error(">"); + addSpacedWord(new String(data, wordStart, wordLength - 1), + ls, + finalWidth + spaceWidth + + embeddedLinkStart, + spaceWidth, textState, false); + + finalWidth += wordWidth; + wordWidth = 0; + ret = i; + } + return ret; + } else if (wordStart == start) { + // first word + overrun = true; + // if not at start of line, return word start + // to try again on a new line + if (finalWidth > 0) { + return wordStart; + } + } else { + return wordStart; } - - if ((ret == wordStart) && // current word couldn't be hypenated - (wordStart == start) && // couldn't fit first word - (finalWidth == 0)) { // I am at the beginning of my line - - MessageHandler.error(">"); - - addSpacedWord(new String(data, wordStart, wordLength - 1), - ls, - finalWidth + spaceWidth - + embeddedLinkStart, - spaceWidth, textState, false); - - finalWidth += wordWidth; - wordWidth = 0; - - ret = i; - } - - return ret; } } } - } // end of iteration over text - + } // end of iteration over text if (prev == TEXT) { diff --git a/test/xml/bugtests/wrap.fo b/test/xml/bugtests/wrap.fo index 1e2639055..c1e4b6272 100644 --- a/test/xml/bugtests/wrap.fo +++ b/test/xml/bugtests/wrap.fo @@ -12,10 +12,25 @@ + + + + + + +This test is to check a number of different possibilities when dealing with +text being wrapped at the end of an area. + This is a simple fo block.This is a simple fo block.This is a simple fo block. This is a simple fo block.This is a simple fo block.This is a simple fo block. @@ -30,6 +45,97 @@ This is simple fo block.This is simple fo block.This is simple fo block.This is simple fo block. This is simple fo block.This is simple fo block.This is simple fo block.This is simple fo block. + +Some examples in a table. + + + + + + + +a normal paragraph with spaces and normal words + + + + + + +a normal paragraph with spaces and normal words + + + + + + +areallylongwordwhichisreallymanywords + + + + + + +areallylongwordwhichisreallymanywords + + + + + + +words with hypenation the activated when doing lots of wrapping + + + + + + +interdependancy is a nice long word + + + + + + +words with hypenation the activated when not doing lots of wrapping + + + + + + + + + This is a simple fo block.This is a simple fo block.This is a simple fo block. + This is a simple fo block.This is a simple fo block.This is a simple fo block. + This is a simple fo block.This is a simple fo block.This is a simple fo block. + This is a simple fo block.This is a simple fo block.This is a simple fo block. + + + This is a simple fo block.This is a simple fo block.This is a simple fo block. + This is a simple fo block.This is a simple fo block.This is a simple fo block. + This is a simple fo block.This is a simple fo block.This is a simple fo block. + + This is simple fo block.This is simple fo block.This is simple fo block.This is simple fo block. + This is simple fo block.This is simple fo block.This is simple fo block.This is simple fo block. + + + -- 2.39.5