Ejemplo n.º 1
0
def add_cell(hd, size, data):
    off = add_record(hd, size, data)
    (col, off) = rdata(data, off, '<B')
    add_iter(hd, 'Column', format_column(col), off - 1, 1, '<B')
    (row, off) = rdata(data, off, '<H')
    add_iter(hd, 'Row', format_row(row), off - 2, 2, '<H')
    return (off, col, row)
Ejemplo n.º 2
0
def chop_tag_f533(hd, size, data):
	(rule, off) = rdata(data, 2, '<H')
	rule_map = {0x12: 'horizontal adjustable', 0x14: 'horizontal fixed',
			0x21: 'vertical adjustable', 0x22: 'block adjustable',
			0x41: 'vertical fixed', 0x44: 'block fixed'}
	rule_str = key2txt(int(rule), rule_map)
	add_iter(hd, 'Rule', rule_str, off - 2, 2, '<H')
Ejemplo n.º 3
0
def add_iwa_compressed_block(hd, size, data):
	(length, off) = rdata(data, 1, '<H')
	add_iter(hd, 'Compressed length', length, off - 2, 2, '<H')
	off += 1
	var_off = off
	(ulength, off) = read_var(data, off)
	add_iter(hd, 'Uncompressed length', ulength, var_off, off - var_off, '%ds' % (off - var_off))
Ejemplo n.º 4
0
def add_column_widths(hd, size, data):
    off = add_record(hd, size, data)
    col = 0
    while off < size:
        (width, off) = rdata(data, off, '<B')
        add_iter(hd, 'Column %s' % format_column(col), width, off - 1, 1, '<B')
        col += 1
Ejemplo n.º 5
0
def add_zmf4_obj_text_frame(hd, size, data):
	_zmf4_obj_common(hd, size, data)
	off = 0x1c
	_zmf4_obj_bbox(hd, size, data, off)
	off = 0x88
	(text, off) = rdata(data, off, '<I')
	add_iter(hd, 'Text reference', '0x%x' % text, off - 4, 4, '<I')
Ejemplo n.º 6
0
def add_comment(hd, size, data, off):
	(row, off) = rdata(data, off, '<H')
	add_iter(hd, 'Row', format_row(row), off - 2, 2, '<H')
	(col, off) = rdata(data, off, '<B')
	add_iter(hd, 'Column', format_column(col), off - 1, 1, '<B')
	off += 1
	add_long_string(hd, size, data, off, 'Comment')
Ejemplo n.º 7
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)
Ejemplo n.º 8
0
def add_cell_type(hd, size, data):
    off = add_record(hd, size, data)
    type_map = {0: 'default', 1: 'text'}
    (typ, off) = rdata(data, off, '<B')
    add_iter(hd, 'Type', key2txt(typ, type_map), off - 1, 1, '<B')
    off += 2
    add_range(hd, size, data, off)
Ejemplo n.º 9
0
def add_font(hd, size, data):
	i = 2
	start = i
	while i < len(data) and data[i] != '\0':
		i += 1
	length = i - start
	add_iter(hd, 'Name', data[start:i], start, length, '<%ds' % length)
Ejemplo n.º 10
0
def add_record(hd, size, data):
    off = 0
    (typ, off) = rdata(data, off, '<B')
    add_iter(hd, 'Record type', typ, off - 1, 1, '<B')
    (length, off) = rdata(data, off, '<H')
    add_iter(hd, 'Record length', length, off - 2, 2, '<H')
    return off
Ejemplo n.º 11
0
def add_string(hd, size, data, off, name, fmt):
	fmtlen = struct.calcsize(fmt)
	(length, off) = rdata(data, off, fmt)
	add_iter(hd, '%s length' % name, length, off - fmtlen, fmtlen, fmt)
	(text, off) = rdata(data, off, '%ds' % length)
	add_iter(hd, name, unicode(text, 'cp1250'), off - length, length, '%ds' % length)
	return off
