本文整理汇总了Python中odf.opendocument.OpenDocumentText.stylesxml方法的典型用法代码示例。如果您正苦于以下问题:Python OpenDocumentText.stylesxml方法的具体用法?Python OpenDocumentText.stylesxml怎么用?Python OpenDocumentText.stylesxml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类odf.opendocument.OpenDocumentText
的用法示例。
在下文中一共展示了OpenDocumentText.stylesxml方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: testAttributeForeign
# 需要导入模块: from odf.opendocument import OpenDocumentText [as 别名]
# 或者: from odf.opendocument.OpenDocumentText import stylesxml [as 别名]
def testAttributeForeign(self):
""" Test that you can add foreign attributes """
textdoc = OpenDocumentText()
standard = style.Style(name="Standard", family="paragraph")
p = style.ParagraphProperties(qattributes={(u'http://foreignuri.com',u'enable-numbering'):'true'})
standard.addElement(p)
textdoc.styles.addElement(standard)
s = unicode(textdoc.stylesxml(),'UTF-8')
s.index(u"""<?xml version='1.0' encoding='UTF-8'?>\n""")
s.index(u'xmlns:ns30="http://foreignuri.com"')
s.index(u'<style:paragraph-properties ns30:enable-numbering="true"/>')
s.index(u'<office:styles><style:style style:name="Standard" style:display-name="Standard" style:family="paragraph">')
示例2: testMasterWithHeader
# 需要导入模块: from odf.opendocument import OpenDocumentText [as 别名]
# 或者: from odf.opendocument.OpenDocumentText import stylesxml [as 别名]
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>')
示例3: test_list
# 需要导入模块: from odf.opendocument import OpenDocumentText [as 别名]
# 或者: from odf.opendocument.OpenDocumentText import stylesxml [as 别名]
def test_list(self):
textdoc = OpenDocumentText()
s = textdoc.styles
listStyle = easyliststyle.styleFromString(u'bullet1', bulletListSpec,
u',', u'0.6cm', easyliststyle.SHOW_ONE_LEVEL)
s.addElement(listStyle)
result = textdoc.stylesxml()
self.assertNotEqual(-1, result.find(u'''style:name="bullet1"'''))
self.assertNotEqual(-1, result.find(u'''text:bullet-char="*"'''))
self.assertNotEqual(-1, result.find(u'''text:level="1"'''))
self.assertNotEqual(-1, result.find(u'''style:list-level-properties'''))
#<text:list-style style:name="bullet1" style:display-name="bullet1">
#<text:list-level-style-bullet text:bullet-char="*" text:level="1">
#<style:list-level-properties text:min-label-width="0.6cm" text:space-before="0.6cm"/>
#</text:list-level-style-bullet>
#<text:list-level-style-bullet text:bullet-char=">" text:level="2">
#<style:list-level-properties text:min-label-width="0.6cm" text:space-before="1.2cm"/>
#</text:list-level-style-bullet>
#<text:list-level-style-bullet text:bullet-char="#" text:level="3">
#<style:list-level-properties text:min-label-width="0.6cm" text:space-before="1.8cm"/>
#</text:list-level-style-bullet>
#<text:list-level-style-bullet text:bullet-char="%" text:level="4">
#<style:list-level-properties text:min-label-width="0.6cm" text:space-before="2.4cm"/>
listElement = self.createList(itemList, u'>', u'bullet1')
textdoc.text.addElement(listElement)
para = P(text="-----------------------");
textdoc.text.addElement(para)
listStyle = easyliststyle.styleFromList('num1', numberListSpecArray,
'0.25in', easyliststyle.SHOW_ALL_LEVELS)
s.addElement(listStyle)
listElement = self.createList(itemList, '>', 'num1')
textdoc.text.addElement(listElement)
para = P(text="-----------------------");
textdoc.text.addElement(para)
listStyle = easyliststyle.styleFromString('mix1', mixedListSpec,
'!', '0.8cm', easyliststyle.SHOW_ONE_LEVEL)
s.addElement(listStyle)
listElement = self.createList(itemList, '>', 'mix1')
textdoc.text.addElement(listElement)
示例4: testAttributeForeign
# 需要导入模块: from odf.opendocument import OpenDocumentText [as 别名]
# 或者: from odf.opendocument.OpenDocumentText import stylesxml [as 别名]
def testAttributeForeign(self):
""" Test that you can add foreign attributes """
textdoc = OpenDocumentText()
standard = style.Style(name=u"Standard", family=u"paragraph")
p = style.ParagraphProperties(qattributes={(u'http://foreignuri.com','enable-numbering'):u'true'})
standard.addElement(p)
textdoc.styles.addElement(standard)
s = textdoc.stylesxml()
s.index(u"""<?xml version='1.0' encoding='UTF-8'?>\n""")
s.index(u'xmlns:ns41="http://foreignuri.com"')
s.index(u'<style:paragraph-properties ns41:enable-numbering="true"/>')
e = ElementParser(s,u'style:style')
# e = ElementParser('<style:style style:name="Standard" style:display-name="Standard" style:family="paragraph">')
self.assertEqual(e.element,u'style:style')
self.assertTrue(e.has_value(u"style:display-name","Standard"))
self.assertTrue(e.has_value(u"style:name","Standard"))
self.assertTrue(e.has_value(u"style:family","paragraph"))
示例5: testAutomaticStyles
# 需要导入模块: from odf.opendocument import OpenDocumentText [as 别名]
# 或者: from odf.opendocument.OpenDocumentText import stylesxml [as 别名]
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 = unicode(textdoc.stylesxml(),'UTF-8')
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 = unicode(textdoc.contentxml(),'UTF-8')
self.assertNotContains(s, u'<style:page-layout style:name="pagelayout"/>')
self.assertContains(s, u'style:name="Para" ')