Skip to content

Commit c7a183f

Browse files
committed
#634 : Added ODFValidator
1 parent 7a70b57 commit c7a183f

File tree

9 files changed

+231
-117
lines changed

9 files changed

+231
-117
lines changed

.github/workflows/odfvalidator.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: ODFValidator
2+
on: [push, pull_request]
3+
jobs:
4+
php-cs-fixer:
5+
name: ODFValidator
6+
runs-on: ubuntu-latest
7+
steps:
8+
- name: Setup PHP
9+
uses: shivammathur/setup-php@v2
10+
with:
11+
php-version: '7.4'
12+
extensions: mbstring, intl, gd, xml, dom, json, fileinfo, curl, zip, iconv
13+
- uses: actions/checkout@v2
14+
15+
- name: Composer Install
16+
run: composer install --ansi --prefer-dist --no-interaction --no-progress
17+
18+
- name: Generate samples files
19+
run: composer run samples
20+
21+
- name: Download ODFValidator
22+
run: wget https://repo1.maven.org/maven2/org/odftoolkit/odfvalidator/0.12.0/odfvalidator-0.12.0-jar-with-dependencies.jar
23+
24+
# https://odftoolkit.org/conformance/ODFValidator.html#what-is-checked
25+
- name: Validate documents (ODF 1.2)
26+
run: java -jar odfvalidator-1.0.0-BETA1-jar-with-dependencies.jar -1.2 -r samples/results/

samples/Sample_03_Image.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535

3636
// Add a file drawing (GIF) to the slide
3737
$shape = new Drawing\File();
38-
$shape->setName('Image File')
38+
$shape
39+
->setName('Image File')
3940
->setDescription('Image File')
4041
->setPath(__DIR__ . '/resources/phppowerpoint_logo.gif')
4142
->setHeight(36)

src/PhpPresentation/DocumentProperties.php

+66-54
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,6 @@
1919

2020
namespace PhpOffice\PhpPresentation;
2121

