1 |
efrain |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
declare(strict_types=1);
|
|
|
4 |
|
|
|
5 |
namespace OpenSpout\Writer\ODS;
|
|
|
6 |
|
|
|
7 |
use OpenSpout\Common\Helper\Escaper\ODS;
|
|
|
8 |
use OpenSpout\Writer\AbstractWriterMultiSheets;
|
|
|
9 |
use OpenSpout\Writer\Common\Entity\Workbook;
|
|
|
10 |
use OpenSpout\Writer\Common\Helper\ZipHelper;
|
|
|
11 |
use OpenSpout\Writer\Common\Manager\Style\StyleMerger;
|
|
|
12 |
use OpenSpout\Writer\ODS\Helper\FileSystemHelper;
|
|
|
13 |
use OpenSpout\Writer\ODS\Manager\Style\StyleManager;
|
|
|
14 |
use OpenSpout\Writer\ODS\Manager\Style\StyleRegistry;
|
|
|
15 |
use OpenSpout\Writer\ODS\Manager\WorkbookManager;
|
|
|
16 |
use OpenSpout\Writer\ODS\Manager\WorksheetManager;
|
|
|
17 |
|
|
|
18 |
final class Writer extends AbstractWriterMultiSheets
|
|
|
19 |
{
|
|
|
20 |
/** @var string Content-Type value for the header */
|
|
|
21 |
protected static string $headerContentType = 'application/vnd.oasis.opendocument.spreadsheet';
|
|
|
22 |
private readonly Options $options;
|
|
|
23 |
|
|
|
24 |
public function __construct(?Options $options = null)
|
|
|
25 |
{
|
|
|
26 |
$this->options = $options ?? new Options();
|
|
|
27 |
}
|
|
|
28 |
|
|
|
29 |
public function getOptions(): Options
|
|
|
30 |
{
|
|
|
31 |
return $this->options;
|
|
|
32 |
}
|
|
|
33 |
|
|
|
34 |
protected function createWorkbookManager(): WorkbookManager
|
|
|
35 |
{
|
|
|
36 |
$workbook = new Workbook();
|
|
|
37 |
|
|
|
38 |
$fileSystemHelper = new FileSystemHelper($this->options->getTempFolder(), new ZipHelper(), $this->creator);
|
|
|
39 |
$fileSystemHelper->createBaseFilesAndFolders();
|
|
|
40 |
|
|
|
41 |
$styleMerger = new StyleMerger();
|
|
|
42 |
$styleManager = new StyleManager(new StyleRegistry($this->options->DEFAULT_ROW_STYLE), $this->options);
|
|
|
43 |
$worksheetManager = new WorksheetManager($styleManager, $styleMerger, new ODS());
|
|
|
44 |
|
|
|
45 |
return new WorkbookManager(
|
|
|
46 |
$workbook,
|
|
|
47 |
$this->options,
|
|
|
48 |
$worksheetManager,
|
|
|
49 |
$styleManager,
|
|
|
50 |
$styleMerger,
|
|
|
51 |
$fileSystemHelper
|
|
|
52 |
);
|
|
|
53 |
}
|
|
|
54 |
}
|