This is similar to WORDSNET-19193
, which was deemed user error.
See the attached project for a demonstration of the failure.
If you use CopyStylesFromTemplate
, some styles are wrong unless you access those styles before the call. I believe this only applies to styles which are default.
In our example DemonstrateSuccess()
,
Heading 3 only has the correct bold setting after CopyStylesFromTemplate
but only if you call
_ = mainDoc.Styles["Heading 3"];
beforehand…
static void Main(string[] args)
{
DemonstrateSuccess();
DemonstrateFailure();
}
public static void DemonstrateSuccess()
{
Document mainDoc = new Document("MyNormal.dotm");
Document newDoc = new Document();
_ = mainDoc.Styles["Heading 3"];
newDoc.CopyStylesFromTemplate(mainDoc);
Assert.AreEqual(mainDoc.Styles["Heading 3"].Font.Bold, newDoc.Styles["Heading 3"].Font.Bold);
}
public static void DemonstrateFailure()
{
Document mainDoc = new Document("MyNormal.dotm");
Document newDoc = new Document();
newDoc.CopyStylesFromTemplate(mainDoc);
Assert.AreEqual(mainDoc.Styles["Heading 3"].Font.Bold, newDoc.Styles["Heading 3"].Font.Bold);
}
CopyStylesFromTemplateBug.zip (5.9 MB)