Advertisement
Guest User

Untitled

a guest
Mar 2nd, 2015
215
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. Dim fussnote As Footnote
  2. For Each fussnote In ActiveDocument.Footnotes
  3. fussnote.Reference.Select
  4. With Selection
  5. With .FootnoteOptions
  6. .Location = wdBottomOfPage
  7. .NumberingRule = wdRestartContinuous
  8. .StartingNumber = 1
  9. .NumberStyle = wdNoteNumberStyleArabic
  10. .NumberingRule = wdRestartSection
  11. End With
  12. .Footnotes.Add range:=Selection.range, Reference:=""
  13. End With
  14. Next
  15.  
  16. public override void Work(WordprocessingDocument args)
  17. {
  18. var __allFootnotes = (Footnotes)args.MainDocumentPart
  19. .FootnotesPart.Footnotes.Clone();
  20. var footnotes = __allFootnotes.Elements<Footnote>()
  21. .SkipWhile(f => !(f.Id.Value > 0)).ToList();
  22. RenumberFootnotes(footnotes,
  23. args.MainDocumentPart.Document.Body.Descendants<Paragraph>().ToList());
  24.  
  25. var __styles = args.MainDocumentPart
  26. .StyleDefinitionsPart.Styles;
  27.  
  28. for (int i = 0; i < footnotes.Count(); i++)
  29. {
  30. //var footnote = footnotes[i];
  31. }
  32.  
  33. args.MainDocumentPart.FootnotesPart
  34. .Footnotes = __allFootnotes;
  35. }
  36.  
  37.  
  38. private void RenumberFootnotes(List<Footnote> footnotes, List<Paragraph> paragraphs)
  39. {
  40. var __p = paragraphs.Where(p => p.Descendants<FootnoteReference>().Any());
  41. var __references = __p.SelectMany(p => p.Descendants<FootnoteReference>());
  42. for (int i = 1; i < footnotes.Count; i++)
  43. {
  44. var __tempId = footnotes[i].Id.Value;
  45. footnotes[i].Id.Value = i;
  46. var __reference = __references.First(fr => fr.Id.Value == __tempId);
  47. __reference.Id.Value = i;
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement