Esempio n. 1
0
def add_cell_lock(hd, size, data):
    off = add_record(hd, size, data)
    lock_flags = {1: 'locked', 2: 'hidden'}
    (lock, off) = rdata(data, off, '<B')
    add_iter(hd, 'Type', bflag2txt(lock, lock_flags), off - 1, 1, '<B')
    off += 2
    add_range(hd, size, data, off)
Esempio n. 2
0
def add_cell_lock(hd, size, data):
	off = add_record(hd, size, data)
	lock_flags = {1: 'locked', 2: 'hidden'}
	(lock, off) = rdata(data, off, '<B')
	add_iter(hd, 'Type', bflag2txt(lock, lock_flags), off - 1, 1, '<B')
	off += 2
	add_range(hd, size, data, off)
Esempio n. 3
0
def add_row_height(hd, size, data, off):
	(row, off) = rdata(data, off, '<H')
	add_iter(hd, 'Row', format_row(row), off - 2, 2, '<H')
	off += 2
	flags_map = {1: 'visible', 2: 'autofilter'}
	(flags, off) = rdata(data, off, '<H')
	add_iter(hd, 'Flags', bflag2txt(flags, flags_map), off - 2, 2, '<H')
	(height, off) = rdata(data, off, '<H')
	add_iter(hd, 'Height', '%.2fpt' % (height / 20.0), off - 2, 2, '<H')
Esempio n. 4
0
def add_categories(hd, size, data):
    off = add_section(hd, size, data)
    (axis_dir, off) = rdata(data, off, '<B')
    add_iter(hd, 'Reversed axis direction', bool(axis_dir), off - 1, 1, '<B')
    (axis_label, off) = rdata(data, off, '<B')
    add_iter(hd, 'Vertical axis label', bool(axis_label), off - 1, 1, '<B')
    raster_flags = {1: 'fine', 2: 'coarse'}
    (raster, off) = rdata(data, off, '<B')
    add_iter(hd, 'Raster', bflag2txt(raster, raster_flags), off - 1, 1, '<B')
Esempio n. 5
0
def add_categories(hd, size, data):
	off = add_section(hd, size, data)
	(axis_dir, off) = rdata(data, off, '<B')
	add_iter(hd, 'Reversed axis direction', bool(axis_dir), off - 1, 1, '<B')
	(axis_label, off) = rdata(data, off, '<B')
	add_iter(hd, 'Vertical axis label', bool(axis_label), off - 1, 1, '<B')
	raster_flags = {1: 'fine', 2: 'coarse'}
	(raster, off) = rdata(data, off, '<B')
	add_iter(hd, 'Raster', bflag2txt(raster, raster_flags), off - 1, 1, '<B')
Esempio n. 6
0
def add_tile_row(hd, size, data):
	# The IDs point to appropriate data lists (c.f. table model)
	off = 2
	type_map = {0: 'empty', 2: 'number', 3: 'simple text', 5: 'date', 6: 'formula', 7: 'duration', 9: 'paragraph text'}
	(typ, off) = rdata(data, off, '<B')
	add_iter(hd, 'Cell type', key2txt(typ, type_map), off - 1, 1, '<B')
	off += 1
	flags_set = {
		0x2: 'style', 0x4: 'format', 0x8: 'formula',
		0x10: 'simple text', 0x20: 'number', 0x40: 'date',
		0x200: 'paragraph text',
		0xc00: 'conditional format',
		0x1000: 'comment',
	}
	(flags, off) = rdata(data, off, '<H')
	add_iter(hd, 'Flags', bflag2txt(flags, flags_set), off - 2, 2, '<H')
	off += 6

	# NOTE: the order is rather experimental; I originally thought the items are sorted by numeric value of the flag,
	# but apparently that's not the case. Sigh...
	if flags & 0x2:
		(style, off) = rdata(data, off, '<I')
		add_iter(hd, 'Style ID', style, off - 4, 4, '<I')
	if flags & 0xc00:
		(fmt, off) = rdata(data, off, '<I')
		add_iter(hd, 'Conditional format ID', fmt, off - 4, 4, '<I')
		off += 4
	if flags & 0x4:
		(fmt, off) = rdata(data, off, '<I')
		add_iter(hd, 'Format ID', fmt, off - 4, 4, '<I')
	if flags & 0x8:
		(formula, off) = rdata(data, off, '<I')
		add_iter(hd, 'Formula ID', formula, off - 4, 4, '<I')
	if flags & 0x10:
		(text, off) = rdata(data, off, '<I')
		add_iter(hd, 'Simple text ID', text, off - 4, 4, '<I')
	if flags & 0x1000:
		(comment, off) = rdata(data, off, '<I')
		add_iter(hd, 'Comment ID', comment, off - 4, 4, '<I')
	if flags & 0x20:
		(value, off) = rdata(data, off, '<d')
		value_str = value
		if typ == 7:
			value_str = '%.1f s' % value
		add_iter(hd, 'Value', value_str, off - 8, 8, '<d')
	if flags & 0x40:
		(date, off) = rdata(data, off, '<d')
		add_iter(hd, 'Date', date, off - 8, 8, '<d')
	if flags & 0x200:
		(text, off) = rdata(data, off, '<I')
		add_iter(hd, 'Paragraph text ID', text, off - 4, 4, '<I')
