gantt.rb_rfpdf115_2.patch

Jun NAITOH, 2011-03-29 16:08

Download (5.64 KB)

View differences:

lib/redmine/helpers/gantt.rb 2011-03-29 22:16:29.000000000 +0900
510 510
      end if Object.const_defined?(:Magick)
511 511

  
512 512
      def to_pdf
513
        pdf = ::Redmine::Export::PDF::IFPDF.new(current_language)
513
        if l(:general_pdf_encoding).upcase == 'UTF-8'
514
          pdf = ::Redmine::Export::PDF::ITCPDF.new(current_language)
515
        else
516
          pdf = ::Redmine::Export::PDF::IFPDF.new(current_language)
517
        end
514 518
        pdf.SetTitle("#{l(:label_gantt)} #{project}")
515
        pdf.AliasNbPages
519
        pdf.alias_nb_pages
516 520
        pdf.footer_date = format_date(Date.today)
517 521
        pdf.AddPage("L")
518 522
        pdf.SetFontStyle('B',12)
519 523
        pdf.SetX(15)
520
        pdf.Cell(PDF::LeftPaneWidth, 20, project.to_s)
524
        pdf.UTF8Cell(PDF::LeftPaneWidth, 20, project.to_s)
521 525
        pdf.Ln
522 526
        pdf.SetFontStyle('B',9)
523 527
        
......
552 556
          width = ((month_f >> 1) - month_f) * zoom 
553 557
          pdf.SetY(y_start)
554 558
          pdf.SetX(left)
555
          pdf.Cell(width, height, "#{month_f.year}-#{month_f.month}", "LTR", 0, "C")
559
          pdf.UTF8Cell(width, height, "#{month_f.year}-#{month_f.month}", "LTR", 0, "C")
556 560
          left = left + width
557 561
          month_f = month_f >> 1
558 562
        end  
......
570 574
            width = (7 - self.date_from.cwday + 1) * zoom-1
571 575
            pdf.SetY(y_start + header_heigth)
572 576
            pdf.SetX(left)
573
            pdf.Cell(width + 1, height, "", "LTR")
577
            pdf.UTF8Cell(width + 1, height, "", "LTR")
574 578
            left = left + width+1
575 579
          end
576 580
          while week_f <= self.date_to
577 581
            width = (week_f + 6 <= self.date_to) ? 7 * zoom : (self.date_to - week_f + 1) * zoom
578 582
            pdf.SetY(y_start + header_heigth)
579 583
            pdf.SetX(left)
580
            pdf.Cell(width, height, (width >= 5 ? week_f.cweek.to_s : ""), "LTR", 0, "C")
584
            pdf.UTF8Cell(width, height, (width >= 5 ? week_f.cweek.to_s : ""), "LTR", 0, "C")
581 585
            left = left + width
582 586
            week_f = week_f+7
583 587
          end
......
593 597
            width = zoom
594 598
            pdf.SetY(y_start + 2 * header_heigth)
595 599
            pdf.SetX(left)
596
            pdf.Cell(width, height, day_name(wday).first, "LTR", 0, "C")
600
            pdf.UTF8Cell(width, height, day_name(wday).first, "LTR", 0, "C")
597 601
            left = left + width
598 602
            wday = wday + 1
599 603
            wday = 1 if wday > 7
......
602 606
        
603 607
        pdf.SetY(y_start)
604 608
        pdf.SetX(15)
605
        pdf.Cell(subject_width+g_width-15, headers_heigth, "", 1)
609
        pdf.UTF8Cell(subject_width+g_width-15, headers_heigth, "", 1)
606 610
        
607 611
        # Tasks
608 612
        top = headers_heigth + y_start
......
722 726
        params[:pdf].SetX(15)
723 727
        
724 728
        char_limit = PDF::MaxCharactorsForSubject - params[:indent]
725
        params[:pdf].Cell(params[:subject_width]-15, 5, (" " * params[:indent]) +  subject.to_s.sub(/^(.{#{char_limit}}[^\s]*\s).*$/, '\1 (...)'), "LR")
729
        params[:pdf].UTF8Cell(params[:subject_width]-15, 5, (" " * params[:indent]) +  subject.to_s.sub(/^(.{#{char_limit}}[^\s]*\s).*$/, '\1 (...)'), "LR")
726 730
      
727 731
        params[:pdf].SetY(params[:top])
728 732
        params[:pdf].SetX(params[:subject_width])
729
        params[:pdf].Cell(params[:g_width], 5, "", "LR")
733
        params[:pdf].UTF8Cell(params[:g_width], 5, "", "LR")
730 734
      end
731 735
      
732 736
      def image_subject(params, subject, options={})
......
783 787
          params[:pdf].SetY(params[:top]+1.5)
784 788
          params[:pdf].SetX(params[:subject_width] + coords[:bar_start])
785 789
          params[:pdf].SetFillColor(200,200,200)
786
          params[:pdf].Cell(coords[:bar_end] - coords[:bar_start], height, "", 0, 0, "", 1)
790
          params[:pdf].UTF8Cell(coords[:bar_end] - coords[:bar_start], height, "", 0, 0, "", 1)
787 791
            
788 792
          if coords[:bar_late_end]
789 793
            params[:pdf].SetY(params[:top]+1.5)
790 794
            params[:pdf].SetX(params[:subject_width] + coords[:bar_start])
791 795
            params[:pdf].SetFillColor(255,100,100)
792
            params[:pdf].Cell(coords[:bar_late_end] - coords[:bar_start], height, "", 0, 0, "", 1)
796
            params[:pdf].UTF8Cell(coords[:bar_late_end] - coords[:bar_start], height, "", 0, 0, "", 1)
793 797
          end
794 798
          if coords[:bar_progress_end]
795 799
            params[:pdf].SetY(params[:top]+1.5)
796 800
            params[:pdf].SetX(params[:subject_width] + coords[:bar_start])
797 801
            params[:pdf].SetFillColor(90,200,90)
798
            params[:pdf].Cell(coords[:bar_progress_end] - coords[:bar_start], height, "", 0, 0, "", 1)
802
            params[:pdf].UTF8Cell(coords[:bar_progress_end] - coords[:bar_start], height, "", 0, 0, "", 1)
799 803
          end
800 804
        end
801 805
        # Renders the markers
......
804 808
            params[:pdf].SetY(params[:top] + 1)
805 809
            params[:pdf].SetX(params[:subject_width] + coords[:start] - 1)
806 810
            params[:pdf].SetFillColor(50,50,200)
807
            params[:pdf].Cell(2, 2, "", 0, 0, "", 1) 
811
            params[:pdf].UTF8Cell(2, 2, "", 0, 0, "", 1) 
808 812
          end
809 813
          if coords[:end]
810 814
            params[:pdf].SetY(params[:top] + 1)
811 815
            params[:pdf].SetX(params[:subject_width] + coords[:end] - 1)
812 816
            params[:pdf].SetFillColor(50,50,200)
813
            params[:pdf].Cell(2, 2, "", 0, 0, "", 1) 
817
            params[:pdf].UTF8Cell(2, 2, "", 0, 0, "", 1) 
814 818
          end
815 819
        end
816 820
        # Renders the label on the right
817 821
        if options[:label]
818 822
          params[:pdf].SetX(params[:subject_width] + (coords[:bar_end] || 0) + 5)
819
          params[:pdf].Cell(30, 2, options[:label])
823
          params[:pdf].UTF8Cell(30, 2, options[:label])
820 824
        end
821 825
      end
822 826