Example #1
0
        public static ParagraphSpacing Override(
            this ParagraphSpacing defaultSpacing,
            Word.SpacingBetweenLines spacingBetweenLines,
            params Word.SpacingBetweenLines[] prioritized)
        {
            StringValue before = null;
            StringValue after  = null;
            StringValue line   = null;
            EnumValue <Word.LineSpacingRuleValues> lineRule = null;

            foreach (var spacing in new[] { spacingBetweenLines }.Union(prioritized).Where(s => s != null))
            {
                before   = before ?? spacing.Before;
                after    = after ?? spacing.After;
                line     = line ?? spacing.Line;
                lineRule = lineRule ?? spacing.LineRule;

                if (before != null && after != null && line != null)
                {
                    break;
                }
            }

            var bf = before?.ToPoint() ?? defaultSpacing.Before;
            var af = after?.ToPoint() ?? defaultSpacing.After;
            var ls = line?.GetLineSpacing(lineRule) ?? defaultSpacing.Line;

            return(new ParagraphSpacing(ls, bf, af));
        }