Fixed shared border definitions across different styles #267
This commit is contained in:
parent
bc40ec1830
commit
65a33577fd
@ -92,18 +92,17 @@ class StyleHelper extends AbstractStyleHelper
|
|||||||
$styleId = $style->getId();
|
$styleId = $style->getId();
|
||||||
|
|
||||||
if ($style->shouldApplyBorder()) {
|
if ($style->shouldApplyBorder()) {
|
||||||
|
|
||||||
$border = $style->getBorder();
|
$border = $style->getBorder();
|
||||||
$serializedBorder = serialize($border);
|
$serializedBorder = serialize($border);
|
||||||
|
|
||||||
if (!isset($this->registeredBorders[$serializedBorder])) {
|
if (isset($this->registeredBorders[$serializedBorder])) {
|
||||||
|
$this->styleIdToBorderMappingTable[$styleId] = $this->registeredBorders[$serializedBorder];
|
||||||
|
} else {
|
||||||
$this->registeredBorders[$serializedBorder] = $styleId;
|
$this->registeredBorders[$serializedBorder] = $styleId;
|
||||||
$this->styleIdToBorderMappingTable[$styleId] = count($this->registeredBorders);
|
$this->styleIdToBorderMappingTable[$styleId] = count($this->registeredBorders);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else { // If no border should be applied - the mapping is the default border: 0
|
||||||
$this->styleIdToBorderMappingTable[$styleId] = 0;
|
$this->styleIdToBorderMappingTable[$styleId] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -189,7 +188,6 @@ EOD;
|
|||||||
|
|
||||||
// The other fills are actually registered by setting a background color
|
// The other fills are actually registered by setting a background color
|
||||||
foreach ($this->registeredFills as $styleId) {
|
foreach ($this->registeredFills as $styleId) {
|
||||||
|
|
||||||
/** @var Style $style */
|
/** @var Style $style */
|
||||||
$style = $this->styleIdToStyleMappingTable[$styleId];
|
$style = $this->styleIdToStyleMappingTable[$styleId];
|
||||||
|
|
||||||
@ -222,7 +220,6 @@ EOD;
|
|||||||
$content .= '<border><left/><right/><top/><bottom/></border>';
|
$content .= '<border><left/><right/><top/><bottom/></border>';
|
||||||
|
|
||||||
foreach ($this->registeredBorders as $styleId) {
|
foreach ($this->registeredBorders as $styleId) {
|
||||||
|
|
||||||
/** @var \Box\Spout\Writer\Style\Style $style */
|
/** @var \Box\Spout\Writer\Style\Style $style */
|
||||||
$style = $this->styleIdToStyleMappingTable[$styleId];
|
$style = $this->styleIdToStyleMappingTable[$styleId];
|
||||||
$border = $style->getBorder();
|
$border = $style->getBorder();
|
||||||
@ -232,7 +229,6 @@ EOD;
|
|||||||
$sortOrder = ['left', 'right', 'top', 'bottom'];
|
$sortOrder = ['left', 'right', 'top', 'bottom'];
|
||||||
|
|
||||||
foreach ($sortOrder as $partName) {
|
foreach ($sortOrder as $partName) {
|
||||||
|
|
||||||
if ($border->hasPart($partName)) {
|
if ($border->hasPart($partName)) {
|
||||||
/** @var $part \Box\Spout\Writer\Style\BorderPart */
|
/** @var $part \Box\Spout\Writer\Style\BorderPart */
|
||||||
$part = $border->getPart($partName);
|
$part = $border->getPart($partName);
|
||||||
@ -275,7 +271,6 @@ EOD;
|
|||||||
$content = '<cellXfs count="' . count($registeredStyles) . '">';
|
$content = '<cellXfs count="' . count($registeredStyles) . '">';
|
||||||
|
|
||||||
foreach ($registeredStyles as $style) {
|
foreach ($registeredStyles as $style) {
|
||||||
|
|
||||||
$styleId = $style->getId();
|
$styleId = $style->getId();
|
||||||
$fillId = $this->styleIdToFillMappingTable[$styleId];
|
$fillId = $this->styleIdToFillMappingTable[$styleId];
|
||||||
$borderId = $this->styleIdToBorderMappingTable[$styleId];
|
$borderId = $this->styleIdToBorderMappingTable[$styleId];
|
||||||
|
@ -429,7 +429,7 @@ class WriterWithStyleTest extends \PHPUnit_Framework_TestCase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->assertEquals(2, $bordersApplied, 'Two borders have been applied');
|
$this->assertEquals(3, $bordersApplied, 'Three borders have been applied');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user