Ejemplo n.º 12
0
def add_alignment(hd, size, data):
    off = add_record(hd, size, data)
    align_map = {0: 'default', 1: 'left', 2: 'center', 3: 'right', 4: 'fill'}
    (align, off) = rdata(data, off, '<B')
    add_iter(hd, 'Alignment', key2txt(align, align_map), off - 1, 1, '<B')
    off += 2
    add_range(hd, size, data, off)
Ejemplo n.º 13
0
def add_string(hd, size, data, off, name, fmt):
	fmtlen = struct.calcsize(fmt)
	(length, off) = rdata(data, off, fmt)
	add_iter(hd, '%s length' % name, length, off - fmtlen, fmtlen, fmt)
	(text, off) = rdata(data, off, '%ds' % length)
	add_iter(hd, name, unicode(text, 'cp1250'), off - length, length, '%ds' % length)
	return off
Ejemplo n.º 14
0
def add_font(hd, size, data):
    off = add_record(hd, size, data)
    font_map = {0: 'normal', 1: 'italic', 2: 'bold', 3: 'high', 4: 'gray'}
    (font, off) = rdata(data, off, '<B')
    add_iter(hd, 'Font', key2txt(font, font_map), off - 1, 1, '<B')
    off += 2
    add_range(hd, size, data, off)
Ejemplo n.º 15
0
def add_cell_type(hd, size, data):
	off = add_record(hd, size, data)
	type_map = {0: 'default', 1: 'text'}
	(typ, off) = rdata(data, off, '<B')
	add_iter(hd, 'Type', key2txt(typ, type_map), off - 1, 1, '<B')
	off += 2
	add_range(hd, size, data, off)
Ejemplo n.º 16
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)
Ejemplo n.º 17
0
def add_font(hd, size, data):
	off = add_record(hd, size, data)
	font_map = {0: 'normal', 1: 'italic', 2: 'bold', 3: 'high', 4: 'gray'}
	(font, off) = rdata(data, off, '<B')
	add_iter(hd, 'Font', key2txt(font, font_map), off - 1, 1, '<B')
	off += 2
	add_range(hd, size, data, off)
Ejemplo n.º 18
0
def add_alignment(hd, size, data):
	off = add_record(hd, size, data)
	align_map = {0: 'default', 1: 'left', 2: 'center', 3: 'right', 4: 'fill'}
	(align, off) = rdata(data, off, '<B')
	add_iter(hd, 'Alignment', key2txt(align, align_map), off - 1, 1, '<B')
	off += 2
	add_range(hd, size, data, off)
Ejemplo n.º 19
0
def add_column_widths(hd, size, data):
	off = add_record(hd, size, data)
	col = 0
	while off < size:
		(width, off) = rdata(data, off, '<B')
		add_iter(hd, 'Column %s' % format_column(col), width, off - 1, 1, '<B')
		col += 1
Ejemplo n.º 20
0
def add_cell(hd, size, data):
	off = add_record(hd, size, data)
	(col, off) = rdata(data, off, '<B')
	add_iter(hd, 'Column', format_column(col), off - 1, 1, '<B')
	(row, off) = rdata(data, off, '<H')
	add_iter(hd, 'Row', format_row(row), off - 2, 2, '<H')
	return (off, col, row)
Ejemplo n.º 21
0
def add_record(hd, size, data):
	off = 0
	(typ, off) = rdata(data, off, '<B')
	add_iter(hd, 'Record type', typ, off - 1, 1, '<B')
	(length, off) = rdata(data, off, '<H')
	add_iter(hd, 'Record length', length, off - 2, 2, '<H')
	return off
Ejemplo n.º 22
0
def add_font(hd, size, data):
	i = 2
	start = i
	while i < len(data) and data[i] != '\0':
		i += 1
	length = i - start
	add_iter(hd, 'Name', data[start:i], start, length, '<%ds' % length)
