Projekt

Allgemein

Profil

« Zurück | Weiter » 

Revision d3897394

Von Moritz Bunkus vor fast 17 Jahren hinzugefügt

  • ID d3897394b6547332743ef7a0c984d391f872373c
  • Vorgänger 47eb3e45
  • Nachfolger 2a9b3298

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

Unterschiede anzeigen:

modules/override/PDF/Table.pm
5 5
use warnings;
6 6
our $VERSION = '0.9.3';
7 7

  
8
use List::Util qw(sum);
8 9

  
9 10
############################################################
10 11
#
......
205 206
# table - utility method to build multi-row, multicolumn tables
206 207
############################################################
207 208
sub table
208
	{
209
{
209 210
	my $self	= shift;
210 211
	my $pdf 	= shift;
211 212
	my $page 	= shift;
......
403 404
		# Calc real column widths and expand table width if needed.
404 405
		my $calc_column_widths; 
405 406
		($calc_column_widths, $width) = $self->CalcColumnWidths( $col_props, $width );
406

  
407
        my $num_cols     = scalar @{ $calc_column_widths };
407 408
		my $comp_cnt 	 = 1;
408 409
		$rows_counter	 = 0;
409 410

  
......
449 450
			# Check for safety reasons
450 451
			if( $bot_marg < 0 )
451 452
			{	# This warning should remain i think
452
				print "!!! Warning: !!! Incorrect Table Geometry! Setting bottom margin to end of sheet!\n";
453
# 				print "!!! Warning: !!! Incorrect Table Geometry! Setting bottom margin to end of sheet!\n";
453 454
				$bot_marg = 0;
454 455
			}
455 456

  
......
493 494
				my $leftovers 	 = undef;	# Reference to text that is returned from textblock()
494 495
				my $do_leftovers = 0;
495 496

  
497
                my ($colspan, @vertical_lines);
498

  
496 499
				# Process every column from current row
497 500
				for( my $j = 0; $j < scalar( @$record); $j++ ) 
498 501
				{
......
547 550
					}
548 551
					#TODO: Implement Center text align
549 552
					$col_props->[$j]->{justify} = $col_props->[$j]->{justify} || 'left';
553

  
554
                    my $this_width;
555
                    if (!$first_row && $cell_props->[$row_cnt]->[$j]->{colspan}) {
556
                        $colspan     = -1 == $cell_props->[$row_cnt]->[$j]->{colspan} ? $num_cols - $j : $cell_props->[$row_cnt]->[$j]->{colspan};
557
                        my $last_idx = $j + $colspan - 1;
558
                        $this_width  = sum @{ $calc_column_widths }[$j..$last_idx];
559

  
560
                    } else {
561
                        $this_width = $calc_column_widths->[$j];
562
                    }
563

  
550 564
					# If the content is wider than the specified width, we need to add the text as a text block
551
					if($record->[$j] !~ m#(.\n.)# and  $record_widths->[$j] and ($record_widths->[$j] < $calc_column_widths->[$j]))
565
					if($record->[$j] !~ m#(.\n.)# and  $record_widths->[$j] and ($record_widths->[$j] < $this_width))
552 566
					{
553 567
						my $space = $pad_left;
554 568
						if($col_props->[$j]->{justify} eq 'right')
555 569
						{
556
							$space = $calc_column_widths->[$j] -($txt->advancewidth($record->[$j]) + $pad_right);
570
							$space = $this_width -($txt->advancewidth($record->[$j]) + $pad_right);
557 571
						}
558 572
						$txt->translate( $cur_x + $space, $text_start );
559 573
						$txt->text( $record->[$j] );
......
566 580
						    $record->[$j],
567 581
						    x        => $cur_x + $pad_left,
568 582
						    y        => $text_start,
569
						    w        => $calc_column_widths->[$j] - $pad_w,
583
						    w        => $this_width - $pad_w,
570 584
							h		 => $cur_y - $bot_marg - $pad_top - $pad_bot,
571 585
							align    => $col_props->[$j]->{justify},
572 586
							lead	 => $lead
......
581 595
						}
582 596
					}
583 597
					$cur_x += $calc_column_widths->[$j];
598

  
599
                    push @vertical_lines, (!$colspan || (1 >= $colspan)) ? 1 : 0;
600
                    $colspan-- if ($colspan);
584 601
				}
585 602
				if( $do_leftovers )
586 603
				{
......
613 630
						}
614 631
						$gfx_bg->fill();
615 632
					}
633

  
616 634
					$cur_x += $calc_column_widths->[$j];
635

  
636
                    if ($line_w && $vertical_lines[$j] && ($j != (scalar(@{ $record }) - 1))) {
637
                        $gfx->move($cur_x, $cur_y);
638
                        $gfx->vline($cur_y - $row_h);
639
                        $gfx->fillcolor($border_color);
640
                    }
617 641
				}#End of for(my $j....
618 642

  
619 643
				$cur_y -= $row_h;
......
626 650
			}# End of while(scalar(@{$data}) and $cur_y-$row_h > $bot_marg)
627 651

  
628 652
			# Draw vertical lines
629
			$gfx->move(  $xbase, $table_top_y);
630
			$gfx->vline( $cur_y );
631
			my $cur_x = $xbase;
632
			for( my $j = 0; $j < scalar(@$record); $j++ )
633
			{
634
				$cur_x += $calc_column_widths->[$j];
635
				$gfx->move(  $cur_x, $table_top_y );
636
				$gfx->vline( $cur_y );
637

  
638
			}
639
			# ACTUALLY draw all the lines
640
			$gfx->fillcolor( $border_color);
641
			$gfx->stroke if $line_w;
653
            if ($line_w) {
654
                $gfx->move($xbase, $table_top_y);
655
                $gfx->vline($cur_y);
656
                $gfx->move($xbase + sum(@{ $calc_column_widths }[0..$num_cols - 1]), $table_top_y);
657
                $gfx->vline($cur_y);
658
                $gfx->fillcolor($border_color);
659
                $gfx->stroke();
660
            }
642 661
			$pg_cnt++;
643 662
		}# End of while(scalar(@{$data}))
644 663
	}# End of if(ref $data eq 'ARRAY')
......
656 675
	my $min_width 	= 0;
657 676

  
658 677
	my $calc_widths	;
659

  
660 678
	for(my $j = 0; $j < scalar( @$col_props); $j++)
661 679
	{
662 680
		$min_width += $col_props->[$j]->{min_w};

Auch abrufbar als: Unified diff