Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision 23c33932

Von Sven Schöling vor mehr als 5 Jahren hinzugefügt

  • ID 23c33932e999f3b18079995daf604228e2c5f8c2
  • Vorgänger 7cb1a2fe
  • Nachfolger 1417bbe8

ReportGenerator: Unterstützung für mehrzeilige und individuell festgelegte Tabellenköpfe/Spaltenüberschriften implementiert.

Reimplementiert den PDF/Table.pm Teil von 84ba8214f6f1e68de5fa317b8239a7888a4aac03

Unterschiede anzeigen:

modules/override/PDF/Table.pm
328 328
        max_word_length       => 1,
329 329
        cell_render_hook      => 1,
330 330
        default_text          => 1,
331
        num_header_rows       => 1,
331 332
    );
332 333
    foreach my $key (keys %arg)
333 334
    {
......
373 374
    #=====================================
374 375
    # Disable header row into the table
375 376
    my $header_props = undef;
376

  
377
    my @header_rows;
377 378
    # Check if the user enabled it ?
378 379
    if(defined $arg{'header_props'} and ref( $arg{'header_props'}) eq 'HASH')
379 380
    {
......
388 389
        $header_props->{'font_underline'} = $header_props->{'font_underline'} || $fnt_underline;
389 390
        $header_props->{'bg_color'      } = $header_props->{'bg_color'      } || '#FFFFAA';
390 391
        $header_props->{'justify'       } = $header_props->{'justify'       };
392
        $header_props->{num_header_rows } = $arg{num_header_rows } || 1;
391 393
    }
392

  
393
    my $header_row  = undef;
394 394
    #=====================================
395 395
    # Other Parameters check
396 396
    #=====================================
......
433 433
    }
434 434

  
435 435
    # Copy the header row if header is enabled
436
    @$header_row = $$data[0] if defined $header_props;
436
    if (defined $header_props) {
437
      map { push @header_rows, $$data[$_] } (0..$header_props->{num_header_rows} - 1);
438
    }
437 439
    # Determine column widths based on content
438 440

  
439 441
    #  an arrayref whose values are a hashref holding
......
444 446
    #  the actual widths of the column/row intersection
445 447
    my $row_col_widths = [];
446 448
    # An array ref with the widths of the header row
447
    my $header_row_props = [];
449
    my @header_row_props;
448 450

  
449 451
    # Scalars that hold sum of the maximum and minimum widths of all columns
450 452
    my ( $max_col_w  , $min_col_w   ) = ( 0,0 );
......
456 458

  
457 459
    for( my $row_idx = 0; $row_idx < scalar(@$data) ; $row_idx++ )
458 460
    {
461
        push @header_row_props, [] if $row_idx < $header_props->{num_header_rows};
462

  
459 463
        my $column_widths = []; #holds the width of each column
460 464
        # Init the height for this row
461 465
        $rows_height->[$row_idx] = 0;
......
544 548
        $row_col_widths->[$row_idx] = $column_widths;
545 549

  
546 550
        # Copy the calculated row properties of header row.
547
        @$header_row_props = @$column_widths if(!$row_idx and ref $header_props);
551
        if (ref $header_props && $row_idx < $header_props->{num_header_rows}) {
552
          push @header_row_props, [ @{ $column_widths } ];
553
        }
548 554
    }
549 555

  
550 556
    # Calc real column widths and expand table width if needed.
......
555 561
    # Lets draw what we have!
556 562
    my $row_index    = 0;
557 563
    # Store header row height for later use if headers have to be repeated
558
    my $header_row_height = $rows_height->[0];
564
    my @header_row_heights = @$rows_height[0 .. $header_props->{num_header_rows}-1];
559 565

  
560 566
    my ( $gfx, $gfx_bg, $background_color, $font_color, $bot_marg, $table_top_y, $text_start);
561 567

  
568
    my $remaining_header_rows = $header_props ? $header_props->{num_header_rows} : 0;
569

  
562 570
    # Each iteration adds a new page as neccessary
563 571
    while(scalar(@{$data}))
564 572
    {
......
601 609

  
602 610
            if( ref $header_props and $header_props->{'repeat'})
603 611
            {
604
                # Copy Header Data
605
                @$page_header = @$header_row;
606
                my $hrp ;
607
                @$hrp = @$header_row_props ;
608
                # Then prepend it to master data array
609
                unshift @$data, @$page_header;
610
                unshift @$row_col_widths, $hrp;
611
                unshift @$rows_height, $header_row_height;
612

  
613
                $first_row = 1; # Means YES
614
                $row_index--; # Rollback the row_index because a new header row has been added
612
                for my $idx (0 .. $header_props->{num_header_rows} - 1) {
613
                  unshift @$data,           [ @{ $header_rows[$idx]      } ];
614
                  unshift @$row_col_widths, [ @{ $header_row_props[$idx] } ];
615
                  unshift @$rows_height,    $header_row_heights[$idx];
616
                }
617
                $remaining_header_rows = $header_props->{num_header_rows};
618
                $first_row = 1;
615 619
            }
616 620
        }
617 621

  
......
695 699
                # look for font information for this cell
696 700
                my ($cell_font, $cell_font_size, $cell_font_color, $cell_font_underline, $justify);
697 701

  
698
                if( $first_row and ref $header_props)
702
                if( $remaining_header_rows and ref $header_props)
699 703
                {
700 704
                    $cell_font           = $header_props->{'font'};
701 705
                    $cell_font_size      = $header_props->{'font_size'};
......
737 741
                                       //  $default_text;
738 742

  
739 743
                my $this_width;
740
                if (!$first_row && $cell_props->[$row_index][$column_idx]->{colspan}) {
744
                if (!$remaining_header_rows && $cell_props->[$row_index][$column_idx]->{colspan}) {
741 745
                    $colspan     = -1 == $cell_props->[$row_index][$column_idx]->{colspan}
742 746
                                 ? $num_cols - $column_idx
743 747
                                 : $cell_props->[$row_index][$column_idx]->{colspan};
......
828 832
            {
829 833
                my $cell_bg_color;
830 834

  
831
                if( $first_row and ref $header_props)
835
                if( $remaining_header_rows and ref $header_props)
832 836
                {                                  #Compatibility                 Consistency with other props
833 837
                    $cell_bg_color = $header_props->{'bg_color'} || $header_props->{'background_color'};
834 838
                }
......
860 864
                $gfx->hline( $xbase + $width );
861 865
            }
862 866

  
863
            $row_index++ unless ( $do_leftovers );
864 867
            $first_row = 0;
868
            if ($remaining_header_rows) {
869
              $remaining_header_rows--;
870
            } else {
871
              $row_index++ unless $do_leftovers;
872
            }
865 873
        }# End of Row_Loop
866 874

  
867 875
        if ($gfx)

Auch abrufbar als: Unified diff