Exemple #1
0
 function &_layout_item($data_id, &$media, $offset, &$context, &$postponed_filter)
 {
     $this->_reset_page_at_rules();
     $this->reset_css();
     $font = $this->_cssState[0]->get_property(CSS_FONT);
     $font->units2pt(0);
     $this->_cssState[0]->set_property(CSS_FONT, $font);
     $data = $this->fetch($data_id);
     if (is_null($data)) {
         $dummy = null;
         return $dummy;
     }
     // Run raw data filters
     for ($i = 0; $i < count($this->data_filters); $i++) {
         $data = $this->data_filters[$i]->process($data);
     }
     // Parse the raw data
     $box =& $this->parser->process($data->get_content(), $this, $media);
     $this->_dispatcher->fire('after-parse', array('pipeline' => &$this, 'document' => &$box, 'media' => $media));
     /**
      * Run obligatory tree filters
      */
     /**
      * height-constraint processing filter;
      */
     $filter = new PreTreeFilterHeightConstraint();
     $filter->process($box, $data, $this);
     /**
      * Footnote support filter
      */
     $filter = new PreTreeFilterFootnotes();
     $filter->process($box, $data, $this);
     // Run pre-layout tree filters
     for ($i = 0, $size = count($this->pre_tree_filters); $i < $size; $i++) {
         $this->pre_tree_filters[$i]->process($box, $data, $this);
     }
     $context = new FlowContext();
     /**
      * Extract absolute/fixed positioned boxes
      */
     $positioned_filter = new PostTreeFilterPositioned($context);
     $positioned_filter->process($box, null, $this);
     $postponed_filter = new PostTreeFilterPostponed($this->output_driver);
     $postponed_filter->process($box, null, $this);
     $this->output_driver->prepare();
     // Force generation of custom characters for margin boxes
     for ($i = 0; $i <= 1; $i++) {
         $this->get_page_media(1, $media);
         $at_rules = $this->_getMarginBoxes($i, $media);
         $boxes = array();
         foreach ($at_rules as $at_rule) {
             $selector = $at_rule->getSelector();
             $boxes[$selector] =& BoxPageMargin::create($this, $at_rule);
         }
     }
     $status = $this->layout_engine->process($box, $media, $this->output_driver, $context);
     if (is_null($status)) {
         error_log('Pipeline::_process_item: layout routine failed');
         $dummy = null;
         return $dummy;
     }
     // Run post-layout tree filters
     for ($i = 0; $i < count($this->post_tree_filters); $i++) {
         $this->post_tree_filters[$i]->process($box);
     }
     return $box;
 }
 function &reflow_margin_boxes($page_no, &$media)
 {
     $at_rules = $this->_getMarginBoxes($page_no, $media);
     $boxes = array();
     foreach ($at_rules as $at_rule) {
         $selector = $at_rule->getSelector();
         $boxes[$selector] =& BoxPageMargin::create($this, $at_rule);
     }
     foreach ($boxes as $selector => $box) {
         $linebox_started = false;
         $previous_whitespace = false;
         $boxes[$selector]->reflow_whitespace($linebox_started, $previous_whitespace);
         $boxes[$selector]->reflow_text($this->output_driver);
     }
     foreach ($boxes as $selector => $box) {
         $boxes[$selector]->reflow($this->output_driver, $media, $boxes);
     }
     return $boxes;
 }