Fix for error 5851 in trunk and 3.4.

'&' and '<' give Pango warnings and does not display properly in
(most) Graphical reports.


svn: r19865
This commit is contained in:
Craig J. Anderson 2012-06-18 18:06:37 +00:00
parent 1e0946784c
commit 19a19adaa9
2 changed files with 24 additions and 15 deletions

View File

@ -339,7 +339,8 @@ class FanChart(Report):
if self.map[index]: if self.map[index]:
if (generation == 0) and self.circle == FULL_CIRCLE: if (generation == 0) and self.circle == FULL_CIRCLE:
yc = y yc = y
self.doc.rotate_text(text_style, self.text[index], txt = '\n'.join(self.text[index])
self.doc.rotate_text(text_style, txt,
xc, yc, text_angle) xc, yc, text_angle)
text_angle += delta text_angle += delta
@ -368,11 +369,12 @@ class FanChart(Report):
start_angle, end_angle, rad1) start_angle, end_angle, rad1)
text_angle += delta text_angle += delta
if self.map[index]: if self.map[index]:
txt = '\n'.join(self.text[index])
if self.radial == RADIAL_UPRIGHT and (start_angle >= 90) and (start_angle < 270): if self.radial == RADIAL_UPRIGHT and (start_angle >= 90) and (start_angle < 270):
self.doc.rotate_text(text_style, self.text[index], self.doc.rotate_text(text_style, txt,
xc, yc, text_angle + 180) xc, yc, text_angle + 180)
else: else:
self.doc.rotate_text(text_style, self.text[index], self.doc.rotate_text(text_style, txt,
xc, yc, text_angle) xc, yc, text_angle)
#------------------------------------------------------------------------ #------------------------------------------------------------------------

View File

@ -7,6 +7,7 @@
# Copyright (C) 2010 Peter Landgren # Copyright (C) 2010 Peter Landgren
# Copyright (C) 2010 Jakim Friant # Copyright (C) 2010 Jakim Friant
# Copyright (C) 2011 Paul Franklin # Copyright (C) 2011 Paul Franklin
# Copyright (C) 2012 Craig Anderson
# #
# This program is free software; you can redistribute it and/or modify # 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 # it under the terms of the GNU General Public License as published by
@ -1431,6 +1432,14 @@ class CairoDoc(BaseDoc, TextDoc, DrawDoc):
newlines.append(' '.join(singleline.split())) newlines.append(' '.join(singleline.split()))
self.__write_text('\n'.join(newlines), markup=True, links=links) self.__write_text('\n'.join(newlines), markup=True, links=links)
self.end_paragraph() self.end_paragraph()
def __markup(self, text, markup=None):
if not markup:
# We need to escape the text here for later pango.Layout.set_markup
# calls. This way we save the markup created by the report
# The markup in the note editor is not in the text so is not
# considered. It must be added by pango too
return self._backend.ESCAPE_FUNC()(text)
def __write_text(self, text, mark=None, markup=False, links=False): def __write_text(self, text, mark=None, markup=False, links=False):
""" """
@ -1457,12 +1466,7 @@ links (like ODF) and write PDF from that format.
""" % cairo.version """ % cairo.version
self._links_error = True self._links_error = True
if not markup: text = self.__markup(text, markup)
# We need to escape the text here for later pango.Layout.set_markup
# calls. This way we save the markup created by the report
# The markup in the note editor is not in the text so is not
# considered. It must be added by pango too
text = self._backend.ESCAPE_FUNC()(text)
if mark: if mark:
self._active_element.add_mark(mark) self._active_element.add_mark(mark)
@ -1572,9 +1576,9 @@ links (like ODF) and write PDF from that format.
if style.get_shadow(): if style.get_shadow():
x_offset = style.get_shadow_space() x_offset = style.get_shadow_space()
else: else:
x_offset = 0.2
new_text = GtkDocText(paragraph_style, 'center', text, 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)
self._active_element.add_child(new_text) self._active_element.add_child(new_text)
@ -1585,7 +1589,8 @@ links (like ODF) and write PDF from that format.
paragraph_style = style_sheet.get_paragraph_style(paragraph_style_name) paragraph_style = style_sheet.get_paragraph_style(paragraph_style_name)
paragraph_style.set_alignment(PARA_ALIGN_LEFT) paragraph_style.set_alignment(PARA_ALIGN_LEFT)
new_text = GtkDocText(paragraph_style, 'top', text, x, y, angle=0) new_text = GtkDocText(paragraph_style, 'top',
self.__markup(text), x, y, angle=0)
self._active_element.add_child(new_text) 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):
@ -1595,7 +1600,8 @@ links (like ODF) and write PDF from that format.
paragraph_style = style_sheet.get_paragraph_style(paragraph_style_name) paragraph_style = style_sheet.get_paragraph_style(paragraph_style_name)
paragraph_style.set_alignment(PARA_ALIGN_CENTER) paragraph_style.set_alignment(PARA_ALIGN_CENTER)
new_text = GtkDocText(paragraph_style, 'top', text, x, y, angle=0) new_text = GtkDocText(paragraph_style, 'top',
self.__markup(text), x, y, angle=0)
self._active_element.add_child(new_text) 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):
@ -1605,8 +1611,8 @@ links (like ODF) and write PDF from that format.
paragraph_style = style_sheet.get_paragraph_style(paragraph_style_name) paragraph_style = style_sheet.get_paragraph_style(paragraph_style_name)
paragraph_style.set_alignment(PARA_ALIGN_CENTER) paragraph_style.set_alignment(PARA_ALIGN_CENTER)
new_text = GtkDocText(paragraph_style, 'center', '\n'.join(text), new_text = GtkDocText(paragraph_style, 'center',
x, y, angle) self.__markup([text]), x, y, angle)
self._active_element.add_child(new_text) self._active_element.add_child(new_text)
# paginating and drawing interface # paginating and drawing interface
@ -1678,3 +1684,4 @@ links (like ODF) and write PDF from that format.
cr.stroke() cr.stroke()
self._pages[page_nr].draw(cr, layout, width, dpi_x, dpi_y) self._pages[page_nr].draw(cr, layout, width, dpi_x, dpi_y)