| 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';
 | 
        
           | 1441 | ariadna | 22 |   | 
        
           |  |  | 23 |     /** @var string document creator */
 | 
        
           |  |  | 24 |     protected string $creator = 'OpenSpout';
 | 
        
           | 1 | efrain | 25 |     private readonly Options $options;
 | 
        
           |  |  | 26 |   | 
        
           |  |  | 27 |     public function __construct(?Options $options = null)
 | 
        
           |  |  | 28 |     {
 | 
        
           |  |  | 29 |         $this->options = $options ?? new Options();
 | 
        
           |  |  | 30 |     }
 | 
        
           |  |  | 31 |   | 
        
           |  |  | 32 |     public function getOptions(): Options
 | 
        
           |  |  | 33 |     {
 | 
        
           |  |  | 34 |         return $this->options;
 | 
        
           |  |  | 35 |     }
 | 
        
           |  |  | 36 |   | 
        
           | 1441 | ariadna | 37 |     public function setCreator(string $creator): void
 | 
        
           |  |  | 38 |     {
 | 
        
           |  |  | 39 |         $this->creator = $creator;
 | 
        
           |  |  | 40 |     }
 | 
        
           |  |  | 41 |   | 
        
           | 1 | efrain | 42 |     protected function createWorkbookManager(): WorkbookManager
 | 
        
           |  |  | 43 |     {
 | 
        
           |  |  | 44 |         $workbook = new Workbook();
 | 
        
           |  |  | 45 |   | 
        
           |  |  | 46 |         $fileSystemHelper = new FileSystemHelper($this->options->getTempFolder(), new ZipHelper(), $this->creator);
 | 
        
           |  |  | 47 |         $fileSystemHelper->createBaseFilesAndFolders();
 | 
        
           |  |  | 48 |   | 
        
           |  |  | 49 |         $styleMerger = new StyleMerger();
 | 
        
           |  |  | 50 |         $styleManager = new StyleManager(new StyleRegistry($this->options->DEFAULT_ROW_STYLE), $this->options);
 | 
        
           |  |  | 51 |         $worksheetManager = new WorksheetManager($styleManager, $styleMerger, new ODS());
 | 
        
           |  |  | 52 |   | 
        
           |  |  | 53 |         return new WorkbookManager(
 | 
        
           |  |  | 54 |             $workbook,
 | 
        
           |  |  | 55 |             $this->options,
 | 
        
           |  |  | 56 |             $worksheetManager,
 | 
        
           |  |  | 57 |             $styleManager,
 | 
        
           |  |  | 58 |             $styleMerger,
 | 
        
           |  |  | 59 |             $fileSystemHelper
 | 
        
           |  |  | 60 |         );
 | 
        
           |  |  | 61 |     }
 | 
        
           |  |  | 62 | }
 |