Пример #1
0
def add_chart_structure_in_document(document):
    """Search the .otc template installed and put xml files in document """
    #We search the template
    my_template = ""
    for p in path:
        if exists(p+"/chart/templates/chart.otc"):
            my_template=p+"/chart/templates/chart.otc"
            break
    
    if my_template == "":
        raise IOError, "Template .otc not found"
    
    #we have to create a folder for the chart
    i = 1
    obj_created = False
    name=""
    manifest = document.get_part('META-INF/manifest.xml')
    while not obj_created:
        name="Object "+str(i)
        if manifest.get_media_type(name+'/') is None:
	    manifest.add_full_path(name+'/',
                                    "application/vnd.oasis.opendocument.chart")

            document.container.set_part(name+'/', '')
            obj_created = True
        else:
            i = i+1

    #We open the template
    chart = odf_new_container(my_template)

    #we add templates files in the document
    document.set_part(name+'/content.xml', chart.get_part('content.xml'))
    manifest.add_full_path(name+'/content.xml' , "text/xml")

    document.set_part(name+'/styles.xml', chart.get_part('styles.xml'))
    manifest.add_full_path(name+'/styles.xml' , "text/xml")
    
    document.set_part(name+'/meta.xml', chart.get_part('meta.xml'))
    manifest.add_full_path(name+'/meta.xml' , "text/xml")

    return name
Пример #2
0
def add_chart_structure_in_document(document):
    """Search the .otc template installed and put xml files in document """
    #We search the template
    my_template = ""
    for p in path:
        if exists(p + "/chart/templates/chart.otc"):
            my_template = p + "/chart/templates/chart.otc"
            break

    if my_template == "":
        raise IOError, "Template .otc not found"

    #we have to create a folder for the chart
    i = 1
    obj_created = False
    name = ""
    manifest = document.get_part('META-INF/manifest.xml')
    while not obj_created:
        name = "Object " + str(i)
        if manifest.get_media_type(name + '/') is None:
            manifest.add_full_path(name + '/',
                                   "application/vnd.oasis.opendocument.chart")

            document.container.set_part(name + '/', '')
            obj_created = True
        else:
            i = i + 1

    #We open the template
    chart = odf_new_container(my_template)

    #we add templates files in the document
    document.set_part(name + '/content.xml', chart.get_part('content.xml'))
    manifest.add_full_path(name + '/content.xml', "text/xml")

    document.set_part(name + '/styles.xml', chart.get_part('styles.xml'))
    manifest.add_full_path(name + '/styles.xml', "text/xml")

    document.set_part(name + '/meta.xml', chart.get_part('meta.xml'))
    manifest.add_full_path(name + '/meta.xml', "text/xml")

    return name
Пример #3
0
 def test_spreadsheet_type(self):
     container = odf_new_container('spreadsheet')
     mimetype = container.get_part('mimetype')
     self.assertEqual(mimetype, ODF_EXTENSIONS['ods'])
Пример #4
0
 def test_drawing_template(self):
     path = '../templates/drawing.otg'
     container = odf_new_container(path)
     mimetype = container.get_part('mimetype')
     self.assertEqual(mimetype, ODF_EXTENSIONS['odg'])
Пример #5
0
 def test_text_type(self):
     container = odf_new_container('text')
     mimetype = container.get_part('mimetype')
     self.assertEqual(mimetype, ODF_EXTENSIONS['odt'])
Пример #6
0
 def test_spreadsheet_template(self):
     path = '../templates/spreadsheet.ots'
     container = odf_new_container(path)
     mimetype = container.get_part('mimetype')
     self.assertEqual(mimetype, ODF_EXTENSIONS['ods'])
Пример #7
0
 def test_presentation_template(self):
     path = '../templates/presentation.otp'
     container = odf_new_container(path)
     mimetype = container.get_part('mimetype')
     self.assertEqual(mimetype, ODF_EXTENSIONS['odp'])
Пример #8
0
 def test_spreadsheet_template(self):
     path = '../lpod/templates/spreadsheet.ots'
     container = odf_new_container(path)
     mimetype = container.get_part('mimetype')
     self.assertEqual(mimetype, ODF_EXTENSIONS['ods'])
Пример #9
0
 def test_text_template(self):
     path = '../templates/text.ott'
     container = odf_new_container(path)
     mimetype = container.get_part('mimetype')
     self.assertEqual(mimetype, ODF_EXTENSIONS['odt'])
Пример #10
0
 def test_drawing_type(self):
     container = odf_new_container('drawing')
     mimetype = container.get_part('mimetype')
     self.assertEqual(mimetype, ODF_EXTENSIONS['odg'])
Пример #11
0
 def test_text_template(self):
     path = '../templates/text.ott'
     container = odf_new_container(path)
     mimetype = container.get_part('mimetype')
     self.assertEqual(mimetype, ODF_EXTENSIONS['odt'])
Пример #12
0
 def test_spreadsheet_type(self):
     container = odf_new_container('spreadsheet')
     mimetype = container.get_part('mimetype')
     self.assertEqual(mimetype, ODF_EXTENSIONS['ods'])
Пример #13
0
 def test_presentation_type(self):
     container = odf_new_container('presentation')
     mimetype = container.get_part('mimetype')
     self.assertEqual(mimetype, ODF_EXTENSIONS['odp'])
Пример #14
0
 def test_text_type(self):
     container = odf_new_container('text')
     mimetype = container.get_part('mimetype')
     self.assertEqual(mimetype, ODF_EXTENSIONS['odt'])
Пример #15
0
 def test_drawing_template(self):
     path = '../lpod/templates/drawing.otg'
     container = odf_new_container(path)
     mimetype = container.get_part('mimetype')
     self.assertEqual(mimetype, ODF_EXTENSIONS['odg'])
Пример #16
0
 def test_presentation_template(self):
     path = '../lpod/templates/presentation.otp'
     container = odf_new_container(path)
     mimetype = container.get_part('mimetype')
     self.assertEqual(mimetype, ODF_EXTENSIONS['odp'])
Пример #17
0
 def test_presentation_type(self):
     container = odf_new_container('presentation')
     mimetype = container.get_part('mimetype')
     self.assertEqual(mimetype, ODF_EXTENSIONS['odp'])
Пример #18
0
 def test_clone(self):
     container = odf_new_container('text')
     clone = container.clone()
     self.assertEqual(clone.path, None)
     self.assertNotEqual(clone._odf_container__data, None)
Пример #19
0
 def test_drawing_type(self):
     container = odf_new_container('drawing')
     mimetype = container.get_part('mimetype')
     self.assertEqual(mimetype, ODF_EXTENSIONS['odg'])
Пример #20
0
 def test_clone(self):
     container = odf_new_container('text')
     clone = container.clone()
     self.assertEqual(clone.path, None)
     self.assertNotEqual(clone._odf_container__data, None)