Skip to content

Commit

Permalink
#634 : Added ODFValidator
Browse files Browse the repository at this point in the history
  • Loading branch information
Progi1984 committed Sep 2, 2024
1 parent 7a70b57 commit 7de021a
Show file tree
Hide file tree
Showing 9 changed files with 231 additions and 119 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/odfvalidator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: ODFValidator
on: [push, pull_request]
jobs:
php-cs-fixer:
name: ODFValidator
runs-on: ubuntu-latest
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
extensions: mbstring, intl, gd, xml, dom, json, fileinfo, curl, zip, iconv
- uses: actions/checkout@v2

- name: Composer Install
run: composer install --ansi --prefer-dist --no-interaction --no-progress

- name: Generate samples files
run: composer run samples

- name: Download ODFValidator
run: wget https://repo1.maven.org/maven2/org/odftoolkit/odfvalidator/1.0.0-BETA1/odfvalidator-1.0.0-BETA1-jar-with-dependencies.jar

# https://odftoolkit.org/conformance/ODFValidator.html#what-is-checked
- name: Validate documents (ODF 1.2)
run: java -jar odfvalidator-1.0.0-BETA1-jar-with-dependencies.jar -1.2 -r samples/results/
3 changes: 2 additions & 1 deletion samples/Sample_03_Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@

// Add a file drawing (GIF) to the slide
$shape = new Drawing\File();
$shape->setName('Image File')
$shape
->setName('Image File')
->setDescription('Image File')
->setPath(__DIR__ . '/resources/phppowerpoint_logo.gif')
->setHeight(36)
Expand Down
120 changes: 66 additions & 54 deletions src/PhpPresentation/DocumentProperties.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@

namespace PhpOffice\PhpPresentation;

