コード例 #1
0
 function _getPagesTraverseTableRow(&$box, $penalty)
 {
     $locations = array();
     $cells = $box->getChildNodes();
     if (count($cells) > 0) {
         $locations[] = new PageBreakLocation($cells[0]->get_top_margin(), $penalty);
         $locations[] = new PageBreakLocation($cells[0]->get_bottom_margin(), $penalty);
     }
     $content_watermark = $cells[0]->get_top_margin() - $cells[0]->get_real_full_height();
     /**
      * Process row content
      */
     $inside_penalty = $penalty;
     if ($box->getCSSProperty(CSS_PAGE_BREAK_INSIDE) == PAGE_BREAK_AVOID) {
         $inside_penalty += PAGE_BREAK_INSIDE_AVOID_PENALTY;
     }
     $cells = $box->getChildNodes();
     $null = null;
     $ungrouped_row_locations = PageBreakLocator::_getPagesTraverseBlock($cells[0], $null, $null, $inside_penalty);
     $row_locations = PageBreakLocator::sort_locations($ungrouped_row_locations);
     for ($i = 1, $size = count($cells); $i < $size; $i++) {
         $ungrouped_child_locations = PageBreakLocator::_getPagesTraverseBlock($cells[$i], $null, $null, $inside_penalty);
         $child_locations = PageBreakLocator::sort_locations($ungrouped_child_locations);
         $current_cell_content_watermark = $cells[$i]->get_top_margin() - $cells[$i]->get_real_full_height();
         $new_row_locations = array();
         // Keep only locations available in all cells
         $current_row_location_index = 0;
         while ($current_row_location_index < count($row_locations)) {
             $current_row_location = $row_locations[$current_row_location_index];
             // Check if current row-wide location is below the current cell content;
             // in this case, accept it immediately
             if ($current_row_location->location < $current_cell_content_watermark) {
                 $new_row_locations[] = $current_row_location;
             } else {
                 // Match all row locations agains the current cell's
                 for ($current_child_location_index = 0, $child_locations_total = count($child_locations); $current_child_location_index < $child_locations_total; $current_child_location_index++) {
                     $current_child_location = $child_locations[$current_child_location_index];
                     if ($current_child_location->location == $current_row_location->location) {
                         $new_row_locations[] = new PageBreakLocation($current_child_location->location, max($current_child_location->penalty, $current_row_location->penalty));
                     }
                 }
             }
             $current_row_location_index++;
         }
         // Add locations available below content in previous cells
         for ($current_child_location_index = 0, $child_locations_total = count($child_locations); $current_child_location_index < $child_locations_total; $current_child_location_index++) {
             $current_child_location = $child_locations[$current_child_location_index];
             if ($current_child_location->location < $content_watermark) {
                 $new_row_locations[] = new PageBreakLocation($current_child_location->location, $current_child_location->penalty);
             }
         }
         $content_watermark = min($content_watermark, $cells[$i]->get_top_margin() - $cells[$i]->get_real_full_height());
         $row_locations = $new_row_locations;
     }
     $locations = array_merge($locations, $row_locations);
     return $locations;
 }
コード例 #2
0
 function _getPagesTraverseTableRow(&$box, $penalty)
 {
     $locations = array();
     $cells = $box->getChildNodes();
     if (count($cells) > 0) {
         $locations[] = new PageBreakLocation($cells[0]->get_top_margin(), $penalty);
         $locations[] = new PageBreakLocation($cells[0]->get_bottom_margin(), $penalty);
     }
     /**
      * Process row content
      */
     $inside_penalty = $penalty;
     if ($box->getCSSProperty(CSS_PAGE_BREAK_INSIDE) == PAGE_BREAK_AVOID) {
         $inside_penalty += PAGE_BREAK_INSIDE_AVOID_PENALTY;
     }
     $cells = $box->getChildNodes();
     $null = null;
     $ungrouped_row_locations = PageBreakLocator::_getPagesTraverseBlock($cells[0], $null, $null, $inside_penalty);
     $row_locations = PageBreakLocator::sort_locations($ungrouped_row_locations);
     for ($i = 1, $size = count($cells); $i < $size; $i++) {
         $ungrouped_child_locations = PageBreakLocator::_getPagesTraverseBlock($cells[$i], $null, $null, $inside_penalty);
         $child_locations = PageBreakLocator::sort_locations($ungrouped_child_locations);
         $new_row_locations = array();
         $current_row_location_index = 0;
         while ($current_row_location_index < count($row_locations)) {
             $current_row_location = $row_locations[$current_row_location_index];
             for ($current_child_location_index = 0, $child_locations_total = count($child_locations); $current_child_location_index < $child_locations_total; $current_child_location_index++) {
                 $current_child_location = $child_locations[$current_child_location_index];
                 if ($current_child_location->location == $current_row_location->location) {
                     $new_row_locations[] = new PageBreakLocation($current_child_location->location, max($current_child_location->penalty, $current_row_location->penalty));
                 }
             }
             $current_row_location_index++;
         }
         $row_locations = $new_row_locations;
     }
     $locations = array_merge($locations, $row_locations);
     return $locations;
 }