[ 
https://issues.apache.org/jira/browse/ODFTOOLKIT-362?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13713569#comment-13713569
 ] 

Florian Hopf edited comment on ODFTOOLKIT-362 at 7/19/13 11:33 AM:
-------------------------------------------------------------------

I added two test cases to reproduce this in r1504833.

This seems to be caused by a special handling of cells regarding the 
replacements. According to the comments in TextNavigation#createSelection this 
is to keep display text and string value of the cells consistent. However, 
testing this showed that both values are kept consistent even if the special 
handling is removed. I am hesitant to remove this code as at least at some 
point in time there seemed to be a reason for it and I can't judge if there are 
any side effects.

For your problem there is a workaround: Instead of calling replace(String) you 
can pass in a paragraph, which circumvents the special handling:

TextParagraphElementBase paragraphElement = new 
TextPElement(doc.getContentDom());
Paragraph para = Paragraph.getInstanceof(paragraphElement);
para.setTextContent(value);
selection.replaceWith(para);

I agree that the original report is a bug but I'd prefer that one of the 
original authors had a look on this. Let us know if the workaround is 
sufficient for you right now.
                
      was (Author: fhopf):
    I added two test cases to reproduce this in r1504833.

This seems to be caused by a special handling of cells regarding the 
replacements. According to the comments in TextNavigation#createSelection this 
is to keep display text and string value of the cells consistent. However, 
testing this showed that both values are kept consistent even if the special 
handling is removed. I am hesitant to remove this code as at least in some 
point in time there seemed to be a reason for it and I can't judge if there are 
any side effects.

For your problem there is a workaround: Instead of calling replace(String) you 
can pass in a paragraph, which circumvents the special handling:

TextParagraphElementBase paragraphElement = new 
TextPElement(doc.getContentDom());
Paragraph para = Paragraph.getInstanceof(paragraphElement);
para.setTextContent(value);
selection.replaceWith(para);

I agree that the original report is a bug but I'd prefer that one of the 
original authors had a look on this. Let us know if the workaround is 
sufficient for you right now.
                  
> TextSelection.replaceWith() ends in an infinite loop
> ----------------------------------------------------
>
>                 Key: ODFTOOLKIT-362
>                 URL: https://issues.apache.org/jira/browse/ODFTOOLKIT-362
>             Project: ODF Toolkit
>          Issue Type: Bug
>          Components: simple api
>    Affects Versions: odfdom-0.8.7
>            Reporter: Jörg Büsse
>         Attachments: OdfBug.java, testTemplate.odt
>
>
> Replacing text parts of a table cell can end in an infinite loop. We created 
> a simple class to reproduce/demonstrate the issue.
> Used libraries:
> odfdom-java-0.8.7.jar
> simple-odf-0.6.6.jar
> Also tried the libraries from odftoolkit-0.5-incubating-bin.tar.gz:
> odfdom-java-0.8.8-incubating.jar
> simple-odf-0.7-incubating.jar

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to