Example #1
0
 public ParagraphStyle(
     LineAlignment lineAlignment,
     ParagraphSpacing spacing)
 {
     this.LineAlignment = lineAlignment;
     this.Spacing       = spacing;
 }
Example #2
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));
        }
Example #3
0
        public static ParagraphSpacing Spacing(
            this Word.Paragraph paragraph,
            ParagraphSpacing defaultParagraphSpacing)
        {
            var spacingXml = paragraph.ParagraphProperties?.SpacingBetweenLines;

            return(spacingXml.ToParagraphSpacing(defaultParagraphSpacing));
        }
Example #4
0
        public static ParagraphSpacing ToParagraphSpacing(
            this Word.SpacingBetweenLines spacingXml,
            ParagraphSpacing ifNull)
        {
            if (spacingXml == null)
            {
                return(ifNull);
            }

            var before = spacingXml.Before.ToPoint();
            var after  = spacingXml.After.ToPoint();
            var line   = spacingXml.GetLineSpacing();

            return(new ParagraphSpacing(line, before, after));
        }