function parse($value)
 {
     if ($value == 'inherit') {
         return CSS_PROPERTY_INHERIT;
     }
     $value = trim(strtolower($value));
     switch (strtolower($value)) {
         case "xx-small":
             return Value::fromData(BASE_FONT_SIZE_PT * 3 / 5, UNIT_PT);
         case "x-small":
             return Value::fromData(BASE_FONT_SIZE_PT * 3 / 4, UNIT_PT);
         case "small":
             return Value::fromData(BASE_FONT_SIZE_PT * 8 / 9, UNIT_PT);
         case "medium":
             return Value::fromData(BASE_FONT_SIZE_PT, UNIT_PT);
         case "large":
             return Value::fromData(BASE_FONT_SIZE_PT * 6 / 5, UNIT_PT);
         case "x-large":
             return Value::fromData(BASE_FONT_SIZE_PT * 3 / 2, UNIT_PT);
         case "xx-large":
             return Value::fromData(BASE_FONT_SIZE_PT * 2 / 1, UNIT_PT);
     }
     switch (strtolower($value)) {
         case "larger":
             return Value::fromData(1.2, UNIT_EM);
         case "smaller":
             return Value::fromData(0.83, UNIT_EM);
             // 0.83 = 1/1.2
     }
     if (preg_match("/(\\d+\\.?\\d*)%/i", $value, $matches)) {
         return Value::fromData($matches[1] / 100, UNIT_EM);
     }
     return Value::fromString($value);
 }
 function BoxNoteCall(&$content, &$pipeline)
 {
     $this->GenericInlineBox();
     $this->_note_content =& $content;
     $this->copy_style($content);
     $this->put_height_constraint(new HCConstraint(null, null, null));
     /**
      * Prepare ::note-call box
      */
     $this->_note_call_box = InlineBox::create_from_text(CSSListStyleType::format_number(LST_DECIMAL, 99), WHITESPACE_NORMAL, $pipeline);
     $this->_note_call_box->copy_style($content);
     $this->_note_call_box->content[0]->copy_style($content);
     $font = $this->_note_call_box->content[0]->getCSSProperty(CSS_FONT);
     $font = $font->copy();
     $font->size->scale(0.75);
     $this->_note_call_box->content[0]->setCSSProperty(CSS_FONT, $font);
     $this->_note_call_box->content[0]->setCSSProperty(CSS_VERTICAL_ALIGN, VA_SUPER);
     $this->_note_call_box->content[0]->setCSSProperty(CSS_LINE_HEIGHT, CSS::getDefaultValue(CSS_LINE_HEIGHT));
     /**
      * Prepare ::marker box
      */
     $this->_note_marker_box = InlineBox::create_from_text(CSSListStyleType::format_number(LST_DECIMAL, 99), WHITESPACE_NORMAL, $pipeline);
     $this->_note_marker_box->copy_style($content);
     $this->_note_marker_box->content[0]->copy_style($content);
     $font = $this->_note_marker_box->content[0]->getCSSProperty(CSS_FONT);
     $font = $font->copy();
     $font->size->scale(0.5);
     $this->_note_marker_box->content[0]->setCSSProperty(CSS_FONT, $font);
     $margin = $this->_note_marker_box->content[0]->getCSSProperty(CSS_MARGIN);
     $margin = $margin->copy();
     $margin->right = Value::fromData(FOOTNOTE_MARKER_MARGIN, UNIT_PT);
     $this->_note_marker_box->content[0]->setCSSProperty(CSS_MARGIN, $margin);
     $this->_note_marker_box->content[0]->setCSSProperty(CSS_VERTICAL_ALIGN, VA_SUPER);
     $this->_note_marker_box->content[0]->setCSSProperty(CSS_LINE_HEIGHT, CSS::getDefaultValue(CSS_LINE_HEIGHT));
 }
 /**
  * Optimization: width/color fields of this class
  * never modified partially, so we could use one shared object 
  * as a default value
  */
 function EdgePDF()
 {
     static $default_width = null;
     if (is_null($default_width)) {
         $default_width =& Value::fromData(0, UNIT_PT);
     }
     static $default_color = null;
     if (is_null($default_color)) {
         $default_color =& new Color(array(0, 0, 0), true);
     }
     $this->width =& $default_width;
     $this->color =& $default_color;
     $this->style = BS_NONE;
     $this->_isDefaultColor = true;
 }
 function doInherit(&$state)
 {
     if ($state->get_propertyDefaultFlag(CSS_FONT_SIZE)) {
         $this->size = Value::fromData(1, UNIT_EM);
     }
     if ($this->style === CSS_PROPERTY_INHERIT) {
         $this->style = $state->getInheritedProperty(CSS_FONT_STYLE);
     }
     if ($this->weight === CSS_PROPERTY_INHERIT) {
         $this->weight = $state->getInheritedProperty(CSS_FONT_WEIGHT);
     }
     if ($this->size === CSS_PROPERTY_INHERIT) {
         $size = $state->getInheritedProperty(CSS_FONT_SIZE);
         $this->size = $size->copy();
     }
     if ($this->family === CSS_PROPERTY_INHERIT) {
         $this->family = $state->getInheritedProperty(CSS_FONT_FAMILY);
     }
     if ($this->line_height === CSS_PROPERTY_INHERIT) {
         $this->line_height = $state->getInheritedProperty(CSS_LINE_HEIGHT);
     }
 }
 function default_value()
 {
     return Value::fromData(1, UNIT_PX);
 }
