* minimize closure allocations by replacing LINQ with foreach when needed
* use lookups when possible
* reuse filtered items, pre-compute when possible
* use lighter Monitor for isolated storage locking instead of Mutex
* fix DocX references to be real project references instead of DLL references
- added a whole bookmarks collection so one can access it from DocX and get the bookmark by name
- added a SetText method to the Bookmark so one can set the text from it using something like this: docX.Bookmarks["MyBookmark"].SetText("MyText")
- Added example BookmarksReplaceTextOfBookmarkKeepingFormat
In addition two new features: Table of contents and a way of validate if a document contains bookmarks with specified names. This is useful in applications where users can upload a template that will be populated based on form data. If this form data expects one or more bookmarks present in the document, one can now check this up front and use it to provide feedback to the user.
The following files have changes:
• DocX.cs
o Method: Addlist(string, int, ListItemType, in, bool) (I've added another paramter, bool)
o Method: AddListItem(List, string, level, ListItemType int, bool) (I've added another paramter, bool)
o All overloads of InsertList: removed adding of mainpart to list items (do this in AddListItem instead)
o New Method: InsertDefaultTableOfContents
o New Method: InsertTableOfContents(string, TableOfContentsSwitches, string, int, int?)
o New Method: InsertTableOfContents(Paragraph, string, TableOfContentsSwitches, string, int, int?)
• HelperFunctions.cs
o Method: CreateItemInList(List, string, int, ListItemType, int, bool) (I've added another paramter, bool)
• List.cs
o Method: CreateNewNumberNumId(int, ListItemType) (I've added two more paramteres, int, bool)
• ExtensionHeadings.cs
o New Method: HasFlag(this Enum, Enum)
• New File: TableOfContents.cs
• _Enumerations.cs:
o New Enum: TableOfContentsSwitches
• DocXUnitTests.cs
o Quite a few new tests. Tests for TableOfContents and new bookmark feature as well as hyper link bugfix for list items
• _BaseClasses.cs
o New class: XmlTemplateBases (holds constants)
• Program.cs: new examples, AddToc and AddTocByReference
• Paragraph.cs
o New Method: ValidateBookmark(string)
• Container.cs
o New Method: ValidateBookmarks(params string[])
Refactor the Table class: RowCount, ColumnCount, Rows properties and Insert/Remove methods. Also refactor CreateTable method - extract the same method CreateTableCell. Add powerfull unit test for this.
This projects contains many of the examples upload on my blog.
Each time docx is released, I will update these examples so as they still work regardless of API changes.