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[])
This patch adds an extension method to Paragraph that allows easy setting of paragraph. It makes setting text as a heading much more intuitive and discoverable.
Covers Heading 1 - Heading 9
Example available in examples under DocumentHeading() method.
This patch adds basic support for inserting and manipulating bookmarks inside a word file. It also allows for inserting text at bookmark locations. The change was predicated on a need to insert text at bookmark locations in a sort of token replacement.
InsertList(List list, double fontSize)
InsertList(List list, System.Drawing.FontFamily fontFamily, double fontSize)
and a new example of usage: DocumentsWithListsFontChange();
Thanks to those 2 methods you can easily set font family and font size when inserting new lists.
Merged from GIT source code. Code provided by Randall Borck and Fainzanj
Changes:
- Fix to allow font family for a paragraph text to be set and read. (faizanj)
- Tightened up how a paragraph is designated as a list item. (faizanj)
- Feature add insert next page section (rgborck)
- Added examples for the section break and the new next page break. (Randall Borck)
- Added Next Page Section break functionality. The new method is called InsertSectionPageBreak(...). (Randall Borck)
- Fix for bug with entering more than one numbering. The system was inserting the abstract in the wrong place. Now the abstract sections are grouped at the beginning and the num section is grouped at the end. This should allow word to find the correct list formatting when a document with multiplelists is created from docx. (Randall Borck)
- Fix for list defaults to help them be more consistant with MS Word. Bullets were indenting twice that of numbers, now they increase the same amount. (Randall Borck)
- Added test for creating text with formatting (fainzanj)
- Added capability to detect underlinestyle (fainzanj)
- Updated the default values to specify Heading styles. (Randall Borck)
- Updated DocX to allow you to create an empty list object. This change is useful for creating a list and then running an iterator or loop to populate it.(Randall Borck)
- Fixed issue with multiple lists in the same document. The second list was overwriting the document numbering instead of appending to it. Also updated the default to be numbering instead of bullet. Added an example of how to create lists.(Randall Borck)
- Updated list items to allow for a start value. (Randall Borck)
- Fixed the Apply Template unit test. (Randall Borck)
- Removed unneeded test. (faizanj)
- Fixed unit tests. (Randall Borck)
- Cleaned up redunant parameters in AddItemList(...) call. (Randall Borck)
- Undid signature changes because of issues. (Randall Borck)
- Fixed a method signature. (Randall Borck)
- Added test for List property (fainzanj)
- Added test for List property(fainzanj)
- Updated documentation comments and default values. (Randall Borck)
- Updates/refactoring changes to list. (Randall Borck)
- Added capability to append list to previous list (fainzanj)
- Updated docx to support adding a list. Added preliminary list support to allow docx to create a list. Currently missing functionality to add elements to the previous list (so each list can only have 1 element in the creation of new lists so far). (faizanj, brendanjerwin)
- Added tests for adding a list (fainzanj)
Known issues:
- Charts related documents doesn't open in Word 2012 (opens up fine in Word 2010)
Additionally:
- Removed StrongNameFile.pfx for easy compile
- Renamed file UnitTests1.cs into DocXUnitTests.cs
- Created Documentation.chm and commited with this release
1. override InsertTable(int rowCount, int columnCount) method in Table Cell because of bug.
Cell need paragraph in the end.
2. InsertTableBeforeSelf(Table t) behaviour changed, now it returns completely new table copied from parameter table.
3. InsertParagraphAfterSelf(Paragraph p) behaviour changed, now it returns completely new paragraph copied from parameter paragraph, but only in case for this is Paragraph
4. InsertTableAfterSelf(Table t) the same as for InsertTableBeforeSelf behaviour changed, now it returns completely new table copied from parameter table.
P.S. Look please my //IMPORTANT notes in code.
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.