adds element with rtf code directly
(no converting will be made by PHPRtfLite)

@param   string               $code
@param   PHPRtfLite_Font      $font
@param   PHPRtfLite_ParFormat $parFormat
@return  PHPRtfLite_Element
423218
public function writeRtfCode($code, PHPRtfLite_Font $font = null, PHPRtfLite_ParFormat $parFormat = null)
    {
        $element = new PHPRtfLite_Element($this->_rtf, $code, $font, $parFormat);
        $element->setIsRtfCode();
        $this->_elements[] = $element;

        return $element;
    }
647490
public function addCustomRegexp($strRegexp, $varValue, \Widget $objWidget)
    {
        $arrFlags = explode('::', $strRegexp);

        switch ($arrFlags[0])
        {
            case 'bic':
                if (!Validator::isBic($varValue))
                {
                    $objWidget->addError(sprintf($GLOBALS['TL_LANG']['ERR']['bic'], $objWidget->label));
                }

                return true;
                break;
            case 'iban':
                if (!Validator::isIban($varValue))
                {
                    $objWidget->addError(sprintf($GLOBALS['TL_LANG']['ERR']['iban'], $objWidget->label));
                }

                return true;
                break;
            case 'price':
                if (!Validator::isPrice($varValue))
                {
                    $objWidget->addError(sprintf($GLOBALS['TL_LANG']['ERR']['price'], $objWidget->label));
                }

                return true;
                break;
            case 'customDate':

                if (empty($arrFlags[1]))
                {
                    return true;
                }

                if (!preg_match('~^' . \Date::getRegexp($arrFlags[1]) . '$~i', $varValue))
                {
                    $objWidget->addError(sprintf($GLOBALS['TL_LANG']['ERR']['date'], \Date::getInputFormat($arrFlags[1])));
                }
                else
                {
                    // Validate the date (see #5086)
                    try
                    {
                        new \Date($varValue, $arrFlags[1]);
                    } catch (\OutOfBoundsException $e)
                    {
                        $objWidget->addError(sprintf($GLOBALS['TL_LANG']['ERR']['invalidDate'], $varValue));
                    }
                }

                return true;
                break;
            case 'posfloat':
                if (strpos($varValue, ',') != false)
                {
                    $objWidget->addError($GLOBALS['TL_LANG']['ERR']['posFloat']['commaFound']);
                }

                if (!preg_match('/^\d+(?:\.\d+)?$/', $varValue))
                {
                    $objWidget->addError($GLOBALS['TL_LANG']['ERR']['posFloat']['noFloat']);
                }

                return true;
                break;
            case 'maxlength':

                if (empty($arrFlags[1]))
                {
                    return true;
                }

                $strString = preg_replace('/[\t\n\r]+/', ' ', $varValue);
                $strString = strip_tags($strString);
                $strString = \StringUtil::restoreBasicEntities($strString);
                $strString = \StringUtil::decodeEntities($strString);
                $strString = trim($strString);

                if (utf8_strlen($strString) > $arrFlags[1])
                {
                    $objWidget->addError(sprintf($GLOBALS['TL_LANG']['ERR']['maxlength'], $objWidget->label, $arrFlags[1]));
                }

                return true;
                break;
        }

        return false;
    }
938540
public function addOption(string $value, string $text) : FormElement
    {
        $this->options[$value] = $text;
        return $this;
    }
62621
public function addImage($src, $style = null) {
		$image = new PHPWord_Section_Image($src, $style);
		
		if(!is_null($image->getSource())) {
			$rID = PHPWord_Media::addSectionMediaElement($src, 'image');
			$image->setRelationId($rID);
			
			$this->_elementCollection[] = $image;
			return $image;
		} else {
			trigger_error('Source does not exist or unsupported image type.');
		}
	}
1252400
public function setStatusCode($code, $text = null)
    {
        $code = intval($code);
        if ($code < 100 || $code > 999)
        {
            throw new InvalidArgumentException('Status code must be from 100 to 999');
        }
        $this->status = $code;
        $this->statusText = $text;
        return $this;
    }
308221
public function tokenize($code, $filename = null)
    {
        if (function_exists('mb_internal_encoding') && ((int) ini_get('mbstring.func_overload')) & 2) {
            $encoding = mb_internal_encoding();
            mb_internal_encoding('ASCII');
        }

        $this->code = str_replace(array("\r\n", "\r"), "\n", $code);
        $this->source = '';
        $this->filename = $filename;
        $this->cursor = 0;
        $this->lineno = 1;
        $this->end = strlen($this->code);
        $this->tokens = array();
        $this->state = self::STATE_DATA;
        $this->states = array();
        $this->brackets = array();
        $this->position = -1;

        preg_match_all(self::REGEX_CHAR, $this->code, $this->positions, PREG_OFFSET_CAPTURE);

        while ($this->cursor < $this->end) {
            switch ($this->state) {
                case self::STATE_DATA:
                    $this->lexData();
                    break;

                case self::STATE_OUTPUT:
                    $this->lexOutput();
                    break;

                case self::STATE_DIRECTIVE:
                    $this->lexDirective();
                    break;
            }
        }

        if ($this->state != self::STATE_DATA) {
            $this->addCode(' ?>');
            $this->popState();
        }

        if (!empty($this->brackets)) {
            list($expect, $lineno) = array_pop($this->brackets);
            throw new SyntaxErrorException(sprintf('Unclosed "%s" at line %d in file %s', $expect, $lineno, $this->filename));
        }

        if (isset($encoding)) {
            mb_internal_encoding($encoding);
        }

        return new TokenStream(token_get_all($this->source));
    }
