# Document Formatting Source

DsWord allows you to detect the source of formatting properties in a Word document. Learn more in DsWord docs.

## Content

Usually, in a Word document, the content formatting is picked from default document style, parent content formatting or direct formatting. In order to detect the source of formatting properties, DsWord library provides the [GetPropertyValueSource](/document-solutions/dot-net-word-api/api/online/DS.Documents.Word/GrapeCity.Documents.Word.GcWordDocument.GetPropertyValueSource.html) method in **GcWordDocument** class. This feature is useful for users, who want to programmatically determine the formatting source of Word objects in documents.
The **GetPropertyValueSource** method takes the formatting "property" as a parameter to find and return the object in the inheritance chain which is the source of the formatting property.
If the target property's value is determined by an object in the inheritance hierarchy, the type of the object returned by the **GetPropertyValueSource** method can be one of:

* Paragraph
* Run
* Table
* Row
* Cell
* ContentControl
* Style
* ConditionalStyle
* StyleCollection
* ListLevel
* PageSetup
* Settings

If the property belongs directly to an object, that object will be returned (and it can be of any type)

## Detect Source Object of Formatting Properties

To detect source of a paragraph's formatting properties:

1. Create an instance of **GcWordDocument** and load the Word document having styles.
2. Get a source object of the "Font.Size" property set for a run within a paragraph formatted with Heading 1 style.

    ```csharp
    public static void DetectFormatting()
    {
        //Create a new GcWordDocument 
        GcWordDocument doc = new GcWordDocument();
    
        //Get Heading 1 style
        Style style = doc.Styles[BuiltInStyleId.Heading1];
    
        //Add a run within a paragraph formatted with Heading 1 style
        doc.Body.Paragraphs.Add("text", style);
    
        //Get a source object of the "Font.Size" property from the created run
        object source = GcWordDocument.GetPropertyValueSource(() => doc.Body.Runs.First.Font.Size);
    
        //The source object must be "Heading1" style because the font size is defined here.
        Console.Write("Formatting source name: " + ((Style)source).Name);
        Console.ReadLine();
    }
    ```

For more information on how to modify theme colors using DsWord, see [DsWord sample browser](https://developer.mescius.com/documents-api-word/demos/basics/miscellaneous/get-style-source/code-cs).