remove trailing white-spaces lib/redmine/export/pdf.rb.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@5663 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2011-05-06 10:40:12 +00:00
parent 2711f4c745
commit 479d9380a7
1 changed files with 31 additions and 31 deletions

View File

@ -1,18 +1,18 @@
# encoding: utf-8 # encoding: utf-8
# #
# Redmine - project management software # Redmine - project management software
# Copyright (C) 2006-2009 Jean-Philippe Lang # Copyright (C) 2006-2011 Jean-Philippe Lang
# #
# This program is free software; you can redistribute it and/or # This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License # modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2 # as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version. # of the License, or (at your option) any later version.
# #
# This program is distributed in the hope that it will be useful, # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of # but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details. # GNU General Public License for more details.
# #
# You should have received a copy of the GNU General Public License # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@ -28,11 +28,11 @@ module Redmine
module PDF module PDF
include ActionView::Helpers::TextHelper include ActionView::Helpers::TextHelper
include ActionView::Helpers::NumberHelper include ActionView::Helpers::NumberHelper
class ITCPDF < TCPDF class ITCPDF < TCPDF
include Redmine::I18n include Redmine::I18n
attr_accessor :footer_date attr_accessor :footer_date
def initialize(lang) def initialize(lang)
super() super()
set_language_if_valid lang set_language_if_valid lang
@ -41,11 +41,11 @@ module Redmine
SetCreator(Redmine::Info.app_name) SetCreator(Redmine::Info.app_name)
SetFont(@font_for_content) SetFont(@font_for_content)
end end
def SetFontStyle(style, size) def SetFontStyle(style, size)
SetFont(@font_for_content, style, size) SetFont(@font_for_content, style, size)
end end
def SetTitle(txt) def SetTitle(txt)
txt = begin txt = begin
utf16txt = Iconv.conv('UTF-16BE', 'UTF-8', txt) utf16txt = Iconv.conv('UTF-16BE', 'UTF-8', txt)
@ -57,7 +57,7 @@ module Redmine
end || '' end || ''
super(txt) super(txt)
end end
def textstring(s) def textstring(s)
# Format a text string # Format a text string
if s =~ /^</ # This means the string is hex-dumped. if s =~ /^</ # This means the string is hex-dumped.
@ -66,10 +66,10 @@ module Redmine
return '('+escape(s)+')' return '('+escape(s)+')'
end end
end end
alias RDMCell Cell alias RDMCell Cell
alias RDMMultiCell MultiCell alias RDMMultiCell MultiCell
def Footer def Footer
SetFont(@font_for_footer, 'I', 8) SetFont(@font_for_footer, 'I', 8)
SetY(-15) SetY(-15)
@ -224,7 +224,7 @@ module Redmine
pdf.SetFontStyle('B',11) pdf.SetFontStyle('B',11)
pdf.RDMCell(190,10, title) pdf.RDMCell(190,10, title)
pdf.Ln pdf.Ln
# headers # headers
pdf.SetFontStyle('B',8) pdf.SetFontStyle('B',8)
pdf.SetFillColor(230, 230, 230) pdf.SetFillColor(230, 230, 230)
@ -241,7 +241,7 @@ module Redmine
issues_to_pdf_write_cells(pdf, query.columns, col_width, row_height, true) issues_to_pdf_write_cells(pdf, query.columns, col_width, row_height, true)
issues_to_pdf_draw_borders(pdf, base_x, base_y, base_y + max_height, col_id_width, col_width) issues_to_pdf_draw_borders(pdf, base_x, base_y, base_y + max_height, col_id_width, col_width)
pdf.SetY(base_y + max_height); pdf.SetY(base_y + max_height);
# rows # rows
pdf.SetFontStyle('',8) pdf.SetFontStyle('',8)
pdf.SetFillColor(255, 255, 255) pdf.SetFillColor(255, 255, 255)
@ -250,7 +250,7 @@ module Redmine
if query.grouped? && if query.grouped? &&
(group = query.group_by_column.value(issue)) != previous_group (group = query.group_by_column.value(issue)) != previous_group
pdf.SetFontStyle('B',9) pdf.SetFontStyle('B',9)
pdf.RDMCell(277, row_height, pdf.RDMCell(277, row_height,
(group.blank? ? 'None' : group.to_s) + " (#{query.issue_count_by_group[group]})", (group.blank? ? 'None' : group.to_s) + " (#{query.issue_count_by_group[group]})",
1, 1, 'L') 1, 1, 'L')
pdf.SetFontStyle('',8) pdf.SetFontStyle('',8)
@ -273,14 +273,14 @@ module Redmine
end end
s.to_s s.to_s
end end
# render it off-page to find the max height used # render it off-page to find the max height used
base_x = pdf.GetX base_x = pdf.GetX
base_y = pdf.GetY base_y = pdf.GetY
pdf.SetY(2 * page_height) pdf.SetY(2 * page_height)
max_height = issues_to_pdf_write_cells(pdf, col_values, col_width, row_height) max_height = issues_to_pdf_write_cells(pdf, col_values, col_width, row_height)
pdf.SetXY(base_x, base_y) pdf.SetXY(base_x, base_y)
# make new page if it doesn't fit on the current one # make new page if it doesn't fit on the current one
space_left = page_height - base_y - bottom_margin space_left = page_height - base_y - bottom_margin
if max_height > space_left if max_height > space_left
@ -295,14 +295,14 @@ module Redmine
issues_to_pdf_draw_borders(pdf, base_x, base_y, base_y + max_height, col_id_width, col_width) issues_to_pdf_draw_borders(pdf, base_x, base_y, base_y + max_height, col_id_width, col_width)
pdf.SetY(base_y + max_height); pdf.SetY(base_y + max_height);
end end
if issues.size == Setting.issues_export_limit.to_i if issues.size == Setting.issues_export_limit.to_i
pdf.SetFontStyle('B',10) pdf.SetFontStyle('B',10)
pdf.RDMCell(0, row_height, '...') pdf.RDMCell(0, row_height, '...')
end end
pdf.Output pdf.Output
end end
# Renders MultiCells and returns the maximum height used # Renders MultiCells and returns the maximum height used
def issues_to_pdf_write_cells(pdf, col_values, col_widths, row_height, head=false) def issues_to_pdf_write_cells(pdf, col_values, col_widths, row_height, head=false)
base_y = pdf.GetY base_y = pdf.GetY
@ -319,7 +319,7 @@ module Redmine
end end
return max_height return max_height
end end
# Draw lines to close the row (MultiCell border drawing in not uniform) # Draw lines to close the row (MultiCell border drawing in not uniform)
def issues_to_pdf_draw_borders(pdf, top_x, top_y, lower_y, id_width, col_widths) def issues_to_pdf_draw_borders(pdf, top_x, top_y, lower_y, id_width, col_widths)
col_x = top_x + id_width col_x = top_x + id_width
@ -331,7 +331,7 @@ module Redmine
pdf.Line(top_x, top_y, top_x, lower_y) # left border pdf.Line(top_x, top_y, top_x, lower_y) # left border
pdf.Line(top_x, lower_y, col_x, lower_y) # bottom border pdf.Line(top_x, lower_y, col_x, lower_y) # bottom border
end end
# Returns a PDF string of a single issue # Returns a PDF string of a single issue
def issue_to_pdf(issue) def issue_to_pdf(issue)
if l(:general_pdf_encoding).upcase != 'UTF-8' if l(:general_pdf_encoding).upcase != 'UTF-8'
@ -343,7 +343,7 @@ module Redmine
pdf.alias_nb_pages pdf.alias_nb_pages
pdf.footer_date = format_date(Date.today) pdf.footer_date = format_date(Date.today)
pdf.AddPage pdf.AddPage
pdf.SetFontStyle('B',11) pdf.SetFontStyle('B',11)
pdf.RDMMultiCell(190,5, "#{issue.project} - #{issue.tracker} # #{issue.id}: #{issue.subject}") pdf.RDMMultiCell(190,5, "#{issue.project} - #{issue.tracker} # #{issue.id}: #{issue.subject}")
pdf.Ln pdf.Ln
@ -358,7 +358,7 @@ module Redmine
pdf.SetFontStyle('',9) pdf.SetFontStyle('',9)
pdf.RDMCell(60,5, issue.priority.to_s,"RT") pdf.RDMCell(60,5, issue.priority.to_s,"RT")
pdf.Ln pdf.Ln
pdf.SetFontStyle('B',9) pdf.SetFontStyle('B',9)
pdf.RDMCell(35,5, l(:field_author) + ":","L") pdf.RDMCell(35,5, l(:field_author) + ":","L")
pdf.SetFontStyle('',9) pdf.SetFontStyle('',9)
@ -367,8 +367,8 @@ module Redmine
pdf.RDMCell(35,5, l(:field_category) + ":","L") pdf.RDMCell(35,5, l(:field_category) + ":","L")
pdf.SetFontStyle('',9) pdf.SetFontStyle('',9)
pdf.RDMCell(60,5, issue.category.to_s,"R") pdf.RDMCell(60,5, issue.category.to_s,"R")
pdf.Ln pdf.Ln
pdf.SetFontStyle('B',9) pdf.SetFontStyle('B',9)
pdf.RDMCell(35,5, l(:field_created_on) + ":","L") pdf.RDMCell(35,5, l(:field_created_on) + ":","L")
pdf.SetFontStyle('',9) pdf.SetFontStyle('',9)
@ -378,7 +378,7 @@ module Redmine
pdf.SetFontStyle('',9) pdf.SetFontStyle('',9)
pdf.RDMCell(60,5, issue.assigned_to.to_s,"R") pdf.RDMCell(60,5, issue.assigned_to.to_s,"R")
pdf.Ln pdf.Ln
pdf.SetFontStyle('B',9) pdf.SetFontStyle('B',9)
pdf.RDMCell(35,5, l(:field_updated_on) + ":","LB") pdf.RDMCell(35,5, l(:field_updated_on) + ":","LB")
pdf.SetFontStyle('',9) pdf.SetFontStyle('',9)
@ -388,14 +388,14 @@ module Redmine
pdf.SetFontStyle('',9) pdf.SetFontStyle('',9)
pdf.RDMCell(60,5, format_date(issue.due_date),"RB") pdf.RDMCell(60,5, format_date(issue.due_date),"RB")
pdf.Ln pdf.Ln
for custom_value in issue.custom_field_values for custom_value in issue.custom_field_values
pdf.SetFontStyle('B',9) pdf.SetFontStyle('B',9)
pdf.RDMCell(35,5, custom_value.custom_field.name + ":","L") pdf.RDMCell(35,5, custom_value.custom_field.name + ":","L")
pdf.SetFontStyle('',9) pdf.SetFontStyle('',9)
pdf.RDMMultiCell(155,5, (show_value custom_value),"R") pdf.RDMMultiCell(155,5, (show_value custom_value),"R")
end end
pdf.SetFontStyle('B',9) pdf.SetFontStyle('B',9)
pdf.RDMCell(35,5, l(:field_subject) + ":","LT") pdf.RDMCell(35,5, l(:field_subject) + ":","LT")
pdf.SetFontStyle('',9) pdf.SetFontStyle('',9)
@ -409,7 +409,7 @@ module Redmine
pdf.Line(pdf.GetX, y0, pdf.GetX, pdf.GetY) pdf.Line(pdf.GetX, y0, pdf.GetX, pdf.GetY)
pdf.Line(pdf.GetX, pdf.GetY, pdf.GetX + 190, pdf.GetY) pdf.Line(pdf.GetX, pdf.GetY, pdf.GetX + 190, pdf.GetY)
pdf.Ln pdf.Ln
if issue.changesets.any? && if issue.changesets.any? &&
User.current.allowed_to?(:view_changesets, issue.project) User.current.allowed_to?(:view_changesets, issue.project)
pdf.SetFontStyle('B',9) pdf.SetFontStyle('B',9)
@ -423,14 +423,14 @@ module Redmine
unless changeset.comments.blank? unless changeset.comments.blank?
pdf.SetFontStyle('',8) pdf.SetFontStyle('',8)
pdf.RDMMultiCell(190,5, changeset.comments.to_s) pdf.RDMMultiCell(190,5, changeset.comments.to_s)
end end
pdf.Ln pdf.Ln
end end
end end
pdf.SetFontStyle('B',9) pdf.SetFontStyle('B',9)
pdf.RDMCell(190,5, l(:label_history), "B") pdf.RDMCell(190,5, l(:label_history), "B")
pdf.Ln pdf.Ln
for journal in issue.journals.find( for journal in issue.journals.find(
:all, :include => [:user, :details], :all, :include => [:user, :details],
:order => "#{Journal.table_name}.created_on ASC") :order => "#{Journal.table_name}.created_on ASC")
@ -446,7 +446,7 @@ module Redmine
pdf.Ln unless journal.details.empty? pdf.Ln unless journal.details.empty?
pdf.SetFontStyle('',8) pdf.SetFontStyle('',8)
pdf.RDMMultiCell(190,5, journal.notes.to_s) pdf.RDMMultiCell(190,5, journal.notes.to_s)
end end
pdf.Ln pdf.Ln
end end