예제 #1
0
    def translate(self, sk2_doc, wmf_doc):
        self.wmf_doc = wmf_doc
        self.sk2_doc = sk2_doc
        self.sk2_mt = sk2_doc.model
        self.sk2_mtds = sk2_doc.methods
        self.wmf_records = []
        self.wmf_objs = []
        self.latest_objs = []

        page = self.sk2_mtds.get_page()
        left, bottom, right, top = self.sk2_mtds.count_bbox(page.childs)
        width = right - left
        height = top - bottom

        self.inch = INCH
        x = max(width, height)
        if x * (INCH / 72.0) > 0xFFFF / 2:
            self.inch = 0xFFFF / (2 * x)
        self.scale = coef = self.inch / 72.0
        self.trafo = [coef, 0, 0, -coef, -coef * left, coef * top]
        self.bbox = self.point4wmf([left, bottom]) + self.point4wmf(
            [right, top])

        self.add(wmf_model.set_window_org(self.bbox[0], self.bbox[3]))
        self.add(wmf_model.set_window_ext(self.bbox[2], self.bbox[1]))
        self.add(wmf_model.set_bkmode(wmf_const.TRANSPARENT))
        self.add(wmf_model.set_bkcolor([
            1.0,
        ] * 3))
        self.add(wmf_model.set_rop2(wmf_const.R2_COPYPEN))
        self.add(wmf_model.set_polyfillmode(wmf_const.ALTERNATE))

        for layer in page.childs:
            if self.sk2_mtds.is_layer_visible(layer):
                self.translate_objs(layer.childs)

        self.add(wmf_model.get_eof_rec())

        filesize, maxrecord = self.count_record_size()
        filesize += 18
        numobjs = len(self.wmf_objs)
        header = wmf_model.get_wmf_header(filesize, numobjs, maxrecord)
        header.childs = self.wmf_records
        placeable = wmf_model.get_placeble_header(self.bbox, self.inch)
        placeable.childs = [
            header,
        ]
        self.wmf_doc.model = placeable
예제 #2
0
	def translate(self, sk2_doc, wmf_doc):
		self.wmf_doc = wmf_doc
		self.sk2_doc = sk2_doc
		self.sk2_mt = sk2_doc.model
		self.sk2_mtds = sk2_doc.methods
		self.wmf_records = []
		self.wmf_objs = []
		self.latest_objs = []

		page = self.sk2_mtds.get_page()
		left, bottom, right, top = self.sk2_mtds.count_bbox(page.childs)
		width = right - left
		height = top - bottom

		self.inch = INCH
		x = max(width, height)
		if x * (INCH / 72.0) > 0xFFFF / 2:
			self.inch = 0xFFFF / (2 * x)
		self.scale = coef = self.inch / 72.0
		self.trafo = [coef, 0, 0, -coef, -coef * left, coef * top]
		self.bbox = self.point4wmf([left, bottom]) + self.point4wmf([right, top])

		self.add(wmf_model.set_window_org(self.bbox[0], self.bbox[3]))
		self.add(wmf_model.set_window_ext(self.bbox[2], self.bbox[1]))
		self.add(wmf_model.set_bkmode(wmfconst.TRANSPARENT))
		self.add(wmf_model.set_bkcolor([1.0, ] * 3))
		self.add(wmf_model.set_rop2(wmfconst.R2_COPYPEN))
		self.add(wmf_model.set_polyfillmode(wmfconst.ALTERNATE))

		self.translate_objs(page.childs)

		self.add(wmf_model.get_eof_rec())

		filesize, maxrecord = self.count_record_size()
		filesize += 18
		numobjs = len(self.wmf_objs)
		header = wmf_model.get_wmf_header(filesize, numobjs, maxrecord)
		header.childs = self.wmf_records
		placeable = wmf_model.get_placeble_header(self.bbox, self.inch)
		placeable.childs = [header, ]
		self.wmf_doc.model = placeable