Leo wrote:
> Hi everybody,
> I found a bug into MultiColumnText class in method addElement.
> The method should be written like this:
>  
>   public void addElement(Element element) throws DocumentException {
>   if (element instanceof Phrase) {
>       columnText.addText((Phrase) element);
>     } else if (element instanceof Chunk) {
>       columnText.addText((Chunk) element);
>     } else if (simple) {
>       columnText.addElement(element);
>     } else {
>       throw new DocumentException("Can't add " + element.getClass() + " 
> to MultiColumnText with complex columns");
>     }
>   }
>  
> Oherwise if you add a simple Chunk to an irregular column the method 
> throw the DocumentException but this is a mistake!!!

Are you sure? Please explain.
Currently the method looks like this:

public void addElement(Element element) throws DocumentException {
     if (simple) {
         columnText.addElement(element);
     } else if (element instanceof Phrase) {
         columnText.addText((Phrase) element);
     } else if (element instanceof Chunk) {
         columnText.addText((Chunk) element);
     } else {
         throw new DocumentException("Can't add " + element.getClass() + 
" to MultiColumnText with complex columns");
     }
}

If the columns are rectangular, YOU MUST use addElement. Using addText 
in this context, would lead to unexpected behavior when working in 
composite mode. That's why I think your "bugfix" introduces a bug, 
rather than solving one. As for the alleged bug: when using irregular 
columns, addText is used in case Phrases or Chunks are added. Please 
explain why you think an exception is thrown if element is an instance 
of chunk.
-- 
This answer is provided by 1T3XT BVBA
http://www.1t3xt.com/ - http://www.1t3xt.info

------------------------------------------------------------------------------
_______________________________________________
iText-questions mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/itext-questions

Buy the iText book: http://www.1t3xt.com/docs/book.php

Reply via email to