@@ -446,9 +446,9 @@ private static void MergeAttributes(OpenXmlElement? target, OpenXmlElement? sour
446446 {
447447 var res = new SpacingBetweenLines ( ) ;
448448 var attributes = new List < string > { "before" , "beforeLines" ,
449- "after" , "afterLines" ,
450- "beforeAutoSpacing" , "afterAutoSpacing" ,
451- "line" , "lineRule" } ;
449+ "after" , "afterLines" ,
450+ "beforeAutoSpacing" , "afterAutoSpacing" ,
451+ "line" , "lineRule" } ;
452452
453453 MergeAttributes ( res , paragraph . ParagraphProperties ? . SpacingBetweenLines , attributes ) ;
454454
@@ -630,8 +630,7 @@ private static void MergeAttributes(OpenXmlElement? target, OpenXmlElement? sour
630630 }
631631
632632 // Check run style
633- var runStyle = stylesPart . GetStyleFromId ( run . RunProperties ? . RunStyle ? . Val , StyleValues . Character ) ??
634- stylesPart . GetStyleFromId ( run . RunProperties ? . RunStyle ? . Val , StyleValues . Paragraph ) ;
633+ var runStyle = stylesPart . GetStyleFromId ( run . RunProperties ? . RunStyle ? . Val , StyleValues . Character ) ;
635634 while ( runStyle != null )
636635 {
637636 propertyValue = runStyle . StyleRunProperties ? . GetFirstChild < T > ( ) ;
@@ -645,16 +644,32 @@ private static void MergeAttributes(OpenXmlElement? target, OpenXmlElement? sour
645644 }
646645
647646 // Check paragraph style
648- var paragraphProperties = run . GetFirstAncestor < Paragraph > ( ) ? . ParagraphProperties ;
647+ var paragraphProperties = paragraph ? . ParagraphProperties ;
649648 var paragraphStyle = stylesPart . GetStyleFromId ( paragraphProperties ? . ParagraphStyleId ? . Val , StyleValues . Paragraph ) ;
650649 while ( paragraphStyle != null )
651650 {
651+ // Check paragraph style run properties
652652 propertyValue = paragraphStyle . StyleRunProperties ? . GetFirstChild < T > ( ) ;
653653 if ( propertyValue != null )
654654 {
655655 return propertyValue ;
656656 }
657657
658+ // Check linked style, if any
659+ var linkedStyleId = paragraphStyle . LinkedStyle ? . Val ;
660+ if ( linkedStyleId != null )
661+ {
662+ var linkedStyle = stylesPart . GetStyleFromId ( linkedStyleId , StyleValues . Character ) ;
663+ if ( linkedStyle != null )
664+ {
665+ propertyValue = linkedStyle . StyleRunProperties ? . GetFirstChild < T > ( ) ;
666+ if ( propertyValue != null )
667+ {
668+ return propertyValue ;
669+ }
670+ }
671+ }
672+
658673 // Check styles from which the current style inherits
659674 paragraphStyle = stylesPart . GetBaseStyle ( paragraphStyle ) ;
660675 }
0 commit comments