설명 없음

TextBox.php 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /**
  3. * This file is part of PHPWord - A pure PHP library for reading and writing
  4. * word processing documents.
  5. *
  6. * PHPWord is free software distributed under the terms of the GNU Lesser
  7. * General Public License version 3 as published by the Free Software Foundation.
  8. *
  9. * For the full copyright and license information, please read the LICENSE
  10. * file that was distributed with this source code. For the full list of
  11. * contributors, visit https://github.com/PHPOffice/PHPWord/contributors.
  12. *
  13. * @link https://github.com/PHPOffice/PHPWord
  14. * @copyright 2010-2014 PHPWord contributors
  15. * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3
  16. */
  17. namespace PhpOffice\PhpWord\Writer\Word2007\Element;
  18. use PhpOffice\PhpWord\Writer\Word2007\Style\TextBox as TextBoxStyleWriter;
  19. /**
  20. * TextBox element writer
  21. *
  22. * @since 0.11.0
  23. */
  24. class TextBox extends Image
  25. {
  26. /**
  27. * Write element.
  28. *
  29. * @return void
  30. */
  31. public function write()
  32. {
  33. $xmlWriter = $this->getXmlWriter();
  34. $element = $this->getElement();
  35. if (!$element instanceof \PhpOffice\PhpWord\Element\TextBox) {
  36. return;
  37. }
  38. $style = $element->getStyle();
  39. $styleWriter = new TextBoxStyleWriter($xmlWriter, $style);
  40. if (!$this->withoutP) {
  41. $xmlWriter->startElement('w:p');
  42. $styleWriter->writeAlignment();
  43. }
  44. $xmlWriter->startElement('w:r');
  45. $xmlWriter->startElement('w:pict');
  46. $xmlWriter->startElement('v:shape');
  47. $xmlWriter->writeAttribute('type', '#_x0000_t0202');
  48. $styleWriter->write();
  49. $styleWriter->writeBorder();
  50. $xmlWriter->startElement('v:textbox');
  51. $styleWriter->writeInnerMargin();
  52. // TextBox content, serving as a container
  53. $xmlWriter->startElement('w:txbxContent');
  54. $containerWriter = new Container($xmlWriter, $element);
  55. $containerWriter->write();
  56. $xmlWriter->endElement(); // w:txbxContent
  57. $xmlWriter->endElement(); // v: textbox
  58. $xmlWriter->endElement(); // v:shape
  59. $xmlWriter->endElement(); // w:pict
  60. $xmlWriter->endElement(); // w:r
  61. $this->endElementP();
  62. }
  63. }