private function getCalculatedWidowsHeight(TcTable $table, $rows, callable $fn = null) {
        $count = count($rows);
        $limit = $count - $this->minWidowsOnPage;
        $h = 0;
        if ($this->minWidowsOnPage && $count && $limit >= 0) {
            for ($i = $count - 1; $i >= $limit; $i--) {
                // the userfunc has returned false everytime, so in the end, the
                // data array is empty. Return current height.
                if (!isset($rows[$i])) {
                    return $h;
                }
                $data = $fn ? $fn($table, $rows[$i], $i, true) : $rows[$i];
                // check row only if it's an array. It gives the possibility to
                // skip some rows with the user func
                if (is_array($data) || is_object($data)) {
                    $this->_widowsCalculatedHeight[$i] = $table->getCurrentRowHeight($data);
                    $h += $this->_widowsCalculatedHeight[$i];
                } else {
                    // adapt limit so the widow management behave the best it
                    // can
                    $limit--;
                }
            }
        }
        return $h;
    }