Browse Source

Fixed a bug in InsertParagraph that introduced a new empty paragraph at the very beginning of a document when inserting at 0.

master
fitdev@hotmail.com 10 years ago
parent
commit
86fb85725d
1 changed files with 15 additions and 8 deletions
  1. 15
    8
      DocX/Container.cs

+ 15
- 8
DocX/Container.cs View File

@@ -669,14 +669,21 @@ namespace Novacode
if (firstPar != null)
{
XElement[] splitParagraph = HelperFunctions.SplitParagraph(firstPar, index - firstPar.startIndex);
firstPar.Xml.ReplaceWith
(
splitParagraph[0],
newParagraph.Xml,
splitParagraph[1]
);
var splitindex = index - firstPar.startIndex;
if (splitindex <= 0)
{
firstPar.Xml.ReplaceWith(newParagraph.Xml, firstPar.Xml);
}
else {
XElement[] splitParagraph = HelperFunctions.SplitParagraph(firstPar, splitindex);
firstPar.Xml.ReplaceWith
(
splitParagraph[0],
newParagraph.Xml,
splitParagraph[1]
);
}
}
else

Loading…
Cancel
Save