Remove rowStyle reference and replace it by new RegisteredStyle class
This commit is contained in:
1 parent
c6f596c776
commit
8a17d6c71f
3 files changed
+66
-18
No files matched your search
@@ -14,6 +14,7 @@ use Box\Spout\Writer\Common\Creator\InternalEntityFactory;
|
||||
use Box\Spout\Writer\Common\Entity\Options;
|
||||
use Box\Spout\Writer\Common\Entity\Worksheet;
|
||||
use Box\Spout\Writer\Common\Helper\CellHelper;
|
||||
use Box\Spout\Writer\Common\Manager\RegisteredStyle;
|
||||
use Box\Spout\Writer\Common\Manager\RowManager;
|
||||
use Box\Spout\Writer\Common\Manager\Style\StyleMerger;
|
||||
use Box\Spout\Writer\Common\Manager\WorksheetManagerInterface;
|
||||
@@ -160,7 +161,12 @@ EOD;
|
||||
$rowXML = '<row r="' . $rowIndexOneBased . '" spans="1:' . $numCells . '">';
|
||||
|
||||
foreach ($row->getCells() as $columnIndexZeroBased => $cell) {
|
||||
$rowXML .= $this->applyStyleAndGetCellXML($cell, $rowStyle, $rowIndexOneBased, $columnIndexZeroBased);
|
||||
$registeredStyle = $this->applyStyleAndRegister($cell, $rowStyle);
|
||||
$cellStyle = $registeredStyle->getStyle();
|
||||
if ($registeredStyle->isRowStyle()) {
|
||||
$rowStyle = $cellStyle;
|
||||
}
|
||||
$rowXML .= $this->getCellXML($rowIndexOneBased, $columnIndexZeroBased, $cell, $cellStyle->getId());
|
||||
}
|
||||
|
||||
$rowXML .= '</row>';
|
||||
@@ -173,18 +179,16 @@ EOD;
|
||||
|
||||
/**
|
||||
* Applies styles to the given style, merging the cell's style with its row's style
|
||||
* Then builds and returns xml for the cell.
|
||||
*
|
||||
* @param Cell $cell
|
||||
* @param Style $rowStyle
|
||||
* @param int $rowIndexOneBased
|
||||
* @param int $columnIndexZeroBased
|
||||
*
|
||||
* @throws InvalidArgumentException If the given value cannot be processed
|
||||
* @return string
|
||||
* @return RegisteredStyle
|
||||
*/
|
||||
private function applyStyleAndGetCellXML(Cell $cell, Style &$rowStyle, $rowIndexOneBased, $columnIndexZeroBased)
|
||||
private function applyStyleAndRegister(Cell $cell, Style $rowStyle) : RegisteredStyle
|
||||
{
|
||||
$isRowStyle = false;
|
||||
if ($cell->getStyle()->isEmpty()) {
|
||||
$cell->setStyle($rowStyle);
|
||||
|
||||
@@ -194,7 +198,7 @@ EOD;
|
||||
$registeredStyle = $this->styleManager->registerStyle($managedStyle->getStyle());
|
||||
} else {
|
||||
$registeredStyle = $this->styleManager->registerStyle($rowStyle);
|
||||
$rowStyle = $registeredStyle;
|
||||
$isRowStyle = true;
|
||||
}
|
||||
} else {
|
||||
$mergedCellAndRowStyle = $this->styleMerger->merge($cell->getStyle(), $rowStyle);
|
||||
@@ -211,7 +215,7 @@ EOD;
|
||||
$registeredStyle = $this->styleManager->registerStyle($newCellStyle);
|
||||
}
|
||||
|
||||
return $this->getCellXML($rowIndexOneBased, $columnIndexZeroBased, $cell, $registeredStyle->getId());
|
||||
return new RegisteredStyle($registeredStyle, $isRowStyle);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user