def test_cond_style_name(self): p = Paragraph() p.cond_style_name = "CONDSTYLE" self.assertEqual(p.cond_style_name, "CONDSTYLE") self.assertIsNotNone(p.xmlnode.get(CN('text:cond-style-name')))
def test_ID(self): p = Paragraph() p.ID = "ID001" self.assertEqual(p.ID, "ID001") self.assertIsNotNone(p.xmlnode.get(CN('text:id')))
def test_plainttext_with_two_paragraphs_as_header(self): item = ListItem('paragraph1') item += Paragraph('paragraph2') self.assertEqual('paragraph1\nparagraph2', item.plaintext(), "wrong item content")
def test_plainttext_with_two_paragraphs_as_header(self): header = ListHeader('paragraph1') header += Paragraph('paragraph2') self.assertEqual('paragraph1\nparagraph2', header.plaintext(), "wrong header content")
def test_paragraph_content(self): np = NumberedParagraph(Paragraph('text')) res = np.content self.assertEqual(res.plaintext(), 'text')
def test_init_xmlroot(self): node = etree.Element(CN('text:p'), test="paragraph") p = Paragraph(xmlnode=node) self.assertTrue(isinstance(p, GenericWrapper)) self.assertEqual(p.xmlnode.tag, CN('text:p')) self.assertEqual(p.xmlnode.get('test'), "paragraph")
def test_wrapped_object(self): cell = Cell(Paragraph('text')) self.assertEqual(cell.value_type, 'string') self.assertEqual(cell.value, 'text') self.assertEqual(cell[0].kind, 'Paragraph')
def test_bare_init(self): p = Paragraph() self.assertTrue(isinstance(p, GenericWrapper)) self.assertEqual(p.xmlnode.tag, CN('text:p'))
def test_replace_two_paragraphs_by_new_string(self): cell = Cell('test1') cell.append(Paragraph('test2')) cell.set_value('new content') self.assertEqual('new content', cell.value)
def test_append_two_paragraphs(self): cell = Cell('test1') cell.append(Paragraph('test2')) self.assertEqual(cell.plaintext(), 'test1\ntest2') self.assertEqual(cell.value, 'test1\ntest2')
#!/usr/bin/env python #coding:utf-8 # Purpose: create simple text document # Created: 06.01.2011 # Copyright (C) 2011, Manfred Moitzi # License: MIT license from __future__ import unicode_literals, print_function, division __author__ = "mozman <*****@*****.**>" import ezodf from ezodf.text import Paragraph, Heading P1 = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." P2 = "Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat." P3 = "Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi." P4 = "Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer" name = 'simple_text_document.odt' odt = ezodf.newdoc(doctype=name[-3:], filename=name) odt.body.append(Heading("A Simple Test Document")) for nr, p in enumerate((P1, P2, P3, P4)): cnr = nr + 1 odt.body.append(Heading("Chapter %d" % cnr, cnr)) odt.body.append(Paragraph(p)) odt.save()
#!/usr/bin/env python #coding:utf-8 # Purpose: # Created: 10.04.12 # Copyright (C) 2012, Manfred Moitzi # License: MIT license import ezodf from ezodf.text import Paragraph, Heading from ezodf.whitespaces import SoftPageBreak name = 'pageBreakText.odt' odt = ezodf.newdoc(doctype=name[-3:], filename=name) odt.body.append(Heading("Page Break test")) odt.body.append(Paragraph("This is the first page")) # does not work with LibO/OOo odt.body.append(SoftPageBreak()) odt.body.append(Paragraph("This is the second page")) odt.save()
# Purpose: create simple text document # Created: 06.01.2011 # Copyright (C) 2011, Manfred Moitzi # License: MIT license from __future__ import unicode_literals, print_function, division __author__ = "mozman <*****@*****.**>" import ezodf from ezodf.text import Paragraph, Heading, Section P1 = "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet." P2 = "Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat." P3 = "Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi." P4 = "Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer" name = 'protected_paragraph.odt' odt = ezodf.newdoc(doctype=name[-3:], filename=name) odt.body.append(Heading("A Simple Test Document")) for nr, p in enumerate((P1, P2, P3, P4)): cnr = nr + 1 if cnr != 2: odt.body.append(Heading("Chapter %d" % cnr, cnr)) odt.body.append(Paragraph(p)) else: section = odt.body.append(Section(name='p1')) section.append(Heading("The write-protected paragraph")) section.append(Paragraph(p)) section.protected = True odt.save()