See Release Notes
Long Term Support Release
Differences Between: [Versions 401 and 402] [Versions 401 and 403]
1 <?php 2 3 namespace PhpOffice\PhpSpreadsheet\Style\ConditionalFormatting; 4 5 use PhpOffice\PhpSpreadsheet\Style\Border; 6 use PhpOffice\PhpSpreadsheet\Style\Borders; 7 use PhpOffice\PhpSpreadsheet\Style\Fill; 8 use PhpOffice\PhpSpreadsheet\Style\Font; 9 use PhpOffice\PhpSpreadsheet\Style\Style; 10 11 class StyleMerger 12 { 13 /** 14 * @var Style 15 */ 16 protected $baseStyle; 17 18 public function __construct(Style $baseStyle) 19 { 20 $this->baseStyle = $baseStyle; 21 } 22 23 public function getStyle(): Style 24 { 25 return $this->baseStyle; 26 } 27 28 public function mergeStyle(Style $style): void 29 { 30 if ($style->getNumberFormat() !== null && $style->getNumberFormat()->getFormatCode() !== null) { 31 $this->baseStyle->getNumberFormat()->setFormatCode($style->getNumberFormat()->getFormatCode()); 32 } 33 34 if ($style->getFont() !== null) { 35 $this->mergeFontStyle($this->baseStyle->getFont(), $style->getFont()); 36 } 37 38 if ($style->getFill() !== null) { 39 $this->mergeFillStyle($this->baseStyle->getFill(), $style->getFill()); 40 } 41 42 if ($style->getBorders() !== null) { 43 $this->mergeBordersStyle($this->baseStyle->getBorders(), $style->getBorders()); 44 } 45 } 46 47 protected function mergeFontStyle(Font $baseFontStyle, Font $fontStyle): void 48 { 49 if ($fontStyle->getBold() !== null) { 50 $baseFontStyle->setBold($fontStyle->getBold()); 51 } 52 53 if ($fontStyle->getItalic() !== null) { 54 $baseFontStyle->setItalic($fontStyle->getItalic()); 55 } 56 57 if ($fontStyle->getStrikethrough() !== null) { 58 $baseFontStyle->setStrikethrough($fontStyle->getStrikethrough()); 59 } 60 61 if ($fontStyle->getUnderline() !== null) { 62 $baseFontStyle->setUnderline($fontStyle->getUnderline()); 63 } 64 65 if ($fontStyle->getColor() !== null && $fontStyle->getColor()->getARGB() !== null) { 66 $baseFontStyle->setColor($fontStyle->getColor()); 67 } 68 } 69 70 protected function mergeFillStyle(Fill $baseFillStyle, Fill $fillStyle): void 71 { 72 if ($fillStyle->getFillType() !== null) { 73 $baseFillStyle->setFillType($fillStyle->getFillType()); 74 } 75 76 if ($fillStyle->getRotation() !== null) { 77 $baseFillStyle->setRotation($fillStyle->getRotation()); 78 } 79 80 if ($fillStyle->getStartColor() !== null && $fillStyle->getStartColor()->getARGB() !== null) { 81 $baseFillStyle->setStartColor($fillStyle->getStartColor()); 82 } 83 84 if ($fillStyle->getEndColor() !== null && $fillStyle->getEndColor()->getARGB() !== null) { 85 $baseFillStyle->setEndColor($fillStyle->getEndColor()); 86 } 87 } 88 89 protected function mergeBordersStyle(Borders $baseBordersStyle, Borders $bordersStyle): void 90 { 91 if ($bordersStyle->getTop() !== null) { 92 $this->mergeBorderStyle($baseBordersStyle->getTop(), $bordersStyle->getTop()); 93 } 94 95 if ($bordersStyle->getBottom() !== null) { 96 $this->mergeBorderStyle($baseBordersStyle->getBottom(), $bordersStyle->getBottom()); 97 } 98 99 if ($bordersStyle->getLeft() !== null) { 100 $this->mergeBorderStyle($baseBordersStyle->getLeft(), $bordersStyle->getLeft()); 101 } 102 103 if ($bordersStyle->getRight() !== null) { 104 $this->mergeBorderStyle($baseBordersStyle->getRight(), $bordersStyle->getRight()); 105 } 106 } 107 108 protected function mergeBorderStyle(Border $baseBorderStyle, Border $borderStyle): void 109 { 110 if ($borderStyle->getBorderStyle() !== null) { 111 $baseBorderStyle->setBorderStyle($borderStyle->getBorderStyle()); 112 } 113 114 if ($borderStyle->getColor() !== null && $borderStyle->getColor()->getARGB() !== null) { 115 $baseBorderStyle->setColor($borderStyle->getColor()); 116 } 117 } 118 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body