This project has moved. For the latest updates, please go here.

Insert Document - Numbered List is Always Continued?

Oct 15, 2014 at 8:06 PM
Playing around with InsertDocument, if I have two documents, Sample List 1.docx and Sample List 2.docx each with a numbered list, the numbered list in Sample List 2.docx is always continued.

I.e. Merged document should be
  1. One
  2. Two
  3. Three
    End of List One
    Start of List Two
  4. One
  5. Two
  6. Three
Instead I end up with
  1. One
  2. Two
  3. Three
    End of List One
    Start of List Two
  4. One
  5. Two
  6. Three
Am I missing something simple here that would ensure the lists are not continued?
Oct 16, 2014 at 3:04 PM
Looking deeper into this...

private void merge_numbering(PackagePart remote_pp, PackagePart local_pp, XDocument remote_mainDoc, DocX remote) in DocX.cs, why is guidd and guidd2 always set to 0 and not set to the last value in the main document one is inserting into?

If I understand merge_numbering and what it is trying to do in its current form:
  1. Spin through the remote document and find the max abstractNum, increase by one
  2. Spin through the remote document and find the max numId, increase by one
  3. Work through the remote document, for any given list replace the numId with the newly found max numId
  4. Lastly, update our main document with the new abstractNum and numId from the remote document.
The current form of merge_numbering works, but each list is a continuation of the last list, as demo'ed with the results I was seeing above.

A proposed solution, spin through the main document, find the max abstractNum and numId before finding those max numbers in the remote document. This would essentially configure guidd and guidd2 with the main document's values before grabbing the values from the remote document.

I have a working solution, and would be happy to post it, but I'm curious if I'm chasing a real problem or not, i.e. is the current behavior by design and am I missing something?
Oct 30, 2014 at 2:55 PM
Can you please post your solution? I'm having a similar problem while adding lists to the document.
Oct 30, 2014 at 3:11 PM
@Lokuzt, included in the gist below

https://gist.github.com/benhysell/952f87a05dee783270a9