Microsoft Word 97 (aka Version 8) for Windows and Macintosh. From the Office book, found in the Microsoft Office Development section in the MSDN Online Library. HTMLified June 1998. Revised Aug 1 1998, added missing Definitions section. Revised Dec 21 1998, added missing Document Properties (section).
Many of the structures written in Word files differ slightly from the corresponding structures Word uses internally. The file-specific version of a structure is typically named by adding a preceding or (more often) trailing F. For example, Word uses internally a PLC (PLex of Cps), but writes to files a PLCF (PLex of Cps in File). Many discussions in this document use the name of the internal structure when the file-specific structure is what is really being referred to. The reader should remember that the name of a seemingly undefined structure type may simply be missing a leading or trailing F.
Word 97 is an OLE 2.0 application. A Word binary file is a docfile and Word binary data is written into streams within the docfile using the OLE 2.0 docfile APIs. These streams are stored in the file as linked lists of file blocks and this data cannot be reliably accessed by using the operating system Open APIs. To access data within a Word binary file, the file must be opened using the OLE 2.0 docfile APIs, and it must be read with the appropriate docfile APIs.
A word docfile consists of a main stream, a summary information stream, a table stream, a data stream, and 0 or more object streams which contain private data for OLE 2.0 objects embedded within the Word document. The summary information stream is described in the section immediately following this one. The object storages contain binary data for embedded objects. Word has no knowledge of the contents of these storages; this information is accessed and manipulated though the OLE 2.0 APIs.
The majority of this document describes the contents of the main stream and the table stream.
OLE 2.0:
Object Linking and Embedding 2.0
API (Application Programming Interface):
A set of libraries, functions, definitions, etc. which describe an interface to a programming environment or model.
docfile:
An OLE 2.0 compatible multi-stream file. Word files are docfiles.
page (or sector):
512 byte segment of the main stream within a Word docfile that begins on a 512-byte boundary. (bytes 0-511 are in page 0, bytes 512-1023 are in page 1, etc.). In Word data structures, an unsigned two-byte integer page number is given the acronym PN (for Page Number).
document:
A named, multi-linked list of data structures, representing an ordered stream of text with properties that was produced by a user of Microsoft Word
stream:
The physical encoding of a Word document 's text and sub data structures in a random access stream within a docfile.
main stream:
The stream within a Word docfile containing the bulk of Word's binary data.
table stream:
The stream within a Word docfile containing the various plcf's and tables that describe a documents structures.
data stream:
The stream within a Word docfile containing various data that hang off of characters in the main stream. For example, binary data describing in-line pictures and/or formfields.
summary information stream:
The stream within a Word docfile containing the document summary information.
object storage:
A storage containing binary data for an embedded OLE 2.0 object.
CP (Character Position):
A four-byte integer which is the position coordinate of a character of text within the logical text stream of a document.
FC( File Character position):
A four-byte integer which is the byte offset of a character (or other object) from the beginning of a stream of the docfile. Before a file has been edited(i.e. in a full saved Word document), CPscan be transformed into FCs by adding the FC coordinate of the beginning of a document's text stream to the CP. After a file has been edited (i.e. in a fast-saved Word document), the mapping from CP to FC is recorded in the piece table (see below)
XCHAR( eXtended CHARacter set):
A data type which defines a "character". Each XCHAR corresponds to a character in the document, where "character" is defined as a glyph, regardless of whether it is a single-byte or double-byte character. With Word6/FE, Word95/FE, Word97/all and future versions of Word, this is defined as a 16-bit integer corresponding to the Unicode character code of the glyph.
PLF(PLex stored in File):
A data structure consisting of an array of structures preceded by a long count of structures.
PLCF(PLex of Cps(or FCs) stored in File):
A data structure consisting of two parallel arrays that allows a relation to be established between a certain CP position in the document text stream (or FC position in a file) and an arbitrary data structure. It consists of an array of n+1 CPs or FCs followed by an array of n instances of a particular arbitrary data structure. In typical usage, the nth CP or FC of the PLCF is in one-to-one correspondence with the nth instanceof the arbitrary data structure, with the n+1st CP or FC marking the limit of the nth instance's influence. When a PLCF is used to record a partitioning of the document's text stream or a partitioning of the bytes stored in a file, the 0th CP/FC stored in the PLCF will be 0. When a PLCF is used to record the location of certain marks or links within the document text stream, the 0th CP/FC stored in the PLCF will record the position of the 0th mark or link. To properly interpret a PLCF stored in a Word file, the length of the stored PLCF and the length of the arbitrary data structure stored in the PLCF must be known. The length of the stored PLCF is recorded in the FIB. The lengths of the data structures stored in PLCFs within Word files are listed later in this document.
piece table:
The piece table is a data structure that describes the logical sequence of characters in a Word document and records recent changes to the formatting of a Word document. It is stored in a Word file as a PLCF named the plcfpcd (PLex of Cps containing Piece Descriptors).The piece table relates a logical character number, called a CP (Character Position), to a physical location within a Word file (an FC). The array of CPs in the plcfpcd defines a partitioning of the Word document into disjoint pieces. The second array is an array of PCDs (Piece Descriptors) which is in 1-to-1 correspondence to the array of CPs that records the physical location in the Word file where the corresponding piece begins. To find the physical location of a particular logical character in aWord document, take the CP coordinate of that character within the document and find the piece that contains that character. This is done by finding the index of the largest CP in the array of CPs that is less than the character CP. Thenreference the PCD with that index in the array of PCDs. The FC stored in the PCD gives the position of the beginning of the piece in the file. Finally, add the offset of the desired character from the beginning of its piece to the FC of the beginning of the piece. This gives a "virtual" file offset of the character. If the second most significant bit is clear, then this indicates the actual file offset of the unicode character (two bytes). If the second most significant bit is set, then the actual address of the codepage-1252 compressed version of the unicode character (one byte), is actually at the offset indicated by clearing this bit and dividing by two.
sprm (Single PRoperty Modifier):
An instruction to modify one or more properties within one of the property defining data structures (CHP, PAP, TAP, SEP, or PIC). It consists of an operation code which identifies the field(s) to be changed, and anoperand which gives the value that a particular field is changed to or else which is a parameter to a procedure which will change the field or fields. A prl (property modifiers stored in a list) is a sprm plus its operand.
grpprl (group of prls):
A grpprl is a data structure that records a set of sprms. The 0th sprm is recorded at offset 0 of the structure. Any succeeding sprms are recorded immediately after the end of the preceding sprm . To traverse a grpprl and locate the sprms recorded within it, it's necessary to fetch the opcode of the first sprm, lookup the length of the sprm with that opcode, use that length to skip past the first sprm, fetch the opcode of the second sprm, lookup the length of that sprm, use the length to skip the second sprm, and so on. See the table in the "SPRM Definition" topic to determine the length of a sprm.
The phrase "apply the sprms of a grpprl (or papx or sepx)" used later in this document means to fetch the 0th sprm recorded in the grpprl and perform the action for that sprm, fetch the first sprm and perform its action, and continue this procedure until all sprms in the grpprl (or papx or sepx) have been processed.
prm (PRoperty Modifier):
A field in piece table entries that records how the properties of text within a piece were changed to reflect user formatting operations. The prm usually contains an index to a grpprl which records the user's formatting changes as a group of sprms. If the user has made only a small change to formatting that can be expressed as a single 2 or 1-byte sprm, that sprm is stored within the prm.
STTBF (STring TaBle stored in File)
Word has many tables of strings that are stored as Pascal type strings. STTBFs consist of an optional short containing 0xFFFF, indicating that the strings are extended character strings, a short indicating how many strings are included in the string table, another short indicating the size in bytes of the extra data stored with each string and each string followed by the extra data. Non-extended charater Pascal strings begin with a single byte length count which describes how many characters follow the length byte in the string. If pst is a pointer to an array of characters storing a Pascal style string then the length of the string is *pst+1. In an STTBF Pascal style strings are concatenated one after another until the length of the STTBF recorded in the FIB is exhausted.Extra data associated with a string may also be stored in an sttbf.When extra data is stored for an STTBF, it is written at the end of each string. For example:The extra data for an STTBF consists of a short.If the string "Cat" were stored, the actual entry in the string table would consist of a length byte containing 3 (3 for "Cat") followed by the bytes 'C' 'a' 't', followed by the 2 bytes containing the short. Extended character strings are stored just the same, except they have a double byte length count and each extended character occupies two bytes.
full-saved (or non-complex) file:
A Word file in which the physical order of characters stored in the file is identical to the logical order of characters in the document that the file represents. The text stream of a non-complex file can be described by an fc (an offset from the beginning of the file) to mark where the text begins and a ccp (count of CPs) to record how many characters are stored in the text stream. Due to unicode compression to code page 1252, all files (simple and complex) now contain a piece table. However, a full-saved piece table will not have property modifiers (prms) and all text in the file will be referenced by the piece table.
fast-saved (or complex) file:
A Word file in which the physical order of characters stored in the file does not match the logical order of characters in the document that the file represents. A piece table must be stored in the file to describe the text stream of the document. Due to unicode compression to code page 1252, all files (simple and complex) now contain a piece table.
FIB (File Information Block):
The header of a Word file. Begins at offset 0 in file. Gives the beginning offsetand lengths of the document's text stream and subsidiary data structures within the file. Also stores other file status information.
paragraph
A contiguous sequence of characters within the text stream of a document that is delimited by a paragraph mark, cell mark, row mark, or a section mark (These are special characters described later in this document).
run of text
A contiguous sequence of characters within the text stream of a document that have the same character formatting properties. A single run may cross paragraph boundaries and may encompass the entire document.
section
A contiguous sequence of paragraphs within the text stream of a document that is delimited by a section mark or by the final paragraph mark at the end of a document. Users frequently treat sections as the equivalent of a chapter in a book. The boundaries of sections mark locations where the layout rules for a document (number of columns, text of headers and footers to use, whether page numbers should be displayed, etc.) are changed.
paragraph style
A named set of character and paragraph properties that can be associated with any number of paragraphs in a Word document's text stream. A paragraph style provides a set of character and paragraph property defaults for the text of any paragraph tagged with that style. When a new paragraph is created and given a particular style, newly typed text is given the character and paragraph properties of that style unless the user makes an exception to the paragraph style definition by performing other editing operations.
CHP (CHaracter Properties)
The data structure describing the character properties of a run of text.
CHPX (Character Property EXception)
A data structure which describes how a particular CHP differs from a reference CHP. In Win Word 6.0, the CHPX simply consists of a grpprl which is applied to the reference CHP to produce the originally encoded CHP. By applying a CHPX to the character properties (CHP) inherited by a particular paragraph from its style,it is possible to reconstitute the CHP for the portion of the character run that intersects that paragraph
character style
A named character property exception that can be associated with any number of runs of text in a Word document's text stream. When a run of text is tagged with a particular character style, a chpx recorded for the character style is applied to the character properties that are defined for the paragraph style of the paragraph that contains the text. This means that the character style can change one or more of the character property field settings specified by the paragraph style of a paragraph to a particular setting without changing the value of any other field.
PAP (PAragraph Properties)
The data structure which describes the properties of a particular paragraph.
PAPX (PAragraph Property EXception)
A data structure describing how a particular paragraph's properties differ from the paragraph properties of the style assigned to the paragraph. By applying a PAPX to the paragraph properties (PAP) inherited by a particular paragraph from its style, it is possible to reconstitute the PAP for that paragraph. The PAPX contains an ISTD (a style code to identify the style in control of the paragraph and a grpprl which specifies how the style's paragraph properties must be changed to produce the paragraph properties of the paragraph.
table row:
A contiguous sequence of paragraphs within the text stream of a document that is partitioned into subsequences of paragraphs called cells. The last paragraph of each cell is terminated by a special paragraph mark called a cell mark. Following the cell mark that ends the last cell of a table row, the table row is terminated by a special paragraph mark called a row mark. When Word displays a table row, it assigns a rectangular shaped display area to each cell in the row. All of the cell display area's top's are aligned at the same vertical position on a page. The leftmost display area in a table row is assigned to the 0th cell of the row; the next display area to the right is assigned to the 1st cell of the row, etc. The text of the cell is wrapped to fit its display area.As more text is added to the cell, the cell display area extends downward. A set of table properties that determine how many cells are in a row, where the horizontal boundaries of cell display areas are, and what borders are drawn around each cell in the table is stored for the row mark that marks the end of the table row.
TAP (TAble Properties):
The data structure which describes the properties of a single table row. The information in the TAP for a table row is stored in a Word file as a list of sprms that modify a TAP which has been cleared to zeros. This list of table sprms is appended to the grpprl of paragraph sprms that is recorded in the PAPX for the row mark that delimits the end of a table row.
STSH (STyle SHeet)
A data structure which represents every style defined within the Word document. The STSH records a unique name string for every style and associates each name with a particular CHP and/or a PAP. The indexes used to refer to individual styles are called ISTDs (Indexesto STyle Descriptors). Every PAPX for every paragraph recorded in a documentcontains an ISTD which identifies the style from which a paragraph inherited its default character and paragraph properties. CHPXs recorded for the text within the paragraph and PAPXs recorded for the paragraph itself encode changes that the user has made with respect to the style's default properties.
FKP (Formatted disK Page):
A data structure that fits in one 512-byte page that encodes either the character properties or the paragraph properties of a certain portion of a Microsoft Word file. An FKP consists of four components:
1) a count of the number of runs or paragraphs described by the page.
2) an array of FCs recorded in ascending order demarcating the boundaries between runs or paragraphs that are recorded adjacent to one another in the Word file.
3) In character FKPs an array of offsets within the FKP in one to one correspondence with the array of FCs that locate the properties of the run that begins at a particular FC.
In LVC FKPs an array of offsets within the FKP in one to one correspondence with the array of FCs that locate the LVCXs that describe the run that begins at a particular FC.
In paragraph FKPs an array of BX structures follows the array of FCs in one to one correspondence with the array of FCs. Each BX begins with an offset that locates the properties of the paragraph that begins at a particular FC. The remainder of the BX contains a PHE structure that encodes information about the height of the paragraph that begins at that FC.
4) a group of CHPXs if the FKP stores character properties, a group of PAPXs if the FKP stores paragraphand table properties, or a group of LVCXs if the FKP stores paragraph level and numbering cache information
To find the CHPX/PAPX corresponding to a particular character in a document, calculate the FC coordinate for that character. Then search through the bin table (see next entry)for the type of property you want to produce, to find the FKP in the document stream whose array of FCs encompasses the FC of the documentcharacter.
Then search within the FKP to find the index of the largest FC entry that is less than or equal to the FC of the document character. Use this index to look up an offset in the array of offsets (for character FKPs) or look up an offset in the array of Bxs (for paragraph FKPs) within the FKP. Add this offset to the beginning address of the FKP in memory. This will be the first byte of the desired CHPX/PAPX.
bin table
Each FKP can be viewed as bucket or bin that contains the properties of a certain range of FCs in the Word file. In Word files, a PLC,the plcfbte (PLex of FCs containing Bin Table Entries) is maintained. Itrecords the association between a particular range of FCs and the PN (Page Number) of the FKP that contains the properties for that FC range in the file. In a complex (fast-saved) Word document, FKP pages are intermingled with pages of textin a random pattern which reflects the history of past fast saves. In a complex document, a plcfbteChpx which records the location of every CHPX FKP must be stored and a plcfbtePapx which records the location of every PAPX FKP must be stored. In a non-complex, full-saved document, all of the CHPX FKPS are recorded in consecutive 512-byte pages with the FKPs recorded in ascending FC order, as are all of the PAPX FKPS. A plcfbteLvcx serves the same purpose for LVCX FKPS.
In a full save document, the plcfbte's may not have been able to be expanded during the save process due to a lack of RAM. In that situation, the plcfbte's will be interspersed with the property pages in a linked list of FBD pages.
SEP(SEction Properties)
The data structure describing the properties of a particular section.
SEPX(SEction Property EXceptions)
A data structure describing how the properties of a particular section differ from a Word-defined standard SEP. As in the PAPX, the differences between the SEP for a section and the standard SEP are encoded as list of sprms that describe how the standard SEP can be transformed into the section's SEP.By applying a SEPX's sprms to the standard SEP, it is possible to reconstitute the SEP for that section.
The PLCFSED, a data structure stored in a Word file, records the locations of all SEPXs stored in a Word file. The array of CPs in the plcfsed records the boundaries of sections in the Word document . The second array in the plcf, an array of SEDs (SEction Descriptors), is in 1-to-1 correspondence to the array of CPs. Each SED stores the beginning FC of the SEPX that records the properties for a section. If the FC stored in a SED is -1, the section properties of the section are exactly equal to the standard section properties.
The SEP for a particular section may be constructed if a CP of a character in that section is known. First search the array of CPs in the PLCSED for the index of the largest CP that is less than or equal to the CP of the character. Use this index to locate the SED in the plcfsed which describes the section. The FC stored in the SED is the offset from the beginning of the Word file at which the SEPX is stored. If the stored FC is equal to 0xFFFFFFFF, then the SEP for the section is exactly equal to the standard SEP (see SEP structure definition) Otherwise, read the SEPX into memory and create a copy of the standard SEP. Finally, apply the sprms stored in the SEPX to the standard SEP to produce the SEP for a section.
DOP (DOcument Properties)
The data structure describing properties that apply to the document as a whole.
sub-document
A separate logical stream of text with properties for which correspondences with the main document text are maintained. Word's headers/footers, footnotes, endnotes,macro procedure text, annotation text, and text within textboxes are kept in separate subdocuments. Each subdocument has its own CP coordinate space. In other words, data structures are stored in Word files that are components of these subdocuments. These data structures contain CP coordinates whose 0 point is the beginning of the subdocument text stream instead of the beginning of the main document text stream.
In full-saved documents, a simple calculation with values stored in the FIB producesthe file offset of the beginning of the subdocument text streams (if they exist). The length of these streams is also stored.
In fast-saved documents, the piece tables of subdocuments are concatenated to the end of the main document piece table. In this case, to identify the beginning of subdocument text , you must sum the length of the main document text stream with the lengths of any subdocument text streams stored ahead of the subdocument (information stored in the FIB) and treat this sum as a CP coordinate. To retrieve the text of the subdocument, you must do lookups in the piece table, starting with the piece that contains the beginning CP coordinate, to find the physical location of each piece of the subdocument text stream.
field
A field is a two-part structure that may be recorded in the CP stream of a document. The first part of the structure contains field codes which instruct Window's Word to insert text into the second part of the structure, the field result. Fields in Window's Word are used to insert text from an external file or to quote another part of a document, to mark index and table of contents entries and produce indexes and tables of contents, maintain DDE links to other programs, to produce dates, times, page numbers, sequence numbers, etc. There are 91 different field types.
A field begin mark delimits the beginning of a field and precedes any of the field codes stored in the field. The end of the field codes and the beginning of the field result is marked with the field separator and the field result and the field itself are terminated by a field end mark.
The CP locations of the field begin mark, field separator, and field end mark are recorded in plcfld data structures that are maintained for the main document and all of the subdocuments of the main document whenever a field is inserted or edited. A field can be dead, in which case it has no field separator, no field result, and no entry in the plcfld. (See the definition of the FLD structure for a list of possible dead field code strings.) An array of two-byte FLD structures is stored in the plcfld in one-to-one correspondence with the CP entries recorded. An FLD associated with a field begin mark records the type of the field. An FLD associated with the field end mark records the current status of the field (i.e. whether the result is dirty or has been edited, whether the result has been locked, etc.)
Fields may be nested. 20 levels of nesting are permitted.
bookmark
A bookmark associates a user definable name with a range of text within a document. A bookmark is frequently used as an operand in field code instructions within a field. In Window's Word a bookmark is represented by three parallel data structures, the sttbBkmk, the plcbkf and the plcbkl. The sttbBkmk is a string table which contains the name of each bookmark that is defined. The plcbkf records the beginning CP position of each bookmark. The plcbkl records the limit CP position that delimits the end of a bookmark. Since bookmarks may be nested within one another to any level, the BKF structure stored in the plcbkf consists of a single index which specifies which plcbkl marks the end of the bookmark. The BKL structure is not written to the file, and the plcbkl contains only CPs.
picture
A picture is represented in the document text stream as a special character, an ASCII 1 whose CHP has the fSpec bit set to 1. The file location of the picture in the Word binary file is stored in the character's CHP in chp.fcPic. The fcPic is a byte offset into the data stream. Beginning at the position recorded in chp.fcPic, a header data structure, the PIC, will be stored. If the picture is a reference to a TIFF file, a Picture file or an Office shape file, the name of the file will be recorded immediately following the PIC in a Pascal style string. If the picture is an Office shape, a Window's metafile or a bitmap, the shape, metafile or bitmap will immediately follow the PIC. Pictures that are a reference to an Office shape file will include both the filename and the shape in that order. Pictures inserted with Word97 are in the new Office shape format (documented elsewhere). However, pictures can be copied from older files into newer ones and their old format will persist until the picture is edited or displayed.
Some files (including all files created by Word for the Macintosh) may store Macintosh PICT pictures as well. In this case, the PIC structure is immediately followed by a standard Windows metafile depicting a large "x", so that older readers expecting only a metafile after the PIC will just display this "x". If a reader detects this standard "x" metafile, it can extract the sizes of the standard "x" metafile and the Macintosh PICT picture that follows it from an early portion of this "x" metafile. Please see Appendix B for a discussion of this technique.
embedded object
The native data for Embedded objects (OBJs) is stored similarly to pictures (PICs).To locate the native data for Embedded objects, scan the plc of field codes for the mother, header, footnote and annotation, textbox and header textbox documents (fib.PlcffldMom/Hdr/Ftn/Atn/Txbx/HdrTxbx).For each separator field, get the chp.
If chp.fSpec=1 and chp.fObj=1, then this separator field has an associated embedded object. The file location of the object data is stored in chp.fcObj. At the specified location an object header is stored followed by the native data for the object. See the _OBJHEADER structure.
If chp.fOle2=1, then this separator field has an associated OLE2 object. The fcPic will be a unique integer that specifies the name of the object's sub-storage instead of an offset into the data stream.
office art object
An office art object is represented in the document stream as a special character, an ASCII 8, which has chp.fSpec set to 1 for the run of text containing the character .Only main documents and header documents contain office art objects.The native data for the office art object may be obtained by taking the CP for the special character and using this to find the corresponding entry in the plcspa.An entry in this plc consists of a FSPA structure, which is described elsewhere in this document.
Office art objects can have text attached to them. Text for the textboxes is stored separately in the textbox subdocument of the main or header document.The textbox subdocument contains a plctxbxs where the text from CP n to CP n+1 in the subdocument is the text which is contained in a textbox as specified in the TXBXS structure for this nth entry in the plctxbxs. Textboxes can be linked in chains of up to 32 textboxes. Ordering of textboxes in the subdocument is completely unrelated to the document structure due to the nature of textbox linking. To find the text for a given office art object, the TXID property (a long: high word is itxbxs+1, low word is the sequence number) must be fetched from the office art data for the shape. This contains an index (itxbxs) into plctxbxs and a sequence number in the chain of linked textboxes. The text for the entire chain of linked textboxes is stored from the CP itxbxs to CP itxbxs+1 of plctxbxs. The plctxbxBkd describes the "page table" within textbox stories (where the textboxes in each linked textbox chain are thought of as "pages"). So, for each entry in the plctxbxs there is a corresponding entry in the plctxbxBkd at the same CP, and there may be additional entries in the plctxbxBkd to describe the breaks from one textbox to the next in linked textbox chains.
Note
In this document, bit 0 is the low-order bit. Structures are described as they would be declared in C for the Intel architecture. When numbering bytes in a word from low offset towards high offset, two-byte integers will have their least significant eight bits stored in byte 0 and most significant eight bits in byte 1. If bit 31 is the most significant bit in a four-byte integer, bits 31 through 24 will be stored in byte 3 of a four-byte integer, bits 23 through 16 will be stored in byte 2, bits 15 through 8 will be stored in byte 1, and bits 7 through 0 will be stored in byte 0.
The names in Word data structures usually consist of a lower case sequence of characters followed by an optional upper case modifier. The following tags are used in the lower case parts of field names to document the data type of a field:
The two following modifiers are used occasionally in this documentation:
The summary information for a Word document is stored in two structured storage streams, SummaryInformation and DocumentSummaryInformation. Information on the layout of the SummaryInformation stream can be found in Appendix B of the OLE 2 Programmers Reference.
The main stream of a Word docfile (non-complex format) consists of the Word file header (FIB), the text, and the formatting information.
- FIB
- Stored at beginning of page 0 of the file. fib.fComplex will be set to zero.
- text of body, footnotes, headers
- Text begins at the position recorded in fib.fcMin.
- FKPs for CHPs, PAPs and LVCs
- The first FKP begins at a 512-byte boundary after the last byte text written.. The remaining FKPs are recorded in the 512-byte pages that immediately follow. The FKPs for CHPs PAPs and LVCs are interleaved. Previous versions of Word wrote them in contiguous chunks. The hplcfbte's of the three flavors (CHP, PAP and LVC) are used to find the relevant FKP of the appropriate type.
- group of SEPXs
- SEPXs immediately follow the FKPs and are concatenated one after the other. SEPXs are no longer guaranteed to start on a page boundary if it would span a boundary if placed immediately after the preceding SEPX.
The main stream of a Word binary file (complex format) consists of the Word file header (FIB), the text, and the formatting information.
- FIB
- Text of body, footnotes, headers stored during last full save
- Text begins at the position recorded in fib.fcMin.
- FKPs for CHPs, PAPs and LVCs
- The first FKP begins at a 512-byte boundary after the last byte text written.. The remaining FKPs are recorded in the 512-byte pages that immediately follow. The FKPs for CHPs PAPs and LVCs are interleaved. Previous versions of Word wrote them in contiguous chunks. The hplcfbte's of the three flavors (CHP, PAP and LVC) are used to find the relevant FKP of the appropriate type.
- Group of SEPXs stored during last full save
- Any text, stored during first fast save
- Any FKPs stored during first fast save
- Any SEPXs stored during first fast save
- Any text, stored during second fast save
- Any FKPs stored during second fast save
- Any SEPXs stored during second fast save
- ...
- Any text, stored during nth fast save
- Any FKPs stored during nth fast save
- Any SEPXs stored during nth fast save
Word stores various plcfs and tables with the stream named either "0Table" or "1Table". Ordinarily a file will contain only one table stream. However, in some unusual circumstances (e.g. crash during file save) a file might have two table streams. In that case the bit field fWhichTblStm in the FIB should be used to determine which table stream to read. If fWhichTblStm is 0, then the FIB refers to the stream named "0Table", and if fWhichTblStm is 1, then the FIB refers to the stream name "1Table".
- sttbfUssr
- Undocumented undo / versioning data
- plcupcRgbuse
- Undocumented undo / versioning data
- plcupcUsp
- Undocumented undo / versioning data
- uskf
- Undocumented undo / versioning data
- stsh (style sheet)
- Written immediately after the preivous table. This is recorded in all Word documents.
- plcffndRef (footnote reference position table)
- Written immediately after the stsh if the document contains footnotes
- plcffndTxt (footnote text position table)
- Written immediately after the plcffndRef if the document contains footnotes
- pgdFtn (footnote text page description table)
- Written immediately after the plcffndTxt if the document contains footnotes
- bkdFtn (footnote text break descriptor table)
- Written immediately after the pgdFtn if the document contains footnotes.
- plcfendRef (endnote reference position table)
- Written immediately after the previously recorded table if the document contains endnotes
- plcfendTxt (endnote text position table)
- Written immediately after the plcfendRef if the document contains endnotes
- pgdEdn (endnote text page description table)
- Written immediately after the plcfendTxt if the document contains endnotes
- bkdEdn (endnote text break descriptor table)
- Written immediately after the pgdEdn if the document contains endnotes
- plcftxbxTxt (text box link table)
- Written immediately after the previously recorded table if the document contains textboxes
- plcftxbxBkd (text box break descriptor table)
- Written immediately after the plcftxbxTxt if the document contains textboxes
- plcfhdrtxbxTxt (header text box link table)
- Written immediately after the previously recorded table if the header subdocument contains textboxes
- plcfhdrtxbxBkd (header text box break descriptor table)
- Written immediately after the plcfhdrtxbxTxt if the header subdocument contains textboxes.
- grpXstAtnOwners (annotation owner table)
- Written immediately after the previously recorded table if the document contains annotations.
- plcfandRef (annotation reference position table)
- Written immediately after the grpXstAtnOwners if the document contains annotations
- plcfandTxt (annotation text position table)
- Written immediately after the plcfandRef if the document contains annotations.
- plcfsed (section table)
- Written immediately after the previously recorded table. Recorded in all Word documents
- pgdMother (page description table)
- Written immediately after the plcfsed in all Word documents
- bkdMother (break descriptor table)
- Written immediately after the pgdMother in all Word documents
- plcfphe (paragraph height table)
- Written after the previously recorded table, if paragraph heights have been recorded. Only written during a fast save.
- plcfsea (private)
- PLCF reserved for private use by Word.
- plcflvc (list and outline level table)
- Written immediately after the previously recorded table during fast save only.
- plcasumy (AutoSummary analysis)
- Written immediately after the previously recorded table, if the document stored is in AutoSummary view mode.
- sttbGlsy (glossary name string table)
- Written immediately after the previously recorded table, if the document stored is a glossary.
- sttbGlsyStyle (glossary style name string table)
- Written immediately after sttbGlsy, if the document stored is a glossary.
- plcfglsy (glossary entry text position table)
- Written immediately after the previously recorded table, if the document stored is a glossary.
- plcfhdd (header text position table)
- Written immediately after the previously recorded table, if the document contains headers or footers.
- plcfbteChpx (bin table for CHP FKPs)
- Written immediately after the previously recorded table. This is recorded in all Word documents.
- plcfbtePapx (bin table for PAP FKPs)
- Written immediately after the plcfbteChpx. This is recorded in all Word documents.
- plcfbteLvc (bin table for LVC FKPs)
- Written immediately after the plcfbtePapx. This is recorded in all Word documents.
- sttbfRMark (revision mark author string table)
- Written immediately after plcfbteLvc, if the document contains revision marks.
- PlcffldMom (table of field positions and statuses for main document)
- Written immediately after the previously recorded table if the main document contains fields.
- PlcffldHdr (table of field positions and statuses for header subdocument)
- Written immediately after the previously recorded table, if the header subdocument contains fields.
- PlcffldFtn (table of field positions and statuses for footnote subdocument)
- Written immediately after the previously recorded table, if the footnote subdocument contains fields.
- PlcffldAtn (table of field positions and statuses for annotation subdocument)
- Written immediately after the previously recorded table, if the annotation subdocument contains fields.
- PlcffldEdn (table of field positions and statuses for endnote subdocument)
- Written immediately after the previously recorded table, if the endnote subdocument contains fields.
- PlcffldTxbx (table of field positions and statuses for textbox subdocument)
- Written immediately after the previously recorded table, if the textbox subdocument contains fields.
- plcOcx (ocx position table)
- Written immediately after the previously recorded table, if the document contains ole controls. Undocumented.
- PlcffldHdrTxbx (table of field positions and statuses for textbox subdocument of header subdocument)
- Written immediately after the previously recorded table, if the textbox subdocument of the header subdocument contains fields.
- dggInfo (office drawing information)
- Written immediately after the previously recorded table. Format is described in the Office drawing group format document.
- plcspaMom (office drawing table)
- Written immediately after the previously recorded table, if the document contains office drawings.
- plcspaHdr (header office drawing table)
- Written immediately after the previously recorded table, if the header subdocument contains office drawings.
- sttbfBkmk (table of bookmark name strings)
- Written immediately after the previously recorded table, if the document contains bookmarks.
- plcfBkmkf (table recording beginning CPs of bookmarks)
- Written immediately after the sttbfBkmk, if the document contains bookmarks.
- plcfBkmkl (table recording limit CPs of bookmarks)
- Written immediately after the plcfBkmkf, if the document contains bookmarks.
- sttbfAtnBkmk (table of annotation bookmark string names)
- Written immediately after the previously recorded table, if the document contains annotations with bookmarks.
- plcfAtnbkf (table recording beginning CPs of bookmarks in the annotation subdocument)
- Written immediately after the sttbfAtnBkmk previously recorded table, if the document contains annotations with bookmarks.
- plcfAtnbkl (table recording limit CPs of bookmarks in the annotation subdocument)
- Written immediately after the plcfAtnbkf previously recorded table, if the document contains anotations with bookmarks.
- plcfspl (spelling state table)
- Written immediately after the previously recorded table. Records state of spell checking in a PLCF of SPLS structures.
- plcfgram (grammar state table)
- Written immediately after the previously recorded table. Records state of grammar checking in a PLCF of SPLS structures.
- plcfwkb (work book document partition table)
- Written immediately after the previously recorded table, if the document is a master document.
- formFldSttbs (form field dropdown string tables)
- Written immediately after the previously recorded table, if the document contains form field dropdown controls.
- sttbCaption (caption title string table)
- Written immediately after the previously recorded table, if the document contains captions.
- sttbAutoCaption (auto caption string table)
- Written immediately after the previously recorded table, if the document contains auto captions.
- sttbFnm (filename reference string table)
- Written immediately after the previously recorded table, if the document references other documents.
- sttbSavedBy (last saved by string table)
- Written immediately after the previously recorded table.
- plcflst (list formats)
- Written immediately after the end of the previously recorded, if there are any lists defined in the document. This begins with a short count of LSTF structures followed by those LSTF structures.
- This is immediately followed by the allocated data hanging off the LSTFs. This data consists of the array of LVLs for each LSTF. (Each LVL consists of an LVLF followed by two grpprls and an XST.)
- plflfo (more list formats)
- Written immediately after the end of the plcflst and its accompanying data, if there are any lists defined in the document. This consists first of a PL of LFO records, followed by the allocated data (if any) hanging off the LFOs. The allocated data consists of the array of LFOLVLFs for each LFO (and each LFOLVLF is immediately followed by some LVLs).
- sttbfListNames (more list formats)
- Written immediately after the end of the plflfo and its accompanying data, if there are any lists defined in the document. This is a string table containg the list names for each list. It is parallel with the plcflst, and may contain null strings if the corresponding LST does not have a list name.
- hplgosl (grammar option settings)
- Written immediately after the previously recorded table. This undocumented structure maps LID and grammar checker type to grammar checking options.
- stwUser (macro user storage)
- routeSlip (mailer routing slip)
- Written immediately after the previously recorded table, if this document has a mailer routing slip.
- cmds (recording of command data structures)
- Written immediately after the previously recorded table, if special commands are linked to this document.
- prDrvr (printer driver information)
- Written immediately after the previously recorded table, if a print environment is recorded for the document.
- prEnvPort (print environment in portrait mode)
- Written immediately after the previously recorded table, if a portrait mode print environment is recorded for this document.
- prEnvLand (print environment in landscape mode)
- Written immediately after the previously recorded table, if a landscape mode print environment is recorded for this document.
- wss (window state structure)
- Written immediately after the end of previously recorded structure, if the document was saved while a window was open.
- pms (print merge state)
- Written immediately after the previously recorded table, if information about the print / mail merge state is recorded for the document
- clx (encoding of the sprm lists for a complex file and piece table for a any file)
- Written immediately after the end of previously recorded structure. This is recorded in all Word documents.
- sttbfffn (table of font name strings)
- Written immediately after the clx. This is recorded in all Word documents. The sttbfffn is an sttbf where each string is instead an FFN structure (note that just as for a pascal-style string, the first byte in the FFN records the total number of bytes not counting the count byte itself). The names of the fonts correspond to the ftc codes in the CHP structure. For example, the first font name listed corresponds is the name for ftc = 0.
- sttbttmbd (true type font embedding string table)
- Written immediately after the end of previously recorded structure if document contains embedded true type fonts.
- dop (document properties record)
- Written immediately after the end of previously recorded structure. This is recorded in all Word documents
- sttbfAssoc (table of associated strings)
- autosaveSource (name of original)
- Written immediately after the sttbfAssoc table. This field only appears in autosave files. These files are normal Word documents in every other way. Also, autosaved files are typically in the complex file format except that we don't overwrite the tables (plcf*, etc.). I.e., an autosaved file is typically longer than the equivalent Word document.
- pictures
- Word picture structures are concatenated one after the other if the document contains pictures.
- embedded objects-native data
- Word embedded object structures are concatenated one after the other if the document contains embedded objects.
- huge PAPXs
- The grpprls from PAPXs which are too large to fit in an FKP are concatenated one after the other as necessary.
The FIB contains a "magic word" and pointers to the various other parts of the file, as well as information about the length of the file. The FIB starts at the beginning of the file. The FIB is defined in the structure definition section of this document.
The text of the file starts at fib.fcMin. fib.fcMin is usually set to the next 128 byte boundary after the end of the FIB. The text in a Word document is ASCII text with the following restrictions (ASCII codes given in decimal):\
The following ASCII codes are treated as "special" characters when they have the character property special on (chp.fSpec == 1):
The end of a section is also the end of a paragraph. The last character of a section is a section mark which stands in place of the paragraph mark normally required to end a paragraph. An exception is made for the last character of a document which is always a paragraph mark although the end of a document is always an implicit end of section.
If !fib.fComplex, the document text stream is represented by the text beginning at fib.fcMin up to (but not including) fib.fcMac. Otherwise, the document is represented by the piece table stored in the file in the data beginning at .fib.fcClx.
The document text stream includes text that is part of the main document, plus any text that exists for the footnote, header, macro, or annotation subdocuments. The sizes of the main document and the header, footnote, macro and annotation subdocuments are stored in the fib, in variables fib.ccpText, fib.ccpFtn, fib.ccpHdr, fib.ccpMcr, fib.ccpEdn, fib.ccpTxbx, fib.ccpHdrTxbox and fib.ccpAtn respectively. In a non-complex file, this means that the text of the main document begins at fib.fcMin in the file and continues through fib.fcMin + fib.ccpText; that the text of the footnote subdocument begins at fib.fcMin + fib.ccpText and extends to fib.fcMin + fib.ccpText + fib.ccpFtn; that the text of the header subdocument begins at fib.fcMin + fib.ccpText + fib.ccpFtn and extends to fib.fcMin + fib.ccpText + fib.ccpFtn + fib.ccpHdr; that the text of the annotation subdocument begins at .fib.fcMin + fib.ccpText + fib.ccpFtn + fib.ccpHdr and extends to fib.fcMin + fib.ccpText + fib.ccpFtn + fib.ccpHdr + ccpAtn; that the text of the endnote subdocument begins at .fib.fcMin + fib.ccpText + fib.ccpFtn + fib.ccpHdr +ccpAtn and extends to fib.fcMin + fib.ccpText + fib.ccpFtn + fib.ccpHdr + fib.ccpEdn; that the text of the textbox subdocument begins at .fib.fcMin + fib.ccpText + fib.ccpFtn + fib.ccpHdr +fib.ccpAtn + fib.ccpEdn and extends to fib.fcMin + fib.ccpText + fib.ccpFtn + fib.ccpHdr + fib.ccpEdn + fib.ccpTxbx and that the text of the header textbox subdocument begins at .fib.fcMin + fib.ccpText + fib.ccpFtn + fib.ccpHdr +fib.ccpAtn + fib.ccpEdn + fib.ccpTxbx and extends to fib.fcMin + fib.ccpText + fib.ccpFtn + fib.ccpHdr + fib.ccpEdn + fib.ccpTxbx + fib.ccpHdrTxbx.
In a complex, fast-saved file, the main document text must be located by examining the piece table entries from the 0th piece table entry through the piece table entry that describes cp = fib.ccpText.
A footnote subdocument's text must be located by examining the piece table entries beginning with the one that describes cp=fib.ccpText through the entry that describes cp = fib.ccpText + fib.ccpFtn.
A header subdocument's text must be located by examining the piece table entries beginning with the one that describes cp=fib.ccpText + ccpFtn through the entry that describes cp = fib.ccpText +fib.ccpFtn + fib.ccpHdr.
An annotation subdocument's text must be located by examining the piece table entries beginning with the one that describes cp=fib.ccpText + ccpFtn + fib.ccpHdr through the entry that describes cp = fib.ccpText +fib.ccpFtn + fib.ccpHdr +fib.ccpAtn.
An endnote subdocument's text must be located by examining the piece table entries beginning with the one that describes cp=fib.ccpText + ccpFtn + fib.ccpHdr + fib.ccpAtn through the entry that describes cp = fib.ccpText +fib.ccpFtn + fib.ccpHdr +fib.ccpAtn.+ fib.ccpEdn
A textbox subdocument's text must be located by examining the piece table entries beginning with the one that describes cp=fib.ccpText + ccpFtn + fib.ccpHdr + fib.ccpAtn + fib.ccpEdn through the entry that describes cp = fib.ccpText +fib.ccpFtn + fib.ccpHdr +fib.ccpAtn.+ fib.ccpEdn + fib.ccpTxbx
A header textbox subdocument's text must be located by examining the piece table entries beginning with the one that describes cp=fib.ccpText + ccpFtn + fib.ccpHdr + fib.ccpAtn + fib.ccpEdn + fib.ccpTxbx through the entry that describes cp = fib.ccpText +fib.ccpFtn + fib.ccpHdr +fib.ccpAtn.+ fib.ccpEdn + fib.ccpTxbx+ fib.ccpHdrTxbx
Character and paragraph properties in Word documents are stored in a compressed format. The information that is stored on disk is not the actual properties of a particular sequence of text but the difference of the properties of a sequence from some reference property.
The PAP is a data structure that holds uncompressed paragraph property information; the CHP (pronounced like "chip") is a structure that holds uncompressed character property information. Each paragraph in a Word document inherits a default set of paragraph and character properties from one of the paragraph styles recorded in the style sheet data structure (STSH).
A particular PAP is converted into its compressed form, the PAPX, by first comparing the pap for a paragraph with the pap stored in the style sheet for the paragraph's style. Any properties in the paragraph's PAP that are different from those stored in the style sheet PAP are encoded as a list of sprms (grpprl). sprms express how the content of the style sheet PAP should be transformed to create the properties for the paragraph. A PAPX is a variable-length data structure that begins with a count of words that encodes the PAPX length. It contains a istd (index to style descriptor) which specifies which style entry in the style sheet contains the default paragraph and character properties for the paragraph, paragraph height information, and the list of difference sprms. If the only difference between the paragraph's PAP and the style's PAP were in the justification code field, which is one byte long, one two-byte sprm, sprmPJc, would be generated to express that difference; thus the total PAPX size would be 5 bytes. This is better than 54-1 compression since the total size of a PAP is 274 bytes.
To convert a CHP for a sequence of characters contained within a single paragraph into its compressed form, the CHPX, it's first necessary to know the paragraph style that is assigned to the paragraph containing those characters and any character style that may be tagging the character run. The character properties inherited from the paragraph style are moved into a buffer. If the chp.istd of the chp to be compressed is not istdNormalChar, the changes recorded for that character style are applied to buffer. Then the character properties of the character sequence are compared with the character properties generated using the paragraph's style and the run's character style. Any properties in the paragraph's CHP that are different from those stored in the generated CHP are encoded as a list of sprms (grpprl). The sprms express how the content of the CHP generated from the paragraph and character styles should be transformed to create the character properties for the text run. A CHPX is a variable-length data structure that begins with a count of words that encodes the CHPX length followed by the list of difference sprms.
If one of the bit fields in the CHP to be compressed such as fBold is different from the reference CHP, you would build a difference sprm using sprmCFBold in the first byte and the bytes pattern 0x81 in the second byte which signifies that the value of the bit in the CHP to be compressed is of opposite value from the value stored in the reference CHP. If there was no difference, sprmCFBold would not be recorded in the grrprl to be generated. If there were difference in a field larger than a single bit such as the chp.hps, a sprmCHps would be generated to record the value of chp.hps in the chp to be compressed. If the chp.hps were equal in both the chp to be compressed and the reference CHP, sprmCHps would not be recorded in the grrprl that is generated. If a sequence of characters has the same character properties and the sequence spans more than one paragraph, it's necessary to examine each paragraph's properties and to generate a different CHPX every time there is a change of style.
In Word documents, the fundamental unit of text for which character exception information is kept is the run of exception text, a contiguous sequence of characters stored on disk that all have the same exception properties with respect to their underlying style character properties. Each run would have an entry recorded in a CHPX FKP. If a user never changed the character properties inherited from the styles used in his document and did a complete save of his document, although each of those styles may have different properties, the entire document stream would be one large run of exception text and one CHPX would suffice to describe the character properties of the entire document.
The fundamental unit of text for which paragraph properties are recorded is the paragraph. Every paragraph has an entry recorded in a PAPX FKP.
The CHPX FKP and the PAPX FKP have similar physical structures. An FKP is a 512-byte data structure that is stored in one page of a Word file. At offset 511 is a 1-byte count named crun, which is a count of runs of exception text for CHPX FKPs and which is a count of paragraphs in PAPX FKPs. Beginning at offset 0 of the FKP is an array of crun+1 FCs, named rgfc, which records the beginning and limit FCs of crun runs of exception text or paragraphs.
For CHPX FKPs, immediately following fkp.rgfc is a byte array of crun word offsets to CHPXs from the beginning of the FKP. This byte array, named rgb, is in 1-to-1 correspondence with the rgfc. The ith rgb gives the word offset of the exception property that belongs to the run\paragraph whose beginning
For PAPX FKPSs, immediately following the fkp.rgfc is an array of 13 byte entries called BXs. This array called the rgbx is in 1-to-1 correspondence with the rgfc. The first byte of the ith BX entry contains a single byte field which gives the word offset of the PAPX that belongs to the paragraph whose beginning in FC space is rgfc[i] and whose limit is rgfc[i+1] in FC space. The last 12 bytes of the ith BX entry contain a PHE structure that stores the current paragraph height of the paragraph whose beginning in FC space is rgfc[i] and whose limit is rgfc[i+1] in FC space.
The fact that the offset to property stored in the rgb or rgbx is a word offset implies that CHPXs and PAPXs are stored in FKPs beginning on word boundaries. Since the values stored in the rgb/rgbx allow random access throughout the FKP, space within an FKP can be conserved by storing the offset of the same physical CHPX/PAPX in rgb/rgbx entries when several runs or paragraphs in the FKP have the same properties. Word uses this optimization.
An rgb or rgbx[].b value of 0 is used in another optimization. When a rgb or rgbx[].b value of 0 is stored in an FKP, it means that instead of referring to a particular CHPX/PAPX in the FKP the 0 value is a signal that the reader should construct for itself a commonly encountered predefined set of properties.
For CHPX FKPs a 0 rgb value means that the properties of the run of text were exactly equal to the character properties inherited from the style of the paragraph it was in. For PAPX FKPs, a 0 rgbx[].b value means that the paragraph's properties were exactly equal to the paragraph properties of the Normal style (stc == 0) and the paragraph contained 1 line of 240 pixels, with a column width of 7980 dxas.
When new entries are added to an FKP, there must be unallocated space in the middle of the FKP equal to 5 bytes for CHPXs (size of an FC plus size of one-byte word offset) or 11 bytes for PAPXs (size of an FC plus the size of a seven byte BX entry), plus the size of the new CHPX or PAPX if the property being added is not already recorded in the FKP and is not the property coded with a 0 rgb/rgbx[].b value. To add a new property in a CHPX FKP, existing rgb entries are moved four bytes to the right in the FKP. . To add a new property in a PAPX FKP, existing rgbx entries are moved four bytes to the right in the FKP. The new FC is added at the end of the rgfc. The new CHPX or PAPX is recorded on a 2-byte boundary before the previously recorded properties stored at the end of the block. The word offset of the beginning of the CHPX or PAPX is stored as the last entry of the relocated rgb/rgbx[].b, and finally, the crun stored at offset 511 is incremented. In Word '97, PAPXs can be generated which are too large to fit in an FKP. In such a case, the grpprl of the PAPX is written to the data stream and a PAPX is stored in an FKP with that grpprl replaced by a sprmPHugePapx.
A bin table (plcfbte) partitions the total extent of the Word file that contains text characters into a set of contiguous intervals marked by a fcFirst and an fcLim. The fcFirst for the nth interval would be plcfbte.rgfc[n] and the fcLim for the nth interval would be plcfbte.rgfc[n+1]. Associated with each interval is a BTE. A BTE holds a four-byte PN (page number) which identifies the FKP page in the file which contains the formatting information for that interval. A CHPX FKP further partitions an interval into runs of exception text. A PAPX FKP in a non-complex, full-saved file, partitions the text within intervals into paragraphs. If a file is in complex format (has been fast-saved), the PAPX FKP only records the FCs within the text that are preceded by a paragraph mark. Even though a sequence of text may be physically located between two paragraph end marks, it may reside in a paragraph different from the one defined by the following paragraph end mark, because the text may have been moved by the user into a different paragraph. In the logical text stream represented by the document's piece table, the paragraph mark that follows the moved text is stored in a non-adjacent physical location in the file.
A stylesheet is a collection of styles. In Word, each document has its own stylesheet.
A style is a set of formatting information collected together and given a name. Word 6.0 supports paragraph and character styles, previous versions supported only paragraph styles. Character styles have just character formatting, paragraph styles have both character and paragraph formatting. The style sheet establishes a correspondence between a style code and a style definition.
Note that the storage and behavior of styles has changed radically since Word 2 for Windows, beginning with nFib 63. Some of the differences are:
This document describes only the final Word 6.0 version of the stylesheet, not the Word 2.x version.
The styles for a document (both paragraph and character styles) are stored in an array in each document. When new styles are created, they are added to the end of the array. The array can have unused slots. Some slots at the beginning of the array are reserved for specific styles, whether they have been created yet or not. Paragraph and character styles are stored in the same array. Each document has a separate array, so the same style will usually have a different istd in two different documents. Thus style matching between documents must be done by name (or by sti if the styles are built-in.)
Styles are usually referred to using an istd. The istd is an index into an array of STD's (STyle Descriptions). A (doc, istd) pair uniquely identifies a style because it tells which style in which array.
Parts of a style (for more information, see the STD structure below):
Every paragraph has a paragraph style. Every character has a character style. The default paragraph style is Normal (stiNormal, istdNormal). The default character style is Default Paragraph Font (stiNormalChar, istdNormalChar).
The formatting of a paragraph (the PAP) and a character (the CHP) depend on the paragraph and character styles applied to them, as well as any additional formatting stored in the FKPs. The PAP and CHP are constructed in a layered fashion:
For a PAP:
For a CHP:
Note that the resulting PAP and CHP have fields that indicate what style was applied: PAP.istd, CHP.istd.
Stylesheet File Format
The style sheet (STSH) is stored in the file in two parts, a STSHI and then an array of STDs. The STSHI contains general information about the following stylesheet, including how many styles are in it. After the STSHI, each style is written as an STD. Both the STSHI and each STD are preceded by a ushort that indicates their length.
The STSHI structure has the following format:
// STSHI: STyleSHeet Information, as stored in a file
// Note that new fields can be added to the STSHI without invalidating
// the file format, because it is stored preceded by it's length.
// When reading a STSHI from an older version, new fields will be zero.
typedef struct _STSHI
{
ushort cstd; // Count of styles in stylesheet
ushort cbSTDBaseInFile; // Length of STD Base as stored in a file
BF fStdStylenamesWritten : 1; // Are built-in stylenames stored?
BF : 15; // Spare flags
ushort stiMaxWhenSaved; // Max sti known when this file was written
ushort istdMaxFixedWhenSaved; // How many fixed-index istds are there?
ushort nVerBuiltInNamesWhenSaved; // Current version of built-in stylenames
FTC rgftcStandardChpStsh[3]; // ftc used by StandardChpStsh for this document
} STSHI;
The cb preceding the STSHI in the file is the length of the STSHI as stored in the file. The current definition of the STSHI structure might be longer or shorter than that stored in the file, the stylesheet reader routine needs to take this into account.
stshi.cstd: The number of styles in this stylesheet. There will be stshi.cstd (cbSTD, STD) pairs in the file following the STSHI. Note that styles can be empty, i.e. cbSTD == 0.
stshi.cbSTDBaseInFile: The STD structure (see below) is divided into a fixed-length "base", and a variable length part. The stshi.cbSTDBaseInFile indicates the size in bytes of the fixed-length base of the STD as it was written in this file. If the STD base is grown in a future version, the file format doesn't change, because the stylesheet reader can discard parts it doesn't know about, or use defaults if the file's STD is not as large as it was expecting. (Currently, stshi.cbSTDBaseInFile is 8.)
stshi.fStdStylenamesWritten: Previous versions of Word did not store the style name if the style was a built-in style; Word 6.0 does, for compatibility with future versions. Note that the built-in stylenames may need to be "regenerated" if the file is opened in a different language or if stshi.nVerBuiltInNamesWhenSaved doesn't match the expected value.
stshi.stiMaxWhenSaved: This indicates the last built-in style known to the version of Word that saved this file.
stshi.istdMaxFixedWhenSaved: Each array of styles has some fixed-index styles at the beginning. This indicates the number of fixed-index positions reserved in the stylesheet when it was saved.
stshi.nVerBuiltInNamesWhenSaved: Since built-in stylenames are saved with the document, this provides an way to see if the saved names are the same "version" as the names in the version of Word that is loading the file. If not, the built-in stylenames need to be "regenerated", i.e. the old names need to be replaced with the new.
stshi.rgftcStandardChpStsh: This is the default fonts for this stylesheet. The first is for Asci characters (0-127), the second is for Far East characters, and the third is the default font for non-Far East, non-Asci text. See notes on sprmCRgftcX for details.
The style description is stored in an STD structure as follows:
// STD: STyle Definition
// The STD contains the entire definition of a style.
// It has two parts, a fixed-length base (cbSTDBase bytes long)
// and a variable length remainder holding the name, and the upx and upe
// arrays (a upx and upe for each type stored in the style, std.cupx)
// Note that new fields can be added to the BASE of the STD without
// invalidating the file format, because the STSHI contains the length
// that is stored in the file. When reading STDs from an older version,
// new fields will be zero.
typedef struct _STD
{
// Base part of STD:
ushort sti : 12; /* invariant style identifier */
ushort fScratch : 1; /* spare field for any temporary use,
always reset back to zero! */
ushort fInvalHeight : 1; /* PHEs of all text with this style are wrong */
ushort fHasUpe : 1; /* UPEs have been generated */
ushort fMassCopy : 1; /* std has been mass-copied; if unused at
save time, style should be deleted */
ushort sgc : 4; /* style type code */
ushort istdBase : 12; /* base style */
ushort cupx : 4; /* # of UPXs (and UPEs) */
ushort istdNext : 12; /* next style */
ushort bchUpe; /* offset to end of upx's, start of upe's */
ushort fAutoRedef : 1; /* auto redefine style when appropriate */
ushort fHidden : 1; /* hidden from UI? */
ushort : 14; /* unused bits */
// Variable length part of STD:
XCHAR xstzName[2]; /* sub-names are separated by chDelimStyle */
/* char grupx[]; */
/* the UPEs are not stored on the file; they are a cache of the based-on
chain */
/* char grupe[]; */
} STD;
The cb preceding each STD is the length of the data, which includes all of the STD except the grupe array (which is derived after the file is read in, by building each UPE from the base style UPE plus the exceptions in the UPX.) A cb of zero indicates an empty slot in the style array, i.e. no style has that istd. Note that the STD structure may be longer or shorter than the one stored in the file, stshi.cbSTDBaseInFile indicates the length of the base of the STD (up to stzName) as stored in the file. The stylesheet reader routine has to take this into account.
The variable-length part of the STD actually has three variable-length subparts, the xstzName, the grupx, and the grupe. Since this doesn't fit well into a C structure declaration, some processing is needed to figure out where one part stops and the next part begins. An important note is that all variable-length parts and subparts of the STD begin on EVEN-BYTE OFFSETS within the STD, even if the length of the preceding variable-length part was odd.
std.sti: The sti is an identifier which built-in style this is, or stiUser for a user-defined style. An sti is intended to be permanent through versions of Word, although new sti's may be added in new versions. The sti definitions are:
// standard sti codes - these are invariant identifiers for built-in styles // and must remain the same (i.e. don't renumber them, or old files will be // messed up.) // NOTE: sti and istd are the same for Normal and level styles // If you want to define a new built-in style: // 1) Decide if you really need one--it will exist in all future versions! // 2) Add a new sti below. You can take the first available slot. // 3) Change stiMax, and stiPapMax or stiChpMax // 4) Add entry to _dnsti, and the two ids's in strman.pp // 5) Add case in GetDefaultUpdForSti // 6) Change cstiMaxBuiltinDependents if necessary // If you want to change the definition of a built-in style // 1) In order to make WinWord 2 documents that use the style look like // they did in WinWord 2, add a case in GetDefaultUpdForSti to handle // fOldDef. This definition will be used when converting WinWord 2 // stylesheets. // 2) If you change the name of a built-in style, increment nVerBuiltInNames #define stiNormal 0 // 0x0000 #define stiLev1 1 // 0x0001 #define stiLev2 2 // 0x0002 #define stiLev3 3 // 0x0003 #define stiLev4 4 // 0x0004 #define stiLev5 5 // 0x0005 #define stiLev6 6 // 0x0006 #define stiLev7 7 // 0x0007 #define stiLev8 8 // 0x0008 #define stiLev9 9 // 0x0009 #define stiLevFirst stiLev1 #define stiLevLast stiLev9 #define stiIndex1 10 // 0x000A #define stiIndex2 11 // 0x000B #define stiIndex3 12 // 0x000C #define stiIndex4 13 // 0x000D #define stiIndex5 14 // 0x000E #define stiIndex6 15 // 0x000F #define stiIndex7 16 // 0x0010 #define stiIndex8 17 // 0x0011 #define stiIndex9 18 // 0x0012 #define stiIndexFirst stiIndex1 #define stiIndexLast stiIndex9 #define stiToc1 19 // 0x0013 #define stiToc2 20 // 0x0014 #define stiToc3 21 // 0x0015 #define stiToc4 22 // 0x0016 #define stiToc5 23 // 0x0017 #define stiToc6 24 // 0x0018 #define stiToc7 25 // 0x0019 #define stiToc8 26 // 0x001A #define stiToc9 27 // 0x001B #define stiTocFirst stiToc1 #define stiTocLast stiToc9 #define stiNormIndent 28 // 0x001C #define stiFtnText 29 // 0x001D #define stiAtnText 30 // 0x001E #define stiHeader 31 // 0x001F #define stiFooter 32 // 0x0020 #define stiIndexHeading 33 // 0x0021 #define stiCaption 34 // 0x0022 #define stiToCaption 35 // 0x0023 #define stiEnvAddr 36 // 0x0024 #define stiEnvRet 37 // 0x0025 #define stiFtnRef 38 // 0x0026 char style #define stiAtnRef 39 // 0x0027 char style #define stiLnn 40 // 0x0028 char style #define stiPgn 41 // 0x0029 char style #define stiEdnRef 42 // 0x002A char style #define stiEdnText 43 // 0x002B #define stiToa 44 // 0x002C #define stiMacro 45 // 0x002D #define stiToaHeading 46 // 0x002E #define stiList 47 // 0x002F #define stiListBullet 48 // 0x0030 #define stiListNumber 49 // 0x0031 #define stiList2 50 // 0x0032 #define stiList3 51 // 0x0033 #define stiList4 52 // 0x0034 #define stiList5 53 // 0x0035 #define stiListBullet2 54 // 0x0036 #define stiListBullet3 55 // 0x0037 #define stiListBullet4 56 // 0x0038 #define stiListBullet5 57 // 0x0039 #define stiListNumber2 58 // 0x003A #define stiListNumber3 59 // 0x003B #define stiListNumber4 60 // 0x003C #define stiListNumber5 61 // 0x003D #define stiTitle 62 // 0x003E #define stiClosing 63 // 0x003F #define stiSignature 64 // 0x0040 #define stiNormalChar 65 // 0x0041 char style #define stiBodyText 66 // 0x0042 #define stiBodyText2 67 // 0x0043 #define stiListCont 68 // 0x0044 #define stiListCont2 69 // 0x0045 #define stiListCont3 70 // 0x0046 #define stiListCont4 71 // 0x0047 #define stiListCont5 72 // 0x0048 #define stiMsgHeader 73 // 0x0049 #define stiSubtitle 74 // 0x004A #define stiSalutation 75 // 0x004B #define stiDate 76 // 0X004C #define stiBodyText1I 77 // 0x004D #define stiBodyText1I2 78 // 0x004E #define stiNoteHeading 79 // 0x004F #define stiBodyText2 80 // 0x0050 #define stiBodyText3 81 // 0x0051 #define stiBodyTextInd2 82 // 0x0052 #define stiBodyTextInd3 83 // 0x0053 #define stiBlockQuote 84 // 0x0054 #define stiHyperlink 85 // 0x0055 char style #define stiHyperlinkFollowed 86 // 0x0056 char style #define stiStrong 87 // 0x0057 char style #define stiEmphasis 88 // 0x0058 char style #define stiNavPane 89 // 0x0059 char style #define stiPlainText 90 // 0x005A #define stiMax 91 // number of defined sti's #define stiUser 0x0ffe // user styles are distinguished by name #define stiNil 0x0fff // max for 12 bits
See below for the names of these styles.
std.stc: The type of each style is indicated by std.sgc. The two types currently in use are:
More style types may exist in the future, so styles of an unknown type should be discarded.
std.istdBase: The style that this style is based on. A style is always based on another style or the null style (istdNil). Following a "chain" of based-on styles will always end at the null style, because a based-on chain cannot have a loop in it. A style can have up to 11 "ancestors" in its based-on chain, including the null style. A style's definition is built up from the style that it is based on. See std.cupx, std.grupx, std.grupe.
std.istdNext: The style that should be applied after this one. For a paragraph style, this is the style that is applied when Enter is pressed at the end of a paragraph. For a character style, the next style is essentially ignored, but should be the same as the current style.
std.xstzName: The name of the style, including aliases. The name is stored as an xstz (preceded by a length byte, followed by a null-terminator.) A style name can contain multiple "aliases", separated by commas. Aliases are alternate names for the same style (e.g. a style named "a,b,c" has three aliases, and can be referred to by "a", "b", or "c", or any combination.) WinWord 2.x did not have aliases, but MacWord 5.x did. If a style is a built-in style, the built-in stylename is always stored first.
All names (and aliases) must be unique within a stylesheet (e.g. styles "a,b" and "b,c" should not exist in the same stylesheet, as "b" matches multiple stylenames.)
A stylename (including all its aliases and comma separators) can be up to 253 characters long. So the xstz format of that name can be up to 255 characters. Stylenames are case sensitive.
The built-in stylenames (corresponding to each sti above) are defined for each language version of Word. For the USA, the names are:
// These are the names of the built-in styles as we want to present them // to the user. Normal Heading 1 Heading 2 Heading 3 Heading 4 Heading 5 Heading 6 Heading 7 Heading 8 Heading 9 Index 1 Index 2 Index 3 Index 4 Index 5 Index 6 Index 7 Index 8 Index 9 TOC 1 TOC 2 TOC 3 TOC 4 TOC 5 TOC 6 TOC 7 TOC 8 TOC 9 Normal Indent Footnote Text Annotation Text Header Footer Index Heading Caption Table of Figures Envelope Address Envelope Return Footnote Reference Annotation Reference Line Number Page Number Endnote Reference Endnote Text Table of Authorities Macro Text TOA Heading List List 2 List 3 List 4 List 5 List Bullet List Bullet 2 List Bullet 3 List Bullet 4 List Bullet 5 List Number List Number 2 List Number 3 List Number 4 List Number 5 Title Closing Signature Default Paragraph Font Body Text Body Text Indent List Continue List Continue 2 List Continue 3 List Continue 4 List Continue 5 Message Header Subtitle Salutation Date Body Text First Indent Body Text First Indent 2 Note Heading Body Text 2 Body Text 3 Body Text Indent 2 Body Text Indent 3 Block Text Hyperlink Followed Hyperlink Strong Emphasis Document Map Plain Text
std.cupx: This is the number of UPXs in the std.grupx array. See below.
std.grupx: This is an array of variable-length UPXs, with std.cupx UPXs in the array. This array begins after the variable-length xstzName field, at the next even-byte offset within the STD. A UPX (Universal Property eXception) describes the difference in formatting of this style as compared to its based-on style. The UPX structure looks like this:
typedef union _UPX
{
struct
{
uchar grpprl[cbMaxGrpprlStyleChpx];
} chpx;
struct
{
ushort istd;
uchar grpprl[cbMaxGrpprlStylePapx];
} papx;
uchar rgb[1];
} UPX;
Each UPX stored in a file is not a complete UPX, rather it is a UPX with all trailing zero bytes lopped off, and preceded by a ushort length field. So it is stored like:
Each UPX begins on an even-byte offset within the STD, even if the length of the previous UPX (cbUPX) was odd.
The meaning of each UPX depends on the style type (std.sgc). For a paragraph style, std.cupx is 2. The first UPX is a paragraph UPX (UPX.papx) and the second UPX is a character UPX (UPX.chpx). For a character style, std.cupx is 1, and that UPX is a character UPX (UPX.chpx). Note that new UPXs may be added in the future, so std.cupx might be larger than expected. Any UPXs past those expected should be discarded.
The grpprl within each UPX contains the differences of this property type for this style from the UPE of that property type for the based on style. For example, if two paragraph styles, A and B, were identical except that B was bold where A was not, and B was based on A, B would have two UPXs, where the paragraph UPX would have an empty grpprl, and the character UPX would have a bold sprm in the grpprl. Thus B looks just like A (since B is based on A), with the exception that B is bold.
std.grupe: This is an array (group) of variable-length UPEs. These are not stored in the file! Rather, they are constructed using the std.istdBase and std.grupx fields. A UPE (Universal Property Expansion) describes the "end-result" of the property formatting, i.e. what the style looks like. The UPE structure is the non-zero prefix of a UPD structure. The UPD structure looks like this:
typedef union _UPD
{
PAP pap;
CHP chp;
struct
{
ushort istd;
uchar cbGrpprl;
uchar grpprl[cbMaxGrpprlStyleChpx];
} chpx;
} UPD;
The std.grupe and std.grupx arrays are similar: there is one UPE for each UPX, and internally they are stored similarly (a length ushort followed by a non-zero prefix), though remember that the UPEs are not stored in the file. The meaning of each UPE depends on the style type (std.sgc). For a paragraph style, the first UPE is a PAP (UPE.pap). The second UPE is a CHP (UPE.chp). For a character style, the first UPE is a CHPX (UPE.chpx).
The UPEs for a style are constructed by taking the UPEs from the based-on style, and applying the UPXs to them. Obviously, if the UPEs for the based-on style haven't yet been constructed, that style's UPE needs to be constructed first. Eventually by following the based-on chain, a style will be based on the null style (istdNil). The UPEs for the null style are predefined:
So, for a paragraph style, the first UPE is a UPE.pap. It can be constructed by starting the with first UPE from the based-on style (std.istdBase), and then applying the first UPX (UPX.papx) in std.grupx to that UPE. To apply a UPX.papx to a UPE.pap, set UPE.pap.istd equal to UPX.papx.istd, and then apply the UPX.papx.grpprl to UPE.pap. Similarly, the second UPE is a UPE.chp. It can be constructed by starting with the second UPE from the based-on style, and then applying the second UPX (UPX.chpx) in std.grupx to that UPE. To apply a UPX.chpx to a UPE.chp, apply the UPX.chpx.grpprl to UPE.chp. Note that a UPE.chp for a paragraph style should always have UPE.chp.istd == istdNormalChar.
For a character style, the first (and only) UPE (a UPE.chpx) can be constructed by starting with the first UPE from the based-on style (std.istdBase), and then applying the first UPX (UPX.chpx) in std.grupx to that UPE. To apply a UPX.chpx to a UPE.chpx, take the grpprl in UPE.chpx.grpprl (which has a length of UPE.chpx.cbGrpprl) and merge the grpprl in UPX.chpx.grpprl into it. Merging grpprls is a tricky business, but for character styles it is easy because no prls in character style grpprls should interact with each other. Each prl from the source (the UPX.chpx.grpprl) should be inserted into the destination (the UPE.chpx.grpprl) so that the sprm of each prl is in increasing order, and any prls that have the same sprm are replaced by the prl in the source. UPE.chpx.cbGrpprl is then set to the length of resulting grpprl, and UPE.chpx.istd is set to the style's istd.
Word 97 stores its paragraph numbering information very differently from Word 6.0. In Word 6.0, all information for a paragraph was stored in that paragraph's pap.anld. In Word 97, the pap only contains two values: a short ilfo and a byte ilvl, which indicate which list the paragraph belongs to and which level of that list it should be, respectively. The ilfo is actually an index into one of the the document's list tables: the pllfo, and the paragraph gets most of its information about appearance from the list tables.
There are three list tables in a word document: the rglst, the hpllfo, and the hsttbListNames. They will be described below in greater detail, and the precise formats of several of these structures (the LSTF, LVLF, LFO, and LFOLVL) are listed in the appendix.
The LST structure is where most of the list appearance data is stored. An LST consists of two main parts: (1) an LSTF, which is stored on disk and contains formatting properties which apply to the entire list, such as whether the list is simple or multilevel, the list's unique list index and template code, the istd's (see Stylesheet above) of the styles (if any) that each level in the list is linked to, and a number of Word 6 compatilibity option; (2) an array of LVL structures, which describe the appearance of each individual level in the LST.
A LVL structure contains two parts to it: (1) an LVLF, which stores all static data such as the start-at value for the list level, the numbering type (arabic or roman), the alignment (left, right or centered) of the number, and several Word 6.0 compatibility options; and (2) a set of pointers to variable length data: (a) a grpprlChpx, which gives character formatting to the paragraph number text itself, (b) a grpprlPapx, which gives paragraph formatting to the paragraph containing the number, such as indenting and tab information, and (c) the number text itself.
Word writes out the rglst as the plcflst by writing out, first, a short integer containing the number of LST structures to be written. It then enumerates through the rglst, writing out each LSTF structure. It then enumerates through the rglst again, deciding, for each LST, whether it has one level (LSTF.fSimpleList) or nine levels (!LSTF.fSimpleList). It then writes the appropriate number of LVL structures as described below.
When Word writes out an LVL structure, it first writes out the LVLF, followed by the grpprlPapx (of LVLF.cbGrpprlPapx bytes in length), followed by the grpprlChpx (of length LVLF.cbGrpprlChpx), and an XCHAR string with the number text, preceded by an XCHAR containing the string's length.
The string table containing the List Names is by far the least significant of the three list tables. Most lists do not have names, and the names are only useful to users of the macro language. If this list has a name, however, it will be in this table: the table is a parallel array with the rglst above, and will contain an empty string for any list which does not have a list name.
The LFO structure serves primarily as a level of indirection between the paragraph and the LST, but also can be used to override certain features of the list formats (LFO stands for List Format Override). An LFO consists of two main parts: (1) the List ID of the list (LST record) to which this LFO belongs, and an array of overrides to the formatting in that LST. For the vast majority of LFOs, there are no overrides, but if there are any, they reside in an array of LFOLVL structures -- one LFOLVL per level of the LST to be overridden. An LFOLVL contains a set of flags to indicate whether just the start-at value of the LST is overridden, or whether just the formatting is overrridden, or both, as well as either a start-at value or a pointer to a LVL record, depending upon the values of the flags. Note that if the LFOLVL says the start-at value should be overridden, what that means is that the FIRST paragraph in the document with this LFO should have a number equal exactly to that start-at value, but any subsequent paragraphs should just follow the previous paragraph in the sequence. Also, if LFOLVL.fFormatting and LFOLVL.fStartAt are both true (rare) then LFOLVL.iStartAt should be ignored in favor of the iStartAt value from the corresponding LVL.
Word writes out the pllfo first by writing out a PL of LFO structures. It then enumerates through each LFO to figure out how many LFOLVLs each one has (LFO.clfolvl), and writes out, in order, each LFOLVL structure followed by its corresponding LVL structure (if LFOLVL.fFormatting is set).
Given a paragraph and its corresponding PAP, the following process must be followed to find out the paragraph's list information:
A sprm is an instruction to modify one or more properties within one of the property defining data structures (CHP, PAP, TAP, SEP, or PIC). A sprm is a two-byte opcode at offset 0 which identifies the operation to be performed. If necessary information for the operation can always be expressed with a fixed length parameter, the fixed length parameter is recorded immediately after the opcode beginning at offset 2. The length of a fixed length sprm is always 2 plus the size of the sprm's parameter. If the parameter for the sprm is variable length, the count of bytes of the following parameter is stored in the byte at offset 2, followed by the parameter at offset 3.
Three sprms -- sprmPChgTabs , sprmTDefTable, and sprmTDefTable10 -- can be longer than 256 bytes. The method for calculating the length of sprmPChgTabs is recorded below with the description of the sprm. For sprmTDefTable and sprmTDefTable10, the length of the parameter plus 1 is recorded in the two bytes beginning at offset 2.
For all other variable length sprms, the total length of the sprm is the count recorded at offset 2 plus three (2 for the sprm + 1 for the count byte). The parameter immediately follows the count.
The sprm value encodes information on the size of the operand, the type of sprm (PAP, CHP, etc), and whether the sprm requires special handling (in cases where a property value isn't simply replaced).
When parsing a grpprl, you can use the sprm's spra value to determine how many bytes are used by that sprm; it also enables you to skip over sprms you don't handle.
Unless otherwise noted, when a sprm is applied to a property the sprm's parameter changes the old value of the property in question to the value stored in the sprm parameter.
sprmPIstdPermute (opcode 0xC601) is a complex sprm which is applied to a piece when the style codes of paragraphs within a piece must be mapped to other style codes. It has the following format:
To interpret sprmPIstdPermute, first check if pap.istd is greater than the istdFirst recorded in the sprm and less than or equal to the istdLast recorded in the sprm If not, the sprm has no effect. If it is, pap.istd is set to rgistd[pap.istd - istdFirst]. sprmPIstdPermute is only stored in grpprls linked to a piece table. It should never be recorded in a PAPX.
sprmPIncLvl (opcode 0x2602) is applied to pieces in the piece table that contain paragraphs with style codes (istds) greater than or equal to 1 and less than or equal to 9. These style codes identify heading levels in a Word outline structure. The sprm causes a set of paragraphs to be changed to a new heading level. The sprm is three bytes long and consists of the sprm code and a one byte two's complement value.
If pap.stc is < 1 or > 9, sprmPIncLvl has no effect. Otherwise, if the value stored in the byte has its highest order bit off, the value is a positive difference which should be added to pap.istd and pap.lvl and then pap.stc should be set to min(pap.istd, 9). If the byte value has its highest order bit on, the value is a negative difference which should be sign extended to a word and then subtracted from pap.istd and pap.lvl. Then pap.stc should be set to max(1, pap.istd). sprmPIncLvl is only stored in grpprls linked to a piece table.
sprmPIlfo (opcode 0x460B) sets the pap.ilfo. Its argument, an ilfo, is an index into the document's hpllfo, which contains the list data for that paragraph, describing the appearance of the automatic number at the beginning of the paragraph. A value of zero means that the paragraph is not numbered, and a value of 2047 indicates that this paragraph came from a pre-Word 97 file so the formatting information is still stored in the pap.anld and the paragraph should be converted to Word 97 format.
sprmPIlvl (opcode (0x260A) sets the pap.ilvl. It takes an index (0 through 8) which indicates which level of a multilevel list this paragraph belongs to. For simple (one-level lists) or unnumbered paragraphs, this value should always be zero.
sprmPAnld (opcode ...) is currently only used for compatibility with pre-Word 97 docs. It sets the pap.anld, which before Word 97 described the automatic number at the beginning of any numbered paragraph. Now we use it only long enough to put the data into the document's list table (rglst) and set the pap.ilfo to point to the proper entry in the list table. The pap.anld is only relavent if pap.ilfo is equal to 2047 (see sprmPIlfo above).
The sprmPChgTabsPapx (opcode 0xC60D) is a complex sprm that describes changes in tab settings from the underlying style. It is only stored as part of PAPXs stored in FKPs and in the STSH. It has the following format:
When sprmPChgTabsPapx is interpreted, the rgdxaDel of the sprm is applied first to the pap that is being transformed. This is done by deleting from the pap the rgdxaTab entry and rgtbd entry of any tab whose rgdxaTab value is equal to one of the rgdxaDel values in the sprm. It is guaranteed that the entries in pap.rgdxaTab and the sprm's rgdxaDel and rgdxaAdd are recorded in ascending dxa order.
Then the rgdxaAdd and rgtbdAdd entries are merged into the pap's rgdxaTab and rgtbd arrays so that the resulting pap rgdxaTab is sorted in ascending order with no duplicates.
sprmPNest (opcode 0x4610) causes its operand, a two-byte dxa value to be added to pap.dxaLeft. If the result of the addition is less than 0, 0 is stored into pap.dxaLeft. It is used to shift the left indent of a paragraph to the right or left. sprmPNest is only stored in grpprls linked to a piece table.
sprmPDyaLine (opcode 0x6412) moves a 4 byte LSPD structure into pap.lspd. Two short fields are stored in this data structure. The first short in the structure is named lspd.dyaLine and the second is named lspd.fMultLinespace. When lspd.fMultLinespace is 0, the magnitude of lspd.dyaLine specifies the amount of space that will be provided for lines in the paragraph in twips. When lspd.dyaLine is positive, Word will ensure that AT LEAST the magnitude of lspd.dyaLine will be reserved on the page for each line displayed in the paragraph. If the height of a line becomes greater than lspd.dyaLine, the size calculated for that line will be reserved on the page. When lspd.dyaLine is negative, Word will ensure that EXACTLY the magnitude of lspd.dyaLine (-lspd.dyaLine) will be reserved on the page for each line displayed in the paragraph. When lspd.fMultLinespace is 1, Word will reserve for each line the (maximal height of the line*lspd.dyaLine)/240.
The sprmPChgTabs (opcode 0xC615) is a complex sprm which describes changes tab settings for any paragraph within a piece. It is only stored as part of a grpprl linked to a piece table. It has the following format:
itbdDelMax and itbdAddMax are defined to be equal to 50. This means that the largest possible instance of sprmPChgTabs is 354. When the length of the sprm is greater than or equal to 255, the cch field will be set equal to 255. When cch == 255, the actual length of the sprm can be calculated as follows: length = 2 + itbdDelMax * 4 + itbdAddMax * 3.
When sprmPChgTabs is interpreted, the rgdxaDel of the sprm is applied first to the pap that is being transformed. This is done by deleting from the pap the rgdxaTab entry and rgtbd entry of any tab whose rgdxaTab value is within the interval [rgdxaDel[i] - rgdxaClose[i], rgdxaDel[i] + rgdxaClose[i]] It is guaranteed that the entries in pap.rgdxaTab and the sprm's rgdxaDel and rgdxaAdd are recorded in ascending dxa order.
Then the rgdxaAdd and rgtbdAdd entries are merged into the pap's rgdxaTab and rgtbd arrays so that the resulting pap rgdxaTab is sorted in ascending order with no duplicates.
The sprmPPc (opcode 0x261B) is a complex sprm which describes changes in the pap.pcHorz and pap.pcVert. It is able to change both fields' contents in parallel. It has the following format:
Length of sprmPPc is three bytes.
sprmPPc is interpreted by moving pcVert to pap.pcVert if pcVert != 3 and by moving pcHorz to pap.pcHorz if pcHorz != 3. sprmPPc is stored in PAPX FKPs and also in grpprls linked to piece table entries.
sprmPPropRMark (opcode 0xC63F) is interpreted by moving the first parameter byte to pap.fPropRMark, the next two bytes to pap.ibstPropRMark, and the remaining four bytes to pap.dttmPropRMark.
sprmPHugePapx is stored in PAPX FKPs in place of the grpprl of a PAPX which would otherwise be too big to fit in an FKP (as of this writing, 488 bytes is the size of the largest PAPX which can fit in an FKP). The parameter fc gives the location of the grpprl in the data stream. The first word at that fc counts the number of bytes in the grpprl (not including the byte count itself). A sprmPHugePapx should therefore only be found in a PAPX FKP and should be the only sprm in that PAPX's grpprl.
sprmCPicLocation (opcode 0x6A03) is used ONLY IN CHPX FKPs. This sprm moves the 4-byte operand of the sprm into the chp.fcPic field. It simultaneously sets chp.fSpec to 1. This sprm is also when the chp.lTagObj field that is unioned with chp.fcPic is to be set for OLE objects.
sprmCChs (opcode 0xEA08) is used to record a character set id for text that was pasted into the Word document that used a character set different than Word's default character set. When chp.fChsDiff is 0, the character set used for a run of text is the default character set for the version of Word that last saved the document. When chp.fChsDiff is 1, chp.chse specifies the character set used for this run of text. This sprm's operand is 3 bytes. When this sprm is interpreted, the first byte of the operand is moved to chp.fChsDiff and the remaining word is moved to chp.chse.
sprmCSymbol (opcode 0x6A09) is used to specify the font and the character that will be used within that font to display a symbol character in Word. This sprm's operand is 4 bytes. The first 2 hold the font code; the last 2 hold a character specifier. When this sprm is interpreted, the font code is moved to chp.ftcSym and the character specifier is moved to chp.xchSym and chp.fSpec is set to 1.
sprmCIstdPermute (opcode 0xCA31) (which has the same format as sprmPIstdPermute (opcode 0xC601)) is a complex sprm which is applied to a piece when the style codes for character styles tagging character runs within a piece must be mapped to other style codes. It has the following format:
To interpret sprmCIstdPermute, first check if chp.istd is greater than the istdFirst recorded in the sprm and less than or equal to the istdLast recorded in the sprm If not, the sprm has no effect. If it is, chp.istd is set to rgstd[chp.istd - istdFirst] and any chpx stored in that rgstd entry is applied to the chp. sprmCIstdPermute is only stored in grpprls linked to a piece table. It should never be recorded in a CHPX.
Note that it is possible that an istd may be recorded in the rgistd that refers to a paragraph style. This will no harmful consequences since the istd for a paragraph style should never be recorded in chp.istd.
sprmCDefault (opcode 0x2A32) clears the fBold, fItalic, fOutline, fStrike, fShadow, fSmallCaps, fCaps, fVanish, kul and ico fields of the chp to 0. It was first defined for Word 3.01 and had to be backward compatible with Word 3.00 so it is a variable length sprm whose count of bytes is 0. It consists of the sprmCDefault opcode followed by a byte of 0. sprmCDefault is stored only in grpprls linked to piece table entries.
sprmCPlain (opcode 0x2A33) is used to make the character properties of runs of text equal to the style character properties of the paragraph that contains the text. When Word interprets this sprm, the style sheet CHP is copied over the original CHP preserving the fSpec setting from the original CHP. sprmCPlain is stored only in grpprls linked to piece table entries.
sprms 0x0835 through 0x083C (sprmCFBold through sprmCFVanish) set single bit properties in the CHP. When the parameter of the sprm is set to 0 or 1, then the CHP property is set to the parameter value.
When the parameter of the sprm is 128, then the CHP property is set to the value that is stored for the property in the style sheet. CHP When the parameter of the sprm is 129, the CHP property is set to the negation of the value that is stored for the property in the style sheet CHP. sprmCFBold through sprmCFVanish are stored only in grpprls linked to piece table entries.
sprmCSizePos (opcode 0xEA3F) is a five-byte sprm consisting of the sprm opcode and a three byte parameter. The sprm has the following format:
When Word interprets this sprm, if hpsSize != 0 then chp.hps is set to hpsSize. If cInc is != 0, the cInc is interpreted as a 7 bit twos complement number and the procedure described below for interpreting sprmCHpsInc is followed to increase or decrease the chp.hps by the specified number of levels. If hpsPos is != 128, then chp.hpsPos is set equal to hpsPos. If fAdjust is on , hpsPos != 128 and hpsPos != 0 and the previous value of chp.hpsPos == 0, then chp.hps is reduced by one level following the method described for sprmCHpsInc. If fAdjust is on, hpsPos == 0 and the previous value of chp.hpsPos != 0, then the chp.hps value is increased by one level using the method described below for sprmCHpsInc.
sprmCHpsInc(opcode 0x2A44) is a three-byte sprm consisting of the sprm opcode and a one-byte parameter. Word keeps an ordered array of the font sizes that are defined for the fonts recorded in the system file with each font size transformed into an hps. The parameter is a one-byte twos complement number. Word uses this number to calculate an index in the font size array to determine the new hps for a run. When Word interprets this sprm and the parameter is positive, it searches the array of font sizes to find the index of the smallest entry in the font size table that is greater than the current chp.hps.It then adds the parameter minus 1 to the index and maxes this with the index of the last array entry. It uses the result as an index into the font size array and assigns that entry of the array to chp.hps.
When the parameter is negative, Word searches the array of font sizes to find the index of the entry that is less than or equal to the current chp.hps. It then adds the negative parameter to the index and does a min of the result with 0. The result of the min function is used as an index into the font size array and that entry of the array is assigned to chp.hps. sprmCHpsInc is stored only in grpprls linked to piece table entries.
sprmCHpsPosAdj (opcode 0x2A46) causes the hps of a run to be reduced the first time text is superscripted or subscripted and causes the hps of a run to be increased when superscripting/subscripting is removed from a run. The one byte parameter of this sprm is the new hpsPos value that is to be stored in chp.hpsPos. If the new hpsPos is not equal 0 (meaning that the text is to be super/subscripted), Word first examines the current value of chp.hpsPos to see if it is equal to 0. If so, Word uses the algorithm described for sprmCHpsInc to decrease chp.hps by one level. If the new hpsPos == 0 (meaning the text is not super/subscripted), Word examines the current chp.hpsPos to see if it is not equal to 0. If it is not (which means text is being restored to normal position), Word uses the sprmCHpsInc algorithm to increase chp.hps by one level. After chp.hps is adjusted, the parameter value is stored in chp.hpsPos. sprmCHpsPosAdj is stored only in grpprls linked to piece table entries.
The parameter of sprmCMajority (opcode 0xCA47) is itself a list of character sprms which encodes a criterion under which certain fields of the chp are to be set equal to the values stored in a style's CHP. Bytes 0 and 1 of sprmCMajority contains the opcode, byte 2 contains the length of the following list of character sprms. . Word begins interpretation of this sprm by applying the stored character sprm list to a standard chp. That chp has chp.istd = istdNormalChar. chp.hps=20, chp.lid=0x0400 and chp.ftc = 4. Word then compares fBold, fItalic, fStrike, fOutline, fShadow, fSmallCaps, fCaps, ftc, hps, hpsPos, kul, qpsSpace and ico in the original CHP with the values recorded for these fields in the generated CHP.. If a field in the original CHP has the same value as the field stored in the generated CHP, then that field is reset to the value stored in the style's CHP. If the two copies differ, then the original CHP value is left unchanged. sprmCMajority is stored only in grpprls linked to piece table entries.
sprmCHpsInc1 (opcode 0xCA4A) is used to increase or decrease chp.hps by increments of 1. This sprm is interpreted by adding the two byte increment stored as the opcode of the sprm to chp.hps. If this result is less than 8, the chp.hps is set to 8. If the result is greater than 32766, the chp.hps is set to 32766.
sprmCMajority50 (opcode 0xCA4C) has the same format as sprmCMajority and is interpreted in the same way.
sprmCPropRMark (opcode 0xCA57) is interpreted by moving the first parameter byte to chp.fPropRMark, the next two bytes to chp.ibstPropRMark, and the remaining four bytes to chp.dttmPropRMark.
sprmCDispFldRMark (opcode 0xCA62) is interpreted by moving the first parameter byte to chp.fDispFldRMark, the next two bytes to chp.ibstDispFldRMark, the next four bytes to chp.dttmDispFldRMark, and the remaining 32 bytes to chp.xstDispFldRMark.
sprmCRgftc0 (opcode 0x4A4F), sprmcCRgftc1(opcode 0x4A50), and sprmCRgftc2 (opcode 0x4A4F) are used to specify the fonts that are available for use with text. Rgftc0 specifies the font used for characters from U+0000 -> U+007F. Rgftc1 specifies the font to be used for Far East characters, and Rgftc2 specifies the font to be used for all other text. See appendix C for details on how the font is calculated.
sprmCRglid0 (opcode 0x486D) and sprmCRglid1 (opcode 0x486E) are used to specify the languages that are available for use with the text in this run. sprmCRglid1 specifies the language for Far East text, sprmCRglid0 specifies the language for all other text. See Appendix C for details on the language is calculated.
sprmCIdctHint (opcode 0x286F) specifies a script bias for the text in the run. For Unicode characters that are shared between Far East and non-Far East scripts, this property determines what font and language the character will use. When this value is 0, text properties bias towards non-Far East properties. When this value is 1, text properties bias towards Far East properties. See Appendix C for details on the calculation of font and language properties.
sprmPicScale (opcode 0xCE01) is used to scale the x and y dimensions of a Word picture and to set the cropping for each side of the picture. The sprm begins with the two-byte opcode, followed by the length of the parameter (always 12) stored in a byte. The 12-byte long operand consists of an array of 6 two-byte integer fields. The 0th integer contains the new setting for pic.mx. The 1st integer contains the new setting for pic.my. The 2nd integer contains the new setting for pic.dxaCropLeft. The 3rd integer contains the new setting for pic.dyaCropTop. The 4th integer contains the new setting for pic.dxaCropRight. The 5th integer contains the new setting of pic.dxaCropBottom. sprmPicScale is stored only in grpprls linked to piece table entries.
sprmSPropRMark (opcode 0xD227) is interpreted by moving the first parameter byte to sep.fPropRMark, the next two bytes to sep.ibstPropRMark, and the remaining four bytes to sep.dttmPropRMark.
sprmSTextFlow (opcode 0x5033) represents the textflow to be applied to this section. Possible values are:
sprmTDxaLeft (opcode 0x9601) is called to adjust the x position within a column which marks the left boundary of text within the first cell of a table row. This sprm causes a whole table row to be shifted left or right within its column leaving the horizontal width and vertical height of cells in the row unchanged. Bytes 0-1 of the sprm contains the opcode, and the new dxa position, call it dxaNew, is stored as an integer in bytes 2 and 3. Word interprets this sprm by addingdxaNew - (rgdxaCenter[0] + tap.dxaGapHalf) to every entry of tap.rgdxaCenter whose index is less than tap.itcMac. sprmTDxaLeft is stored only in grpprls linked to piece table entries.
sprmTDxaGapHalf (opcode 0x9602) adjusts the white space that is maintained between columns by changing tap.dxaGapHalf. Because we want the left boundary of text within the leftmost cell to be at the same location after the sprm is applied, Word also adjusts tap.rgdxCenter[0] by the amount that tap.dxaGapHalf changes. Bytes 0-1 of the sprm contains the opcode, and the new dxaGapHalf, call it dxaGapHalfNew, is stored in bytes 2 and 3. When the sprm is interpreted, the change between the old and new dxaGapHalf values, tap.dxaGapHalf - dxaGapHalfNew, is added to tap.rgdxaCenter[0] and then dxaGapHalfNew is moved to tap.dxaGapHalf. sprmTDxaGapHalf is stored in PAPXs and also in grpprls linked to piece table entries.
sprmTTableBorders (opcode 0xD605) sets the tap.rgbrcTable. The sprm is interpreted by moving the 24 bytes of the sprm's operand to tap.rgbrcTable.
sprmTDefTable10 (opcode0xD606) is an obsolete version of sprmTDefTable (opcode 0xD608) that was used in WinWord 1.x. Its contents are identical to those in sprmTDefTable, except that the TC structures contain the obsolete structures BRC10s.
sprmTDefTable (opcode 0xD608) defines the boundaries of table cells (tap.rgdxaCenter) and the properties of each cell in a table (tap.rgtc). Bytes 0 and 1 of the sprm contain its opcode. Bytes 2 and 3 store a two-byte length of the following parameter. Byte 4 contains the number of cells that are to be defined by the sprm, call it itcMac. When the sprm is interpreted, itcMac is moved to tap.itcMac. itcMac cannot be larger than 32. In bytes 5 through 5+2*(itcMac + 1) -1 , is stored an array of integer dxa values sorted in ascending order which will be moved to tap.rgdxaCenter. In bytes 5+ 2*(itcMac + 1) through byte 5+2*(itcMac + 1) + 10*itcMac - 1 is stored an array of TC entries corresponding to the stored tap.rgdxaCenter. This array is moved to tap.rgtc. sprmTDefTable is only stored in PAPXs.
sprmTDefTableShd (opcode 0xD609) is similar to sprmTDefTable, and compliments it by defining the shading of each cell in a table (tap.rgshd). Bytes 0 and 1 of the sprm contain its opcode. Bytes 2 and 3 store a two-byte length of the following parameter. Byte 4 contains the number of cells that are to be defined by the sprm, call it itcMac. itcMac cannot be larger than 32. In bytes 5 through 5+2*(itcMac + 1) -1 , is stored an array of SHDs. This array is moved to tap.rgshd. sprmTDefTable is only stored in PAPXs.
sprmTSetBrc (opcode 0xD620) allows the border definitions(BRCs) within TCs to be set to new values. It has the following format:
This sprm changes the brc fields selected by the fChange* flags in the sprm to the brc value stored in the sprm, for every tap.rgtc entry whose index is greater than or equal to itcFirst and less than itcLim.sprmTSetBrc is stored only in grpprls linked to piece table entries.
sprmTInsert (opcode 0x7621) inserts new cell definitions in an existing table's cell structure. Bytes 0 and 1 of the sprm contain the opcode. Byte 2 is the index within tap.rgdxaCenter and tap.rgtc at which the new dxaCenter and tc values will be inserted. Call this index itcInsert. Byte 3 contains a count of the cell definitions to be added to the tap, call it ctc. Bytes 4 and 5 contain the width of the cells that will be added, call it dxaCol. If there are already cells defined at the index where cells are to be inserted, tap.rgdxaCenter entries at or above this index must be moved to the entry ctc higher and must be adjusted by adding ctc*dxaCol to the value stored. The contents of tap.rgtc at or above the index must be moved 10*ctc bytes higher in tap.rgtc. If itcInsert is greater than the original tap.itcMac, itcInsert - tap.ctc columns beginning with index tap.itcMac must be added of width dxaCol (loop from itcMac to itcMac+itcInsert-tap.ctc adding dxaCol to the rgdxaCenter value of the previous entry and storing sum as dxaCenter of new entry), whose TC entries are cleared to zeros. Beginning with index itcInsert, ctc columns of width dxaCol must be added by constructing new tap.rgdxaCenter and tap.rgtc entries with the newly defined rgtc entries cleared to zeros. Finally, the number of cells that were added to the tap is added to tap.itcMac. sprmTInsert is stored only in grpprls linked to piece table entries.
sprmTDelete (opcode 0x5622) deletes cell definitions from an existing table's cell structure. Bytes 0 and 1of the sprm contain the opcode. Byte 2 contains the index of the first cell to delete, call it itcFirst. Byte 3 contains the index of the cell that follows the last cell to be deleted, call it itcLim. sprmTDelete causes any rgdxaCenter and rgtc entries whose index is greater than or equal to itcLim to be moved to the entry that is itcLim - itcFirst lower, and causes tap.itcMac to be decreased by the number of cells deleted. sprmTDelete is stored only in grpprls linked to piece table entries.
sprmTDxaCol (opcode 0x7623) changes the width of cells whose index is within a certain range to be a certain value. Bytes 0 and 1of the sprm contain the opcode. Byte 2 contains the index of the first cell whose width is to be changed, call it itcFirst. Byte 3 contains the index of the cell that follows the last cell whose width is to be changed, call it itcLim. Bytes 4 and 5 contain the new width of the cell, call it dxaCol. This sprm causes the itcLim - itcFirst entries of tap.rgdxaCenter to be adjusted so that tap.rgdxaCenter[i+1] = tap.rgdxaCenter[i] + dxaCol. Any tap.rgdxaCenter entries that exist beyond itcLim are adjusted to take into account the amount added to or removed from the previous columns.sprmTDxaCol is stored only in grpprls linked to piece table entries.
sprmTMerge (opcode 0x5624) merges the display areas of cells within a specified range. Bytes 0 and 1 of the sprm contain the opcode. Byte 2 contains the index of the first cell that is to be merged, call it itcFirst. Byte 3 contains the index of the cell that follows the last cell to be merged, call it itcLim. This sprm causes tap.rgtc[itcFirst].fFirstMerged to be set to 1. Cells in the range whose index is greater than itcFirst and less than itcLim have tap.rgtc[].fMerged set to 1. sprmTMerge is stored only in grpprls linked to piece table entries.
sprmTSplit (opcode 0x5625) splits the display areas of merged cells into their originally assigned display areas. Bytes 0 and 1 of the sprm contain the opcode. Byte 2 contains the index of the first cell that is to be split, call it itcFirst. Byte 3 contains the index of the cell that follows the last cell to be split, call it itcLim. This sprm clears tap.rgtc[].fFirstMerged and tap.rgtc[].fMerged for all rgtc entries >= itcFirst and < itcLim. sprmTSplit is stored only in grpprls linked to piece table entries.
SprmTSetBrc10 (opcode 0xD626) has the same format as SprmTSetBrc but uses the old BRC10 structure.
sprmTSetShd (opcode 0x7627) allows the shading definitions(SHDs) within a tap to be set to new values. Bytes 0 and 1 of the sprm contain the opcode. Byte 2 contains the index of the first cell whose shading is to be changed, call it itcFirst. Byte 3 contains the index of the cell that follows the last cell whose shading is to be changed, call it itcLim. Bytes 4 and 5 contain the SHD structure, call it shd. This sprm causes the itcLim - itcFirst entries of tap.rgshd to be set to shd. sprmTSetShd is stored only in grpprls linked to piece table entries.
sprmTSetShdOdd (opcode 0x7628) is identical to sprmTSetShd, but it only changes the rgshd for odd indices between itcFirst and. sprmTSetShdOdd is stored only in grpprls linked to piece table entries.
sprmTVertMerge (opcode 0xD62B) changes the vertical cell merge properties for a cell in the tap.rgtc[]. Bytes 0 and 1 of the sprm contain the opcode. Byte 2 contains the index of the cell whose vertical cell merge properties are to be changed. Byte 3 codes the new vertical cell merge properties for the cell, a 0 clears both fVertMerge and fVertRestart, a 1 sets fVertMerge and clears fVertRestart, and a 3 sets both flags. sprmTVertMerge is stored only in grpprls linked to piece table entries.
sprmTVertAlign (opcode 0xD62C) changes the vertical alignment property in the tap.rgtc[]. Bytes 0 and 1 of the sprm contain the opcode. Byte 2 contains the index of the first cell whose shading is to be changed, call it itcFirst. Byte 3 contains the index of the cell that follows the last cell whose shading is to be changed, call it itcLim. This sprm causes the vertAlign properties of the itcLim - itcFirst entries of tap.rgtc[] to be set to the new vertical alignment property contained in Byte 4. sprmTVertAlign is stored only in grpprls linked to piece table entries.
There are some differences between the file format of a full saved document and that of a fast saved document. In previous versions of Word, one of the differences was the necessity of the "complex" table information. In Word '97 and later, the fcClx always indicates the location of the "complex" table information and it is always necessary to determine the location and contents of text and properties. This arises due to unicode and unicode compression.
fcClx is the fc where the complex part of the file begins, and cbClx is the size (in bytes) of the complex part. The complex part of the file contains a group of grpprls that encode formatting changes made by the user and a piece table (plcfpcd). The piece table is needed because the text of the document is not stored contiguously in the file after a fast save.
The complex part of a file (CLX) is composed of a number of variable-sized blocks of data. Recorded first are any grpprls that may be referenced by the plcfpcd (if the plcfpcd has no grpprl references, no grpprls will be recorded) followed by the plcfpcd. Each block in the complex part is prefaced by a clxt (clx type), which is a 1-byte code, either 1 (meaning the block contains a grpprl) or 2 (meaning this is the plcfpcd). A clxtGrpprl (1) is followed by a 2-byte cb which is the count of bytes of the grpprl. A clxtPlcfpcd (2) is followed by a 4-byte lcb which is the count of bytes of the piece table. A full saved file will have no clxtGrpprl's. So the formats of the two types of blocks are:
or
The entire CLX would look like this, depending on the number of grpprl's:
clxtGrpprl
cb
grpprl (0th grpprl)
clxtGrpprl
cb
grpprl (1st grpprl)
...
clxtPlcfpcd
cb
plcfpcd
When the prm in pcds stored in the plcfpcd, contains an igrpprl (index to a grpprl), the index stored is the order in which that grpprl was stored in the CLX.
When a document is recorded in non-complex format, the bounds of the paragraph that contains a particular character can be found by calculating the FC coordinate of the character, searching the bin table to find an FKP page that describes that FC, fetching that FKP, and then searching the FKP to find the interval in the rgfc that encloses the character. The bounds of the interval are the fcFirst and fcLim of the containing paragraph. Every character greater than or equal to fcFirst and less than fcLim is part of the containing paragraph.
When a document is recorded in complex format, a piece that was originally part of one paragraph can be copied or moved within a different paragraph. To find the beginning of the paragraph containing a character in a complex document, it's first necessary to search for the piece containing the character in the piece table. Then calculate the FC in the file that stores the character from the piece table information. Using the FC, search the FCs FKP for the largest FC less than the character's FC, call it fcTest. If the character at fcTest-1 is contained in the current piece, then the character corresponding to that FC in the piece is the first character of the paragraph. If that FC is before or marks the beginning of the piece, scan a piece at a time towards the beginning of the piece table until a piece is found that contains a paragraph mark. This can be done by using the end of the piece FC, finding the largest FC in its FKP that is less than or equal to the end of piece FC, and checking to see if the character in front of the FKP FC (which must mark a paragraph end) is within the piece. When such an FKP FC is found, the FC marks the first byte of paragraph text.
To find the end of a paragraph for a character in a complex format file, again it is necessary to know the piece that contains the character and the FC assigned to the character. Using the FC of the character, first search the FKP that describes the character to find the smallest FC in the rgfc that is larger than the character FC. If the FC found in the FKP is less than or equal to the limit FC of the piece, the end of the paragraph that contains the character is at the FKP FC minus 1. If the FKP FC that was found was greater than the FC of the end of the piece, scan piece by piece toward the end of the document until a piece is found that contains a paragraph end mark. It's possible to check if a piece contains a paragraph mark by using the FC of the beginning of the piece to search in the FKPs for the smallest FC in the FKP rgfc that is greater than the FC of the beginning of the piece. If the FC found is less than or equal to the limit FC of the piece, then the character that ends the paragraph is the character immediately before the FKP FC.
A special procedure must be followed to locate the last paragraph of the main document text when footnote or header/footer text is saved in a Word file (i.e. when fib.ccpFtn != 0 or fib.ccpHdr != 0).
In this case the CP of that paragraph mark is fib.ccpText + fib.ccpFtn + fib.ccpHdr + fib.ccpMcr + fib.ccpAtn and the limit CP of the entire plcfpcd is fib.ccpText + fib.ccpFtn + fib.ccpHdr + fib.ccpMcr + fib.ccpAtn + 1.
Having found the index i of the FC in an FKP that marks the character stored in the file immediately after the paragraph's paragraph mark, it is necessary to use the word offset stored in the first byte of the fkp.rgbx[i - 1] to find the PAPX for the paragraph. Using papx.istd to index into the properties stored for the style sheet , the paragraph properties of the style are copied to a local PAP. Then the grpprl stored in the PAPX is applied to the local PAP, and papx.istd along with fkp.rgbx.phe are moved into the local PAP. The process thus far has created a PAP that describes what the paragraph properties of the paragraph were at the last full save. Now it's necessary to apply any paragraph sprms that were linked to the piece that contains the paragraph's paragraph mark. If pcd.prm.fComplex is 0, pcd.prm contains 1 sprm which should only be applied to the local PAP if it is a paragraph sprm. If pcd.prm.fComplex is 1, pcd.prm.igrpprl is the index of a grpprl in the CLX. If that grpprl contains any paragraph sprms, they should be applied to the local PAP. After applying all of the sprms for the piece, the local PAP contains the correct paragraph property values.
To determine the table properties for a table row in a complex file, scan paragraph-by-paragraph toward the end of the table row, until a paragraph is found that has pap.fTtp set to 1. This paragraph consists of a single row end character. This row end character is linked to the table properties of the row. To create the TAP for the table row, clear a local TAP to zeros. Then the PAPX for the row end character must be fetched from an FKP, and the table sprms that are stored in this PAPX must be applied to the local TAP. The process thus far has created a TAP that describes what the table properties of the table row were at the last full save. Now apply any table sprms that were linked to the piece that contains the table row's row end character. If pcd.prm.fComplex is 0, pcd.prm contains 1 sprm which should be applied to the local TAP if it is a table sprm. If pcd.prm.fComplex is 1, pcd.prm.igrpprl is the index of a grpprl in the CLX. If that grpprl contains any table sprms, apply them to the local TAP. After all of the sprms for the piece are applied, the local TAP contains the correct table property values for the table row.
It is first necessary to fetch the paragraph properties of the paragraph that contains the character. The pap.istd of the fetched properties specifies which style sheet entry provides the default character properties for the character. The character properties recorded in the style sheet for that style are copied into a local CHP. Then, the piece containing the character is located in the piece table (plcfpcd) and the fc of the character is calculated. Using the character's FC, the page number of the CHPX FKP that describes the character is found by searching the bin table (hplcfbteChpx). The CHPX FKP stored in that page is fetched and then the rgfc in the FKP is searched to locate the bounds of the run of exception text that encompasses the character. The CHPX for that run is then located within the FKP, and the CHPX is applied to the contents of the local CHP. The process thus far has created a CHP that describes what the character properties of the character were at the last full save. Now apply any character sprms that were linked to the piece that contains the character. If pcd.prm.fComplex is 0, pcd.prm contains 1 sprm which should be applied to the local CHP if it is a character sprm. If pcd.prm.fComplex is 1, pcd.prm.igrpprl is the index of a grpprl in the CLX. If that grpprl contains any character sprms, apply them to the local CHP. After applying all of the sprms for the piece, the local CHP contains the correct properties for the character.
Characters that are within the same piece, same paragraph, and same run of exception text are guaranteed to have the same properties. This fact can be used to construct a scanner that can return the limit CPs and properties of a sequence of characters that all have the same properties.
To determine which section a character belongs to and what its section properties are, it is necessary to use the CP of the character to search the plcfsed for the index i of the largest CP that is less than or equal to the character's CP. plcfsed.rgcp[i] is the CP of the first character of the section and plcfsed.rgcp[i+1] is the CP of the character following the section mark that terminates the section (call it cpLim). Then retrieve plcfsed.rgsed[i]. The FC in this SED gives the location where the SEPX for the section is stored. Then create a local SEP with default section properties. If the sed.fc != 0xFFFFFFFF, then the sprms within the SEPX that is stored at offset sed.fc must be applied to the local SEP. The process thus far has created a SEP that describes what the section properties of the section at the last full save. Now apply any section sprms that were linked to the piece that contains the section's section mark. If pcd.prm.fComplex is 0, pcd.prm contains 1 sprm which should be applied to the local SEP if it is a section sprm. If pcd.prm.fComplex is 1, pcd.prm.igrpprl is the index of a grpprl in the CLX. If that grpprl contains any section sprms, they should be applied to the local SEP. After applying all of the section sprms for the piece , the local SEP contains the correct section properties.
The picture sprms contained in the prm's grpprl apply to any picture characters within the piece that have their chp.fSpec character == fTrue. The picture properties for a picture (the PIC described in the Structure Definitions) are derived by fetching the PIC stored with the picture and applying to that PIC any picture sprms linked to the piece containing the picture special character.
In Word the text of footnotes and endnotes is anchored to a particular position within the document's main text , the location of its footnote/endnote reference. The following discussion only describes footnotes, with endnotes being handled identically except that the endnote data structures contain the "edn" abbreviation where footnote data structures contain the "fnd" abbreviation. There is a structure referenced by the fib, the plcffndRef, which records the locations of the footnote references within the main text address space and another structure referenced by the fib, the plcffndTxt, which records the beginning locations of corresponding footnote text within the footnote text address space . The footnote text characters in a full saved file begin at offset fib.fcMin + fib.ccpText and extends till fib.fcMin + fib.ccpText + fib.ccpFtn. In a complex fast-saved document , the footnote text begins at CP fib.ccpText and extends till fib.ccpText + fib.ccpFtn. To find the location of the ith footnote reference in the main text address space, look up the ith entry in the plcffndRef and find the location of the text corresponding to the reference within the footnote text address space by looking up the ith entry in the plcffndTxt.
When there are n footnotes, the plcffndTxt structure consists of n+2 CP entries. The CP entries mark the beginning character position within the footnote text address space of the footnote text for the footnotes defined for the file. The beginning CP of the text of the ith footnote is the ith CP within the plcffndTxt. The limit CP of the text of the ith footnote is the i+1st CP within the plcffndTxt.
The last character of footnote text for a footnote (i.e. the character at limit CP - 1) is always a paragraph end(ASCII 13). If there are n footnotes, the n+2nd CP entry value is always 1 greater than the n+1st CP entry value. A paragraph end (ASCII 13) is always stored at the file position marked by the n+1st CP value.
When there are n footnotes, the plcffndRef structure consists of n+1 CP entries followed by n integer flags, named fAuto. The ith CP in the plcffndRef corresponds to the ith fAuto flag. The CP entries give the locations of footnote references within the main text address space. The n+1th CP entry contains the value fib.ccpText + fib.ccpFtn + fib.ccpHdr + 1. The fAuto flag contains 1 whenever the footnote reference name is auto-generated by Word.
When a footnote reference name is automatically generated by Word, Word generates the name by adding 1 to the index number of the reference in the plcffndRef and translating that number to ASCII text. When the footnote reference is auto generated, the character at the main text CP position for the footnote reference should be a footnote reference character (ASCII 5) which has a chp recorded with chp.fSpec = 1.
The number of footnotes stored in a Word binary file can be found by dividing fib.cbPlcffndTxt by 4 and subtracting 1.
The header and footer text characters in a full saved file begin at offset fib.fcMin + fib.ccpText + fib.ccpFtn and extend till fib.fcMin + fib.ccpText + fib.ccpFtn + fib.ccpHdr. In a complex fast-saved document , the footnote text begins at CP fib.ccpText + fib.ccpFtn and extends till fib.ccpText + fib.ccpFtn + fib.ccpHdr. The plcfhdd, a table whose location and length within the file is stored in fib.fcPlcfhdd and fib.cbPlcfhdd, describes where the text of each header/footer begins. If there are n headers/footers stored in the Word file, the plcfhdd consists of n + 2 CP entries. The beginning CP of the ith header/footer is the ith CP in the plcfhdd. The limit CP (the CP of character 1 position past the end of a header/footer) of the ith header/footer is the i + 1 st CP in the plcfhdd. Note that at the limit CP - 1, Word always places a chEop as a placeholder which is never displayed as part of the header/footer. This allows Word to change an existing header/footer to be empty.
If there are n header/footers, the n+2nd CP entry value is always 1 greater than the n+1st CP entry value. A paragraph end (ASCII 13) is always stored at the file position marked by the n+1st CP value.
The transformation in a full saved file from a header/footer CP to an offset from the beginning of a file (fc) is fc = fib.fcMin + ccpText + ccpFtn + cp.
In Word, headers/footers can be defined for a document that:
Also for each section defined for the document, distinct headers can be defined for printing on odd-numbered/right facing pages, even-numbered /left facing pages and the first page of a section. Similarly for each document section, distinct footers can be defined for printing on odd-numbered/right facing pages, even-numbered/left facing pages and the first page of a section.
The plcfhdd contains an entry for each kind of header or footer. (The grpfIhdt is no longer used to find entries in the plcfhdd.) Indices in the plcfhdd are as follows:
Page table information is optional data which is not always stored in a Word binary file. It may be stored for the main text, footnote text and endnote text. The fib contains three FCPGD structures (fcpgdMother, fcpgdFtn, fcpgdEdn) which point to where the data is stored. Each fcpgd points to a PLF of PGD structures and a PLCF of BKD structures. The PLF of PGD descriptors contains n entries where n is the number of pages in the associated text stream. The PLC of BKDs contains >= n entries where each entry describes a single break (page break or otherwise) within the text stream. Each BKD is associated with a PGD and contains an ipgd which is an index into the PLF of PGDs. To find the CP range of a given page, traverse the BKDs searching for the first and last BKD which refer to the given page. The CP range of these BKDs is the CP range of the page.
Third-party creators of Word files should not attempt to create fcpgd structures. They can only be created properly using Word's page layout routines. If a Word document is edited in any way, the fcpgds in the fib should be filled with 0s.
A Word glossary file is a normal Word binary file with two supplemental files, the sttbfglsy, the sttbglsystyle and the plcfglsy, also stored in the file. The sttbfglsy contains a list of the names of glossary entries, the sttbglsystyle contains a list of the stylenames for every autotext entry, and the plcfglsy contains a table of beginning positions within the text address space of the file of the text of glossary entries.
The sttbfglsy begins with an integer count of bytes of the size of the sttbfglsy (includes the size of the integer count of bytes). If there are n glossary entries defined, there will follow n Pascal-type strings (string preceded by length byte) concatenated one after the other which store glossary entry names. The glossary entry names must be sorted in case-insensitive ascending order. (i.e. a and A are treated as equal). Also the names date and time must be included in the list of names. The name of the ith glossary entry is the ith name defined in the sttbfglsy. The extra field in each entry contains an index on the sttbglsystyle that indicates the stylename of the first paragraph in plcfglsy.
The sttbglsystyle is not sorted and has no duplicates. Each entry has an extra field indicating how many autotext entries have that style.
If there are n glossary entries, the plcfglsy, will consist of n+2 CP entries. The ith CP entry will contain the location of the beginning of the text for the ith glossary entry. The i+1st CP entry will contain the limit CP of the ith glossary entry. The character at a CP position of limit CP - 1 is always a paragraph mark. The n+2nd CP entry always contains fib.ccpText + fib.ccpFtn + fib.ccpHdr + 1 if there are headers, footers or footnotes stored in the glossary and contains fib.ccpText + fib.ccpFtn + fib.ccpHdr otherwise. The n+1st CP entry is always 1 less than the value of the n+2nd entry.
The text for the time and date entries will always be a single paragraph mark (ASCII 13).
A routing slip is stored in the main document stream as an RS (Routing Slip) structure followed by a set of variable length data. After the RS are 4 null terminated strings. Each string is preceded by a short containing the string length (including the null terminator). The strings are: the subject, the message text, status and title. Following these strings are a variable number (rs.cRecip) of Routing Recipient (RR) records. Each RR is immediately followed by a variable number (rr.cb) of bytescontaining private data, which is in turn followed by a null terminated string containing the recipient name.
For a document for which AutoSummary View is active (specified in the ASUMYI), the plcfasumy records the result of the last AutoSummary analysis. Each ASUMY in the PLCF gives the AutoSummary level for the text starting at the corresponding CP. The level must be non-negative and no greater than the upper bound specified in the ASUMYI. The ASUMYI specifies the current summary view level. In emphasize view mode, all text at and below the current summary view level is highlighted. In reduce view mode, all text above the current summary view level is hidden.
The following are indices into a table of associated strings:
The format of the ibstAssocCriteriaX strings are as follows:
int cbIbstAssoc:8; // BYTE 0 size of ibstAssocCriteriaX string int fCompOr:1; // BYTE 1 set if cond is an or cond int iCompOp:7; // BYTE 1 index of Comparison Operator char stMergeField[]; // Name of MergeField char stCompInfo[]; // User Supplied Comparison Information
Both stMergeField and stCompInfo are variable length character arrays preceded by a length byte.
cbATRD (count of bytes of ATRD) is 30 (decimal), 1E(hex).
cbANLD (count of bytes of ANLD) is 84 (decimal), 54(hex).
cbANLV (count of bytes of ANLV) is 16 bytes (decimal), 10 bytes (hex).
cbASUMY (count of bytes of ASUMY) is 4 bytes.
cbASUMYI (count of bytes of ASUMYI) is 12 bytes (decimal), C bytes (hex).
cbBTE (count of bytes of BTE) is 4 bytes.
cbBKD (count of bytes of BKD) is 6.
cbBKF (count of bytes of BKF) is 4.
The BKL is no longer stored in the plcfbkl or plcfatnbkl, and is instead reconstructed from the plcfbkf or plcfatnbkf when the file is opened.
cbBKL (count of bytes of BKL) is 2.
The BRC is a substructure of the CHP, PAP, PIC, SEP, TAP and TC. See also the obsolete BRC10 structure.
cbBRC (count of bytes of BRC) is 4.
The seven types of border lines that Windows Word 1.0 supports are coded with different sets of values for dxpLine1Width, dxpSpaceBetween, and dxpLine2 Width.
The border lines and their brc10 settings follow:
When the no border settings are stored in the BRC, brc.fShadow and brc.dxpSpace should be set to 0.
cbBRC10 (count of bytes of BRC10) is 2.
The CHP is never stored in Word files. It is the result of decompression operations applied to CHPXs
The CHPX is stored in CHPX FKPS and within the STSH
When a CHPX is stored in an FKP it is prefixed by a one-byte count of bytes that records the size of the non-zero prefix of the CHPX. Since the count of bytes must begin on an even boundary within the FKP followed by the non-zero prefix, it's guaranteed that the int and FC fields of the CHPX are aligned on an odd-byte boundary. Using normal integer or long load instructions will cause address errors on a 68000. The best technique for reconstituting the CHPX is to move the non-zero prefix to the beginning of a local instance of a CHPX that has been cleared to zeros.
cbCHP (count of bytes of CHP) is 136 (decimal), 88(hex).
The standard CHP is all zeros except:
The CHPX is stored within Character FKPs and within the STSH in STDs for paragraph style and character style entries.
cbDTTM (count of bytes of DTTM) is 4.
cbDCS (count of bytes of DCS) is 2.
The drawing object grid is Far East only, and it sets up a grid in which Far Eastern characters are displayed (one character per grid square).
cbDOGRID (count of bytes of DOGRID) is 10 bytes (decimal), A bytes (hex).
Each version of Word, the DOP gets a little bit larger. Shown below are three different versions of the DOP: for nFib values < 103, for nFib values between 103 and 105, and for nFib values> 105.. Winword 97 and later products write files with nFib> 105. Word 6.0 for the Macintosh writes files with nFib == 103 or 104. The compatibility options (copts) section was grown (to add more compatibility options in the Tools/Options/Compatibility dialog) and copied to the end of the DOP, so for files with nFib>= 103, the first copts section should be ignored (and the analogous fields in the new copts section used instead), whereas files with nFib < 103 will have DOP's without the new copts section. See below for the addition.
b10
b16
field
type
size
bitfield
default value
comment
0
0
fFacingPages
short
:1
0001
0
1 when facing pages should be printed
fWidowControl
short
:1
0002
1
1 when widow control is in effect. 0 when widow control disabled.
fPMHMainDoc
short
:1
0004
0
1 when doc is a main doc for Print Merge Helper, 0 when not; default=0
grfSuppression
short
:2
0018
0
Default line suppression storage; 0= form letter line suppression; 1= no line suppression; default=0. No longer used.
fpc
short
:2
0060
1
footnote position code
0 print as endnotes
1 print at bottom of page
2 print immediately beneath text
short
:1
0080
0
unused
1
1
grpfIhdt
short
:8
FF00
0
No longer used.
2
2
rncFtn
short
:2
0003
0
restart index for footnotes
0 don't restart note numbering
1 restart for each section
2 restart for each page
nFtn
short
:14
FFFC
1
initial footnote number for document
4
4
fOutlineDirtySave
short
:1
0001
when 1, indicates that information in the hplcpad should be refreshed since outline has been dirtied
short
:7
00FE
reserved
5
5
fOnlyMacPics
short
:1
0100
when 1, Word believes all pictures recorded in the document were created on a Macintosh
fOnlyWinPics
short
:1
0200
when 1, Word believes all pictures recorded in the document were created in Windows
fLabelDoc
short
:1
0400
when 1, document was created as a print merge labels document
fHyphCapitals
short
:1
0800
when 1, Word is allowed to hyphenate words that are capitalized. When 0, capitalized may not be hyphenated
fAutoHyphen
short
:1
1000
when 1, Word will hyphenate newly typed text as a background task
fFormNoFields
short
:1
2000
fLinkStyles
short
:1
4000
when 1, Word will merge styles from its template
fRevMarking
short
:1
8000
when 1, Word will mark revisions as the document is edited
6
6
fBackup
short
:1
0001
always make backup when document saved when 1.
fExactCWords
short
:1
0002
when 1, the results of the last Word Count execution (as recorded in several DOP fields) are still exactly correct.
fPagHidden
short
:1
0004
when 1, hidden document contents are displayed.
fPagResults
short
:1
0008
when 1, field results are displayed, when 0 field codes are displayed.
fLockAtn
short
:1
0010
when 1, annotations are locked for editing
fMirrorMargins
short
:1
0020
swap margins on left/right pages when 1.
short
:1
reserved
fDfltTrueType
short
:1
0080
when 1, use TrueType fonts by default (flag obeyed only when doc was created by WinWord 2.x)
7
7
fPagSuppressTopSpacing
short
:1
0100
when 1, file created with SUPPRESSTOPSPACING=YES in win.ini. (flag obeyed only when doc was created by WinWord 2.x).
fProtEnabled
short
:1
0200
when 1, document is protected from edit operations
fDispFormFldSel
short
:1
0400
when 1, restrict selections to occur only within form fields
fRMView
short
:1
0800
when 1, show revision markings on screen
fRMPrint
short
:1
1000
when 1, print revision marks when document is printed
short
:1
reserved
fLockRev
short
:1
4000
when 1, the current revision marking state is locked
fEmbedFonts
short
:1
8000
when 1, document contains embedded TrueType fonts
8
8
copts.fNoTabForInd
short
:1
0001
compatibility option: when 1, don't add automatic tab stops for hanging indent
copts.fNoSpaceRaiseLower
:1
0002
compatibility option: when 1, don't add extra space for raised or lowered characters
copts.fSuppressSpbfAfterPageBreak:
:1
0004
compatibility option: when 1, suppress the paragraph Space Before and Space After options after a page break
copts.fWrapTrailSpaces
:1
0008
compatibility option: when 1, wrap trailing spaces at the end of a line to the next line
copts.fMapPrintTextColor
:1
0010
compatibility option: when 1, print colors as black on non-color printers
copts.fNoColumnBalance
:1
0020
compatibility option: when 1, don't balance columns for Continuous Section starts
copts.fConvMailMergeEsc
:1
0040
copts.fSupressTopSpacing
:1
0080
compatibility option: when 1, suppress extra line spacing at top of page
copts.fOrigWordTableRules
:1
0100
compatibility option: when 1, combine table borders like Word 5.x for the Macintosh
copts.fTransparentMetafiles
:1
0200
compatibility option: when 1, don't blank area between metafile pictures
copts.fShowBreaksInFrames
:1
0400
compatibility option: when 1, show hard page or column breaks in frames
copts.fSwapBordersFacingPgs
:1
0800
compatibility option: when 1, swap left and right pages on odd facing pages
F000
reserved
10
A
dxaTab
uns short
720 twips
default tab width
12
C
wSpare
uns short
14
E
dxaHotZ
uns short
width of hyphenation hot zone measured in twips
16
10
cConsecHypLim
uns short
number of lines allowed to have consecutive hyphens
18
12
wSpare2
uns short
reserved
20
14
dttmCreated
DTTM
date and time document was created
24
18
dttmRevised
DTTM
date and time document was last revised
28
1C
dttmLastPrint
DTTM
date and time document was last printed
32
20
nRevision
int
number of times document has been revised since its creation
34
22
tmEdited
long
time document was last edited
38
26
cWords
long
count of words tallied by last Word Count execution
42
2A
cCh
long
count of characters tallied by last Word Count execution
46
2E
cPg
int
count of pages tallied by last Word Count execution
48
30
cParas
long
count of paragraphs tallied by last Word Count execution
52
34
rncEdn
short
:2
0003
restart endnote number code
0 don't restart endnote numbering
1 restart for each section
2 restart for each page
nEdn
short
:14
FFFC
beginning endnote number
54
36
epc
short
:2
0003
endnote position code
0 display endnotes at end of section
3 display endnotes at end of document
nfcFtnRef
short
:4
003C
number format code for auto footnotes
0 Arabic
1 Upper case Roman
2 Lower case Roman
3 Upper case Letter
4 Lower case Letter
nfcEdnRef
short
:4
03C0
number format code for auto endnotes
0 Arabic
1 Upper case Roman
2 Lower case Roman
3 Upper case Letter
4 Lower case Letter
fPrintFormData
short
:1
0400
only print data inside of form fields
fSaveFormData
short
:1
0800
only save document data that is inside of a form field.
fShadeFormData
short
:1
1000
shade form fields
:2
6000
reserved
fWCFtnEdn
short
:1
8000
when 1, include footnotes and endnotes in word count
56
38
cLines
long
count of lines tallied by last Word Count operation
60
3C
cWordsFtnEnd
long
count of words in footnotes and endnotes tallied by last Word Count operation
64
40
cChFtnEdn
long
count of characters in footnotes and endnotes tallied by last Word Count operation
68
44
cPgFtnEdn
short
count of pages in footnotes and endnotes tallied by last Word Count operation
70
46
cParasFtnEdn
long
count of paragraphs in footnotes and endnotes tallied by last Word Count operation
74
4A
cLinesFtnEdn
long
count of paragraphs in footnotes and endnotes tallied by last Word Count operation
78
4E
lKeyProtDoc
long
document protection password key, only valid if dop.fProtEnabled, dop.fLockAtn or dop.fLockRev are 1.
82
52
wvkSaved
short
:3
0007
document view kind
0 Normal view
1 Outline view
2 Page View
wScaleSaved
short
:9
0FF8
zoom percentage
zkSaved
short
:2
3000
zoom type
0 None
1 Full page
2 Page width
fRotateFontW6
short
:1
4000
This is a vertical document (Word 6/95 only)
iGutterPos
short
:1
8000
Gutter position for this doc: 0 => side; 1 => top
In a file with nFib < 103-for example, documents created with Word 6.0 for Windows-the DOP would end here. This DOP would have a cbDOP of 84, and a cwDOP of 42.
Files with nFib>= 103, the compatibility options (copts) section at offset 8 was copied here and expanded. Options marked "(see above)" hold the same value that the same-named field in the old copts section above had in files with nFib < 103.
84
54
fNoTabForInd
uns long
:1
00000001
(see above)
fNoSpaceRaiseLower
:1
00000002
(see above)
fSupressSpbfAfterPageBreak
:1
00000004
(see above)
fWrapTrailSpaces
:1
00000008
(see above)
fMapPrintTextColor
:1
00000010
(see above)
fNoColumnBalance
:1
00000020
(see above)
fConvMailMergeEsc
:1
00000040
(see above)
fSupressTopSpacing
:1
00000080
(see above)
fOrigWordTableRules
:1
00000100
(see above)
fTransparentMetafiles
:1
00000200
(see above)
fShowBreaksInFrames
:1
00000400
(see above)
fSwapBordersFacingPgs
:1
00000800
(see above)
:4
0000F000
(reserved)
fSuppressTopSpacingMac5
:1
00010000
Suppress extra line spacing at top of page like MacWord 5.x
fTruncDxaExpand
:1
00020000
Expand/Condense by whole number of points.
fPrintBodyBeforeHdr
:1
00040000
Print body text before header/footer
fNoLeading
:1
00080000
Don't add leading (extra space) between rows of text
:1
00100000
(reserved)
fMWSmallCaps
:1
00200000
Use larger small caps like MacWord 5.x
:10
FFC00000
(reserved)
For this expanded DOP, cbDOP = 88 and cwDOP = 44.
For files with nFib> 105, the DOP has a number of additional fields:
88
58
adt
short
Autoformat Document Type: 0 for normal. 1 for letter, and 2 for email.
90
5A
doptypography
DOPTYPOGRAPHY
see DOPTYPOGRAPHY
400
190
dogrid
DOGRID
see DOGRID
410
19A
reserved
short
:1
0001
Always set to zero when writing files
lvl
short
:4
001E
Which outline levels are showing in outline view (0 => heading 1 only, 4 => headings 1 through 5, 9 => all levels showing)
fGramAllDone
short
:1
0020
Doc has been completely grammar checked
fGramAllClean
short
:1
0040
No grammer errors exist in doc
fSubsetFonts
short
:1
0080
if you are doing font embedding, you should only embed the characters in the font that are used in the document
fHideLastVersion
short
:1
0100
Hide the version created for autoversion
fHtmlDoc
short
:1
0200
This file is based upon an HTML file
reserved
short
:1
0400
Always set to zero when writing files
fSnapBorder
short
:1
0800
Snap table and page borders to page border
fIncludeHeader
short
:1
1000
Place header inside page border
fIncludeFooter
short
:1
2000
Place footer inside page border
fForcePageSizePag
short
:1
4000
Are we in online view
fMinFontSizePag
short
:1
8000
Are we auto-promoting fonts to>= hpsZoonFontPag?
412
19C
fHaveVersions
short
:1
0001
versioning is turned on
fAutoVersion
short
:1
0002
autoversioning is enabled
reserved
short
:14
FFFC
Always set to zero when writing files
414
19E
asumyi
ASUMYI
Autosummary info
426
1AA
cChWS
long
Count of characters with spaces
430
1AE
cChWSFtnEdn
long
Count of characters with spaces in footnotes and endnotes
434
1B2
grfDocEvents
long
438
1B6
fVirusPrompted
long
:1
0001
Have we prompted for virus protection on this doc?
fVirusLoadSafe
long
:1
0002
If prompted, load safely for this doc?
KeyVirusSession30
long
:30
FFFC
Random session key to sign above bits for a Word session.
442
1BA
Spare
30 bytes
Spare
472
1D8
reserved
long
Always set to zero when writing files
476
1DC
reserved
long
Always set to zero when writing files
480
1E0
cDBC
long
Count of double byte characters
484
1E4
cDBCFtnEdn
long
Count od double byte characters in footnotes and endnotes
488
1E8
reserved
long
Always set to zero when writing files
492
1EC
nfcFtnRef
short
number format code for auto footnote references
0 Arabic
1 Upper case Roman
2 Lower case Roman
3 Upper case Letter
4 Lower case Letter
494
1EE
nfcEdnRef
short
number format code for auto endnote references
0 Arabic
1 Upper case Roman
2 Lower case Roman
3 Upper case Letter
4 Lower case Letter
496
1F0
hpsZoonFontPag
short
minimum font size if fMinFontSizePag is true
498
1F2
dywDispPag
short
height of the window in online view during last repag
For this expanded DOP, cbDOP = 500 and cwDOP = 250.
These options are Far East only, and are accessible through the Typography tab of the Tools/Options dialog.
cbDOPTYPOGRAPHY (count of bytes of DOPTYPOGRAPHY) is 310 bytes (decimal), 136 (hex)..
Since dead fields have no entry in the plcffld, the string in the field code must be used to determine the field type. All versions of Word '97 use English field code strings, except French, German, and Spanish versions of Word. The strings for all languages for all possible dead fields are listed below.
cbFSPA (count of bytes of FSPA) is 26 (decimal), 1A (hex).
Definition of type: "FIBFCLCB"
Definition of type: "FIB"
In Word version 8, the FIB is reorganized to make future extention easier, and to make it easier to make backward compatible file format changes. The FIB now consists of four substructures: the header and three arrays. The FIB header, is unchanged from past versions. The second part is an array of 16-bit "shorts", most of which were present in earlier versions in different locations. The third part is an array of 32-bit longs, many of which were scattered through the previous version FIB. Finally, there is an array of FC/LCB pairs, which were divided into several disjoint arrays in the previous FIB. Future versions of Word will add entries to the three arrays, so readers of the FIB must be careful to skip over any entries in each array that were not present in the version for which the reader was designed. Writers of the FIB must write exactly as many entries as was defined for the nFib value they put in the FIB.
The FIBFCLCB structure, used in the last array in the FIB:
The FIB structure itself:
cbFIB (count of bytes of FIB) is 898 (decimal), 382 (hex).
If a table does not exist in the file, its cb in the FIB is zero and its fc is equal to that of the following table (the latter equality is irrelevant, as the cb should be used to determine existence of the table).
The FRD is stored in both the plcffndRef and the plcfendRef
The CHP is never stored in a Word file. It is derived by expanding stored CHPXs.
The PAP is never stored in a Word file. It is derived by expanding stored PAPXs.
cbLSPD (count of bytes of LSPD) is 4.
cbOLST (count of bytes of OLST) is 212(decimal), D4(hex).
The NUMRM structure is used to track revision marking data for paragraph numbers, and is stored in the PAP for each numbered paragraph. When revision marking tracking is turned on, we fill out the NUMRM for each number with the data required to recreate the number's text. Then at display time, that string is compared with the current paragraph number string, and displayed as changed (old deleted, current inserted) if the strings differ. The string construction algorithm is the same as for an LVL structure.
cbNUMRM (count of bytes of NUMRM) is 128 (decimal), 80 (hex).
cbPGD (count of bytes of PGD) is 10.
The PHE is a substructure of the PAP and the PAPX FKP and is also stored in the PLCFPHE.
If the PHE is stored in a PAP whose fTtp field is set (non-zero), the following structure is used:
cbPHE (the count of bytes of PHE) is 12.
If there is no paragraph height information stored for a paragraph, all of the fields in the PHE are set to 0. If a paragraph contains more than 127 lines, the clMac, dylLine variant cannot be used, so fDiffLines must be set to 1 and the total size of the paragraph stored in dylHeight. If a paragraph height is greater than 32767 twips, the height cannot be represented by a PHE so all fields of the PHE must be set to 0.
If a new Word file is created, the PHE of every papx fkp entry created to describe the paragraphs of the file should be set to 0. If a Word file is altered in place (a character of the file changed to a new character or a property changed), the paragraph containing the change must have its papx.phe field set to 0. If this paragraph is in a table row, the PHE in the papx at the end of the row (indicated by fInTable) must also be set to 0.
/* the brcp and brcl fields have been superseded by the newly defined brcLeft, brcTop, etc. fields. They remain in the PAP for compatibility with MacWord 3.0 */
cbPAP (count of bytes of PAP) is 610 (decimal), 262(hex)
The standard PAP is all zeros except:
The PAPX is stored within FKPs and within the STSH.
For calculating papx.cw when storing in a FKP: For even-sized grpprl's, the grpprl plus the istd and cw bytes will be an even number of bytes, so we store the count of words for all three elements in papx.cw. For odd-sized grpprl's, the three elements will be an odd number of bytes, which can't be represented with a count of words; so, we store a 'pad' byte of 0 at the beginning (in the normal cw location), followed by a count that is the size of the grpprl and istd byte only (since that's an even number of bytes). In either case, papx.cw is immediately followed by the istd and grpprl.
If a Windows metafile is stored immediately following the PIC structure, the mfp is a Window's METAFILEPICT structure. When the data immediately following the PIC is a TIFF filename, mfp.mm == 98 If a bitmap is stored after the pic, mfp.mm == 99
When the PIC describes a bitmap, mfp.xExt is the width of the bitmap in pixels and mfp.yExt is the height of the bitmap in pixels..
when scaling bitmaps, dxaGoal and dyaGoal may be ignored if the operation would cause the bitmap to shrink or grow by a non -power-of-two factor
for all of the Crop values, a positive measurement means the specified border has been moved inward from its original setting and a negative measurement means the border has been moved outward from its original setting.
cbPCD (count of bytes of PCD) is 8.
cbPLC (count of bytes of a PLC) is iMac(4 + cbStruct) + 4.
The PRM has two variants. In the first variant, the PRM records a single sprm with a bit- or byte-sized operand.
cbPRM (count of bytes of PRM) is 2.
Since isprm is 7 bits, rgsprmPrm can hold 0x80 entries.
{sprmNoop, sprmNoop, sprmNoop, sprmNoop, sprmPIncLvl, sprmPJc, sprmPFSideBySide, sprmPFKeep, sprmPFKeepFollow, sprmPFPageBreakBefore, sprmPBrcl, sprmPBrcp, sprmPIlvl, sprmNoop, sprmPFNoLineNumb, sprmNoop, sprmNoop, sprmNoop, sprmNoop, sprmNoop, sprmNoop, sprmNoop, sprmNoop, sprmNoop, sprmPFInTable, sprmPFTtp, sprmNoop, sprmNoop, sprmNoop, sprmPPc, sprmNoop, sprmNoop, sprmNoop, sprmNoop, sprmNoop, sprmNoop, sprmNoop, sprmPWr, sprmNoop, sprmNoop, sprmNoop, sprmNoop, sprmNoop, sprmNoop, sprmPFNoAutoHyph, sprmNoop, sprmNoop, sprmNoop, sprmNoop, sprmNoop, sprmPFLocked, sprmPFWidowControl, sprmNoop, sprmPFKinsoku, sprmPFWordWrap, sprmPFOverflowPunct, sprmPFTopLinePunct, sprmPFAutoSpaceDE, sprmPFAutoSpaceDN, sprmNoop, sprmNoop, sprmPISnapBaseLine, sprmNoop, sprmNoop, sprmNoop, sprmCFStrikeRM, sprmCFRMark, sprmCFFldVanish, sprmNoop, sprmNoop, sprmNoop, sprmCFData, sprmNoop, sprmNoop, sprmNoop, sprmCFOle2, sprmNoop, sprmCHighlight, sprmCFEmboss, sprmCSfxText, sprmNoop, sprmNoop, sprmNoop, sprmCPlain, sprmNoop, sprmCFBold, sprmCFItalic, sprmCFStrike, sprmCFOutline, sprmCFShadow, sprmCFSmallCaps, sprmCFCaps, sprmCFVanish, sprmNoop, sprmCKul, sprmNoop, sprmNoop, sprmNoop, sprmCIco, sprmNoop, sprmCHpsInc, sprmNoop, sprmCHpsPosAdj, sprmNoop, sprmCIss, sprmNoop, sprmNoop, sprmNoop, sprmNoop, sprmNoop, sprmNoop, sprmNoop, sprmNoop, sprmNoop, sprmNoop, sprmCFDStrike, sprmCFImprint, sprmCFSpec, sprmCFObj, sprmPicBrcl, sprmPOutLvl, sprmNoop, sprmNoop, sprmNoop, sprmNoop, sprmNoop, sprmPPnbrRMarkNot}
In the second variant, prm.fComplex is 1, and the rest of the structure records an index to a grpprl stored in the CLX (described in Complex File Format topic).
cbPRM (count of bytes of PRM) is 2.
cbRS (count of bytes of RS) is 16 (decimal), 10 (hex).
cbRR (count of bytes of RR) is 4.
cbSED (count of bytes of SED) is 12 (decimal), C (hex).
The standard SEP is all zeros except as follows:
cbSEP (count of bytes of SEP) is 704(decimal), 2C0(hex).
The SHD is a substructure of the CHP and PAP.
cbSHD (count of bytes of SHD) is 2.
The TBD is a substructure of the PAP.
cbTBD (count of bytes of TBD) is 1.
The TC is a substructure of the TAP.
cbTC (count of bytes of TC) is 20(decimal), 14(hex).
cbTLP (count of bytes of TLP) is 4.
cbTAP (count of bytes of TAP) is 1728 (decimal), 6C0(hex).
cbFTXBXS (cout of bytes of FTXBXS) is 22 (decimal), 16 (hex).
cbWKB (count of bytes of WKB) is 12 (decimal), C (hex).
As described under "picture" in the Definition section of this document, some pictures in Word documents are stored as Macintosh PICT graphics, particularly in files created by Word for the Macintosh. All pictures, including these, are stored as a block of binary data attached to a special chPic character in the text stream. This block always begins with a PIC structure. (Please see the "picture" definition mentioned above for more information on general picture-reading.)
Normal graphics follow the PIC structure with a single Office shape, Windows metafile, bitmap, or TIFF representation, as described in the "picture" definition section. Macintosh PICT graphics have a standard, unchanging Windows metafile after the PIC which always depicts an "x", followed by the actual Macintosh PICT picture. This is for backward-compatibility with older readers, which expect to find a Windows metafile after the PIC structure. These readers will simply display the fixed "x" image. In the Macintosh PICT case, the PIC structure's lcb field represents the size of the entire picture data block, including the PIC itself, the "x" metafile and the Macintosh PICT data. (see the description of the PIC structure in the Structure Definitions section of this document.)
To distinguish between normal and Macintosh PICT graphics, a reader needs to detect the presence of the special "x" metafile. The bytes below are in an early portion of the "x" metafile.
unsigned char rgbWmfXBegin[] =
{
'\x14', '\x00', '\x00', '\x00', '\x26', '\x06', '\x0F', '\x00', '\x1E', '\x00',
'\xFF', '\xFF', '\xFF', '\xFF', '\x04', '\x00', '\x14', '\x00', '\x00', '\x00',
'\x57', '\x6F', '\x72', '\x64', '\x0E', '\x00', '\x4D', '\x69', '\x63', '\x72',
'\x6F', '\x73', '\x6F', '\x66', '\x74', '\x20', '\x57', '\x6F', '\x72', '\x64',
'\x0E', '\x00', '\x00', '\x00', '\x26', '\x06', '\x0F', '\x00', '\x12', '\x00',
'\x57', '\x6F', '\x72', '\x64', '\xFF', '\xFF', '\x08', '\x00', '\x00', '\x00'
/* "x" wmf and PICT data sizes immediately follow as 2 four-byte longs */
};
#define cbMETAHDR 18 // size of a standard Windows metafile header
#define cbWmfXBegin 60 // length of this beginning section of the x metafile
After reading the PIC structure from the picture data block, the reader should skip cbMETAHDR bytes (the size of a standard Windows metafile header). It should then compare the next cbWmfXBegin bytes in the picture data block against the bytes in the rgbWmfXBegin array above. If they do not match, the picture is a normal picture -- Windows metafile, bitmap or TIFF.
If they do match, then the reader should read the next 8 bytes in the picture data block as two 4-byte "long"s (Intel 80x86 byte order). These numbers are the sizes (in bytes) of the "x" metafile and the Macintosh PICT data, respectively. The size of the "x" metafile is measured from its start immediately after the PIC structure. It is possible for the PICT's size to be zero. In this case, there is no PICT data, and the reader may use the "x" Windows metafile as the picture's representation.
Certain Unicode characters are shared between Far East and non-Far East scripts requiring the calculation of font and language based on the Unicode character code and the chp.idctHint property.
Characters are classified into one of four groups, ASCII, Far East, floating, and non-Far East. Properties are calculated as follows:
The table below defines the classification of various ranges of Unicode characters:
The table below describes the behavior of the unicode subrange usrLatin1. Shared characters are marked in this table with a 1, while characters marked with a 0 are considered "non-Far East". All other characters in this unicode subrange are considered "non-Far East".
// 0 1 2 3 4 5 6 7 8 9 a b c d e f 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 1, // 0x00a0-0x00af 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, // 0x00b0-0x00bf 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x00c0-0x00cf 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, // 0x00d0-0x00df 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x00e0-0x00ef 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, // 0x00f0-0x00ff };
The table below describes the behavior of the unicode range usrLatinXA. Shared characters are marked in this table with a 1, while characters marked with a 0 are considered "non-Far East". All other characters in this unicode subrange are considered "non-Far East".
// 0 1 2 3 4 5 6 7 8 9 a b c d e f 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x0100-0x010f 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, // 0x0110-0x011f 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, // 0x0120-0x012f 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x0130-0x013f 0, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, // 0x0140-0x014f 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 0x0150-0x015f 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, // 0x0160-0x016f
In usrLatinXB shared characters are 0x192, 0x1FA, 0x1FB, 0x1FC, 0x1FD, 0x1FE and 0x1FF. All other characters in this unicode subrange are considered "non-Far East".
In usrIPAExtensions shared characters are 0x251, and 0x261.
An optimization is available. If the Far East font chp.ftcFE is 0 and chp.idctHint is 0 and chp.ftcAscii is equal to chp.ftcOther, the font is chp.ftcAscii and the language is chp.lidDefault.