Exemplo n.º 1
0
        private List <Portion> GetPortions(A.Paragraph aParagraph, SCParagraph paragraph)
        {
            IEnumerable <A.Run> aRuns = aParagraph.Elements <A.Run>();

            if (aRuns.Any())
            {
                var runPortions = new List <Portion>(aRuns.Count());
                foreach (A.Run aRun in aRuns)
                {
                    runPortions.Add(new Portion(aRun.Text, paragraph));
                }

                return(runPortions);
            }

            A.Field aField = aParagraph.GetFirstChild <A.Field>();
            if (aField != null)
            {
                A.Text aText          = aParagraph.GetFirstChild <A.Field>().GetFirstChild <A.Text>();
                var    aFieldPortions = new List <Portion>(new[] { new Portion(aText, paragraph) });
                return(aFieldPortions);
            }

            return(new List <Portion>());
        }
Exemplo n.º 2
0
        private List <Portion> PortionsFromField()
        {
            var text     = _xmlParagraph.GetFirstChild <A.Field>().GetFirstChild <A.Text>().Text;
            var fh       = FontHeightFromOther();
            var portions = new List <Portion>(1)
            {
                new Portion(text, fh)
            };

            return(portions);
        }
Exemplo n.º 3
0
 // ReSharper disable once UnusedParameter.Local
 private static void UpdatePowerPointBlock(OpenXmlPartContainer container, OpenXmlElement block, string content)
 {
     OXP.Shape shape = (OXP.Shape)block.CloneNode(true);
     OXD.Run   run   = (OXD.Run)shape.TextBody.Descendants <OXD.Run>().First().CloneNode(true);
     run.Text = new OXD.Text(content);
     OXD.Paragraph paragraph = shape.TextBody.GetFirstChild <OXD.Paragraph>();
     paragraph.RemoveAllChildren <OXD.Run>();
     OXD.EndParagraphRunProperties endP = paragraph.GetFirstChild <OXD.EndParagraphRunProperties>();
     paragraph.InsertBefore(run, endP);
     block.Parent.ReplaceChild(shape, block);
 }
Exemplo n.º 4
0
        public static a.Paragraph SetTextAlignment(this a.Paragraph paragraph, a.TextAlignmentTypeValues textAlignment)
        {
            var paragraphProperties = paragraph.GetFirstChild <a.ParagraphProperties>();

            if (paragraphProperties == null)
            {
                paragraphProperties = new a.ParagraphProperties();
                paragraph.PrependChild(paragraphProperties);
            }
            paragraphProperties.Alignment = textAlignment;
            return(paragraph);
        }
Exemplo n.º 5
0
        public static a.Paragraph SetLineSpace(this a.Paragraph paragraph, float heightMultiplier)
        {
            var paragraphProperties = paragraph.GetFirstChild <a.ParagraphProperties>();

            if (paragraphProperties == null)
            {
                paragraphProperties = new a.ParagraphProperties();
                paragraph.PrependChild(paragraphProperties);
            }
            paragraphProperties.LineSpacing = new a.LineSpacing(new a.SpacingPercent()
            {
                Val = (int)(heightMultiplier * 100000)
            });
            return(paragraph);
        }