public interface IRevisionCriteria
Revision should be accepted/rejected or not by the RevisionCollection.accept(com.aspose.words.IRevisionCriteria)/ RevisionCollection.reject(com.aspose.words.IRevisionCriteria) methods.
Examples:
Shows how to accept or reject revision based on criteria.
public void revisionSpecifiedCriteria() throws Exception
{
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.write("This does not count as a revision. ");
// To register our edits as revisions, we need to declare an author, and then start tracking them.
doc.startTrackRevisions("John Doe", new Date());
builder.write("This is insertion revision #1. ");
doc.stopTrackRevisions();
doc.startTrackRevisions("Jane Doe", new Date());
builder.write("This is insertion revision #2. ");
// Remove a run "This does not count as a revision.".
doc.getFirstSection().getBody().getFirstParagraph().getRuns().get(0).remove();
doc.stopTrackRevisions();
Assert.assertEquals(3, doc.getRevisions().getCount());
// We have two revisions from different authors, so we need to accept only one.
doc.getRevisions().accept(new RevisionCriteria("John Doe", RevisionType.INSERTION));
Assert.assertEquals(2, doc.getRevisions().getCount());
// Reject revision with different author name and revision type.
doc.getRevisions().reject(new RevisionCriteria("Jane Doe", RevisionType.DELETION));
Assert.assertEquals(1, doc.getRevisions().getCount());
doc.save(getArtifactsDir() + "Revision.RevisionSpecifiedCriteria.docx");
}
/// <summary>
/// Control when certain revision should be accepted/rejected.
/// </summary>
public static class RevisionCriteria implements IRevisionCriteria
{
private String AuthorName;
private int _RevisionType;
public RevisionCriteria(String authorName, int revisionType)
{
AuthorName = authorName;
_RevisionType = revisionType;
}
public boolean isMatch(Revision revision)
{
return AuthorName.equals(revision.getAuthor()) && revision.getRevisionType() == _RevisionType;
}
}
| Modifier and Type | Method and Description |
|---|---|
boolean |
isMatch(Revision revision)
Checks whether or not specified
revision matches criteria. |
boolean isMatch(Revision revision) throws java.lang.Exception
revision matches criteria.
Remarks:
The method implementation should not accept/reject the revision or modify it in any way due to unexpected results.
Examples:
Shows how to accept or reject revision based on criteria.
public void revisionSpecifiedCriteria() throws Exception
{
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
builder.write("This does not count as a revision. ");
// To register our edits as revisions, we need to declare an author, and then start tracking them.
doc.startTrackRevisions("John Doe", new Date());
builder.write("This is insertion revision #1. ");
doc.stopTrackRevisions();
doc.startTrackRevisions("Jane Doe", new Date());
builder.write("This is insertion revision #2. ");
// Remove a run "This does not count as a revision.".
doc.getFirstSection().getBody().getFirstParagraph().getRuns().get(0).remove();
doc.stopTrackRevisions();
Assert.assertEquals(3, doc.getRevisions().getCount());
// We have two revisions from different authors, so we need to accept only one.
doc.getRevisions().accept(new RevisionCriteria("John Doe", RevisionType.INSERTION));
Assert.assertEquals(2, doc.getRevisions().getCount());
// Reject revision with different author name and revision type.
doc.getRevisions().reject(new RevisionCriteria("Jane Doe", RevisionType.DELETION));
Assert.assertEquals(1, doc.getRevisions().getCount());
doc.save(getArtifactsDir() + "Revision.RevisionSpecifiedCriteria.docx");
}
/// <summary>
/// Control when certain revision should be accepted/rejected.
/// </summary>
public static class RevisionCriteria implements IRevisionCriteria
{
private String AuthorName;
private int _RevisionType;
public RevisionCriteria(String authorName, int revisionType)
{
AuthorName = authorName;
_RevisionType = revisionType;
}
public boolean isMatch(Revision revision)
{
return AuthorName.equals(revision.getAuthor()) && revision.getRevisionType() == _RevisionType;
}
}
revision - The Revision instance to match criteria.True if the revision matches criteria, otherwise False.java.lang.Exception