def setUp(self): d = OpenDocumentText() # Styles h1style = style.Style(name=u"Heading 1", family=u"paragraph") h1style.addElement( style.TextProperties(attributes={ 'fontsize': u"24pt", 'fontweight': u"bold" })) d.styles.addElement(h1style) boldstyle = style.Style(name=u"Bold", family=u"text") boldstyle.addElement( style.TextProperties(attributes={'fontweight': u"bold"})) d.automaticstyles.addElement(boldstyle) # Text h = H(outlinelevel=1, stylename=h1style, text=u"Simple test document") d.text.addElement(h) p = P( text= u"The earth's climate has not changed many times in the course of its long history. " ) d.text.addElement(p) boldpart = Span(stylename=boldstyle, text=u"This part is bold. ") p.addElement(boldpart) p.addText(u"This is after bold.") d.save(u"TEST.odt")
def _make_layout(self, doc, layout, firstpage): # set paper dimensions pageLayout = style.PageLayout(name=u"pl1") doc.automaticstyles.addElement(pageLayout) plProp = style.PageLayoutProperties(pageheight=str(layout.height), pagewidth=str(layout.width), marginleft=str(layout.left), marginright=str(layout.right), margintop=str(layout.top), marginbottom=str(layout.bottom)) pageLayout.addElement(plProp) # add page numbers to the footers footer = style.Footer() foostyle = style.Style(name="Footer", family="paragraph") foostyle.addElement(style.ParagraphProperties(textalign='center')) foostyle.addElement(style.TextProperties(fontsize='10pt')) doc.automaticstyles.addElement(foostyle) p = text.P(stylename=foostyle) p.addElement( text.PageNumber(selectpage="current", pageadjust=str(firstpage - 1))) footer.addElement(p) masterpage = style.MasterPage(name=u"Standard", pagelayoutname=pageLayout) masterpage.addElement(footer) doc.masterstyles.addElement(masterpage)
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"')
def test_style(self): """ Get an automatic style with getStyleByName """ textdoc = OpenDocumentText() boldstyle = style.Style(name='Bold', family="text") boldstyle.addElement(style.TextProperties(fontweight="bold")) textdoc.automaticstyles.addElement(boldstyle) s = textdoc.getStyleByName('Bold') self.assertEquals((u'urn:oasis:names:tc:opendocument:xmlns:style:1.0', 'style'), s.qname)
def build_default_style(self): """Creates default style for Libreoffice Documents""" # Add the right language to the template language_code = locale.getlocale()[0][:2] country_code = locale.getlocale()[0][-2:] default_style = style.DefaultStyle(family="paragraph") default_style.addElement( style.TextProperties(language=language_code, country=country_code)) return default_style
def textBold(self) -> style.Style: """ Return text bold property. @return Style Property. """ bold_style = style.Style(name="Bold", family="text") bold_style.addElement(style.TextProperties(fontweight="bold")) return bold_style
def textUnderline(self) -> style.Style: """ Return text bold property. @return Style Property. """ bold_style = style.Style(name="Underline", family="text") bold_style.addElement(style.TextProperties(fontstyle="underline")) return bold_style
def textItalic(self) -> style.Style: """ Return italic text. @return Style Property. """ italic_style = style.Style(name="Italic", family="text") italic_style.addElement(style.TextProperties(fontstyle="italic")) return italic_style
def testTable(self): """ Create a presentation with a page layout called MyLayout """ presdoc = OpenDocumentPresentation() # We must describe the dimensions of the page pagelayout = style.PageLayout(name="MyLayout") presdoc.automaticstyles.addElement(pagelayout) pagelayout.addElement( style.PageLayoutProperties(margin="0cm", pagewidth="28cm", pageheight="21cm", printorientation="landscape")) # Every drawing page must have a master page assigned to it. masterpage = style.MasterPage(name="MyMaster", pagelayoutname=pagelayout) presdoc.masterstyles.addElement(masterpage) # Style for the title frame of the page # We set a centered 34pt font with yellowish background titlestyle = style.Style(name="MyMaster-title", family="presentation") titlestyle.addElement(style.ParagraphProperties(textalign="center")) titlestyle.addElement(style.TextProperties(fontsize="34pt")) titlestyle.addElement(style.GraphicProperties(fillcolor="#ffff99")) presdoc.styles.addElement(titlestyle) # Style for the photo frame mainstyle = style.Style(name="MyMaster-main", family="presentation") presdoc.styles.addElement(mainstyle) # Create style for drawing page dpstyle = style.Style(name="dp1", family="drawing-page") presdoc.automaticstyles.addElement(dpstyle) page = draw.Page(stylename=dpstyle, masterpagename=masterpage) presdoc.presentation.addElement(page) titleframe = draw.Frame(stylename=titlestyle, width="720pt", height="56pt", x="40pt", y="10pt") page.addElement(titleframe) textbox = draw.TextBox() titleframe.addElement(textbox) textbox.addElement(text.P(text="Presentation")) mainframe = draw.Frame(stylename=mainstyle, width="720pt", height="500pt", x="0pt", y="56pt") page.addElement(mainframe) mainframe.addElement(table.Table())
def testStyle(self): """ Create a presentation with a page layout called MyLayout Add a presentation style for the title Check that MyLayout is listed in styles.xml """ presdoc = OpenDocumentPresentation() # We must describe the dimensions of the page pagelayout = style.PageLayout(name="MyLayout") presdoc.automaticstyles.addElement(pagelayout) pagelayout.addElement( style.PageLayoutProperties(margin="0cm", pagewidth="28cm", pageheight="21cm", printorientation="landscape")) # Every drawing page must have a master page assigned to it. masterpage = style.MasterPage(name="MyMaster", pagelayoutname=pagelayout) presdoc.masterstyles.addElement(masterpage) # Style for the title frame of the page # We set a centered 34pt font with yellowish background titlestyle = style.Style(name="MyMaster-title", family="presentation") titlestyle.addElement(style.ParagraphProperties(textalign="center")) titlestyle.addElement(style.TextProperties(fontsize="34pt")) titlestyle.addElement(style.GraphicProperties(fillcolor="#ffff99")) presdoc.styles.addElement(titlestyle) s = presdoc.stylesxml() self.assertContains( s, '<style:page-layout style:name="MyLayout"><style:page-layout-properties ' ) e = ElementParser(s, 'style:page-layout-properties') self.assertEqual(e.element, 'style:page-layout-properties') self.assertTrue(e.has_value("fo:margin", "0cm")) self.assertTrue(e.has_value("fo:page-width", "28cm")) self.assertTrue(e.has_value("fo:page-height", "21cm")) self.assertTrue(e.has_value("style:print-orientation", "landscape")) e = ElementParser(s, 'style:style') self.assertTrue(e.has_value("style:name", "MyMaster-title")) self.assertTrue(e.has_value("style:display-name", "MyMaster-title")) self.assertTrue(e.has_value("style:family", "presentation")) self.assertContains( s, '<style:paragraph-properties fo:text-align="center"/><style:text-properties fo:font-size="34pt"/><style:graphic-properties draw:fill-color="#ffff99"/></style:style></office:styles>' ) e = ElementParser(s, 'style:master-page') self.assertTrue(e.has_value("style:name", "MyMaster")) self.assertTrue(e.has_value("style:display-name", "MyMaster")) self.assertTrue(e.has_value("style:page-layout-name", "MyLayout"))
def __call__(self, doc): chartstyle = style.Style(name="chartstyle", family="chart") chartstyle.addElement( style.GraphicProperties(stroke="none", fillcolor="#ffffff")) doc.automaticstyles.addElement(chartstyle) mychart = chart.Chart( width="576pt", height="504pt", stylename=chartstyle, attributes={'class':self.charttype}) doc.chart.addElement(mychart) # Title if self.title: titlestyle = style.Style(name="titlestyle", family="chart") titlestyle.addElement( style.GraphicProperties(stroke="none", fill="none")) titlestyle.addElement( style.TextProperties(fontfamily="'Nimbus Sans L'", fontfamilygeneric="swiss", fontpitch="variable", fontsize="13pt")) doc.automaticstyles.addElement(titlestyle) mytitle = chart.Title(x="385pt", y="27pt", stylename=titlestyle) mytitle.addElement( text.P(text=self.title)) mychart.addElement(mytitle) # Subtitle if self.subtitle: subtitlestyle = style.Style(name="subtitlestyle", family="chart") subtitlestyle.addElement( style.GraphicProperties(stroke="none", fill="none")) subtitlestyle.addElement( style.TextProperties(fontfamily="'Nimbus Sans L'", fontfamilygeneric="swiss", fontpitch="variable", fontsize="10pt")) doc.automaticstyles.addElement(subtitlestyle) subtitle = chart.Subtitle(x="0pt", y="123pt", stylename=subtitlestyle) subtitle.addElement( text.P(text= self.subtitle)) mychart.addElement(subtitle) # Legend legendstyle = style.Style(name="legendstyle", family="chart") legendstyle.addElement( style.GraphicProperties(fill="none")) legendstyle.addElement( style.TextProperties(fontfamily="'Nimbus Sans L'", fontfamilygeneric="swiss", fontpitch="variable", fontsize="6pt")) doc.automaticstyles.addElement(legendstyle) mylegend = chart.Legend(legendposition="end", legendalign="center", stylename=legendstyle) mychart.addElement(mylegend) # Plot area plotstyle = style.Style(name="plotstyle", family="chart") if self.subtype == "stacked": percentage="false"; stacked="true" elif self.subtype == "percentage": percentage="true"; stacked="false" else: percentage="false"; stacked="false" plotstyle.addElement( style.ChartProperties(seriessource="columns", percentage=percentage, stacked=stacked, threedimensional=self.threedimensional)) doc.automaticstyles.addElement(plotstyle) plotarea = chart.PlotArea(datasourcehaslabels=self.datasourcehaslabels, stylename=plotstyle) mychart.addElement(plotarea) # Style for the X,Y axes axisstyle = style.Style(name="axisstyle", family="chart") axisstyle.addElement( style.ChartProperties(displaylabel="true")) doc.automaticstyles.addElement(axisstyle) # Title for the X axis xaxis = chart.Axis(dimension="x", name="primary-x", stylename=axisstyle) plotarea.addElement(xaxis) xt = chart.Title() xaxis.addElement(xt) xt.addElement(text.P(text=self.x_axis)) # Title for the Y axis yaxis = chart.Axis(dimension="y", name="primary-y", stylename=axisstyle) plotarea.addElement(yaxis) yt = chart.Title() yaxis.addElement(yt) yt.addElement(text.P(text=self.y_axis)) # Data area datatable = DataTable( self.values ) datatable.datasourcehaslabels = self.datasourcehaslabels mychart.addElement(datatable())
# -*- coding: utf-8 -*- """ Tablib - ODF Support. """ from io import BytesIO from odf import opendocument, style, table, text from tablib.compat import unicode title = 'ods' extensions = ('ods', ) bold = style.Style(name="bold", family="paragraph") bold.addElement( style.TextProperties(fontweight="bold", fontweightasian="bold", fontweightcomplex="bold")) def export_set(dataset): """Returns ODF representation of Dataset.""" wb = opendocument.OpenDocumentSpreadsheet() wb.automaticstyles.addElement(bold) ws = table.Table(name=dataset.title if dataset.title else 'Tablib Dataset') wb.spreadsheet.addElement(ws) dset_sheet(dataset, ws) stream = BytesIO() wb.save(stream) return stream.getvalue()
def _make_styles(self, doc, layout): """Generate set of styles for the document. Parameters ---------- doc : `OpenDocumentText` ODT document object. layout : `PageLayout` ODT page layout. """ styles = {} # heading styles, occupies whole page, centered h1font = '22pt' h1topmrg = (layout.height - layout.top - layout.bottom) * 0.5 h1topmrg -= Size(h1font) h1style = style.Style(name="Heading 1", family="paragraph") h1style.addElement( style.ParagraphProperties(textalign='center', breakbefore='page', margintop=str(h1topmrg))) h1style.addElement( style.TextProperties(fontsize=h1font, fontweight='bold')) doc.styles.addElement(h1style) styles['h1'] = h1style brstyle = style.Style(name="Break", family="paragraph") brstyle.addElement( style.ParagraphProperties(textalign='center', breakafter='page')) doc.automaticstyles.addElement(brstyle) styles['br'] = brstyle h2namestyle = style.Style(name="Heading 2 (Name)", family="paragraph") h2namestyle.addElement( style.ParagraphProperties(textalign='center', breakbefore='page', marginbottom="14pt")) h2namestyle.addElement( style.TextProperties(fontsize='14pt', fontweight='bold')) doc.styles.addElement(h2namestyle) styles['h2br'] = h2namestyle h2style = style.Style(name="Heading 2", family="paragraph") h2style.addElement( style.ParagraphProperties(textalign='center', margintop="12pt")) h2style.addElement( style.TextProperties(fontsize='14pt', fontweight='bold')) doc.styles.addElement(h2style) styles['h2'] = h2style h3style = style.Style(name="Heading 3", family="paragraph") # h3style.addElement(style.ParagraphProperties(textalign='center', # margintop="12pt", borderbottom="0.06pt solid #000000")) h3style.addElement( style.ParagraphProperties(textalign='center', margintop="12pt")) h3style.addElement(style.TextProperties(fontweight='bold')) doc.styles.addElement(h3style) styles['h3'] = h3style # style for image imgstyle = style.Style(name="ImgStyle", family="graphic", parentstylename="Graphics") imgstyle.addElement( style.GraphicProperties(verticalpos='top', verticalrel='paragraph-content', horizontalpos='right', horizontalrel='page-content', marginleft="0.1in", marginbottom="0.1in")) doc.automaticstyles.addElement(imgstyle) styles['img'] = imgstyle # centered paragraph centered = style.Style(name="centered", family="paragraph") centered.addElement(style.ParagraphProperties(textalign='center')) doc.styles.addElement(centered) styles['center'] = centered # centered frame frame_center = style.Style(name="frame-center", family="graphic", parentstylename="Graphics") frame_center.addElement( style.GraphicProperties(horizontalpos="center", horizontalrel="paragraph")) doc.automaticstyles.addElement(frame_center) styles['frame_center'] = frame_center # style for tree table treetablestyle = style.Style(name="TreeTableStyle", family="table") treetablestyle.addElement(style.TableProperties(align='center')) doc.automaticstyles.addElement(treetablestyle) styles['treetable'] = treetablestyle treecellstyle = style.Style(name="TreeTableCellStyle", family="table-cell") treecellstyle.addElement( style.TableCellProperties(verticalalign='middle', padding='0.03in')) doc.automaticstyles.addElement(treecellstyle) styles['treecell'] = treecellstyle treeparastyle = style.Style(name="TreeTableParaStyle", family="paragraph") treeparastyle.addElement( style.ParagraphProperties(textalign='center', verticalalign='middle', border="0.06pt solid #000000", padding='0.01in')) treeparastyle.addElement(style.TextProperties(fontsize='10pt')) doc.automaticstyles.addElement(treeparastyle) styles['treepara'] = treeparastyle return styles
def testTextStyleName(self): """ Test that you can use the name of the style in references """ boldstyle = style.Style(name=u"Bold", family=u"text") boldstyle.addElement( style.TextProperties(attributes={u'fontweight': u"bold"})) text.Span(stylename=u"Bold", text=u"This part is bold. ")
sect = style.Style(name="Sect1", family="section") sectTable = style.Style(name="SectTable", family="section") # # Paragraph styles # standard = style.Style(name="Standard", family="paragraph") standard.addElement( style.ParagraphProperties(margintop="0in", marginbottom="0in", punctuationwrap="hanging", linebreak="strict")) standard.addElement( style.TextProperties(color="#000000", fontsize="12pt", fontname="DejaVuSerif", language="en", country="US")) # textbody is the default for text textbody = style.Style(name="TextBody", family="paragraph") textbody.addElement( style.ParagraphProperties(marginbottom="0.05in", margintop="0.04in", textalign="left")) textbody.addElement( style.TextProperties(color="#000000", fontsize="12pt", language="en", country="US", fontname="DejaVuSerif"))
# # textbody is the default for text textbody = style.Style(name="TextBody", family="paragraph") textbody.addElement( style.ParagraphProperties( marginbottom="0.05in", margintop="0.04in", textalign="left", punctuationwrap="hanging", linebreak="strict", orphans="3", keeptogether="always", ) ) textbody.addElement( style.TextProperties( fontsize="12pt", language="en", country="US", fontname="DejaVuSerif" ) ) # # special paragraph styles: paragraph text styles # preformatted = style.Style(name="Preformatted", family="paragraph") preformatted.addElement( style.ParagraphProperties( marginleft=".25in", marginright=".25in", margintop=".25in", marginbottom=".25in", backgroundcolor="#e6e6e6", orphans="3", keeptogether="always", ) ) preformatted.addElement(
if copyrights is not None: # doc.meta.addElement(dc.Rights(text=copyrights)) doc.meta.addElement(meta.UserDefined(name="Rights", text=copyrights)) if ebooknum is not None: doc.meta.addElement(meta.UserDefined(name="EText", text=ebooknum)) arial = style.FontFace(name="Arial", fontfamily="Arial", fontfamilygeneric="swiss", fontpitch="variable") doc.fontfacedecls.addElement(arial) # Paragraph styles standardstyle = style.Style(name="Standard", family="paragraph") standardstyle.addElement(style.ParagraphProperties(marginbottom="0cm", margintop="0cm" )) doc.styles.addElement(standardstyle) h1style = style.Style(name="Heading 1", family="paragraph", defaultoutlinelevel="1") h1style.addElement(style.TextProperties(attributes={'fontsize':"20pt", 'fontweight':"bold"})) doc.styles.addElement(h1style) textbodystyle = style.Style(name="Text body", family="paragraph", parentstylename=standardstyle) textbodystyle.addElement(style.ParagraphProperties(attributes={'marginbottom':"0.212cm", 'margintop':"0cm", 'textalign':"justify", 'justifysingleword':"false"})) doc.styles.addElement(textbodystyle) subtitlestyle = style.Style(name="Subtitle", family="paragraph", nextstylename=textbodystyle) subtitlestyle.addElement(style.ParagraphProperties(textalign="center") ) subtitlestyle.addElement(style.TextProperties(fontsize="14pt", fontstyle="italic", fontname="Arial")) doc.styles.addElement(subtitlestyle) titlestyle = style.Style(name="Title", family="paragraph", nextstylename=subtitlestyle) titlestyle.addElement(style.ParagraphProperties(textalign="center") ) titlestyle.addElement(style.TextProperties(fontsize="18pt", fontweight="bold", fontname="Arial"))
def __call__(self, doc): chartstyle = style.Style(name="chartstyle", family="chart") chartstyle.addElement( style.GraphicProperties(stroke="none", fillcolor="#ffffff")) doc.automaticstyles.addElement(chartstyle) mychart = chart.Chart(width=self.width, height=self.height, stylename=chartstyle, attributes={'class': self.charttype}) doc.chart.addElement(mychart) # Title if self.title: titlestyle = style.Style(name="titlestyle", family="chart") titlestyle.addElement( style.GraphicProperties(stroke="none", fill="none")) titlestyle.addElement( style.TextProperties(fontfamily="'Nimbus Sans L'", fontfamilygeneric="swiss", fontpitch="variable", fontsize="13pt")) doc.automaticstyles.addElement(titlestyle) mytitle = chart.Title(x="185pt", y="27pt", stylename=titlestyle) mytitle.addElement(text.P(text=self.title)) mychart.addElement(mytitle) # Subtitle if self.subtitle: subtitlestyle = style.Style(name="subtitlestyle", family="chart") subtitlestyle.addElement( style.GraphicProperties(stroke="none", fill="none")) subtitlestyle.addElement( style.TextProperties(fontfamily="'Nimbus Sans L'", fontfamilygeneric="swiss", fontpitch="variable", fontsize="10pt")) doc.automaticstyles.addElement(subtitlestyle) subtitle = chart.Subtitle(x="50pt", y="50pt", stylename=subtitlestyle) subtitle.addElement(text.P(text=self.subtitle)) mychart.addElement(subtitle) # Legend legendstyle = style.Style(name="legendstyle", family="chart") legendstyle.addElement(style.GraphicProperties(fill="none")) legendstyle.addElement( style.TextProperties(fontfamily="'Nimbus Sans L'", fontfamilygeneric="swiss", fontpitch="variable", fontsize="8pt")) doc.automaticstyles.addElement(legendstyle) mylegend = chart.Legend(legendposition="end", legendalign="center", stylename=legendstyle) mychart.addElement(mylegend) # Plot area plotstyle = style.Style(name="plotstyle", family="chart") if self.subtype == "stacked": percentage = "false" stacked = "true" elif self.subtype == "percentage": percentage = "true" stacked = "false" else: percentage = "false" stacked = "false" plotstyle.addElement( style.ChartProperties(seriessource="columns", percentage=percentage, stacked=stacked, threedimensional=self.threedimensional)) doc.automaticstyles.addElement(plotstyle) plotarea = chart.PlotArea(datasourcehaslabels=self.datasourcehaslabels, stylename=plotstyle) mychart.addElement(plotarea) # Style for the X,Y axes axisstyle = style.Style(name="axisstyle", family="chart") axisstyle.addElement(style.ChartProperties(displaylabel="true")) axisstyle.addElement( style.TextProperties(fontfamily="'Nimbus Sans L'", fontfamilygeneric="swiss", fontpitch="variable", fontsize="8pt")) doc.automaticstyles.addElement(axisstyle) # Title for the X axis xaxis = chart.Axis(dimension="x", name="primary-x", stylename=axisstyle) plotarea.addElement(xaxis) xt = chart.Title() xaxis.addElement(xt) xt.addElement(text.P(text=self.x_axis)) # Title for the Y axis yaxis = chart.Axis(dimension="y", name="primary-y", stylename=axisstyle) plotarea.addElement(yaxis) yt = chart.Title() yaxis.addElement(yt) yt.addElement(text.P(text=self.y_axis)) # chart colors piestyle = style.Style(name="series", family="chart") piestyle.addElement(style.GraphicProperties(fillcolor="#000000")) doc.automaticstyles.addElement(piestyle) piestyle = style.Style(name="piestyle.critical", family="chart") piestyle.addElement(style.ChartProperties(solidtype="cuboid")) piestyle.addElement(style.GraphicProperties(fillcolor=riskCritical)) doc.automaticstyles.addElement(piestyle) piestyle = style.Style(name="piestyle.high", family="chart") piestyle.addElement(style.ChartProperties(solidtype="cuboid")) piestyle.addElement(style.GraphicProperties(fillcolor=riskHigh)) doc.automaticstyles.addElement(piestyle) piestyle = style.Style(name="piestyle.medium", family="chart") piestyle.addElement(style.ChartProperties(solidtype="cuboid")) piestyle.addElement(style.GraphicProperties(fillcolor=riskMedium)) doc.automaticstyles.addElement(piestyle) piestyle = style.Style(name="piestyle.low", family="chart") piestyle.addElement(style.ChartProperties(solidtype="cuboid")) piestyle.addElement(style.GraphicProperties(fillcolor=riskLow)) doc.automaticstyles.addElement(piestyle) piestyle = style.Style(name="piestyle.none", family="chart") piestyle.addElement(style.ChartProperties(solidtype="cuboid")) piestyle.addElement(style.GraphicProperties(fillcolor=riskNone)) doc.automaticstyles.addElement(piestyle) # Set up the data series. OOo doesn't show correctly without them. s = chart.Series(valuescellrangeaddress="local-table.$B$2:.$B$6", labelcelladdress="local-table.$B$1", attributes={'class': self.charttype}, stylename="series") s.addElement(chart.DataPoint(stylename="piestyle.critical")) s.addElement(chart.DataPoint(stylename="piestyle.high")) s.addElement(chart.DataPoint(stylename="piestyle.medium")) s.addElement(chart.DataPoint(stylename="piestyle.low")) s.addElement(chart.DataPoint(stylename="piestyle.none")) plotarea.addElement(s) # The data are placed in a table inside the chart object - but could also be a # table in the main document datatable = DataTable(self.values) datatable.datasourcehaslabels = self.datasourcehaslabels mychart.addElement(datatable())
for child in children: if not parents.has_key(child): parents[child] = [] if not parent in parents[child]: parents[child].append(parent) doc=OpenDocumentText() textdoc = doc.text def makeclass(t): return "%s.%s" % ( nsdict[t[0]], t[1].title().replace('-','')) # Styles h1style = style.Style(name="Heading 1",family="paragraph") h1style.addElement(style.TextProperties(attributes={'fontsize':"24pt", 'fontweight':"bold"})) doc.styles.addElement(h1style) h2style = style.Style(name="Heading 2",family="paragraph") h2style.addElement(style.TextProperties(attributes={'fontsize':"16pt", 'fontweight':"bold", 'fontstyle':"italic"})) doc.styles.addElement(h2style) h3style = style.Style(name="Heading 3",family="paragraph") h3style.addElement(style.TextProperties(attributes={'fontsize':"14pt", 'fontweight':"bold"})) doc.styles.addElement(h3style) #boldstyle = style.Style(name="Bold",family="text") #boldstyle.addElement(style.TextProperties(attributes={'fontweight':"bold"})) #textdoc.automaticstyles.addElement(boldstyle) attrliststyle = style.Style(name="Attribute List",family="text") attrliststyle.addElement(style.TextProperties(fontstyle="italic")) doc.styles.addElement(attrliststyle)