| internal static Paragraph GetFirstParagraphEffectedByInsert(DocX document, int index) | internal static Paragraph GetFirstParagraphEffectedByInsert(DocX document, int index) | ||||
| { | { | ||||
| // This document contains no Paragraphs and insertion is at index 0 | // This document contains no Paragraphs and insertion is at index 0 | ||||
| if (document.paragraphLookup.Keys.Count() == 0 && index == 0) | |||||
| if (document.Paragraphs.Count() == 0 && index == 0) | |||||
| return null; | return null; | ||||
| foreach (int paragraphEndIndex in document.paragraphLookup.Keys) | |||||
| foreach (Paragraph p in document.Paragraphs) | |||||
| { | { | ||||
| if (paragraphEndIndex >= index) | |||||
| return document.paragraphLookup[paragraphEndIndex]; | |||||
| if (p.endIndex >= index) | |||||
| return p; | |||||
| } | } | ||||
| throw new ArgumentOutOfRangeException(); | throw new ArgumentOutOfRangeException(); |