Proyectos de Subversion Moodle

Rev

Rev 1 | | Comparar con el anterior | Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
 
3
declare(strict_types=1);
4
 
5
namespace OpenSpout\Writer\XLSX;
6
 
7
use OpenSpout\Common\Entity\Style\Style;
8
use OpenSpout\Writer\Common\AbstractOptions;
9
use OpenSpout\Writer\XLSX\Options\HeaderFooter;
10
use OpenSpout\Writer\XLSX\Options\PageMargin;
11
use OpenSpout\Writer\XLSX\Options\PageSetup;
1441 ariadna 12
use OpenSpout\Writer\XLSX\Options\WorkbookProtection;
1 efrain 13
 
14
final class Options extends AbstractOptions
15
{
16
    public const DEFAULT_FONT_SIZE = 12;
17
    public const DEFAULT_FONT_NAME = 'Calibri';
18
 
19
    public bool $SHOULD_USE_INLINE_STRINGS = true;
20
 
21
    /** @var MergeCell[] */
22
    private array $MERGE_CELLS = [];
23
 
24
    private ?PageMargin $pageMargin = null;
25
 
26
    private ?PageSetup $pageSetup = null;
27
 
28
    private ?HeaderFooter $headerFooter = null;
29
 
1441 ariadna 30
    private ?WorkbookProtection $workbookProtection = null;
31
 
32
    private Properties $properties;
33
 
1 efrain 34
    public function __construct()
35
    {
36
        parent::__construct();
37
 
38
        $defaultRowStyle = new Style();
39
        $defaultRowStyle->setFontSize(self::DEFAULT_FONT_SIZE);
40
        $defaultRowStyle->setFontName(self::DEFAULT_FONT_NAME);
41
 
42
        $this->DEFAULT_ROW_STYLE = $defaultRowStyle;
1441 ariadna 43
 
44
        $this->properties = new Properties();
1 efrain 45
    }
46
 
47
    /**
48
     * Row coordinates are indexed from 1, columns from 0 (A = 0),
49
     * so a merge B2:G2 looks like $writer->mergeCells(1, 2, 6, 2);.
50
     *
51
     * @param 0|positive-int $topLeftColumn
52
     * @param positive-int   $topLeftRow
53
     * @param 0|positive-int $bottomRightColumn
54
     * @param positive-int   $bottomRightRow
55
     * @param 0|positive-int $sheetIndex
56
     */
57
    public function mergeCells(
58
        int $topLeftColumn,
59
        int $topLeftRow,
60
        int $bottomRightColumn,
61
        int $bottomRightRow,
62
        int $sheetIndex = 0,
63
    ): void {
64
        $this->MERGE_CELLS[] = new MergeCell(
65
            $sheetIndex,
66
            $topLeftColumn,
67
            $topLeftRow,
68
            $bottomRightColumn,
69
            $bottomRightRow
70
        );
71
    }
72
 
73
    /**
74
     * @return MergeCell[]
75
     *
76
     * @internal
77
     */
78
    public function getMergeCells(): array
79
    {
80
        return $this->MERGE_CELLS;
81
    }
82
 
83
    public function setPageMargin(PageMargin $pageMargin): void
84
    {
85
        $this->pageMargin = $pageMargin;
86
    }
87
 
88
    public function getPageMargin(): ?PageMargin
89
    {
90
        return $this->pageMargin;
91
    }
92
 
93
    public function setPageSetup(PageSetup $pageSetup): void
94
    {
95
        $this->pageSetup = $pageSetup;
96
    }
97
 
98
    public function getPageSetup(): ?PageSetup
99
    {
100
        return $this->pageSetup;
101
    }
102
 
103
    public function setHeaderFooter(HeaderFooter $headerFooter): void
104
    {
105
        $this->headerFooter = $headerFooter;
106
    }
107
 
108
    public function getHeaderFooter(): ?HeaderFooter
109
    {
110
        return $this->headerFooter;
111
    }
1441 ariadna 112
 
113
    public function getWorkbookProtection(): ?WorkbookProtection
114
    {
115
        return $this->workbookProtection;
116
    }
117
 
118
    public function setWorkbookProtection(WorkbookProtection $workbookProtection): void
119
    {
120
        $this->workbookProtection = $workbookProtection;
121
    }
122
 
123
    public function getProperties(): Properties
124
    {
125
        return $this->properties;
126
    }
127
 
128
    public function setProperties(Properties $properties): void
129
    {
130
        $this->properties = $properties;
131
    }
1 efrain 132
}