com.aspose.words

Class FieldOptions

  • java.lang.Object
    • com.aspose.words.FieldOptions
public class FieldOptions 
extends java.lang.Object

Represents options to control field handling in a document.

Example:

Shows how to specify where the locale for date formatting during field update and mail merge is chosen from.
// Set the culture used during field update to the culture used by the field.
doc.getFieldOptions().setFieldUpdateCultureSource(FieldUpdateCultureSource.FIELD_CODE);
doc.getMailMerge().execute(new String[]{"Date2"}, new Object[]{new SimpleDateFormat("yyyy/MM/DD").parse("2011/01/01")});

Property Getters/Setters Summary
IBarcodeGeneratorgetBarcodeGenerator()
void
           Gets or set custom barcode generator.
java.lang.String[]getBuiltInTemplatesPaths()
void
setBuiltInTemplatesPaths(java.lang.String[]value)
           Gets or sets paths of MS Word built-in templates.
UserInformationgetCurrentUser()
void
           Gets or sets the current user information.
java.lang.StringgetCustomTocStyleSeparator()
void
setCustomTocStyleSeparator(java.lang.Stringvalue)
           Gets or sets custom style separator for the \t switch in TOC field.
java.lang.StringgetDefaultDocumentAuthor()
void
setDefaultDocumentAuthor(java.lang.Stringvalue)
           Gets or sets default document author's name. If author's name is already specified in built-in document properties, this option is not considered.
intgetFieldUpdateCultureSource()
void
           Specifies what culture to use to format the field result. The value of the property is FieldUpdateCultureSource integer constant.
java.lang.StringgetFileName()
void
setFileName(java.lang.Stringvalue)
           Gets or sets the file name of the document.
booleanisBidiTextSupportedOnUpdate()
void
           Gets or sets the value indicating whether bidirectional text is fully supported during field update or not.
booleangetLegacyNumberFormat()
void
setLegacyNumberFormat(booleanvalue)
           Gets or sets the value indicating whether legacy (early than AW 13.10) number format for fields is enabled or not.
System.Globalization.CultureInfogetPreProcessCulture()
Gets or sets the culture to preprocess field values.
IFieldResultFormattergetResultFormatter()
void
           Allows to control how the field result is formatted.
ToaCategoriesgetToaCategories()
void
           Gets or sets the table of authorities categories.
booleangetUseInvariantCultureNumberFormat()
void
           Gets or sets the value indicating that number format is parsed using invariant culture or not
