Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision b6a82d77

Von Sven Schöling vor fast 9 Jahren hinzugefügt

  • ID b6a82d77ccccdc54fa33118c41c84fa6ba5cb660
  • Vorgänger 35cd4452
  • Nachfolger 39414125

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
319 319
        column_props          => 1,
320 320
        cell_props            => 1,
321 321
        max_word_length       => 1,
322
        num_header_rows       => 1,
322 323
    );
323 324
    foreach my $key (keys %arg) {
324 325
	croak "Error: Invalid setting key '$key' received." 
......
369 370
    #=====================================
370 371
    # Disable header row into the table
371 372
    my $header_props = undef;
372

  
373
    my @header_rows;
373 374
    # Check if the user enabled it ?
374 375
    if(defined $arg{'header_props'} and ref( $arg{'header_props'}) eq 'HASH')
375 376
    {
......
383 384
        $header_props->{'font_size'     } = $header_props->{'font_size'     } || $fnt_size + 2;
384 385
        $header_props->{'bg_color'      } = $header_props->{'bg_color'      } || '#FFFFAA';
385 386
        $header_props->{'justify'       } = $header_props->{'justify'       };
387
        $header_props->{num_header_rows } = $arg{num_header_rows } || 1;
386 388
    }
387

  
388
    my $header_row  = undef;
389 389
    #=====================================
390 390
    # Other Parameters check
391 391
    #=====================================
......
427 427
    }
428 428

  
429 429
    # Copy the header row if header is enabled
430
    @$header_row = $$data[0] if defined $header_props;
430
    if (defined $header_props) {
431
      map { push @header_rows, $$data[$_] } (0..$header_props->{num_header_rows} - 1);
432
    }
431 433
    # Determine column widths based on content
432 434

  
433 435
    #  an arrayref whose values are a hashref holding 
......
438 440
    #  the actual widths of the column/row intersection
439 441
    my $row_col_widths = [];
440 442
    # An array ref with the widths of the header row 
441
    my $header_row_props = [];
443
    my @header_row_props;
442 444
 
443 445
    # Scalars that hold sum of the maximum and minimum widths of all columns 
444 446
    my ( $max_col_w  , $min_col_w   ) = ( 0,0 );
......
446 448

  
447 449
    my $word_widths  = {};
448 450
    my $rows_height  = [];
449
    my $first_row    = 1;
450 451

  
451 452
    for( my $row_idx = 0; $row_idx < scalar(@$data) ; $row_idx++ )
452 453
    {
454
        push @header_row_props, [] if $row_idx < $header_props->{num_header_rows};
455

  
453 456
        my $column_widths = []; #holds the width of each column
454 457
        # Init the height for this row
455 458
        $rows_height->[$row_idx] = 0;
......
531 534
        $row_col_widths->[$row_idx] = $column_widths;
532 535
        
533 536
        # Copy the calculated row properties of header row. 
534
        @$header_row_props = @$column_widths if(!$row_idx and ref $header_props);
537
        if (ref $header_props && $row_idx < $header_props->{num_header_rows}) {
538
          push @header_row_props, [ @{ $column_widths } ];
539
        }
535 540
    }
536 541

  
537 542
    # Calc real column widths and expand table width if needed.
......
542 547
    # Lets draw what we have!
543 548
    my $row_index    = 0;
544 549
    # Store header row height for later use if headers have to be repeated
545
    my $header_row_height = $rows_height->[0];
550
    my @header_row_heights = @$rows_height[0 .. $header_props->{num_header_rows}-1];
546 551

  
547 552
    my ( $gfx, $gfx_bg, $background_color, $font_color, $bot_marg, $table_top_y, $text_start);
548 553

  
554
    my $remaining_header_rows = $header_props ? $header_props->{num_header_rows} : 0;
555

  
549 556
    # Each iteration adds a new page as neccessary
550 557
    while(scalar(@{$data}))
551 558
    {
......
572 579

  
573 580
            if( ref $header_props and $header_props->{'repeat'})
574 581
            {
575
                # Copy Header Data
576
                @$page_header = @$header_row;
577
                my $hrp ;
578
                @$hrp = @$header_row_props ;
579
                # Then prepend it to master data array
580
                unshift @$data, @$page_header;
581
                unshift @$row_col_widths, $hrp;
582
                unshift @$rows_height, $header_row_height;
583

  
584
                $first_row = 1; # Means YES
585
                $row_index--; # Rollback the row_index because a new header row has been added
582
                for my $idx (0 .. $header_props->{num_header_rows} - 1) {
583
                  unshift @$data,           [ @{ $header_rows[$idx]      } ];
584
                  unshift @$row_col_widths, [ @{ $header_row_props[$idx] } ];
585
                  unshift @$rows_height,    $header_row_heights[$idx];
586
                }
587
                $remaining_header_rows = $header_props->{num_header_rows};
586 588
            }
587 589
        }
588 590

  
......
678 680
                # look for font information for this cell
679 681
                my ($cell_font, $cell_font_size, $cell_font_color, $justify);
680 682
                                    
681
                if( $first_row and ref $header_props)
683
                if( $remaining_header_rows and ref $header_props)
682 684
                {   
683 685
                    $cell_font       = $header_props->{'font'};
684 686
                    $cell_font_size  = $header_props->{'font_size'};
......
709 711
                $txt->fillcolor($cell_font_color);
710 712

  
711 713
                my $this_width;
712
                if (!$first_row && $cell_props->[$row_index][$column_idx]->{colspan}) {
714
                if (!$remaining_header_rows && $cell_props->[$row_index][$column_idx]->{colspan}) {
713 715
                    $colspan     = -1 == $cell_props->[$row_index][$column_idx]->{colspan} 
714 716
                                 ? $num_cols - $column_idx
715 717
                                 : $cell_props->[$row_index][$column_idx]->{colspan};
......
783 785
            {
784 786
                my $cell_bg_color;
785 787
                                    
786
                if( $first_row and ref $header_props)
788
                if( $remaining_header_rows and ref $header_props)
787 789
                {                                  #Compatibility                 Consistency with other props    
788 790
                    $cell_bg_color = $header_props->{'bg_color'} || $header_props->{'background_color'};
789 791
                }
......
815 817
                $gfx->hline( $xbase + $width );
816 818
            }
817 819

  
818
            $row_index++ unless ( $do_leftovers );
819
            $first_row = 0;
820
            if ($remaining_header_rows) {
821
              $remaining_header_rows--;
822
            } else {
823
              $row_index++ unless $do_leftovers;
824
            }
820 825
        }# End of Row_Loop
821 826

  
822 827
        if ($gfx)

Auch abrufbar als: Unified diff