Пример #1
0
    def __census_changed(self, combo):
        """
        Called when the user selects a new census from the combo box.
        """
        model = combo.get_model()
        index = combo.get_active()
        census_id = model[index][2]

        # Set date
        census_date = get_census_date(census_id)

        date_text = self.widgets['date_text']
        date_text.set_text(displayer.display(census_date))
        self.event.set_date_object(census_date)
        self.citation.set_date_object(census_date)

        # Set source
        self.citation.set_reference_handle(model[index][0])

        # Set new columns
        columns = get_census_columns(census_id)
        report_columns = get_report_columns(census_id)
        self.details.create_table(columns, report_columns)
        heading_list = get_census_headings(census_id)
        self.headings.create_table(heading_list)
Пример #2
0
    def make_default_style(self, default_style):
        """
        Make the default output style for the Census report.
        """
        #
        # CEN-Title
        #
        font = FontStyle()
        font.set(face=FONT_SANS_SERIF, size=16, bold=1)
        para = ParagraphStyle()
        para.set_font(font)
        para.set_header_level(1)
        para.set_top_margin(0.25)
        para.set_bottom_margin(0.25)
        para.set_alignment(PARA_ALIGN_CENTER)       
        para.set_description(_('The style used for the title of the page.'))
        default_style.add_paragraph_style("CEN-Title", para)
    
        #
        # CEN-Heading
        #
        font = FontStyle()
        font.set(face=FONT_SANS_SERIF, size=14, italic=1)
        para = ParagraphStyle()
        para.set_font(font)
        para.set_header_level(2)
        para.set_top_margin(0.5)
        para.set_bottom_margin(0.125)        
        para.set_description(_('The style used for headings.'))
        default_style.add_paragraph_style("CEN-Heading", para)
    
        #
        # CEN-Name
        #
        font = FontStyle()
        font.set(face=FONT_SANS_SERIF, size=10)
        para = ParagraphStyle()
        para.set_font(font)
        para.set_description(_('The style used for names.'))
        default_style.add_paragraph_style("CEN-Name", para)
        
        #
        # CEN-Column
        #
        font = FontStyle()
        font.set(face=FONT_SANS_SERIF, size=10, italic=1)
        para = ParagraphStyle()
        para.set_font(font)
        para.set_description(_('The style used for column headings.'))
        default_style.add_paragraph_style("CEN-Column", para)
        
        #
        # CEN-Normal
        #
        font = FontStyle()
        font.set(face=FONT_SANS_SERIF, size=10)
        para = ParagraphStyle()
        para.set_font(font)
        #para.set(first_indent=-1.0, lmargin=1.0)
        para.set_description(_('The default text style.'))
        default_style.add_paragraph_style("CEN-Normal", para)

        #
        # Table Styles
        #
        for census_id in get_census_ids():
            columns = get_report_columns(census_id)
            tbl = TableStyle()
            tbl.set_width(100)
            tbl.set_columns(len(columns))
            for index, column in enumerate(columns):
                tbl.set_column_width(index, column[1])
            default_style.add_table_style("CEN-" + census_id, tbl)

        #
        # CEN-HeadingTable
        #
        tbl = TableStyle()
        tbl.set_width(100)
        tbl.set_columns(2)
        tbl.set_column_width(0, 30)
        tbl.set_column_width(1, 70)
        default_style.add_table_style("CEN-HeadingTable", tbl)
        
        #
        # CEN-HeadingCell
        #
        cell = TableCellStyle()
        default_style.add_cell_style("CEN-HeadingCell", cell)
        
        #
        # CEN-ColumnCell
        #
        cell = TableCellStyle()
        cell.set_left_border(1)
        cell.set_right_border(1)
        default_style.add_cell_style("CEN-ColumnCell", cell)
        
        #
        # CEN-BodyCell
        #
        cell = TableCellStyle()
        cell.set_left_border(1)
        cell.set_right_border(1)
        cell.set_top_border(1)
        cell.set_bottom_border(1)
        default_style.add_cell_style("CEN-BodyCell", cell)
