List behaviour while tracking changes

Hi,
While keeping the track changes ON in a word document
If I parse the following List after adding a new element in a list

  1. Level 1
    1.1) Level 1.1
    Text at level 1.

1.2) New Added Level
Text at new added level

1.3) Level 1.2
2) Level 2
(“New Added level” being the new inserted text)
For both “New Added Level” and “Text at new added level” if the text was inserted in Ms Word 2007 its gives list level as 1

and for the same in Ms Word 2003 it gives “New Added Level” at list level 1 and “Text at new added level” at list level 0
Why is this behaving so in Ms Word 2007 and what should be done to resolve this problem
Thanks in advance

Hi

Thanks for your inquiry. Could you please attach your documents and code here for testing? I will check the issue and provide you more information.
Best regards.

Hi,
Please find the attached documents MS2003.doc is edited in Ms Word 2003 and MS2007.doc is edited in Ms Word 2007
The code is as follows:

Document doc = new Document("C:/MS2003.doc");
DocumentBuilder dbuilder = new DocumentBuilder(doc);
doc.unprotect();
NodeCollection docSections = doc.getChildNodes(NodeType.PARAGRAPH, true);
for (Paragraph paragraph : docSections)
{
    ListFormat listFormatLevel1 = paragraph.getListFormat();
    System.out.println("Paragraph : " + paragraph.getText() + "level : " + listFormatLevel1.getListLevelNumber());
}

Just changing the file name for second run.
Thanks

Hello

Thank you for additional information. I have tried to save MS2003.doc using MS Words 2007 and after running your code I got the same result (as with original document). So I cannot see the problem here.
Best regards,

Hi,
Thanks for your prompt reply. But the problem persists at my end.
Please find another attached document Test1.doc , this document is created in Ms Word 2003 and the track changes were kept on. After editing it in 2007 I get the same result.

Document doc = new Document("C:/Test1.doc");
DocumentBuilder dbuilder = new DocumentBuilder(doc);
NodeCollection docSections = doc.getChildNodes(NodeType.PARAGRAPH, true);
for (Paragraph paragraph : docSections)
{
    ListFormat listFormatLevel1 = paragraph.getListFormat();
    System.out.println("Paragraph : " + paragraph.getText() + "level : " + listFormatLevel1.getListLevelNumber() + "\n");
}

Hi
Thank you for additional information. Some of your paragraphs are not list items, that is why you see ListLevel = 0.
Please try using the following code:

NodeCollection<Paragraph> docSections = doc.getChildNodes(NodeType.PARAGRAPH, true);
for (Paragraph paragraph : docSections)
{
    if (paragraph.isListItem())
    {
        ListFormat listFormatLevel1 = paragraph.getListFormat();
        System.out.println("Paragraph : " + paragraph.getText() + "level : " + listFormatLevel1.getListLevelNumber());
    }
}

Best regards,

Hi,

I tried with the code you said. But i am still not getting expected output.
Please find attached java file and test.doc.

I am getting the following output:
Paragraph : Section 1
level : 0
Paragraph : Clause 1
level : 1
Paragraph : Data in clause 1
level : 2
Paragraph : Section 2
level : 2
Paragraph : Clause 2
level : 2
Paragraph : Data in clause 2level : 2

While the expected output is:
Paragraph : Section 1
level : 0
Paragraph : Clause 1
level : 1
Paragraph : Data in clause 1
level : 2
Paragraph : Section 2
level : 0
Paragraph : Clause 2
level : 1
Paragraph : Data in clause 2level : 2

Thanks in advance.

Hi

Thank you for additional information. I managed to reproduce the problem on my side. Your request has been linked to the appropriate issue. You will be notified as soon as it is fixed.
As a workaround you can try calling acceptAllRevisions method before retrieving ListNumber.
Best regards,

Hi,
Thanks for the information. As of now i am working with the workaround. Can you provide me with the issue number of the same so i can keep a follow up with the same.
Warm Regards,

Hi

Thanks for your request. The issue number is 19333.
Best regards,

Hi,

Are there any updates on the issue 19333?

Can you please take it on priority. Its directly affecting a major feature in our product and hence our customers.

Thanks and Regards,
Tarul