22-
/**
23-
* \PhpOffice\PhpPresentation\DocumentProperties.
24-
*/
2522
class DocumentProperties
2623
{
2724
public const PROPERTY_TYPE_BOOLEAN = 'b';
@@ -36,14 +33,14 @@ class DocumentProperties
3633
*
3734
* @var string
3835
*/
39-
private $creator;
36+
private $creator = 'Unknown Creator';
4037

4138
/**
4239
* LastModifiedBy.
4340
*
4441
* @var string
4542
*/
46-
private $lastModifiedBy;
43+
private $lastModifiedBy = 'Unknown Creator';
4744

4845
/**
4946
* Created.
@@ -64,56 +61,56 @@ class DocumentProperties
6461
*
6562
* @var string
6663
*/
67-
private $title;
64+
private $title = 'Untitled Presentation';
6865

6966
/**
7067
* Description.
7168
*
7269
* @var string
7370
*/
74-
private $description;
71+
private $description = '';
7572

7673
/**
7774
* Subject.
7875
*
7976
* @var string
8077
*/
81-
private $subject;
78+
private $subject = '';
8279

8380
/**
8481
* Keywords.
8582
*
8683
* @var string
8784
*/
88-
private $keywords;
85+
private $keywords = '';
8986

9087
/**
9188
* Category.
9289
*
9390
* @var string
9491
*/
95-
private $category;
92+
private $category = '';
9693

9794
/**
9895
* Company.
9996
*
10097
* @var string
10198
*/
102-
private $company;
99+
private $company = 'Unknown Company';
103100

104101
/**
105102
* Revision.
106103
*
107104
* @var string
108105
*/
109-
private $revision;
106+
private $revision = '';
110107

111108
/**
112109
* Status.
113110
*
114111
* @var string
115112
*/
116-
private $status;
113+
private $status = '';
117114

118115
/**
119116
* Custom Properties.
@@ -125,29 +122,20 @@ class DocumentProperties
125122
/**
126123
* Create a new \PhpOffice\PhpPresentation\DocumentProperties.
127124
*/
125+
private $generator = '';
126+
128127
public function __construct()
129128
{
130-
// Initialise values
131-
$this->creator = 'Unknown Creator';
132-
$this->lastModifiedBy = $this->creator;
133129
$this->created = time();
134130
$this->modified = time();
135-
$this->title = 'Untitled Presentation';
136-
$this->subject = '';
137-
$this->description = '';
138-
$this->keywords = '';
139-
$this->category = '';
140-
$this->company = 'Microsoft Corporation';
141-
$this->revision = '';
142-
$this->status = '';
143131
}
144132

145133
/**
146134
* Get Creator.
147135
*
148136
* @return string
149137
*/
150-
public function getCreator()
138+
public function getCreator(): string
151139
{
152140
return $this->creator;
153141
}
@@ -157,9 +145,9 @@ public function getCreator()
157145
*
158146
* @param string $pValue
159147
*
160-
* @return DocumentProperties
148+
* @return self
161149
*/
162-
public function setCreator($pValue = '')
150+
public function setCreator(string $pValue = ''): self
163151
{
164152
$this->creator = $pValue;
165153

@@ -171,7 +159,7 @@ public function setCreator($pValue = '')
171159
*
172160
* @return string
173161
*/
174-
public function getLastModifiedBy()
162+
public function getLastModifiedBy(): string
175163
{
176164
return $this->lastModifiedBy;
177165
}
@@ -181,9 +169,9 @@ public function getLastModifiedBy()
181169
*
182170
* @param string $pValue
183171
*
184-
* @return DocumentProperties
172+
* @return self
185173
*/
186-
public function setLastModifiedBy($pValue = '')
174+
public function setLastModifiedBy(string $pValue = ''): self
187175
{
188176
$this->lastModifiedBy = $pValue;
189177

@@ -195,7 +183,7 @@ public function setLastModifiedBy($pValue = '')
195183
*
196184
* @return int
197185
*/
198-
public function getCreated()
186+
public function getCreated(): int
199187
{
200188
return $this->created;
201189
}
@@ -205,9 +193,9 @@ public function getCreated()
205193
*
206194
* @param int $pValue
207195
*
208-
* @return DocumentProperties
196+
* @return self
209197
*/
210-
public function setCreated($pValue = null)
198+
public function setCreated(int $pValue = null): self
211199
{
212200
if (null === $pValue) {
213201
$pValue = time();
@@ -222,7 +210,7 @@ public function setCreated($pValue = null)
222210
*
223211
* @return int
224212
*/
225-
public function getModified()
213+
public function getModified(): int
226214
{
227215
return $this->modified;
228216
}
@@ -232,9 +220,9 @@ public function getModified()
232220
*
233221
* @param int $pValue
234222
*
235-
* @return DocumentProperties
223+
* @return self
236224
*/
237-
public function setModified($pValue = null)
225+
public function setModified(int $pValue = null): self
238226
{
239227
if (null === $pValue) {
240228
$pValue = time();
@@ -249,7 +237,7 @@ public function setModified($pValue = null)
249237
*
250238
* @return string
251239
*/
252-
public function getTitle()
240+
public function getTitle(): string
253241
{
254242
return $this->title;
255243
}
@@ -259,9 +247,9 @@ public function getTitle()
259247
*
260248
* @param string $pValue
261249
*
262-
* @return DocumentProperties
250+
* @return self
263251
*/
264-
public function setTitle($pValue = '')
252+
public function setTitle(string $pValue = ''): self
265253
{
266254
$this->title = $pValue;
267255

@@ -273,7 +261,7 @@ public function setTitle($pValue = '')
273261
*
274262
* @return string
275263
*/
276-
public function getDescription()
264+
public function getDescription(): string
277265
{
278266
return $this->description;
279267
}
@@ -283,9 +271,9 @@ public function getDescription()
283271
*
284272
* @param string $pValue
285273
*
286-
* @return DocumentProperties
274+
* @return self
287275
*/
288-
public function setDescription($pValue = '')
276+
public function setDescription(string $pValue = ''): self
289277
{
290278
$this->description = $pValue;
291279

@@ -297,7 +285,7 @@ public function setDescription($pValue = '')
297285
*
298286
* @return string
299287
*/
300-
public function getSubject()
288+
public function getSubject(): string
301289
{
302290
return $this->subject;
303291
}
@@ -307,9 +295,9 @@ public function getSubject()
307295
*
308296
* @param string $pValue
309297
*
310-
* @return DocumentProperties
298+
* @return self
311299
*/
312-
public function setSubject($pValue = '')
300+
public function setSubject(string $pValue = ''): self
313301
{
314302
$this->subject = $pValue;
315303

@@ -321,7 +309,7 @@ public function setSubject($pValue = '')
321309
*
322310
* @return string
323311
*/
324-
public function getKeywords()
312+
public function getKeywords(): string
325313
{
326314
return $this->keywords;
327315
}
@@ -331,9 +319,9 @@ public function getKeywords()
331319
*
332320
* @param string $pValue
333321
*
334-
* @return DocumentProperties
322+
* @return self
335323
*/
336-
public function setKeywords($pValue = '')
324+
public function setKeywords(string $pValue = ''): self
337325
{
338326
$this->keywords = $pValue;
339327

@@ -345,7 +333,7 @@ public function setKeywords($pValue = '')
345333
*
346334
* @return string
347335
*/
348-
public function getCategory()
336+
public function getCategory(): string
349337
{
350338
return $this->category;
351339
}
@@ -355,9 +343,9 @@ public function getCategory()
355343
*
356344
* @param string $pValue
357345
*
358-
* @return DocumentProperties
346+
* @return self
359347
*/
360-
public function setCategory($pValue = '')
348+
public function setCategory(string $pValue = ''): self
361349
{
362350
$this->category = $pValue;
363351

@@ -369,7 +357,7 @@ public function setCategory($pValue = '')
369357
*
370358
* @return string
371359
*/
372-
public function getCompany()
360+
public function getCompany(): string
373361
{
374362
return $this->company;
375363
}
@@ -379,9 +367,9 @@ public function getCompany()
379367
*
380368
* @param string $pValue
381369
*
382-
* @return DocumentProperties
370+
* @return self
383371
*/
384-
public function setCompany($pValue = '')
372+
public function setCompany(string $pValue = ''): self
385373
{
386374
$this->company = $pValue;
387375

@@ -505,4 +493,28 @@ public function setStatus(string $pValue = ''): self
505493

506494
return $this;
507495
}
496+
497+
/**
498+
* Get Generator.
499+
*
500+
* @return string
501+
*/
502+
public function getGenerator(): string
503+
{
504+
return $this->generator;
505+
}
506+
507+
/**
508+
* Set Generator.
509+
*
510+
* @param string $pValue
511+
*
512+
* @return self
513+
*/
514+
public function setGenerator(string $pValue = ''): self
515+
{
516+
$this->generator = $pValue;
517+
518+
return $this;
519+
}
508520
}

0 commit comments

Comments
 (0)