The WordPerfect 6 and later page lists the function codes, sub-codes and packet types of 6.x-format documents (6.0 up to today’s WordPerfect). This page gives the byte layout of the data inside them, as far as libwpd reads it. Numbers are little-endian; distances are in WordPerfect units (WPU), 1,200 to the inch; “16.16” is a 32-bit number whose high 16 bits are the whole part and low 16 bits the fraction. In a variable-length group, offsets count from the byte after the non-deletable size. A character written as a “WP character” is 16 bits: the character set in the high byte and the character in the low byte. Corel does not publish the format, and what libwpd skips is not described in public.
0xD0 end of line: table data
An end-of-line group may carry table information. Its data starts with a 16-bit size of a part libwpd skips; then, up to the end of the non-deletable data, comes a series of items, each a one-byte code followed by its data. The sizes include the code byte.
| Item | Size | Data |
|---|---|---|
| 128 row information | 5 | Flags: bit 2 header row; bit 1 the row has a height, then bit 4 minimum (else exact) and a 16-bit height in WPU. Without bit 1 the height is automatic |
| 129 cell formula | variable | 16-bit size, then the formula (not read) |
| 130 top gutter spacing | 4 | not read |
| 131 bottom gutter spacing | 4 | not read |
| 132 cell information | 9 | Flags (bit 0 use the cell’s attributes, bit 1 use its justification, bit 6 ignore in calculations, bit 7 locked); justification (bits 0–2); vertical alignment (bits 0–1: 0 top, 1 centre, 2 bottom, 3 full); attributes as two 16-bit words (the first, plus bits 0–1 of the second as bits 16–17) |
| 133 cell spanning | 4 | Columns spanned, rows spanned; a column value of 128 or more means the cell is covered by the one above |
| 134 cell fill colours | 10 | Foreground red, green, blue, shade; background red, green, blue, shade |
| 135 cell line colour | 6 | Red, green, blue, shade |
| 136 cell number type | 6 | not read |
| 137 cell floating-point number | 11 | not read |
| 139 cell prefix flag | 3 | Cell borders byte |
| 140 cell recalculation error number | 3 | not read |
| 141 do not end a paragraph style here | 1 | none |
| 142, 143 | variable | unknown; a 16-bit size follows |
Item 138 and items above 143 are not known; libwpd treats an unknown item as an error.
0xD1 page
| Sub-code | Data |
|---|---|
| 0 top margin, 1 bottom margin | Margin (2), WPU |
| 2 suppress page features | Flags (1), listed on the 6.x page |
| 3 page number position | Typeface descriptor (2), use flag (1), copy of the font’s packet ID (2), point size (2), position (1), matched font index (2), matched point size (2), attributes (2 + 2), colour (red, green, blue, shade), height (2), new page position (1) |
| 17 paper form | 3 bytes; length (2), width (2), WPU; form type (1); orientation (0 portrait, 1 landscape) |
0xD2 column
| Sub-code | Data |
|---|---|
| 0 left margin, 1 right margin | Margin (2), WPU |
| 2 column definition | Type (1: 0 newspaper, 1 balanced newspaper, 2 parallel, 3 parallel with block protect); row spacing (16.16); column count n (1); if n > 1, 2n − 1 entries alternating column and gap, each a definition byte (bit 0: fixed width) and a 16-bit width, in WPU when fixed or as a fraction of 65,536 of the free space otherwise |
| 3 column border | not read |
0xD3 paragraph
| Sub-code | Data |
|---|---|
| 1 line spacing | Spacing (16.16) |
| 4 tab set | See tab set |
| 5 justification | Value (1): 0 left, 1 full, 2 centre, 3 right, 4 full including the last line, 5 decimal-aligned in libwpd (the 6.x page’s “reserved”) |
| 10 spacing after paragraph | Relative spacing (16.16); when the non-deletable size is 6, also the absolute spacing (2), WPU |
| 11 first-line indent | Signed offset (2), WPU |
| 12 left margin adjustment, 13 right margin adjustment | Signed offset (2), WPU |
| 14 outline definition | Outline hash (2), numbering method for each of 8 levels (1 each), tab behaviour flag (1) |
Tab set
| Size | Field |
|---|---|
| 1 | Definition: 0 tabs measured from the paper’s left edge; otherwise relative to the margin |
| 2 | Adjustment (WPU) subtracted from relative positions |
| 1 | Number of entries |
| 3 each | Entries: a type byte and a 16-bit position in WPU (FFFF none) |
Type byte: if bit 7 is set, bits 0–6 are a repeat count, and the following position is a step added that many times to the previous tab. Otherwise bits 0–3 are the alignment (0 left, 1 centre, 2 right, 3 decimal, 4 bar), bit 4 says there is a leader, and bits 5–6 its kind: 0 dots in the method used before WordPerfect 9, 1 dots, 2 hyphens, 3 underscores.
0xD4 character
| Sub-code | Data |
|---|---|
| 0 alignment character | WP character (2) |
| 24 colour | Red, green, blue (1 each) |
| 25 shading | Shading (1), applied to the text colour |
| 26 font face | Old matched point size (2), font hash (2), matched font index (2), matched point size (2); then, in the deletable part when it is longer than 24 bytes, a font descriptor (as packet 0x55 below) |
| 27 font size | Desired size (2), divided by 50 for points |
| 29 comment | No data read; the comment text is in a packet named by the group’s prefix ID |
| 30 dot leader characters | WP character (2), number of spaces (1) |
| 42 table definition on | Flags (1), position (1), left offset (2), WPU |
| 43 table definition off | none |
| 44 table column | Flags (1), width (2), left gutter (2), right gutter (2), attributes (4, low 18 bits used), alignment (1, bits 0–2), absolute position from the right (2), number type (2), currency index (1) |
| 50 paragraph number on | Outline hash (2), level (1), flag (1) |
Other variable-length groups
| Group | Data |
|---|---|
D6 header, footer, watermark | Occurrence (1): bit 1 odd pages, bit 2 even pages. The text is a general text packet named by the group’s prefix ID |
D7 footnote, endnote | No data read; the note text is a general text packet named by the prefix ID |
D8 set number, sub-code 2 page | Count of level numbers (1), starting level (1), number (2) |
D9 numbering method, sub-code 2 page | Level (1), method (1): 0 Arabic, 1 lower-case letters, 2 upper-case letters, 3 lower-case Roman, 4 upper-case Roman |
DA display number, even sub-codes | Level number to display (1) |
DD style, sub-code 10 global on | Style hash (2), system style number (1) |
E0 tab | Group flag 0x40 means “ignore this function”. libwpd’s reading of the position is reverse-engineered: for left tabs (sub-code bits 6–7 clear) the position (2, WPU from the paper’s left edge) comes first; for others it is found at an offset depending on the group size |
0xDF box
Sub-codes 0, 1 and 2 (anchored to a character, paragraph or page):
| Size | Field |
|---|---|
| 14 | Reserved |
| 2 | Total size of override and wrap rectangle data |
| 2 | Size of override data |
| 2 | Override flags: which blocks follow (0x8000 counter, 0x4000 positioning, 0x2000 content, 0x1000 caption, 0x0800 border, 0x0400 fill, 0x0200 wrapping, 0x0100 hypertext, 0x0080 HTML, 0x0040 grouping, 0x0020 drawing object) |
| … | The blocks in that order, each starting with its 16-bit size and a 16-bit flags word that says which of its fields follow |
Positioning block fields, by its flags: 0x8000 two bytes; 0x4000 general positioning mask and value (1 + 1; bits 0–1 of the value: 0 page, 1 paragraph, 2 character anchor); 0x2000 horizontal flags (1), signed offset (2), left and right column (1 + 1); 0x1000 vertical flags (1), signed offset (2); 0x0800 width flags (1), width (2); 0x0400 height flags (1), height (2); 0x0200 z-order flags (1). Content block: 0x8000 two bytes; 0x4000 content type (1; 3 is an image); 0x2000 rendering information, for an image a size (2), flags (2) and, with flag 0x4000, the native width and height (2 + 2). The other blocks are not read. Sub-code 3 (graphics line) is not read.
Fixed-length groups
| Code | Data |
|---|---|
F0 extended character | Character (1), character set (1) |
F1 undo | Type (1), level (2) |
F2, F3 attribute on, off | Attribute (1) |
FB, FC highlight on, off | Red, green, blue, shade (1 each) |
The contents of F4–FA, FD and
FE are not known.
Prefix packets
Each packet’s data is found through its 14-byte index entry (see the 6.x page). Several packets begin with a list of the other packets they use (“child” IDs): a 16-bit count and that many 16-bit IDs.
| Type | Data |
|---|---|
0x07 hyperlink | The link target as 16-bit characters, ending with 0 |
0x08 general text | Number of blocks n (2), 4 bytes, n block sizes (4 each), then the blocks. Joined, they are a document stream in the same codes as the main text (a header, footnote or box text) |
0x12 extended document summary | A series of fields, each: field length (2), field number (2, listed on the 6.x page), 2 bytes, the field’s name in WP characters ending 0, then the value. Dates (fields 14 creation, 15 completed, 37 recorded, 39 revision, 49 version) are year (2), month, day, hour, minute, second, day of week, time zone and one unused byte; other values are WP characters ending 0 |
0x1B comment | Child count (must be 1), the ID of the general text packet with the comment (2), flags (1) |
0x25 initial font | Child count (2), font descriptor packet ID (2), point size (2) |
0x31 outline style | Child count (2), 8 paragraph style IDs (2 each), flags (1), outline hash (2), numbering method for 8 levels (1 each), tab behaviour flag (1) |
0x40 graphics file name | If the index entry’s flag bit 0 is set: child count (2) and child IDs (2 each), the cached data packets of the picture |
0x41 graphics box style | Child count and IDs; box data size (2); then blocks each starting with its 16-bit size: name/library (1 byte, flags with bit 0 library style, name length (signed 2) and the name in WP characters; a length of 0, −1, −2, −3, −4, −5 means the built-in Figure, Table, Text, User, Equation or Button box), counter, positioning (as in the box group, without flag words), content (1 byte, type, alignment flags: bits 0–1 horizontal, bits 6–7 vertical, bit 4 clear keeps the aspect ratio; for type 3 a rendering block with native width and height), caption, border, fill, wrapping, hypertext |
0x43 fill style | Child count and IDs, 6 bytes, fill name length (signed 2) and name, 3 bytes, foreground red, green, blue, shade, background red, green, blue, shade |
0x55 font descriptor | Character width, ascender height, x-height, descender height, italic adjustment (2 each); primary family member ID, primary family ID, scripting system, primary character set, width, weight, attributes, general characteristics, classification, fill, font type, font source file type (1 each); name length in bytes (2); the name in WP characters |
0x69 table style | Not read |
0x6F cached graphics data | The picture data itself (libwpd’s debugging code saves it with a .wpg name) |
The contents of the other packet types (document settings, printer selection, style data, file dates, spelling data, time stamp, web data, undo information, and the types libwpd does not name) are not described in public.
Source
- libwpd source –
WP6FileStructure.h,WP6VariableLengthGroup,WP6EOLGroup,WP6PageGroup,WP6ColumnGroup,WP6ParagraphGroup,WP6CharacterGroup,WP6HeaderFooterGroup,WP6FootnoteEndnoteGroup,WP6SetNumberGroup,WP6NumberingMethodGroup,WP6DisplayNumberReferenceGroup,WP6StyleGroup,WP6TabGroup,WP6BoxGroup,WP6HighlightGroup,WP6UndoGroup,WP6PrefixDataPacketand theWP6*Packetreaders,WP6ContentListener,WPXContentListener,libwpd_internal.cpp