Esempio n. 7
0
def get_char_style(flags):
	names = {
		0x1: 'font size',
		0x2: 'bold',
		0x4: 'italic',
		0x8: 'underline type',
		0x10: 'position',
		0x20: 'transform',
		0x40: 'color',
		0x80: 'font',
		0x100: 'letter spacing',
		0x200: 'shaded',
		0x400: 'line-through type',
		0x800: 'outline',
	}
	return bflag2txt(flags, names)
Esempio n. 8
0
def get_char_style(flags):
	names = {
		0x1: 'font size',
		0x2: 'bold',
		0x4: 'italic',
		0x8: 'underline type',
		0x10: 'position',
		0x20: 'transform',
		0x40: 'color',
		0x80: 'font',
		0x100: 'letter spacing',
		0x200: 'shaded',
		0x400: 'line-through type',
		0x800: 'outline',
	}
	return bflag2txt(flags, names)
Esempio n. 9
0
def add_text_attrs(hd, size, data, off):
	(size, off) = rdata(data, off, '<H')
	add_iter(hd, 'Font size', '%d pt' % (size / 20), off - 2, 2, '<H')
	flags_map = {2: 'italic', 8: 'line through',}
	(flags, off) = rdata(data, off, '<H')
	add_iter(hd, 'Flags?', bflag2txt(flags, flags_map), off - 2, 2, '<H')
	(color, off) = rdata(data, off, '<H')
	if color == 0x7fff:
		color_str = "default"
	else:
		color_str = '%d' % color
	# I can see no record that'd look like a palette, though. Maybe it is implicit?
	add_iter(hd, 'Color index', color_str, off - 2, 2, '<H')
	font_weight_map = {400: 'normal', 700: 'bold'}
	(font_weight, off) = rdata(data, off, '<H')
	add_iter(hd, 'Font weight', key2txt(font_weight, font_weight_map), off - 2, 2, '<H')
	off += 2
	(underline, off) = rdata(data, off, '<B')
	add_iter(hd, 'Underline', bool(underline), off - 1, 1, '<B')
	(line_through, off) = rdata(data, off, '<B')
	add_iter(hd, 'Line-through?', line_through, off - 1, 1, '<B')
	off += 2
	add_short_string(hd, size, data, off, 'Font name')
Esempio n. 10
0
def get_para_flags(flags):
	names = {0x8: 'page break', 0x100: 'paragraph break'}
	return bflag2txt(flags, names)
