3. Style Information
• A style defines a specific set of formatting
properties
– For example, the Normal style in Word 2003 is
defined as:
• Font = Times New Roman
• Font Size = 12 point
• Font Language = Language of Word (English (US) for
me)
• Justification = Left
• Line Spacing = Single
• Widow/Orphan control
4. Styles Storage
• Within a WordprocessingML package, styles
are stored in a unique part
– Target of an implicit relationship from the
document part
– Relationship type:
http://schemas.openxmlformats.org/wordprocessingml/2006/st
yles
– Content type:
vnd-openxmlformats.officedocument.wordprocessingml-
styles+xml
5. Styles Storage
• Within the styles part, there are two primary
components:
– Style definitions
– Latent style information
6. Style Definitions
• A style is defined using the style element
• The style definition contains three pieces of
information
– Common style properties
– Style 'type'
– Type-specific properties
7. Common Style Properties
• All styles share a set of common properties:
– Style name
– Additional aliases
– Style ID
• This is what is used to reference this style from
document content
– Automatically redefine based on direct formatting
– Hidden
8. Common Style Properties
• Common properties (cont'd):
– Lock (prevent changes to style)
– Priority (for user interface sorting)
– Unhide when used (for user interface)
– Semi-hidden
– Revision ID (used to compare two instances of a
style)
9. Common Style Properties
• ..and the most interesting two properties:
– Parent style on which this style is based (which
we'll discuss more later)
– Is this style the default for its type? (i.e. is this the
style that is applied when no style of this type is
referenced by the content)
11. Style Types
• WordprocessingML supports the creation of
six different types of styles:
– Paragraph styles
– Character styles
– Linked styles (paragraph + character)
– Table styles
– List styles
– Default paragraph + character properties
12. Paragraph Styles
• Paragraph styles apply to the contents of an
entire paragraph as well as the paragraph
mark
– This means they can affect the paragraph
properties as well as the text formatting
– They cannot be applied to sub-paragraph ranges
13. Paragraph Styles
• A paragraph style has three defining
characteristics:
– It is specified using a type attribute of "paragraph"
on the style element
– It defines the paragraph style for the next
paragraph
– It contains both a set of run properties (rPr) and
paragraph properties (pPr)
14. Paragraph Styles
• The run properties are the set of properties
applied to each run in the paragraph
15. Paragraph Styles Example
• Consider a paragraph style "Test Paragraph
Style" which defines:
– Font: Algerian
– Font Size: 20
– Font Color: Red
– Paragraph Spacing: double
– Paragraph Indent: 1" (first line)
16. Paragraph Styles Example
• In styles part:
Common Properties
Paragraph Properties
Character (Run) Properties
18. Character Styles
• Character styles apply to the contents of one
or more runs which are explicitly given that
character style
– They can be applied to any run within the
document
– Cannot specify paragraph properties
19. Character Styles
• A character style has two defining
characteristics:
– It is specified using a type attribute of "character"
on the style element
– It contains only a set of run properties (rPr)
• The run properties are the set of properties to
each run who references the character style
20. Character Styles Example
• Consider a character style which is defined as
follows:
– Font: Courier New
– Font Color: Yellow
– Underline
23. Linked Styles
• Linked styles are a paired combination of both
a paragraph and character style
• This allows the style to be used in both
paragraph and character contexts
– When the current selection is a run, the character
style is applied
– When the current selection is a paragraph, the
paragraph style is applied
24. Linked Styles
• Linked styles in WordprocessingML are
literally two styles: one paragraph, one
character
• They are 'linked' using the link element
• This tells the consumer that it should mask
the fact that these are two different styles at
runtime
26. Linked Style Example
• Consider a linked style defined as follows:
– Font: Arial (a character property)
– Font Color: green (a character property)
– Double spaced (a paragraph property)
– 1" left indent (a paragraph property)
• In the styles part, we get two style definitions:
27. Linked Style Example
• A paragraph style:
Wants to link to a character
style with styleID =
"TestLinkedStyleChar"
28. Linked Style Example
• A character style:
Wants to link to a paragraph
style with styleID =
"TestLinkedStyle"
31. Numbering Styles
• Numbering styles are styles which define the
structure of a multi-level numbering format
• They are an index into a numbering format
that is stored with the document
• The numbering style syntax is used to give the
numbering style a persistent name, as well as
specify common style properties
32. Table Styles
• Table styles supply formatting information for
tables
– e.g. borders, shading, etc.
• As well, they provide formatting information
for the text of the table's contents
33. Table Styles
• A table is associated with a style via the tblStyle element
Associated Table Style
Components of Table Style Used
34. Table Styles
• Although each of these properties are
optional, their omissions each supply a default
value:
– Omitting tblStyle uses the default table style
– Omitting tblLook specifies that all aspects of the
table style should be included
35. Table Sections
• Table styles have all of the properties that can
be applied to a table
– Like paragraph styles and paragraph formatting
• However, table styles allow for the definition
of unique formats for different table 'sections'
of the table
36. Table Sections
Within the main table rows, there are also table formatting
properties for alternating rows and columns
38. Table Section Priorities
1.Top left, top right, bottom left, bottom right
2.First column, last column
3.First row, last row
4.Banded rows, even row banding
5.Banded columns, even column banding
6.Whole table
(application order is bottom to top)
40. Default Paragraph and Character
Properties
• Whew! The final type of style isn't really a
style as much as a set of properties
• Let's come back to this…
41. Style Inheritance
• Styles of any given type can inherit from other styles
of that type.
– e.g. The Tristan Test style can inherit from the Heading 1
paragraph style can be specified to inherit properties from
the Normal paragraph style
• This lineage is traced using the basedOn element, which
specifies the styleId of the 'parent'
42. Style Inheritance
• To build up the resulting style:
– Trace the hierarchy back to its root
– Follow each level down, applying its properties
– When properties conflict, they are overridden (this
includes turning OFF a property set at an earlier level)
• On save, properties that match those
inherited are not explicitly saved for that style
43. Default Paragraph and Character
Properties
• Now that we've covered style inheritance…
• All styles eventually inherit back to a style
which has no basedOn property
• This means we need to have a default value
for formatting properties
– What would it mean if Font was never explicitly
specified in a style hierarchy?
44. Default Paragraph and Character
Properties
• These default properties are called the
document defaults and are applied before any
other formatting information
• However, in previous versions of Word these
defaults were coded into the EXE and could
not be changed
• In WordprocessingML, these defaults are
stored in the styles part under the
docDefaults element
45. Default Paragraph and Character
Properties
default
run
properties
default
paragraph
properties
46. Style Application
• Multiple style ‘types’ can be applied to the same text
within a file, so properties are applied in a specific
order.
– As with inheritance, the resulting formatting
properties set by one type can be removed or
supplemented by following types.
47. Style Application
Table Characters Paragraph List Item
Table
Paragraph
Character
Direct Formatting
Numbering
Applicationorder
Document Defaults
48. Style Application
• First, the document defaults are applied to
text
• Next, the table style properties are applied to
each table in the document
• Next, list item and paragraph properties are
applied to each paragraph formatted with a
list style
• Next, paragraph and run properties are
applied to each paragraph
49. Style Application
• Next, run properties are applied based on
character styles
• Finally, we apply direct formatting (paragraph
or run properties not from styles)
• It's important to remember that each level
can *not* specify properties and get the
properties from previous levels
50. Latent Styles
• The other piece of style information stored in
the document
• Stores properties about styles without saving
the actual style in the file
– e.g. for documents where formatting is restricted
to a selection of styles – can this one be used?
• Needed because the document may not have
access to its template
51. Latent Styles
• Latent style properties:
– Style lockdown (can style be used?)
– UI sorting priority
– Use as top-level format
– Unhide when used
52. Latent Styles
• For efficiency, the latent style information is
stored as a set of latent style defaults with
exceptions defining properties for those styles
which do not match the defaults
53. Disclaimer
This presentation is for informational purposes only, and should
not be relied upon as a substitute or replacement for Microsoft
formal file format documentation, which is available at the
following website: https://msdn.microsoft.com/en-
us/library/cc313118(v=office.12).aspx. Any views or opinions
presented in this material are solely those of the author and do
not necessarily represent those of Microsoft. Microsoft
disclaims all liability for mistakes or inaccuracies in this
presentation.