ICU-2405 Change nextLine() to return the rest of the paragraph if width <= 0.

X-SVN-Rev: 11299
This commit is contained in:
Eric Mader 2003-03-13 22:55:37 +00:00
parent 102ad41655
commit 7771903a16
2 changed files with 27 additions and 21 deletions

View file

@ -451,30 +451,34 @@ const ParagraphLayout::Line *ParagraphLayout::nextLine(float width)
fLineStart = fLineEnd;
le_int32 glyph = fCharToGlyphMap[fLineStart];
float widthSoFar = 0;
if (width > 0) {
le_int32 glyph = fCharToGlyphMap[fLineStart];
float widthSoFar = 0;
while (glyph < fGlyphCount && widthSoFar + fGlyphWidths[glyph] <= width) {
widthSoFar += fGlyphWidths[glyph++];
}
while (glyph < fGlyphCount && widthSoFar + fGlyphWidths[glyph] <= width) {
widthSoFar += fGlyphWidths[glyph++];
}
// If no glyphs fit on the line, force one to fit.
//
// (There shouldn't be any zero width glyphs at the
// start of a line unless the paragraph consists of
// only zero width glyphs, because otherwise the zero
// width glyphs will have been included on the end of
// the previous line...)
if (widthSoFar == 0 && glyph < fGlyphCount) {
glyph += 1;
}
// If no glyphs fit on the line, force one to fit.
//
// (There shouldn't be any zero width glyphs at the
// start of a line unless the paragraph consists of
// only zero width glyphs, because otherwise the zero
// width glyphs will have been included on the end of
// the previous line...)
if (widthSoFar == 0 && glyph < fGlyphCount) {
glyph += 1;
}
fLineEnd = previousBreak(fGlyphToCharMap[glyph]);
fLineEnd = previousBreak(fGlyphToCharMap[glyph]);
// If there's no real break, break at the
// glyph that didn't fit.
if (fLineEnd <= fLineStart) {
fLineEnd = fGlyphToCharMap[glyph];
// If there's no real break, break at the
// glyph that didn't fit.
if (fLineEnd <= fLineStart) {
fLineEnd = fGlyphToCharMap[glyph];
}
} else {
fLineEnd = fCharCount;
}
return computeVisualRuns();

View file

@ -187,7 +187,9 @@ public:
* in the paragraph. The width of the line is specified each time so that it can
* be varied to support arbitrary paragraph shapes.
*
* @param width is the width of the line.
* @param width is the width of the line. If <code>width</code> is less than or equal
* to zero, a <code>ParagraphLayout::Line</code> object represnting the
* rest of the paragraph will be returned.
*
* @return a <code>ParagraphLayout::Line</code> object which represents the line. The caller
* is responsible for deleting the object.