Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 7cb1a2fe

Von Sven Schöling vor etwa 5 Jahren hinzugefügt

  • ID 7cb1a2fecdb21a48b6f314fc29b891d1260eea66
  • Vorgänger a5a81f46
  • Nachfolger 23c33932

Unterstützung für zellenübergreifende Überschriften im PDF-Export des ReportGenerators verbessert.

Reimplementation von d3897394/35cd4452.

Unterschiede anzeigen:

modules/override/PDF/Table.pm
8 8
package PDF::Table;
9 9

  
10 10
use Carp;
11
use List::Util qw(sum);
12

  
11 13
our $VERSION = '0.10.1';
12 14

  
13 15
print __PACKAGE__.' is version: '.$VERSION.$/ if($ENV{'PDF_TABLE_DEBUG'});
......
548 550
    # Calc real column widths and expand table width if needed.
549 551
    my $calc_column_widths;
550 552
    ($calc_column_widths, $width) = CalcColumnWidths( $col_props, $width );
553
    my $num_cols = scalar @{ $calc_column_widths };
551 554

  
552 555
    # Lets draw what we have!
553 556
    my $row_index    = 0;
......
570 573
            # Check for safety reasons
571 574
            if( $bot_marg < 0 )
572 575
            {   # This warning should remain i think
573
                carp "!!! Warning: !!! Incorrect Table Geometry! start_h (${height}) is above start_y (${table_top_y}). Setting bottom margin to end of sheet!\n";
576
                #carp "!!! Warning: !!! Incorrect Table Geometry! start_h (${height}) is above start_y (${table_top_y}). Setting bottom margin to end of sheet!\n";
574 577
                $bot_marg = 0;
575 578
            }
576 579

  
......
592 595
            # Check for safety reasons
593 596
            if( $bot_marg < 0 )
594 597
            {   # This warning should remain i think
595
                carp "!!! Warning: !!! Incorrect Table Geometry! next_y or start_y (${next_y}) is above next_h or start_h (${next_h}). Setting bottom margin to end of sheet!\n";
598
                #carp "!!! Warning: !!! Incorrect Table Geometry! next_y or start_y (${next_y}) is above next_h or start_h (${next_h}). Setting bottom margin to end of sheet!\n";
596 599
                $bot_marg = 0;
597 600
            }
598 601

  
......
680 683
            my $cur_x        = $xbase;
681 684
            my $leftovers    = undef;   # Reference to text that is returned from textblock()
682 685
            my $do_leftovers = 0;
686
            my ($colspan, @vertical_lines);
683 687

  
684 688
            # Process every cell(column) from current row
685 689
            for( my $column_idx = 0; $column_idx < scalar( @$record); $column_idx++ )
......
732 736
                                       //  $col_props->[$column_idx]->{'default_text'}
733 737
                                       //  $default_text;
734 738

  
739
                my $this_width;
740
                if (!$first_row && $cell_props->[$row_index][$column_idx]->{colspan}) {
741
                    $colspan     = -1 == $cell_props->[$row_index][$column_idx]->{colspan}
742
                                 ? $num_cols - $column_idx
743
                                 : $cell_props->[$row_index][$column_idx]->{colspan};
744
                    my $last_idx = $column_idx + $colspan - 1;
745
                    $this_width  = sum @{ $calc_column_widths }[$column_idx..$last_idx];
746

  
747
                } else {
748
                    $this_width = $calc_column_widths->[$column_idx];
749
                }
750

  
735 751
                # If the content is wider than the specified width, we need to add the text as a text block
736 752
                if( $record->[$column_idx] !~ m/(.\n.)/ and
737 753
                    $record_widths->[$column_idx] and
738
                    $record_widths->[$column_idx] <= $calc_column_widths->[$column_idx]
754
                    $record_widths->[$column_idx] <= $this_width
739 755
                ){
740 756
                    my $space = $pad_left;
741 757
                    if ($justify eq 'right')
742 758
                    {
743
                        $space = $calc_column_widths->[$column_idx] -($txt->advancewidth($record->[$column_idx]) + $pad_right);
759
                        $space = $this_width -($txt->advancewidth($record->[$column_idx]) + $pad_right);
744 760
                    }
745 761
                    elsif ($justify eq 'center')
746 762
                    {
747
                        $space = ($calc_column_widths->[$column_idx] - $txt->advancewidth($record->[$column_idx])) / 2;
763
                        $space = ($this_width - $txt->advancewidth($record->[$column_idx])) / 2;
748 764
                    }
749 765
                    $txt->translate( $cur_x + $space, $text_start );
750 766
                    my %text_options;
......
759 775
                        $record->[$column_idx],
760 776
                        x        => $cur_x + $pad_left,
761 777
                        y        => $text_start,
762
                        w        => $calc_column_widths->[$column_idx] - $pad_left - $pad_right,
778
                        w        => $this_width - $pad_left - $pad_right,
763 779
                        h        => $cur_y - $bot_marg - $pad_top - $pad_bot,
764 780
                        align    => $justify,
765 781
                        lead     => $lead
......
793 809
                }
794 810

  
795 811
                $cur_x += $calc_column_widths->[$column_idx];
812

  
813
                push @vertical_lines, (!$colspan || (1 >= $colspan)) ? 1 : 0;
814
                $colspan-- if $colspan;
796 815
            }
797 816
            if( $do_leftovers )
798 817
            {
......
826 845
                    $gfx_bg->fill();
827 846
                }
828 847
                $cur_x += $calc_column_widths->[$column_idx];
848

  
849
                if ($line_w && $vertical_lines[$column_idx] && ($column_idx != (scalar(@{ $record }) - 1))) {
850
                    $gfx->move($cur_x, $cur_y);
851
                    $gfx->vline($cur_y - $row_h);
852
                    $gfx->fillcolor($border_color);
853
                }
829 854
            }#End of for(my $column_idx....
830 855

  
831 856
            $cur_y -= $current_row_height;
......
846 871
            {
847 872
                $gfx->move(  $xbase, $table_top_y);
848 873
                $gfx->vline( $cur_y );
849
                my $cur_x = $xbase;
850
                for( my $j = 0; $j < $columns_number; $j++ )
851
                {
852
                    $cur_x += $calc_column_widths->[$j];
853
                    $gfx->move(  $cur_x, $table_top_y );
854
                    $gfx->vline( $cur_y );
855
                }
874
                $gfx->move($xbase + sum(@{ $calc_column_widths }[0..$num_cols - 1]), $table_top_y);
875
                $gfx->vline( $cur_y );
856 876
            }
857 877

  
858 878
            # ACTUALLY draw all the lines

Auch abrufbar als: Unified diff