|
27 | 27 | use PhpOffice\PhpPowerpoint\Style\Color;
|
28 | 28 | use PhpOffice\PhpPowerpoint\Writer\ODPresentation;
|
29 | 29 | use PhpOffice\PhpPowerpoint\Tests\TestHelperDOCX;
|
| 30 | +use PhpOffice\Common\Drawing; |
| 31 | +use PhpOffice\PhpPowerpoint\Style\Fill; |
| 32 | +use PhpOffice\PhpPowerpoint\Style\PhpOffice\PhpPowerpoint\Style; |
30 | 33 |
|
31 | 34 | /**
|
32 | 35 | * Test class for PhpOffice\PhpPowerpoint\Writer\ODPresentation\Manifest
|
@@ -57,6 +60,23 @@ public function testDrawingWithHyperlink()
|
57 | 60 | $this->assertTrue($pres->elementExists($element, 'content.xml'));
|
58 | 61 | $this->assertEquals('https://github.com/PHPOffice/PHPPowerPoint/', $pres->getElementAttribute($element, 'xlink:href', 'content.xml'));
|
59 | 62 | }
|
| 63 | + |
| 64 | + public function testGroup() |
| 65 | + { |
| 66 | + $phpPowerPoint = new PhpPowerpoint(); |
| 67 | + $oSlide = $phpPowerPoint->getActiveSlide(); |
| 68 | + $oShapeGroup = $oSlide->createGroup(); |
| 69 | + $oShape = $oShapeGroup->createDrawingShape(); |
| 70 | + $oShape->setPath(PHPPOWERPOINT_TESTS_BASE_DIR.'/resources/images/PHPPowerPointLogo.png'); |
| 71 | + $oShape->getHyperlink()->setUrl('https://github.com/PHPOffice/PHPPowerPoint/'); |
| 72 | + |
| 73 | + $pres = TestHelperDOCX::getDocument($phpPowerPoint, 'ODPresentation'); |
| 74 | + |
| 75 | + $element = '/office:document-content/office:body/office:presentation/draw:page/draw:g'; |
| 76 | + $this->assertTrue($pres->elementExists($element, 'content.xml')); |
| 77 | + $element = '/office:document-content/office:body/office:presentation/draw:page/draw:g/draw:frame/office:event-listeners/presentation:event-listener'; |
| 78 | + $this->assertTrue($pres->elementExists($element, 'content.xml')); |
| 79 | + } |
60 | 80 |
|
61 | 81 | public function testList()
|
62 | 82 | {
|
@@ -171,7 +191,7 @@ public function testNote()
|
171 | 191 | $this->assertTrue($pres->elementExists($element, 'content.xml'));
|
172 | 192 | }
|
173 | 193 |
|
174 |
| - public function testRichtextAutoShrink() |
| 194 | + public function testRichTextAutoShrink() |
175 | 195 | {
|
176 | 196 | $phpPowerPoint = new PhpPowerpoint();
|
177 | 197 | $oSlide = $phpPowerPoint->getActiveSlide();
|
@@ -202,7 +222,7 @@ public function testRichtextAutoShrink()
|
202 | 222 | $this->assertEquals('true', $pres->getElementAttribute($element, 'draw:auto-grow-width', 'content.xml'));
|
203 | 223 | }
|
204 | 224 |
|
205 |
| - public function testRichtextBorder() |
| 225 | + public function testRichTextBorder() |
206 | 226 | {
|
207 | 227 | $phpPowerPoint = new PhpPowerpoint();
|
208 | 228 | $oSlide = $phpPowerPoint->getActiveSlide();
|
@@ -241,18 +261,49 @@ public function testRichtextBorder()
|
241 | 261 |
|
242 | 262 | public function testRichTextShadow()
|
243 | 263 | {
|
| 264 | + $randAlpha = rand(0,100); |
244 | 265 | $phpPowerPoint = new PhpPowerpoint();
|
245 | 266 | $oSlide = $phpPowerPoint->getActiveSlide();
|
246 | 267 | $oRichText = $oSlide->createRichTextShape();
|
247 | 268 | $oRichText->createTextRun('AAA');
|
248 |
| - $oRichText->getShadow()->setVisible(true)->setAlpha(75)->setBlurRadius(2)->setDirection(45); |
249 |
| - |
250 |
| - $pres = TestHelperDOCX::getDocument($phpPowerPoint, 'ODPresentation'); |
| 269 | + $oRichText->getShadow()->setVisible(true)->setAlpha($randAlpha)->setBlurRadius(2); |
251 | 270 |
|
252 | 271 | $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'gr1\']/style:graphic-properties';
|
253 |
| - $this->assertTrue($pres->elementExists($element, 'content.xml')); |
254 |
| - $this->assertEquals('visible', $pres->getElementAttribute($element, 'draw:shadow', 'content.xml')); |
255 |
| - $this->assertStringStartsWith('#', $pres->getElementAttribute($element, 'draw:shadow-color', 'content.xml')); |
| 272 | + for ($inc = 0 ; $inc <= 360 ; $inc += 45) { |
| 273 | + $randDistance = rand(0, 100); |
| 274 | + $oRichText->getShadow()->setDirection($inc)->setDistance($randDistance); |
| 275 | + $pres = TestHelperDOCX::getDocument($phpPowerPoint, 'ODPresentation'); |
| 276 | + $this->assertTrue($pres->elementExists($element, 'content.xml')); |
| 277 | + $this->assertEquals('visible', $pres->getElementAttribute($element, 'draw:shadow', 'content.xml')); |
| 278 | + $this->assertEquals('none', $pres->getElementAttribute($element, 'style:mirror', 'content.xml')); |
| 279 | + // Opacity |
| 280 | + $this->assertStringStartsWith((string)(100 - $randAlpha), $pres->getElementAttribute($element, 'draw:shadow-opacity', 'content.xml')); |
| 281 | + $this->assertStringEndsWith('%', $pres->getElementAttribute($element, 'draw:shadow-opacity', 'content.xml')); |
| 282 | + // Color |
| 283 | + $this->assertStringStartsWith('#', $pres->getElementAttribute($element, 'draw:shadow-color', 'content.xml')); |
| 284 | + // X |
| 285 | + $xOffset = $pres->getElementAttribute($element, 'draw:shadow-offset-x', 'content.xml'); |
| 286 | + if ($inc == 90 || $inc == 270) { |
| 287 | + $this->assertEquals('0cm', $xOffset); |
| 288 | + } else { |
| 289 | + if ($inc > 90 && $inc < 270) { |
| 290 | + $this->assertEquals('-'.Drawing::pixelsToCentimeters($randDistance).'cm', $xOffset); |
| 291 | + } else { |
| 292 | + $this->assertEquals(Drawing::pixelsToCentimeters($randDistance).'cm', $xOffset); |
| 293 | + } |
| 294 | + } |
| 295 | + // Y |
| 296 | + $yOffset = $pres->getElementAttribute($element, 'draw:shadow-offset-y', 'content.xml'); |
| 297 | + if ($inc == 0 || $inc == 180 || $inc == 360) { |
| 298 | + $this->assertEquals('0cm', $yOffset); |
| 299 | + } else { |
| 300 | + if (($inc > 0 && $inc < 180) || $inc == 360) { |
| 301 | + $this->assertEquals(Drawing::pixelsToCentimeters($randDistance).'cm', $yOffset); |
| 302 | + } else { |
| 303 | + $this->assertEquals('-'.Drawing::pixelsToCentimeters($randDistance).'cm', $yOffset); |
| 304 | + } |
| 305 | + } |
| 306 | + } |
256 | 307 | }
|
257 | 308 |
|
258 | 309 | public function testStyleAlignment()
|
@@ -344,6 +395,32 @@ public function testTable()
|
344 | 395 | $this->assertTrue($pres->elementExists($element, 'content.xml'));
|
345 | 396 | }
|
346 | 397 |
|
| 398 | + public function testTableCellFill() |
| 399 | + { |
| 400 | + $oColor = new Color(); |
| 401 | + $oColor->setRGB(Color::COLOR_BLUE); |
| 402 | + |
| 403 | + $oFill = new Fill(); |
| 404 | + $oFill->setFillType(Fill::FILL_SOLID)->setStartColor($oColor); |
| 405 | + |
| 406 | + $phpPowerPoint = new PhpPowerpoint(); |
| 407 | + $oSlide = $phpPowerPoint->getActiveSlide(); |
| 408 | + $oShape = $oSlide->createTableShape(); |
| 409 | + $oRow = $oShape->createRow(); |
| 410 | + $oCell = $oRow->getCell(); |
| 411 | + $oCell->setFill($oFill); |
| 412 | + |
| 413 | + $pres = TestHelperDOCX::getDocument($phpPowerPoint, 'ODPresentation'); |
| 414 | + $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'gr1r0c0\']'; |
| 415 | + $this->assertTrue($pres->elementExists($element, 'content.xml')); |
| 416 | + $this->assertEquals('table-cell', $pres->getElementAttribute($element, 'style:family', 'content.xml')); |
| 417 | + $element = '/office:document-content/office:automatic-styles/style:style[@style:name=\'gr1r0c0\']/style:graphic-properties'; |
| 418 | + $this->assertTrue($pres->elementExists($element, 'content.xml')); |
| 419 | + $this->assertEquals('solid', $pres->getElementAttribute($element, 'draw:fill', 'content.xml')); |
| 420 | + $this->assertStringStartsWith('#', $pres->getElementAttribute($element, 'draw:fill-color', 'content.xml')); |
| 421 | + $this->assertStringEndsWith($oColor->getRGB(), $pres->getElementAttribute($element, 'draw:fill-color', 'content.xml')); |
| 422 | + } |
| 423 | + |
347 | 424 | public function testTableWithColspan()
|
348 | 425 | {
|
349 | 426 | $value = rand(2, 100);
|
@@ -394,11 +471,14 @@ public function testTableWithText()
|
394 | 471 | $oRow = $oShape->createRow();
|
395 | 472 | $oCell = $oRow->getCell();
|
396 | 473 | $oCell->addText($oRun);
|
| 474 | + $oCell->createBreak(); |
397 | 475 |
|
398 | 476 | $pres = TestHelperDOCX::getDocument($phpPowerPoint, 'ODPresentation');
|
399 | 477 | $element = '/office:document-content/office:body/office:presentation/draw:page/draw:frame/table:table/table:table-row/table:table-cell/text:p/text:span';
|
400 | 478 | $this->assertTrue($pres->elementExists($element, 'content.xml'));
|
401 | 479 | $this->assertEquals('Test', $pres->getElement($element, 'content.xml')->nodeValue);
|
| 480 | + $element = '/office:document-content/office:body/office:presentation/draw:page/draw:frame/table:table/table:table-row/table:table-cell/text:p/text:span/text:line-break'; |
| 481 | + $this->assertTrue($pres->elementExists($element, 'content.xml')); |
402 | 482 | }
|
403 | 483 |
|
404 | 484 | public function testTransition()
|
|
0 commit comments