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=27901>.
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=27901

TextCharIterator.remove() does not work properly





------- Additional Comments From [EMAIL PROTECTED]  2004-03-26 11:31 -------
Hi again, this is my try:

- added an ArrayList called "blackList" to the FOText class; when remove is 
called, the index of the character to be removed is stored in this list (and 
nothing else is done); the first element in this blackList is always -1, and 
the last ca.length
- added an int called "length" to the FOText class, to store the computed 
length of the text, which is < ca.length if some characters are removed
- created a new method for the FOText class, called "compactText"; it is 
called in the TextLayoutManager constructor, before modifying textArray; it 
modifies the start and length variables of the FOText node
- textArray is given a dimension of "length" (not ca.length) and then 
arraycopy is called with the start and length computed before

The compactText method:
1) starts examining the black list from the beginning
2) founds two black indexes (position of char to be removed) which are not 
consecutive, so that they define a range of "good" characters
3) if this range is the first one found, nothing is done except updating start 
and length, else the range is shifted to the left, thus removing the "bad" 
characters
and then 2) and 3) until the end of the blacklist is found

 |   Text is   here and  here.|  <- this is the ca array
 xxxx        xx         x     x  <- these are the bad indexes
     --------  --------- -----   <- these are the ranges found beween
                                    two not-consecutive bad indexes
 |   Text is here and here.   |  <- this is the compacted array
     ^start                ^start+length

In this way every good character is shifted at most one time; two times, 
actually, as arraycopy is called with src = dest, and a temporary array is 
created; maybe the TextLayoutManager should use the blacklist to perform 
arraycopy directly between ca and textArray, without compacting the FOText 
array?.

I am going to attach the patch with these changes.

Bye
    Luca

Reply via email to