GlossaryDocument Class |
Namespace: Aspose.Words.BuildingBlocks
The GlossaryDocument type exposes the following members.
Name | Description | |
---|---|---|
![]() | GlossaryDocument | Initializes a new instance of the GlossaryDocument class |
Name | Description | |
---|---|---|
![]() ![]() | BackgroundShape |
Gets or sets the background shape of the document. Can be null.
(Inherited from DocumentBase.) |
![]() ![]() | BuildingBlocks |
Returns a typed collection that represents all building blocks in the glossary document.
|
![]() ![]() | ChildNodes |
Gets all immediate child nodes of this node.
(Inherited from CompositeNode.) |
![]() ![]() | Count |
Gets the number of immediate children of this node.
(Inherited from CompositeNode.) |
![]() | Document | (Inherited from DocumentBase.) |
![]() ![]() | FirstBuildingBlock |
Gets the first building block in the glossary document.
|
![]() ![]() | FirstChild |
Gets the first child of the node.
(Inherited from CompositeNode.) |
![]() ![]() | FontInfos |
Provides access to properties of fonts used in this document.
(Inherited from DocumentBase.) |
![]() ![]() | HasChildNodes |
Returns true if this node has any child nodes.
(Inherited from CompositeNode.) |
![]() ![]() | IsComposite |
Returns true as this node can have child nodes.
(Inherited from CompositeNode.) |
![]() ![]() | LastBuildingBlock |
Gets the last building block in the glossary document.
|
![]() ![]() | LastChild |
Gets the last child of the node.
(Inherited from CompositeNode.) |
![]() ![]() | Lists |
Provides access to the list formatting used in the document.
(Inherited from DocumentBase.) |
![]() ![]() | NextSibling |
Gets the node immediately following this node.
(Inherited from Node.) |
![]() ![]() | NodeChangingCallback |
Called when a node is inserted or removed in the document.
(Inherited from DocumentBase.) |
![]() ![]() | NodeType |
Returns the GlossaryDocument value.
(Overrides NodeNodeType.) |
![]() ![]() | PageColor |
Gets or sets the page color of the document. This property is a simpler version of BackgroundShape.
(Inherited from DocumentBase.) |
![]() ![]() | ParentNode |
Gets the immediate parent of this node.
(Inherited from Node.) |
![]() ![]() | PreviousSibling |
Gets the node immediately preceding this node.
(Inherited from Node.) |
![]() ![]() | Range |
Returns a Range object that represents the portion of a document that is contained in this node.
(Inherited from Node.) |
![]() ![]() | ResourceLoadingCallback |
Allows to control how external resources are loaded.
(Inherited from DocumentBase.) |
![]() ![]() | Styles |
Returns a collection of styles defined in the document.
(Inherited from DocumentBase.) |
![]() ![]() | WarningCallback |
Called during various document processing procedures when an issue is detected that might result
in data or formatting fidelity loss.
(Inherited from DocumentBase.) |
Name | Description | |
---|---|---|
![]() ![]() | Accept |
Accepts a visitor.
(Overrides NodeAccept(DocumentVisitor).) |
![]() ![]() | AppendChild |
Adds the specified node to the end of the list of child nodes for this node.
(Inherited from CompositeNode.) |
![]() ![]() | Clone | (Inherited from Node.) |
![]() | Equals | (Inherited from Object.) |
![]() ![]() | GetAncestor(Type) |
Gets the first ancestor of the specified object type.
(Inherited from Node.) |
![]() ![]() | GetAncestor(NodeType) |
Gets the first ancestor of the specified NodeType.
(Inherited from Node.) |
![]() ![]() | GetBuildingBlock |
Finds a building block using the specified gallery, category and name.
|
![]() ![]() | GetChild |
Returns an Nth child node that matches the specified type.
(Inherited from CompositeNode.) |
![]() ![]() | GetChildNodes |
Returns a live collection of child nodes that match the specified type.
(Inherited from CompositeNode.) |
![]() ![]() | GetEnumerator |
Provides support for the for each style iteration over the child nodes of this node.
(Inherited from CompositeNode.) |
![]() | GetHashCode | (Inherited from Object.) |
![]() ![]() | GetText |
Gets the text of this node and of all its children.
(Inherited from CompositeNode.) |
![]() | GetType | (Inherited from Object.) |
![]() ![]() | ImportNode(Node, Boolean) | Imports a node from another document to the current document. |
![]() ![]() | ImportNode(Node, Boolean, ImportFormatMode) | Imports a node from another document to the current document with an option to control formatting. |
![]() ![]() | IndexOf |
Returns the index of the specified child node in the child node array.
(Inherited from CompositeNode.) |
![]() ![]() | InsertAfter |
Inserts the specified node immediately after the specified reference node.
(Inherited from CompositeNode.) |
![]() ![]() | InsertBefore |
Inserts the specified node immediately before the specified reference node.
(Inherited from CompositeNode.) |
![]() ![]() | NextPreOrder |
Gets next node according to the pre-order tree traversal algorithm.
(Inherited from Node.) |
![]() ![]() | PrependChild |
Adds the specified node to the beginning of the list of child nodes for this node.
(Inherited from CompositeNode.) |
![]() ![]() | PreviousPreOrder |
Gets the previous node according to the pre-order tree traversal algorithm.
(Inherited from Node.) |
![]() ![]() | Remove |
Removes itself from the parent.
(Inherited from Node.) |
![]() ![]() | RemoveAllChildren |
Removes all the child nodes of the current node.
(Inherited from CompositeNode.) |
![]() ![]() | RemoveChild |
Removes the specified child node.
(Inherited from CompositeNode.) |
![]() ![]() | RemoveSmartTags |
Removes all SmartTag descendant nodes of the current node.
(Inherited from CompositeNode.) |
![]() ![]() | SelectNodes |
Selects a list of nodes matching the XPath expression.
(Inherited from CompositeNode.) |
![]() ![]() | SelectSingleNode |
Selects the first Node that matches the XPath expression.
(Inherited from CompositeNode.) |
![]() | ToString | (Inherited from Object.) |
![]() ![]() | ToString(SaveFormat) |
Exports the content of the node into a string in the specified format.
(Inherited from Node.) |
![]() ![]() | ToString(SaveOptions) |
Exports the content of the node into a string using the specified save options.
(Inherited from Node.) |
Some documents, usually templates, can contain AutoText, AutoCorrect entries and/or Building Blocks (also known as glossary document entries, document parts or building blocks).
To access building blocks, you need to load a document into a Document object. Building blocks will be available via the GlossaryDocument property.
GlossaryDocument can contain any number of BuildingBlock objects. Each BuildingBlock represents one document part.
Corresponds to the glossaryDocument and docParts elements in OOXML.
public void GlossaryDocument() { Document doc = new Document(); GlossaryDocument glossaryDoc = new GlossaryDocument(); glossaryDoc.AppendChild(new BuildingBlock(glossaryDoc) { Name = "Block 1" }); glossaryDoc.AppendChild(new BuildingBlock(glossaryDoc) { Name = "Block 2" }); glossaryDoc.AppendChild(new BuildingBlock(glossaryDoc) { Name = "Block 3" }); glossaryDoc.AppendChild(new BuildingBlock(glossaryDoc) { Name = "Block 4" }); glossaryDoc.AppendChild(new BuildingBlock(glossaryDoc) { Name = "Block 5" }); Assert.AreEqual(5, glossaryDoc.BuildingBlocks.Count); doc.GlossaryDocument = glossaryDoc; // There is a different ways how to get created building blocks Assert.AreEqual("Block 1", glossaryDoc.FirstBuildingBlock.Name); Assert.AreEqual("Block 2", glossaryDoc.BuildingBlocks[1].Name); Assert.AreEqual("Block 3", glossaryDoc.BuildingBlocks.ToArray()[2].Name); Assert.AreEqual("Block 5", glossaryDoc.LastBuildingBlock.Name); // Get a block by gallery, category and name BuildingBlock block4 = glossaryDoc.GetBuildingBlock(BuildingBlockGallery.All, "(Empty Category)", "Block 4"); // All GUIDs are the same by default Assert.AreEqual("00000000-0000-0000-0000-000000000000", block4.Guid.ToString()); // To be able to uniquely identify blocks by GUID, each GUID must be unique // We will do that using a custom visitor GlossaryDocVisitor visitor = new GlossaryDocVisitor(); glossaryDoc.Accept(visitor); Assert.AreEqual(5, visitor.GetDictionary().Count); Console.WriteLine(visitor.GetText()); // We can find our new blocks in Microsoft Word via Insert > Quick Parts > Building Blocks Organizer... doc.Save(ArtifactsDir + "BuildingBlocks.GlossaryDocument.dotx"); } /// <summary> /// Simple implementation of giving each building block in a glossary document a unique GUID. Implemented as a Visitor. /// </summary> public class GlossaryDocVisitor : DocumentVisitor { public GlossaryDocVisitor() { mBlocksByGuid = new Dictionary<Guid, BuildingBlock>(); mBuilder = new StringBuilder(); } public string GetText() { return mBuilder.ToString(); } public Dictionary<Guid, BuildingBlock> GetDictionary() { return mBlocksByGuid; } public override VisitorAction VisitGlossaryDocumentStart(GlossaryDocument glossary) { mBuilder.AppendLine("Glossary document found!"); return VisitorAction.Continue; } public override VisitorAction VisitGlossaryDocumentEnd(GlossaryDocument glossary) { mBuilder.AppendLine("Reached end of glossary!"); mBuilder.AppendLine("BuildingBlocks found: " + mBlocksByGuid.Count); return VisitorAction.Continue; } public override VisitorAction VisitBuildingBlockStart(BuildingBlock block) { block.Guid = Guid.NewGuid(); mBlocksByGuid.Add(block.Guid, block); return VisitorAction.Continue; } public override VisitorAction VisitBuildingBlockEnd(BuildingBlock block) { mBuilder.AppendLine("\tVisited block \"" + block.Name + "\""); mBuilder.AppendLine("\t Type: " + block.Type); mBuilder.AppendLine("\t Gallery: " + block.Gallery); mBuilder.AppendLine("\t Behavior: " + block.Behavior); mBuilder.AppendLine("\t Description: " + block.Description); return VisitorAction.Continue; } private readonly Dictionary<Guid, BuildingBlock> mBlocksByGuid; private readonly StringBuilder mBuilder; }