Ejemplo n.º 23
0
def add_zmf4_obj_text_frame(hd, size, data):
	_zmf4_obj_common(hd, size, data)
	off = 0x1c
	_zmf4_obj_bbox(hd, size, data, off)
	off = 0x88
	(text, off) = rdata(data, off, '<I')
	add_iter(hd, 'Text reference', '0x%x' % text, off - 4, 4, '<I')
Ejemplo n.º 24
0
def add_text(hd, size, data, off, name='Text'):
    (length, off) = rdata(data, off, '<B')
    add_iter(hd, '%s length' % name, length, off - 1, 1, '<B')
    (text, off) = rdata(data, off, '%ds' % length)
    add_iter(hd, name, unicode(text, 'cp852'), off - length, length,
             '%ds' % length)
    return off
Ejemplo n.º 25
0
def add_style_para(hd, size, data):
	off = 0
	(attribs, off) = rdata(data, off, '<H')
	# add_iter(hd, 'Changed attributes', '%s' % get_para_style(attribs), off - 2, 2, '<H')
	off += 2
	(attrset, off) = rdata(data, off, '<H')
	add_iter(hd, 'Attribute set', attrset, off - 2, 2, '<H')
Ejemplo n.º 26
0
def add_packed(hd, size, data, parser, p16=False):
	off = add_field(hd, size, data)
	obj = parser(data, off, 0, size)
	i = 0
	for (v, e) in zip(obj.value, obj.extents):
		add_iter(hd, 'Value %d' % i, v, e[0], e[1] - e[0], '%ds' % (e[1] - e[0]))
		i += 1
Ejemplo n.º 27
0
def add_style_para(hd, size, data):
	off = 0
	(attribs, off) = rdata(data, off, '<H')
	# add_iter(hd, 'Changed attributes', '%s' % get_para_style(attribs), off - 2, 2, '<H')
	off += 2
	(attrset, off) = rdata(data, off, '<H')
	add_iter(hd, 'Attribute set', attrset, off - 2, 2, '<H')
Ejemplo n.º 28
0
def add_table_ref(hd, size, data, off):
	(table, off) = rdata(data, off, '<H')
	if table == 0xffff:
		table_str = 'this'
	else:
		table_str = str(table)
	add_iter(hd, 'Table', table_str, off - 2, 2, '<H')
	return off
Ejemplo n.º 29
0
def chop_tag_f55c(hd, size, data):
	(count, off) = rdata(data, 2, '<H')
	add_iter(hd, 'Page count', count, off - 2, 2, '<H')
	i = 0
	while i != int(count):
		(pid, off) = rdata(data, off, '<I')
		add_iter(hd, 'Page %d' % i, '0x%x' % pid, off - 4, 4, '<I')
		i += 1
Ejemplo n.º 30
0
def add_table_ref(hd, size, data, off):
    (table, off) = rdata(data, off, '<H')
    if table == 0xffff:
        table_str = 'this'
    else:
        table_str = str(table)
    add_iter(hd, 'Table', table_str, off - 2, 2, '<H')
    return off
Ejemplo n.º 31
0
def add_offsets(hd, size, data):
	off = 0
	i = 0
	while off + 4 <= size:
		(offset, off) = rdata(data, off, '<I')
		name = key2txt(i, wt602_section_names, 'Section %d' % i)
		add_iter(hd, name, offset, off - 4, 4, '<I')
		i += 1
Ejemplo n.º 32
0
def add_palette(hd, size, data):
	off = 0
	i = 0
	while off + 4 <= size:
		(color, off) = rdata(data, off, '3s')
		add_iter(hd, 'Color %d (BGR)' % (i + 1), d2hex(color), off - 3, 3, '3s')
		off += 1
		i += 1