Esempio n. 11
0
def add_frame(hd, size, data):
	off = 0xc
	(sid, off) = rdata(data, off, '<H')
	add_iter(hd, 'Shape ID', sid, off - 2, 2, '<H')
	kind_map = {0x8: 'text', 0xb: 'image', 0xd: 'table', 0xe: 'group', 0xf: 'form control', 0x11: 'shape'}
	(kind, off) = rdata(data, off, '<B')
	add_iter(hd, 'Kind', key2txt(kind, kind_map), off - 1, 1, '<B')
	off += 5
	(above, off) = rdata(data, off, '<H')
	add_iter(hd, 'Is above', key2txt(above, {0xffff: 'none'}, above), off - 2, 2, '<H')
	(below, off) = rdata(data, off, '<H')
	add_iter(hd, 'Is below', key2txt(below, {0xffff: 'none'}, below), off - 2, 2, '<H')
	off += 8
	anchor_map = {
		0x0: 'fixed', 0x1: 'fixed on page',
		0x2: 'floating with paragraph', 0x3: 'floating with column',
		# 0xy: 'floating with character',
		0x4: 'repeated in document', 0x8: 'repeated in chapter',
	}
	anchor_flags = {0x10: 'resize with text', 0x40: 'lock size and position',}
	(anchor, off) = rdata(data, off, '<B')
	add_iter(hd, 'Anchor type', key2txt(anchor & 0xf, anchor_map), off - 1, 1, '<B')
	add_iter(hd, 'Flags', bflag2txt(anchor & 0xf0, anchor_flags), off - 1, 1, '<B')
	off += 3
	# extents
	(left, off) = rdata(data, off, '<I') # TODO: maybe it's <H?
	add_iter(hd, 'Left', '%.2f cm' % to_cm(left), off - 4, 4, '<I')
	(top, off) = rdata(data, off, '<I')
	add_iter(hd, 'Top', '%.2f cm' % to_cm(top), off - 4, 4, '<I')
	(right, off) = rdata(data, off, '<I')
	add_iter(hd, 'Right', '%.2f cm' % to_cm(right), off - 4, 4, '<I')
	(bottom, off) = rdata(data, off, '<I')
	add_iter(hd, 'Bottom', '%.2f cm' % to_cm(bottom), off - 4, 4, '<I')
	# extents with padding
	(left_padding, off) = rdata(data, off, '<I')
	add_iter(hd, 'Left with padding', '%.2f cm' % to_cm(left_padding), off - 4, 4, '<I')
	(top_padding, off) = rdata(data, off, '<I')
	add_iter(hd, 'Top with padding', '%.2f cm' % to_cm(top_padding), off - 4, 4, '<I')
	(right_padding, off) = rdata(data, off, '<I')
	add_iter(hd, 'Right with padding', '%.2f cm' % to_cm(right_padding), off - 4, 4, '<I')
	(bottom_padding, off) = rdata(data, off, '<I')
	add_iter(hd, 'Bottom with padding', '%.2f cm' % to_cm(bottom_padding), off - 4, 4, '<I')
	# borders
	(left_border, off) = rdata(data, off, '<I')
	add_iter(hd, 'Left text frame margin', '%.2f cm' % to_cm(left_border), off - 4, 4, '<I')
	(top_border, off) = rdata(data, off, '<I')
	add_iter(hd, 'Top text frame margin', '%.2f cm' % to_cm(top_border), off - 4, 4, '<I')
	(right_border, off) = rdata(data, off, '<I')
	add_iter(hd, 'Right text frame margin', '%.2f cm' % to_cm(right_border), off - 4, 4, '<I')
	(bottom_border, off) = rdata(data, off, '<I')
	add_iter(hd, 'Bottom text frame margin', '%.2f cm' % to_cm(bottom_border), off - 4, 4, '<I')
	off += 24
	(height, off) = rdata(data, off, '<I')
	add_iter(hd, 'Text frame height', '%.2f cm' % to_cm(height), off - 4, 4, '<I')
	(width, off) = rdata(data, off, '<I')
	add_iter(hd, 'Text frame width', '%.2f cm' % to_cm(width), off - 4, 4, '<I')
	off += 0x30
	wrap_map = {0: 'run-through', 1: 'none', 2: 'parallel'}
	(wrap, off) = rdata(data, off, '<B')
	add_iter(hd, 'Wrap', key2txt(wrap, wrap_map), off - 1, 1, '<B')
	off += 3
	(border_line, off) = rdata(data, off, '<B') # TODO: border line is probably only 1B; change elsewhere
	add_iter(hd, 'Border line', key2txt(border_line, line_map), off - 1, 1, '<B')
	off += 0x13
	(group, off) = rdata(data, off, '<H')
	add_iter(hd, 'Group', key2txt(group & 1, {0: 'none'}, group & 0xfe), off - 2, 2, '<H')
	off += 2
	(border_color, off) = rdata(data, off, '<B') # TODO: apparently color palette index is only 1B; change elsewhere
	add_iter(hd, 'Border color', border_color, off - 1, 1, '<B')
	(shading_color, off) = rdata(data, off, '<B')
	add_iter(hd, 'Shading color', shading_color, off - 1, 1, '<B')
	off += 2
	page_map = {0: 'first', 1: 'odd', 2: 'even', 3: 'all'}
	(page, off) = rdata(data, off, '<B')
	add_iter(hd, 'On page', key2txt(page & 0x3, page_map), off - 1, 1, '<B')
	add_iter(hd, 'Not on first', bool(page & 0x4), off - 1, 1, '<B')
Esempio n. 12
0
		def __call__(self, data, off):
			i = self.parser(data, off)
			return bflag2txt(i, bits)
