Project

General

Profile

Feature #35683 » 0001-interpret-thumbnail-macro-in-description-notes-and-f.patch

Jens Krämer, 2021-08-25 11:51

View differences:

lib/redmine/export/pdf.rb
104 104
          atta = RDMPdfEncoding.attach(@attachments, attrname, "UTF-8")
105 105
          if atta
106 106
            return atta.diskfile
107
          elsif %r{/attachments/download/(?<id>[^/]+)/} =~ attrname and
108
                atta = @attachments.find{|a| a.id.to_s == id} and
109
                atta.readable? and atta.visible?
110
            return atta.diskfile
107 111
          elsif %r{/attachments/thumbnail/(?<id>[^/]+)/(?<size>\d+)} =~ attrname and
108 112
                atta = @attachments.find{|a| a.id.to_s == id} and
109 113
                atta.readable? and atta.visible?
lib/redmine/export/pdf/issues_pdf_helper.rb
122 122

  
123 123
          # Set resize image scale
124 124
          pdf.set_image_scale(1.6)
125
          text =
126
            textilizable(
127
              issue, :description,
128
              :only_path => false,
129
              :edit_section_links => false,
130
              :headings => false,
131
              :inline_attachments => false
132
            )
125
          text = pdf_format_text(issue, :description)
133 126
          pdf.RDMwriteFormattedCell(35+155, 5, '', '', text, issue.attachments, "LRB")
134 127

  
135 128
          custom_field_values = issue.visible_custom_field_values.select {|value| value.custom_field.full_width_layout?}
......
232 225
              if journal.notes?
233 226
                pdf.ln unless journal.details.empty?
234 227
                pdf.SetFontStyle('', 8)
235
                text =
236
                  textilizable(
237
                    journal, :notes,
238
                    :only_path => false,
239
                    :edit_section_links => false,
240
                    :headings => false,
241
                    :inline_attachments => false
242
                  )
228
                text = pdf_format_text(journal, :notes)
243 229
                pdf.RDMwriteFormattedCell(190, 5, '', '', text, issue.attachments, "")
244 230
              end
245 231
              pdf.ln
......
347 333
            pdf.set_y(base_y + max_height)
348 334

  
349 335
            query.block_columns.each do |column|
336
              is_html = false
350 337
              if column.is_a?(QueryCustomFieldColumn)
351 338
                cv =
352 339
                  issue.visible_custom_field_values.detect do |v|
353 340
                    v.custom_field_id == column.custom_field.id
354 341
                  end
355
                text = show_value(cv, false)
342
                is_html = cv.custom_field.full_text_formatting?
343
                text = show_value(cv, is_html)
356 344
              else
357
                text = issue.send(column.name)
345
                text = pdf_format_text issue, column.name.to_sym
346
                is_html = true
358 347
              end
359 348
              next if text.blank?
360 349

  
......
363 352
              pdf.SetFontStyle('B', 9)
364 353
              pdf.RDMCell(0, 5, column.caption, "LRT", 1)
365 354
              pdf.SetFontStyle('', 9)
366
              pdf.RDMwriteHTMLCell(0, 5, '', '', text, [], "LRB")
355
              if is_html
356
                pdf.RDMwriteFormattedCell(0, 5, '', '', text, issue.attachments, "LRB")
357
              else
358
                pdf.RDMwriteHTMLCell(0, 5, '', '', text, [], "LRB")
359
              end
367 360
              pdf.set_auto_page_break(false)
368 361
            end
369 362
          end
......
375 368
          pdf.output
376 369
        end
377 370

  
371
        def pdf_format_text(object, attribute)
372
          textilizable(object, attribute,
373
                       :only_path => false,
374
                       :edit_section_links => false,
375
                       :headings => false,
376
                       :inline_attachments => false
377
                      )
378
        end
379

  
378 380
        def is_cjk?
379 381
          case current_language.to_s.downcase
380 382
          when 'ja', 'zh-tw', 'zh', 'ko'
(3-3/3)