Ejemplo n.º 33
0
def add_comment(hd, size, data):
	off = 2
	(comment_len, off) = rdata(data, off, '<I')
	add_iter(hd, 'Comment length', comment_len, off - 4, 4, '<I')
	off += 2
	(comment, off) = rdata(data, off, '%ds' % (comment_len - 1)) # skip trailing 0
	off += 1
	add_iter(hd, 'Comment', comment, off - comment_len, comment_len, '%ds' % comment_len)
Ejemplo n.º 34
0
 def add_iter(self, name, value, offset, length, vtype):
     utils.add_iter(self.hd,
                    name,
                    value,
                    offset,
                    length,
                    vtype,
                    parent=self.iter)
Ejemplo n.º 35
0
def add_page_breaks(hd, size, data, off):
	(count, off) = rdata(data, off, '<H')
	add_iter(hd, 'Number of breaks', count, off - 2, 2, '<H')
	i = 0
	while off + 2 <= size:
		(row, off) = rdata(data, off, '<H')
		add_iter(hd, 'Break before row [%d]' % i, format_row(row), off - 2, 2, '<H')
		i += 1
Ejemplo n.º 36
0
def add_offset_table(hd, size, data, fmt):
    fmtsize = struct.calcsize(fmt)
    n = 0
    off = 0
    while off + fmtsize < size:
        (offset, off) = rdata(data, off, fmt)
        add_iter(hd, "Offset %d" % n, offset, off - fmtsize, fmtsize, fmt)
        n += 1
Ejemplo n.º 37
0
def add_string(hd, size, data):
    off = 0
    (c, off) = rdata(data, off, ">B")
    sz = c & 0xF
    if sz == 0xF:
        (sz, off) = read_int(data, off)
    (string, off) = rdata(data, off, "%ds" % sz)
    add_iter(hd, "Value", string, off - sz, sz, "%ds" % sz)
Ejemplo n.º 38
0
def add_offset_table(hd, size, data, fmt):
    fmtsize = struct.calcsize(fmt)
    n = 0
    off = 0
    while off + fmtsize < size:
        (offset, off) = rdata(data, off, fmt)
        add_iter(hd, 'Offset %d' % n, offset, off - fmtsize, fmtsize, fmt)
        n += 1
Ejemplo n.º 39
0
def chop_tag_f55c(hd, size, data):
    (count, off) = rdata(data, 2, '<H')
    add_iter(hd, 'Page count', count, off - 2, 2, '<H')
    i = 0
    while i != int(count):
        (pid, off) = rdata(data, off, '<I')
        add_iter(hd, 'Page %d' % i, '0x%x' % pid, off - 4, 4, '<I')
        i += 1
Ejemplo n.º 40
0
def add_string(hd, size, data):
    off = 0
    (c, off) = rdata(data, off, '>B')
    sz = c & 0xf
    if sz == 0xf:
        (sz, off) = read_int(data, off)
    (string, off) = rdata(data, off, '%ds' % sz)
    add_iter(hd, 'Value', string, off - sz, sz, '%ds' % sz)
Ejemplo n.º 41
0
def chop_tag_f535(hd, size, data):
    (layout, off) = rdata(data, 2, '<H')
    layout_map = {
        0x41: 'top-to-bottom right-to-left',
        0x34: 'left-to-right top-to-bottom'
    }
    layout_str = key2txt(int(layout), layout_map)
    add_iter(hd, 'Layout', layout_str, off - 2, 2, '<H')
Ejemplo n.º 42
0
def add_attrset_ids(hd, size, data):
	off = 0
	(count, off) = rdata(data, off, '<H')
	add_iter(hd, 'Number of attr. sets', count, off - 2, 2, '<H')
	n = 0
	while off < len(data):
		(id, off) = rdata(data, off, '<H')
		add_iter(hd, 'ID of attr. set %d' % n, id, off - 2, 2, '<H')
		n += 1
