Tables, equations, pictures, OLE objects, drawings and groups are controls that carry the common object properties: where the object sits, how text flows round it, its size. Drawings, pictures, OLE objects and groups also have a shape component with their transformation. This page follows Hancom’s HWP 5.0 specification, revision 1.3, section 4.3.9, with its table numbers. Lengths are in HWPUNIT (1/7200 inch); drawing coordinates are in the object’s own coordinate system.
Object controls
| Object | Control ID (table 67) | Common properties | Shape component |
|---|---|---|---|
| Table | tbl | Yes | No |
| Line, rectangle, ellipse, arc, polygon, curve | $lin, $rec, $ell, $arc, $pol, $cur | Yes | Yes |
| Equation (Hangul 97 equation) | eqed | Yes | No |
| Picture | $pic | Yes | Yes |
| OLE object | $ole | Yes | Yes |
| Group (container) | $con | Yes | Yes |
The drawing objects, pictures, OLE objects and groups are generic shape objects: the
specification says their ID is written twice. pyhwp reads gso as
the ID in the control header and the specific ID ($pic and so on) at the
start of the shape component. The records nest like this:
CTRL_HEADER 'gso ' level 1 common object properties (+ caption)
SHAPE_COMPONENT level 2 '$rec', element properties, line, fill, text box
LIST_HEADER level 3 (text box only) and its paragraphs
SHAPE_COMPONENT_RECTANGLE level 3 the shape's own fields
CTRL_HEADER 'tbl ' level 1 common object properties
TABLE level 2 table properties
LIST_HEADER + cell properties level 2 one per cell, followed by its paragraphs
Common object properties
The data of the object’s CTRL_HEADER (table 69), followed by a caption
list if the object has a caption (table 68).
| Offset | Type | Field |
|---|---|---|
0 | UINT32 | Control ID |
4 | UINT32 | Properties (below) |
8 | HWPUNIT | Vertical offset |
12 | HWPUNIT | Horizontal offset |
16 | HWPUNIT | Width |
20 | HWPUNIT | Height |
24 | INT32 | Z-order |
28 | HWPUNIT16[4] | Outside margins on the four sides |
36 | UINT32 | Instance ID, unique to the object in the document |
40 | INT32 | Prevent page breaks: 1 on, 0 off |
44 | WORD + WCHAR[len] | Description of the object (alternative text) |
46 + 2 × len bytes.
| Bits | Meaning (table 70) | Values |
|---|---|---|
| 0 | Treat as a character (inline) | |
| 1 | Reserved | |
| 2 | Affects the line spacing | |
| 3–4 | Vertical position relative to (VertRelTo) | 0 paper, 1 page, 2 paragraph |
| 5–7 | Vertical alignment against it | With paper or page: 0 top, 1 centre, 2 bottom, 3 inside, 4 outside. Otherwise 0 is printed as left and 2 as right |
| 8–9 | Horizontal position relative to (HorzRelTo) | 0 page (printed twice; presumably paper), 1 page, 2 column, 3 paragraph |
| 10–12 | Horizontal alignment against it | As bits 5–7 (left, centre, right, inside, outside) |
| 13 | With VertRelTo paragraph, keep the object inside the body area | 0 off, 1 on |
| 14 | Allow overlap with other objects | Always treated as false when bit 13 keeps it in the body |
| 15–17 | Width relative to | 0 paper, 1 page, 2 column, 3 paragraph, 4 absolute |
| 18–19 | Height relative to | 0 paper, 1 page, 2 absolute |
| 20 | With VertRelTo paragraph, protect the size | 0 off, 1 on |
| 21–23 | Text wrapping | 0 Square (round the bounding box), 1 Tight (round the outline), 2 Through (into empty space inside), 3 TopAndBottom (no text beside it), 4 BehindText, 5 InFrontOfText |
| 24–25 | Which side text goes | 0 both sides, 1 left only, 2 right only, 3 the larger side only |
| 26–28 | Numbering category | 0 none, 1 figure, 2 table, 3 equation |
Caption
A caption is a list header followed by these fields (tables 71 and 72), then its paragraphs:
| Offset | Type | Field |
|---|---|---|
0 | UINT32 | Properties: bits 0–1 side, 0 left, 1 right, 2 top, 3 bottom; bit 2 the caption width includes the margin (left and right captions only) (table 73) |
4 | HWPUNIT | Caption width (left and right captions only) |
8 | HWPUNIT16 | Gap between caption and frame |
10 | HWPUNIT | Maximum text length (the object’s width) |
14 bytes; the specification’s table 71 counts 12.
HWPTAG_TABLE
| Offset | Type | Field (table 75) |
|---|---|---|
0 | UINT32 | Properties: bits 0–1 splitting at a page boundary, 0 do not split, 1 split by cell, 2 printed as “do not split” too; bit 2 repeat the header row automatically (table 76) |
4 | UINT16 | Number of rows, r |
6 | UINT16 | Number of columns |
8 | HWPUNIT16 | Cell spacing |
10 | HWPUNIT16[4] | Inner margins: left, right, top, bottom (table 77) |
18 | UINT16[r] | Row sizes, one per row |
| 18 + 2r | UINT16 | Border and fill ID |
| 20 + 2r | UINT16 | Number of zones, z (from version 5.0.1.0) |
| 22 + 2r | 10 bytes × z | Zones (from 5.0.1.0): each start column, start row, end column, end row and border and fill ID, all UINT16 (table 78) |
22 + 2r + 10z bytes. The meaning of the row sizes is not spelt out;
pyhwp names the array rowcols (cells per row), and reads the zones from
version 5.0.0.7.
Cells
Each cell is a list header whose record goes on with these 26 bytes (tables 79 and 80), followed by the cell’s paragraphs:
| Offset | Type | Field |
|---|---|---|
0 | UINT16 | Column address, 0 for the leftmost cell |
2 | UINT16 | Row address, 0 for the top row |
4 | UINT16 | Columns merged (column span) |
6 | UINT16 | Rows merged (row span) |
8 | HWPUNIT | Cell width |
12 | HWPUNIT | Cell height |
16 | HWPUNIT16[4] | Cell margins on the four sides |
24 | UINT16 | Border and fill ID |
HWPTAG_SHAPE_COMPONENT
Every drawing object (table 81) is its element properties, then an 11-byte line, then fill information, then, if it holds text, a 12-byte text box with a list header: 23 + n + n2 bytes. The element properties start with the object’s UINT32 control ID (table 82), then (table 83):
| Offset | Type | Field |
|---|---|---|
0 | INT32 | X offset inside the group it belongs to |
4 | INT32 | Y offset inside the group |
8 | WORD | How many times it has been grouped |
10 | WORD | Local file version of the element |
12 | UINT32 | Width when created |
16 | UINT32 | Height when created |
20 | UINT32 | Current width |
24 | UINT32 | Current height |
28 | UINT32 | Properties: bit 0 flipped horizontally, bit 1 flipped vertically |
32 | HWPUNIT16 | Rotation angle |
34 | INT32 | Rotation centre X |
38 | INT32 | Rotation centre Y |
42 | bytes | Rendering information |
Rendering information
| Type | Field (table 84) |
|---|---|
| WORD | Number of scale and rotation pairs, cnt: 1 at first, one more each time the object is grouped, one less each time it is ungrouped |
| 48 bytes | Translation matrix |
| cnt × 96 bytes | Pairs of a scale matrix and a rotation matrix |
Each matrix is a 3 × 3 matrix of doubles whose last row is always 0, 0, 1, so only the first two rows are stored: six 8-byte doubles (table 85). 50 + 96 × cnt bytes. The order of the six elements is not stated.
Line
| Offset | Type | Field (table 86) |
|---|---|---|
0 | COLORREF | Line colour |
4 | INT16 | Line width |
6 | UINT32 | Properties (below) |
10 | BYTE | Outline style: 0 normal, 1 outer, 2 inner (table 88) |
| Bits | Meaning (table 87) | Values |
|---|---|---|
| 0–5 | Line type | A line type |
| 6–9 | Line end | 0 round, 1 flat; round is the default for pictures, flat for drawings |
| 10–15 | Arrow at the start | 0 none, 1 arrow, 2 concave arrow, 3 hollow diamond, 4 hollow circle, 5 hollow square, 6 filled diamond, 7 filled circle, 8 filled square |
| 16–21 | Arrow at the end | |
| 22–25 | Start arrow size | Width-length: 0 small-small, 1 small-medium, 2 small-large, 3 medium-small, 4 medium-medium, 5 medium-large, 6 large-small, 7 large-medium, 8 printed again as large-medium (presumably large-large) |
| 26–29 | End arrow size | |
| 30 | Fill the start arrow | |
| 31 | Fill the end arrow |
Text box
| Offset | Type | Field (tables 89 and 90) |
|---|---|---|
0 | HWPUNIT16 | Left margin of the text |
2 | HWPUNIT16 | Right margin |
4 | HWPUNIT16 | Top margin |
6 | HWPUNIT16 | Bottom margin |
8 | HWPUNIT | Maximum width of the text (usually the object’s width) |
12 | bytes | List header, then the paragraphs |
Drawing shapes
Each shape’s own record is a child of its shape component.
HWPTAG_SHAPE_COMPONENT_LINE
| Offset | Type | Field (table 92) |
|---|---|---|
0 | INT32 | Start X |
4 | INT32 | Start Y |
8 | INT32 | End X |
12 | INT32 | End Y |
16 | UINT16 | A flag that corrects the direction: a line first drawn exactly vertical or horizontal is always taken as pointing right (or up) |
HWPTAG_SHAPE_COMPONENT_RECTANGLE
| Offset | Type | Field (table 94) |
|---|---|---|
0 | BYTE | Corner rounding in percent: 0 square corners, 20 rounded, 50 semicircular ends, other values as needed |
1 | INT32[4] | X of the four corners |
17 | INT32[4] | Y of the four corners |
HWPTAG_SHAPE_COMPONENT_ELLIPSE
| Offset | Type | Field (table 96) |
|---|---|---|
0 | UINT32 | Properties (below) |
4 | INT32 × 2 | Centre X, Y |
12 | INT32 × 2 | First axis X, Y |
20 | INT32 × 2 | Second axis X, Y |
28 | INT32 × 2 | Start position X, Y |
36 | INT32 × 2 | End position X, Y |
44 | INT32 × 2 | Second start position X, Y: the interval of the curve, used only when the ellipse has become an arc |
52 | INT32 × 2 | Second end position X, Y |
Properties (table 97): bit 0 the interval (the distance between two points on the circle) must be recalculated when it becomes an arc; bit 1 it has become an arc; bits 2–9 the kind of arc (values not listed).
HWPTAG_SHAPE_COMPONENT_ARC
| Offset | Type | Field (table 101) |
|---|---|---|
0 | UINT32 | Properties (the specification points at table 92; the ellipse and arc properties of table 97 are meant) |
4 | INT32 × 2 | Centre of the ellipse X, Y |
12 | INT32 × 2 | First axis X, Y |
20 | INT32 × 2 | Second axis X, Y |
HWPTAG_SHAPE_COMPONENT_POLYGON
An INT16 number of points cnt, then INT32[cnt] X coordinates, then INT32[cnt] Y coordinates: 2 + 8 × cnt bytes (table 99).
HWPTAG_SHAPE_COMPONENT_CURVE
As the polygon, then BYTE[cnt − 1] segment types, one per segment: 0 straight line, 1 curve (table 103).
HWPTAG_EQEDIT
The equation control eqed has the common object properties and this
record (table 105):
| Type | Field |
|---|---|
| UINT32 | Properties: bit 0 set, the script covers whole lines; clear, it is measured in characters |
| WORD + WCHAR[len] | The equation script |
| HWPUNIT | Character size |
| COLORREF | Text colour |
| INT16 | Baseline |
| WCHAR[len] | Equation version information |
| WCHAR[len] | Equation font name |
The script language is compatible with EQN scripts; Hancom describes it in a separate equation specification, not covered here. The version and font strings are probably each preceded by their own length, as the total 16 + 6 × len suggests, but the table does not show it.
HWPTAG_SHAPE_COMPONENT_PICTURE
A picture is the common properties, the shape component and this record (tables 106 and 107):
| Offset | Type | Field |
|---|---|---|
0 | COLORREF | Border colour |
4 | INT32 | Border width |
8 | UINT32 | Border properties, as the line properties |
12 | INT32[4] | X of the picture’s border rectangle (its size when first inserted) |
28 | INT32[4] | Y of that rectangle |
44 | INT32 | Crop rectangle, left |
48 | INT32 | Crop rectangle, top |
52 | INT32 | Crop rectangle, right |
56 | INT32 | Crop rectangle, bottom |
60 | HWPUNIT16[4] | Inner margins (default 141 for tables, 0 for pictures) |
68 | 5 bytes | Picture information: brightness, contrast, effect, BinData ID |
73 | BYTE | Border transparency |
74 | UINT32 | Instance ID |
78 | bytes | Picture effects |
Table 116 adds further picture properties: HWPUNIT × 2, the size of the image when the picture was created, and an INT8 image transparency, 9 bytes. Where they sit in the record is not stated.
Picture effects
A UINT32 saying which effects are present – shadow, glow (“neon”), soft edge and reflection – then each present effect (table 108). The bit for each effect is not given.
| Effect | Fields, in order |
|---|---|
| Shadow (table 109) | INT32 style; float transparency, blur, direction, distance; INT32 alignment; float skew angle X, skew angle Y, scale X, scale Y; INT32 rotate with the shape; colour. 44 + n bytes |
| Glow (table 110) | float transparency, radius; colour. 8 + n bytes |
| Soft edge (table 111) | float radius. 4 bytes |
| Reflection (table 112) | INT32 style; float radius, direction, distance, skew angle X, skew angle Y, scale X, scale Y; INT32 rotation style; float start transparency, start position, end transparency, end position, offset direction. 56 bytes (printed as 53) |
The shadow’s fields are typed in the order INT32, then four floats, INT32, four floats, INT32, colour.
Colour
| Type | Field (table 113) |
|---|---|
| INT32 | Colour type |
| UINT32 | RGB, 0x00RRGGBB (not the COLORREF order) |
| UINT32 | CMYK, 0xCCMMYYKK |
| INT32 | Scheme colour type |
| INT32 | System colour type |
| INT32 | Preset colour type |
| float × 3 | scR, scG, scB |
| float × 3 | Hue, saturation, luminance |
| UINT32 | Number of colour effects, n |
| 8 × n bytes | Colour effects: INT32 kind, float value (table 114) |
The total is given as 4 + m (4 to 12) + n, which suggests that only the fields for the colour type are stored; the specification does not say which, nor list the colour type values.
| Kind | Effect (table 115) | Kind | Effect |
|---|---|---|---|
| 0 | alpha | 14 | hue_off |
| 1 | alpha_mod | 15 | sat |
| 2 | alpha_off | 16 | sat_mod |
| 3 | red | 17 | sat_off |
| 4 | red_mod | 18 | lum |
| 5 | red_off | 19 | lum_mod |
| 6 | green | 20 | lum_off |
| 7 | green_mod | 21 | shade |
| 8 | green_off | 22 | tint |
| 9 | blue | 23 | gray |
| 10 | blue_mod | 24 | comp |
| 11 | blue_off | 25 | gamma |
| 12 | hue | 26 | inv_gamma |
| 13 | hue_mod | 27 | inv |
HWPTAG_SHAPE_COMPONENT_OLE
| Offset | Type | Field (table 118) |
|---|---|---|
0 | UINT16 | Properties (below) |
2 | INT32 | Extent X of the object itself |
6 | INT32 | Extent Y |
10 | UINT16 | BinData ID of the storage the object uses |
12 | COLORREF | Border colour |
16 | INT32 | Border width |
20 | UINT32 | Border properties, as the line properties |
| Bits | Meaning (table 119) | Values |
|---|---|---|
| 0–7 | Draw aspect (MFC COleClientItem::m_nDrawAspect) | 1 DVASPECT_CONTENT, 2 DVASPECT_THUMBNAIL, 4 DVASPECT_ICON, 8 DVASPECT_DOCPRINT |
| 8 | A moniker is assigned (m_bMoniker) | |
| 9–15 | Baseline | 0 the default (85%), 1–101 mean 0–100%; at present only equations have their own baseline |
| 16–21 | Object kind | 0 unknown, 1 embedded, 2 link, 3 static, 4 equation |
The properties are typed UINT16, but bits 16–21 need a wider field; how they are stored is not explained.
Charts
A chart is stored in the text as an OLE object; its contents are an OLE compound file whose top storage can hold two streams:
Contents– Hangul’s own chart format, the only stream in charts from Hangul Neo and older. Hancom describes it in a separate chart specification (in Korean): a sequence of chart objects, each alongID, alongstored type ID, the stored name (char*) and stored version (int) – left out when the same type ID has already appeared – and the object’s data, which may contain further chart objects. The tree starts at aVtChartobject with Backdrop, DataGrid, Footnote, Legend, Plot, PrintInformation and Title objects; the chart specification lists the properties of 63 object types and 52 tables of constants.OOXMLChartContents– from Hangul 2018, an Office Open XML chart: the root element ischartSpace, as in the DrawingML chart part of ECMA-376 and ISO/IEC 29500. Hangul 2018 also writesContentsas a fallback, converted to the old chart format.
The HWPTAG_CHART_DATA record is 2 bytes; its meaning is not given. The
chart objects, their properties and constants are on the
charts page.
HWPTAG_SHAPE_COMPONENT_CONTAINER
A group (table 120) is the common properties, then a WORD number of objects n and UINT32[n] control IDs of the grouped objects (table 121), then the shape records of each object in turn. Drawing objects, OLE objects, pictures and other groups can be grouped.
HWPTAG_VIDEO_DATA
A video (the specification heads it HWPTAG_VIDEO_TDATA) is the common
properties and (table 123) an INT32 video type, 0 local or 1 web (table 124), then:
| Type | Field |
|---|---|
| Local video (table 125) | |
| UINT16 | BinData ID of the video file |
| UINT16 | BinData ID of the thumbnail |
| Web video (table 126) | |
| WCHAR[len] | The web tag (the embed code) |
| UINT16 | BinData ID of the thumbnail |
The file header’s bit 16 says a document contains video controls.
Not described
Text art (HWPTAG_SHAPE_COMPONENT_TEXTART), form objects
(HWPTAG_FORM_OBJECT), memo list headers (HWPTAG_MEMO_LIST)
and HWPTAG_SHAPE_COMPONENT_UNKNOWN (36 bytes) are named in the
specification without a layout; their fields are unknown here.
Sources
- Hangul document file format 5.0, revision 1.3 – Hancom’s specification (PDF, in Korean), section 4.3.9
- Hangul document file format: charts, revision 1.2 – Hancom’s chart specification (PDF, in Korean)
- pyhwp – open-source reader, for the control ID of generic shapes (Python)