Esempio n. 1
0
	def update(self):
		mcfg = find_chunk(self.childs, 'mcfg')
		data = mcfg.chunk
		offset = 12
		if self.version == CDR7: offset = 8
		if self.version == CDR6: offset = 36
		if self.version == CDR13: offset = 20
		self.page_width = parse_size_value(data[offset:offset + 4])
		mcfg.cache_fields.append((offset, 4, 'page width'))
		self.page_height = parse_size_value(data[offset + 4:offset + 8])
		mcfg.cache_fields.append((offset + 4, 4, 'page height'))
Esempio n. 2
0
def parse_ellipse(obj):
	data = obj.loda.chunk
	offset = 108
	for item in obj.loda.data_list:
		if item[0] == const.DATA_COORDS:
			offset = item[1] + 8

	#Ellipse size 
	w = parse_size_value(data[offset:offset + 4])
	h = parse_size_value(data[offset + 4:offset + 8])
	obj.ellipse_size = [w, h]
	obj.loda.cache_fields.append((offset, 8, 'ellipse size'))

	#Ellipse angles
	start = math.radians(long2py_float(data[offset + 8:offset + 12]) / 1000000.0)
	end = math.radians(long2py_float(data[offset + 12:offset + 16]) / 1000000.0)
	rot = math.radians(long2py_float(data[offset + 16:offset + 20]) / 1000000.0)
	obj.ellipse_angles = [start, end, rot]
	obj.loda.cache_fields.append((offset + 8, 12, 'ellipse angles'))
Esempio n. 3
0
def parse_rectangle(obj):
	data = obj.loda.chunk[8:]
	offset = 100
#		if self.version == CDR6: offset = 96

	for item in obj.loda.data_list:
		if item[0] == const.DATA_COORDS:
			offset = item[1]

	#Rectangle size 
	w = parse_size_value(data[offset:offset + 4])
	h = parse_size_value(data[offset + 4:offset + 8])
	obj.rect_size = [w, h]
	obj.loda.cache_fields.append((offset + 8, 8, 'rect size'))

	#Radiuses of rectangle angles
	r1 = r2 = r3 = r4 = parse_size_value(data[offset + 8:offset + 12])
	if obj.version in [CDR6, CDR7]:
		obj.loda.cache_fields.append((offset + 16, 4, 'radius of angles'))
	else:
		r2 = parse_size_value(data[offset + 12:offset + 16])
		r3 = parse_size_value(data[offset + 16:offset + 20])
		r4 = parse_size_value(data[offset + 20:offset + 24])
		obj.loda.cache_fields.append((offset + 16, 16, 'radiuses of angles'))
	obj.radiuses = [r1, r2, r3, r4]
Esempio n. 4
0
	def update(self):
		self.stroke_id = str(self.chunk[8:12].encode('hex'))
		self.cache_fields.append((8, 4, 'outline id'))

		data = self.chunk[8:]

		ls_offset = 4
		lc_offset = 6
		ct_offset = 8
		lw_offset = 12
		offset = 28
		dash_offset = 104

		if self.version == CDR13:
			ls_offset = 24
			lc_offset = 26
			ct_offset = 28
			lw_offset = 30
			offset = 40
			dash_offset = 116

		self.stroke_spec = ord(data[ls_offset])
		self.cache_fields.append((ls_offset + 8, 1, 'outline specification'))

		self.stroke_caps = ord(data[lc_offset])
		self.cache_fields.append((lc_offset + 8, 1, 'outline caps'))

		self.stroke_join = ord(data[ct_offset])
		self.cache_fields.append((ct_offset + 8, 1, 'outline corners'))

		self.stroke_width = parse_size_value(data[lw_offset:lw_offset + 4])
		self.cache_fields.append((lw_offset + 8, 1, 'outline width'))

		dashnum = word2py_int(data[dash_offset:dash_offset + 2])
		self.cache_fields.append((dash_offset + 8, 2, 'number of dash records'))

		if dashnum > 0:
			self.stroke_dashes = range(dashnum)
			for i in self.stroke_dashes:
				dash = word2py_int(data[dash_offset + 2 + i * 2:dash_offset + 4 + i * 2])
				self.stroke_dashes[i] = dash
			self.cache_fields.append((dash_offset + 10, 2 * dashnum, 'dash records'))

		offset += 0x30
		self.color_space_type = ord(data[offset])
		self.cache_fields.append((offset + 8, 1, 'color space type'))

		offset += 16
		self.stroke_color = parse_cdr_color(self.color_space_type, self.chunk[offset:offset + 4])
		if self.stroke_color:
			self.cache_fields.append((offset, 4, 'color value'))
Esempio n. 5
0
	def update(self):
		CdrGraphObj.update(self)
		data = self.loda.chunk
		offset = 108

		for item in self.loda.data_list:
			if item[0] == const.DATA_COORDS:
				offset = item[1] + 8

		self.paths = []
		path = []
		points = []
		point1 = []
		point2 = []

		pointnum = dword2py_int(data[offset:offset + 4])
		self.num_of_points = pointnum
		self.loda.cache_fields.append((offset, 4, 'num of points'))
		self.loda.cache_fields.append((offset + 4, 8 * pointnum, 'curve points'))
		self.loda.cache_fields.append((offset + 4 + pointnum * 8, pointnum, 'point flags'))

		for i in range (pointnum):
			x = parse_size_value(data[offset + 4 + i * 8:offset + 8 + i * 8])
			y = parse_size_value(data[offset + 8 + i * 8:offset + 12 + i * 8])

			point_type = ord(data[offset + 4 + pointnum * 8 + i])
			if point_type & 0x10 == 0 and point_type & 0x20 == 0:
				marker = NODE_CUSP
			if point_type & 0x10 == 0x10:
				marker = NODE_SMOOTH
			if point_type & 0x20 == 0x20:
				marker = NODE_SYMMETRICAL

			if point_type & 0x40 == 0 and point_type & 0x80 == 0:
				if path:
					path.append(deepcopy(points))
					path.append(CURVE_OPENED)
					self.paths.append(deepcopy(path))
				path = []
				points = []
				point1 = []
				point2 = []
				path.append([x, y])
			if point_type & 0x40 == 0x40 and point_type & 0x80 == 0:
				points.append([x, y])
				point1 = []
				point2 = []
			if point_type & 0x40 == 0 and point_type & 0x80 == 0x80:
				points.append(deepcopy([point1, point2, [x, y], marker]))
				point1 = []
				point2 = []
			if point_type & 0x40 == 0x40 and point_type & 0x80 == 0x80:
				if point1:
					point2 = [x, y]
				else:
					point1 = [x, y]
			if point_type & 8 == 8:
				if path and points:
					path.append(deepcopy(points))
					path.append(CURVE_CLOSED)
					self.paths.append(deepcopy(path))
					path = []
					points = []
		if path:
			path.append(deepcopy(points))
			path.append(CURVE_OPENED)
			self.paths.append(deepcopy(path))