/**
* \PhpOffice\PhpPresentation\DocumentProperties.
*/
class DocumentProperties
{
public const PROPERTY_TYPE_BOOLEAN = 'b';
Expand All @@ -36,14 +33,14 @@ class DocumentProperties
*
* @var string
*/
private $creator;
private $creator = 'Unknown Creator';

/**
* LastModifiedBy.
*
* @var string
*/
private $lastModifiedBy;
private $lastModifiedBy = 'Unknown Creator';

/**
* Created.
Expand All @@ -64,56 +61,56 @@ class DocumentProperties
*
* @var string
*/
private $title;
private $title = 'Untitled Presentation';

/**
* Description.
*
* @var string
*/
private $description;
private $description = '';

/**
* Subject.
*
* @var string
*/
private $subject;
private $subject = '';

/**
* Keywords.
*
* @var string
*/
private $keywords;
private $keywords = '';

/**
* Category.
*
* @var string
*/
private $category;
private $category = '';

/**
* Company.
*
* @var string
*/
private $company;
private $company = 'Unknown Company';

/**
* Revision.
*
* @var string
*/
private $revision;
private $revision = '';

/**
* Status.
*
* @var string
*/
private $status;
private $status = '';

/**
* Custom Properties.
Expand All @@ -125,29 +122,20 @@ class DocumentProperties
/**
* Create a new \PhpOffice\PhpPresentation\DocumentProperties.
*/
private $generator = '';

Check failure on line 125 in src/PhpPresentation/DocumentProperties.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis (8.3)

Property PhpOffice\PhpPresentation\DocumentProperties::$generator has no type specified.

Check failure on line 125 in src/PhpPresentation/DocumentProperties.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis (8.2)

Property PhpOffice\PhpPresentation\DocumentProperties::$generator has no type specified.

Check failure on line 125 in src/PhpPresentation/DocumentProperties.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis (8.1)

Property PhpOffice\PhpPresentation\DocumentProperties::$generator has no type specified.

Check failure on line 125 in src/PhpPresentation/DocumentProperties.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis (7.4)

Property PhpOffice\PhpPresentation\DocumentProperties::$generator has no type specified.

Check failure on line 125 in src/PhpPresentation/DocumentProperties.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis (8.0)

Property PhpOffice\PhpPresentation\DocumentProperties::$generator has no type specified.

Check failure on line 125 in src/PhpPresentation/DocumentProperties.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis (7.2)

Property PhpOffice\PhpPresentation\DocumentProperties::$generator has no type specified.

Check failure on line 125 in src/PhpPresentation/DocumentProperties.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis (7.3)

Property PhpOffice\PhpPresentation\DocumentProperties::$generator has no type specified.

Check failure on line 125 in src/PhpPresentation/DocumentProperties.php

View workflow job for this annotation

GitHub Actions / PHP Static Analysis (7.1)

Property PhpOffice\PhpPresentation\DocumentProperties::$generator has no type specified.

public function __construct()
{
// Initialise values
$this->creator = 'Unknown Creator';
$this->lastModifiedBy = $this->creator;
$this->created = time();
$this->modified = time();
$this->title = 'Untitled Presentation';
$this->subject = '';
$this->description = '';
$this->keywords = '';
$this->category = '';
$this->company = 'Microsoft Corporation';
$this->revision = '';
$this->status = '';
}

/**
* Get Creator.
*
* @return string
*/
public function getCreator()
public function getCreator(): string
{
return $this->creator;
}
Expand All @@ -157,9 +145,9 @@ public function getCreator()
*
* @param string $pValue
*
* @return DocumentProperties
* @return self
*/
public function setCreator($pValue = '')
public function setCreator(string $pValue = ''): self
{
$this->creator = $pValue;

Expand All @@ -171,7 +159,7 @@ public function setCreator($pValue = '')
*
* @return string
*/
public function getLastModifiedBy()
public function getLastModifiedBy(): string
{
return $this->lastModifiedBy;
}
Expand All @@ -181,9 +169,9 @@ public function getLastModifiedBy()
*
* @param string $pValue
*
* @return DocumentProperties
* @return self
*/
public function setLastModifiedBy($pValue = '')
public function setLastModifiedBy(string $pValue = ''): self
{
$this->lastModifiedBy = $pValue;

Expand All @@ -195,7 +183,7 @@ public function setLastModifiedBy($pValue = '')
*
* @return int
*/
public function getCreated()
public function getCreated(): int
{
return $this->created;
}
Expand All @@ -205,9 +193,9 @@ public function getCreated()
*
* @param int $pValue
*
* @return DocumentProperties
* @return self
*/
public function setCreated($pValue = null)
public function setCreated(int $pValue = null): self
{
if (null === $pValue) {
$pValue = time();
Expand All @@ -222,7 +210,7 @@ public function setCreated($pValue = null)
*
* @return int
*/
public function getModified()
public function getModified(): int
{
return $this->modified;
}
Expand All @@ -232,9 +220,9 @@ public function getModified()
*
* @param int $pValue
*
* @return DocumentProperties
* @return self
*/
public function setModified($pValue = null)
public function setModified(int $pValue = null): self
{
if (null === $pValue) {
$pValue = time();
Expand All @@ -249,7 +237,7 @@ public function setModified($pValue = null)
*
* @return string
*/
public function getTitle()
public function getTitle(): string
{
return $this->title;
}
Expand All @@ -259,9 +247,9 @@ public function getTitle()
*
* @param string $pValue
*
* @return DocumentProperties
* @return self
*/
public function setTitle($pValue = '')
public function setTitle(string $pValue = ''): self
{
$this->title = $pValue;

Expand All @@ -273,7 +261,7 @@ public function setTitle($pValue = '')
*
* @return string
*/
public function getDescription()
public function getDescription(): string
{
return $this->description;
}
Expand All @@ -283,9 +271,9 @@ public function getDescription()
*
* @param string $pValue
*
* @return DocumentProperties
* @return self
*/
public function setDescription($pValue = '')
public function setDescription(string $pValue = ''): self
{
$this->description = $pValue;

Expand All @@ -297,7 +285,7 @@ public function setDescription($pValue = '')
*
* @return string
*/
public function getSubject()
public function getSubject(): string
{
return $this->subject;
}
Expand All @@ -307,9 +295,9 @@ public function getSubject()
*
* @param string $pValue
*
* @return DocumentProperties
* @return self
*/
public function setSubject($pValue = '')
public function setSubject(string $pValue = ''): self
{
$this->subject = $pValue;

Expand All @@ -321,7 +309,7 @@ public function setSubject($pValue = '')
*
* @return string
*/
public function getKeywords()
public function getKeywords(): string
{
return $this->keywords;
}
Expand All @@ -331,9 +319,9 @@ public function getKeywords()
*
* @param string $pValue
*
* @return DocumentProperties
* @return self
*/
public function setKeywords($pValue = '')
public function setKeywords(string $pValue = ''): self
{
$this->keywords = $pValue;

Expand All @@ -345,7 +333,7 @@ public function setKeywords($pValue = '')
*
* @return string
*/
public function getCategory()
public function getCategory(): string
{
return $this->category;
}
Expand All @@ -355,9 +343,9 @@ public function getCategory()
*
* @param string $pValue
*
* @return DocumentProperties
* @return self
*/
public function setCategory($pValue = '')
public function setCategory(string $pValue = ''): self
{
$this->category = $pValue;

Expand All @@ -369,7 +357,7 @@ public function setCategory($pValue = '')
*
* @return string
*/
public function getCompany()
public function getCompany(): string
{
return $this->company;
}
Expand All @@ -379,9 +367,9 @@ public function getCompany()
*
* @param string $pValue
*
* @return DocumentProperties
* @return self
*/
public function setCompany($pValue = '')
public function setCompany(string $pValue = ''): self
{
$this->company = $pValue;

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

return $this;
}

/**
* Get Generator.
*
* @return string
*/
public function getGenerator(): string
{
return $this->generator;
}

/**
* Set Generator.
*
* @param string $pValue
*
* @return self
*/
public function setGenerator(string $pValue = ''): self
{
$this->generator = $pValue;

return $this;
}
}
Loading

0 comments on commit 7de021a

Please sign in to comment.