summaryrefslogtreecommitdiffstats
path: root/word_file_fmt.h
blob: 61e13fae2e5586e35a6779988ef84c5af8557cde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#ifndef _WORD_FILE_FMT_H
#define _WORD_FILE_FMT_H

#include <stdint.h>

/* Header file defining common data structures of MS Word for DOS file format
 * (C) 2011 by Harald Welte <laforge@gnumonks.org>
 * 
 * largely based on http://www.msxnet.org/word2rtf/formats/ffh-dosword5
 * Chapter 16 of Dr. Dobbs File Format Handbook */

struct word_file_hdr {
	uint8_t		magic[4];
	uint8_t		reserved[8];
	uint16_t	reserved2;
	uint32_t	ptr_end_of_text;
	uint16_t	bptr_fmt_para;
	uint16_t	bptr_footnote;
	uint16_t	bptr_fmt_sect;
	uint16_t	bptr_nation;
	uint16_t	bptr_page_breaks;
	uint16_t	bptr_file_mgr_info;
	uint8_t		print_format[66];
	uint16_t	win_write_flag;
	uint8_t		printer_drvr[8];
	uint16_t	num_blks_used;
	uint16_t	corrected_text;
	uint8_t		reserved3[18];
} __attribute__ ((packed));

struct word_fmt_entry {
	uint32_t	ptr_text;	/* pointer to first character in different fmt */
	uint16_t	offset_fmt;	/* pointer to format definition */
} __attribute__ ((packed));

struct word_char_fmt {
	uint8_t		length;
	uint8_t		coding_print_tmpl;
	uint8_t		fmt_code;	/* format code */
	uint8_t		font_size;	/* 1/2 point */
	uint8_t		char_attr;	/* character attributes */
	uint8_t		reserved;
	uint8_t		char_pos;	/* superscript, subscript, ... */
} __attribute__ ((packed));

struct word_par_fmt {
	uint8_t		length;
	uint8_t		fmt_code;
	uint8_t		par_align:2,
			par_same_page:1,
			par_next_same_page:1,
			par_two_columns:1,
			par_reserved:3;
	uint8_t		std_par_fmt;
	uint8_t		heading_lvl;
	uint16_t	indent_right;
	uint16_t	indent_left;
	uint16_t	indent_left_first;
	uint16_t	line_space;
	uint16_t	heading_space;
	uint16_t	end_space;
	uint8_t		frame_lines:2,
			frame_type:2,
			hdr_ftr_1st_page:1,
			hdr_ftr_even_page:1,
			hdr_ftr_odd_page:1,
			footer:1,
			header:1;
	uint32_t	line_position;
	uint32_t	reserved;
	uint8_t		tab_descr[80];
} __attribute__ ((packed));

extern const uint8_t word_file_magic[];

#define WORD_BLOCK_SIZE		0x80

#endif /* _WORD_FILE_FMT_H */