Пример #3
0
    def write_census(self, event, citation):
        """
        Called for each census.
        """
        if self.pgbrk and not self.first_page:
            self.doc.page_break()
            self.first_page = False
        
        # Date, Source, Place
        p_handle = event.get_place_handle()
        place = self.database.get_place_from_handle(p_handle)
        src_handle = citation.get_reference_handle()
        source = self.database.get_source_from_handle(src_handle)
        census_id = get_census_id(source)
        headings = [x[0] for x in get_report_columns(census_id)]

        # Census title
        self.doc.start_paragraph("CEN-Heading")
        self.doc.write_text(source.get_title())
        self.doc.end_paragraph()

        self.doc.start_table("centab", "CEN-HeadingTable")

        # Date
        self.write_heading(_("Date:"), get_date(event))
        
        # Source Reference
        self.write_heading(_("Citation:"), citation.get_page())

        # Address
        if place:
            self.write_heading(_("Address:"), place.get_display_info()[0])
        else:
            self.write_heading(_("Address:"), "")

        # Blank line
        self.write_heading("", "")

        self.doc.end_table()
        self.doc.start_table("centab", "CEN-" + census_id)
       
        # People
        person_list = []
        e_handle = event.get_handle()
        for link in self.database.find_backlink_handles(
                                e_handle, include_classes=['Person']):
            person = self.database.get_person_from_handle(link[1])
            person_list.append(get_attributes(person, e_handle))

        # Heading row
        self.doc.start_row()

        for column in headings:
            self.doc.start_cell("CEN-ColumnCell")
            self.doc.start_paragraph("CEN-Column")
            self.doc.write_text(column)
            self.doc.end_paragraph()
            self.doc.end_cell()
            
        self.doc.end_row()
        
        for row in sorted(person_list):
            self.doc.start_row()

            for offset, column in enumerate(get_census_columns(census_id)):
                self.doc.start_cell("CEN-BodyCell")
                if column == _('Name'):
                    self.doc.start_paragraph("CEN-Name")
                    self.doc.write_text(row[2].get(column, row[1]))
                else:
                    self.doc.start_paragraph("CEN-Normal")
                    if column in row[2]:
                        self.doc.write_text(row[2].get(column))

                self.doc.end_paragraph()
                self.doc.end_cell()
                
            self.doc.end_row()
            
        self.doc.end_table()
