Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Foot/endnotes, Indexes, Char styles #393

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
################################################################################
# This .gitignore file was automatically created by Microsoft(R) Visual Studio.
################################################################################

/Xceed.Document.NET/obj
/.vs
/Xceed.Words.NET/obj/Debug
/Xceed.Words.NET/obj/Release
/Xceed.Words.NET.Examples/obj
/Xceed.Document.NET/bin/Debug
/Xceed.Words.NET/bin/Debug
/Xceed.Words.NET.Examples/bin/Debug
*.user
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## Changes in this fork

This fork/branch includes several changes that were introduced in support of a project to generate "Register Format" reports from GEDCOM files. This use-case anticipates that the output document is to be processed programatically just once, when it is created, and will be subsequently edited manually.

The changes include:

* Character Styles: if the format object passed when appending text to a paragraph includes a style name (id) it is applied to the text as a character style (in the base version, it is simply ignored)
* Indexing: supports inserting index entries (XE fields) into paragraphs and indexes (INDEX fields). Features supported include "type" (used to separate e.g. name index from place index)
* Footnotes/Endnotes: supports inserting footnotes and/or endnotes into paragraphs. Notes can include hyperlinks and can include references to other notes (of the same flavor). NB: This is a "one-way" capability: existing Notes (including ones just added using this feature) cannot be modified and cannot be deleted (except, of course, by hand in an editor).

Simple examples of footnotes, endnotes, and indexes are provided.

Full, unedited text of the base project readme follows.

## What is DocX?

DocX is a .NET library that allows developers to manipulate Word 2007/2010/2013 files, in an easy and intuitive manner. DocX is fast, lightweight and best of all it does not require Microsoft Word or Office to be installed.
Expand Down
94 changes: 94 additions & 0 deletions Xceed.Document.NET/Src/AbstractField.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
using System.Xml.Linq;

namespace Xceed.Document.NET
{
public abstract class AbstractField : DocumentElement
{
//public AbstractField(Document doc) : base(doc, null) { }

//public XElement Xml { get; internal set; }

/// <summary>
/// Wrap the supplied arbitrary text of the field, in the field begin and
/// end markers in a run.
/// </summary>
/// <param name="fieldText">the field Id and any parameters needed, NO CHECKING is done</param>
/// <param name="fieldContent"></param>
/// <returns>XML with the run representing the field</returns>
internal XElement Build(string fieldText, string fieldContent = null)
{
// to unravel the nesting, build the inner parts in an array first
object[] parts = new object[(fieldContent==null)?3:5];
int next = 0;

parts[next++] = new XElement
(
XName.Get("r", Document.w.NamespaceName),
new XElement
(
XName.Get("fldChar", Document.w.NamespaceName),
new XAttribute(Document.w + "fldCharType", "begin")
)
);


parts[next++] = new XElement
(
XName.Get("r", Document.w.NamespaceName),
new XElement
(
XName.Get("instrText", Document.w.NamespaceName),
new XAttribute(XNamespace.Xml + "space", "preserve"),
fieldText
)
);

// additional text e.g. for a hyperlink inserted for the field
// entails two runs, one for a separator and the second for the text
if (fieldContent != null)
{
parts[next++] = new XElement
(
XName.Get("r", Document.w.NamespaceName),
new XElement
(
XName.Get("fldChar", Document.w.NamespaceName),
new XAttribute(Document.w + "fldCharType", "separate")
)
);
parts[next++] = new XElement
(
XName.Get("r", Document.w.NamespaceName),
new XElement
(
XName.Get("t", Document.w.NamespaceName),
fieldContent
)
);
}

parts[next] = new XElement
(
XName.Get("r", Document.w.NamespaceName),
new XElement
(
XName.Get("fldChar", Document.w.NamespaceName),
new XAttribute(Document.w + "fldCharType", "end")
)
);

// then wrap them all up in a run, and we are done
XElement xe = new XElement
(
XName.Get("r", Document.w.NamespaceName),
parts
);

return Xml = xe;
}

public abstract AbstractField Build();

protected AbstractField(Document document, XElement xml) : base(document, xml) { }
}
}
Loading