User`s guide

Format Inheritance
13-25
Format Inheritance
The DOM API allows you to use both template-based styles and format object-based
styles (or equivalent format properties) to specify the appearance of an object. If you
set both the StyleName and the Style property of an object, the formats in the Style
property override corresponding formats specified by the template-based style of the
StyleName property. Consider, for example, the following script.
d = Document('MyDoc','docx','MyTemplate');
p = Paragraph('Danger!');
p.StyleName = 'Warning';
p.Style = {Color('red')};
append(d,p);
close(d);
Suppose that the Warning style defines the color of a warning as yellow. In that case,
this example overrides the color specified by the Warning style.
If a document object does not specify a StyleName (a template-based style), it inherits
from its container any formats that it does not itself specify. The container itself inherits
any formats that it does not specify from its container, and so on, all the way to the top of
a container hierarchy. Format inheritance allows you to use a single statement to assign
a format for all the objects contained by a container. For example, the following script
uses a single Style property to assign a color to all the entries in a table.
d = Document('MyDoc');
tableArray = {'a', 'b'; 'c', 'd'};
table = append(d, tableArray);
table.Style = {Color('blue')};
append(d, table);
close(d);
Related Examples
“Use Style Sheets” on page 13-21
“Use Format Objects” on page 13-23
More About
“Report Formatting Approaches” on page 13-20