1
0
mirror of https://github.com/meineerde/redmine.git synced 2026-01-31 19:47:14 +00:00

Interpret thumbnail macro in description, notes and formatted custom fields in issues list PDF export (35683).

Patch by Jens Krämer.

git-svn-id: http://svn.redmine.org/redmine/trunk@21213 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Marius Balteanu 2021-09-06 19:22:50 +00:00
parent fdf949a509
commit 326a1b4dd2
2 changed files with 25 additions and 19 deletions

View File

@ -104,6 +104,10 @@ module Redmine
atta = RDMPdfEncoding.attach(@attachments, attrname, "UTF-8")
if atta
return atta.diskfile
elsif %r{/attachments/download/(?<id>[^/]+)/} =~ attrname and
atta = @attachments.find{|a| a.id.to_s == id} and
atta.readable? and atta.visible?
return atta.diskfile
elsif %r{/attachments/thumbnail/(?<id>[^/]+)/(?<size>\d+)} =~ attrname and
atta = @attachments.find{|a| a.id.to_s == id} and
atta.readable? and atta.visible?

View File

@ -122,14 +122,7 @@ module Redmine
# Set resize image scale
pdf.set_image_scale(1.6)
text =
textilizable(
issue, :description,
:only_path => false,
:edit_section_links => false,
:headings => false,
:inline_attachments => false
)
text = pdf_format_text(issue, :description)
pdf.RDMwriteFormattedCell(35+155, 5, '', '', text, issue.attachments, "LRB")
custom_field_values = issue.visible_custom_field_values.select {|value| value.custom_field.full_width_layout?}
@ -232,14 +225,7 @@ module Redmine
if journal.notes?
pdf.ln unless journal.details.empty?
pdf.SetFontStyle('', 8)
text =
textilizable(
journal, :notes,
:only_path => false,
:edit_section_links => false,
:headings => false,
:inline_attachments => false
)
text = pdf_format_text(journal, :notes)
pdf.RDMwriteFormattedCell(190, 5, '', '', text, issue.attachments, "")
end
pdf.ln
@ -347,14 +333,17 @@ module Redmine
pdf.set_y(base_y + max_height)
query.block_columns.each do |column|
is_html = false
if column.is_a?(QueryCustomFieldColumn)
cv =
issue.visible_custom_field_values.detect do |v|
v.custom_field_id == column.custom_field.id
end
text = show_value(cv, false)
is_html = cv.custom_field.full_text_formatting?
text = show_value(cv, is_html)
else
text = issue.send(column.name)
text = pdf_format_text issue, column.name.to_sym
is_html = true
end
next if text.blank?
@ -363,7 +352,11 @@ module Redmine
pdf.SetFontStyle('B', 9)
pdf.RDMCell(0, 5, column.caption, "LRT", 1)
pdf.SetFontStyle('', 9)
pdf.RDMwriteHTMLCell(0, 5, '', '', text, [], "LRB")
if is_html
pdf.RDMwriteFormattedCell(0, 5, '', '', text, issue.attachments, "LRB")
else
pdf.RDMwriteHTMLCell(0, 5, '', '', text, [], "LRB")
end
pdf.set_auto_page_break(false)
end
end
@ -375,6 +368,15 @@ module Redmine
pdf.output
end
def pdf_format_text(object, attribute)
textilizable(object, attribute,
:only_path => false,
:edit_section_links => false,
:headings => false,
:inline_attachments => false
)
end
def is_cjk?
case current_language.to_s.downcase
when 'ja', 'zh-tw', 'zh', 'ko'