com.aspose.words
Class FieldUpdatingProgressArgs

java.lang.Object
    extended by com.aspose.words.FieldUpdatingProgressArgs

public class FieldUpdatingProgressArgs 
extends java.lang.Object

Provides data for the field updating progress event.

Example:

Shows how to use callback methods during a field update.
public void fieldUpdatingCallbackTest() throws Exception
{
    Document doc = new Document();
    DocumentBuilder builder = new DocumentBuilder(doc);

    builder.insertField(" DATE \\@ \"dddd, d MMMM yyyy\" ");
    builder.insertField(" TIME ");
    builder.insertField(" REVNUM ");
    builder.insertField(" AUTHOR  \"John Doe\" ");
    builder.insertField(" SUBJECT \"My Subject\" ");
    builder.insertField(" QUOTE \"Hello world!\" ");

    FieldUpdatingCallback callback = new FieldUpdatingCallback();
    doc.getFieldOptions().setFieldUpdatingCallback(callback);

    doc.updateFields();

    Assert.assertTrue(callback.getFieldUpdatedCalls().contains("Updating John Doe"));
}

/// <summary>
/// Implement this interface if you want to have your own custom methods called during a field update.
/// </summary>
public static class FieldUpdatingCallback implements IFieldUpdatingCallback
{
    public FieldUpdatingCallback()
    {
        mFieldUpdatedCalls = new ArrayList<String>();
    }