671512
public static function applyformatToText() {
    $args = func_get_args();
    $count = func_num_args();

    $text = $args[$count - 1];
    if ($count == 1) { return $text; }

    $mode_texts = array_slice($args, 0, $count - 1);

    return self::buildEscapeCodes($mode_texts).$text.self::buildEscapeCodes('plain');
  }
480492
public function addFootnote($noteText, PHPRtfLite_Font $font = null, PHPRtfLite_ParFormat $parFormat = null)
    {
        $footnote = new PHPRtfLite_Footnote($this->_rtf, $noteText, $font, $parFormat);
        $this->_elements[] = $footnote;
        return $footnote;
    }
229044
public Font getFont( int code )
  {
    Style s = _tokenStyles.get( new Integer( code ) );
    if( s == null )
    {
      s = getStyle( DEFAULT_STYLE );
    }
    return getFont( s );
  }
474337
public function render()
    {
        $stream = $this->_rtf->getWriter();

        if ($this instanceof PHPRtfLite_Table_Cell && $this->countElements() == 0) {
            $stream->write('{');
            $font = $this->getCellFont($this);
            if ($font) {
                $stream->write($font->getContent());
            }
            if ((!$this->isVerticalMerged() && !$this->isHorizontalMerged()) || $this->isVerticalMergedFirstInRange()) {
                $stream->write('{\~}');
            }
            $stream->write('}\intbl');
        }

        $lastKey = $this->countElements() - 1;

        foreach ($this->_elements as $key => $element) {
            if ($this instanceof PHPRtfLite_Table_Cell && !($element instanceof PHPRtfLite_Table)) {
                // table cell initialization
                $stream->write('\intbl\itap' . $this->getTable()->getNestDepth() . "\r\n");
                $stream->write($this->getCellAlignment());
            }

            if ($element instanceof PHPRtfLite_Element_Plain) {
                $element->render();
                continue;
            }

            $parFormat = null;
            if (!($element instanceof PHPRtfLite_Table)) {
                $parFormat = $element->getParFormat();
            }

            if ($parFormat) {
                $stream->write($this->_pard);
                if ($this instanceof PHPRtfLite_Table_Cell && $lastKey != $key) {
                    $stream->write('{');
                }
                $stream->write($parFormat->getContent());
            }

            $font = $this->getCellFont($element);
            if ($font) {
                $stream->write($font->getContent());
            }

            $element->render();

            if ($this->needToAddParagraphEnd($key)) {
                $stream->write('\par ');
            }

            if ($font) {
                $stream->write($font->getClosingContent());
            }

            if ($parFormat && $this instanceof PHPRtfLite_Table_Cell && $lastKey != $key) {
                $stream->write('}');
            }
        }
    }
498528
public static function builtInFormatCodeIndex($formatCode)
    {
        // Ensure built-in format codes are available
        self::fillBuiltInFormatCodes();

        // Lookup format code
        if (isset(self::$flippedBuiltInFormats[$formatCode])) {
            return self::$flippedBuiltInFormats[$formatCode];
        }

        return false;
    }
181151
public function addJsCode(string $code, bool $defer = false, $prepend = false, array $attrs = null, $target = self::TARGET_HEAD) {
		ArgUtils::valEnum($target, array(self::TARGET_HEAD, self::TARGET_BODY_START, self::TARGET_BODY_END));
		
		if ($target == self::TARGET_HEAD) {
			$target = self::HEAD_SCRIPT_KEY;
		}
		
		$attrs = array(/*'type' => 'text/javascript'*/);
		if ($defer) {
			$attrs['defer'] = 'defer';
		}
		
		$this->htmlProperties->push($target,
				new HtmlElement('script', $attrs, new Raw("\r\n" . $code . "\r\n" . "\r\n")),
				$prepend);
		
		return $this;
	}
236421
protected function makeCodeSpan($code) {
		if ($this->code_span_content_func) {
			$code = call_user_func($this->code_span_content_func, $code);
		} else {
			$code = htmlspecialchars(trim($code), ENT_NOQUOTES);
		}
		return $this->hashPart("<code>$code</code>");
	}