Esempio n. 13
0
def add_frame(hd, size, data):
	off = 0xc
	(sid, off) = rdata(data, off, '<H')
	add_iter(hd, 'Shape ID', sid, off - 2, 2, '<H')
	kind_map = {0x8: 'text', 0xb: 'image', 0xd: 'table', 0xe: 'group', 0xf: 'form control', 0x11: 'shape'}
	(kind, off) = rdata(data, off, '<B')
	add_iter(hd, 'Kind', key2txt(kind, kind_map), off - 1, 1, '<B')
	off += 5
	(above, off) = rdata(data, off, '<H')
	add_iter(hd, 'Is above', key2txt(above, {0xffff: 'none'}, above), off - 2, 2, '<H')
	(below, off) = rdata(data, off, '<H')
	add_iter(hd, 'Is below', key2txt(below, {0xffff: 'none'}, below), off - 2, 2, '<H')
	off += 8
	anchor_map = {
		0x0: 'fixed', 0x1: 'fixed on page',
		0x2: 'floating with paragraph', 0x3: 'floating with column',
		# 0xy: 'floating with character',
		0x4: 'repeated in document', 0x8: 'repeated in chapter',
	}
	anchor_flags = {0x10: 'resize with text', 0x40: 'lock size and position',}
	(anchor, off) = rdata(data, off, '<B')
	add_iter(hd, 'Anchor type', key2txt(anchor & 0xf, anchor_map), off - 1, 1, '<B')
	add_iter(hd, 'Flags', bflag2txt(anchor & 0xf0, anchor_flags), off - 1, 1, '<B')
	off += 3
	# extents
	(left, off) = rdata(data, off, '<I') # TODO: maybe it's <H?
	add_iter(hd, 'Left', '%.2f cm' % to_cm(left), off - 4, 4, '<I')
	(top, off) = rdata(data, off, '<I')
	add_iter(hd, 'Top', '%.2f cm' % to_cm(top), off - 4, 4, '<I')
	(right, off) = rdata(data, off, '<I')
	add_iter(hd, 'Right', '%.2f cm' % to_cm(right), off - 4, 4, '<I')
	(bottom, off) = rdata(data, off, '<I')
	add_iter(hd, 'Bottom', '%.2f cm' % to_cm(bottom), off - 4, 4, '<I')
	# extents with padding
	(left_padding, off) = rdata(data, off, '<I')
	add_iter(hd, 'Left with padding', '%.2f cm' % to_cm(left_padding), off - 4, 4, '<I')
	(top_padding, off) = rdata(data, off, '<I')
	add_iter(hd, 'Top with padding', '%.2f cm' % to_cm(top_padding), off - 4, 4, '<I')
	(right_padding, off) = rdata(data, off, '<I')
	add_iter(hd, 'Right with padding', '%.2f cm' % to_cm(right_padding), off - 4, 4, '<I')
	(bottom_padding, off) = rdata(data, off, '<I')
	add_iter(hd, 'Bottom with padding', '%.2f cm' % to_cm(bottom_padding), off - 4, 4, '<I')
	# borders
	(left_border, off) = rdata(data, off, '<I')
	add_iter(hd, 'Left text frame margin', '%.2f cm' % to_cm(left_border), off - 4, 4, '<I')
	(top_border, off) = rdata(data, off, '<I')
	add_iter(hd, 'Top text frame margin', '%.2f cm' % to_cm(top_border), off - 4, 4, '<I')
	(right_border, off) = rdata(data, off, '<I')
	add_iter(hd, 'Right text frame margin', '%.2f cm' % to_cm(right_border), off - 4, 4, '<I')
	(bottom_border, off) = rdata(data, off, '<I')
	add_iter(hd, 'Bottom text frame margin', '%.2f cm' % to_cm(bottom_border), off - 4, 4, '<I')
	off += 24
	(height, off) = rdata(data, off, '<I')
	add_iter(hd, 'Text frame height', '%.2f cm' % to_cm(height), off - 4, 4, '<I')
	(width, off) = rdata(data, off, '<I')
	add_iter(hd, 'Text frame width', '%.2f cm' % to_cm(width), off - 4, 4, '<I')
	off += 0x30
	wrap_map = {0: 'run-through', 1: 'none', 2: 'parallel'}
	(wrap, off) = rdata(data, off, '<B')
	add_iter(hd, 'Wrap', key2txt(wrap, wrap_map), off - 1, 1, '<B')
	off += 3
	(border_line, off) = rdata(data, off, '<B') # TODO: border line is probably only 1B; change elsewhere
	add_iter(hd, 'Border line', key2txt(border_line, line_map), off - 1, 1, '<B')
	off += 0x13
	(group, off) = rdata(data, off, '<H')
	add_iter(hd, 'Group', key2txt(group & 1, {0: 'none'}, group & 0xfe), off - 2, 2, '<H')
	off += 2
	(border_color, off) = rdata(data, off, '<B') # TODO: apparently color palette index is only 1B; change elsewhere
	add_iter(hd, 'Border color', border_color, off - 1, 1, '<B')
	(shading_color, off) = rdata(data, off, '<B')
	add_iter(hd, 'Shading color', shading_color, off - 1, 1, '<B')
	off += 2
	page_map = {0: 'first', 1: 'odd', 2: 'even', 3: 'all'}
	(page, off) = rdata(data, off, '<B')
	add_iter(hd, 'On page', key2txt(page & 0x3, page_map), off - 1, 1, '<B')
	add_iter(hd, 'Not on first', bool(page & 0x4), off - 1, 1, '<B')
Esempio n. 14
0
def get_para_flags(flags):
	names = {0x8: 'page break', 0x100: 'paragraph break'}
	return bflag2txt(flags, names)