protected function _calculate_height() { $style = $this->_frame->get_style(); $height = $style->height; $cellmap = $this->_frame->get_cellmap(); $cellmap->assign_frame_heights(); $rows = $cellmap->get_rows(); // Determine our content height $content_height = 0; foreach ($rows as $r) { $content_height += $r["height"]; } $cb = $this->_frame->get_containing_block(); if (!($style->overflow === "visible" || $style->overflow === "hidden" && $height === "auto")) { // Only handle min/max height if the height is independent of the frame's content $min_height = $style->min_height; $max_height = $style->max_height; if (isset($cb["h"])) { $min_height = $style->length_in_pt($min_height, $cb["h"]); $max_height = $style->length_in_pt($max_height, $cb["h"]); } else { if (isset($cb["w"])) { if (mb_strpos($min_height, "%") !== false) { $min_height = 0; } else { $min_height = $style->length_in_pt($min_height, $cb["w"]); } if (mb_strpos($max_height, "%") !== false) { $max_height = "none"; } else { $max_height = $style->length_in_pt($max_height, $cb["w"]); } } } if ($max_height !== "none" && $min_height > $max_height) { list($max_height, $min_height) = array($min_height, $max_height); } if ($max_height !== "none" && $height > $max_height) { $height = $max_height; } if ($height < $min_height) { $height = $min_height; } } else { // Use the content height or the height value, whichever is greater if ($height !== "auto") { $height = $style->length_in_pt($height, $cb["h"]); if ($height <= $content_height) { $height = $content_height; } else { $cellmap->set_frame_heights($height, $content_height); } } else { $height = $content_height; } } return $height; }
function get_min_max_width() { if (!is_null($this->_min_max_cache)) { return $this->_min_max_cache; } $style = $this->_frame->get_style(); $this->_frame->normalise(); // Add the cells to the cellmap (this will calcluate column widths as // frames are added) $this->_frame->get_cellmap()->add_frame($this->_frame); // Find the min/max width of the table and sort the columns into // absolute/percent/auto arrays $this->_state = array(); $this->_state["min_width"] = 0; $this->_state["max_width"] = 0; $this->_state["percent_used"] = 0; $this->_state["absolute_used"] = 0; $this->_state["auto_min"] = 0; $this->_state["absolute"] = array(); $this->_state["percent"] = array(); $this->_state["auto"] = array(); $columns =& $this->_frame->get_cellmap()->get_columns(); foreach (array_keys($columns) as $i) { $this->_state["min_width"] += $columns[$i]["min-width"]; $this->_state["max_width"] += $columns[$i]["max-width"]; if ($columns[$i]["absolute"] > 0) { $this->_state["absolute"][] = $i; $this->_state["absolute_used"] += $columns[$i]["absolute"]; } else { if ($columns[$i]["percent"] > 0) { $this->_state["percent"][] = $i; $this->_state["percent_used"] += $columns[$i]["percent"]; } else { $this->_state["auto"][] = $i; $this->_state["auto_min"] += $columns[$i]["min-width"]; } } } // Account for margins & padding $dims = array($style->border_left_width, $style->border_right_width, $style->padding_left, $style->padding_right, $style->margin_left, $style->margin_right); if ($style->border_collapse !== "collapse") { list($dims[]) = $style->border_spacing; } $delta = $style->length_in_pt($dims, $this->_frame->get_containing_block("w")); $this->_state["min_width"] += $delta; $this->_state["max_width"] += $delta; return $this->_min_max_cache = array($this->_state["min_width"], $this->_state["max_width"], "min" => $this->_state["min_width"], "max" => $this->_state["max_width"]); }