def test_get_draw_ellipse_by_id(self):
     body = self.content.get_body()
     page = body.get_draw_page_by_position(0)
     ellipse = odf_create_ellipse(shape_id=u'an id')
     page.append_element(ellipse)
     ellipse = page.get_draw_ellipse_by_id(ur'an id')
     expected = ('<draw:ellipse draw:id="an id" svg:width="1cm" '
                 'svg:height="1cm"/>\n')
     self.assertEqual(ellipse.serialize(pretty=True), expected)
Beispiel #2
0
 def test_get_draw_ellipse_by_id(self):
     body = self.content.get_body()
     page = body.get_draw_page()
     ellipse = odf_create_ellipse(shape_id=u'an id')
     page.append(ellipse)
     ellipse = page.get_draw_ellipse(id=ur'an id')
     expected = ('<draw:ellipse draw:id="an id" svg:width="1cm" '
                 'svg:height="1cm"/>\n')
     self.assertEqual(ellipse.serialize(pretty=True), expected)
 def test_create_ellipse(self):
     page = odf_create_draw_page('Page1')
     svg_attrs = {
         'svg:width': '2cm',
         'svg:height': '2cm',
         'svg:x': '2cm',
         'svg:y': '2cm'}
     ellipse = odf_create_ellipse(size=('2cm', '1cm'), position=('3cm',
     '4cm'))
     page.append_element(ellipse)
     expected = ('<draw:page draw:id="Page1">\n'
                 '  <draw:ellipse svg:width="2cm" svg:height="1cm" '
                 'svg:x="3cm" svg:y="4cm"/>\n'
                 '</draw:page>\n')
     self.assertEqual(page.serialize(pretty=True), expected)
Beispiel #4
0
 def test_create_ellipse(self):
     page = odf_create_draw_page('Page1')
     svg_attrs = {
         'svg:width': '2cm',
         'svg:height': '2cm',
         'svg:x': '2cm',
         'svg:y': '2cm'
     }
     ellipse = odf_create_ellipse(size=('2cm', '1cm'),
                                  position=('3cm', '4cm'))
     page.append(ellipse)
     expected = ('<draw:page draw:id="Page1">\n'
                 '  <draw:ellipse svg:width="2cm" svg:height="1cm" '
                 'svg:x="3cm" svg:y="4cm"/>\n'
                 '</draw:page>\n')
     self.assertEqual(page.serialize(pretty=True), expected)
Beispiel #5
0
 def test_create_connector(self):
     page = odf_create_draw_page('Page1')
     rectangle = odf_create_rectangle(size=('2cm', '1cm'),
                                      position=('3cm', '4cm'),
                                      shape_id='rectangle')
     ellipse = odf_create_ellipse(size=('2cm', '1cm'),
                                  position=('3cm', '4cm'),
                                  shape_id='ellipse')
     connector = odf_create_connector(connected_shapes=(rectangle, ellipse),
                                      glue_points=(1, 2))
     page.append(rectangle)
     page.append(ellipse)
     page.append(connector)
     expected = ('<draw:page draw:id="Page1">\n'
                 '  <draw:rect draw:id="rectangle" svg:width="2cm" '
                 'svg:height="1cm" svg:x="3cm" svg:y="4cm"/>\n'
                 '  <draw:ellipse draw:id="ellipse" svg:width="2cm" '
                 'svg:height="1cm" svg:x="3cm" svg:y="4cm"/>\n'
                 '  <draw:connector draw:start-shape="rectangle" '
                 'draw:end-shape="ellipse" draw:start-glue-point="1" '
                 'draw:end-glue-point="2"/>\n'
                 '</draw:page>\n')
     self.assertEqual(page.serialize(pretty=True), expected)
 def test_create_connector(self):
     page = odf_create_draw_page('Page1')
     rectangle = odf_create_rectangle(size=('2cm', '1cm'),
                                      position=('3cm', '4cm'),
                                      shape_id='rectangle')
     ellipse = odf_create_ellipse(size=('2cm', '1cm'),
                                  position=('3cm', '4cm'),
                                  shape_id='ellipse')
     connector = odf_create_connector(connected_shapes=(rectangle,
                                                        ellipse),
                                      glue_points=(1, 2))
     page.append_element(rectangle)
     page.append_element(ellipse)
     page.append_element(connector)
     expected = ('<draw:page draw:id="Page1">\n'
                 '  <draw:rect draw:id="rectangle" svg:width="2cm" '
                 'svg:height="1cm" svg:x="3cm" svg:y="4cm"/>\n'
                 '  <draw:ellipse draw:id="ellipse" svg:width="2cm" '
                 'svg:height="1cm" svg:x="3cm" svg:y="4cm"/>\n'
                 '  <draw:connector draw:start-shape="rectangle" '
                 'draw:end-shape="ellipse" draw:start-glue-point="1" '
                 'draw:end-glue-point="2"/>\n'
                 '</draw:page>\n')
     self.assertEqual(page.serialize(pretty=True), expected)
Beispiel #7
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
Beispiel #8
0
#
# Shapes
#

# 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'
    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)
Beispiel #10
0
    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)