##// END OF EJS Templates
remove trailing white-spaces lib/redmine/export/pdf.rb....
Toshi MARUYAMA -
r5543:479d9380a7ec
parent child
Show More
@@ -1,18 +1,18
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-2011 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.
@@ -28,11 +28,11 module Redmine
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
@@ -41,11 +41,11 module Redmine
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)
@@ -57,7 +57,7 module Redmine
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.
@@ -66,10 +66,10 module Redmine
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)
@@ -224,7 +224,7 module Redmine
224 pdf.SetFontStyle('B',11)
224 pdf.SetFontStyle('B',11)
225 pdf.RDMCell(190,10, title)
225 pdf.RDMCell(190,10, title)
226 pdf.Ln
226 pdf.Ln
227
227
228 # headers
228 # headers
229 pdf.SetFontStyle('B',8)
229 pdf.SetFontStyle('B',8)
230 pdf.SetFillColor(230, 230, 230)
230 pdf.SetFillColor(230, 230, 230)
@@ -241,7 +241,7 module Redmine
241 issues_to_pdf_write_cells(pdf, query.columns, col_width, row_height, true)
241 issues_to_pdf_write_cells(pdf, query.columns, col_width, row_height, true)
242 issues_to_pdf_draw_borders(pdf, base_x, base_y, base_y + max_height, col_id_width, col_width)
242 issues_to_pdf_draw_borders(pdf, base_x, base_y, base_y + max_height, col_id_width, col_width)
243 pdf.SetY(base_y + max_height);
243 pdf.SetY(base_y + max_height);
244
244
245 # rows
245 # rows
246 pdf.SetFontStyle('',8)
246 pdf.SetFontStyle('',8)
247 pdf.SetFillColor(255, 255, 255)
247 pdf.SetFillColor(255, 255, 255)
@@ -250,7 +250,7 module Redmine
250 if query.grouped? &&
250 if query.grouped? &&
251 (group = query.group_by_column.value(issue)) != previous_group
251 (group = query.group_by_column.value(issue)) != previous_group
252 pdf.SetFontStyle('B',9)
252 pdf.SetFontStyle('B',9)
253 pdf.RDMCell(277, row_height,
253 pdf.RDMCell(277, row_height,
254 (group.blank? ? 'None' : group.to_s) + " (#{query.issue_count_by_group[group]})",
254 (group.blank? ? 'None' : group.to_s) + " (#{query.issue_count_by_group[group]})",
255 1, 1, 'L')
255 1, 1, 'L')
256 pdf.SetFontStyle('',8)
256 pdf.SetFontStyle('',8)
@@ -273,14 +273,14 module Redmine
273 end
273 end
274 s.to_s
274 s.to_s
275 end
275 end
276
276
277 # render it off-page to find the max height used
277 # render it off-page to find the max height used
278 base_x = pdf.GetX
278 base_x = pdf.GetX
279 base_y = pdf.GetY
279 base_y = pdf.GetY
280 pdf.SetY(2 * page_height)
280 pdf.SetY(2 * page_height)
281 max_height = issues_to_pdf_write_cells(pdf, col_values, col_width, row_height)
281 max_height = issues_to_pdf_write_cells(pdf, col_values, col_width, row_height)
282 pdf.SetXY(base_x, base_y)
282 pdf.SetXY(base_x, base_y)
283
283
284 # make new page if it doesn't fit on the current one
284 # make new page if it doesn't fit on the current one
285 space_left = page_height - base_y - bottom_margin
285 space_left = page_height - base_y - bottom_margin
286 if max_height > space_left
286 if max_height > space_left
@@ -295,14 +295,14 module Redmine
295 issues_to_pdf_draw_borders(pdf, base_x, base_y, base_y + max_height, col_id_width, col_width)
295 issues_to_pdf_draw_borders(pdf, base_x, base_y, base_y + max_height, col_id_width, col_width)
296 pdf.SetY(base_y + max_height);
296 pdf.SetY(base_y + max_height);
297 end
297 end
298
298
299 if issues.size == Setting.issues_export_limit.to_i
299 if issues.size == Setting.issues_export_limit.to_i
300 pdf.SetFontStyle('B',10)
300 pdf.SetFontStyle('B',10)
301 pdf.RDMCell(0, row_height, '...')
301 pdf.RDMCell(0, row_height, '...')
302 end
302 end
303 pdf.Output
303 pdf.Output
304 end
304 end
305
305
306 # Renders MultiCells and returns the maximum height used
306 # Renders MultiCells and returns the maximum height used
307 def issues_to_pdf_write_cells(pdf, col_values, col_widths, row_height, head=false)
307 def issues_to_pdf_write_cells(pdf, col_values, col_widths, row_height, head=false)
308 base_y = pdf.GetY
308 base_y = pdf.GetY
@@ -319,7 +319,7 module Redmine
319 end
319 end
320 return max_height
320 return max_height
321 end
321 end
322
322
323 # Draw lines to close the row (MultiCell border drawing in not uniform)
323 # Draw lines to close the row (MultiCell border drawing in not uniform)
324 def issues_to_pdf_draw_borders(pdf, top_x, top_y, lower_y, id_width, col_widths)
324 def issues_to_pdf_draw_borders(pdf, top_x, top_y, lower_y, id_width, col_widths)
325 col_x = top_x + id_width
325 col_x = top_x + id_width
@@ -331,7 +331,7 module Redmine
331 pdf.Line(top_x, top_y, top_x, lower_y) # left border
331 pdf.Line(top_x, top_y, top_x, lower_y) # left border
332 pdf.Line(top_x, lower_y, col_x, lower_y) # bottom border
332 pdf.Line(top_x, lower_y, col_x, lower_y) # bottom border
333 end
333 end
334
334
335 # Returns a PDF string of a single issue
335 # Returns a PDF string of a single issue
336 def issue_to_pdf(issue)
336 def issue_to_pdf(issue)
337 if l(:general_pdf_encoding).upcase != 'UTF-8'
337 if l(:general_pdf_encoding).upcase != 'UTF-8'
@@ -343,7 +343,7 module Redmine
343 pdf.alias_nb_pages
343 pdf.alias_nb_pages
344 pdf.footer_date = format_date(Date.today)
344 pdf.footer_date = format_date(Date.today)
345 pdf.AddPage
345 pdf.AddPage
346 pdf.SetFontStyle('B',11)
346 pdf.SetFontStyle('B',11)
347 pdf.RDMMultiCell(190,5, "#{issue.project} - #{issue.tracker} # #{issue.id}: #{issue.subject}")
347 pdf.RDMMultiCell(190,5, "#{issue.project} - #{issue.tracker} # #{issue.id}: #{issue.subject}")
348 pdf.Ln
348 pdf.Ln
349
349
@@ -358,7 +358,7 module Redmine
358 pdf.SetFontStyle('',9)
358 pdf.SetFontStyle('',9)
359 pdf.RDMCell(60,5, issue.priority.to_s,"RT")
359 pdf.RDMCell(60,5, issue.priority.to_s,"RT")
360 pdf.Ln
360 pdf.Ln
361
361
362 pdf.SetFontStyle('B',9)
362 pdf.SetFontStyle('B',9)
363 pdf.RDMCell(35,5, l(:field_author) + ":","L")
363 pdf.RDMCell(35,5, l(:field_author) + ":","L")
364 pdf.SetFontStyle('',9)
364 pdf.SetFontStyle('',9)
@@ -367,8 +367,8 module Redmine
367 pdf.RDMCell(35,5, l(:field_category) + ":","L")
367 pdf.RDMCell(35,5, l(:field_category) + ":","L")
368 pdf.SetFontStyle('',9)
368 pdf.SetFontStyle('',9)
369 pdf.RDMCell(60,5, issue.category.to_s,"R")
369 pdf.RDMCell(60,5, issue.category.to_s,"R")
370 pdf.Ln
370 pdf.Ln
371
371
372 pdf.SetFontStyle('B',9)
372 pdf.SetFontStyle('B',9)
373 pdf.RDMCell(35,5, l(:field_created_on) + ":","L")
373 pdf.RDMCell(35,5, l(:field_created_on) + ":","L")
374 pdf.SetFontStyle('',9)
374 pdf.SetFontStyle('',9)
@@ -378,7 +378,7 module Redmine
378 pdf.SetFontStyle('',9)
378 pdf.SetFontStyle('',9)
379 pdf.RDMCell(60,5, issue.assigned_to.to_s,"R")
379 pdf.RDMCell(60,5, issue.assigned_to.to_s,"R")
380 pdf.Ln
380 pdf.Ln
381
381
382 pdf.SetFontStyle('B',9)
382 pdf.SetFontStyle('B',9)
383 pdf.RDMCell(35,5, l(:field_updated_on) + ":","LB")
383 pdf.RDMCell(35,5, l(:field_updated_on) + ":","LB")
384 pdf.SetFontStyle('',9)
384 pdf.SetFontStyle('',9)
@@ -388,14 +388,14 module Redmine
388 pdf.SetFontStyle('',9)
388 pdf.SetFontStyle('',9)
389 pdf.RDMCell(60,5, format_date(issue.due_date),"RB")
389 pdf.RDMCell(60,5, format_date(issue.due_date),"RB")
390 pdf.Ln
390 pdf.Ln
391
391
392 for custom_value in issue.custom_field_values
392 for custom_value in issue.custom_field_values
393 pdf.SetFontStyle('B',9)
393 pdf.SetFontStyle('B',9)
394 pdf.RDMCell(35,5, custom_value.custom_field.name + ":","L")
394 pdf.RDMCell(35,5, custom_value.custom_field.name + ":","L")
395 pdf.SetFontStyle('',9)
395 pdf.SetFontStyle('',9)
396 pdf.RDMMultiCell(155,5, (show_value custom_value),"R")
396 pdf.RDMMultiCell(155,5, (show_value custom_value),"R")
397 end
397 end
398
398
399 pdf.SetFontStyle('B',9)
399 pdf.SetFontStyle('B',9)
400 pdf.RDMCell(35,5, l(:field_subject) + ":","LT")
400 pdf.RDMCell(35,5, l(:field_subject) + ":","LT")
401 pdf.SetFontStyle('',9)
401 pdf.SetFontStyle('',9)
@@ -409,7 +409,7 module Redmine
409 pdf.Line(pdf.GetX, y0, pdf.GetX, pdf.GetY)
409 pdf.Line(pdf.GetX, y0, pdf.GetX, pdf.GetY)
410 pdf.Line(pdf.GetX, pdf.GetY, pdf.GetX + 190, pdf.GetY)
410 pdf.Line(pdf.GetX, pdf.GetY, pdf.GetX + 190, pdf.GetY)
411 pdf.Ln
411 pdf.Ln
412
412
413 if issue.changesets.any? &&
413 if issue.changesets.any? &&
414 User.current.allowed_to?(:view_changesets, issue.project)
414 User.current.allowed_to?(:view_changesets, issue.project)
415 pdf.SetFontStyle('B',9)
415 pdf.SetFontStyle('B',9)
@@ -423,14 +423,14 module Redmine
423 unless changeset.comments.blank?
423 unless changeset.comments.blank?
424 pdf.SetFontStyle('',8)
424 pdf.SetFontStyle('',8)
425 pdf.RDMMultiCell(190,5, changeset.comments.to_s)
425 pdf.RDMMultiCell(190,5, changeset.comments.to_s)
426 end
426 end
427 pdf.Ln
427 pdf.Ln
428 end
428 end
429 end
429 end
430
430
431 pdf.SetFontStyle('B',9)
431 pdf.SetFontStyle('B',9)
432 pdf.RDMCell(190,5, l(:label_history), "B")
432 pdf.RDMCell(190,5, l(:label_history), "B")
433 pdf.Ln
433 pdf.Ln
434 for journal in issue.journals.find(
434 for journal in issue.journals.find(
435 :all, :include => [:user, :details],
435 :all, :include => [:user, :details],
436 :order => "#{Journal.table_name}.created_on ASC")
436 :order => "#{Journal.table_name}.created_on ASC")
@@ -446,7 +446,7 module Redmine
446 pdf.Ln unless journal.details.empty?
446 pdf.Ln unless journal.details.empty?
447 pdf.SetFontStyle('',8)
447 pdf.SetFontStyle('',8)
448 pdf.RDMMultiCell(190,5, journal.notes.to_s)
448 pdf.RDMMultiCell(190,5, journal.notes.to_s)
449 end
449 end
450 pdf.Ln
450 pdf.Ln
451 end
451 end
452
452
General Comments 0
You need to be logged in to leave comments. Login now