We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Revision Track Changes in Aspose

Hi Brian,

Thanks for your inquiry. To attach this file, please ZIP it and Click ‘Reply’ button that will bring you to the ‘reply page’ and there at the bottom you can include any attachments with your post by clicking the ‘Add/Update’ button. Hope, this helps.

Best regards,

Thank you Awais,
I’ve had trouble sending this zip file with licensing issues. hopefully this works. brian

Hi Brian,

Thanks for the additional information. You can use the following simple code to simulate the scenario where a Run can have Insertion as well as Deletion Revisions.

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

// Insert a new Run using user1
doc.startTrackRevisions("user1");
builder.write("Fish");

// Delete that Run using user2
Run run = (Run) doc.getFirstSection().getBody().getFirstParagraph().getFirstChild();
doc.startTrackRevisions("user2");
run.remove();

doc.stopTrackRevisions();

// Now see if this Run has a Insertion as well as Deletion Revisions
System.out.println(run.isInsertRevision() + " and " + run.isDeleteRevision());

doc.save("D:\temp**android-via-java**-17.5.docx");

Hope, this helps.

Best regards,

Hi: A follow-up: Rather than getting the same Run object and then starting revision tracking for the second user, would bookmarking the inserted text, starting revision tracking for the second user, and then setting the text within the bookmark to an empty string also work? Is there a way to find out who both authors are - i.e. the one who did the insertion as well as the one who did the deletion?

Hi Brian,

Thanks for your inquiry.

Brian:
Hi: A follow-up: Rather than getting the same Run object and then starting revision tracking for the second user, would bookmarking the inserted text, starting revision tracking for the second user, and then setting the text within the bookmark to an empty string also work? Is there a way to find out who both authors are - i.e. the one who did the insertion as well as the one who did the deletion?

Yes, this would also work. Please see the following code for example:

Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.startBookmark("bm");

// Insert a new Run using user1
doc.startTrackRevisions("user1");
builder.write("Fish");

builder.endBookmark("bm");

Bookmark bm = doc.getRange().getBookmarks().get(0);

doc.startTrackRevisions("user2");
bm.setText("");

doc.stopTrackRevisions();

Run run = null;
// Now get the Run(s) which has Insertion as well as Deletion Revisions and store them in HashMap maybe
for(Run r : (Iterable) doc.getChildNodes(NodeType.RUN, true)){
    if (r.isInsertRevision() && r.isDeleteRevision()){
        run = r;
        break;
    }
}

for (Revision rev : doc.getRevisions()) {
    if (rev.getParentNode() == run) {
        System.out.println(rev.getRevisionType() +
                " by " + rev.getAuthor() + " : " +
                rev.getParentNode().toString(SaveFormat.TEXT));
    }
}

doc.save("D:\\temp\**android-via-java**-17.5.docx");

Hope, this helps.

Best regards,

Hello Awais,
Thanks as always. My coder thinks that you missed this part of the question earlier.

For a Run object that’s both an insertion and a deletion,
getAuthor() seems to return the person who did the deletion. Is there a way to
also find out who did the insertion? In other words, is there a way to find out
both user1 and user2?

Hi Brian,

Thanks for your inquiry. No, I didn’t miss that part. The following piece of code from my previous post can be adopted to collect those Run nodes which have both Insertion as well as Deletion Revisions. And then ofcourse you can find the Authors of those Revisions.

Awais:

Run run = null;
// Now get the Run(s) which has Insertion as well as Deletion Revisions and store them in HashMap maybe
for(Run r : (Iterable) doc.getChildNodes(NodeType.RUN, true)){
    if (r.isInsertRevision() && r.isDeleteRevision()){
        run = r;
        break;
    }
}

for (Revision rev : doc.getRevisions()) {
    if (rev.getParentNode() == run) {
        System.out.println(rev.getRevisionType() +
                " by " + rev.getAuthor() + " : " +
                rev.getParentNode().toString(SaveFormat.TEXT));
    }
}

Please let us know if you need more information; we are always glad to help you.

Best regards,

thanks here is his response Okay. I think I was making an assumption that caused me to misunderstand his
answer. Here, therefore, is one more question for clarification:

If a Run is both an insertion and a deletion, does that mean that there are two
Revision objects that both point to that same Run object as their parent node?

Hi Brian,

Thanks for your inquiry. Yes, in this case, there will be two Revision objects and the ‘parent nodes’ of those Revisions will point to the same Run.

Best regards,