incubator-odf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "DaLi Liu (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (ODFTOOLKIT-338) [Simple API]The Value of VariableField always is "" when try to get a VariableField instance by TextDocument.getVariableFieldByName(String)
Date Wed, 12 Sep 2012 10:33:07 GMT

     [ https://issues.apache.org/jira/browse/ODFTOOLKIT-338?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

DaLi Liu updated ODFTOOLKIT-338:
--------------------------------

    Attachment: 338_AbstractVariableContainer.java.patch

Patch for this bug:
This is caused by the code in AbstractVariableContainer.java
line 76:
return Fields.createUserVariableField(this, name, "");
Here always create UserVariableField with "".

Fix this issue with following codes:
String type = userVariableElement.getOfficeValueTypeAttribute();
					if(type.equalsIgnoreCase("string")){
						String stringValue = userVariableElement.getOfficeStringValueAttribute();
						return Fields.createUserVariableField(this, name, stringValue);
					}
					Double DoubleValue = userVariableElement.getOfficeValueAttribute();
					DoubleValue.toString();
					return Fields.createUserVariableField(this, name, DoubleValue.toString());

                
> [Simple API]The Value of VariableField always is "" when try to get a VariableField instance
by TextDocument.getVariableFieldByName(String)
> -------------------------------------------------------------------------------------------------------------------------------------------
>
>                 Key: ODFTOOLKIT-338
>                 URL: https://issues.apache.org/jira/browse/ODFTOOLKIT-338
>             Project: ODF Toolkit
>          Issue Type: Bug
>          Components: simple api
>    Affects Versions: 0.7
>            Reporter: DaLi Liu
>             Fix For: 0.8
>
>         Attachments: 338_AbstractVariableContainer.java.patch, TestMySelectionResultsssss.odt
>
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> 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();
> 		}

--
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

Mime
View raw message