Beispiel #6
0
 function &getInheritedProperty($code)
 {
     $handler =& CSS::get_handler($code);
     $size = count($this->_state);
     for ($i = 0; $i < $size; $i++) {
         $value =& $handler->get($this->_state[$i]);
         if ($value != CSS_PROPERTY_INHERIT) {
             return $value;
         }
         // Prevent taking  the font-size property; as,  according to CSS
         // standard,  'inherit'  should mean  calculated  value, we  use
         // '1em' instead,  forcing the script to  take parent calculated
         // value later
         if ($code == CSS_FONT_SIZE) {
             $value =& Value::fromData(1, UNIT_EM);
             return $value;
         }
     }
     $null = null;
     return $null;
 }
 function &create(&$root, &$pipeline)
 {
     // Create contents of this inline box
     if ($root->node_type() == XML_TEXT_NODE) {
         $css_state =& $pipeline->getCurrentCSSState();
         return InlineBox::create_from_text($root->content, $css_state->getProperty(CSS_WHITE_SPACE), $pipeline);
     } else {
         $box =& new InlineBox();
         $css_state =& $pipeline->getCurrentCSSState();
         $box->readCSS($css_state);
         // Initialize content
         $child = $root->first_child();
         while ($child) {
             $child_box =& create_pdf_box($child, $pipeline);
             $box->add_child($child_box);
             $child = $child->next_sibling();
         }
         // Add fake whitespace box with zero size for the anchor spans
         // We need this, as "reflow" functions will automatically remove empty inline boxes from the
         // document tree
         //
         if ($box->is_null()) {
             $css_state->pushState();
             $css_state->setProperty(CSS_FONT_SIZE, Value::fromData(0.01, UNIT_PT));
             $whitespace = WhitespaceBox::create($pipeline);
             $whitespace->readCSS($css_state);
             $box->add_child($whitespace);
             $css_state->popState();
         }
     }
     return $box;
 }
 function WidthConstraint()
 {
     $this->_min_width = Value::fromData(0, UNIT_PT);
 }
Beispiel #9
0
function attr_cellpadding_before(&$root, &$pipeline)
{
    $css_state =& $pipeline->get_current_css_state();
    $handler =& CSS::get_handler(CSS_HTML2PS_CELLPADDING);
    $handler->replace(Value::fromData((int) $root->get_attribute('cellpadding'), UNIT_PX), $css_state);
}
 function CSSBorderWidth(&$owner)
 {
     $this->CSSSubProperty($owner);
     $this->_defaultValue = new BorderWidth(Value::fromData(0, UNIT_PT), Value::fromData(0, UNIT_PT), Value::fromData(0, UNIT_PT), Value::fromData(0, UNIT_PT));
 }