]> source.dussan.org Git - redmine.git/commitdiff
Interpret thumbnail macro in description, notes and formatted custom fields in issues...
authorMarius Balteanu <marius.balteanu@zitec.com>
Mon, 6 Sep 2021 19:22:50 +0000 (19:22 +0000)
committerMarius Balteanu <marius.balteanu@zitec.com>
Mon, 6 Sep 2021 19:22:50 +0000 (19:22 +0000)
Patch by Jens Krämer.

git-svn-id: http://svn.redmine.org/redmine/trunk@21213 e93f8b46-1217-0410-a6f0-8f06a7374b81

lib/redmine/export/pdf.rb
lib/redmine/export/pdf/issues_pdf_helper.rb

index 7e6252b3f6e82a1a86ea17892b01118b9d33dc2f..cba4167b4927574b3e248646187a774d99181607 100644 (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?
index 98c7347ab800eaa74a74bfd1b3aa2fc1d6944e3e..7fda6ad3607e80ce46eb12d10d021e122451f958 100644 (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'