Nav apraksta

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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\Style;
  18. use PhpOffice\PhpWord\Style\TextBox as TextBoxStyle;
  19. /**
  20. * TextBox style writer
  21. *
  22. * @since 0.11.0
  23. */
  24. class TextBox extends Frame
  25. {
  26. /**
  27. * Writer inner margin.
  28. *
  29. * @return void
  30. */
  31. public function writeInnerMargin()
  32. {
  33. $style = $this->getStyle();
  34. if (!$style instanceof TextBoxStyle || !$style->hasInnerMargins()) {
  35. return;
  36. }
  37. $xmlWriter = $this->getXmlWriter();
  38. $margins = implode(', ', $style->getInnerMargin());
  39. $xmlWriter->writeAttribute('inset', $margins);
  40. }
  41. /**
  42. * Writer border.
  43. *
  44. * @return void
  45. */
  46. public function writeBorder()
  47. {
  48. $style = $this->getStyle();
  49. if (!$style instanceof TextBoxStyle) {
  50. return;
  51. }
  52. $xmlWriter = $this->getXmlWriter();
  53. $xmlWriter->startElement('v:stroke');
  54. $xmlWriter->writeAttributeIf($style->getBorderSize() !== null, 'weight', $style->getBorderSize() . 'pt');
  55. $xmlWriter->writeAttributeIf($style->getBorderColor() !== null, 'color', $style->getBorderColor());
  56. $xmlWriter->endElement(); // v:stroke
  57. }
  58. }