    /// <summary>
    /// A user defined method that is called just before a field is updated.
    /// </summary>
    public void /*IFieldUpdatingCallback.*/fieldUpdating(Field field) {
        if (field.getType() == FieldType.FIELD_AUTHOR)
        {
            FieldAuthor fieldAuthor = (FieldAuthor) field;
            try {
                fieldAuthor.setAuthorName("Updating John Doe");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    /// <summary>
    /// A user defined method that is called just after a field is updated.
    /// </summary>
    public void /*IFieldUpdatingCallback.*/fieldUpdated(Field field)
    {
        getFieldUpdatedCalls().add(field.getResult());
    }

    public ArrayList<String> getFieldUpdatedCalls() { return mFieldUpdatedCalls; };

    private ArrayList<String> mFieldUpdatedCalls;
}

Property Getters/Setters Summary
intgetTotalFieldsCount()
           Gets the total fields count to be updated.
booleangetUpdateCompleted()
           Gets a value indicating whether field updating is completed.
intgetUpdatedFieldsCount()
           Gets the number of updated fields.
 

Property Getters/Setters Detail

getTotalFieldsCount

public int getTotalFieldsCount()
Gets the total fields count to be updated. The value is not constant and may be increased during updating process.

Example:

Shows how to use callback methods during a field update.
public void fieldUpdatingCallbackTest() throws Exception
{
    Document doc = new Document();
    DocumentBuilder builder = new DocumentBuilder(doc);

    builder.insertField(" DATE \\@ \"dddd, d MMMM yyyy\" ");
    builder.insertField(" TIME ");
    builder.insertField(" REVNUM ");
    builder.insertField(" AUTHOR  \"John Doe\" ");
    builder.insertField(" SUBJECT \"My Subject\" ");
    builder.insertField(" QUOTE \"Hello world!\" ");

    FieldUpdatingCallback callback = new FieldUpdatingCallback();
    doc.getFieldOptions().setFieldUpdatingCallback(callback);

    doc.updateFields();

    Assert.assertTrue(callback.getFieldUpdatedCalls().contains("Updating John Doe"));
}

/// <summary>
/// Implement this interface if you want to have your own custom methods called during a field update.
/// </summary>
public static class FieldUpdatingCallback implements IFieldUpdatingCallback
{
    public FieldUpdatingCallback()
    {
        mFieldUpdatedCalls = new ArrayList<String>();
    }

    /// <summary>
    /// A user defined method that is called just before a field is updated.
    /// </summary>
    public void /*IFieldUpdatingCallback.*/fieldUpdating(Field field) {
        if (field.getType() == FieldType.FIELD_AUTHOR)
        {
            FieldAuthor fieldAuthor = (FieldAuthor) field;
            try {
                fieldAuthor.setAuthorName("Updating John Doe");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    /// <summary>
    /// A user defined method that is called just after a field is updated.
    /// </summary>
    public void /*IFieldUpdatingCallback.*/fieldUpdated(Field field)
    {
        getFieldUpdatedCalls().add(field.getResult());
    }

    public ArrayList<String> getFieldUpdatedCalls() { return mFieldUpdatedCalls; };

    private ArrayList<String> mFieldUpdatedCalls;
}

getUpdateCompleted

public boolean getUpdateCompleted()
Gets a value indicating whether field updating is completed.

Example:

Shows how to use callback methods during a field update.
public void fieldUpdatingCallbackTest() throws Exception
{
    Document doc = new Document();
    DocumentBuilder builder = new DocumentBuilder(doc);

    builder.insertField(" DATE \\@ \"dddd, d MMMM yyyy\" ");
    builder.insertField(" TIME ");
    builder.insertField(" REVNUM ");
    builder.insertField(" AUTHOR  \"John Doe\" ");
    builder.insertField(" SUBJECT \"My Subject\" ");
    builder.insertField(" QUOTE \"Hello world!\" ");

    FieldUpdatingCallback callback = new FieldUpdatingCallback();
    doc.getFieldOptions().setFieldUpdatingCallback(callback);

    doc.updateFields();

    Assert.assertTrue(callback.getFieldUpdatedCalls().contains("Updating John Doe"));
}

/// <summary>
/// Implement this interface if you want to have your own custom methods called during a field update.
/// </summary>
public static class FieldUpdatingCallback implements IFieldUpdatingCallback
{
    public FieldUpdatingCallback()
    {
        mFieldUpdatedCalls = new ArrayList<String>();
    }

    /// <summary>
    /// A user defined method that is called just before a field is updated.
    /// </summary>
    public void /*IFieldUpdatingCallback.*/fieldUpdating(Field field) {
        if (field.getType() == FieldType.FIELD_AUTHOR)
        {
            FieldAuthor fieldAuthor = (FieldAuthor) field;
            try {
                fieldAuthor.setAuthorName("Updating John Doe");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    /// <summary>
    /// A user defined method that is called just after a field is updated.
    /// </summary>
    public void /*IFieldUpdatingCallback.*/fieldUpdated(Field field)
    {
        getFieldUpdatedCalls().add(field.getResult());
    }

    public ArrayList<String> getFieldUpdatedCalls() { return mFieldUpdatedCalls; };

    private ArrayList<String> mFieldUpdatedCalls;
}

getUpdatedFieldsCount

public int getUpdatedFieldsCount()
Gets the number of updated fields.

Example:

Shows how to use callback methods during a field update.
public void fieldUpdatingCallbackTest() throws Exception
{
    Document doc = new Document();
    DocumentBuilder builder = new DocumentBuilder(doc);

    builder.insertField(" DATE \\@ \"dddd, d MMMM yyyy\" ");
    builder.insertField(" TIME ");
    builder.insertField(" REVNUM ");
    builder.insertField(" AUTHOR  \"John Doe\" ");
    builder.insertField(" SUBJECT \"My Subject\" ");
    builder.insertField(" QUOTE \"Hello world!\" ");

    FieldUpdatingCallback callback = new FieldUpdatingCallback();
    doc.getFieldOptions().setFieldUpdatingCallback(callback);

    doc.updateFields();

    Assert.assertTrue(callback.getFieldUpdatedCalls().contains("Updating John Doe"));
}

/// <summary>
/// Implement this interface if you want to have your own custom methods called during a field update.
/// </summary>
public static class FieldUpdatingCallback implements IFieldUpdatingCallback
{
    public FieldUpdatingCallback()
    {
        mFieldUpdatedCalls = new ArrayList<String>();
    }

    /// <summary>
    /// A user defined method that is called just before a field is updated.
    /// </summary>
    public void /*IFieldUpdatingCallback.*/fieldUpdating(Field field) {
        if (field.getType() == FieldType.FIELD_AUTHOR)
        {
            FieldAuthor fieldAuthor = (FieldAuthor) field;
            try {
                fieldAuthor.setAuthorName("Updating John Doe");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }

    /// <summary>
    /// A user defined method that is called just after a field is updated.
    /// </summary>
    public void /*IFieldUpdatingCallback.*/fieldUpdated(Field field)
    {
        getFieldUpdatedCalls().add(field.getResult());
    }

    public ArrayList<String> getFieldUpdatedCalls() { return mFieldUpdatedCalls; };

    private ArrayList<String> mFieldUpdatedCalls;
}

See Also:
          Aspose.Words Documentation - the home page for the Aspose.Words Product Documentation.
          Aspose.Words Support Forum - our preferred method of support.