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

The order of paragraph properties and runs does matter #83

Merged
merged 1 commit into from
Nov 25, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions OfficeIMO.Word/WordList.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using DocumentFormat.OpenXml;
Expand Down Expand Up @@ -59,7 +59,6 @@ public WordParagraph AddItem(string text, int level = 0) {
var run = new Run();
run.Append(new RunProperties());
run.Append(new Text { Space = SpaceProcessingModeValues.Preserve });
paragraph.Append(run);

var paragraphProperties = new ParagraphProperties();
paragraphProperties.Append(new ParagraphStyleId { Val = "ListParagraph" });
Expand All @@ -69,7 +68,7 @@ public WordParagraph AddItem(string text, int level = 0) {
new NumberingId { Val = _numberId }
));
paragraph.Append(paragraphProperties);

paragraph.Append(run);
_wordprocessingDocument.MainDocumentPart!.Document.Body!.AppendChild(paragraph);

var wordParagraph = new WordParagraph(_document, paragraph, run) {
Expand All @@ -87,15 +86,15 @@ public WordParagraph AddItem(string text, int level = 0) {
internal static int GetNextAbstractNum(Numbering numbering) {
var ids = numbering.ChildElements
.OfType<AbstractNum>()
.Select(element => (int) element.AbstractNumberId)
.Select(element => (int)element.AbstractNumberId)
.ToList();
return ids.Count > 0 ? ids.Max() + 1 : 1;
}

internal static int GetNextNumberingInstance(Numbering numbering) {
var ids = numbering.ChildElements
.OfType<NumberingInstance>()
.Select(element => (int) element.NumberID)
.Select(element => (int)element.NumberID)
.ToList();
return ids.Count > 0 ? ids.Max() + 1 : 1;
}
Expand Down