18
18
namespace PhpOffice \PhpPresentation \Writer ;
19
19
20
20
use DirectoryIterator ;
21
+ use PhpOffice \Common \Adapter \Zip \ZipArchiveAdapter ;
21
22
use PhpOffice \PhpPresentation \HashTable ;
22
23
use PhpOffice \PhpPresentation \PhpPresentation ;
23
24
use PhpOffice \PhpPresentation \Shape \AbstractDrawing ;
30
31
/**
31
32
* \PhpOffice\PhpPresentation\Writer\PowerPoint2007
32
33
*/
33
- class PowerPoint2007 implements WriterInterface
34
+ class PowerPoint2007 extends AbstractWriter implements WriterInterface
34
35
{
35
36
/**
36
37
* Private PhpPresentation
@@ -68,7 +69,7 @@ class PowerPoint2007 implements WriterInterface
68
69
protected $ layoutPack ;
69
70
70
71
/**
71
- * Create a new \PhpOffice\PhpPresentation\Writer\ PowerPoint2007
72
+ * Create a new PowerPoint2007 file
72
73
*
73
74
* @param PhpPresentation $pPhpPresentation
74
75
*/
@@ -85,6 +86,8 @@ public function __construct(PhpPresentation $pPhpPresentation = null)
85
86
86
87
// Set HashTable variables
87
88
$ this ->drawingHashTable = new HashTable ();
89
+
90
+ $ this ->setZipAdapter (new ZipArchiveAdapter ());
88
91
}
89
92
90
93
/**
@@ -113,14 +116,8 @@ public function save($pFilename)
113
116
// Create drawing dictionary
114
117
$ this ->drawingHashTable ->addFromSource ($ this ->allDrawings ());
115
118
116
- $ oZip = new \ZipArchive ();
117
-
118
- // Try opening the ZIP file
119
- if ($ oZip ->open ($ pFilename , \ZipArchive::OVERWRITE ) !== true ) {
120
- if ($ oZip ->open ($ pFilename , \ZipArchive::CREATE ) !== true ) {
121
- throw new \Exception ("Could not open " . $ pFilename . " for writing. " );
122
- }
123
- }
119
+ $ oZip = $ this ->getZipAdapter ();
120
+ $ oZip ->open ($ pFilename );
124
121
125
122
$ oDir = new DirectoryIterator (dirname (__FILE__ ).DIRECTORY_SEPARATOR .'PowerPoint2007 ' );
126
123
foreach ($ oDir as $ oFile ) {
@@ -142,9 +139,7 @@ public function save($pFilename)
142
139
}
143
140
144
141
// Close file
145
- if ($ oZip ->close () === false ) {
146
- throw new \Exception ("Could not close zip file $ pFilename. " );
147
- }
142
+ $ oZip ->close ();
148
143
149
144
// If a temporary file was used, copy it to the correct file stream
150
145
if ($ originalFilename != $ pFilename ) {
0 commit comments