Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
97.37% |
37 / 38 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| Ruby | |
97.37% |
37 / 38 |
|
0.00% |
0 / 1 |
2 | |
0.00% |
0 / 1 |
| write | |
97.37% |
37 / 38 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * This file is part of PHPWord - A pure PHP library for reading and writing |
| 5 | * word processing documents. |
| 6 | * |
| 7 | * PHPWord is free software distributed under the terms of the GNU Lesser |
| 8 | * General Public License version 3 as published by the Free Software Foundation. |
| 9 | * |
| 10 | * For the full copyright and license information, please read the LICENSE |
| 11 | * file that was distributed with this source code. For the full list of |
| 12 | * contributors, visit https://github.com/PHPOffice/PHPWord/contributors. |
| 13 | * |
| 14 | * @see https://github.com/PHPOffice/PHPWord |
| 15 | * |
| 16 | * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 |
| 17 | */ |
| 18 | |
| 19 | namespace PhpOffice\PhpWord\Writer\Word2007\Element; |
| 20 | |
| 21 | /** |
| 22 | * Ruby element writer. |
| 23 | */ |
| 24 | class Ruby extends AbstractElement |
| 25 | { |
| 26 | /** |
| 27 | * Write ruby element. |
| 28 | */ |
| 29 | public function write(): void |
| 30 | { |
| 31 | $xmlWriter = $this->getXmlWriter(); |
| 32 | $element = $this->getElement(); |
| 33 | if (!$element instanceof \PhpOffice\PhpWord\Element\Ruby) { |
| 34 | return; |
| 35 | } |
| 36 | /** @var \PhpOffice\PhpWord\Element\Ruby $element */ |
| 37 | $this->startElementP(); |
| 38 | |
| 39 | $xmlWriter->startElement('w:r'); |
| 40 | $xmlWriter->startElement('w:ruby'); |
| 41 | |
| 42 | // write properties |
| 43 | $xmlWriter->startElement('w:rubyPr'); |
| 44 | $properties = $element->getProperties(); |
| 45 | $xmlWriter->startElement('w:rubyAlign'); |
| 46 | $xmlWriter->writeAttribute('w:val', $properties->getAlignment()); |
| 47 | $xmlWriter->endElement(); // w:rubyAlign |
| 48 | $xmlWriter->startElement('w:hps'); |
| 49 | $xmlWriter->writeAttribute('w:val', $properties->getFontFaceSize()); |
| 50 | $xmlWriter->endElement(); // w:hps |
| 51 | $xmlWriter->startElement('w:hpsRaise'); |
| 52 | $xmlWriter->writeAttribute('w:val', $properties->getFontPointsAboveBaseText()); |
| 53 | $xmlWriter->endElement(); // w:hpsRaise |
| 54 | $xmlWriter->startElement('w:hpsBaseText'); |
| 55 | $xmlWriter->writeAttribute('w:val', $properties->getFontSizeForBaseText()); |
| 56 | $xmlWriter->endElement(); // w:hpsBaseText |
| 57 | $xmlWriter->startElement('w:lid'); |
| 58 | $xmlWriter->writeAttribute('w:val', $properties->getLanguageId()); |
| 59 | $xmlWriter->endElement(); // w:lid |
| 60 | |
| 61 | $xmlWriter->endElement(); // w:rubyPr |
| 62 | |
| 63 | // write ruby text |
| 64 | $xmlWriter->startElement('w:rt'); |
| 65 | $rubyTextRun = $element->getRubyTextRun(); |
| 66 | $textRunWriter = new TextRun($xmlWriter, $rubyTextRun, true); |
| 67 | $textRunWriter->write(); |
| 68 | $xmlWriter->endElement(); // w:rt |
| 69 | // write base text |
| 70 | $xmlWriter->startElement('w:rubyBase'); |
| 71 | $baseTextRun = $element->getBaseTextRun(); |
| 72 | $textRunWriter = new TextRun($xmlWriter, $baseTextRun, true); |
| 73 | $textRunWriter->write(); |
| 74 | $xmlWriter->endElement(); // w:rubyBase |
| 75 | |
| 76 | $xmlWriter->endElement(); // w:ruby |
| 77 | $xmlWriter->endElement(); // w:r |
| 78 | |
| 79 | $this->endElementP(); |
| 80 | } |
| 81 | } |