Пример #4
0
    def make_default_style(self, default_style):
        """
        Make the default output style for the Census report.
        """
        #
        # CEN-Title
        #
        font = FontStyle()
        font.set(face=FONT_SANS_SERIF, size=16, bold=1)
        para = ParagraphStyle()
        para.set_font(font)
        para.set_header_level(1)
        para.set_top_margin(0.25)
        para.set_bottom_margin(0.25)
        para.set_alignment(PARA_ALIGN_CENTER)
        para.set_description(_('The style used for the title of the page.'))
        default_style.add_paragraph_style("CEN-Title", para)

        #
        # CEN-Heading
        #
        font = FontStyle()
        font.set(face=FONT_SANS_SERIF, size=14, italic=1)
        para = ParagraphStyle()
        para.set_font(font)
        para.set_header_level(2)
        para.set_top_margin(0.5)
        para.set_bottom_margin(0.125)
        para.set_description(_('The style used for headings.'))
        default_style.add_paragraph_style("CEN-Heading", para)

        #
        # CEN-Name
        #
        font = FontStyle()
        font.set(face=FONT_SANS_SERIF, size=10)
        para = ParagraphStyle()
        para.set_font(font)
        para.set_description(_('The style used for names.'))
        default_style.add_paragraph_style("CEN-Name", para)

        #
        # CEN-Column
        #
        font = FontStyle()
        font.set(face=FONT_SANS_SERIF, size=10, italic=1)
        para = ParagraphStyle()
        para.set_font(font)
        para.set_description(_('The style used for column headings.'))
        default_style.add_paragraph_style("CEN-Column", para)

        #
        # CEN-Normal
        #
        font = FontStyle()
        font.set(face=FONT_SANS_SERIF, size=10)
        para = ParagraphStyle()
        para.set_font(font)
        #para.set(first_indent=-1.0, lmargin=1.0)
        para.set_description(_('The default text style.'))
        default_style.add_paragraph_style("CEN-Normal", para)

        #
        # Table Styles
        #
        for census_id in get_census_ids():
            columns = get_report_columns(census_id)
            tbl = TableStyle()
            tbl.set_width(100)
            tbl.set_columns(len(columns))
            for index, column in enumerate(columns):
                tbl.set_column_width(index, column[1])
            default_style.add_table_style("CEN-" + census_id, tbl)

        #
        # CEN-HeadingTable
        #
        tbl = TableStyle()
        tbl.set_width(100)
        tbl.set_columns(2)
        tbl.set_column_width(0, 30)
        tbl.set_column_width(1, 70)
        default_style.add_table_style("CEN-HeadingTable", tbl)

        #
        # CEN-HeadingCell
        #
        cell = TableCellStyle()
        default_style.add_cell_style("CEN-HeadingCell", cell)

        #
        # CEN-ColumnCell
        #
        cell = TableCellStyle()
        cell.set_left_border(1)
        cell.set_right_border(1)
        default_style.add_cell_style("CEN-ColumnCell", cell)

        #
        # CEN-BodyCell
        #
        cell = TableCellStyle()
        cell.set_left_border(1)
        cell.set_right_border(1)
        cell.set_top_border(1)
        cell.set_bottom_border(1)
        default_style.add_cell_style("CEN-BodyCell", cell)
Пример #5
0
    def write_census(self, event, citation):
        """
        Called for each census.
        """
        if self.pgbrk and not self.first_page:
            self.doc.page_break()
            self.first_page = False

        # Date, Source, Place
        p_handle = event.get_place_handle()
        place = self.database.get_place_from_handle(p_handle)
        src_handle = citation.get_reference_handle()
        source = self.database.get_source_from_handle(src_handle)
        census_id = get_census_id(source)
        headings = [x[0] for x in get_report_columns(census_id)]

        # Census title
        self.doc.start_paragraph("CEN-Heading")
        self.doc.write_text(source.get_title())
        self.doc.end_paragraph()

        self.doc.start_table("centab", "CEN-HeadingTable")

        # Date
        self.write_heading(_("Date:"), get_date(event))

        # Source Reference
        self.write_heading(_("Citation:"), citation.get_page())

        # Address
        if place:
            self.write_heading(_("Address:"), place.get_title())
        else:
            self.write_heading(_("Address:"), "")

        # Blank line
        self.write_heading("", "")

        self.doc.end_table()
        self.doc.start_table("centab", "CEN-" + census_id)

        # People
        person_list = []
        e_handle = event.get_handle()
        for link in self.database.find_backlink_handles(
                e_handle, include_classes=['Person']):
            person = self.database.get_person_from_handle(link[1])
            person_list.append(get_attributes(person, e_handle))

        # Heading row
        self.doc.start_row()

        for column in headings:
            self.doc.start_cell("CEN-ColumnCell")
            self.doc.start_paragraph("CEN-Column")
            self.doc.write_text(column)
            self.doc.end_paragraph()
            self.doc.end_cell()

        self.doc.end_row()

        for row in sorted(person_list):
            self.doc.start_row()

            for offset, column in enumerate(get_census_columns(census_id)):
                self.doc.start_cell("CEN-BodyCell")
                if column == _('Name'):
                    self.doc.start_paragraph("CEN-Name")
                    self.doc.write_text(row[2].get(column, row[1]))
                else:
                    self.doc.start_paragraph("CEN-Normal")
                    if column in row[2]:
                        self.doc.write_text(row[2].get(column))

                self.doc.end_paragraph()
                self.doc.end_cell()

            self.doc.end_row()

        self.doc.end_table()