diff --git a/src/gen/plug/docgen/drawdoc.py b/src/gen/plug/docgen/drawdoc.py index 8d4cfb8ad..3a99a003c 100644 --- a/src/gen/plug/docgen/drawdoc.py +++ b/src/gen/plug/docgen/drawdoc.py @@ -6,6 +6,7 @@ # Copyright (C) 2007 Brian G. Matherly # Copyright (C) 2009 Benny Malengier # Copyright (C) 2009 Gary Burton +# Copyright (C) 2012 Paul Franklin # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -91,16 +92,20 @@ class DrawDoc(object): def draw_path(self, style, path): raise NotImplementedError - def draw_box(self, style, text, x, y, w, h): + def draw_box(self, style, text, x, y, w, h, mark=None): + """ @param mark: IndexMark to use for indexing (if supported) """ raise NotImplementedError - def draw_text(self, style, text, x1, y1): + def draw_text(self, style, text, x1, y1, mark=None): + """ @param mark: IndexMark to use for indexing (if supported) """ raise NotImplementedError - def center_text(self, style, text, x1, y1): + def center_text(self, style, text, x1, y1, mark=None): + """ @param mark: IndexMark to use for indexing (if supported) """ raise NotImplementedError - def rotate_text(self, style, text, x, y, angle): + def rotate_text(self, style, text, x, y, angle, mark=None): + """ @param mark: IndexMark to use for indexing (if supported) """ raise NotImplementedError def draw_line(self, style, x1, y1, x2, y2): diff --git a/src/plugins/docgen/htmldoc.py b/src/plugins/docgen/htmldoc.py index 10a4b012b..4b81d6adb 100644 --- a/src/plugins/docgen/htmldoc.py +++ b/src/plugins/docgen/htmldoc.py @@ -310,7 +310,7 @@ class HtmlDoc(BaseDoc, TextDoc): def __write_text(self, text, mark=None, markup=False, links=False): """ @param text: text to write. - @param mark: IndexMark to use for indexing (if supported) + @param mark: IndexMark to use for indexing (not supported) @param markup: True if text already contains markup info. Then text will no longer be escaped @param links: make URLs clickable if True diff --git a/src/plugins/docgen/odfdoc.py b/src/plugins/docgen/odfdoc.py index 5df7e105a..b4d077e53 100644 --- a/src/plugins/docgen/odfdoc.py +++ b/src/plugins/docgen/odfdoc.py @@ -7,6 +7,7 @@ # Copyright (C) 2010 Peter Landgren # Copyright (C) 2010 Jakim Friant # Copyright (C) 2011 Adam Stein +# Copyright (C) 2012 Paul Franklin # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -1576,12 +1577,21 @@ class ODFDoc(BaseDoc, TextDoc, DrawDoc): Uses the xml.sax.saxutils.escape function to convert XML entities. The _esc_map dictionary allows us to add our own mappings. + @param mark: IndexMark to use for indexing """ text = escape(text, _esc_map) if links == True: text = re.sub(URL_PATTERN, _CLICKABLE, text) + self._write_mark(mark, text) + + self.cntnt.write(text) + + def _write_mark(self, mark, text): + """ + Insert a mark at this point in the document. + """ if mark: key = escape(mark.key, _esc_map) key = key.replace('"', '"') @@ -1590,7 +1600,6 @@ class ODFDoc(BaseDoc, TextDoc, DrawDoc): '' % key ) - elif mark.type == INDEX_TYPE_TOC: self.cntnt.write( '' % key) - self.cntnt.write(text) - def insert_toc(self): """ Insert a Table of Contents at this point in the document. @@ -1763,9 +1770,10 @@ class ODFDoc(BaseDoc, TextDoc, DrawDoc): _META_XML % locals() ) - def rotate_text(self, style, text, x, y, angle): + def rotate_text(self, style, text, x, y, angle, mark=None): """ Used to rotate a text with an angle. + @param mark: IndexMark to use for indexing """ style_sheet = self.get_style_sheet() stype = style_sheet.get_draw_style(style) @@ -1785,6 +1793,8 @@ class ODFDoc(BaseDoc, TextDoc, DrawDoc): xloc = x - (wcm / 2.0) * cos(rangle) + (hcm / 2.0) * sin(rangle) yloc = y - (hcm / 2.0) * cos(rangle) - (wcm / 2.0) * sin(rangle) + self._write_mark(mark, text) + self.cntnt.write( '\n' ) - def draw_text(self, style, text, x, y): + def draw_text(self, style, text, x, y, mark=None): """ Draw a text + @param mark: IndexMark to use for indexing """ style_sheet = self.get_style_sheet() box_style = style_sheet.get_draw_style(style) @@ -1866,6 +1877,8 @@ class ODFDoc(BaseDoc, TextDoc, DrawDoc): font = pstyle.get_font() sw = ReportUtils.pt2cm(string_width(font, text))*1.3 + self._write_mark(mark, text) + self.cntnt.write( '\n' ) - def draw_box(self, style, text, x, y, w, h): + def draw_box(self, style, text, x, y, w, h, mark=None): """ Draw a box + @param mark: IndexMark to use for indexing """ style_sheet = self.get_style_sheet() box_style = style_sheet.get_draw_style(style) para_name = box_style.get_paragraph_style() shadow_width = box_style.get_shadow_space() + self._write_mark(mark, text) + if box_style.get_shadow(): self.cntnt.write( '\n') - def center_text(self, style, text, x, y): + def center_text(self, style, text, x, y, mark=None): """ Center a text in a cell, a row, a line, ... + @param mark: IndexMark to use for indexing """ style_sheet = self.get_style_sheet() box_style = style_sheet.get_draw_style(style) @@ -1940,6 +1957,8 @@ class ODFDoc(BaseDoc, TextDoc, DrawDoc): size = (string_width(font, text) / 72.0) * 2.54 + self._write_mark(mark, text) + self.cntnt.write( '\n' ) - def rotate_text(self, style, text, x, y, angle): + def rotate_text(self, style, text, x, y, angle, mark=None): + """ @param mark: IndexMark to use for indexing (not supported) """ style_sheet = self.get_style_sheet() stype = style_sheet.get_draw_style(style) pname = stype.get_paragraph_style() @@ -187,7 +188,8 @@ class SvgDrawDoc(BaseDoc, DrawDoc): ) self.f.write('"/>\n') - def draw_box(self, style, text, x, y, w, h): + def draw_box(self, style, text, x, y, w, h, mark=None): + """ @param mark: IndexMark to use for indexing (not supported) """ x += self.paper.get_left_margin() y += self.paper.get_top_margin() @@ -252,7 +254,8 @@ class SvgDrawDoc(BaseDoc, DrawDoc): '\n' ) - def draw_text(self, style, text, x, y): + def draw_text(self, style, text, x, y, mark=None): + """ @param mark: IndexMark to use for indexing (not supported) """ x += self.paper.get_left_margin() y += self.paper.get_top_margin() @@ -285,7 +288,8 @@ class SvgDrawDoc(BaseDoc, DrawDoc): '\n' ) - def center_text(self, style, text, x, y): + def center_text(self, style, text, x, y, mark=None): + """ @param mark: IndexMark to use for indexing (not supported) """ style_sheet = self.get_style_sheet() box_style = style_sheet.get_draw_style(style) para_name = box_style.get_paragraph_style() diff --git a/src/plugins/drawreport/calendarreport.py b/src/plugins/drawreport/calendarreport.py index 065239771..78510b8ed 100644 --- a/src/plugins/drawreport/calendarreport.py +++ b/src/plugins/drawreport/calendarreport.py @@ -3,6 +3,7 @@ # Copyright (C) 2000-2007 Donald N. Allingham # Copyright (C) 2008-2009 Brian G. Matherly # Copyright (C) 2010 Jakim Friant +# Copyright (C) 2012 Paul Franklin # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -41,7 +42,8 @@ from gen.errors import ReportError from gen.relationship import get_relationship_calculator from gen.plug.docgen import (FontStyle, ParagraphStyle, GraphicsStyle, FONT_SERIF, PARA_ALIGN_CENTER, - PARA_ALIGN_LEFT, PARA_ALIGN_RIGHT) + PARA_ALIGN_LEFT, PARA_ALIGN_RIGHT, + IndexMark, INDEX_TYPE_TOC) from gen.plug.docgen.fontscale import string_trim from gen.plug.menu import (BooleanOption, StringOption, NumberOption, EnumeratedListOption, FilterOption, PersonOption) @@ -131,11 +133,11 @@ class Calendar(Report): ### The rest of these all have to deal with calendar specific things - def add_day_item(self, text, month, day, format="CAL-Text"): + def add_day_item(self, text, month, day, format="CAL-Text", marks=[None]): """ Add an item to a day. """ month_dict = self.calendar.get(month, {}) day_list = month_dict.get(day, []) - day_list.append((format, text)) + day_list.append((format, text, marks)) month_dict[day] = day_list self.calendar[month] = month_dict @@ -184,13 +186,18 @@ class Calendar(Report): width = self.doc.get_usable_width() height = self.doc.get_usable_height() header = 2.54 # one inch + mark = None + if month == 1: + mark = IndexMark(_('Calendar Report'), INDEX_TYPE_TOC, 1) self.draw_rectangle("CAL-Border", 0, 0, width, height) - self.doc.draw_box("CAL-Title", "", 0, 0, width, header) + self.doc.draw_box("CAL-Title", "", 0, 0, width, header, mark) self.doc.draw_line("CAL-Border", 0, header, width, header) year = self.year title = "%s %d" % (_dd.long_months[month].capitalize(), year) + mark = IndexMark(title, INDEX_TYPE_TOC, 2) font_height = pt2cm(ptitle.get_font().get_size()) - self.doc.center_text("CAL-Title", title, width/2, font_height * 0.25) + self.doc.center_text("CAL-Title", title, + width/2, font_height * 0.25, mark) cell_width = width / 7 cell_height = (height - header)/ 6 current_date = datetime.date(year, month, 1) @@ -226,7 +233,7 @@ class Calendar(Report): list_ = self.calendar.get(month, {}).get(thisday.day, []) list_.sort() # to get CAL-Holiday on bottom position = 0.0 - for (format, p) in list_: + for (format, p, m_list) in list_: lines = p.count("\n") + 1 # lines in the text position += (lines * spacing) current = 0 @@ -239,7 +246,9 @@ class Calendar(Report): line = string_trim(font, line, cm2pt(cell_width + 0.2)) self.doc.draw_text(format, line, day_col * cell_width + 0.1, - header + (week_row + 1) * cell_height - position + (current * spacing) - 0.1) + header + (week_row + 1) * cell_height - position + (current * spacing) - 0.1, m_list[0]) + if len(m_list) > 1: # index the spouse too + self.doc.draw_text(format, "",0,0, m_list[1]) current += 1 current_ord += 1 if not something_this_week: @@ -272,6 +281,7 @@ class Calendar(Report): for person_handle in people: self._user.step_progress() person = db.get_person_from_handle(person_handle) + mark = ReportUtils.get_person_mark(db, person) birth_ref = person.get_birth_ref() birth_date = None if birth_ref: @@ -318,7 +328,7 @@ class Calendar(Report): % {'person' : short_name, 'age' : nyears, 'relation' : ""}) - self.add_day_item(text, month, day) + self.add_day_item(text, month, day, marks=[mark]) if self.anniversaries: family_list = person.get_family_handle_list() for fhandle in family_list: @@ -333,6 +343,7 @@ class Calendar(Report): if spouse_handle: spouse = db.get_person_from_handle(spouse_handle) if spouse: + s_m = ReportUtils.get_person_mark(db, spouse) spouse_name = self.get_name(spouse) short_name = self.get_name(person) # TEMP: this will handle ordered events @@ -383,7 +394,8 @@ class Calendar(Report): alive2 = probably_alive(spouse, self.database, prob_alive_date) if ((self.alive and alive1 and alive2) or not self.alive): - self.add_day_item(text, month, day) + self.add_day_item(text, month, day, + marks=[mark,s_m]) self._user.end_progress() #------------------------------------------------------------------------ diff --git a/src/plugins/drawreport/fanchart.py b/src/plugins/drawreport/fanchart.py index 626811395..a8847f30f 100644 --- a/src/plugins/drawreport/fanchart.py +++ b/src/plugins/drawreport/fanchart.py @@ -3,7 +3,8 @@ # # Copyright (C) 2003-2006 Donald N. Allingham # Copyright (C) 2007-2008 Brian G. Matherly -# Copyright (C) 2010 Jakim Friant +# Copyright (C) 2010 Jakim Friant +# Copyright (C) 2012 Paul Franklin # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -43,7 +44,8 @@ def log2(val): #------------------------------------------------------------------------ from gen.errors import ReportError from gen.plug.docgen import (FontStyle, ParagraphStyle, GraphicsStyle, - FONT_SANS_SERIF, PARA_ALIGN_CENTER) + FONT_SANS_SERIF, PARA_ALIGN_CENTER, + IndexMark, INDEX_TYPE_TOC) from gen.plug.menu import EnumeratedListOption, NumberOption, PersonOption from gen.plug.report import Report from gen.plug.report import utils as ReportUtils @@ -249,7 +251,9 @@ class FanChart(Report): block_size = min_xy / self.max_generations text = _("%(generations)d Generation Fan Chart for %(person)s" ) % \ { 'generations' : self.max_generations, 'person' : n } - self.doc.center_text ('t', text, self.doc.get_usable_width() / 2, 0) + mark = IndexMark(text, INDEX_TYPE_TOC, 1) + self.doc.center_text ('t', text, + self.doc.get_usable_width() / 2, 0, mark) for generation in range (0, min (max_circular, self.max_generations)): self.draw_circular (x, y, start_angle, max_angle, block_size, generation) @@ -339,9 +343,11 @@ class FanChart(Report): if self.map[index]: if (generation == 0) and self.circle == FULL_CIRCLE: yc = y + person = self.database.get_person_from_handle(self.map[index]) + mark = ReportUtils.get_person_mark(self.database, person) txt = '\n'.join(self.text[index]) self.doc.rotate_text(text_style, txt, - xc, yc, text_angle) + xc, yc, text_angle, mark) text_angle += delta @@ -369,13 +375,15 @@ class FanChart(Report): start_angle, end_angle, rad1) text_angle += delta if self.map[index]: + person = self.database.get_person_from_handle(self.map[index]) + mark = ReportUtils.get_person_mark(self.database, person) txt = '\n'.join(self.text[index]) if self.radial == RADIAL_UPRIGHT and (start_angle >= 90) and (start_angle < 270): self.doc.rotate_text(text_style, txt, - xc, yc, text_angle + 180) + xc, yc, text_angle + 180, mark) else: self.doc.rotate_text(text_style, txt, - xc, yc, text_angle) + xc, yc, text_angle, mark) #------------------------------------------------------------------------ # diff --git a/src/plugins/drawreport/statisticschart.py b/src/plugins/drawreport/statisticschart.py index 752befadb..73b3d7220 100644 --- a/src/plugins/drawreport/statisticschart.py +++ b/src/plugins/drawreport/statisticschart.py @@ -5,7 +5,8 @@ # Copyright (C) 2004-2005 Eero Tamminen # Copyright (C) 2007-2008 Brian G. Matherly # Copyright (C) 2008 Peter Landgren -# Copyright (C) 2010 Jakim Friant +# Copyright (C) 2010 Jakim Friant +# Copyright (C) 2012 Paul Franklin # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -46,10 +47,11 @@ from gen.lib import Person, FamilyRelType, EventType, EventRoleType from gen.lib.date import Date # gender and report type names from gen.plug.docgen import (FontStyle, ParagraphStyle, GraphicsStyle, - FONT_SANS_SERIF, FONT_SERIF, - PARA_ALIGN_CENTER, PARA_ALIGN_LEFT) -from gen.plug.menu import BooleanOption, NumberOption, EnumeratedListOption, \ - FilterOption, PersonOption + FONT_SANS_SERIF, FONT_SERIF, + PARA_ALIGN_CENTER, PARA_ALIGN_LEFT, + IndexMark, INDEX_TYPE_TOC) +from gen.plug.menu import (BooleanOption, NumberOption, EnumeratedListOption, + FilterOption, PersonOption) from gen.plug.report import Report from gen.plug.report import utils as ReportUtils from gen.plug.report import MenuReportOptions @@ -782,10 +784,14 @@ class StatisticsChart(Report): def write_report(self): "output the selected statistics..." + mark = IndexMark(_('Statistics Charts'), INDEX_TYPE_TOC, 1) self._user.begin_progress(_('Statistics Charts'), _('Saving charts...'), len(self.data)) for data in self.data: self.doc.start_page() + if mark: + self.doc.draw_text('SC-title', '', 0, 0, mark) # put it in TOC + mark = None # crock, but we only want one of them if len(data[2]) < self.bar_items: self.output_piechart(*data[:4]) else: @@ -803,7 +809,8 @@ class StatisticsChart(Report): middle = min(middle_w,middle_h) # start output - self.doc.center_text('SC-title', title, middle_w, 0) + mark = IndexMark(title, INDEX_TYPE_TOC, 2) + self.doc.center_text('SC-title', title, middle_w, 0, mark) style_sheet = self.doc.get_style_sheet() pstyle = style_sheet.get_paragraph_style('SC-Title') yoffset = ReportUtils.pt2cm(pstyle.get_font().get_size()) @@ -857,7 +864,8 @@ class StatisticsChart(Report): maxsize = stopx - margin # start output - self.doc.center_text('SC-title', title, middle, 0) + mark = IndexMark(title, INDEX_TYPE_TOC, 2) + self.doc.center_text('SC-title', title, middle, 0, mark) pstyle = style_sheet.get_paragraph_style('SC-Title') yoffset = pt2cm(pstyle.get_font().get_size()) #print title diff --git a/src/plugins/drawreport/timeline.py b/src/plugins/drawreport/timeline.py index e164703ed..9ddc12fa6 100644 --- a/src/plugins/drawreport/timeline.py +++ b/src/plugins/drawreport/timeline.py @@ -3,7 +3,8 @@ # # Copyright (C) 2003-2007 Donald N. Allingham # Copyright (C) 2007-2008 Brian G. Matherly -# Copyright (C) 2010 Jakim Friant +# Copyright (C) 2010 Jakim Friant +# Copyright (C) 2012 Paul Franklin # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -44,7 +45,8 @@ from gen.plug.report import utils as ReportUtils from gen.plug.report import MenuReportOptions pt2cm = ReportUtils.pt2cm from gen.plug.docgen import (FontStyle, ParagraphStyle, GraphicsStyle, - FONT_SANS_SERIF, DASHED, PARA_ALIGN_CENTER) + FONT_SANS_SERIF, DASHED, PARA_ALIGN_CENTER, + IndexMark, INDEX_TYPE_TOC) from gen.sort import Sort from gen.display.name import displayer as name_displayer from gen.config import config @@ -138,7 +140,7 @@ class TimeLine(Report): self._user.end_progress() self.doc.start_page() - self.build_grid(low, high, start, stop) + self.build_grid(low, high, start, stop, True) index = 1 current = 1; @@ -163,8 +165,9 @@ class TimeLine(Report): d = None n = name_displayer.display_formal(p) + mark = ReportUtils.get_person_mark(self.database, p) self.doc.draw_text('TLG-text', n,incr+pad, - self.header + (incr+pad)*index) + self.header + (incr+pad)*index, mark) y1 = self.header + (pad+incr)*index y2 = self.header + ((pad+incr)*index)+incr @@ -205,7 +208,7 @@ class TimeLine(Report): self.doc.end_page() self._user.end_progress() - def build_grid(self, year_low, year_high, start_pos, stop_pos): + def build_grid(self, year_low, year_high, start_pos, stop_pos, toc=False): """ Draws the grid outline for the chart. Sets the document label, draws the vertical lines, and adds the year labels. Arguments @@ -216,7 +219,7 @@ class TimeLine(Report): start_pos - x position of the lowest leftmost grid line stop_pos - x position of the rightmost grid line """ - self.draw_title() + self.draw_title(toc) self.draw_columns(start_pos, stop_pos) if year_high is not None and year_low is not None: self.draw_year_headings(year_low, year_high, start_pos, stop_pos) @@ -237,7 +240,7 @@ class TimeLine(Report): xpos = start_pos + (val * delta) self.doc.draw_line('TLG-grid', xpos, top_y, xpos, bottom_y) - def draw_title(self): + def draw_title(self, toc): """ Draws the title for the page. """ @@ -246,7 +249,11 @@ class TimeLine(Report): byline = _("Sorted by %s") % self.sort_name # feature request 2356: avoid genitive form title = _("Timeline Graph for %s") % self.filter.get_name() - self.doc.center_text('TLG-title', title + "\n" + byline, width / 2.0, 0) + mark = None + if toc: + mark = IndexMark(title, INDEX_TYPE_TOC, 1) + self.doc.center_text('TLG-title', title + "\n" + byline, + width / 2.0, 0, mark) def draw_year_headings(self, year_low, year_high, start_pos, stop_pos): """ diff --git a/src/plugins/lib/libcairodoc.py b/src/plugins/lib/libcairodoc.py index fe6c2935e..423909d8c 100644 --- a/src/plugins/lib/libcairodoc.py +++ b/src/plugins/lib/libcairodoc.py @@ -1,13 +1,14 @@ # # Gramps - a GTK+/GNOME based genealogy program # -# Copyright (C) 2007 Zsolt Foldvari -# Copyright (C) 2009 Benny Malengier -# Copyright (C) 2009 Brian Matherly -# Copyright (C) 2010 Peter Landgren -# Copyright (C) 2010 Jakim Friant -# Copyright (C) 2011 Paul Franklin -# Copyright (C) 2012 Craig Anderson +# Copyright (C) 2000-2007 Donald N. Allingham +# Copyright (C) 2007 Zsolt Foldvari +# Copyright (C) 2009 Benny Malengier +# Copyright (C) 2009 Brian Matherly +# Copyright (C) 2010 Peter Landgren +# Copyright (C) 2010 Jakim Friant +# Copyright (C) 2011-2012 Paul Franklin +# Copyright (C) 2012 Craig Anderson # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -1228,13 +1229,17 @@ class GtkDocText(GtkDocBaseElement): # line spacing is not defined in ParagraphStyle spacingfractionfont = 0.2 - def __init__(self, style, vertical_alignment, text, x, y, angle=0): + def __init__(self, style, vertical_alignment, text, x, y, + angle=0, mark=None): GtkDocBaseElement.__init__(self, style) self._align_y = vertical_alignment self._text = text self._x = x self._y = y self._angle = angle + self._marklist = [] + if mark: + self._marklist = [mark] def draw(self, cr, layout, width, dpi_x, dpi_y): text_x = self._x * dpi_x / 2.54 @@ -1296,6 +1301,12 @@ class GtkDocText(GtkDocBaseElement): return layout_height + def get_marks(self): + """ + Return the index mark for this text + """ + return self._marklist + #------------------------------------------------------------------------ # # CairoDoc class @@ -1444,7 +1455,7 @@ class CairoDoc(BaseDoc, TextDoc, DrawDoc): def __write_text(self, text, mark=None, markup=False, links=False): """ @param text: text to write. - @param mark: IndexMark to use for indexing (if supported) + @param mark: IndexMark to use for indexing @param markup: True if text already contains markup info. Then text will no longer be escaped @param links: True if URLs should be made clickable @@ -1477,7 +1488,7 @@ links (like ODF) and write PDF from that format. """Write a normal piece of text according to the present style @param text: text to write. - @param mark: IndexMark to use for indexing (if supported) + @param mark: IndexMark to use for indexing @param links: True if URLs should be made clickable """ self.__write_text(text, mark, links=links) @@ -1557,7 +1568,8 @@ links (like ODF) and write PDF from that format. new_polygon = GtkDocPolygon(style, path) self._active_element.add_child(new_polygon) - def draw_box(self, style_name, text, x, y, w, h): + def draw_box(self, style_name, text, x, y, w, h, mark=None): + """ @param mark: IndexMark to use for indexing """ # we handle the box and... style_sheet = self.get_style_sheet() style = style_sheet.get_draw_style(style_name) @@ -1580,10 +1592,11 @@ links (like ODF) and write PDF from that format. new_text = GtkDocText(paragraph_style, 'center', self.__markup(text), - x + x_offset , y + h / 2, angle=0) + x + x_offset, y + h / 2, angle=0, mark=mark) self._active_element.add_child(new_text) - def draw_text(self, style_name, text, x, y): + def draw_text(self, style_name, text, x, y, mark=None): + """ @param mark: IndexMark to use for indexing """ style_sheet = self.get_style_sheet() style = style_sheet.get_draw_style(style_name) paragraph_style_name = style.get_paragraph_style() @@ -1591,10 +1604,11 @@ links (like ODF) and write PDF from that format. paragraph_style.set_alignment(PARA_ALIGN_LEFT) new_text = GtkDocText(paragraph_style, 'top', - self.__markup(text), x, y, angle=0) + self.__markup(text), x, y, angle=0, mark=mark) self._active_element.add_child(new_text) - def center_text(self, style_name, text, x, y): + def center_text(self, style_name, text, x, y, mark=None): + """ @param mark: IndexMark to use for indexing """ style_sheet = self.get_style_sheet() style = style_sheet.get_draw_style(style_name) paragraph_style_name = style.get_paragraph_style() @@ -1602,10 +1616,11 @@ links (like ODF) and write PDF from that format. paragraph_style.set_alignment(PARA_ALIGN_CENTER) new_text = GtkDocText(paragraph_style, 'top', - self.__markup(text), x, y, angle=0) + self.__markup(text), x, y, angle=0, mark=mark) self._active_element.add_child(new_text) - def rotate_text(self, style_name, text, x, y, angle): + def rotate_text(self, style_name, text, x, y, angle, mark=None): + """ @param mark: IndexMark to use for indexing """ style_sheet = self.get_style_sheet() style = style_sheet.get_draw_style(style_name) paragraph_style_name = style.get_paragraph_style() @@ -1613,7 +1628,7 @@ links (like ODF) and write PDF from that format. paragraph_style.set_alignment(PARA_ALIGN_CENTER) new_text = GtkDocText(paragraph_style, 'center', - self.__markup(text), x, y, angle) + self.__markup(text), x, y, angle, mark) self._active_element.add_child(new_text) # paginating and drawing interface diff --git a/src/plugins/textreport/alphabeticalindex.py b/src/plugins/textreport/alphabeticalindex.py index 307fa04f3..bf66c885a 100644 --- a/src/plugins/textreport/alphabeticalindex.py +++ b/src/plugins/textreport/alphabeticalindex.py @@ -1,6 +1,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2012 Nick Hall +# Copyright (C) 2012 Paul Franklin # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -33,7 +34,8 @@ from gen.ggettext import sgettext as _ from gen.plug.report import Report from gen.plug.report import MenuReportOptions from gen.plug.docgen import (FontStyle, ParagraphStyle, TableStyle, - TableCellStyle, FONT_SANS_SERIF) + TableCellStyle, FONT_SANS_SERIF, + IndexMark, INDEX_TYPE_TOC) #------------------------------------------------------------------------ # @@ -59,6 +61,10 @@ class AlphabeticalIndex(Report): def write_report(self): """ Generate the contents of the report """ + mark = IndexMark(_("Alphabetical Index"), INDEX_TYPE_TOC, 1) + self.doc.start_paragraph("IDX-Title") + self.doc.write_text('', mark) + self.doc.end_paragraph() self.doc.insert_index() #------------------------------------------------------------------------ diff --git a/src/plugins/textreport/ancestorreport.py b/src/plugins/textreport/ancestorreport.py index 5a5bab0a9..b82201499 100644 --- a/src/plugins/textreport/ancestorreport.py +++ b/src/plugins/textreport/ancestorreport.py @@ -4,6 +4,7 @@ # Copyright (C) 2000-2007 Donald N. Allingham # Copyright (C) 2007-2009 Brian G. Matherly # Copyright (C) 2010 Jakim Friant +# Copyright (C) 2012 Paul Franklin # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -209,9 +210,12 @@ class AncestorReport(Report): generation += 1 # Create the Generation title, set an index marker - mark = IndexMark(title, INDEX_TYPE_TOC, 2) + gen_text = self._("Generation %d") % generation + mark = None # don't need any with no page breaks + if self.pgbrk: + mark = IndexMark(gen_text, INDEX_TYPE_TOC, 2) self.doc.start_paragraph("AHN-Generation") - self.doc.write_text(self._("Generation %d") % generation, mark) + self.doc.write_text(gen_text, mark) self.doc.end_paragraph() # Build the entry diff --git a/src/plugins/textreport/custombooktext.py b/src/plugins/textreport/custombooktext.py index ffeaa7291..90f0accab 100644 --- a/src/plugins/textreport/custombooktext.py +++ b/src/plugins/textreport/custombooktext.py @@ -3,6 +3,7 @@ # Copyright (C) 2003-2006 Donald N. Allingham # Copyright (C) 2008 Brian G. Matherly # Copyright (C) 2010 Jakim Friant +# Copyright (C) 2012 Paul Franklin # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -46,7 +47,7 @@ from gen.plug.menu import TextOption from gen.plug.report import Report from gen.plug.report import MenuReportOptions from gen.plug.docgen import (FontStyle, ParagraphStyle, FONT_SANS_SERIF, - PARA_ALIGN_CENTER) + PARA_ALIGN_CENTER, IndexMark, INDEX_TYPE_TOC) #------------------------------------------------------------------------ # @@ -80,9 +81,17 @@ class CustomText(Report): self.bottom_text = menu.get_option_by_name('bot').get_value() def write_report(self): + mark_text = _("Custom Text") + if self.top_text[0]: + mark_text = "%s (%s)" % (_("Custom Text"), self.top_text[0]) + elif self.middle_text[0]: + mark_text = "%s (%s)" % (_("Custom Text"), self.middle_text[0]) + elif self.bottom_text[0]: + mark_text = "%s (%s)" % (_("Custom Text"), self.bottom_text[0]) + mark = IndexMark(mark_text, INDEX_TYPE_TOC, 1) self.doc.start_paragraph('CBT-Initial') for line in self.top_text: - self.doc.write_text(line) + self.doc.write_text(line, mark) self.doc.write_text("\n") self.doc.end_paragraph() diff --git a/src/plugins/textreport/tableofcontents.py b/src/plugins/textreport/tableofcontents.py index 2c9f09c28..cac702826 100644 --- a/src/plugins/textreport/tableofcontents.py +++ b/src/plugins/textreport/tableofcontents.py @@ -1,6 +1,7 @@ # Gramps - a GTK+/GNOME based genealogy program # # Copyright (C) 2012 Nick Hall +# Copyright (C) 2012 Paul Franklin # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -33,7 +34,8 @@ from gen.ggettext import sgettext as _ from gen.plug.report import Report from gen.plug.report import MenuReportOptions from gen.plug.docgen import (FontStyle, ParagraphStyle, TableStyle, - TableCellStyle, FONT_SANS_SERIF) + TableCellStyle, FONT_SANS_SERIF, + IndexMark, INDEX_TYPE_TOC) #------------------------------------------------------------------------ # @@ -59,6 +61,10 @@ class TableOfContents(Report): def write_report(self): """ Generate the contents of the report """ + mark = IndexMark(_("Table Of Contents"), INDEX_TYPE_TOC, 1) + self.doc.start_paragraph("TOC-Title") + self.doc.write_text('', mark) + self.doc.end_paragraph() self.doc.insert_toc() #------------------------------------------------------------------------