Bob Hecker created ODFTOOLKIT-383:
-------------------------------------

             Summary: Object TextNavigation doesn't return search value
                 Key: ODFTOOLKIT-383
                 URL: https://issues.apache.org/jira/browse/ODFTOOLKIT-383
             Project: ODF Toolkit
          Issue Type: Bug
          Components: simple api
    Affects Versions: 0.6-incubating
            Reporter: Bob Hecker
            Priority: Minor


When I load an .ott file and I try to search for placeholders I encounter 
strange behavior. Some of the placeholders (not all) in the template cannot be 
found. I use the code shown below to open the document and search for the 
placeholders

TextDocument odt = TextDocument.loadDocument("/template-001.ott");

TextNavigation search = new TextNavigation("<name>", odt);
while (search.hasNext()) {                
   TextSelection item = (TextSelection) search.nextSelection();
   System.out.println("Placeholder found");
   item.replaceWith("SOME_TEXT");
}

The code works because some placeholders get replaced, but unfortunately not 
all. The only difference I can find between the placeholders is the way they 
are recorded in the .ott file Openoffice generated.

The placeholders who get replaced have this syntax:

<text:span text:style-name="T5">
   <text:placeholder text:placeholder-type="text">&lt;name&gt;    
</text:placeholder>
</text:span>

While the placeholders who don't get replaced are recorded this way:

<text:placeholder 
text:placeholder-type="text">&lt;name&gt;</text:placeholder></text:p>

The ones who get replaced seem to have a text:span tag. I'm not sire if this is 
the real cause of the problem but when I give the specific fields (who are not 
working) a text:span tag they seem to get replaced.

I dont't have any deep knowledge of the odftoolkit but I think the loadDocument 
does something with the data so the TextNavigation can't find the specific 
elements. Or the TextNavigation is not functioning as I would expect.



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to