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

Ralf Heydenreich commented on ODFTOOLKIT-383:
---------------------------------------------

Hi Bob,
no idea if this is an actual problem for you, but I've run into the same 
problem. I've solved it with a new PlaceHolder class and PlaceHolderNavigation 
class. This solved different problems: 1) spanned and not spanned placeholders 
doesn't matter; 2) placeholder can be replaced by an image; 3) placeholder 
inside a table can be used for fillng the complete table, i.e., you give one 
row as "template" row and a list of values which should be replaced and the 
PlaceholderNavigation replaces each row. 
At the moment I test this solution in my own application (since I heavily use 
the ODFToolkit for generating documents). If I think that all things work then 
I'll try to contribute the solution to this project.


> 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
>              Labels: Replace, Search, TextNavigation, loadDocument
>
> 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.3.4#6332)

Reply via email to