Uploaded image for project: 'ODF Toolkit'
  1. ODF Toolkit
  2. ODFTOOLKIT-383

Object TextNavigation doesn't return search value

    XMLWordPrintableJSON

    Details

      Description

      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"><name> </text:placeholder>
      </text:span>

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

      <text:placeholder text:placeholder-type="text"><name></text:placeholder></text>

      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.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              HeckerBob Bob Hecker
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: