Ver código fonte

Update HelperFunctions.cs

On my search to solve the inserting problem of tables and paragraphs I change this code.
If the document.paragraphLookup is always correct or filled no problem.
But why depend on document.paragraphLookup if it can be done direct?
So this is not a bug.
For me it is not clear why we have the dictionary paragraphLookup.
Is there a real need for the dictionary paragraphLookup, or is it just a result of historical starting ideas and should it be cleaned?
master
Twotsman 9 anos atrás
pai
commit
434e522c4e
1 arquivos alterados com 4 adições e 4 exclusões
  1. 4
    4
      DocX/HelperFunctions.cs

+ 4
- 4
DocX/HelperFunctions.cs Ver arquivo

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();

Carregando…
Cancelar
Salvar