def _numbered_style(): """Create a numbered list style.""" style = ListStyle(name='_numbered_list') lls = ListLevelStyleNumber(level=1) lls.setAttribute('displaylevels', 1) lls.setAttribute('numsuffix', '. ') lls.setAttribute('numformat', '1') llp = ListLevelProperties() llp.setAttribute('listlevelpositionandspacemode', 'label-alignment') llla = ListLevelLabelAlignment(labelfollowedby='listtab') llla.setAttribute('listtabstopposition', '1.27cm') llla.setAttribute('textindent', '-0.635cm') llla.setAttribute('marginleft', '1.27cm') llp.addElement(llla) # llp.setAttribute('spacebefore', '') # llp.setAttribute('minlabelwidth', '') lls.addElement(llp) style.addElement(lls) return style
def styleFromList( styleName, specArray, spacing, showAllLevels): bullet = "" numPrefix = "" numSuffix = "" numberFormat = "" cssLengthNum = 0 cssLengthUnits = "" numbered = False displayLevels = 0 listStyle = ListStyle(name=styleName) numFormatPattern = re.compile("([1IiAa])") cssLengthPattern = re.compile("([^a-z]+)\\s*([a-z]+)?") m = cssLengthPattern.search( spacing ) if (m != None): cssLengthNum = float(m.group(1)) if (m.lastindex == 2): cssLengthUnits = m.group(2) i = 0 while i < len(specArray): specification = specArray[i] m = numFormatPattern.search(specification) if (m != None): numberFormat = m.group(1) numPrefix = specification[0:m.start(1)] numSuffix = specification[m.end(1):] bullet = "" numbered = True if (showAllLevels): displayLevels = i + 1 else: displayLevels = 1 else: # it's a bullet style bullet = specification numPrefix = "" numSuffix = "" numberFormat = "" displayLevels = 1 numbered = False if (numbered): lls = ListLevelStyleNumber(level=(i+1)) if (numPrefix != ''): lls.setAttribute('numprefix', numPrefix) if (numSuffix != ''): lls.setAttribute('numsuffix', numSuffix) lls.setAttribute('displaylevels', displayLevels) else: lls = ListLevelStyleBullet(level=(i+1),bulletchar=bullet[0]) llp = ListLevelProperties() llp.setAttribute('spacebefore', str(cssLengthNum * (i+1)) + cssLengthUnits) llp.setAttribute('minlabelwidth', str(cssLengthNum) + cssLengthUnits) lls.addElement( llp ) listStyle.addElement(lls) i += 1 return listStyle
def __init__(self, filename): self.filename = filename self.doc = OpenDocumentText() # font self.doc.fontfacedecls.addElement((FontFace(name="Arial", fontfamily="Arial", fontsize="10", fontpitch="variable", fontfamilygeneric="swiss"))) # styles style_standard = Style(name="Standard", family="paragraph", attributes={"class": "text"}) style_standard.addElement( ParagraphProperties(punctuationwrap="hanging", writingmode="page", linebreak="strict")) style_standard.addElement(TextProperties(fontname="Arial", fontsize="10pt", fontsizecomplex="10pt", fontsizeasian="10pt")) self.doc.styles.addElement(style_standard) # automatic styles style_normal = Style(name="ResumeText", parentstylename="Standard", family="paragraph") self.doc.automaticstyles.addElement(style_normal) style_bold_text = Style( name="ResumeBoldText", parentstylename="Standard", family="text") style_bold_text.addElement(TextProperties(fontweight="bold", fontweightasian="bold", fontweightcomplex="bold")) self.doc.automaticstyles.addElement(style_bold_text) style_list_text = ListStyle(name="ResumeListText") style_list_bullet = ListLevelStyleBullet(level="1", stylename="ResumeListTextBullet", numsuffix=".", bulletchar=u'\u2022') style_list_bullet.addElement(ListLevelProperties(spacebefore="0.1in", minlabelwidth="0.2in")) style_list_text.addElement(style_list_bullet) self.doc.automaticstyles.addElement(style_list_text) style_bold_para = Style(name="ResumeH2", parentstylename="Standard", family="paragraph") style_bold_para.addElement(TextProperties(fontweight="bold", fontweightasian="bold", fontweightcomplex="bold")) self.doc.automaticstyles.addElement(style_bold_para) style_bold_center = Style(name="ResumeH1", parentstylename="Standard", family="paragraph") style_bold_center.addElement(TextProperties(fontweight="bold", fontweightasian="bold", fontweightcomplex="bold")) style_bold_center.addElement(ParagraphProperties(textalign="center")) self.doc.automaticstyles.addElement(style_bold_center)
def styleFromList(styleName, specArray, spacing, showAllLevels): bullet = "" numPrefix = "" numSuffix = "" numberFormat = "" cssLengthNum = 0 cssLengthUnits = "" numbered = False displayLevels = 0 listStyle = ListStyle(name=styleName) numFormatPattern = re.compile("([1IiAa])") cssLengthPattern = re.compile("([^a-z]+)\\s*([a-z]+)?") m = cssLengthPattern.search(spacing) if (m != None): cssLengthNum = float(m.group(1)) if (m.lastindex == 2): cssLengthUnits = m.group(2) i = 0 while i < len(specArray): specification = specArray[i] m = numFormatPattern.search(specification) if (m != None): numberFormat = m.group(1) numPrefix = specification[0:m.start(1)] numSuffix = specification[m.end(1):] bullet = "" numbered = True if (showAllLevels): displayLevels = i + 1 else: displayLevels = 1 else: # it's a bullet style bullet = specification numPrefix = "" numSuffix = "" numberFormat = "" displayLevels = 1 numbered = False if (numbered): lls = ListLevelStyleNumber(level=(i + 1)) if (numPrefix != ''): lls.setAttribute('numprefix', numPrefix) if (numSuffix != ''): lls.setAttribute('numsuffix', numSuffix) lls.setAttribute('displaylevels', displayLevels) else: lls = ListLevelStyleBullet(level=(i + 1), bulletchar=bullet[0]) llp = ListLevelProperties() llp.setAttribute('spacebefore', str(cssLengthNum * (i + 1)) + cssLengthUnits) llp.setAttribute('minlabelwidth', str(cssLengthNum) + cssLengthUnits) lls.addElement(llp) listStyle.addElement(lls) i += 1 return listStyle
def insert_table_(self, ar, column_names=None, table_width=180): # logger.info("20160330 insert_table(%s)", ar) ar.setup_from(self.ar) columns, headers, widths = ar.get_field_info(column_names) widths = map(int, widths) tw = sum(widths) # specifying relative widths doesn't seem to work (and that's # a pity because absolute widths requires us to know the # table_width). use_relative_widths = False if use_relative_widths: width_specs = ["%d*" % (w * 100 / tw) for w in widths] else: width_specs = ["%dmm" % (table_width * w / tw) for w in widths] doc = OpenDocumentText() def add_style(**kw): st = Style(**cleankw(kw)) doc.styles.addElement(st) self.my_styles.append(st) return st table_style_name = str(ar.actor) st = add_style(name=table_style_name, family="table", parentstylename="Default") st.addElement( TableProperties(align="margins", maybreakbetweenrows="0")) # create some *visible* styles st = add_style(name="Table Contents", family="paragraph", parentstylename="Default") st.addElement(ParagraphProperties(numberlines="false", linenumber="0")) st = add_style(name="Number Cell", family="paragraph", parentstylename="Table Contents") st.addElement(ParagraphProperties( numberlines="false", textalign="end", justifysingleword="true", linenumber="0")) dn = "Table Column Header" st = self.stylesManager.styles.getStyle(dn) if st is None: st = add_style(name=dn, family="paragraph", parentstylename="Table Contents") st.addElement( ParagraphProperties(numberlines="false", linenumber="0")) st.addElement(TextProperties(fontweight="bold")) dn = "Bold Text" st = self.stylesManager.styles.getStyle(dn) if st is None: st = add_style(name=dn, family="text", parentstylename="Default") #~ st = add_style(name=dn, family="text") st.addElement(TextProperties(fontweight="bold")) if False: dn = "L1" st = self.stylesManager.styles.getStyle(dn) if st is None: st = ListStyle(name=dn) doc.styles.addElement(st) p = ListLevelProperties( listlevelpositionandspacemode="label-alignment") st.addElement(p) #~ label-followed-by="listtab" text:list-tab-stop-position="1.27cm" fo:text-indent="-0.635cm" fo:margin-left="1.27cm"/> p.addElement(ListLevelLabelAlignment(labelfollowedby="listtab", listtabstopposition="1.27cm", textindent="-0.635cm", marginleft="1.27cm" )) self.my_styles.append(st) #~ list_style = add_style(name=dn, family="list") bullet = text.ListLevelStyleBullet( level=1, stylename="Bullet_20_Symbols", bulletchar=u"•") #~ bullet = text.ListLevelStyleBullet(level=1,stylename="Bullet_20_Symbols",bulletchar=u"*") #~ <text:list-level-style-bullet text:level="1" text:style-name="Bullet_20_Symbols" text:bullet-char="•"> st.addElement(bullet) # create some automatic styles def add_style(**kw): st = Style(**cleankw(kw)) doc.automaticstyles.addElement(st) self.my_automaticstyles.append(st) return st cell_style = add_style(name="Lino Cell Style", family="table-cell") cell_style.addElement(TableCellProperties( paddingleft="1mm", paddingright="1mm", paddingtop="1mm", paddingbottom="0.5mm", border="0.002cm solid #000000")) header_row_style = add_style( name="Lino Header Row", family="table-row", parentstylename=cell_style) header_row_style.addElement( TableRowProperties(backgroundcolor="#eeeeee")) total_row_style = add_style( name="Lino Total Row", family="table-row", parentstylename=cell_style) total_row_style.addElement( TableRowProperties(backgroundcolor="#ffffff")) table = Table(name=table_style_name, stylename=table_style_name) table_columns = TableColumns() table.addElement(table_columns) table_header_rows = TableHeaderRows() table.addElement(table_header_rows) table_rows = TableRows() table.addElement(table_rows) # create table columns and automatic table-column styles for i, fld in enumerate(columns): #~ print 20120415, repr(fld.name) name = str(ar.actor) + "." + str(fld.name) cs = add_style(name=name, family="table-column") if use_relative_widths: cs.addElement( TableColumnProperties(relcolumnwidth=width_specs[i])) else: cs.addElement( TableColumnProperties(columnwidth=width_specs[i])) #~ cs.addElement(TableColumnProperties(useoptimalcolumnwidth='true')) #~ k = cs.getAttribute('name') #~ renderer.stylesManager.styles[k] = toxml(e) #~ doc.automaticstyles.addElement(cs) #~ self.my_automaticstyles.append(cs) table_columns.addElement(TableColumn(stylename=name)) def fldstyle(fld): #~ if isinstance(fld,ext_store.VirtStoreField): #~ fld = fld.delegate if isinstance(fld, NumberFieldElement): return "Number Cell" return "Table Contents" def value2cell(ar, i, fld, val, style_name, tc): # if i == 0: # logger.info("20160330a value2cell(%s, %s)", fld.__class__, val) txt = fld.value2html(ar, val) # if i == 0: # logger.info("20160330b value2cell(%s)", E.tostring(txt)) p = text.P(stylename=style_name) html2odf(txt, p) try: tc.addElement(p) except Exception as e: dd.logger.warning("20120614 addElement %s %s %r : %s", i, fld, val, e) #~ print 20120614, i, fld, val, e #~ yield P(stylename=tablecontents,text=text) # create header row #~ hr = TableRow(stylename=HEADER_ROW_STYLE_NAME) hr = TableRow(stylename=header_row_style) table_header_rows.addElement(hr) for h in headers: #~ for fld in fields: #~ tc = TableCell(stylename=CELL_STYLE_NAME) tc = TableCell(stylename=cell_style) tc.addElement(text.P( stylename="Table Column Header", #~ text=force_text(fld.field.verbose_name or fld.name))) text=force_text(h))) hr.addElement(tc) sums = [fld.zero for fld in columns] for row in ar.data_iterator: #~ for grp in ar.group_headers(row): #~ raise NotImplementedError() tr = TableRow() has_numeric_value = False for i, fld in enumerate(columns): #~ tc = TableCell(stylename=CELL_STYLE_NAME) tc = TableCell(stylename=cell_style) #~ if fld.field is not None: v = fld.field._lino_atomizer.full_value_from_object(row, ar) stylename = fldstyle(fld) if v is None: tc.addElement(text.P(stylename=stylename, text='')) else: value2cell(ar, i, fld, v, stylename, tc) nv = fld.value2num(v) if nv != 0: sums[i] += nv has_numeric_value = True #~ sums[i] += fld.value2num(v) tr.addElement(tc) if has_numeric_value or not ar.actor.hide_zero_rows: table_rows.addElement(tr) if not ar.actor.hide_sums: if sums != [fld.zero for fld in columns]: tr = TableRow(stylename=total_row_style) table_rows.addElement(tr) sums = {fld.name: sums[i] for i, fld in enumerate(columns)} for i, fld in enumerate(columns): tc = TableCell(stylename=cell_style) stylename = fldstyle(fld) p = text.P(stylename=stylename) e = fld.format_sum(ar, sums, i) html2odf(e, p) tc.addElement(p) #~ if len(txt) != 0: #~ msg = "html2odf() returned " #~ logger.warning(msg) #~ txt = tuple(html2odf(fld.format_sum(ar,sums,i),p)) #~ assert len(txt) == 1 #~ tc.addElement(text.P(stylename=stylename,text=txt[0])) tr.addElement(tc) doc.text.addElement(table) return toxml(table)
""" <text:list-style style:name="L1"> <text:list-level-style-bullet text:level="1" text:style-name="Numbering_20_Symbols" style:num-suffix="." text:bullet-char="•"> <style:list-level-properties text:space-before="0.25in" text:min-label-width="0.25in"/> <style:text-properties style:font-name="StarSymbol"/> </text:list-level-style-bullet> </text:list-style> """ L1style=ListStyle(name="L1") # u'\u2022' is the bullet character (http://www.unicode.org/charts/PDF/U2000.pdf) bullet1 = ListLevelStyleBullet(level="1", stylename="Numbering_20_Symbols", numsuffix=".", bulletchar=u'\u2022') L1prop1 = ListLevelProperties(spacebefore="0.25in", minlabelwidth="0.25in") bullet1.addElement(L1prop1) L1style.addElement(bullet1) textdoc.automaticstyles.addElement(L1style) # P6 """ <style:style style:name="P6" style:family="paragraph" style:parent-style-name="Standard" style:list-style-name="L5"/> """ P6style = Style(name="P6", family="paragraph", parentstylename="Standard", liststylename="L5") textdoc.automaticstyles.addElement(P6style)
def insert_table_(self,ar,column_names=None,table_width=180): ar.setup_from(self.ar) columns, headers, widths = ar.get_field_info(column_names) widths = map(int,widths) tw = sum(widths) """ specifying relative widths doesn't seem to work (and that's a pity because absolute widths requires us to know the table_width). """ use_relative_widths = False if use_relative_widths: width_specs = ["%d*" % (w*100/tw) for w in widths] #~ width_specs = [(w*100/tw) for w in widths] else: #~ total_width = 180 # suppose table width = 18cm = 180mm width_specs = ["%dmm" % (table_width*w/tw) for w in widths] #~ else: #~ width_specs = [] #~ for w in widths: #~ if w.endswith('%'): #~ mm = float(w[:-1]) * table_width / 100 #~ width_specs.append("%dmm" % mm) #~ else: #~ print 20120419, width_specs doc = OpenDocumentText() def add_style(**kw): st = Style(**kw) doc.styles.addElement(st) self.my_styles.append(st) return st table_style_name = str(ar.actor) st = add_style(name=table_style_name, family="table",parentstylename="Default") st.addElement(TableProperties(align="margins", maybreakbetweenrows="0")) # create some *visible* styles st = add_style(name="Table Contents", family="paragraph",parentstylename="Default") st.addElement(ParagraphProperties(numberlines="false", linenumber="0")) st = add_style(name="Number Cell", family="paragraph",parentstylename="Table Contents") st.addElement(ParagraphProperties(numberlines="false", textalign="end", justifysingleword="true", linenumber="0")) dn = "Table Column Header" st = self.stylesManager.styles.getStyle(dn) if st is None: st = add_style(name=dn, family="paragraph",parentstylename="Table Contents") st.addElement(ParagraphProperties(numberlines="false", linenumber="0")) st.addElement(TextProperties(fontweight="bold")) dn = "Bold Text" st = self.stylesManager.styles.getStyle(dn) if st is None: st = add_style(name=dn, family="text",parentstylename="Default") #~ st = add_style(name=dn, family="text") st.addElement(TextProperties(fontweight="bold")) if False: dn = "L1" st = self.stylesManager.styles.getStyle(dn) if st is None: st = ListStyle(name=dn) doc.styles.addElement(st) p = ListLevelProperties(listlevelpositionandspacemode="label-alignment") st.addElement(p) #~ label-followed-by="listtab" text:list-tab-stop-position="1.27cm" fo:text-indent="-0.635cm" fo:margin-left="1.27cm"/> p.addElement(ListLevelLabelAlignment(labelfollowedby="listtab", listtabstopposition="1.27cm", textindent="-0.635cm", marginleft="1.27cm" )) self.my_styles.append(st) #~ list_style = add_style(name=dn, family="list") bullet = text.ListLevelStyleBullet(level=1,stylename="Bullet_20_Symbols",bulletchar=u"•") #~ bullet = text.ListLevelStyleBullet(level=1,stylename="Bullet_20_Symbols",bulletchar=u"*") #~ <text:list-level-style-bullet text:level="1" text:style-name="Bullet_20_Symbols" text:bullet-char="•"> st.addElement(bullet) # create some automatic styles def add_style(**kw): st = Style(**kw) doc.automaticstyles.addElement(st) self.my_automaticstyles.append(st) return st cell_style = add_style(name="Lino Cell Style",family="table-cell") cell_style.addElement(TableCellProperties( paddingleft="1mm",paddingright="1mm", paddingtop="1mm",paddingbottom="0.5mm", border="0.002cm solid #000000")) header_row_style = add_style(name="Lino Header Row",family="table-row",parentstylename=cell_style) header_row_style.addElement(TableRowProperties(backgroundcolor="#eeeeee")) total_row_style = add_style(name="Lino Total Row",family="table-row",parentstylename=cell_style) total_row_style.addElement(TableRowProperties(backgroundcolor="#ffffff")) table = Table(name=table_style_name,stylename=table_style_name) table_columns = TableColumns() table.addElement(table_columns) table_header_rows = TableHeaderRows() table.addElement(table_header_rows) table_rows = TableRows() table.addElement(table_rows) # create table columns and automatic table-column styles for i,fld in enumerate(columns): #~ print 20120415, repr(fld.name) name = str(ar.actor)+"."+fld.name cs = add_style(name=name, family="table-column") if use_relative_widths: cs.addElement(TableColumnProperties(relcolumnwidth=width_specs[i])) else: cs.addElement(TableColumnProperties(columnwidth=width_specs[i])) #~ cs.addElement(TableColumnProperties(useoptimalcolumnwidth='true')) #~ k = cs.getAttribute('name') #~ renderer.stylesManager.styles[k] = toxml(e) #~ doc.automaticstyles.addElement(cs) #~ self.my_automaticstyles.append(cs) table_columns.addElement(TableColumn(stylename=name)) from lino.ui import elems def fldstyle(fld): #~ if isinstance(fld,ext_store.VirtStoreField): #~ fld = fld.delegate if isinstance(fld,elems.NumberFieldElement): return "Number Cell" return "Table Contents" def value2cell(ar,i,fld,val,style_name,tc): #~ text = html2odt.html2odt(fld.value2html(ar,val)) params = dict() #~ if isinstance(fld,ext_store.BooleanStoreField): #~ params.update(text=fld.value2html(ar,val)) #~ else: #~ params.update(text=fld.format_value(ar,val)) #~ params.update(text=fld.format_value(ar,val)) txt = fld.value2html(ar,val) p = text.P(stylename=style_name) html2odf(txt,p) try: tc.addElement(p) except Exception as e: logger.warning("20120614 addElement %s %s %r : %s", i, fld, val, e) #~ print 20120614, i, fld, val, e #~ yield P(stylename=tablecontents,text=text) # create header row #~ hr = TableRow(stylename=HEADER_ROW_STYLE_NAME) hr = TableRow(stylename=header_row_style) table_header_rows.addElement(hr) for h in headers: #~ for fld in fields: #~ tc = TableCell(stylename=CELL_STYLE_NAME) tc = TableCell(stylename=cell_style) tc.addElement(text.P( stylename="Table Column Header", #~ text=force_unicode(fld.field.verbose_name or fld.name))) text=force_unicode(h))) hr.addElement(tc) sums = [fld.zero for fld in columns] for row in ar.data_iterator: #~ for grp in ar.group_headers(row): #~ raise NotImplementedError() tr = TableRow() has_numeric_value = False for i,fld in enumerate(columns): #~ tc = TableCell(stylename=CELL_STYLE_NAME) tc = TableCell(stylename=cell_style) #~ if fld.field is not None: v = fld.field._lino_atomizer.full_value_from_object(row,ar) stylename = fldstyle(fld) if v is None: tc.addElement(text.P(stylename=stylename,text='')) else: value2cell(ar,i,fld,v,stylename,tc) nv = fld.value2num(v) if nv != 0: sums[i] += nv has_numeric_value = True #~ sums[i] += fld.value2num(v) tr.addElement(tc) if has_numeric_value or not ar.actor.hide_zero_rows: table_rows.addElement(tr) if not ar.actor.hide_sums: if sums != [fld.zero for fld in columns]: tr = TableRow(stylename=total_row_style) table_rows.addElement(tr) for i,fld in enumerate(columns): tc = TableCell(stylename=cell_style) stylename = fldstyle(fld) p = text.P(stylename=stylename) e = fld.format_sum(ar,sums,i) html2odf(e,p) tc.addElement(p) #~ if len(txt) != 0: #~ msg = "html2odf() returned " #~ logger.warning(msg) #~ txt = tuple(html2odf(fld.format_sum(ar,sums,i),p)) #~ assert len(txt) == 1 #~ tc.addElement(text.P(stylename=stylename,text=txt[0])) tr.addElement(tc) doc.text.addElement(table) return toxml(table)
def generate(self): self._textdoc = OpenDocumentText() # Creating different style used in the document s = self._textdoc.styles # For Level-1 Headings that are centerd h1style = Style(name="BsHeading 1", family="paragraph") h1style.addElement( ParagraphProperties(attributes={"textalign": "center"})) h1style.addElement( TextProperties(attributes={ "fontsize": "18pt", "fontweight": "bold" })) # For Level-2 Headings that are centered self._h2style = Style(name="BsHeading 2", family="paragraph") self._h2style.addElement( ParagraphProperties(attributes={"textalign": "left"})) self._h2style.addElement( TextProperties(attributes={ "fontsize": "15pt", "fontweight": "bold" })) # For Level-3 Headings that are centered self._h3style = Style(name="BsHeading 3", family="paragraph") self._h3style.addElement( ParagraphProperties(attributes={"textalign": "left"})) self._h3style.addElement( TextProperties(attributes={ "fontsize": "14pt", "fontweight": "bold" })) # For bold text boldstyle = Style(name="Bold", family="text") boldstyle.addElement(TextProperties(attributes={"fontweight": "bold"})) # For numbered list numberedliststyle = ListStyle(name="NumberedList") level = 1 numberedlistproperty = ListLevelStyleNumber(level=str(level), numsuffix=".", startvalue=1) numberedlistproperty.setAttribute('numsuffix', ".") numberedlistproperty.addElement( ListLevelProperties(minlabelwidth="%fcm" % (level - .2))) numberedliststyle.addElement(numberedlistproperty) # For Bulleted list bulletedliststyle = ListStyle(name="BulletList") level = 1 bulletlistproperty = ListLevelStyleBullet(level=str(level), bulletchar=u"•") bulletlistproperty.addElement( ListLevelProperties(minlabelwidth="%fcm" % level)) bulletedliststyle.addElement(bulletlistproperty) # Justified style self._justifystyle = Style(name="justified", family="paragraph") self._justifystyle.addElement( ParagraphProperties(attributes={"textalign": "justify"})) # Creating a tabstop at 10cm tabstops_style = TabStops() tabstop_style = TabStop(position="10cm") tabstops_style.addElement(tabstop_style) tabstoppar = ParagraphProperties() tabstoppar.addElement(tabstops_style) tabparagraphstyle = Style(name="Question", family="paragraph") tabparagraphstyle.addElement(tabstoppar) s.addElement(tabparagraphstyle) # Register created styles to styleset s.addElement(h1style) s.addElement(self._h2style) s.addElement(boldstyle) s.addElement(numberedliststyle) s.addElement(bulletedliststyle) s.addElement(self._justifystyle) s.addElement(tabparagraphstyle) # Adding main heading mymainheading_element = H(outlinelevel=1, stylename=h1style) mymainheading_text = "Save the Cat Beat Sheet" teletype.addTextToElement(mymainheading_element, mymainheading_text) self._textdoc.text.addElement(mymainheading_element) self._addSubSection('Name', self._data['movie']['name']) self._addSubSection('LogLine', self._data['movie']['logline']) self._addSubSection('Theme', self._data['movie']['theme']) self._addSubSection('Genre', self._data['movie']['genre']) self._addSubSection('Author', '') self._addParagraph('Nome: ' + self._data['author']['name']) self._addParagraph('e-mail: ' + self._data['author']['email']) self._addParagraph('Institute: ' + self._data['author']['institute']) self._addSubSection('Synopsis', self._data['synopsis']) self._addSubSection('Beat Sheet', '') for card in self._data[1]['beat-sheet']: self._addSubSubSection(card['title'], card['text']) self._addSubSection('Plot', self._data['plot']) self._addSubSection('Argumento', self._data['argumento']) self._addSubSection('Escaleta', self._data['escaleta']) # Adding bulleted list # bulletlist = List(stylename=bulletedliststyle) # listitemelement1 = ListItem() # listitemelement1_paragraph = P() # listitemelement1_content = "My first item" # teletype.addTextToElement(listitemelement1_paragraph, listitemelement1_content) # listitemelement1.addElement(listitemelement1_paragraph) # bulletlist.addElement(listitemelement1) # listitemelement2 = ListItem() # listitemelement2_paragraph = P() # listitemelement2_content = "My second item" # teletype.addTextToElement(listitemelement2_paragraph, listitemelement2_content) # listitemelement2.addElement(listitemelement2_paragraph) # bulletlist.addElement(listitemelement2) # # self._textdoc.text.addElement(bulletlist) # # # Adding numbered list # numberlist = List(stylename=numberedliststyle) # listitemelement1 = ListItem() # listitemelement1_paragraph = P() # listitemelement1_content = "My first item" # teletype.addTextToElement(listitemelement1_paragraph, listitemelement1_content) # listitemelement1.addElement(listitemelement1_paragraph) # numberlist.addElement(listitemelement1) # listitemelement2 = ListItem() # listitemelement2_paragraph = P() # listitemelement2_content = "My second item" # teletype.addTextToElement(listitemelement2_paragraph, listitemelement2_content) # listitemelement2.addElement(listitemelement2_paragraph) ## numberlist.addElement(listitemelement2) ## # self._textdoc.text.addElement(numberlist) # Adding a tabbed sentence to check tabstop # newtext = "Testing\tTabstops" # tabp = P(stylename=tabparagraphstyle) # teletype.addTextToElement(tabp, newtext) # self._textdoc.text.addElement(tabp) self._textdoc.save(u"/tmp/save-the-cat.odt")