Ejemplo n.º 43
0
def add_zmf4_obj_text(hd, size, data):
	_zmf4_obj_common(hd, size, data)
	off = 0x3c
	(count, off) = rdata(data, off, '<I')
	add_iter(hd, 'Length', count, off - 4, 4, '<I')
	off += 8
	length = 2 * int(count)
	(text, off) = rdata(data, off, '%ds' % length)
	add_iter(hd, 'Text', unicode(text, 'utf-16le'), off - length, length, '%ds' % length)
Ejemplo n.º 44
0
def add_toc(hd, size, data):
	off = 0
	i = 1
	while off + 6 <= size:
		(tag, off) = rdata(data, off, '<H')
		add_iter(hd, 'Stream tag %d' % i, key2txt(tag, stream_tags), off - 2, 2, '<H')
		(offset, off) = rdata(data, off, '<I')
		add_iter(hd, 'Offset to %s' % key2txt(tag, stream_tags), offset, off - 4, 4, '<I')
		i += 1
Ejemplo n.º 45
0
def add_named_range(hd, size, data):
	off = add_record(hd, size, data)
	(id, off) = rdata(data, off, '<H')
	add_iter(hd, 'ID', id, off - 2, 2, '<H')
	off = add_text(hd, size, data, off, 'Name')
	(ordinal, off) = rdata(data, off, '<H')
	add_iter(hd, 'Ordinal number', ordinal, off - 2, 2, '<H')
	off += 2
	add_formula(hd, size, data, off)
Ejemplo n.º 46
0
def add_utf16(hd, size, data):
    off = 0
    (c, off) = rdata(data, off, ">B")
    sz = c & 0xF
    if sz == 0xF:
        (sz, off) = read_int(data, off)
    sz = 2 * sz
    (utf16, off) = rdata(data, off, "%ds" % sz)
    add_iter(hd, "Value", unicode(utf16, "utf-16be"), off - sz, sz, "%ds" % sz)
Ejemplo n.º 47
0
def add_named_range(hd, size, data):
    off = add_record(hd, size, data)
    (id, off) = rdata(data, off, '<H')
    add_iter(hd, 'ID', id, off - 2, 2, '<H')
    off = add_text(hd, size, data, off, 'Name')
    (ordinal, off) = rdata(data, off, '<H')
    add_iter(hd, 'Ordinal number', ordinal, off - 2, 2, '<H')
    off += 2
    add_formula(hd, size, data, off)
Ejemplo n.º 48
0
def add_attrset_ids(hd, size, data):
	off = 0
	(count, off) = rdata(data, off, '<H')
	add_iter(hd, 'Number of attr. sets', count, off - 2, 2, '<H')
	n = 0
	while off < len(data):
		(id, off) = rdata(data, off, '<H')
		add_iter(hd, 'ID of attr. set %d' % n, id, off - 2, 2, '<H')
		n += 1
Ejemplo n.º 49
0
def add_utf16(hd, size, data):
    off = 0
    (c, off) = rdata(data, off, '>B')
    sz = c & 0xf
    if sz == 0xf:
        (sz, off) = read_int(data, off)
    sz = 2 * sz
    (utf16, off) = rdata(data, off, '%ds' % sz)
    add_iter(hd, 'Value', unicode(utf16, 'utf-16be'), off - sz, sz, '%ds' % sz)
Ejemplo n.º 50
0
def add_zmf4_obj_text(hd, size, data):
	_zmf4_obj_common(hd, size, data)
	off = 0x3c
	(count, off) = rdata(data, off, '<I')
	add_iter(hd, 'Length', count, off - 4, 4, '<I')
	off += 8
	length = 2 * int(count)
	(text, off) = rdata(data, off, '%ds' % length)
	add_iter(hd, 'Text', unicode(text, 'utf-16le'), off - length, length, '%ds' % length)
Ejemplo n.º 51
0
def add_tile_offsets(hd, size, data):
	off = add_field(hd, size, data)
	n = 0
	while off + 2 <= size:
		(offset, off) = rdata(data, off, '<H')
		offset_str = offset
		if offset == 0xffff:
			offset_str = 'none'
		add_iter(hd, 'Column %d' % n, offset_str, off - 2, 2, '<H')
		n += 1
