NodeChangingArgs Class
Provides data for methods of the INodeChangingCallback interface.
Inheritance Hierarchy
SystemObject
  Aspose.WordsNodeChangingArgs

Namespace: Aspose.Words
Assembly: Aspose.Words (in Aspose.Words.dll) Version: 19.9
Syntax
public class NodeChangingArgs

The NodeChangingArgs type exposes the following members.

Properties
  NameDescription
Public propertyAction
Gets a value indicating what type of node change event is occurring.
Public propertyNewParent
Gets the node's parent that will be set after the operation completes.
Public propertyCode exampleNode
Gets the Node that is being added or removed.
Public propertyOldParent
Gets the node's parent before the operation began.
Methods
  NameDescription
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Examples
Shows how to implement custom logic over node insertion in the document by changing the font of inserted HTML content.
[C#]

public void TestNodeChangingInDocument()
{
    // Create a blank document object
    Document doc = new Document();
    DocumentBuilder builder = new DocumentBuilder(doc);

    // Set up and pass the object which implements the handler methods.
    doc.NodeChangingCallback = new HandleNodeChangingFontChanger();

    // Insert sample HTML content
    builder.InsertHtml("<p>Hello World</p>");

    doc.Save(ArtifactsDir + "Document.FontChanger.doc");

    // Check that the inserted content has the correct formatting
    Run run = (Run) doc.GetChild(NodeType.Run, 0, true);
    Assert.AreEqual(24.0, run.Font.Size);
    Assert.AreEqual("Arial", run.Font.Name);
}

public class HandleNodeChangingFontChanger : INodeChangingCallback
{
    // Implement the NodeInserted handler to set default font settings for every Run node inserted into the Document
    void INodeChangingCallback.NodeInserted(NodeChangingArgs args)
    {
        // Change the font of inserted text contained in the Run nodes.
        if (args.Node.NodeType == NodeType.Run)
        {
            Aspose.Words.Font font = ((Run) args.Node).Font;
            font.Size = 24;
            font.Name = "Arial";
        }
    }

    void INodeChangingCallback.NodeInserting(NodeChangingArgs args)
    {
        // Do Nothing
    }

    void INodeChangingCallback.NodeRemoved(NodeChangingArgs args)
    {
        // Do Nothing
    }

    void INodeChangingCallback.NodeRemoving(NodeChangingArgs args)
    {
        // Do Nothing
    }
}
See Also