Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting font size for list symbol #201

Open
tmpmachine opened this issue Feb 5, 2024 · 7 comments
Open

Setting font size for list symbol #201

tmpmachine opened this issue Feb 5, 2024 · 7 comments
Labels
bug Something isn't working

Comments

@tmpmachine
Copy link

tmpmachine commented Feb 5, 2024

Related PR : #196

This PR adds option to set font size on list symbol by appending NumberingSymbolRunProperties on each Level. The issue is that this font size affect all lists with the same WordListStyle.

Here I have two list with Headings111Shifted style :

 var ListItems1 = new List<string>() { "sample " }; 
 var ListItems2 = new List<string>() { "gogo " }; 

 {
     int listFontSize = 13;
     int listSymbolFontSize = 24; // applied to all
     var wordList2 = doc.AddList(WordListStyle.Headings111Shifted, false, listSymbolFontSize);
     foreach (var point in ListItems1) {
         wordList2.AddItem($"{point}", 0)
             .SetFontSize(listFontSize);
     }
 }
 {
     int listFontSize = 22;
     int listSymbolFontSize = 55; // not applied
     var wordList2 = doc.AddList(WordListStyle.Headings111Shifted, false, listSymbolFontSize);
     foreach (var point in ListItems2 ) {
         wordList2.AddItem($"{point}", 0)
             .SetFontSize(listFontSize);
     }
 }

image

Findings so far

Both list correctly reference it's own NumberingInstance with it's own NumberingSymbolRunProperties. What could be missing?

image

image

image

image

@PrzemyslawKlys
Copy link
Member

Lists are complicated beasts. I'll take a look. For now I'll link to old PR maybe it will give you something:

@PrzemyslawKlys
Copy link
Member

So when I look at how Word deals with font size it seems to be applying it to ParagraphProperties

image

And not to AbstractNum. Is there a reason you want it done that way?

@PrzemyslawKlys
Copy link
Member

I found a reason why it doesn't work. It's related to Nsid.

image

In the original code each list has different Nsid, but only if the list is different. If the list is the same it uses same Nsid (as it's hardcoded).

For this to work, it needs to be fixed so that Nsid is randomized or have proper numbering like NumberingInstance/AbstractNum.

I did quick hack and it works...

@tmpmachine
Copy link
Author

It looks like randomizing nsid causing the continueNumbering to fail. Created a quick test in db16983.

Need more investigation, will check later.

[Fact]
public void Test_CreatingWordDocumentWithLists3() {
    
    var filePath = Path.Combine(_directoryWithFiles, "CreatedDocumentWithLists2.docx");
    using (var doc = WordDocument.Create(filePath)) {


        doc.AddParagraph("Capybaras:");
        { 
            WordList wl = doc.AddList(WordListStyle.HeadingIA1);
            wl.AddItem("Pablo");
        }
        {
            WordList wl = doc.AddList(WordListStyle.HeadingIA1, true);
            wl.AddItem("Ponyo");
        }

        doc.Save(true);
    }

}

image

@PrzemyslawKlys
Copy link
Member

PrzemyslawKlys commented Feb 12, 2024

I guess when we want to continuenumbering we will now need to refer to the original AbstractNum, instead of adding a new one...

SO when user uses WordListStyle.headingIA1, find it on the list if it's there already and if it's continueNumbering, attach to it - my guess.

@tmpmachine
Copy link
Author

tmpmachine commented Feb 13, 2024

So when I look at how Word deals with font size it seems to be applying it to ParagraphProperties

And not to AbstractNum. Is there a reason you want it done that way?

Not really, at that time I went straight to abstractnum instead of checking on a higher level (paragraph).

@PrzemyslawKlys
Copy link
Member

I've now removed restart numbering/continue numbering as it makes no sense:

If you feel this is somehow wrong please let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants