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

[Simple API]The Value of VariableField always is "" when try to get a VariableField instance by TextDocument.getVariableFieldByName(String)

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 0.5-incubating
    • 0.6-incubating
    • simple api
    • None

    Description

      The Value of VariableField always is "" when try to get a VariableField instance by TextDocument.getVariableFieldByName.
      Here is the sample codes to show the error.

      try {
      TextDocument sourcedoc = (TextDocument) Document.loadDocument(ResourceUtilities.getAbsolutePath("TestMySelectionResultsssss.odt"));
      VariableField userVariableField = sourcedoc.getVariableFieldByName("textt");
      if (userVariableField.getOdfElement() instanceof TextUserFieldDeclElement)

      { TextUserFieldDeclElement textUserFieldDeclElement = (TextUserFieldDeclElement) userVariableField.getOdfElement(); String fieldname = userVariableField.getVariableName(); String value = textUserFieldDeclElement.getOfficeStringValueAttribute(); System.out.println("FieldName:" + fieldname); System.out.println("Fieldvalue:" + value);// value always is "" }

      } catch (FileNotFoundException e1)

      { e1.printStackTrace(); } catch (Exception e1) { e1.printStackTrace(); }

      Attachments

        Activity

          People

            liudali Da Li Liu
            liudali Da Li Liu
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - 24h
                24h
                Remaining:
                Remaining Estimate - 24h
                24h
                Logged:
                Time Spent - Not Specified
                Not Specified