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