Index: branches/5.1.x/core/units/pdf/pdf_table.php =================================================================== diff -u -N -r12127 -r12657 --- branches/5.1.x/core/units/pdf/pdf_table.php (.../pdf_table.php) (revision 12127) +++ branches/5.1.x/core/units/pdf/pdf_table.php (.../pdf_table.php) (revision 12657) @@ -1,6 +1,6 @@ GetCSSProperty('height'); if ($row_height == 'auto') { @@ -40,7 +42,7 @@ $row_height = $elem_height; } } - + foreach ($this->Children as $elem) { $vertical_align = $elem->GetCSSProperty('vertical-align'); $dim = $elem->GetBoxDimensions(); @@ -63,36 +65,36 @@ } $add_bottom = $row_height - $elem_height - $add_top; } - + $elem->SetCSSProperty('padding-top', $elem->GetCSSProperty('padding-top') + $add_top); $elem->SetCSSProperty('padding-bottom', $elem->GetCSSProperty('padding-bottom') + $add_bottom); } } - + } class kPDFTable extends kPDFElement { public $InitialMode = null; - + public $Table = array(); public $TableBuild = false; public $CurCol = 0; public $CurRow = 0; - + public $ColWidths = array(); - + function __construct($node, $helper) { parent::__construct($node, $helper); } - + function Init() { parent::Init(); $this->InitialMode = $this->Helper->DimensionsMode; $this->Helper->DimensionsMode = kPDFHelper::DM_SKIP; } - + function Closed() { $this->BuildTable($this); @@ -101,25 +103,25 @@ // $this->LayoutChildren(); $this->Helper->DimensionsMode = $this->InitialMode;*/ } - + function ComputeWidthAndMargins() { if (!$this->TableBuild || !$this->GetContainingBlock()->WidthComputed || $this->WidthComputed) return ; $this->ComputeCSSProperty('WIDTH', $this->CSSSpecifiedProperties['WIDTH']); - + if ($this->GetCSSProperty('table-layout') == 'fixed') { - $this->CalculateWidthsFixed(); + $this->CalculateWidthsFixed(); } if ($this->GetCSSProperty('table-layout') == 'auto') { - $this->CalculateWidthsAuto(); //CalculateWidthsAuto(); + $this->CalculateWidthsAuto(); //CalculateWidthsAuto(); } $this->WidthComputed = true; } - + function CalculateWidthsFixed() { if (count($this->Table) == 0) return ; - + $specified_width = 0; $specified_count = 0; $i = 0; @@ -145,10 +147,10 @@ $this->ColWidths[$i] = $auto_width; } } - + $this->SetColWidths($max_cols); } - + function SetColWidths($max_cols) { foreach ($this->Table as $row) { @@ -158,7 +160,7 @@ if ($i > $max_cols) { break; } - $cell_extra_width = + $cell_extra_width = $cell->GetCSSProperty('border-left-width') + $cell->GetCSSProperty('padding-left') + $cell->GetCSSProperty('padding-right') + @@ -182,7 +184,7 @@ } $this->SetCSSProperty('width', array_sum($this->ColWidths)); } - + function BuildTable($node) { $this->ColWidths = array(); @@ -204,16 +206,16 @@ } $this->TableBuild = true; } - + function CalculateWidthsAuto() { if (count($this->Table) == 0) return ; - + $min_col_widths = array(); $max_col_widths = array(); $specified_widths = array(); $percent_widths = array(); - + $row = 0; $max_cols = 0; foreach ($this->Table as $row) @@ -229,7 +231,7 @@ } $min_cw = $cell_w == 'auto' && !$percent_w ? $cell->MinContentWidth : max($cell_w, $cell->MinContentWidth); $max_cw = $cell->MaxContentWidth; - + if ($cell_w != 'auto' && is_numeric($cell_w)) { if ($cell_w < $min_cw) { $cell_w = $min_cw; @@ -238,7 +240,7 @@ $specified_widths[$col] = $cell_w; } } - + $colspan = isset($cell->Node->Attributes['COLSPAN']) ? $cell->Node->Attributes['COLSPAN'] : 1; if ($colspan == 1) { if (!isset($min_col_widths[$col]) || $min_cw > $min_col_widths[$col]) { @@ -255,30 +257,30 @@ $spans_min = array_slice($min_col_widths, $col-1, $colspan); $spans_max = array_slice($max_col_widths, $col-1, $colspan); $spans_percent = array_slice($percent_widths, $col-1, $colspan); - + $min_diff = ($min_cw - array_sum($spans_min)); if ($min_diff > 0) { for($i=$col; $i < $col+$colspan; $i++) { if (!isset($min_col_widths[$i])) $min_col_widths[$i] = 0; $min_col_widths[$i] += $min_diff/$colspan; } } - + $max_diff = ($max_cw - array_sum($spans_max)); if ($max_diff > 0) { for($i=$col; $i < $col+$colspan; $i++) { if (!isset($max_col_widths[$i])) $max_col_widths[$i] = 0; $max_col_widths[$i] += $max_diff/$colspan; } } - + $percent_diff = ($percent_w - array_sum($spans_percent)); if ($percent_diff > 0) { for($i=$col; $i < $col+$colspan; $i++) { $percent_widths[$i] += $percent_diff/$colspan; } } - + $col += $colspan-1; } } @@ -289,7 +291,7 @@ $table_min_width = array_sum($min_col_widths); $table_max_width = array_sum($max_col_widths) - $this->GetCSSProperty('border-left-width') - $this->GetCSSProperty('border-right-width'); $table_specifid_width = array_sum($specified_widths); - + $cb_width = $this->GetContainingBlock()->GetCSSProperty('width'); $computed_width = $this->ComputeCSSProperty('WIDTH', $this->GetCSSProperty('width')); if ($computed_width == 'auto') { @@ -304,7 +306,7 @@ } else { $width = max($table_min_width, $computed_width); - + // try to satisfy percent widths $reset_to_min = false; $percent_sum = 0; @@ -321,7 +323,7 @@ } } $distribute = $width - array_sum($min_col_widths); // recalc min width here, because of % changes - + $total_max = 0; for ($i=1; $i<=$max_cols; $i++) { if (isset($specified_widths[$i])) { @@ -333,7 +335,7 @@ $total_max += $max_col_widths[$i]; } } - + for ($i=1; $i<=$max_cols; $i++) { if (isset($this->ColWidths[$i])) { continue; @@ -343,7 +345,7 @@ $this->ColWidths[$i] = $min_col_widths[$i] + $add; } } - + $this->SetColWidths($max_cols); } } \ No newline at end of file