548531
public function addXfWriter($style, $isStyleXf = false)
	{
		$xfWriter = new PHPExcel_Writer_Excel5_Xf($style);
		$xfWriter->setIsStyleXf($isStyleXf);

		// Add the font if not already added
		$fontIndex = $this->_addFont($style->getFont());

		// Assign the font index to the xf record
		$xfWriter->setFontIndex($fontIndex);

		// Background colors, best to treat these after the font so black will come after white in custom palette
		$xfWriter->setFgColor($this->_addColor($style->getFill()->getStartColor()->getRGB()));
		$xfWriter->setBgColor($this->_addColor($style->getFill()->getEndColor()->getRGB()));
		$xfWriter->setBottomColor($this->_addColor($style->getBorders()->getBottom()->getColor()->getRGB()));
		$xfWriter->setTopColor($this->_addColor($style->getBorders()->getTop()->getColor()->getRGB()));
		$xfWriter->setRightColor($this->_addColor($style->getBorders()->getRight()->getColor()->getRGB()));
		$xfWriter->setLeftColor($this->_addColor($style->getBorders()->getLeft()->getColor()->getRGB()));
		$xfWriter->setDiagColor($this->_addColor($style->getBorders()->getDiagonal()->getColor()->getRGB()));

		// Add the number format if it is not a built-in one and not already added
		if ($style->getNumberFormat()->getBuiltInFormatCode() === false) {
			$numberFormatHashCode = $style->getNumberFormat()->getHashCode();

			if (isset($this->_addedNumberFormats[$numberFormatHashCode])) {
				$numberFormatIndex = $this->_addedNumberFormats[$numberFormatHashCode];
			} else {
				$numberFormatIndex = 164 + count($this->_numberFormats);
				$this->_numberFormats[$numberFormatIndex] = $style->getNumberFormat();
				$this->_addedNumberFormats[$numberFormatHashCode] = $numberFormatIndex;
			}
		} else {
			$numberFormatIndex = (int) $style->getNumberFormat()->getBuiltInFormatCode();
		}

		// Assign the number format index to xf record
		$xfWriter->setNumberFormatIndex($numberFormatIndex);

		$this->_xfWriters[] = $xfWriter;

		$xfIndex = count($this->_xfWriters) - 1;
		return $xfIndex;
	}
1339112
protected function mbRenderImageByGD($code, $encoding)
    {
        $image = imagecreatetruecolor($this->width, $this->height);

        $backColor = imagecolorallocate($image,
            (int)($this->backColor % 0x1000000 / 0x10000),
            (int)($this->backColor % 0x10000 / 0x100),
            $this->backColor % 0x100);
        imagefilledrectangle($image, 0, 0, $this->width, $this->height, $backColor);
        imagecolordeallocate($image, $backColor);

        if ($this->transparent) {
            imagecolortransparent($image, $backColor);
        }

        $foreColor = imagecolorallocate($image,
            (int)($this->foreColor % 0x1000000 / 0x10000),
            (int)($this->foreColor % 0x10000 / 0x100),
            $this->foreColor % 0x100);

        $length = mb_strlen($code, $encoding);
        $box = imagettfbbox(30, 0, $this->mbFontFile, $code);
        $w = $box[4] - $box[0] + $this->mbOffset * ($length - 1);
        $h = $box[1] - $box[5];
        if ($h <= 0) {
            $h = $w / $length;
        }
        $scale = min(($this->width - $this->padding * 2) / $w, ($this->height - $this->padding * 2) / $h);
        $x = 8;
        // font size and angle
        $fontSize = (int)(30 * $scale * 0.90);
        $angle = 0;
        // base line
        $yBottom = $this->height - $this->padding * 4;
        $yTop = (int)($h * $scale * 0.95) + $this->padding * 4;
        if ($yTop > $yBottom) {
            $yTop = $yBottom;
        }
        for ($i = 0; $i < $length; ++$i) {
            $letter = mb_substr($code, $i, 1, $encoding);
            $y = mt_rand($yTop, $yBottom);
            if (!$this->fixedAngle) {
                $angle = mt_rand(-15, 15);
            }
            $box = imagettftext($image, $fontSize, $angle, $x, $y, $foreColor, $this->mbFontFile, $letter);
            $x = $box[2] + $this->mbOffset;
        }

        imagecolordeallocate($image, $foreColor);

        ob_start();
        imagepng($image);
        imagedestroy($image);
        return ob_get_clean();
    }
1145568
public function addCheckbox(PHPRtfLite_Font $font = null, PHPRtfLite_ParFormat $parFormat = null)
    {
        $checkBox = new PHPRtfLite_FormField_Checkbox($this->_rtf, $font, $parFormat);
        $this->_elements[] = $checkBox;
        return $checkBox;
    }
1111091
public function setCode($code){
        if(!$this->setModified('code', $code)->isModified()) {
            return $this;
        }
        $this->code = $code;

        return $this;
    }