Beispiel #1
0
        private List <Portion> GetPortions()
        {
            var runs           = _xmlParagraph.Elements <A.Run>();
            var resultPortions = runs.Any() ? PortionsFromRuns(runs) : PortionsFromField();

            return(resultPortions);
        }
        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>());
        }