False Deletion Revisions

Hi

We are using Aspose.Words to compare two documents, however we are seeing what appears to be False Deletion Revisions

Please see the attached console test harnessAspose.Words.FalseRevisions.zip (25.3 KB)

This application requires VS 2017 and will require nuget packages to be restored

When run the app will take DocumentA and DocumentB and create a comparison document (output to \bin\Debug\Output Documents)

If you open the output document you will see a Deletion, however the DocumentA and DocumentB appear to be identical, can you please advise

Thanks

@david.hancock.imagef,

Thanks for your inquiry. Please note that Aspose.Words mimics the behavior of MS Word. If you compare the documents using MS Word, you will get the delete revision. The attached image shows the MS Word’s comparison. ms word comparison.png (41.3 KB)

Thanks for the response

When i run the same compare in WORD, I don’t get the Deletion, see attached

Capture.JPG (270.6 KB)

Looking at the revision object, how do I determine what Deletion has picked up

@david.hancock.imagef,

Thanks for your inquiry. Please ignore the “Formatting” from comparison setting during comparing the document. Please check Comparison setting.png (11.7 KB). You can see the delete revision in reviewing pane. Please check Delete Revision.png (57.9 KB)
.

Hi

Capture2.JPG (313.0 KB)

I’ve done that in MS Word and I still don’t get the Deletion revision, I simply don’t get the same odd false deletion that I am seeing with Aspose.

I would like to programmatically remove these odd false deletions

from the Revision object how can I see what the actually deletion text is, as In this case Aspose thinks it a CRLF

Thanks

@david.hancock.imagef,

Thanks for your inquiry. After further investigation, we have noticed that Aspose.Words generates one extra delete revision. Please check the attached image for detail. aspose.words.png (48.9 KB).

For the sake of correction, we have logged this problem in our issue tracking system as WORDSNET-16598. You will be notified via this forum thread once this issue is resolved. We apologize for your inconvenience.

Please use the following code snippet to remove the delete revision after comparing document. Hope this helps you.

wordDocument1.Compare(wordDocument2, "DocumentCompare", DateTime.Now, compareOptions);

ArrayList formatRevisions = new ArrayList();
for (int index = 0; index < wordDocument1.Revisions.Count; index++)
{
    switch (wordDocument1.Revisions[index].RevisionType)

    {
        case RevisionType.Deletion:
            formatRevisions.Add(wordDocument1.Revisions[index]);
            break;
        default: break;
    }
}

// Accept all collected revisions.
foreach (Revision revision in formatRevisions)
    revision.Accept();

Thanks,

Perhaps I was not clear enough, we want to be able to remove ANY false deletions that we are seeing

How can we programmatically test for the false deletion?, using the revision objects how can we what the extract Deletion being pick up, as in this case it appears to be CRLF

@david.hancock.imagef,

Thanks for your inquiry. The Revision.ParentNode property returns the immediate parent node (owner) of this revision. Please use this property to check if the parent node of revision is Paragraph node and use Node.ToString(SaveFormat.Text) method to check if it is empty paragraph or not. If paragraph is empty, you can accept or reject the revision according to your requirement.

In your scenario, the empty paragraph is the last paragraph of section. You can use following code snippet to get the desired output. Hope this helps you.

foreach (Revision revision in formatRevisions)
{
    if (revision.ParentNode.NodeType == NodeType.Paragraph && ((Paragraph)revision.ParentNode).IsEndOfSection)
        revision.Accept();
}