示例#1
0
        private FlatTextRange CreateFlatTextRange(XElement parent)
        {
            var range = new FlatTextRange(parent);

            this.ranges.Add(range);
            return(range);
        }
示例#2
0
        private void CreateFlatTextRanges()
        {
            foreach (XDocument document in this.documents)
            {
                FlatTextRange currentRange = null;
                foreach (XElement run in document.Descendants(FlatConstants.RunElementName))
                {
                    if (!run.HasElements)
                    {
                        continue;
                    }

                    FlatText flatText = FlattenRunElement(run);
                    if (flatText == null)
                    {
                        continue;
                    }

                    // If current Run doesn't belong to same parent (like paragraph, hyperlink, etc.)
                    // create new FlatTextRange, otherwise use current one.
                    if (currentRange == null || currentRange.Parent != run.Parent)
                    {
                        currentRange = this.CreateFlatTextRange(run.Parent);
                    }
                    currentRange.AddFlatText(flatText);
                }
            }
        }