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