1 | <?php |
||
12 | abstract class AbstractDecoratorWriter extends \PhpOffice\PhpPresentation\Writer\AbstractDecoratorWriter |
||
13 | { |
||
14 | /** |
||
15 | * Write relationship |
||
16 | * |
||
17 | * @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
||
18 | * @param int $pId Relationship ID. rId will be prepended! |
||
19 | * @param string $pType Relationship type |
||
20 | * @param string $pTarget Relationship target |
||
21 | * @param string $pTargetMode Relationship target mode |
||
22 | * @throws \Exception |
||
23 | */ |
||
24 | 113 | protected function writeRelationship(XMLWriter $objWriter, $pId = 1, $pType = '', $pTarget = '', $pTargetMode = '') |
|
45 | |||
46 | /** |
||
47 | * Write Border |
||
48 | * |
||
49 | * @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
||
50 | * @param \PhpOffice\PhpPresentation\Style\Border $pBorder Border |
||
51 | * @param string $pElementName Element name |
||
52 | * @throws \Exception |
||
53 | */ |
||
54 | 71 | protected function writeBorder(XMLWriter $objWriter, $pBorder, $pElementName = 'L') |
|
55 | { |
||
56 | 71 | if (!($pBorder instanceof Border)) { |
|
57 | return; |
||
58 | } |
||
59 | |||
60 | 71 | if ($pBorder->getLineStyle() == Border::LINE_NONE && $pElementName == '') { |
|
61 | 26 | return; |
|
62 | } |
||
63 | |||
64 | // Line style |
||
65 | 46 | $lineStyle = $pBorder->getLineStyle(); |
|
66 | 46 | if ($lineStyle == Border::LINE_NONE) { |
|
67 | 11 | $lineStyle = Border::LINE_SINGLE; |
|
68 | } |
||
69 | |||
70 | // Line width |
||
71 | 46 | $lineWidth = 12700 * $pBorder->getLineWidth(); |
|
72 | |||
73 | // a:ln $pElementName |
||
74 | 46 | $objWriter->startElement('a:ln' . $pElementName); |
|
75 | 46 | $objWriter->writeAttribute('w', $lineWidth); |
|
76 | 46 | $objWriter->writeAttribute('cap', 'flat'); |
|
77 | 46 | $objWriter->writeAttribute('cmpd', $lineStyle); |
|
78 | 46 | $objWriter->writeAttribute('algn', 'ctr'); |
|
79 | |||
80 | // Fill? |
||
81 | 46 | if ($pBorder->getLineStyle() == Border::LINE_NONE) { |
|
82 | // a:noFill |
||
83 | 11 | $objWriter->writeElement('a:noFill', null); |
|
84 | } else { |
||
85 | // a:solidFill |
||
86 | 46 | $objWriter->startElement('a:solidFill'); |
|
87 | 46 | $this->writeColor($objWriter, $pBorder->getColor()); |
|
88 | 46 | $objWriter->endElement(); |
|
89 | } |
||
90 | |||
91 | // Dash |
||
92 | 46 | $objWriter->startElement('a:prstDash'); |
|
93 | 46 | $objWriter->writeAttribute('val', $pBorder->getDashStyle()); |
|
94 | 46 | $objWriter->endElement(); |
|
95 | |||
96 | // a:round |
||
97 | 46 | $objWriter->writeElement('a:round', null); |
|
98 | |||
99 | // a:headEnd |
||
100 | 46 | $objWriter->startElement('a:headEnd'); |
|
101 | 46 | $objWriter->writeAttribute('type', 'none'); |
|
102 | 46 | $objWriter->writeAttribute('w', 'med'); |
|
103 | 46 | $objWriter->writeAttribute('len', 'med'); |
|
104 | 46 | $objWriter->endElement(); |
|
105 | |||
106 | // a:tailEnd |
||
107 | 46 | $objWriter->startElement('a:tailEnd'); |
|
108 | 46 | $objWriter->writeAttribute('type', 'none'); |
|
109 | 46 | $objWriter->writeAttribute('w', 'med'); |
|
110 | 46 | $objWriter->writeAttribute('len', 'med'); |
|
111 | 46 | $objWriter->endElement(); |
|
112 | |||
113 | 46 | $objWriter->endElement(); |
|
114 | 46 | } |
|
115 | |||
116 | /** |
||
117 | * @param XMLWriter $objWriter |
||
118 | * @param Color $color |
||
119 | * @param int|null $alpha |
||
120 | */ |
||
121 | 71 | protected function writeColor(XMLWriter $objWriter, Color $color, $alpha = null) |
|
138 | |||
139 | /** |
||
140 | * Write Fill |
||
141 | * |
||
142 | * @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
||
143 | * @param \PhpOffice\PhpPresentation\Style\Fill $pFill Fill style |
||
144 | * @throws \Exception |
||
145 | */ |
||
146 | 69 | protected function writeFill(XMLWriter $objWriter, $pFill) |
|
147 | { |
||
148 | 69 | if (! $pFill instanceof Fill) { |
|
149 | return; |
||
150 | } |
||
151 | |||
152 | // Is it a fill? |
||
153 | 69 | if ($pFill->getFillType() == Fill::FILL_NONE) { |
|
154 | 62 | $objWriter->writeElement('a:noFill'); |
|
155 | 62 | return; |
|
156 | } |
||
157 | |||
158 | // Is it a solid fill? |
||
159 | 16 | if ($pFill->getFillType() == Fill::FILL_SOLID) { |
|
160 | 11 | $this->writeSolidFill($objWriter, $pFill); |
|
161 | 11 | return; |
|
162 | } |
||
163 | |||
164 | // Check if this is a pattern type or gradient type |
||
165 | 6 | if ($pFill->getFillType() == Fill::FILL_GRADIENT_LINEAR || $pFill->getFillType() == Fill::FILL_GRADIENT_PATH) { |
|
166 | // Gradient fill |
||
167 | 5 | $this->writeGradientFill($objWriter, $pFill); |
|
168 | } else { |
||
169 | // Pattern fill |
||
170 | 1 | $this->writePatternFill($objWriter, $pFill); |
|
171 | } |
||
172 | 6 | } |
|
173 | |||
174 | /** |
||
175 | * Write Solid Fill |
||
176 | * |
||
177 | * @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
||
178 | * @param \PhpOffice\PhpPresentation\Style\Fill $pFill Fill style |
||
179 | * @throws \Exception |
||
180 | */ |
||
181 | 11 | protected function writeSolidFill(XMLWriter $objWriter, Fill $pFill) |
|
188 | |||
189 | /** |
||
190 | * Write Gradient Fill |
||
191 | * |
||
192 | * @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
||
193 | * @param \PhpOffice\PhpPresentation\Style\Fill $pFill Fill style |
||
194 | * @throws \Exception |
||
195 | */ |
||
196 | 5 | protected function writeGradientFill(XMLWriter $objWriter, Fill $pFill) |
|
225 | |||
226 | /** |
||
227 | * Write Pattern Fill |
||
228 | * |
||
229 | * @param \PhpOffice\Common\XMLWriter $objWriter XML Writer |
||
230 | * @param \PhpOffice\PhpPresentation\Style\Fill $pFill Fill style |
||
231 | * @throws \Exception |
||
232 | */ |
||
233 | 1 | protected function writePatternFill(XMLWriter $objWriter, Fill $pFill) |
|
254 | |||
255 | /** |
||
256 | * Write Outline |
||
257 | * @param XMLWriter $objWriter |
||
258 | * @param Outline $oOutline |
||
259 | */ |
||
260 | 28 | protected function writeOutline(XMLWriter $objWriter, $oOutline) |
|
282 | |||
283 | /** |
||
284 | * Determine absolute zip path |
||
285 | * |
||
286 | * @param string $path |
||
287 | * @return string |
||
288 | */ |
||
289 | protected function absoluteZipPath($path) |
||
310 | } |
||
311 |