EvotecIT / OfficeIMO

Fast and easy to use cross-platform .NET library that creates or modifies Microsoft Word (DocX) and later also Excel (XLSX) files without installing any software. Library is based on Open XML SDK
MIT License
286 stars 50 forks source link

Remove continue numbering & restart numbering for lists #204

Closed PrzemyslawKlys closed 7 months ago

PrzemyslawKlys commented 7 months ago

So I'm thinking that we need to remove continue numbering completely as it doesn't make sense to keep it.

If you want to continue numbering then you basically create a list and attach items to it at any place and it refers original AbstractNum.

internal static void Example_BasicLists3(string folderPath, bool openWord) {
    string filePath = System.IO.Path.Combine(folderPath, "Document with Lists3.docx");
    using (WordDocument document = WordDocument.Create(filePath)) {
        var paragraph = document.AddParagraph("This is 1st list");
        paragraph.ParagraphAlignment = JustificationValues.Center;

        WordList wordList1 = document.AddList(WordListStyle.Headings111);
        wordList1.AddItem("Text 1");
        wordList1.AddItem("Text 2", 1);
        wordList1.AddItem("Text 3", 2);

        paragraph = document.AddParagraph("This is 2nd list");
        paragraph.ParagraphAlignment = JustificationValues.Center;

        WordList wordList2 = document.AddList(WordListStyle.Headings111);
        wordList2.AddItem("Text 1");
        wordList2.AddItem("Text 2", 1);
        wordList2.AddItem("Text 3", 2);

        paragraph = document.AddParagraph("This is 3rd list").SetColor(Color.DeepPink).SetUnderline(UnderlineValues.Double);
        paragraph.ParagraphAlignment = JustificationValues.Center;

        WordList wordList3 = document.AddList(WordListStyle.Bulleted);
        wordList3.AddItem("Text 8.1", 1);
        wordList3.AddItem("Text 8.2", 2);
        wordList3.AddItem("Text 8.3", 2);
        wordList3.AddItem("Text 8.4", 0);
        wordList3.AddItem("Text 8.5", 0);
        wordList3.AddItem("Text 8.6", 1);
        wordList3.AddItem("Text 8");

        paragraph = document.AddParagraph("This is 4th list").SetColor(Color.Aqua).SetUnderline(UnderlineValues.Double);
        paragraph.ParagraphAlignment = JustificationValues.Center;

        WordList wordList4 = document.AddList(WordListStyle.Bulleted);
        wordList4.AddItem("Text 8");
        wordList4.AddItem("Text 8.1", 1);
        wordList4.AddItem("Text 8.2", 2);
        wordList4.AddItem("Text 8.3", 2);
        wordList4.AddItem("Text 8.4", 0);
        wordList4.AddItem("Text 8.5", 0);
        wordList4.AddItem("Text 8.6", 1);

        document.Save(openWord);
    }
}

When I look at how Word behaves when you do Continue Numbering it basically reattaches current list to existing list and leaves the other one not used at all (at least I think that's what I see).

That means the whole continue numbering thing is not going to make any sense as it's the same list.

Same goes for restart numbering - it makes no sense. The only thing that makes sense is to have RestartNumberingAfterBreak which changes how things are.

So the solution is: