def test_create_date_text(self):
     date_elt =  odf_create_date_variable(datetime(2009, 7, 20),
             text=u'20 juil. 09')
     expected = ('<text:date text:date-value="2009-07-20T00:00:00">'
                   '20 juil. 09'
                 '</text:date>')
     self.assertEqual(date_elt.serialize(), expected)
示例#2
0
 def test_create_date_text(self):
     date_elt =  odf_create_date_variable(datetime(2009, 7, 20),
             text='20 juil. 09')
     expected = ('<text:date text:date-value="2009-07-20T00:00:00">'
                   '20 juil. 09'
                 '</text:date>')
     self.assertEqual(date_elt.serialize(), expected)
示例#3
0
 def test_create_date_fixed(self):
     date_elt = odf_create_date_variable(datetime(2009, 7, 20), fixed=True)
     expected = ('<text:date text:date-value="2009-07-20T00:00:00" '
                 'text:fixed="true">'
                 '2009-07-20'
                 '</text:date>')
     self.assertEqual(date_elt.serialize(), expected)
 def test_create_date_fixed(self):
     date_elt = odf_create_date_variable(datetime(2009, 7, 20),
                                         fixed=True)
     expected = ('<text:date text:date-value="2009-07-20T00:00:00" '
                   'text:fixed="true">'
                   '2009-07-20'
                 '</text:date>')
     self.assertEqual(date_elt.serialize(), expected)
示例#5
0
body.append(paragraph)
paragraph.insert_variable(odf_create_page_count_variable(), u"is: ")

# 9- Date
# -------

heading = odf_create_heading(1, text=u'Date insertion')
body.append(heading)

text1 = u'A fixed date: '
text2 = u'Today: '

paragraph = odf_create_paragraph(text1, style=u"Standard")
body.append(paragraph)
paragraph.insert_variable(
    odf_create_date_variable(date(2009, 7, 20), fixed=True), u"date: ")

paragraph = odf_create_paragraph(text2, style=u"Standard")
body.append(paragraph)
paragraph.insert_variable(odf_create_date_variable(date(2009, 7, 20)),
                          u"Today: ")

# 10- Time
# --------

heading = odf_create_heading(1, text=u'Time insertion')
body.append(heading)

text1 = u'A fixed time: '
text2 = u'Now: '
text3 = u'In 1 hour: '
示例#6
0
body.append(paragraph)
paragraph.insert_variable(odf_create_page_count_variable(), u"is: ")


# 7- Date
# -------

heading = odf_create_heading(1, text=u'Date insertion')
body.append(heading)

text1 = u'A fixed date: '
text2 = u'Today: '

paragraph = odf_create_paragraph(text1, style=u"Standard")
body.append(paragraph)
paragraph.insert_variable(odf_create_date_variable(date(2009, 7, 20),
    fixed=True), u"date: ")

paragraph = odf_create_paragraph(text2, style=u"Standard")
body.append(paragraph)
paragraph.insert_variable(odf_create_date_variable(date(2009, 7, 20)),
    u"Today: ")


# 8- Time
# --------

heading = odf_create_heading(1, text=u'Time insertion')
body.append(heading)

text1 = u'A fixed time: '
text2 = u'Now: '
示例#7
0
# The first paragraph will set the page::
paragraph = odf_create_paragraph(u"lpOD generated Document with styled pages",
                                 style.get_style_name())
body.append(paragraph)

# To modify the footer and header we get the style
first_page_style = document.get_style('master-page', u"First_20_Page")

# Overwrite the footer
first_page_style.set_footer(u'lpOD project')

# Complement the header
header = first_page_style.get_header()
header.append(odf_create_paragraph(u"Final Version"))

# Example of default style: a date
date_style = odf_create_default_date_style()
document.insert_style(date_style, automatic=True)
today = odf_create_date_variable(date.today(),
                                 data_style=date_style.get_style_name())
paragraph = odf_create_paragraph(u"The current date with the default lpOD "
                                 u"date style: ")
paragraph.append(today)
body.append(paragraph)


# Save
filename = 'styles.odt'
document.save(filename, pretty=True)
print 'Document "%s" generated.' % filename