1 | <?php |
||
14 | class StyleManager implements StyleManagerInterface |
||
15 | { |
||
16 | /** @var StyleRegistry Registry for all used styles */ |
||
17 | protected $styleRegistry; |
||
18 | |||
19 | /** |
||
20 | * @param StyleRegistry $styleRegistry |
||
21 | */ |
||
22 | 100 | public function __construct(StyleRegistry $styleRegistry) |
|
26 | |||
27 | /** |
||
28 | * Returns the default style |
||
29 | * |
||
30 | * @return Style Default style |
||
31 | */ |
||
32 | 34 | protected function getDefaultStyle() |
|
37 | |||
38 | /** |
||
39 | * Registers the given style as a used style. |
||
40 | * Duplicate styles won't be registered more than once. |
||
41 | * |
||
42 | * @param Style $style The style to be registered |
||
43 | * @return Style The registered style, updated with an internal ID. |
||
44 | */ |
||
45 | 64 | public function registerStyle($style) |
|
49 | |||
50 | |||
51 | /** |
||
52 | * Apply additional styles if the given row needs it. |
||
53 | * Typically, set "wrap text" if a cell contains a new line. |
||
54 | * |
||
55 | * @param Cell $cell |
||
56 | * @return Style |
||
57 | */ |
||
58 | 66 | public function applyExtraStylesIfNeeded(Cell $cell) |
|
63 | |||
64 | /** |
||
65 | * Set the "wrap text" option if a cell of the given row contains a new line. |
||
66 | * |
||
67 | * @NOTE: There is a bug on the Mac version of Excel (2011 and below) where new lines |
||
68 | * are ignored even when the "wrap text" option is set. This only occurs with |
||
69 | * inline strings (shared strings do work fine). |
||
70 | * A workaround would be to encode "\n" as "_x000D_" but it does not work |
||
71 | * on the Windows version of Excel... |
||
72 | * |
||
73 | * @param Cell $cell The cell the style should be applied to |
||
74 | * @return \Box\Spout\Writer\Common\Entity\Style\Style The eventually updated style |
||
75 | */ |
||
76 | 66 | protected function applyWrapTextIfCellContainsNewLine(Cell $cell) |
|
87 | } |
||
88 |