예제 #1
0
def write_presentation_plugin(frame, indoc, outdoc, encoding):
    plugin = frame.get_element('draw:plugin')
    src = plugin.get_attribute('xlink:href')
    if not isabs(src):
        f = open(make_image_path(outdoc, src), 'wb')
        f.write(indoc.get_part(src))
        f.close()
    width, height = frame.get_size()
    width = Unit(width).convert('px')
    height = Unit(height).convert('px')
    text = plugin.get_text_content()  # XXX get_svg_title?
    mimetype = plugin.get_attribute('draw:mime-type')
    outdoc.write(
        '''<div class="plugin">
  <object data="%(src)s" type="%(mimetype)s" width="%(width)s"
    height="%(height)s">
    <param name="src" value="%(src)s"/>
    <param name="autoplay" value="false"/>
    <param name="autoStart" value="0"/>
    %(text)s
  </object>
</div>\n''' % {
            'src': src,
            'mimetype': mimetype,
            'width': width,
            'height': height,
            'text': text
        })
예제 #2
0
def cmp_frames(a, b):
    # XXX obsolete if "get_position" returns Unit
    ax, ay = a.get_position()
    ax = Unit(ax)
    ay = Unit(ay)
    bx, by = b.get_position()
    bx = Unit(bx)
    by = Unit(by)
    # Top-bottom then left-right
    return cmp((ay, ax), (by, bx))
예제 #3
0
def write_presentation_table(frame, outdoc, encoding):
    width, height = frame.get_size()
    width = Unit(width).convert('px')
    height = Unit(height).convert('px')
    outdoc.write('<table width="%(width)s" height="%(height)s">')
    table = frame.get_table()
    for y, row in table.get_rows():
        outdoc.write('  <tr>')
        for x, cell in row.get_cells():
            text = get_string(cell.get_text_content(), encoding)
            outdoc.write('    <td>%s</td>\n' % text)
        outdoc.write('  </tr>\n')
    outdoc.write('</table>\n')
예제 #4
0
 def test_encode(self):
     value = '1.847mm'
     unit = Unit(value)
     self.assertEqual(str(unit), value)
예제 #5
0
 def test_convert(self):
     unit = Unit('10cm')
     self.assertEqual(unit.convert('px'), Unit('283px'))
예제 #6
0
 def test_int(self):
     unit = Unit(1)
     self.assertEqual(unit.value, Decimal('1'))
     self.assertEqual(unit.unit, 'cm')
예제 #7
0
 def test_float(self):
     unit = Unit(3.14)
     self.assertEqual(unit.value, Decimal('3.14'))
     self.assertEqual(unit.unit, 'cm')
예제 #8
0
 def test_str(self):
     unit = Unit('1.847mm')
     self.assertEqual(unit.value, Decimal('1.847'))
     self.assertEqual(unit.unit, 'mm')
예제 #9
0
 def test_convert(self):
     unit = Unit('10cm')
     self.assertEqual(unit.convert('px'), Unit('283px'))
예제 #10
0
 def test_ge(self):
     unit1 = Unit('2.54cm')
     unit2 = Unit('2.54cm')
     self.assertTrue(unit1 >= unit2)
예제 #11
0
 def test_ngt(self):
     unit1 = Unit('2.54cm')
     unit2 = Unit('2.53cm')
     self.assertFalse(unit1 < unit2)
예제 #12
0
 def test_gt(self):
     unit1 = Unit('2.54cm')
     unit2 = Unit('2.53cm')
     self.assertTrue(unit1 > unit2)