Esempio n. 1
0
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
Esempio n. 2
0
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
Esempio n. 3
0
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
Esempio n. 4
0
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
Esempio n. 5
0
    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)
Esempio n. 6
0
    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)
Esempio n. 7
0
liststylename="L1")
textdoc.automaticstyles.addElement(P1style)

# L1
"""
<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"/>
"""
Esempio n. 8
0
    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)
Esempio n. 9
0
P1style = Style(name="P1", family="paragraph", parentstylename="Standard", liststylename="L1")
textdoc.automaticstyles.addElement(P1style)

# L1
"""
<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")
Esempio n. 10
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")
Esempio n. 11
0
#

from odf.opendocument import OpenDocumentText
from odf.style import Style, TextProperties, ParagraphProperties, ListLevelProperties
from odf.text import P, List, ListItem, ListStyle, ListLevelStyleBullet

textdoc = OpenDocumentText()

symbolstyle = Style(name="Numbering Symbols", family="text")
textdoc.styles.addElement(symbolstyle)

liststyle = Style(name="List Content", family="paragraph")
liststyle.addElement(ParagraphProperties(numberlines="false", linenumber="0"))
textdoc.automaticstyles.addElement(liststyle)

listhier = ListStyle(name="MyList")
level = 1
for bullet in [u"–", u"•", u"–",u"•", u"✗", u"✗", u"✗", u"✗", u"✗", u"✗"]:
    b = ListLevelStyleBullet(level=str(level), stylename=symbolstyle, bulletchar=bullet)
    listhier.addElement(b)
    b.addElement(ListLevelProperties(minlabelwidth="%dcm" % level))
    b.addElement(TextProperties(fontname="StarSymbol"))
    level = level + 1

textdoc.styles.addElement(listhier)

l = List(stylename=listhier)
textdoc.text.addElement(l)
for x in [1,2,3,4]:
    elem = ListItem()
    elem.addElement(P(text="Listitem %d" % x))
Esempio n. 12
0
    def __init__(self, dest, dico_layer, dico_fields, dico_profil, dico_rekurs, dico_text):
        """
        Parameters depending on Metadator main class
        dest : destination folder path
        dico_layer : dictionary about layer
        dico_fields : dictionary about layers's fields
        dico_profil : dictionary about profile selected informations
        dico_rekurs : dictionary about recurring fields
        dico_text : dictionary of text according to language selected
        """
        # creating the document
        doc_obj = OpenDocumentText()  # create a new document object

        # BASIC STYLES
        doc_styles = doc_obj.styles
        # styles settings
        StandardStyle = Style(name="Standard", family="paragraph")
        TextBodyStyle = Style(
            name="Text_20_body", family="paragraph", parentstylename="Standard", displayname="Text body"
        )
        TextBodyStyle.addElement(ParagraphProperties(margintop="0in", marginbottom="0.0835in"))

        # adding the styles
        doc_styles.addElement(StandardStyle)
        doc_styles.addElement(TextBodyStyle)

        # fonts
        doc_obj.fontfacedecls.addElement(
            (FontFace(name="Arial", fontfamily="Arial", fontfamilygeneric="swiss", fontpitch="variable"))
        )
        # AUTOMATIC STYLES
        # 1st type of paragraph (P1)
        P1_style = Style(name="P1", family="paragraph", parentstylename="Standard", liststylename="L1")
        doc_obj.automaticstyles.addElement(P1_style)
        # 2nd type of paragraph (P2)
        P2_style = Style(name="P2", family="paragraph", liststylename="L2")
        P2_style.addElement(TextProperties(fontweight="bold", fontweightasian="bold", fontweightcomplex="bold"))
        doc_obj.automaticstyles.addElement(P2_style)
        # List 1 (unordered)
        L1_style = ListStyle(name="L1")
        L1_bullet = ListLevelStyleBullet(
            level="1", stylename="Numbering_20_Symbols", numsuffix=".", bulletchar="\u2022"
        )  # bullet char (utf8)
        L1_prop = ListLevelProperties(spacebefore="0.25in", minlabelwidth="0.25in")
        L1_bullet.addElement(L1_prop)
        L1_style.addElement(L1_bullet)
        # adding the style
        doc_obj.automaticstyles.addElement(L1_style)
        # List 2 (ordered)
        L2_style = ListStyle(name="L2")
        L2_num = ListLevelStyleNumber(level="1", stylename="Numbering_20_Symbols", numsuffix=" - ", numformat="1")
        L2_prop = ListLevelProperties(spacebefore="0.25in", minlabelwidth="0.25in")
        L2_num.addElement(L2_prop)
        L2_style.addElement(L2_num)
        # adding the style
        doc_obj.automaticstyles.addElement(L2_style)

        # Text 5: bold
        T5_style = Style(name="T5", family="text")
        T5_style.addElement(TextProperties(color="#ff0000", fontname="Arial"))
        doc_obj.automaticstyles.addElement(T5_style)

        # Text 2: bold
        T2_style = Style(name="T2", family="text")
        T2_style.addElement(TextProperties(fontweight="bold", fontweightasian="bold", fontweightcomplex="bold"))
        doc_obj.automaticstyles.addElement(T2_style)

        # Table : cell formatting
        TAB_style = Style(name="Table", family="table-cell", parentstylename="Standard")
        TAB_style.addElement(TableCellProperties(border="0.05pt solid #000000"))
        doc_obj.automaticstyles.addElement(TAB_style)

        # BODY - table
        # table creation
        doc_table = Table(name="Metadata")
        doc_table.addElement(TableColumn(numbercolumnsrepeated="2"))

        # title
        tr_title = TableRow()
        doc_table.addElement(tr_title)
        # merged columns
        tc_1_title = TableCell(valuetype="string", stylename="Table", numbercolumnsspanned="2")
        tc_1_title.addElement(P(text="Metadata of %s" % dico_layer.get("title"), stylename="P1"))
        tr_title.addElement(tc_1_title)

        # file name
        tr_name = TableRow()
        doc_table.addElement(tr_name)
        # column 1
        tc_1_name = TableCell(valuetype="string", stylename="Table")
        tc_1_name.addElement(P(text=dico_text.get("nomfic"), stylename="P2"))
        tr_name.addElement(tc_1_name)
        # column 2
        tc_2_name = TableCell(valuetype="string", stylename="Table")
        tc_2_name.addElement(P(text=dico_layer.get("name")))
        tr_name.addElement(tc_2_name)

        # thematic keywords
        tr_themes = TableRow()
        doc_table.addElement(tr_themes)
        # column 1
        tc_1_themes = TableCell(valuetype="string", stylename="Table")
        tc_1_themes.addElement(P(text=dico_text.get("mtcthem"), stylename="P2"))
        tr_themes.addElement(tc_1_themes)
        # column 2
        tc_2_themes = TableCell(valuetype="string", stylename="Table")
        tc_2_themes.addElement(P(text=", ".join(dico_profil.get("keywords"))))
        tr_themes.addElement(tc_2_themes)

        # places keywords
        tr_places = TableRow()
        doc_table.addElement(tr_places)
        # column 1
        tc_1_places = TableCell(valuetype="string", stylename="Table")
        tc_1_places.addElement(P(text=dico_text.get("mtcgeo"), stylename="P2"))
        tr_places.addElement(tc_1_places)
        # column 2
        tc_2_places = TableCell(valuetype="string", stylename="Table")
        tc_2_places.addElement(P(text=", ".join(dico_profil.get("geokeywords"))))
        tr_places.addElement(tc_2_places)

        # description
        tr_description = TableRow()
        doc_table.addElement(tr_description)
        # column 1
        tc_1_description = TableCell(valuetype="string", stylename="Table")
        tc_1_description.addElement(P(text=dico_text.get("description"), stylename="P2"))
        tr_description.addElement(tc_1_description)
        # column 2
        tc_2_description = TableCell(valuetype="string", stylename="Table")
        tc_2_description.addElement(P(text=""))
        tr_description.addElement(tc_2_description)

        # context/summary
        tr_summary = TableRow()
        doc_table.addElement(tr_summary)
        # column 1
        tc_1_summary = TableCell(valuetype="string", stylename="Table")
        tc_1_summary.addElement(P(text=dico_text.get("cadre"), stylename="P2"))
        tr_summary.addElement(tc_1_summary)
        # column 2
        tc_2_summary = TableCell(valuetype="string", stylename="Table")
        tc_2_summary.addElement(P(text=dico_profil.get("description")))
        tr_summary.addElement(tc_2_summary)

        # objects count
        tr_features = TableRow()
        doc_table.addElement(tr_features)
        # column 1
        tc_1_features = TableCell(valuetype="string", stylename="Table")
        tc_1_features.addElement(P(text=dico_text.get("num_objets"), stylename="P2"))
        tr_features.addElement(tc_1_features)
        # column 2
        tc_2_features = TableCell(valuetype="string", stylename="Table")
        tc_2_features.addElement(P(text=dico_layer.get("num_obj")))
        tr_features.addElement(tc_2_features)

        # fields count
        tr_fields = TableRow()
        doc_table.addElement(tr_fields)
        # column 1
        tc_1_fields = TableCell(valuetype="string", stylename="Table")
        tc_1_fields.addElement(P(text=dico_text.get("num_attrib"), stylename="P2"))
        tr_fields.addElement(tc_1_fields)
        # column 2
        tc_2_fields = TableCell(valuetype="string", stylename="Table")
        tc_2_fields.addElement(P(text=dico_layer.get("num_fields")))
        tr_fields.addElement(tc_2_fields)

        # creation date (on computer)
        tr_date_crea = TableRow()
        doc_table.addElement(tr_date_crea)
        # column 1
        tc_1_date_crea = TableCell(valuetype="string", stylename="Table")
        tc_1_date_crea.addElement(P(text=dico_text.get("date_crea"), stylename="P2"))
        tr_date_crea.addElement(tc_1_date_crea)
        # column 2
        tc_2_date_crea = TableCell(valuetype="string", stylename="Table")
        tc_2_date_crea.addElement(P(text=dico_layer.get("date_crea")))
        tr_date_crea.addElement(tc_2_date_crea)

        # last update
        tr_date_up = TableRow()
        doc_table.addElement(tr_date_up)
        # column 1
        tc_1_date_up = TableCell(valuetype="string", stylename="Table")
        tc_1_date_up.addElement(P(text=dico_text.get("date_actu"), stylename="P2"))
        tr_date_up.addElement(tc_1_date_up)
        # column 2
        tc_2_date_up = TableCell(valuetype="string", stylename="Table")
        tc_2_date_up.addElement(P(text=dico_layer.get("date_actu")))
        tr_date_up.addElement(tc_2_date_up)

        # sources
        tr_sources = TableRow()
        doc_table.addElement(tr_sources)
        # column 1
        tc_1_sources = TableCell(valuetype="string", stylename="Table")
        tc_1_sources.addElement(P(text=dico_text.get("source"), stylename="P2"))
        tr_sources.addElement(tc_1_sources)
        # column 2
        tc_2_sources = TableCell(valuetype="string", stylename="Table")
        tc_2_sources.addElement(P(text=dico_profil.get("sources")))
        tr_sources.addElement(tc_2_sources)

        # global responsable
        tr_resp = TableRow()
        doc_table.addElement(tr_resp)
        # column 1
        tc_1_resp = TableCell(valuetype="string", stylename="Table")
        tc_1_resp.addElement(P(text=dico_text.get("responsable"), stylename="P2"))
        tr_resp.addElement(tc_1_resp)
        # column 2
        tc_2_resp = TableCell(valuetype="string", stylename="Table")
        tc_2_resp.addElement(
            P(
                text=dico_profil.get("resp_name")
                + " ("
                + dico_profil.get("resp_orga")
                + "), "
                + dico_profil.get("resp_mail")
            )
        )
        tr_resp.addElement(tc_2_resp)

        # point of contact
        tr_cont = TableRow()
        doc_table.addElement(tr_cont)
        # column 1
        tc_1_cont = TableCell(valuetype="string", stylename="Table")
        tc_1_cont.addElement(P(text=dico_text.get("ptcontact"), stylename="P2"))
        tr_cont.addElement(tc_1_cont)
        # column 2
        tc_2_cont = TableCell(valuetype="string", stylename="Table")
        tc_2_cont.addElement(
            P(
                text=dico_profil.get("cont_name")
                + " ("
                + dico_profil.get("cont_orga")
                + "), "
                + dico_profil.get("cont_mail")
            )
        )
        tr_cont.addElement(tc_2_cont)

        # URL
        tr_url = TableRow()
        doc_table.addElement(tr_url)
        # column 1
        tc_1_url = TableCell(valuetype="string", stylename="Table")
        tc_1_url.addElement(P(text=dico_text.get("siteweb"), stylename="P2"))
        tr_url.addElement(tc_1_url)
        # column 2
        tc_2_url = TableCell(valuetype="string", stylename="Table")
        urlink = A(type="simple", href=dico_profil.get("url"), text=dico_profil.get("url_label"))
        plink = P(text="")
        plink.addElement(urlink)
        tc_2_url.addElement(plink)
        tr_url.addElement(tc_2_url)

        # geometry type
        tr_geom = TableRow()
        doc_table.addElement(tr_geom)
        # column 1
        tc_1_geom = TableCell(valuetype="string", stylename="Table")
        tc_1_geom.addElement(P(text=dico_text.get("geometrie"), stylename="P2"))
        tr_geom.addElement(tc_1_geom)
        # column 2
        tc_2_geom = TableCell(valuetype="string", stylename="Table")
        tc_2_geom.addElement(P(text=dico_layer.get("type_geom")))
        tr_geom.addElement(tc_2_geom)

        # scale
        tr_scale = TableRow()
        doc_table.addElement(tr_scale)
        # column 1
        tc_1_scale = TableCell(valuetype="string", stylename="Table")
        tc_1_scale.addElement(P(text=dico_text.get("echelle"), stylename="P2"))
        tr_scale.addElement(tc_1_scale)
        # column 2
        tc_2_sources = TableCell(valuetype="string", stylename="Table")
        tc_2_sources.addElement(P(text="1:"))
        tr_scale.addElement(tc_2_sources)

        # precision
        tr_prec = TableRow()
        doc_table.addElement(tr_prec)
        # column 1
        tc_1_prec = TableCell(valuetype="string", stylename="Table")
        tc_1_prec.addElement(P(text=dico_text.get("precision"), stylename="P2"))
        tr_prec.addElement(tc_1_prec)
        # column 2
        tc_2_prec = TableCell(valuetype="string", stylename="Table")
        tc_2_prec.addElement(P(text=" m"))
        tr_prec.addElement(tc_2_prec)

        # SRS
        tr_srs = TableRow()
        doc_table.addElement(tr_srs)
        # column 1
        tc_1_srs = TableCell(valuetype="string", stylename="Table")
        tc_1_srs.addElement(P(text=dico_text.get("srs"), stylename="P2"))
        tr_srs.addElement(tc_1_srs)
        # column 2
        tc_2_srs = TableCell(valuetype="string", stylename="Table")
        srs_text = "SRS : %s\u000A%s%s" % (dico_layer.get("srs"), dico_text.get("codepsg"), dico_layer.get("EPSG"))
        tc_2_srs.addElement(P(text=srs_text))
        tr_srs.addElement(tc_2_srs)

        # spatial extension
        tr_extent = TableRow()
        doc_table.addElement(tr_extent)
        # column 1
        tc_1_extent = TableCell(valuetype="string", stylename="Table")
        tc_1_extent.addElement(P(text=dico_text.get("emprise"), stylename="P2"))
        tr_extent.addElement(tc_1_extent)
        # column 2
        tc_2_extent = TableCell(valuetype="string", stylename="Table")
        spatial_extent = "\tMax Y : %s \tMin X : %s\t\tMax X : %s\tMin Y : %s" % (
            dico_layer["Ymax"],
            dico_layer["Xmin"],
            dico_layer["Xmax"],
            dico_layer["Ymin"],
        )
        tc_2_extent.addElement(P(text=spatial_extent))
        tr_extent.addElement(tc_2_extent)

        # adding the table
        doc_obj.text.addElement(doc_table)

        ## BODY - attributes
        doc_obj.text.addElement(Section(name="Attributes"))
        doc_obj.text.addElement(H(outlinelevel=1, text=dico_text.get("listattributs")))
        x = 0  # rank of the field
        for chp in dico_fields.keys():
            """ parsing fields"""
            x = x + 1
            # field name
            try:
                """ check the encoding of the field name """
                p_name = P(text=str(x) + " - " + chp, stylename="P2")
            except UnicodeDecodeError:
                """ raise the exception and re-encode it """
                p_name = P(text=str(x) + " - " + chp.decode("latin1"), stylename="T2")
            doc_obj.text.addElement(p_name)

            # more friendly local variables
            lg = dico_fields.get(chp)[0][1]
            prec = dico_fields.get(chp)[0][2]
            desc = dico_fields.get(chp)[1]

            # field information depending on field type
            if dico_fields[chp][0][0] == "Integer":
                """ for integers """
                # type
                p_type = P(text="")
                s_type = Span(text=dico_text.get("type"), stylename="T2")
                p_type.addElement(s_type)
                p_type.addText(" %s" % dico_text.get("entier"))
                doc_obj.text.addElement(p_type)

                # length
                p_lg = P(text="")
                s_lg = Span(text=dico_text.get("longueur"), stylename="T2")
                p_lg.addElement(s_lg)
                p_lg.addText(" %s" % lg)
                doc_obj.text.addElement(p_lg)

                # description
                p_descr = P(text="")
                s_descr = Span(text=dico_text.get("description"), stylename="T2")
                p_descr.addElement(s_descr)
                p_descr.addText(" %s" % desc)
                doc_obj.text.addElement(p_descr)

                # basics stats only if there are'nt disabled
                if dico_fields[chp][2]:
                    # more friendly local variables
                    som = dico_fields[chp][2][0]
                    med = dico_fields[chp][2][1]
                    moy = dico_fields[chp][2][2]
                    uppest = dico_fields[chp][2][3]
                    bottom = dico_fields[chp][2][4]
                    freq = dico_fields[chp][2][5]
                    mod = dico_fields[chp][2][6]
                    ect = dico_fields[chp][2][7]
                    vid = dico_fields[chp][2][8]

                    # basics stats
                    p_stats = P(text="")
                    s_stats = Span(text=dico_text.get("statsbase"), stylename="T2")
                    p_stats.addElement(s_stats)
                    doc_obj.text.addElement(p_stats)
                    stats_list = List(stylename="L5")
                    item = ListItem()
                    item.addElement(P(text="%s (%s)" % (dico_text.get("somme"), som), stylename="P1"))
                    stats_list.addElement(item)
                    if vid != 0:  # for null values
                        perc = round(float(vid) * 100 / dico_layer.get("num_obj"), 2)
                        item = ListItem()
                        item.addElement(
                            P(
                                text="%s%s (%s %s%s)"
                                % (
                                    dico_text.get("valnulles"),
                                    vid,
                                    dico_text.get("soit"),
                                    perc,
                                    dico_text.get("perctotal"),
                                ),
                                stylename="P1",
                            )
                        )
                        stats_list.addElement(item)
                    item = ListItem()
                    item.addElement(P(text="%s%s" % (dico_text.get("min"), bottom), stylename="P1"))
                    stats_list.addElement(item)
                    item = ListItem()
                    item.addElement(P(text="%s%s" % (dico_text.get("max"), uppest), stylename="P1"))
                    stats_list.addElement(item)
                    item = ListItem()
                    item.addElement(P(text="%s%s" % (dico_text.get("moyenne"), moy), stylename="P1"))
                    stats_list.addElement(item)
                    item = ListItem()
                    item.addElement(P(text="%s%s" % (dico_text.get("mediane"), med), stylename="P1"))
                    stats_list.addElement(item)
                    item = ListItem()
                    item.addElement(P(text="%s%s" % (dico_text.get("ecartype"), ect), stylename="P1"))
                    stats_list.addElement(item)
                    doc_obj.text.addElement(stats_list)

                    # modalities
                    p_moda = P(text="")
                    s_moda = Span(text=dico_text.get("val_freq"), stylename="T2")
                    p_moda.addElement(s_moda)
                    p_moda.addText(" %s" % mod.replace("\n", "<br>"))
                    doc_obj.text.addElement(p_moda)
                    if freq > 0:
                        freq_list = List(stylename="L5")
                        for val, okur in freq:
                            item = ListItem()
                            item.addElement(P(text="%s (%s)" % (val, okur), stylename="P1"))
                            freq_list.addElement(item)
                    else:
                        pass
                    doc_obj.text.addElement(freq_list)
                else:
                    pass

            elif dico_fields[chp][0][0] == "Real":
                """ for real / float """
                # type
                p_type = P(text="")
                s_type = Span(text=dico_text.get("type"), stylename="T2")
                p_type.addElement(s_type)
                p_type.addText(" %s" % dico_text.get("reel"))
                doc_obj.text.addElement(p_type)

                # length
                p_lg = P(text="")
                s_lg = Span(text=dico_text.get("longueur"), stylename="T2")
                p_lg.addElement(s_lg)
                p_lg.addText(" %s" % lg)
                doc_obj.text.addElement(p_lg)

                # precision
                p_prec = P(text="")
                s_prec = Span(text=dico_text.get("precision"), stylename="T2")
                p_prec.addElement(s_prec)
                p_prec.addText(" %s" % prec)
                doc_obj.text.addElement(p_prec)

                # description
                p_descr = P(text="")
                s_descr = Span(text=dico_text.get("description"), stylename="T2")
                p_descr.addElement(s_descr)
                p_descr.addText(" %s" % desc)
                doc_obj.text.addElement(p_descr)

                # basics stats only if there are'nt disabled
                if dico_fields[chp][2]:
                    # more friendly local variables
                    som = dico_fields[chp][2][0]
                    med = dico_fields[chp][2][1]
                    moy = dico_fields[chp][2][2]
                    uppest = dico_fields[chp][2][3]
                    bottom = dico_fields[chp][2][4]
                    freq = dico_fields[chp][2][5]
                    mod = dico_fields[chp][2][6]
                    ect = dico_fields[chp][2][7]
                    vid = dico_fields[chp][2][8]

                    # basics stats
                    p_stats = P(text="")
                    s_stats = Span(text=dico_text.get("statsbase"), stylename="T2")
                    p_stats.addElement(s_stats)
                    doc_obj.text.addElement(p_stats)
                    stats_list = List(stylename="L5")
                    item = ListItem()
                    item.addElement(P(text="%s (%s)" % (dico_text.get("somme"), som), stylename="P1"))
                    stats_list.addElement(item)
                    if vid != 0:  # for null values
                        perc = round(float(vid) * 100 / dico_layer.get("num_obj"), 2)
                        item = ListItem()
                        item.addElement(
                            P(
                                text="%s%s (%s %s%s)"
                                % (
                                    dico_text.get("valnulles"),
                                    vid,
                                    dico_text.get("soit"),
                                    perc,
                                    dico_text.get("perctotal"),
                                ),
                                stylename="P1",
                            )
                        )
                        stats_list.addElement(item)
                    item = ListItem()
                    item.addElement(P(text="%s%s" % (dico_text.get("min"), bottom), stylename="P1"))
                    stats_list.addElement(item)
                    item = ListItem()
                    item.addElement(P(text="%s%s" % (dico_text.get("max"), uppest), stylename="P1"))
                    stats_list.addElement(item)
                    item = ListItem()
                    item.addElement(P(text="%s%s" % (dico_text.get("moyenne"), moy), stylename="P1"))
                    stats_list.addElement(item)
                    item = ListItem()
                    item.addElement(P(text="%s%s" % (dico_text.get("mediane"), med), stylename="P1"))
                    stats_list.addElement(item)
                    item = ListItem()
                    item.addElement(P(text="%s%s" % (dico_text.get("ecartype"), ect), stylename="P1"))
                    stats_list.addElement(item)
                    doc_obj.text.addElement(stats_list)

                    # modalities
                    p_moda = P(text="")
                    s_moda = Span(text=dico_text.get("val_freq"), stylename="T2")
                    p_moda.addElement(s_moda)
                    p_moda.addText(" %s" % mod.replace("\n", "<br>"))
                    doc_obj.text.addElement(p_moda)
                    if freq > 0:
                        freq_list = List(stylename="L5")
                        for val, okur in freq:
                            item = ListItem()
                            item.addElement(P(text="%s (%s)" % (val, okur), stylename="P1"))
                            freq_list.addElement(item)
                    else:
                        pass
                    doc_obj.text.addElement(freq_list)
                else:
                    pass

            elif dico_fields[chp][0][0] == "String":
                """ for caracter string """
                # type
                p_type = P(text="")
                s_type = Span(text=dico_text.get("type"), stylename="T2")
                p_type.addElement(s_type)
                p_type.addText(" %s" % dico_text.get("string"))
                doc_obj.text.addElement(p_type)

                # length
                p_lg = P(text="")
                s_lg = Span(text=dico_text.get("longueur"), stylename="T2")
                p_lg.addElement(s_lg)
                p_lg.addText(" %s" % lg)
                doc_obj.text.addElement(p_lg)

                # description
                p_descr = P(text="")
                s_descr = Span(text=dico_text.get("description"), stylename="T2")
                p_descr.addElement(s_descr)
                p_descr.addText(" %s" % desc)
                doc_obj.text.addElement(p_descr)

                # basics stats only if there are'nt disabled
                if dico_fields[chp][2]:
                    # more friendly local variables
                    mod = dico_fields[chp][2][0]
                    freq = dico_fields[chp][2][1]
                    vid = dico_fields[chp][2][2]

                    # modalities
                    p_moda = P(text="")
                    s_moda = Span(text=dico_text.get("txt_moda"), stylename="T2")
                    p_moda.addElement(s_moda)
                    p_moda.addText(" %s" % mod.replace("\n", "<br>"))
                    doc_obj.text.addElement(p_moda)
                    if freq > 0:
                        freq_list = List(stylename="L5")
                        for val, okur in freq:
                            item = ListItem()
                            try:
                                item.addElement(P(text="%s (%s)" % (val, okur), stylename="P1"))
                            except UnicodeDecodeError:
                                val = val.decode("latin1")
                                item.addElement(P(text="%s (%s)" % (val, okur), stylename="P1"))
                            freq_list.addElement(item)
                        # if null values
                        if vid != 0:
                            item = ListItem()
                            item.addElement(P(text="%s (%s)" % (dico_text.get("valnulles"), vid), stylename="P1"))
                            freq_list.addElement(item)
                        else:
                            pass
                        doc_obj.text.addElement(freq_list)
                    else:
                        pass

            elif dico_fields[chp][0][0] == "Date":
                """ for dates """
                # type
                p_type = P(text="")
                s_type = Span(text=dico_text.get("type"), stylename="T2")
                p_type.addElement(s_type)
                p_type.addText(" %s" % dico_text.get("date"))
                doc_obj.text.addElement(p_type)

                # description
                p_descr = P(text="")
                s_descr = Span(text=dico_text.get("description"), stylename="T2")
                p_descr.addElement(s_descr)
                p_descr.addText(" %s" % desc)
                doc_obj.text.addElement(p_descr)

                # basics stats only if there are'nt disabled
                if dico_fields[chp][2]:
                    # more friendly local variables
                    uppest = dico_fields[chp][2][0]
                    bottom = dico_fields[chp][2][1]
                    diffdays = dico_fields[chp][2][2]
                    freq = dico_fields[chp][2][3]
                    mod = dico_fields[chp][2][4]
                    vid = dico_fields[chp][2][5]

                    # dates delta
                    if vid != dico_layer.get("num_obj"):
                        """ check if attribute is empty """
                        # oldest
                        p_old = P(text="")
                        s_old = Span(text=dico_text.get("datancienne"), stylename="T2")
                        p_old.addElement(s_old)
                        p_old.addText(" %s" % date.isoformat(bottom))
                        doc_obj.text.addElement(p_old)

                        # recent
                        p_rec = P(text="")
                        s_rec = Span(text=dico_text.get("daterecente"), stylename="T2")
                        p_rec.addElement(s_rec)
                        p_rec.addText(" %s" % date.isoformat(uppest))
                        doc_obj.text.addElement(p_rec)

                        # interval
                        p_interv = P(text="")
                        s_interv = Span(text=dico_text.get("date_intervmax"), stylename="T2")
                        p_interv.addElement(s_interv)
                        p_interv.addText(" %s" % diffdays)
                        doc_obj.text.addElement(p_interv)

            # separating line
            doc_obj.text.addElement(P(text="______________________________________\n"))

            ## END
        # saving the document
        output = path.join(dest, "{0}_MD.odt".format(dico_layer.get("name")[:-4]))
        doc_obj.save(output)