Ejemplo n.º 52
0
def add_zmf2_polygon(hd, size, data):
	(tl_x, off) = rdata(data, 0, '<I')
	add_iter(hd, 'Top left X?', tl_x, off - 4, 4, '<I')
	(tl_y, off) = rdata(data, off, '<I')
	add_iter(hd, 'Top left Y?', tl_y, off - 4, 4, '<I')
	(br_x, off) = rdata(data, off, '<I')
	add_iter(hd, 'Bottom right X?', br_x, off - 4, 4, '<I')
	(br_y, off) = rdata(data, off, '<I')
	add_iter(hd, 'Bottom right Y?', br_y, off - 4, 4, '<I')
	(points, off) = rdata(data, off, '<I')
	add_iter(hd, 'Number of edges', points, off - 4, 4, '<I')
Ejemplo n.º 53
0
def chop_tag_f548(hd, size, data):
    (pos, off) = rdata(data, 2, '<H')
    pos_map = {
        1: 'bottom left',
        2: 'bottom right',
        3: 'top right',
        4: 'top left',
        5: 'base'
    }
    pos_str = key2txt(int(pos), pos_map)
    add_iter(hd, 'Position', pos_str, off - 2, 2, '<H')
Ejemplo n.º 54
0
def chop_tag_f57a(hd, size, data):
    (mode, off) = rdata(data, 2, '<H')
    mode_map = {
        0x0: 'none',
        0x10: 'solid',
        0x20: 'dashed',
        0x30: 'double',
        0x40: 'dotted'
    }
    mode_str = key2txt(int(mode), mode_map)
    add_iter(hd, 'Mode', mode_str, off - 2, 2, '<H')
Ejemplo n.º 55
0
def add_palette(hd, size, data):
	n = 0
	off = 0
	while off + 4 <= size:
		(blue, off) = rdata(data, off, 'B')
		(green, off) = rdata(data, off, 'B')
		(red, off) = rdata(data, off, 'B')
		off += 1
		add_iter(hd, 'Color %d' % n, 'rgb(%d, %d, %d)' % (red, green, blue), off - 4, 4, '<I')
		n += 1
	assert off == size
Ejemplo n.º 56
0
def add_print_settings(hd, size, data):
	off = 0
	(height, off) = rdata(data, off, '<H')
	add_iter(hd, 'Height', '%d cm' % height, off - 2, 2, '<H')
	(width, off) = rdata(data, off, '<H')
	add_iter(hd, 'Width', '%d cm' % width, off - 2, 2, '<H')
	(rotate, off) = rdata(data, off, '<B')
	add_iter(hd, 'Rotate', bool(rotate), off - 1, 1, '<B')
	(quality, off) = rdata(data, off, '<B')
	add_iter(hd, 'Higher quality', bool(quality), off - 1, 1, '<B')
	(file, off) = rdata(data, off, '<B')
	add_iter(hd, 'Print to file', bool(file), off - 1, 1, '<B')
Ejemplo n.º 57
0
def add_text_info(hd, size, data):
	(flags, off) = rdata(data, 0, '<H')
	add_iter(hd, 'Flags', '%x' % flags, off - 2, 2, '<H')
	off += 2
	(para_flags, off) = rdata(data, off, '<H')
	add_iter(hd, 'Text flags', '%s' % get_para_flags(para_flags), off - 2, 2, '<H')
	off += 4
	(attrset, off) = rdata(data, off, '<H')
	add_iter(hd, 'Attribute set ID', attrset, off - 2, 2, '<H')
	(attribs, off) = rdata(data, off, '<H')
	add_iter(hd, 'Changed attributes', '%s' % get_char_style(attribs), off - 2, 2, '<H')
	(length, off) = rdata(data, off, '<H')
	add_iter(hd, 'Length', length, off - 2, 2, '<H')