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));
 }
Example #2
0
 function parse($value)
 {
     if ($value == 'inherit') {
         return CSS_PROPERTY_INHERIT;
     }
     // Remove spaces between color values in rgb() color definition; this will allow us to tread
     // this declaration as a single value
     $value = preg_replace("/\\s*,\\s*/", ",", $value);
     // Remove spaces before and after parens in rgb color definition
     $value = preg_replace("/rgb\\s*\\(\\s*(.*?)\\s*\\)/", 'rgb(\\1)', $value);
     $subvalues = explode(" ", $value);
     $border = CSS::getDefaultValue(CSS_BORDER);
     foreach ($subvalues as $subvalue) {
         $subvalue = trim(strtolower($subvalue));
         switch (CSSBorder::detect_border_value_type($subvalue)) {
             case BORDER_VALUE_COLOR:
                 $color_handler = CSS::get_handler(CSS_BORDER_COLOR);
                 $border_color = $color_handler->parse($subvalue);
                 $color_handler->setValue($border, $border_color);
                 break;
             case BORDER_VALUE_WIDTH:
                 $width_handler = CSS::get_handler(CSS_BORDER_WIDTH);
                 $border_width = $width_handler->parse($subvalue);
                 $width_handler->setValue($border, $border_width);
                 break;
             case BORDER_VALUE_STYLE:
                 $style_handler = CSS::get_handler(CSS_BORDER_STYLE);
                 $border_style = $style_handler->parse($subvalue);
                 $style_handler->setValue($border, $border_style);
                 break;
         }
     }
     return $border;
 }
Example #3
0
 function parse($value)
 {
     $font = CSS::getDefaultValue(CSS_FONT);
     if ($value === 'inherit') {
         $font->style = CSS_PROPERTY_INHERIT;
         $font->weight = CSS_PROPERTY_INHERIT;
         $font->size = CSS_PROPERTY_INHERIT;
         $font->family = CSS_PROPERTY_INHERIT;
         $font->line_height = CSS_PROPERTY_INHERIT;
         return $font;
     }
     // according to CSS 2.1 standard,
     // value of 'font' CSS property can be represented as follows:
     //   [ <'font-style'> || <'font-variant'> || <'font-weight'> ]? <'font-size'> [ / <'line-height'> ]? <'font-family'> ] |
     //   caption | icon | menu | message-box | small-caption | status-bar | inherit
     // Note that font-family value, unlike other values, can contain spaces (in this case it should be quoted)
     // Breaking value by spaces, we'll break such multi-word families.
     // Replace all white space sequences with only one space;
     // Remove spaces after commas; it will allow us
     // to split value correctly using look-backward expressions
     $value = preg_replace("/\\s+/", " ", $value);
     $value = preg_replace("/,\\s+/", ",", $value);
     $value = preg_replace("#\\s*/\\s*#", "/", $value);
     // Split value to subvalues by all whitespaces NOT preceeded by comma;
     // thus, we'll keep all alternative font-families together instead of breaking them.
     // Still we have a problem with multi-word family names.
     $subvalues = preg_split("/ /", $value);
     // Let's scan subvalues we've received and join values containing multiword family names
     $family_start = 0;
     $family_running = false;
     $family_double_quote = false;
     for ($i = 0, $num_subvalues = count($subvalues); $i < $num_subvalues; $i++) {
         $current_value = $subvalues[$i];
         if ($family_running) {
             $subvalues[$family_start] .= " " . $subvalues[$i];
             // Remove this subvalues from the subvalue list at all
             array_splice($subvalues, $i, 1);
             $num_subvalues--;
             $i--;
         }
         // Check if current subvalue contains beginning of multi-word family name
         // We can detect it by searching for single or double quote without pair
         if ($family_running && $family_double_quote && !preg_match('/^[^"]*("[^"]*")*[^"]*$/', $current_value)) {
             $family_running = false;
         } elseif ($family_running && !$family_double_quote && !preg_match("/^[^']*('[^']*')*[^']*\$/", $current_value)) {
             $family_running = false;
         } elseif (!$family_running && !preg_match("/^[^']*('[^']*')*[^']*\$/", $current_value)) {
             $family_running = true;
             $family_start = $i;
             $family_double_quote = false;
         } elseif (!$family_running && !preg_match('/^[^"]*("[^"]*")*[^"]*$/', $current_value)) {
             $family_running = true;
             $family_start = $i;
             $family_double_quote = true;
         }
     }
     // Now process subvalues one-by-one.
     foreach ($subvalues as $subvalue) {
         $subvalue = trim(strtolower($subvalue));
         $subvalue_type = detect_font_value_type($subvalue);
         switch ($subvalue_type) {
             case FONT_VALUE_STYLE:
                 $font->style = CSSFontStyle::parse($subvalue);
                 break;
             case FONT_VALUE_WEIGHT:
                 $font->weight = CSSFontWeight::parse($subvalue);
                 break;
             case FONT_VALUE_SIZE:
                 $size_subvalues = explode('/', $subvalue);
                 $font->size = CSSFontSize::parse($size_subvalues[0]);
                 if (isset($size_subvalues[1])) {
                     $handler =& CSS::get_handler(CSS_LINE_HEIGHT);
                     $font->line_height = $handler->parse($size_subvalues[1]);
                 }
                 break;
             case FONT_VALUE_FAMILY:
                 $font->family = CSSFontFamily::parse($subvalue);
                 break;
         }
     }
     return $font;
 }