예제 #1
0
 function get_pages_traverse(&$box, $penalty)
 {
     if (!is_a($box, 'GenericContainerBox')) {
         return array();
     }
     $locations = array();
     for ($i = 0, $content_size = count($box->content); $i < $content_size; $i++) {
         $previous_child =& PageBreakLocator::get_previous($i, $box->content, $content_size);
         $next_child =& PageBreakLocator::get_next($i, $box->content, $content_size);
         $child =& $box->content[$i];
         /**
          * Note that page-break-xxx properties apply to block-level elements only
          */
         if (is_a($child, 'BRBox')) {
             // Do nothing
         } elseif ($child->isBlockLevel()) {
             $locations = array_merge($locations, PageBreakLocator::get_pages_traverse_block($child, $next_child, $previous_child, $penalty));
         } elseif (is_a($child, 'TableCellBox')) {
             $null = null;
             $child_locations = PageBreakLocator::get_pages_traverse_block($child, $null, $null, $penalty);
             $locations = array_merge($locations, $child_locations);
         } elseif (is_a($child, 'InlineBox')) {
             $more_before = 0;
             $more_after = 0;
             if (is_a($previous_child, 'BRBox')) {
                 $more_before = PageBreakLocator::get_more_before($i, $box->content, $content_size);
             }
             if (is_a($next_child, 'BRBox')) {
                 $more_after = PageBreakLocator::get_more_after($i, $box->content, $content_size);
             }
             $locations = array_merge($locations, PageBreakLocator::get_pages_traverse_inline($child, $penalty, $more_before, $more_after));
         } elseif (is_a($child, 'TableRowBox')) {
             $locations = array_merge($locations, PageBreakLocator::get_pages_traverse_table_row($child, $penalty));
         }
     }
     return $locations;
 }