Exemplo n.º 1
0
def process_paragraph(element, attributes):
    """
    Process jrxml 'paragraph' element.
    :param element: jrxml 'paragraph' element
    :param attributes: attributes related to the 'element'
    """
    add_attr2attributes(element, attributes)
Exemplo n.º 2
0
def process_font(element, attributes):
    """
    Process jrxml 'font' element.
    Set font attributes.
    :param element: jrxml 'font' element
    :param attributes: attributes related to the 'element'
    """
    add_attr2attributes(element, attributes, 'font')
Exemplo n.º 3
0
def process_image(report, element):
    """
    Process jrxml 'image' element.
    :param report: dictionary holding report information
    :param element: jrxml image element to process
    """
    image_element = element.get('child')
    if image_element is not None:
        report_element = process_reportElement(
            report, image_element[0].get('reportElement'))  # get reportElement
        # get scaleImage attribute on image element
        add_attr2attributes(element, report_element)
        for tag in image_element[1:]:
            for key, value in tag.items():
                if image_dict[key] is not None:
                    image_dict[key](report, value, report_element)
Exemplo n.º 4
0
def process_graphicElement(report, element, attributes):
    """
    Process jrxml graphicElement.
    Get attributes on graphicElement.
    :param report: dictionary holding report information
    :param element: current jrxml element being processes.
    :param attributes: current dictionary of attributes.
    :return: attributes with attributes of pen under graphicElements.
    """
    if len(element) > 1:
        graphic_element = element[1].get('graphicElement')  # get graphicElement
        if graphic_element is not None:
            pen = graphic_element.get('child')
            if pen is not None:
                add_attr2attributes(pen[0].get('pen'), attributes)
    return attributes
Exemplo n.º 5
0
def process_barbecue(report, key, element, attributes):
    """
    Process jrxml barbecue component elements.
    :param report: dictionary holding report information
    :param element: jrxml barbecue element
    :param attributes: attributes of this element
    """
    add_attr2attributes(element, attributes)
    type = attributes.get('type')
    if type is not None:
        barcode_element_list = element.get('child')
        if barcode_element_list is not None:
            barcode_type = barcode_types_dict.get(type)
            if barcode_type is not None:
                barcode_type[0](report, barcode_type[1],
                                barcode_element_list[0], attributes)
Exemplo n.º 6
0
def process_rectangle(report, element):
    """
    Process jrxml "rectangle" element.
    :param report:
    :param element:
    :return:
    """
    # global report_info

    rectangle_element = element.get('child')
    if rectangle_element is not None:
        attributes = process_reportElement(
            report,
            rectangle_element[0].get('reportElement'))  # get reportElement
        # get radius attribute on rectangle element
        add_attr2attributes(element, attributes)

        # set attributes from following graphicElement
        attributes = process_graphicElement(report, rectangle_element,
                                            attributes)

        # set line attributes
        line_style = attributes.get('lineStyle')
        line_width = float(attributes.get('lineWidth', '1.0'))
        fore_color = attributes.get('forecolor')

        mode = attributes.get('mode')
        background_color = attributes.get('backcolor')
        if mode == 'Opaque':
            fill = 1
        else:
            fill = 0

        # draw rectangle
        if line_style == 'Double':  # double line consists of wide solid line with thin white line in between
            draw_rectangle(report, attributes, line_style_dict['Solid'],
                           line_width * 1.5, fore_color, background_color,
                           fill)
            draw_rectangle(report, attributes, line_style_dict['Solid'],
                           line_width * 0.3, '#FFFFFF', background_color, fill)
        else:
            draw_rectangle(report, attributes, line_style, line_width,
                           fore_color, background_color, fill)
Exemplo n.º 7
0
def process_textField(report, element):
    """
    Process textField jrxml element.
    :param report: dictionary holding report information
    :param element:
    # :param row_data: a row from data source
    """
    text_field = element.get('child')
    if text_field is not None:
        attributes = process_reportElement(report, text_field[0].get('reportElement'))  # get reportElement

        # set attributes to reportElement (e.g. pattern, isBlankWhenNull)
        add_attr2attributes(element, attributes)

        for tag in text_field[1:]:
            for key, value in tag.items():
                if textField_dict[key] is not None:
                    if key == 'textElement':
                        attributes = process_textElement(report, value, attributes)
                    else:   # reportElement, box
                        textField_dict[key](report, value, attributes)
Exemplo n.º 8
0
def process_line(report, element):
    """
    Process jrxml line element.
    :param report: dictionary holding report information
    :param element: jrxml line element
    """
    line_element = element.get('child')
    if line_element is not None:
        report_element = process_reportElement(
            report, line_element[0].get('reportElement'))  # get reportElement
        # get attributes on line element (e.g. "direction") to determine which direction to draw a line
        add_attr2attributes(element, report_element)

        # set attributes from following graphicElement
        # reportElement = process_graphicElement(report, line_element, report_element)
        process_graphicElement(report, line_element, report_element)

        # set line attributes
        line_style = report_element.get('lineStyle')
        line_width = float(report_element.get('lineWidth', '1.0'))
        line_color = report_element.get('lineColor')

        draw_diagonal_line(report, report_element, line_style, line_width,
                           line_color)