Hi
Thanks for your request. Unfortunately, at the moment I cannot provide you any additional information regarding this issue. I added your request into my monthly report, this will push the issue up in the priority list. We will let you know once the issue is resolved.
Best regards,

I think the correct output before accepting changes is:
0
1
2
2
2
2
Then the correct output after accepting changes is:
0
1
2
0
1
2
Was this what you were getting before or not?
We fixed some other issues in revisions in AW and I think this addressed the problem so it outputs the results as show above. I think it is correct and I am closing this issue. It will be released end of May.

Hi Romnak,

What you said is right that it behaves perfect once we accept the changes in 2007 the list levels read are correct.

But in 2003 it works without accepting the track changes. I dont think that this issue is solved.

Thanks and Regards
Tarul.

Hi Tarul,
Thank you for additional information. Here is code I used for testing:

    @Test
    public void Test001() throws Exception {
        Document doc = new Document("C:\\Temp\\Test.doc");
        PrintListLevels(doc);
        System.out.println("===============================");
        doc.acceptAllRevisions();
        PrintListLevels(doc);
    }
    private void PrintListLevels(Document doc)
    {
        NodeCollection<Paragraph> docSections = doc.getChildNodes(NodeType.PARAGRAPH, true);
        for (Paragraph paragraph : docSections)
        {
            if (paragraph.isListItem())
            {
                ListFormat listFormatLevel1 = paragraph.getListFormat();
                System.out.println("Paragraph : " + paragraph.getText() + "level : "+ listFormatLevel1.getListLevelNumber());
            }
        }
    }

I checked list levels before and after accepting revisions in your document. The output is expected, just as Roman mentioned.
Best regards,

Hi Alexey,

I know it works for 2007 document once Accept all revisions are done.

But , we do not need to Accept all revisions in 2003 document for the same.

Please find attached documents created and edited with track changes on in 2003 and 2007 respectively. And below is the code i used to test it.

public class ListTest
{
    public static void main(String[] args)
    {
        try
        {
            //Document doc = new Document("C:/ListLevel2003.doc");
            Document doc = new Document("C:/ListLevel2007.doc");
            NodeCollection docSections = doc.getChildNodes(NodeType.PARAGRAPH, true);

            for (Paragraph paragraph : docSections)
            {
                if (paragraph.isListItem())
                {
                    ListFormat listFormatLevel1 = paragraph.getListFormat();
                    System.out.println("Paragraph : " + paragraph.getText() + "level : "
                        +listFormatLevel1.getListLevelNumber());
                }
            }
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }
}

Thanks and Regards,
Tarul

Hi Tarul,
Thank you for additional information. But still I do not see any problems. To make sure that Aspose.Words returns correct values I created the same test code using MS Word Automation.
Here is my Java code for testing:

    @Test
    public void Test001() throws Exception {
        Document doc = new Document("C:\\Temp\\ListLevel2003.doc");
        PrintListLevels(doc);
        doc.acceptAllRevisions();
        System.out.println("===================");
        PrintListLevels(doc);
    }
    private static void PrintListLevels(Document doc)
    {
        NodeCollection<Paragraph> docSections = doc.getChildNodes(NodeType.PARAGRAPH, true);
        for (Paragraph paragraph : docSections)
        {
            if (paragraph.isListItem())
            {
                ListFormat listFormatLevel1 = paragraph.getListFormat();
                System.out.println("Paragraph : " + paragraph.getText() + "level : "
                        \+ listFormatLevel1.getListLevelNumber());
            }
        }
    }

Here is my C# code that used Word automation:

