예제 #1
0
 def ConfigurarEstilos(self):
     nombre = "Linea horizontal gruesa"
     ###############
     ### Estilos ###
     ###############
     #H1
     H1 = "Heading 1"
     estilo = Style(name=H1, family="paragraph")
     estilo.addElement(
         TextProperties(
             attributes={
                 'fontsize': "14pt",
                 'fontweight': "bold",
                 'fontfamily': "helvetica"
             }))
     estilo.addElement(
         ParagraphProperties(attributes={
             'textalign': "Left",
             'paddingtop': "0cm"
         }))
     self.UpdateEstilos(H1, estilo)
     #H2
     H2 = "Heading 2"
     estilo = Style(name=H2, family="paragraph", parentstylename=H1)
     estilo.addElement(TextProperties(attributes={"fontsize": "12pt"}))
     self.UpdateEstilos(H2, estilo)
     #normal
     normal = "Normal"
     estilo = Style(name=normal, family="text")
     estilo.addElement(
         TextProperties(fontfamily="helvetica", fontsize="10pt"))
     self.UpdateEstilos(normal, estilo)
     #negritas
     negritas = "Negritas"
     estilo = Style(name=negritas, family="text", parentstylename=normal)
     estilo.addElement(TextProperties(fontweight="bold"))
     self.UpdateEstilos(negritas, estilo)
     #normal parrafo
     normal_parrafo = "NormalP"
     estilo = Style(name=normal_parrafo, family="paragraph")
     estilo.addElement(
         TextProperties(fontfamily="helvetica", fontsize="10pt"))
     self.UpdateEstilos(normal_parrafo, estilo)
     #negritas parrafo
     negritas_parrafo = "NegritasP"
     estilo = Style(name=negritas_parrafo,
                    family="paragraph",
                    parentstylename=normal_parrafo)
     estilo.addElement(TextProperties(fontweight="bold"))
     self.UpdateEstilos(negritas_parrafo, estilo)
     #conjunto de tabuladores 1 (PARA  EL LISTADO DE CAPITULOS)
     tabstops_list_capitulos = TabStops()
     #Cada tabulador
     tabstop1 = TabStop(position="1.2cm")
     tabstops_list_capitulos.addElement(tabstop1)
     tabstop1 = TabStop(position="14.0cm",
                        type="char",
                        char=",",
                        leaderstyle="dotted")
     tabstops_list_capitulos.addElement(tabstop1)
     tabstop1 = TabStop(position="15.0cm")
     tabstops_list_capitulos.addElement(tabstop1)
     tabstoppar_capitulos = ParagraphProperties()
     tabstoppar_capitulos.addElement(tabstops_list_capitulos)
     tabuladores_hoja_capitulos = "Tabuladores Hoja Capitulos"
     estilo = Style(name=tabuladores_hoja_capitulos, family="paragraph")
     estilo.addElement(tabstoppar_capitulos)
     self.UpdateEstilos(tabuladores_hoja_capitulos, estilo)
     #conjunto de tabuladores 2 (PARA  LAS LINEAS DE RESUMEN)
     tabstops_list_resumen = TabStops()
     #Cada tabulador
     tabstop2 = TabStop(position="1.2cm")
     tabstops_list_resumen.addElement(tabstop2)
     tabstop2 = TabStop(position="2.0cm")
     tabstops_list_resumen.addElement(tabstop2)
     tabstop2 = TabStop(position="14.0cm",
                        type="char",
                        char=",",
                        leaderstyle="dotted")
     tabstops_list_resumen.addElement(tabstop2)
     tabstoppar_resumen = ParagraphProperties()
     tabstoppar_resumen.addElement(tabstops_list_resumen)
     tabuladores_hoja_resumen = "Tabuladores Hoja Resumen"
     estilo = Style(name=tabuladores_hoja_resumen, family="paragraph")
     estilo.addElement(tabstoppar_resumen)
     self.UpdateEstilos(tabuladores_hoja_resumen, estilo)
     #normal con tabuladores hoja capitulos
     normal_con_tabuladores_capitulos = "Normal con tabuladores capitulos"
     estilo = Style(name=normal_con_tabuladores_capitulos,
                    family="paragraph",
                    parentstylename=tabuladores_hoja_capitulos)
     estilo.addElement(
         TextProperties(fontweight="light",
                        fontfamily="helvetica",
                        fontsize="10pt"))
     self.UpdateEstilos(normal_con_tabuladores_capitulos, estilo)
     #normal con tabuladores hoja resumen
     normal_con_tabuladores_resumen = "Normal con tabuladores resumen"
     estilo = Style(name=normal_con_tabuladores_resumen,
                    family="paragraph",
                    parentstylename=tabuladores_hoja_resumen)
     estilo.addElement(
         TextProperties(fontweight="light",
                        fontfamily="helvetica",
                        fontsize="10pt"))
     self.UpdateEstilos(normal_con_tabuladores_resumen, estilo)
     #normal con tabuladores hoja resumen neritas
     normal_con_tabuladores_resumen_negritas = "Normal con tabuladores resumen negritas"
     estilo = Style(name=normal_con_tabuladores_resumen_negritas,
                    family="paragraph",
                    parentstylename=normal_con_tabuladores_resumen)
     estilo.addElement(TextProperties(fontweight="bold"))
     self.UpdateEstilos(normal_con_tabuladores_resumen_negritas, estilo)
     #linea horizontal gruesa
     #linea horizontal gruesa
     linea_horizontal_gruesa = "Linea horizontal gruesa"
     estilo = Style(name=linea_horizontal_gruesa,
                    displayname="Horizontal Line Thick",
                    family="paragraph",
                    parentstylename="Standard")
     estilo.addElement(ParagraphProperties(margintop="0cm", marginbottom="0cm", marginright="0cm", marginleft="0cm", \
      contextualspacing="false", borderlinewidthbottom="0cm 0.030cm 0.06cm", padding="0cm", borderleft="none", borderright="none", \
      bordertop="none", borderbottom="0.06pt double #3a3b3d", numberlines="false", linenumber="0", joinborder="false"))
     self.UpdateEstilos(linea_horizontal_gruesa, estilo)
     #linea horizontal fina
     linea_horizontal_fina = "Linea horizontal fina"
     estilo = Style(name=linea_horizontal_fina,
                    displayname="Horizontal Line Thin",
                    family="paragraph",
                    parentstylename="Standard")
     estilo.addElement(ParagraphProperties(margintop="0cm", marginbottom="0cm", marginright="0cm", marginleft="0cm", \
     contextualspacing="false", borderlinewidthbottom="0cm 0.030cm 0.02cm", padding="0cm", borderleft="none", borderright="none", \
     bordertop="none", borderbottom="0.06pt double #3a3b3d", numberlines="false", linenumber="0", joinborder="false"))
     self.UpdateEstilos(linea_horizontal_fina, estilo)
