##// END OF EJS Templates
PDF: use explicit return value in Redmine::Export::PDF.fix_text_encoding() (#61)....
Toshi MARUYAMA -
r5478:c47144a14f71
parent child
Show More
@@ -1,402 +1,403
1 # encoding: utf-8
1 # encoding: utf-8
2 #
2 #
3 # Redmine - project management software
3 # Redmine - project management software
4 # Copyright (C) 2006-2009 Jean-Philippe Lang
4 # Copyright (C) 2006-2009 Jean-Philippe Lang
5 #
5 #
6 # This program is free software; you can redistribute it and/or
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
9 # of the License, or (at your option) any later version.
10 #
10 #
11 # This program is distributed in the hope that it will be useful,
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
14 # GNU General Public License for more details.
15 #
15 #
16 # You should have received a copy of the GNU General Public License
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19
19
20 require 'iconv'
20 require 'iconv'
21 require 'rfpdf/fpdf'
21 require 'rfpdf/fpdf'
22 require 'fpdf/chinese'
22 require 'fpdf/chinese'
23 require 'fpdf/japanese'
23 require 'fpdf/japanese'
24 require 'fpdf/korean'
24 require 'fpdf/korean'
25
25
26 module Redmine
26 module Redmine
27 module Export
27 module Export
28 module PDF
28 module PDF
29 include ActionView::Helpers::TextHelper
29 include ActionView::Helpers::TextHelper
30 include ActionView::Helpers::NumberHelper
30 include ActionView::Helpers::NumberHelper
31
31
32 class ITCPDF < TCPDF
32 class ITCPDF < TCPDF
33 include Redmine::I18n
33 include Redmine::I18n
34 attr_accessor :footer_date
34 attr_accessor :footer_date
35
35
36 def initialize(lang)
36 def initialize(lang)
37 super()
37 super()
38 set_language_if_valid lang
38 set_language_if_valid lang
39 @font_for_content = 'FreeSans'
39 @font_for_content = 'FreeSans'
40 @font_for_footer = 'FreeSans'
40 @font_for_footer = 'FreeSans'
41 SetCreator(Redmine::Info.app_name)
41 SetCreator(Redmine::Info.app_name)
42 SetFont(@font_for_content)
42 SetFont(@font_for_content)
43 end
43 end
44
44
45 def SetFontStyle(style, size)
45 def SetFontStyle(style, size)
46 SetFont(@font_for_content, style, size)
46 SetFont(@font_for_content, style, size)
47 end
47 end
48
48
49 def SetTitle(txt)
49 def SetTitle(txt)
50 txt = begin
50 txt = begin
51 utf16txt = Iconv.conv('UTF-16BE', 'UTF-8', txt)
51 utf16txt = Iconv.conv('UTF-16BE', 'UTF-8', txt)
52 hextxt = "<FEFF" # FEFF is BOM
52 hextxt = "<FEFF" # FEFF is BOM
53 hextxt << utf16txt.unpack("C*").map {|x| sprintf("%02X",x) }.join
53 hextxt << utf16txt.unpack("C*").map {|x| sprintf("%02X",x) }.join
54 hextxt << ">"
54 hextxt << ">"
55 rescue
55 rescue
56 txt
56 txt
57 end || ''
57 end || ''
58 super(txt)
58 super(txt)
59 end
59 end
60
60
61 def textstring(s)
61 def textstring(s)
62 # Format a text string
62 # Format a text string
63 if s =~ /^</ # This means the string is hex-dumped.
63 if s =~ /^</ # This means the string is hex-dumped.
64 return s
64 return s
65 else
65 else
66 return '('+escape(s)+')'
66 return '('+escape(s)+')'
67 end
67 end
68 end
68 end
69
69
70 alias RDMCell Cell
70 alias RDMCell Cell
71 alias RDMMultiCell MultiCell
71 alias RDMMultiCell MultiCell
72
72
73 def Footer
73 def Footer
74 SetFont(@font_for_footer, 'I', 8)
74 SetFont(@font_for_footer, 'I', 8)
75 SetY(-15)
75 SetY(-15)
76 SetX(15)
76 SetX(15)
77 RDMCell(0, 5, @footer_date, 0, 0, 'L')
77 RDMCell(0, 5, @footer_date, 0, 0, 'L')
78 SetY(-15)
78 SetY(-15)
79 SetX(-30)
79 SetX(-30)
80 RDMCell(0, 5, PageNo().to_s + '/{nb}', 0, 0, 'C')
80 RDMCell(0, 5, PageNo().to_s + '/{nb}', 0, 0, 'C')
81 end
81 end
82 end
82 end
83
83
84 class IFPDF < FPDF
84 class IFPDF < FPDF
85 include Redmine::I18n
85 include Redmine::I18n
86 attr_accessor :footer_date
86 attr_accessor :footer_date
87
87
88 def initialize(lang)
88 def initialize(lang)
89 super()
89 super()
90 set_language_if_valid lang
90 set_language_if_valid lang
91 case l(:general_pdf_encoding).upcase
91 case l(:general_pdf_encoding).upcase
92 when 'CP949'
92 when 'CP949'
93 extend(PDF_Korean)
93 extend(PDF_Korean)
94 AddUHCFont()
94 AddUHCFont()
95 @font_for_content = 'UHC'
95 @font_for_content = 'UHC'
96 @font_for_footer = 'UHC'
96 @font_for_footer = 'UHC'
97 when 'CP932'
97 when 'CP932'
98 extend(PDF_Japanese)
98 extend(PDF_Japanese)
99 AddSJISFont()
99 AddSJISFont()
100 @font_for_content = 'SJIS'
100 @font_for_content = 'SJIS'
101 @font_for_footer = 'SJIS'
101 @font_for_footer = 'SJIS'
102 when 'GB18030'
102 when 'GB18030'
103 extend(PDF_Chinese)
103 extend(PDF_Chinese)
104 AddGBFont()
104 AddGBFont()
105 @font_for_content = 'GB'
105 @font_for_content = 'GB'
106 @font_for_footer = 'GB'
106 @font_for_footer = 'GB'
107 when 'BIG5'
107 when 'BIG5'
108 extend(PDF_Chinese)
108 extend(PDF_Chinese)
109 AddBig5Font()
109 AddBig5Font()
110 @font_for_content = 'Big5'
110 @font_for_content = 'Big5'
111 @font_for_footer = 'Big5'
111 @font_for_footer = 'Big5'
112 else
112 else
113 @font_for_content = 'Arial'
113 @font_for_content = 'Arial'
114 @font_for_footer = 'Helvetica'
114 @font_for_footer = 'Helvetica'
115 end
115 end
116 SetCreator(Redmine::Info.app_name)
116 SetCreator(Redmine::Info.app_name)
117 SetFont(@font_for_content)
117 SetFont(@font_for_content)
118 end
118 end
119
119
120 def SetFontStyle(style, size)
120 def SetFontStyle(style, size)
121 SetFont(@font_for_content, style, size)
121 SetFont(@font_for_content, style, size)
122 end
122 end
123
123
124 def SetTitle(txt)
124 def SetTitle(txt)
125 txt = begin
125 txt = begin
126 utf16txt = Iconv.conv('UTF-16BE', 'UTF-8', txt)
126 utf16txt = Iconv.conv('UTF-16BE', 'UTF-8', txt)
127 hextxt = "<FEFF" # FEFF is BOM
127 hextxt = "<FEFF" # FEFF is BOM
128 hextxt << utf16txt.unpack("C*").map {|x| sprintf("%02X",x) }.join
128 hextxt << utf16txt.unpack("C*").map {|x| sprintf("%02X",x) }.join
129 hextxt << ">"
129 hextxt << ">"
130 rescue
130 rescue
131 txt
131 txt
132 end || ''
132 end || ''
133 super(txt)
133 super(txt)
134 end
134 end
135
135
136 def textstring(s)
136 def textstring(s)
137 # Format a text string
137 # Format a text string
138 if s =~ /^</ # This means the string is hex-dumped.
138 if s =~ /^</ # This means the string is hex-dumped.
139 return s
139 return s
140 else
140 else
141 return '('+escape(s)+')'
141 return '('+escape(s)+')'
142 end
142 end
143 end
143 end
144
144
145 def fix_text_encoding(txt)
145 def fix_text_encoding(txt)
146 txt ||= ''
146 txt ||= ''
147 if txt.respond_to?(:force_encoding)
147 if txt.respond_to?(:force_encoding)
148 txt.force_encoding('UTF-8')
148 txt.force_encoding('UTF-8')
149 txt = txt.encode(l(:general_pdf_encoding), :invalid => :replace,
149 txt = txt.encode(l(:general_pdf_encoding), :invalid => :replace,
150 :undef => :replace, :replace => '?')
150 :undef => :replace, :replace => '?')
151 txt.force_encoding('ASCII-8BIT')
151 txt.force_encoding('ASCII-8BIT')
152 else
152 else
153 @ic ||= Iconv.new(l(:general_pdf_encoding), 'UTF-8')
153 @ic ||= Iconv.new(l(:general_pdf_encoding), 'UTF-8')
154 txtar = ""
154 txtar = ""
155 begin
155 begin
156 txtar += @ic.iconv(txt)
156 txtar += @ic.iconv(txt)
157 rescue Iconv::IllegalSequence
157 rescue Iconv::IllegalSequence
158 txtar += $!.success
158 txtar += $!.success
159 txt = '?' + $!.failed[1,$!.failed.length]
159 txt = '?' + $!.failed[1,$!.failed.length]
160 retry
160 retry
161 rescue
161 rescue
162 txtar += $!.success
162 txtar += $!.success
163 end
163 end
164 txt = txtar
164 txt = txtar
165 end
165 end
166 txt
166 end
167 end
167
168
168 def RDMCell(w,h=0,txt='',border=0,ln=0,align='',fill=0,link='')
169 def RDMCell(w,h=0,txt='',border=0,ln=0,align='',fill=0,link='')
169 Cell(w,h,fix_text_encoding(txt),border,ln,align,fill,link)
170 Cell(w,h,fix_text_encoding(txt),border,ln,align,fill,link)
170 end
171 end
171
172
172 def RDMMultiCell(w,h=0,txt='',border=0,align='',fill=0)
173 def RDMMultiCell(w,h=0,txt='',border=0,align='',fill=0)
173 MultiCell(w,h,fix_text_encoding(txt),border,align,fill)
174 MultiCell(w,h,fix_text_encoding(txt),border,align,fill)
174 end
175 end
175
176
176 def Footer
177 def Footer
177 SetFont(@font_for_footer, 'I', 8)
178 SetFont(@font_for_footer, 'I', 8)
178 SetY(-15)
179 SetY(-15)
179 SetX(15)
180 SetX(15)
180 RDMCell(0, 5, @footer_date, 0, 0, 'L')
181 RDMCell(0, 5, @footer_date, 0, 0, 'L')
181 SetY(-15)
182 SetY(-15)
182 SetX(-30)
183 SetX(-30)
183 RDMCell(0, 5, PageNo().to_s + '/{nb}', 0, 0, 'C')
184 RDMCell(0, 5, PageNo().to_s + '/{nb}', 0, 0, 'C')
184 end
185 end
185 alias alias_nb_pages AliasNbPages
186 alias alias_nb_pages AliasNbPages
186 end
187 end
187
188
188 # Returns a PDF string of a list of issues
189 # Returns a PDF string of a list of issues
189 def issues_to_pdf(issues, project, query)
190 def issues_to_pdf(issues, project, query)
190 if l(:general_pdf_encoding).upcase != 'UTF-8'
191 if l(:general_pdf_encoding).upcase != 'UTF-8'
191 pdf = IFPDF.new(current_language)
192 pdf = IFPDF.new(current_language)
192 else
193 else
193 pdf = ITCPDF.new(current_language)
194 pdf = ITCPDF.new(current_language)
194 end
195 end
195 title = query.new_record? ? l(:label_issue_plural) : query.name
196 title = query.new_record? ? l(:label_issue_plural) : query.name
196 title = "#{project} - #{title}" if project
197 title = "#{project} - #{title}" if project
197 pdf.SetTitle(title)
198 pdf.SetTitle(title)
198 pdf.alias_nb_pages
199 pdf.alias_nb_pages
199 pdf.footer_date = format_date(Date.today)
200 pdf.footer_date = format_date(Date.today)
200 pdf.AddPage("L")
201 pdf.AddPage("L")
201
202
202 row_height = 6
203 row_height = 6
203 col_width = []
204 col_width = []
204 unless query.columns.empty?
205 unless query.columns.empty?
205 col_width = query.columns.collect {|column| column.name == :subject ? 4.0 : 1.0 }
206 col_width = query.columns.collect {|column| column.name == :subject ? 4.0 : 1.0 }
206 ratio = 262.0 / col_width.inject(0) {|s,w| s += w}
207 ratio = 262.0 / col_width.inject(0) {|s,w| s += w}
207 col_width = col_width.collect {|w| w * ratio}
208 col_width = col_width.collect {|w| w * ratio}
208 end
209 end
209
210
210 # title
211 # title
211 pdf.SetFontStyle('B',11)
212 pdf.SetFontStyle('B',11)
212 pdf.RDMCell(190,10, title)
213 pdf.RDMCell(190,10, title)
213 pdf.Ln
214 pdf.Ln
214
215
215 # headers
216 # headers
216 pdf.SetFontStyle('B',8)
217 pdf.SetFontStyle('B',8)
217 pdf.SetFillColor(230, 230, 230)
218 pdf.SetFillColor(230, 230, 230)
218 pdf.RDMCell(15, row_height, "#", 1, 0, 'L', 1)
219 pdf.RDMCell(15, row_height, "#", 1, 0, 'L', 1)
219 query.columns.each_with_index do |column, i|
220 query.columns.each_with_index do |column, i|
220 pdf.RDMCell(col_width[i], row_height, column.caption, 1, 0, 'L', 1)
221 pdf.RDMCell(col_width[i], row_height, column.caption, 1, 0, 'L', 1)
221 end
222 end
222 pdf.Ln
223 pdf.Ln
223
224
224 # rows
225 # rows
225 pdf.SetFontStyle('',8)
226 pdf.SetFontStyle('',8)
226 pdf.SetFillColor(255, 255, 255)
227 pdf.SetFillColor(255, 255, 255)
227 previous_group = false
228 previous_group = false
228 issues.each do |issue|
229 issues.each do |issue|
229 if query.grouped? &&
230 if query.grouped? &&
230 (group = query.group_by_column.value(issue)) != previous_group
231 (group = query.group_by_column.value(issue)) != previous_group
231 pdf.SetFontStyle('B',9)
232 pdf.SetFontStyle('B',9)
232 pdf.RDMCell(277, row_height,
233 pdf.RDMCell(277, row_height,
233 (group.blank? ? 'None' : group.to_s) + " (#{query.issue_count_by_group[group]})",
234 (group.blank? ? 'None' : group.to_s) + " (#{query.issue_count_by_group[group]})",
234 1, 1, 'L')
235 1, 1, 'L')
235 pdf.SetFontStyle('',8)
236 pdf.SetFontStyle('',8)
236 previous_group = group
237 previous_group = group
237 end
238 end
238 pdf.RDMCell(15, row_height, issue.id.to_s, 1, 0, 'L', 1)
239 pdf.RDMCell(15, row_height, issue.id.to_s, 1, 0, 'L', 1)
239 query.columns.each_with_index do |column, i|
240 query.columns.each_with_index do |column, i|
240 s = if column.is_a?(QueryCustomFieldColumn)
241 s = if column.is_a?(QueryCustomFieldColumn)
241 cv = issue.custom_values.detect {|v| v.custom_field_id == column.custom_field.id}
242 cv = issue.custom_values.detect {|v| v.custom_field_id == column.custom_field.id}
242 show_value(cv)
243 show_value(cv)
243 else
244 else
244 value = issue.send(column.name)
245 value = issue.send(column.name)
245 if value.is_a?(Date)
246 if value.is_a?(Date)
246 format_date(value)
247 format_date(value)
247 elsif value.is_a?(Time)
248 elsif value.is_a?(Time)
248 format_time(value)
249 format_time(value)
249 else
250 else
250 value
251 value
251 end
252 end
252 end
253 end
253 pdf.RDMCell(col_width[i], row_height, s.to_s, 1, 0, 'L', 1)
254 pdf.RDMCell(col_width[i], row_height, s.to_s, 1, 0, 'L', 1)
254 end
255 end
255 pdf.Ln
256 pdf.Ln
256 end
257 end
257 if issues.size == Setting.issues_export_limit.to_i
258 if issues.size == Setting.issues_export_limit.to_i
258 pdf.SetFontStyle('B',10)
259 pdf.SetFontStyle('B',10)
259 pdf.RDMCell(0, row_height, '...')
260 pdf.RDMCell(0, row_height, '...')
260 end
261 end
261 pdf.Output
262 pdf.Output
262 end
263 end
263
264
264 # Returns a PDF string of a single issue
265 # Returns a PDF string of a single issue
265 def issue_to_pdf(issue)
266 def issue_to_pdf(issue)
266 if l(:general_pdf_encoding).upcase != 'UTF-8'
267 if l(:general_pdf_encoding).upcase != 'UTF-8'
267 pdf = IFPDF.new(current_language)
268 pdf = IFPDF.new(current_language)
268 else
269 else
269 pdf = ITCPDF.new(current_language)
270 pdf = ITCPDF.new(current_language)
270 end
271 end
271 pdf.SetTitle("#{issue.project} - ##{issue.tracker} #{issue.id}")
272 pdf.SetTitle("#{issue.project} - ##{issue.tracker} #{issue.id}")
272 pdf.alias_nb_pages
273 pdf.alias_nb_pages
273 pdf.footer_date = format_date(Date.today)
274 pdf.footer_date = format_date(Date.today)
274 pdf.AddPage
275 pdf.AddPage
275
276
276 pdf.SetFontStyle('B',11)
277 pdf.SetFontStyle('B',11)
277 pdf.RDMCell(190,10,
278 pdf.RDMCell(190,10,
278 "#{issue.project} - #{issue.tracker} # #{issue.id}: #{issue.subject}")
279 "#{issue.project} - #{issue.tracker} # #{issue.id}: #{issue.subject}")
279 pdf.Ln
280 pdf.Ln
280
281
281 y0 = pdf.GetY
282 y0 = pdf.GetY
282
283
283 pdf.SetFontStyle('B',9)
284 pdf.SetFontStyle('B',9)
284 pdf.RDMCell(35,5, l(:field_status) + ":","LT")
285 pdf.RDMCell(35,5, l(:field_status) + ":","LT")
285 pdf.SetFontStyle('',9)
286 pdf.SetFontStyle('',9)
286 pdf.RDMCell(60,5, issue.status.to_s,"RT")
287 pdf.RDMCell(60,5, issue.status.to_s,"RT")
287 pdf.SetFontStyle('B',9)
288 pdf.SetFontStyle('B',9)
288 pdf.RDMCell(35,5, l(:field_priority) + ":","LT")
289 pdf.RDMCell(35,5, l(:field_priority) + ":","LT")
289 pdf.SetFontStyle('',9)
290 pdf.SetFontStyle('',9)
290 pdf.RDMCell(60,5, issue.priority.to_s,"RT")
291 pdf.RDMCell(60,5, issue.priority.to_s,"RT")
291 pdf.Ln
292 pdf.Ln
292
293
293 pdf.SetFontStyle('B',9)
294 pdf.SetFontStyle('B',9)
294 pdf.RDMCell(35,5, l(:field_author) + ":","L")
295 pdf.RDMCell(35,5, l(:field_author) + ":","L")
295 pdf.SetFontStyle('',9)
296 pdf.SetFontStyle('',9)
296 pdf.RDMCell(60,5, issue.author.to_s,"R")
297 pdf.RDMCell(60,5, issue.author.to_s,"R")
297 pdf.SetFontStyle('B',9)
298 pdf.SetFontStyle('B',9)
298 pdf.RDMCell(35,5, l(:field_category) + ":","L")
299 pdf.RDMCell(35,5, l(:field_category) + ":","L")
299 pdf.SetFontStyle('',9)
300 pdf.SetFontStyle('',9)
300 pdf.RDMCell(60,5, issue.category.to_s,"R")
301 pdf.RDMCell(60,5, issue.category.to_s,"R")
301 pdf.Ln
302 pdf.Ln
302
303
303 pdf.SetFontStyle('B',9)
304 pdf.SetFontStyle('B',9)
304 pdf.RDMCell(35,5, l(:field_created_on) + ":","L")
305 pdf.RDMCell(35,5, l(:field_created_on) + ":","L")
305 pdf.SetFontStyle('',9)
306 pdf.SetFontStyle('',9)
306 pdf.RDMCell(60,5, format_date(issue.created_on),"R")
307 pdf.RDMCell(60,5, format_date(issue.created_on),"R")
307 pdf.SetFontStyle('B',9)
308 pdf.SetFontStyle('B',9)
308 pdf.RDMCell(35,5, l(:field_assigned_to) + ":","L")
309 pdf.RDMCell(35,5, l(:field_assigned_to) + ":","L")
309 pdf.SetFontStyle('',9)
310 pdf.SetFontStyle('',9)
310 pdf.RDMCell(60,5, issue.assigned_to.to_s,"R")
311 pdf.RDMCell(60,5, issue.assigned_to.to_s,"R")
311 pdf.Ln
312 pdf.Ln
312
313
313 pdf.SetFontStyle('B',9)
314 pdf.SetFontStyle('B',9)
314 pdf.RDMCell(35,5, l(:field_updated_on) + ":","LB")
315 pdf.RDMCell(35,5, l(:field_updated_on) + ":","LB")
315 pdf.SetFontStyle('',9)
316 pdf.SetFontStyle('',9)
316 pdf.RDMCell(60,5, format_date(issue.updated_on),"RB")
317 pdf.RDMCell(60,5, format_date(issue.updated_on),"RB")
317 pdf.SetFontStyle('B',9)
318 pdf.SetFontStyle('B',9)
318 pdf.RDMCell(35,5, l(:field_due_date) + ":","LB")
319 pdf.RDMCell(35,5, l(:field_due_date) + ":","LB")
319 pdf.SetFontStyle('',9)
320 pdf.SetFontStyle('',9)
320 pdf.RDMCell(60,5, format_date(issue.due_date),"RB")
321 pdf.RDMCell(60,5, format_date(issue.due_date),"RB")
321 pdf.Ln
322 pdf.Ln
322
323
323 for custom_value in issue.custom_field_values
324 for custom_value in issue.custom_field_values
324 pdf.SetFontStyle('B',9)
325 pdf.SetFontStyle('B',9)
325 pdf.RDMCell(35,5, custom_value.custom_field.name + ":","L")
326 pdf.RDMCell(35,5, custom_value.custom_field.name + ":","L")
326 pdf.SetFontStyle('',9)
327 pdf.SetFontStyle('',9)
327 pdf.RDMMultiCell(155,5, (show_value custom_value),"R")
328 pdf.RDMMultiCell(155,5, (show_value custom_value),"R")
328 end
329 end
329
330
330 pdf.SetFontStyle('B',9)
331 pdf.SetFontStyle('B',9)
331 pdf.RDMCell(35,5, l(:field_subject) + ":","LTB")
332 pdf.RDMCell(35,5, l(:field_subject) + ":","LTB")
332 pdf.SetFontStyle('',9)
333 pdf.SetFontStyle('',9)
333 pdf.RDMCell(155,5, issue.subject,"RTB")
334 pdf.RDMCell(155,5, issue.subject,"RTB")
334 pdf.Ln
335 pdf.Ln
335
336
336 pdf.SetFontStyle('B',9)
337 pdf.SetFontStyle('B',9)
337 pdf.RDMCell(35,5, l(:field_description) + ":")
338 pdf.RDMCell(35,5, l(:field_description) + ":")
338 pdf.SetFontStyle('',9)
339 pdf.SetFontStyle('',9)
339 pdf.RDMMultiCell(155,5, issue.description.to_s,"BR")
340 pdf.RDMMultiCell(155,5, issue.description.to_s,"BR")
340
341
341 pdf.Line(pdf.GetX, y0, pdf.GetX, pdf.GetY)
342 pdf.Line(pdf.GetX, y0, pdf.GetX, pdf.GetY)
342 pdf.Line(pdf.GetX, pdf.GetY, 170, pdf.GetY)
343 pdf.Line(pdf.GetX, pdf.GetY, 170, pdf.GetY)
343 pdf.Ln
344 pdf.Ln
344
345
345 if issue.changesets.any? &&
346 if issue.changesets.any? &&
346 User.current.allowed_to?(:view_changesets, issue.project)
347 User.current.allowed_to?(:view_changesets, issue.project)
347 pdf.SetFontStyle('B',9)
348 pdf.SetFontStyle('B',9)
348 pdf.RDMCell(190,5, l(:label_associated_revisions), "B")
349 pdf.RDMCell(190,5, l(:label_associated_revisions), "B")
349 pdf.Ln
350 pdf.Ln
350 for changeset in issue.changesets
351 for changeset in issue.changesets
351 pdf.SetFontStyle('B',8)
352 pdf.SetFontStyle('B',8)
352 pdf.RDMCell(190,5,
353 pdf.RDMCell(190,5,
353 format_time(changeset.committed_on) + " - " + changeset.author.to_s)
354 format_time(changeset.committed_on) + " - " + changeset.author.to_s)
354 pdf.Ln
355 pdf.Ln
355 unless changeset.comments.blank?
356 unless changeset.comments.blank?
356 pdf.SetFontStyle('',8)
357 pdf.SetFontStyle('',8)
357 pdf.RDMMultiCell(190,5, changeset.comments.to_s)
358 pdf.RDMMultiCell(190,5, changeset.comments.to_s)
358 end
359 end
359 pdf.Ln
360 pdf.Ln
360 end
361 end
361 end
362 end
362
363
363 pdf.SetFontStyle('B',9)
364 pdf.SetFontStyle('B',9)
364 pdf.RDMCell(190,5, l(:label_history), "B")
365 pdf.RDMCell(190,5, l(:label_history), "B")
365 pdf.Ln
366 pdf.Ln
366 for journal in issue.journals.find(
367 for journal in issue.journals.find(
367 :all, :include => [:user, :details],
368 :all, :include => [:user, :details],
368 :order => "#{Journal.table_name}.created_on ASC")
369 :order => "#{Journal.table_name}.created_on ASC")
369 pdf.SetFontStyle('B',8)
370 pdf.SetFontStyle('B',8)
370 pdf.RDMCell(190,5,
371 pdf.RDMCell(190,5,
371 format_time(journal.created_on) + " - " + journal.user.name)
372 format_time(journal.created_on) + " - " + journal.user.name)
372 pdf.Ln
373 pdf.Ln
373 pdf.SetFontStyle('I',8)
374 pdf.SetFontStyle('I',8)
374 for detail in journal.details
375 for detail in journal.details
375 pdf.RDMCell(190,5, "- " + show_detail(detail, true))
376 pdf.RDMCell(190,5, "- " + show_detail(detail, true))
376 pdf.Ln
377 pdf.Ln
377 end
378 end
378 if journal.notes?
379 if journal.notes?
379 pdf.SetFontStyle('',8)
380 pdf.SetFontStyle('',8)
380 pdf.RDMMultiCell(190,5, journal.notes.to_s)
381 pdf.RDMMultiCell(190,5, journal.notes.to_s)
381 end
382 end
382 pdf.Ln
383 pdf.Ln
383 end
384 end
384
385
385 if issue.attachments.any?
386 if issue.attachments.any?
386 pdf.SetFontStyle('B',9)
387 pdf.SetFontStyle('B',9)
387 pdf.RDMCell(190,5, l(:label_attachment_plural), "B")
388 pdf.RDMCell(190,5, l(:label_attachment_plural), "B")
388 pdf.Ln
389 pdf.Ln
389 for attachment in issue.attachments
390 for attachment in issue.attachments
390 pdf.SetFontStyle('',8)
391 pdf.SetFontStyle('',8)
391 pdf.RDMCell(80,5, attachment.filename)
392 pdf.RDMCell(80,5, attachment.filename)
392 pdf.RDMCell(20,5, number_to_human_size(attachment.filesize),0,0,"R")
393 pdf.RDMCell(20,5, number_to_human_size(attachment.filesize),0,0,"R")
393 pdf.RDMCell(25,5, format_date(attachment.created_on),0,0,"R")
394 pdf.RDMCell(25,5, format_date(attachment.created_on),0,0,"R")
394 pdf.RDMCell(65,5, attachment.author.name,0,0,"R")
395 pdf.RDMCell(65,5, attachment.author.name,0,0,"R")
395 pdf.Ln
396 pdf.Ln
396 end
397 end
397 end
398 end
398 pdf.Output
399 pdf.Output
399 end
400 end
400 end
401 end
401 end
402 end
402 end
403 end
General Comments 0
You need to be logged in to leave comments. Login now