提交的内容

This commit is contained in:
2025-05-12 15:45:02 +08:00
parent 629c4750da
commit b48c692775
3043 changed files with 34732 additions and 60810 deletions

View File

@ -219,15 +219,18 @@ class BaseDrawing implements IComparable
public function setWorksheet(?Worksheet $worksheet = null, bool $overrideOld = false): self
{
if ($this->worksheet === null) {
// Add drawing to \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet
// Add drawing to Worksheet
if ($worksheet !== null) {
$this->worksheet = $worksheet;
$this->worksheet->getCell($this->coordinates);
$this->worksheet->getDrawingCollection()->append($this);
if (!($this instanceof Drawing && $this->getPath() === '')) {
$this->worksheet->getCell($this->coordinates);
}
$this->worksheet->getDrawingCollection()
->append($this);
}
} else {
if ($overrideOld) {
// Remove drawing from old \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet
// Remove drawing from old Worksheet
$iterator = $this->worksheet->getDrawingCollection()->getIterator();
while ($iterator->valid()) {
@ -239,10 +242,10 @@ class BaseDrawing implements IComparable
}
}
// Set new \PhpOffice\PhpSpreadsheet\Worksheet\Worksheet
// Set new Worksheet
$this->setWorksheet($worksheet);
} else {
throw new PhpSpreadsheetException('A Worksheet has already been assigned. Drawings can only exist on one \\PhpOffice\\PhpSpreadsheet\\Worksheet.');
throw new PhpSpreadsheetException('A Worksheet has already been assigned. Drawings can only exist on one Worksheet.');
}
}
@ -257,6 +260,11 @@ class BaseDrawing implements IComparable
public function setCoordinates(string $coordinates): self
{
$this->coordinates = $coordinates;
if ($this->worksheet !== null) {
if (!($this instanceof Drawing && $this->getPath() === '')) {
$this->worksheet->getCell($this->coordinates);
}
}
return $this;
}
@ -436,7 +444,7 @@ class BaseDrawing implements IComparable
return md5(
$this->name .
$this->description .
(($this->worksheet === null) ? '' : $this->worksheet->getHashCode()) .
(($this->worksheet === null) ? '' : (string) $this->worksheet->getHashInt()) .
$this->coordinates .
$this->offsetX .
$this->offsetY .