예제 #2
0
    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")
예제 #3
0
 def ConfigurarEstilos(self):
     nombre = "Linea horizontal gruesa"
     ###############
     ### Estilos ###
     ###############
     #H1
     H1 = "Heading 1"
     estilo = Style(name=H1, family="paragraph")
     estilo.addElement(
         TextProperties(
             attributes={
                 'fontsize': "14pt",
                 'fontweight': "bold",
                 'fontfamily': "helvetica"
             }))
     estilo.addElement(
         ParagraphProperties(attributes={
             'textalign': "Left",
             'paddingtop': "0cm"
         }))
     self.UpdateEstilos(H1, estilo)
     #H2
     H2 = "Heading 2"
     estilo = Style(name=H2, family="paragraph", parentstylename=H1)
     estilo.addElement(TextProperties(attributes={"fontsize": "12pt"}))
     self.UpdateEstilos(H2, estilo)
     #BASE
     base = "Base"
     estilo = Style(name=base, family="paragraph")
     estilo.addElement(
         ParagraphProperties(textalign="justify",
                             padding="0cm",
                             marginleft="2cm",
                             marginright="5cm"))
     estilo.addElement(
         TextProperties(fontfamily="helvetica", fontsize="12pt"))
     self.UpdateEstilos(base, estilo)
     #Capitulo
     CAP = "Capitulo"
     estilo = Style(name=CAP, family="paragraph", parentstylename=base)
     estilo.addElement(
         TextProperties(
             attributes={
                 'fontsize': "10pt",
                 'fontweight': "bold",
                 'fontfamily': "helvetica",
                 'backgroundcolor': '#a2f2f5'
             }))
     self.UpdateEstilos(CAP, estilo)
     #Subcapitulo
     SUBCAP = "SubCapitulo"
     estilo = Style(name=SUBCAP, family="paragraph", parentstylename=CAP)
     estilo.addElement(TextProperties(attributes={"fontsize": "10pt"}))
     self.UpdateEstilos(SUBCAP, estilo)
     #normal
     normal = "Normal"
     estilo = Style(name=normal, family="paragraph", parentstylename=base)
     estilo.addElement(TextProperties(fontsize="8pt"))
     self.UpdateEstilos(normal, estilo)
     #texto
     texto = "Texto"
     estilo = Style(name=texto, family="paragraph", parentstylename=base)
     estilo.addElement(ParagraphProperties(textalign="justify"))
     estilo.addElement(TextProperties(fontsize="8pt"))
     self.UpdateEstilos(texto, estilo)
     #negritas
     negritas = "Negritas"
     estilo = Style(name=negritas, family="paragraph", parentstylename=base)
     estilo.addElement(TextProperties(fontsize="9pt", fontweight="bold"))
     estilo.addElement(ParagraphProperties(marginleft="cm"))
     self.UpdateEstilos(negritas, estilo)
     #normal parrafo
     normal_parrafo = "NormalP"
     estilo = Style(name=normal_parrafo, family="paragraph")
     estilo.addElement(
         TextProperties(fontfamily="helvetica", fontsize="10pt"))
     self.UpdateEstilos(normal_parrafo, estilo)
     #negritas parrafo
     negritas_parrafo = "NegritasP"
     estilo = Style(name=negritas_parrafo,
                    family="paragraph",
                    parentstylename=normal_parrafo)
     estilo.addElement(TextProperties(fontweight="bold"))
     self.UpdateEstilos(negritas_parrafo, estilo)
     #conjunto de tabuladores 1 (PARA  EL LISTADO DE CAPITULOS)
     tabstops_list = TabStops()
     #Cada tabulador
     tabstop1 = TabStop(position="4.5cm")
     tabstops_list.addElement(tabstop1)
     tabstop1 = TabStop(position="5.5cm")
     tabstops_list.addElement(tabstop1)
     tabstop1 = TabStop(position="6.5cm")
     tabstops_list.addElement(tabstop1)
     tabstop1 = TabStop(position="7.5cm")
     tabstops_list.addElement(tabstop1)
     tabstop1 = TabStop(position="8.5cm")
     tabstops_list.addElement(tabstop1)
     tabstop1 = TabStop(position="9.5cm")
     tabstops_list.addElement(tabstop1)
     tabstop1 = TabStop(position="11.5cm")
     tabstops_list.addElement(tabstop1)
     tabstop1 = TabStop(position="13.5cm")
     tabstops_list.addElement(tabstop1)
     tabstoppar_mediciones = ParagraphProperties()
     tabstoppar_mediciones.addElement(tabstops_list)
     #estilo tabuladores normal
     tabuladores_normal = "Tabuladores Lineas Medicion"
     estilo = Style(name=tabuladores_normal,
                    family="paragraph",
                    parentstylename=texto)
     estilo.addElement(tabstoppar_mediciones)
     estilo.addElement(
         ParagraphProperties(marginright="0cm", marginleft="2cm"))
     self.UpdateEstilos(tabuladores_normal, estilo)
     #estilo tabuladores negritas
     tabuladores_negritas = "Tabuladores Hoja Listados Negritas"
     estilo = Style(name=tabuladores_negritas,
                    family="paragraph",
                    parentstylename=tabuladores_normal)
     estilo.addElement(TextProperties(fontweight="bold",
                                      fontstyle="italic"))
     self.UpdateEstilos(tabuladores_negritas, estilo)
     #tabuladores linea total capitulos
     tabstops_list_total_capitulos = TabStops()
     tabstop = TabStop(position="15.5cm",
                       type="char",
                       char=",",
                       leaderstyle="dotted")
     tabstops_list_total_capitulos.addElement(tabstop)
     tabstoppar_total_capitulo = ParagraphProperties()
     tabstoppar_total_capitulo.addElement(tabstops_list_total_capitulos)
     tabuladores_total_capitulos = "Tabuladores Linea Total Capitulo"
     estilo = Style(name=tabuladores_total_capitulos,
                    family="paragraph",
                    parentstylename=negritas)
     estilo.addElement(tabstoppar_total_capitulo)
     estilo.addElement(
         ParagraphProperties(marginright="0cm", marginleft="0cm"))
     self.UpdateEstilos(tabuladores_total_capitulos, estilo)
     #linea horizontal gruesa
     linea_horizontal_gruesa = "Linea horizontal gruesa"
     estilo = Style(name=linea_horizontal_gruesa,
                    displayname="Horizontal Line Thick",
                    family="paragraph",
                    parentstylename="Standard")
     estilo.addElement(ParagraphProperties(margintop="0cm", marginbottom="0cm", marginright="0cm", marginleft="0cm", \
      contextualspacing="false", borderlinewidthbottom="0cm 0.030cm 0.06cm", padding="0cm", borderleft="none", borderright="none", \
      bordertop="none", borderbottom="0.06pt double #3a3b3d", numberlines="false", linenumber="0", joinborder="false"))
     self.UpdateEstilos(linea_horizontal_gruesa, estilo)
     #linea horizontal sumatoria
     linea_horizontal_sumatoria = "Linea horizontal sumatoria"
     estilo = Style(name=linea_horizontal_sumatoria,
                    displayname="Horizontal Line Sumatory",
                    family="paragraph")
     estilo.addElement(TextProperties(attributes={"fontsize": "8pt"}))
     estilo.addElement(ParagraphProperties(margintop="0cm", marginbottom="0cm", marginright="0cm", marginleft="10cm", \
      contextualspacing="false", borderlinewidthbottom="0cm 0.030cm 0.01cm", padding="0cm", borderleft="none", borderright="none", \
      borderbottom="none", bordertop="0.06pt double #3a3b3d", numberlines="false", linenumber="0", joinborder="false"))
     self.UpdateEstilos(linea_horizontal_sumatoria, estilo)
     #salto de pagina
     salto_pagina = "Salto de Pagina"
     estilo = Style(name=salto_pagina,
                    parentstylename="Standard",
                    family="paragraph")
     estilo.addElement(ParagraphProperties(breakbefore="page"))
     self.UpdateEstilos(salto_pagina, estilo)