Example #1
0
 def test_get_draw_line_by_id(self):
     body = self.content.get_body()
     page = body.get_draw_page()
     line = odf_create_line(shape_id=u'an id')
     page.append(line)
     line = page.get_draw_line(id=ur'an id')
     expected = '<draw:line draw:id="an id"/>\n'
     self.assertEqual(line.serialize(pretty=True), expected)
 def test_get_draw_line_by_id(self):
     body = self.content.get_body()
     page = body.get_draw_page_by_position(0)
     line = odf_create_line(shape_id=u'an id')
     page.append_element(line)
     line = page.get_draw_line_by_id(ur'an id')
     expected = '<draw:line draw:id="an id"/>\n'
     self.assertEqual(line.serialize(pretty=True), expected)
 def test_create_line(self):
     page = odf_create_draw_page('Page1')
     line = odf_create_line(p1=('2cm', '2cm'), p2=('1cm', '1cm'))
     page.append_element(line)
     expected = ('<draw:page draw:id="Page1">\n'
                 '  <draw:line svg:x1="2cm" svg:y1="2cm" svg:x2="1cm" '
                 'svg:y2="1cm"/>\n'
                 '</draw:page>\n')
     self.assertEqual(page.serialize(pretty=True), expected)
Example #4
0
 def test_create_line(self):
     page = odf_create_draw_page('Page1')
     line = odf_create_line(p1=('2cm', '2cm'), p2=('1cm', '1cm'))
     page.append(line)
     expected = ('<draw:page draw:id="Page1">\n'
                 '  <draw:line svg:x1="2cm" svg:y1="2cm" svg:x2="1cm" '
                 'svg:y2="1cm"/>\n'
                 '</draw:page>\n')
     self.assertEqual(page.serialize(pretty=True), expected)
Example #5
0
# Square
square = odf_create_rectangle(shape_id=u"square",
                              size=('8cm', '8cm'),
                              position=('17cm', '2.5cm'),
                              style=u"colored")
page3.append(square)

# Circle
circle = odf_create_ellipse(shape_id=u"circle",
                            size=('8cm', '8cm'),
                            position=('2cm', '10cm'),
                            style=u"colored")
page3.append(circle)

# Line
line = odf_create_line(p1=('8cm', '5cm'), p2=('20cm', '17.5cm'))
page3.append(line)

# Connector
connector = odf_create_connector(connected_shapes=(square, circle),
                                 glue_points=('1', '3'))

# Add a transition for this frame
page3.set_transition("fade", "fadeOverColor")

# Save
filename = 'presentation.odp'
document.save(filename, pretty=True)
print 'Document "%s" generated.' % filename
Example #6
0
# Last page
page3 = odf_create_draw_page(u"page3")
body.append(page3)

# Square
square = odf_create_rectangle(shape_id=u"square", size=('8cm', '8cm'),
                              position=('17cm', '2.5cm'),
                              style=u"colored")
page3.append(square)

# Circle
circle = odf_create_ellipse(shape_id=u"circle", size=('8cm', '8cm'),
                            position=('2cm', '10cm'), style=u"colored")
page3.append(circle)

# Line
line = odf_create_line(p1=('8cm', '5cm'), p2=('20cm', '17.5cm'))
page3.append(line)

# Connector
connector = odf_create_connector(connected_shapes=(square, circle),
                                 glue_points=('1', '3'))

# Add a transition for this frame
page3.set_transition("fade", "fadeOverColor")

# Save
filename = 'presentation.odp'
document.save(filename, pretty=True)
print 'Document "%s" generated.' % filename
    style = document.get_style('graphic')
    style.set_properties({"svg:stroke_color" : "#0000ff"})
    style.set_properties(fill_color = "#ffffcc")

    para = odf_create_paragraph(u"")
    body.append(para)

    # some computation of oordinates
    center, vlist = make_coords(side=12.0, vpos=8.0)

    # create a circle
    rad = 8.0
    pos = center - complex(rad, rad)
    circle = odf_create_ellipse(
        size=('%.2fcm' % (rad * 2), '%.2fcm' % (rad * 2) ),
        position=('%.2fcm' % pos.real, '%.2fcm' % pos.imag) )
    para.append(circle)

    # create a drawing with a lot of lines
    para.append(u'number of lines: %s' % len(vlist))
    for v in vlist:
        line = odf_create_line(p1 = v.in_cm(0), p2 = v.in_cm(1))
        para.append(line)

if not os.path.exists('test_output'):
    os.mkdir('test_output')

output = os.path.join('test_output', 'my_Koch_fractal.odt')

document.save(target=output, pretty=True)
Example #8
0
    style.set_properties({"svg:stroke_color": "#0000ff"})
    style.set_properties(fill_color="#ffffcc")

    para = odf_create_paragraph(u"")
    body.append(para)

    # some computation of oordinates
    center, vlist = make_coords(side=12.0, vpos=8.0)

    # create a circle
    rad = 8.0
    pos = center - complex(rad, rad)
    circle = odf_create_ellipse(size=('%.2fcm' % (rad * 2),
                                      '%.2fcm' % (rad * 2)),
                                position=('%.2fcm' % pos.real,
                                          '%.2fcm' % pos.imag))
    para.append(circle)

    # create a drawing with a lot of lines
    para.append(u'number of lines: %s' % len(vlist))
    for v in vlist:
        line = odf_create_line(p1=v.in_cm(0), p2=v.in_cm(1))
        para.append(line)

if not os.path.exists('test_output'):
    os.mkdir('test_output')

output = os.path.join('test_output', 'my_Koch_fractal.odt')

document.save(target=output, pretty=True)