Left Indent is Incorrect After Applying Style to Paragraph using .NET

I’ve noticed that if I use a list, that if a Style is assigned to the next paragraph, it doesn’t apply correctly.
LeftIndent on the paragraphFormat is zero, but LeftIndent on the paragraphFormat.Style.ParagraphFormat.LeftIndent is not.
However, if I clear formatting and then apply a style, then it is applied correctly.

Our product is producing word documents from configuration, rather than hard-coding, so it’s not clear what impact ClearFormatting() will have on our system.

Is this expected behaviour (that the Style didn’t update the paragraph’s formatting?)

	public static void Test()
	{
		var doc = new Aspose.Words.Document();
		doc.CopyStylesFromTemplate(@"c:\temp\IndentedStyleTemplate.dotx");
		var builder = new Aspose.Words.DocumentBuilder(doc);
		var list = doc.Lists.Add(Aspose.Words.Lists.ListTemplate.NumberArabicDot);
		
		builder.ListFormat.List = list;
		builder.Writeln("List item 1");
		builder.Writeln("List item 2");
		builder.ListFormat.RemoveNumbers();
		builder.Writeln("Setting style");
		builder.CurrentParagraph.ParagraphFormat.Style = doc.Styles["SmallIndent"];
		builder.Writeln("This line should be indented but it isn't");

		builder.Writeln("");
		builder.ParagraphFormat.ClearFormatting();
		builder.Writeln("Setting style again");
		builder.CurrentParagraph.ParagraphFormat.Style = doc.Styles["SmallIndent"];
		builder.Writeln("This line should be indented");

		doc.Save(@"c:\temp\Output.docx");
	}

I was going to attach the template, but can’t seem to find the ‘attachments’ button. All SmallIndent is, is a paragraph style indented by a centimetre.

@GMiddleton

Could you please ZIP and attach the ‘IndentedStyleTemplate.dotx’ here for testing? Please also share the expected output Word document. We will investigate the issue and provide you more information on it.

IndentedStyleTemplate.zip (10.5 KB)

Please find enclosed the template used.

Thank you

And the expected/actual outputsOutputs.zip (39.8 KB)

@GMiddleton

We suggest you please call the ParagraphFormat.ClearFormatting before applying the style to paragraph. However, to find the root cause of this issue, we have logged this problem in our issue tracking system as WORDSNET-21457. You will be notified via this forum thread once this issue is resolved.

We apologize for your inconvenience.