1: <?php
2:
3: /**
4: * Class PCompositeNode
5: * @version 1.0.0
6: * @author v.raskin
7: * @package vsword.node
8: */
9: class PCompositeNode extends EmptyCompositeNode implements INodeTextAdded, IBlockContext, IPNodeStyleAdded {
10:
11: /**
12: *
13: * @var PPrCompositeNode
14: */
15: protected $pPr;
16:
17:
18: public function __construct() {
19: $this->addNode($this->getPPr());
20: }
21:
22: /**
23: *
24: * @param IPNodeStyle $node
25: */
26: public function addPNodeStyle(IPNodeStyle $node) {
27: $this->getPPr()->addPNodeStyle($node);
28: }
29:
30: /**
31: *
32: * @return PCompositeNode
33: */
34: public function getPPr() {
35: if(is_null($this->pPr)) {
36: $this->pPr = new PPrCompositeNode();
37: }
38: return $this->pPr;
39: }
40:
41: /**
42: * Add some text to last node RCompositeNode
43: * @param string $text
44: * @return INode
45: */
46: public function addText($text) {
47: return $this->getLastRCompositeNode()->addText($text);
48: }
49:
50: /**
51: *
52: * @return \RCompositeNode
53: */
54: public function getLastRCompositeNode() {
55: $node = $this->getLastNode();
56: if(is_null($node) || !($node instanceof RCompositeNode)) {
57: $node = new RCompositeNode();
58: $this->addNode($node);
59: }
60: return $node;
61: }
62:
63: /**
64: *
65: */
66: public function clearTextStyle() {
67: $this->addNode(new RCompositeNode());
68: }
69:
70:
71:
72: protected function beforeRenderChildrensWord() {
73: $this->getPPr()->setStyleID($this->styleId);
74: return '<w:p>';
75: }
76:
77: protected function afterRenderChildrensWord() {
78: return '</w:p>';
79: }
80: }