DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=28314>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=28314

[PATCH] Alignment of the last line in a justified block





------- Additional Comments From [EMAIL PROTECTED]  2004-04-23 15:15 -------
Hi

I have tried to follow the other idea, i.e. understand why reset() is called 
in these problematic situations, and maybe I have found an alternative patch 
which doesn't involve white-space-treatment changes.

Problems in the justification of the last line arise when the 
TextLayoutManagers returns to the LineLM, in sequence:
- a valid BreakPoss, stored in the ArrayList vecInlineBreaks and in the
  variable prevBP
- one or more invalid BreakPoss, for which isSuppressible() is true, stored
  only in vecInlineBreaks
- nothing else, as ther are no more child LM with something to layout

An important detail: if the spaces are at the end of the text of a TLM, prevBP 
has the REST_ARE_SUPPRESS_AT_LB flag set; in the other case it hasn't.
The invalid bp have the ALL_ARE_SUPPRESS_AT_LB flag set.

The method reset() is called if
  bp != prevBP                  (the last returned bp is invalid)
  && !prevCouldEndLine(prevBP)  (we cannot ignore what is after prevBP)
and I think in our problematic situations !prevCouldEndLine(prevBP) should be 
false, i.e. prevCouldEndLine(prevBP) should be true.

So, this is how I would calculate prevCouldEndLine(prev):
1) first of all, check if isFinished() is true: if it's not, there are other 
childLM and we cannot ignore any space
2) starting from the last element in vecInlineBreaks and moving backward 
(stopping when prev is reached), check if bp are suppressible

At the moment, prevCouldEndLine calls bp.couldEndLine(), which checks the 
REST_ARE_SUPPRESS_AT_LB bit, which can be true only for a valid BreakPoss 
followed by suppressible spaces, and not for the invalid BreakPoss; with my 
patch, this method would be very similar to allAreSuppressible.

There is only another change to do in the getNextBreakPoss method: if 
(bpDim.min > availIPD.max) and !(bTextAlignment == TextAlign.JUSTIFY || prevBP 
== null) the bp should be added to vecInlineBreaks whether prevBP is null or 
not, otherwise if the last line of a non-justified block contains only a word 
it is not shown.
You can see this using the sample fo file I attached before: the first block 
is left-aligned, and its third and last line is "spaces."; without this last 
change, the line disappears. In this case reset() should have been called, but 
prevBP is the last BreakPoss in vecInlineBreaks, so prevCouldEndLine(prevBP) 
returns true.

I'm going to attach this alternative proposed patch.

    Luca

Reply via email to