Merge lp:~unifield-team/unifield-server/unifield-server-UF_881 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 3403
Proposed branch: lp:~unifield-team/unifield-server/unifield-server-UF_881
Merge into: lp:unifield-server
Diff against target: 61 lines (+30/-2)
1 file modified
bin/report/render/rml2pdf/trml2pdf.py (+30/-2)
To merge this branch: bzr merge lp:~unifield-team/unifield-server/unifield-server-UF_881
Reviewer Review Type Date Requested Status
UniField Dev Team Pending
Review via email: mp+114628@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bin/report/render/rml2pdf/trml2pdf.py'
--- bin/report/render/rml2pdf/trml2pdf.py 2011-07-26 16:02:06 +0000
+++ bin/report/render/rml2pdf/trml2pdf.py 2012-07-12 12:37:33 +0000
@@ -37,6 +37,7 @@
37from reportlab.lib.units import inch,cm,mm37from reportlab.lib.units import inch,cm,mm
38from tools.misc import file_open38from tools.misc import file_open
39from reportlab.pdfbase import pdfmetrics39from reportlab.pdfbase import pdfmetrics
40from reportlab.lib.textsplit import wordSplit
4041
41try:42try:
42 from cStringIO import StringIO43 from cStringIO import StringIO
@@ -46,6 +47,30 @@
4647
47encoding = 'utf-8'48encoding = 'utf-8'
4849
50class ParaWrap(platypus.Paragraph):
51 def wrap(self, availWidth, availHeight):
52 # work out widths array for breaking
53 self.width = availWidth
54 leftIndent = self.style.leftIndent
55 first_line_width = availWidth - (leftIndent+self.style.firstLineIndent) - self.style.rightIndent
56 later_widths = availWidth - leftIndent - self.style.rightIndent
57
58 if self.style.wordWrap == 'CJK':
59 #use Asian text wrap algorithm to break characters
60 self.blPara = self.breakLinesCJK([first_line_width, later_widths])
61 else:
62 self.blPara = self.breakLines([first_line_width, later_widths])
63 new = []
64 for line in self.blPara.lines:
65 if line[0] < 0:
66 for w in wordSplit(line[1][0], first_line_width, self.blPara.fontName, self.blPara.fontSize):
67 new.append((w[0], [w[1]]))
68 else:
69 new.append(line)
70 self.blPara.lines = new
71 self.height = len(self.blPara.lines) * self.style.leading
72 return (self.width, self.height)
73
49def _open_image(filename, path=None):74def _open_image(filename, path=None):
50 """Attempt to open a binary file and return the descriptor75 """Attempt to open a binary file and return the descriptor
51 """76 """
@@ -723,13 +748,16 @@
723 def _flowable(self, node, extra_style=None):748 def _flowable(self, node, extra_style=None):
724 if node.tag=='pto':749 if node.tag=='pto':
725 return self._pto(node)750 return self._pto(node)
726 if node.tag=='para':751 if node.tag in ('para', 'parawrap'):
727 style = self.styles.para_style_get(node)752 style = self.styles.para_style_get(node)
728 if extra_style:753 if extra_style:
729 style.__dict__.update(extra_style)754 style.__dict__.update(extra_style)
730 result = []755 result = []
731 for i in self._textual(node).split('\n'):756 for i in self._textual(node).split('\n'):
732 result.append(platypus.Paragraph(i, style, **(utils.attr_get(node, [], {'bulletText':'str'}))))757 if node.tag == 'para':
758 result.append(platypus.Paragraph(i, style, **(utils.attr_get(node, [], {'bulletText':'str'}))))
759 else:
760 result.append(ParaWrap(self._textual(node), style, **(utils.attr_get(node, [], {'bulletText':'str'}))))
733 return result761 return result
734 elif node.tag=='barCode':762 elif node.tag=='barCode':
735 try:763 try:

Subscribers

People subscribed via source and target branches

to all changes: