コード例 #1
0
ファイル: Note.php プロジェクト: alipek/rtf
 /** Set the RTF text this Note object should represent. Overwrites any previously set RTF data. */
 function setRTF($rtf)
 {
     $this->raw_rtf = $rtf;
     $rtf = $this->stripOuterBraces($rtf);
     $tree = $this->convertBracesToArray($rtf);
     // find 'text' section (last element of tree array) and escape RTF tokens (brace lexer un-escapes them)
     $textSection = $tree[count($tree) - 1];
     $textSection = str_replace('{', '\\{', $textSection);
     $textSection = str_replace('}', '\\}', $textSection);
     $tree[count($tree) - 1] = $textSection;
     $sectionLexer = new JoshRibakoff_Note_SectionLexer();
     $sectionLexer->setInput($tree);
     $this->rtf_fonttable = $sectionLexer->fontTable();
     $this->rtf_colortable = $sectionLexer->colorTable();
     $this->rtf_text_pieces = $sectionLexer->textPieces();
     $this->rtf_text = $sectionLexer->text();
 }
コード例 #2
0
ファイル: SectionLexerTest.php プロジェクト: alipek/rtf
 function testShouldKeepEscapedCurlyBraces()
 {
     $lexer = new JoshRibakoff_Note_SectionLexer();
     $lexer->setInput(array('\\{\\}'));
     $textPieces = $lexer->textPieces();
     $this->assertEquals('\\{\\}', $textPieces[0]['rtf']);
     $text = $lexer->text();
     $this->assertEquals('\\{\\}', $text);
 }