Hi Gökhan,
Thanks for your inquiry. Regarding WORDSJAVA-1275, our product team has completed the work on your issue and has come to a conclusion that this issue and the undesired behavior you're observing is actually not a bug. So, we will close this issue as 'Not a Bug'.
This is MS Word's behavior. We slightly simplified your scenario as follows:
Document doc = new Document(getMyDir() + "Buggy.docx");
// process report
doc.getMailMerge().execute(new DataSource());
// cleanup: REF fields and page counters may contain an intermediate state, therefore we need an explicit update on all remaining fields
doc.updateFields();
doc.save(getMyDir() + "out.docx");
static class DataSource implements IMailMergeDataSource
{
private boolean first = true;
public String getTableName()
{
return "";
}
public boolean moveNext()
{
if (first)
{
first = false;
return true;
}
return false;
}
public boolean getValue(String fieldName, Object[] paramArrayOfObject)
{
if ("merge_field".equals(fieldName))
{
paramArrayOfObject[0] = "REPLACED MERGE FIELD";
return true;
}
if ("my_ref".equals(fieldName))
{
paramArrayOfObject[0] = "REPLACED REF FIELD";
return true;
}
//paramArrayOfObject[0] = null;
return false;
}
public IMailMergeDataSource getChildDataSource(String tableName)
{
return null;
}
}
Note that REF field in your scenario is not removed, it is just replaced with empty string.