Xlsx Support Flipping of Image (#3801)

* Xlsx Support Flipping of Image

Fix #731. Opened over 5 years ago, probably the second oldest problem I've worked on. Images attached to an Xlsx spreadsheet can be rotated, which is supported by PhpSpreadsheet. They can also be flipped along their horizontal and/or vertical axes, and that has not been supported. This PR adds that support.

* Update CHANGELOG.md
This commit is contained in:
oleibman
2023-11-30 08:46:43 -08:00
committed by GitHub
parent 009e009811
commit 9fcfa4b7ec
6 changed files with 81 additions and 0 deletions
@@ -0,0 +1,38 @@
<?php
declare(strict_types=1);
namespace PhpOffice\PhpSpreadsheetTests\Reader\Xlsx;
use PhpOffice\PhpSpreadsheet\Reader\Xlsx;
use PhpOffice\PhpSpreadsheetTests\Functional\AbstractFunctional;
class Issue731Test extends AbstractFunctional
{
private static string $testbook = 'tests/data/Reader/XLSX/issue.731.xlsx';
public function testRotateAndFlipImages(): void
{
$reader = new Xlsx();
$spreadsheet = $reader->load(self::$testbook);
$reloadedSpreadsheet = $this->writeAndReload($spreadsheet, 'Xlsx');
$spreadsheet->disconnectWorksheets();
$reloadedSheet = $reloadedSpreadsheet->getActiveSheet();
$expected = [
[0, false, false],
[90, false, false],
[270, false, false],
[0, false, true],
[0, true, false],
[20, false, false],
[20, false, true],
[0, true, true],
];
$actual = [];
foreach ($reloadedSheet->getDrawingCollection() as $drawing) {
$actual[] = [$drawing->getRotation(), $drawing->getFlipHorizontal(), $drawing->getFlipVertical()];
}
self::assertSame($expected, $actual);
$reloadedSpreadsheet->disconnectWorksheets();
}
}