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
1=== modified file 'bin/report/render/rml2pdf/trml2pdf.py'
2--- bin/report/render/rml2pdf/trml2pdf.py 2011-07-26 16:02:06 +0000
3+++ bin/report/render/rml2pdf/trml2pdf.py 2012-07-12 12:37:33 +0000
4@@ -37,6 +37,7 @@
5 from reportlab.lib.units import inch,cm,mm
6 from tools.misc import file_open
7 from reportlab.pdfbase import pdfmetrics
8+from reportlab.lib.textsplit import wordSplit
9
10 try:
11 from cStringIO import StringIO
12@@ -46,6 +47,30 @@
13
14 encoding = 'utf-8'
15
16+class ParaWrap(platypus.Paragraph):
17+ def wrap(self, availWidth, availHeight):
18+ # work out widths array for breaking
19+ self.width = availWidth
20+ leftIndent = self.style.leftIndent
21+ first_line_width = availWidth - (leftIndent+self.style.firstLineIndent) - self.style.rightIndent
22+ later_widths = availWidth - leftIndent - self.style.rightIndent
23+
24+ if self.style.wordWrap == 'CJK':
25+ #use Asian text wrap algorithm to break characters
26+ self.blPara = self.breakLinesCJK([first_line_width, later_widths])
27+ else:
28+ self.blPara = self.breakLines([first_line_width, later_widths])
29+ new = []
30+ for line in self.blPara.lines:
31+ if line[0] < 0:
32+ for w in wordSplit(line[1][0], first_line_width, self.blPara.fontName, self.blPara.fontSize):
33+ new.append((w[0], [w[1]]))
34+ else:
35+ new.append(line)
36+ self.blPara.lines = new
37+ self.height = len(self.blPara.lines) * self.style.leading
38+ return (self.width, self.height)
39+
40 def _open_image(filename, path=None):
41 """Attempt to open a binary file and return the descriptor
42 """
43@@ -723,13 +748,16 @@
44 def _flowable(self, node, extra_style=None):
45 if node.tag=='pto':
46 return self._pto(node)
47- if node.tag=='para':
48+ if node.tag in ('para', 'parawrap'):
49 style = self.styles.para_style_get(node)
50 if extra_style:
51 style.__dict__.update(extra_style)
52 result = []
53 for i in self._textual(node).split('\n'):
54- result.append(platypus.Paragraph(i, style, **(utils.attr_get(node, [], {'bulletText':'str'}))))
55+ if node.tag == 'para':
56+ result.append(platypus.Paragraph(i, style, **(utils.attr_get(node, [], {'bulletText':'str'}))))
57+ else:
58+ result.append(ParaWrap(self._textual(node), style, **(utils.attr_get(node, [], {'bulletText':'str'}))))
59 return result
60 elif node.tag=='barCode':
61 try:

Subscribers

People subscribed via source and target branches

to all changes: