def testMasterWithHeader(self): """ Create a text document with a page layout called "pagelayout" Add a master page Check that pagelayout is listed in styles.xml """ textdoc = OpenDocumentText() pl = style.PageLayout(name="pagelayout") textdoc.automaticstyles.addElement(pl) mp = style.MasterPage(name="Standard", pagelayoutname=pl) textdoc.masterstyles.addElement(mp) h = style.Header() hp = text.P(text="header try") h.addElement(hp) mp.addElement(h) s = unicode(textdoc.stylesxml(),'UTF-8') self.assertContains(s, u'<office:automatic-styles><style:page-layout style:name="pagelayout"/></office:automatic-styles>')
def testAutomaticStyles(self): """ Create a text document with a page layout called "pagelayout" Add a master page Add an automatic style for the heading Check that pagelayout is listed in styles.xml under automatic-styles Check that the heading style is NOT listed in styles.xml Check that the pagelayout is NOT listed in content.xml """ textdoc = OpenDocumentText() parastyle = style.Style(name="Para", family="paragraph") parastyle.addElement( style.ParagraphProperties(numberlines="false", linenumber="0")) parastyle.addElement( style.TextProperties(fontsize="24pt", fontweight="bold")) textdoc.automaticstyles.addElement(parastyle) hpstyle = style.Style(name="HeaderPara", family="paragraph") hpstyle.addElement(style.ParagraphProperties(linenumber="0")) hpstyle.addElement( style.TextProperties(fontsize="18pt", fontstyle="italic")) textdoc.automaticstyles.addElement(hpstyle) pl = style.PageLayout(name="pagelayout") textdoc.automaticstyles.addElement(pl) mp = style.MasterPage(name="Standard", pagelayoutname=pl) textdoc.masterstyles.addElement(mp) h = style.Header() hp = text.P(text="header content", stylename=hpstyle) h.addElement(hp) mp.addElement(h) textdoc.text.addElement(text.P(text="Paragraph 1", stylename=parastyle)) # Check styles.xml s = textdoc.stylesxml() self.assertContains(s, u'<style:page-layout style:name="pagelayout"/>') self.assertContains(s, u'style:name="HeaderPara"') self.assertNotContains(s, u'style:name="Para" ') # Check content.xml s = textdoc.contentxml() # contentxml is supposed to yed a byts self.assertNotContains( s, b'<style:page-layout style:name="pagelayout"/>') self.assertContains(s, b'style:name="Para"')