An extended control character in a paragraph’s text (see
control characters)
stands for a control whose data is in a HWPTAG_CTRL_HEADER record, a child
of the paragraph. The record starts with the control ID and goes on with the control’s
own fields; further records, and paragraph lists for controls that hold text, follow
one level deeper. This page covers every control that is not a table or drawing object
(those are on tables, pictures and
drawings), following Hancom’s HWP 5.0 specification, revision 1.3, sections 4.3.6
to 4.3.8 and 4.3.10, with its table numbers. Lengths are in HWPUNIT, 1/7200 inch.
HWPTAG_CTRL_HEADER
| Type | Field (table 64) |
|---|---|
| UINT32 | Control ID |
| varies | The control’s own fields, which depend on the ID (below) |
An ID is four characters packed as
MAKE_4CHID(a, b, c, d) = (a << 24) | (b << 16) | (c << 8) | d
and stored little-endian, so the bytes in the file read backwards: the column
definition cold is 0x636F6C64, stored
64 6C 6F 63.
| ID | Control (table 127) | Paragraph list | Fields |
|---|---|---|---|
secd | Section definition | Yes (master pages) | Section definition |
cold | Column definition | No | Column definition |
head, foot | Header, footer | Yes | Header and footer |
fn , en | Footnote, endnote | Yes | Notes |
atno | Automatic number | No | Automatic number |
nwno | New number (restart a count) | No | New number |
pghd | Hide (on this page) | No | Hide |
pgct | Odd/even page adjustment | No | Odd/even adjustment |
pgnp | Page number position | No | Page number position |
idxm | Index mark | No | Index mark |
bokm | Bookmark | No | Bookmark |
tcps | Overlapping characters | No | Overlapping characters |
tdut | Ruby text (dutmal) | No | Ruby text |
tcmt | Hidden comment | Yes | Hidden comment |
%… | Field start | No | Field |
The table, drawing object, equation, picture, OLE and group controls are on the tables, pictures and drawings page; the field IDs are listed on the paragraphs page.
HWPTAG_LIST_HEADER
Starts a list of paragraphs inside a control: a table cell, a header, a note, a
text box. The paragraphs follow as PARA_HEADER records at the same level
as the list header. Table 65:
| Offset | Type | Field |
|---|---|---|
0 | INT16 | Number of paragraphs |
2 | UINT32 | Properties (below) |
| Bits | Meaning | Values |
|---|---|---|
| 0–2 | Text direction | 0 horizontal, 1 vertical |
| 3–4 | Line breaking | 0 normal; 1 keep one line by narrowing the letter spacing; 2 the width grows with the content |
| 5–6 | Vertical alignment | 0 top, 1 centre, 2 bottom |
Six bytes; a control may add its own fields after them, such as a table cell’s cell properties.
HWPTAG_CTRL_DATA
Free data of a control, such as a field’s name or a hyperlink, stored as a parameter set (table 66). A bookmark keeps its name here.
Section definition (secd)
Stored in the first paragraph of each section. Table 129:
| Offset | Type | Field |
|---|---|---|
0 | UINT32 | Properties (below) |
4 | HWPUNIT16 | Gap between columns on the same page |
6 | HWPUNIT16 | Vertical line grid: 0 off, otherwise the spacing |
8 | HWPUNIT16 | Horizontal character grid: 0 off, otherwise the spacing |
10 | HWPUNIT | Default tab spacing (HWPUNIT or relative characters) |
14 | UINT16 | Numbering paragraph shape ID (outline numbering) |
16 | UINT16 | Page number: 0 continue from the previous section, n start at n |
18 | UINT16[3] | Figure, table and equation numbers: 0 continue, n start at n |
24 | UINT16 | Representative language: 0 means the application’s (from version 5.0.1.5) |
| Bits | Meaning (table 130) |
|---|---|
| 0 | Hide the header |
| 1 | Hide the footer |
| 2 | Hide the master page |
| 3 | Hide the border |
| 4 | Hide the background |
| 5 | Hide the page number position |
| 8 | Show the border on the first page of the section only |
| 9 | Show the background on the first page of the section only |
| 16–18 | Text direction: 0 horizontal, 1 vertical |
| 19 | Hide empty lines |
| 20–21 | Whether to apply page numbering when a section break makes a new page |
| 22 | Apply manuscript-paper (wongoji) rules |
Child records, in order: HWPTAG_PAGE_DEF (40 bytes),
HWPTAG_FOOTNOTE_SHAPE for footnotes and again for endnotes (26 bytes
each), HWPTAG_PAGE_BORDER_FILL, and, when the section has master pages
for both, odd or even pages, the master page information
with its paragraph list. The specification counts 140 bytes for all of this. The end
of each section also holds the extended master pages (last page, any page), and the
end of the last section the memos; their layout is not given.
HWPTAG_PAGE_DEF
| Offset | Type | Field (table 131) |
|---|---|---|
0 | HWPUNIT | Paper width |
4 | HWPUNIT | Paper height |
8 | HWPUNIT | Left margin |
12 | HWPUNIT | Right margin |
16 | HWPUNIT | Top margin |
20 | HWPUNIT | Bottom margin |
24 | HWPUNIT | Header margin |
28 | HWPUNIT | Footer margin |
32 | HWPUNIT | Binding (gutter) margin |
36 | UINT32 | Properties: bit 0 orientation (0 portrait, 1 landscape); bits 1–2 binding (0 one-sided, 1 facing pages, 2 flipped upwards) (table 132) |
An A4 sheet, 210 × 297 mm, is about 59,528 × 84,189 HWPUNIT (210 ÷ 25.4 × 7200 and 297 ÷ 25.4 × 7200).
HWPTAG_FOOTNOTE_SHAPE
| Offset | Type | Field (table 133) |
|---|---|---|
0 | UINT32 | Properties (below) |
4 | WCHAR | User symbol |
6 | WCHAR | Character before the number |
8 | WCHAR | Character after the number |
10 | UINT16 | Start number |
12 | HWPUNIT16 | Separator line length |
14 | HWPUNIT16 | Space above the separator |
16 | HWPUNIT16 | Space below the separator |
18 | HWPUNIT16 | Space between notes |
20 | UINT8 | Separator line type |
21 | UINT8 | Separator line width |
22 | COLORREF | Separator colour |
| Bits | Meaning (table 134) | Values |
|---|---|---|
| 0–7 | Number format | 0–14 as the number formats; 15 갑, 을, 병, 정, 무, 기, 경, 신, 임, 계 (the ten heavenly stems in Hangul); 16 甲, 乙, 丙, 丁, 戊, 己, 庚, 辛, 壬, 癸 (the same in Chinese characters); 0x80 four characters repeated in turn; 0x81 a user character repeated (the last two for notes only) |
| 8–9 | Placement | Footnotes with several columns: 0 under each column, 1 across all columns, 2 in the rightmost column. Endnotes: 0 at the end of the document, 1 at the end of the section |
| 10–11 | Numbering | 0 continue from the previous section, 1 restart in this section, 2 restart on each page (footnotes only) |
| 12 | The number in the note text is superscript | |
| 13 | The notes follow straight after the text |
HWPTAG_PAGE_BORDER_FILL
| Offset | Type | Field (table 135) |
|---|---|---|
0 | UINT32 | Properties (below) |
4 | HWPUNIT16 | Gap, left |
6 | HWPUNIT16 | Gap, right |
8 | HWPUNIT16 | Gap, top |
10 | HWPUNIT16 | Gap, bottom |
12 | UINT16 | Border and fill ID |
The fields take 14 bytes, as the specification’s table 5 says; its table 135 gives 12.
| Bits | Meaning (table 136) | Values |
|---|---|---|
| 0 | Position measured from | 0 the body text, 1 the paper |
| 1 | Include the header | 0 no, 1 yes |
| 2 | Include the footer | 0 no, 1 yes |
| 3–4 | Area to fill | 0 paper, 1 page, 2 border |
Master page information
| Offset | Type | Field (table 137) |
|---|---|---|
0 | HWPUNIT | Width of the text area |
4 | HWPUNIT | Height of the text area |
8 | BYTE | One bit per level: whether the text of that level is referred to |
9 | BYTE | One bit per level: whether the number of that level is referred to |
Followed by the master page’s paragraph list.
Column definition (cold)
Stored in the first paragraph of each run of columns. Table 138:
| Type | Field |
|---|---|
| UINT16 | Properties, bits 0–15 (below) |
| HWPUNIT16 | Gap between columns |
| WORD[cnt] | Width of each column, only when the widths are not all equal |
| UINT16 | Properties, bits 16–31 |
| UINT8 | Column line type |
| UINT8 | Column line width |
| COLORREF | Column line colour |
| Bits | Meaning (table 139) | Values |
|---|---|---|
| 0–1 | Column kind | 0 normal, 1 distributed (balanced), 2 parallel |
| 2–9 | Number of columns, cnt | 1–255 |
| 10–11 | Direction | 0 from the left, 1 from the right, 2 facing pages |
| 12 | All columns the same width |
12 + 2 × cnt bytes. The meaning of bits 16–31 is not given.
Footnote and endnote (fn , en )
A note has no properties of its own, only its paragraph list, but 8 bytes are written after the ID so that no stray values are stored and updates are avoided. Their meaning is not given. How notes look and are numbered comes from the section’s footnote shape.
Automatic number (atno)
| Offset | Type | Field (table 142) |
|---|---|---|
0 | UINT32 | Properties (below) |
4 | UINT16 | Number |
6 | WCHAR | User symbol |
8 | WCHAR | Character before |
10 | WCHAR | Character after |
| Bits | Meaning (table 143) | Values |
|---|---|---|
| 0–3 | What is counted | 0 page, 1 footnote, 2 endnote, 3 figure, 4 table, 5 equation |
| 4–11 | Number format | As the footnote shape’s bits 0–7 |
| 12 | Superscript | Footnotes only: the number in the note text is superscript |
New number (nwno)
Restarts a count from here (table 144): a UINT32 whose bits 0–3 say what is counted, with the same values as the automatic number, then a UINT16 new number. The specification gives the length as 8; the fields take 6.
Hide (pghd)
Hides parts of the current page (table 145). One value, typed UINT but given a length of 2, whose bits say what to hide:
| Value | Hides |
|---|---|
0x01 | Header |
0x02 | Footer |
0x04 | Master page |
0x08 | Border |
0x10 | Background |
0x20 | Page number position |
Odd/even adjustment (pgct)
A UINT32 (table 146) whose bits 0–1 choose the page: 0 both, 1 even page, 2 odd page. The next page is moved so that it falls on that kind of page.
Page number position (pgnp)
| Offset | Type | Field (table 147) |
|---|---|---|
0 | UINT32 | Properties (below) |
4 | WCHAR | User symbol |
6 | WCHAR | Character before |
8 | WCHAR | Character after |
10 | WCHAR | Always - |
| Bits | Meaning (table 148) | Values |
|---|---|---|
| 0–7 | Number format | As the footnote shape’s bits 0–7 |
| 8–11 | Position | 0 no page number, 1 top left, 2 top centre, 3 top right, 4 bottom left, 5 bottom centre, 6 bottom right, 7 top outside, 8 bottom outside, 9 top inside, 10 bottom inside |
Index mark (idxm)
| Type | Field (table 149) |
|---|---|
| WORD + WCHAR[len1] | First keyword for the index |
| WORD + WCHAR[len2] | Second keyword |
| UINT16 | Unused |
Bookmark (bokm)
A bookmark has only its name, which is kept in a control
data record. A bookmark over a block of text is a field instead
(%bmk).
Overlapping characters (tcps)
| Type | Field (table 150) |
|---|---|
| UINT32 | Control ID |
| WORD + WCHAR[len] | The characters to overlap |
| UINT8 | Border type |
| INT8 | Size of the inner characters |
| UINT8 | Spread of the characters inside the border |
| UINT8 | Number of character shape IDs, cnt |
| UINT[cnt] | Character shape IDs of the characters inside the border |
10 + 2 × len + 4 × cnt bytes. The border type values are not listed.
Ruby text (tdut)
Small text set above or below main text (Korean dutmal). Table 151:
| Type | Field | Values |
|---|---|---|
| WORD + WCHAR[len] | Main text | |
| WORD + WCHAR[len] | Ruby (sub) text | |
| UINT | Position | 0 above, 1 below, 2 centre |
| UINT | Size ratio (Fsizeratio) | |
| UINT | Option | Not described |
| UINT | Style number | |
| UINT | Alignment | 0 justified, 1 left, 2 right, 3 centre, 4 distributed, 5 divided (spread at spaces only) |
The specification prints the two texts as single WCHARs with a length before each, and gives a total of 18 bytes; the texts are strings of the stated length.
Hidden comment (tcmt)
Only a paragraph list. Depending on the document’s security level, hidden comment data may be voided.
Field start
Fields start with control character 3 and end with control character 4; the field control’s ID says the kind (see field IDs). Table 152:
| Type | Field |
|---|---|
| UINT32 | Control ID |
| UINT | Properties (below) |
| BYTE | Other properties |
| WORD + WCHAR[len] | Command: the information each kind of field needs (for a hyperlink, its address) |
| UINT32 | ID, unique in the document |
| Bits | Meaning (table 153) | Values |
|---|---|---|
| 0 | Can be edited even when the document is read-only | |
| 11–14 | Character attributes when a hyperlink field is updated | 0x1 link not yet opened, 0x2 link opened, 0x4 link created |
| 15 | The field’s content has been changed |
15 + 2 × len bytes. The command syntax of each field kind is not given.
Sources
- Hangul document file format 5.0, revision 1.3 – Hancom’s specification (PDF, in Korean), sections 4.3.6–4.3.8 and 4.3.10