IFieldUserPromptRespondentgetUserPromptRespondent()
void
           Gets or sets the respondent to user prompts during field update.
 

    • Property Getters/Setters Detail

      • getBarcodeGenerator/setBarcodeGenerator

        public IBarcodeGenerator getBarcodeGenerator() / public void setBarcodeGenerator(IBarcodeGenerator value)
        
        Gets or set custom barcode generator. Custom barcode generator should implement public interface IBarcodeGenerator.
      • getBuiltInTemplatesPaths/setBuiltInTemplatesPaths

        public java.lang.String[] getBuiltInTemplatesPaths() / public void setBuiltInTemplatesPaths(java.lang.String[] value)
        
        Gets or sets paths of MS Word built-in templates.

        This property is used by the AUTOTEXT and GLOSSARY fields, if referenced auto text entry is not found in the Document.AttachedTemplate template.

        By defalut MS Word stores built-in templates in c:\Users\<username>\AppData\Roaming\Microsoft\Document Building Blocks\1033\16\Built-In Building Blocks.dotx and C:\Users\<username>\AppData\Roaming\Microsoft\Templates\Normal.dotm files.

      • getCurrentUser/setCurrentUser

        public UserInformation getCurrentUser() / public void setCurrentUser(UserInformation value)
        
        Gets or sets the current user information.
      • getCustomTocStyleSeparator/setCustomTocStyleSeparator

        public java.lang.String getCustomTocStyleSeparator() / public void setCustomTocStyleSeparator(java.lang.String value)
        
        Gets or sets custom style separator for the \t switch in TOC field. By default, custom styles defined by the \t switch in the TOC field are separated by a delimiter taken from the current culture. This property overrides that behaviour by specifying a user defined delimiter.
      • getDefaultDocumentAuthor/setDefaultDocumentAuthor

        public java.lang.String getDefaultDocumentAuthor() / public void setDefaultDocumentAuthor(java.lang.String value)
        
        Gets or sets default document author's name. If author's name is already specified in built-in document properties, this option is not considered.
      • getFieldUpdateCultureSource/setFieldUpdateCultureSource

        public int getFieldUpdateCultureSource() / public void setFieldUpdateCultureSource(int value)
        
        Specifies what culture to use to format the field result. The value of the property is FieldUpdateCultureSource integer constant.

        By default, the culture of the current thread is used.

        The setting affects only date/time fields with \\@ format switch.

        Example:

        Shows how to specify where the locale for date formatting during field update and mail merge is chosen from.
        // Set the culture used during field update to the culture used by the field.
        doc.getFieldOptions().setFieldUpdateCultureSource(FieldUpdateCultureSource.FIELD_CODE);
        doc.getMailMerge().execute(new String[]{"Date2"}, new Object[]{new SimpleDateFormat("yyyy/MM/DD").parse("2011/01/01")});
      • getFileName/setFileName

        public java.lang.String getFileName() / public void setFileName(java.lang.String value)
        
        Gets or sets the file name of the document.

        This property is used by the FILENAME field with higher priority than the Document.OriginalFileName property.

      • isBidiTextSupportedOnUpdate/isBidiTextSupportedOnUpdate

        public boolean isBidiTextSupportedOnUpdate() / public void isBidiTextSupportedOnUpdate(boolean value)
        
        Gets or sets the value indicating whether bidirectional text is fully supported during field update or not.

        When this property is set to true, additional steps are performed to produce Right-To-Left language (i.e. Arabic or Hebrew) compatible field result during its update.

        When this property is set to false and Right-To-Left language is used, correctness of field result after its update is not guaranteed.

        The default value is false.

      • getLegacyNumberFormat/setLegacyNumberFormat

        public boolean getLegacyNumberFormat() / public void setLegacyNumberFormat(boolean value)
        
        Gets or sets the value indicating whether legacy (early than AW 13.10) number format for fields is enabled or not.

        When this property is set to true, template symbol "#" worked as in .net: Replaces the pound sign with the corresponding digit if one is present; otherwise, no symbols appears in the result string.

        When this property is set to false, template symbol "#" works as MS Word: This format item specifies the requisite numeric places to display in the result. If the result does not include a digit in that place, MS Word displays a space. For example, { = 9 + 6 \# $### } displays $ 15.

        The default value is false.

      • getPreProcessCulture

        public System.Globalization.CultureInfo getPreProcessCulture()
        
        Gets or sets the culture to preprocess field values.

        Currently this property only affects value of the DOCPROPERTY field.

        The default value is null. When this property is set to null, the DOCPROPERTY field's value is preprocessed with the culture controlled by the FieldUpdateCultureSource property.

      • getResultFormatter/setResultFormatter

        public IFieldResultFormatter getResultFormatter() / public void setResultFormatter(IFieldResultFormatter value)
        
        Allows to control how the field result is formatted.

        Example:

        Shows how to control how the field result is formatted.
        public void insertCustomFormattingField() throws Exception
        {
            Document doc = new Document();
            DocumentBuilder builder = new DocumentBuilder(doc);
        
            Field field = builder.insertField("=-1234567.89 \\# \"### ### ###.000\"", null);
            doc.getFieldOptions().setResultFormatter(new FieldResultFormatter("[{0}]", null));
        
            field.update();
        
        }
        
        private class FieldResultFormatter implements IFieldResultFormatter
        {
            FieldResultFormatter(String numberFormat, String dateFormat)
            {
                mNumberFormat = numberFormat;
                mDateFormat = dateFormat;
            }
        
            public String formatNumeric(double value, String format)
            {
                mNumberFormatInvocations.add(new Object[]{value, format});
        
                return (mNumberFormat == null || "".equals(mNumberFormat)) ? null : MessageFormat.format(mNumberFormat, value);
            }
        
            public String formatDateTime(Date value, String format, /*CalendarType*/int calendarType)
            {
                mDateFormatInvocations.add(new Object[]{value, format, calendarType});
        
                return (mDateFormat == null || "".equals(mDateFormat)) ? null : MessageFormat.format(mDateFormat, value);
            }
        
            public String format(String value, /*GeneralFormat*/int format)
            {
                throw new UnsupportedOperationException();
            }
        
            public String format(double value, /*GeneralFormat*/int format)
            {
                throw new UnsupportedOperationException();
            }
        
            private /*final*/ String mNumberFormat;
            private /*final*/ String mDateFormat;
        
            private /*final*/ ArrayList mNumberFormatInvocations = new ArrayList();
            private /*final*/ ArrayList mDateFormatInvocations = new ArrayList();
            private IFieldResultFormatter fieldResultFormatterImplementation;
        }
      • getToaCategories/setToaCategories

        public ToaCategories getToaCategories() / public void setToaCategories(ToaCategories value)
        
        Gets or sets the table of authorities categories.
      • getUseInvariantCultureNumberFormat/setUseInvariantCultureNumberFormat

        public boolean getUseInvariantCultureNumberFormat() / public void setUseInvariantCultureNumberFormat(boolean value)
        
        Gets or sets the value indicating that number format is parsed using invariant culture or not

        When this property is set to true, number format is taken from an invariant culture.

        When this property is set to false, number format is taken from the current thread's culture.

        The default value is false.

      • getUserPromptRespondent/setUserPromptRespondent

        public IFieldUserPromptRespondent getUserPromptRespondent() / public void setUserPromptRespondent(IFieldUserPromptRespondent value)
        
        Gets or sets the respondent to user prompts during field update.

        If the value of this property is set to null, the fields that require user response on prompting (such as ASK or FILLIN) are not updated.

        The default value is null.