    static void Main(string[] args)
    {
        Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application();
        Microsoft.Office.Interop.Word.Document doc = new Microsoft.Office.Interop.Word.Document();
        object missing = Type.Missing;
        object donotSaveChagnes = Microsoft.Office.Interop.Word.WdSaveOptions.wdDoNotSaveChanges;
        object fileName = @"C:\Temp\ListLevel2003.doc";
        doc = app.Documents.Open(ref fileName, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
        PrintListLevels(app.ActiveDocument);
        doc.AcceptAllRevisions();
        Console.WriteLine("=========================");
        PrintListLevels(app.ActiveDocument);
        doc.Close(ref donotSaveChagnes, ref missing, ref missing);
        Console.ReadLine();
    }
    private static void PrintListLevels(Microsoft.Office.Interop.Word.Document doc)
    {
        for (int i = 1; i <= doc.ListParagraphs.Count; i++)
        {
            object shapeIndex = i;
            Console.WriteLine(" Paragraph : {0} \n level : {1}", doc.ListParagraphs[i].Range.Text, doc.ListParagraphs[i].Range.ListFormat.ListLevelNumber);
        }
    }

I put test results in the table.

MS Word Automation Aspose.Words for Java
Paragraph : Section 1
level : 1
Paragraph : Clause 1
level : 2
Paragraph : Section New
level : 1
Paragraph : Clause New
level : 2
Paragraph : Section 2
level : 1
Paragraph : Clause 2
level : 2
Paragraph : Section 3
level : 1
Paragraph : Clause 3
level : 2
=========================
Paragraph : Section 1
level : 1
Paragraph : Clause 1
level : 2
Paragraph : Section New
level : 1
Paragraph : Clause New
level : 2
Paragraph : Section 2
level : 1
Paragraph : Clause 2
level : 2
Paragraph : Section 3
level : 1
Paragraph : Clause 3
level : 2
Paragraph : Section 1
level : 0
Paragraph : Clause 1
level : 1
Paragraph : Section New
level : 0
Paragraph : Clause New
level : 1
Paragraph : Section 2
level : 0
Paragraph : Clause 2
level : 1
Paragraph : Section 3
level : 0
Paragraph : Clause 3
level : 1
===================
Paragraph : Section 1
level : 0
Paragraph : Clause 1
level : 1
Paragraph : Section New
level : 0
Paragraph : Clause New
level : 1
Paragraph : Section 2
level : 0
Paragraph : Clause 2
level : 1
Paragraph : Section 3
level : 0
Paragraph : Clause 3
level : 1

As you can see the only difference between MS Word Automation and Aspose.Words outputs is that Aspose.Words uses zero-based list level numbers.
Best regards.

Hi Alexey,

I tried using your code with ListLevel2007.doc document. I am using Aspose.Words for Java 10.0.1 version.
Here is the output I got.

Before Accepting Changes:
Paragraph : Section 1
level : 0
Paragraph : Cl 1
level : 1
Paragraph : Section 2
level : 0
Paragraph : Cl 2
level : 1
Paragraph : Cl3
level : 1
Paragraph : Section new
level : 1
Paragraph : Cl new
level : 1
Paragraph : Section 3
level : 0
Paragraph : Cl 4_level : 1
===================
After Accepting Changes:
Paragraph : Section 1
level : 0
Paragraph : Cl 1
level : 1
Paragraph : Section 2
level : 0
Paragraph : Cl 2
level : 1
Paragraph : Cl3
level : 1
Paragraph : Section new
level : 0
Paragraph : Cl new
level : 1
Paragraph : Section 3
level : 0
Paragraph : Cl 4_level : 1

Attached is the code and document.
I just want to highlight that I do not want to accept the revisions of the document. I expect the output same every time (before or after accepting revisions). Again just to stress this works as expected in documents created in MS Word 2003 (without accepting revisions) and fails for higher version of MS Word.
For your reference following is the expected output:
Before Accepting Changes:
Paragraph : Section 1
level : 0
Paragraph : Cl 1
level : 1
Paragraph : Section 2
level : 0
Paragraph : Cl 2
level : 1
Paragraph : Cl3
level : 1
Paragraph : Section new
level : 0
Paragraph : Cl new
level : 1
Paragraph : Section 3
level : 0
Paragraph : Cl 4_level : 1
===================
After Accepting Changes:
Paragraph : Section 1
level : 0
Paragraph : Cl 1
level : 1
Paragraph : Section 2
level : 0
Paragraph : Cl 2
level : 1
Paragraph : Cl3
level : 1
Paragraph : Section new
level : 0
Paragraph : Cl new
level : 1
Paragraph : Section 3
level : 0
Paragraph : Cl 4_level : 1

Thanks,
Tarul

Hi Tarul,
Thank you for additional information. What I try to explain is that Aspose.Words does not calculate these values. Aspose.Words just returns the values stored in the document. So I am still sure that here is no problem in Aspose.Words.
Best regards,

The issues you have found earlier (filed as 19333) have been fixed in this .NET update and in this Java update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.