Skip to content

Commit

Permalink
#634 : Added ODFValidator
Browse files Browse the repository at this point in the history
  • Loading branch information
Progi1984 committed Jul 7, 2021
1 parent 743d0cf commit 9c28413
Show file tree
Hide file tree
Showing 14 changed files with 98 additions and 19 deletions.
50 changes: 50 additions & 0 deletions .github/workflows/odfvalidator.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: ODFValidator
on: [push, pull_request]
jobs:
php-cs-fixer:
name: ODFValidator
runs-on: ubuntu-latest
env:
FILES:
- Sample_01_Complex
- Sample_01_Simple
- Sample_02_Serialized
- Sample_03_Image
- Sample_03_Video
- Sample_04_Table
- Sample_05_Chart_Line
- Sample_05_Chart
- Sample_05_Chart_with_PhpSpreadsheet
- Sample_06_Fill
- Sample_07_Border
- Sample_08_Group
- Sample_09_SlideNote
- Sample_10_Transition
- Sample_11_Shape
- Sample_13_MarkAsFinal
- Sample_14_Zoom
- Sample_15_Background
- Sample_16_Thumbnail
- Sample_17_Comment
- Sample_18_Animation
- Sample_19_SlideMaster
- Sample_20_ExternalSlide
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

- name: Validate documents (ODF 1.2)
run: java -jar odfvalidator-1.0.0-BETA1-jar-with-dependencies.jar -1.2 -r samples/results/
26 changes: 26 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,31 @@
"psr-4": {
"PhpOffice\\PhpPresentation\\": "src/PhpPresentation/"
}
},
"scripts": {
"samples": [
"php samples/Sample_01_Complex.php",
"php samples/Sample_01_Simple.php",
"php samples/Sample_03_Image.php",
"php samples/Sample_03_Video.php",
"php samples/Sample_04_Table.php",
"php samples/Sample_05_Chart_Line.php",
"php samples/Sample_05_Chart.php",
"php samples/Sample_05_Chart_with_PhpSpreadsheet.php",
"php samples/Sample_06_Fill.php",
"php samples/Sample_07_Border.php",
"php samples/Sample_08_Group.php",
"php samples/Sample_09_SlideNote.php",
"php samples/Sample_10_Transition.php",
"php samples/Sample_11_Shape.php",
"php samples/Sample_13_MarkAsFinal.php",
"php samples/Sample_14_Zoom.php",
"php samples/Sample_15_Background.php",
"php samples/Sample_16_Thumbnail.php",
"php samples/Sample_17_Comment.php",
"php samples/Sample_18_Animation.php",
"php samples/Sample_19_SlideMaster.php",
"php samples/Sample_20_ExternalSlide.php"
]
}
}
2 changes: 1 addition & 1 deletion samples/Sample_01_Simple.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
$shape = $currentSlide->createDrawingShape();
$shape->setName('PHPPresentation logo')
->setDescription('PHPPresentation logo')
->setPath('./resources/phppowerpoint_logo.gif')
->setPath(__DIR__ . '/resources/phppowerpoint_logo.gif')
->setHeight(36)
->setOffsetX(10)
->setOffsetY(10);
Expand Down
2 changes: 1 addition & 1 deletion samples/Sample_02_Serialized.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
$shape = $currentSlide->createDrawingShape();
$shape->setName('PHPPresentation logo')
->setDescription('PHPPresentation logo')
->setPath('./resources/phppowerpoint_logo.gif')
->setPath(__DIR__ . '/resources/phppowerpoint_logo.gif')
->setHeight(36)
->setOffsetX(10)
->setOffsetY(10);
Expand Down
6 changes: 3 additions & 3 deletions samples/Sample_03_Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
$shape = new Drawing\File();
$shape->setName('PHPPresentation logo')
->setDescription('PHPPresentation logo')
->setPath('./resources/phppowerpoint_logo.gif')
->setPath(__DIR__ . '/resources/phppowerpoint_logo.gif')
->setHeight(36)
->setOffsetX(10)
->setOffsetY(100);
Expand All @@ -47,7 +47,7 @@
$shape = new Drawing\ZipFile();
$shape->setName('PHPPresentation logo')
->setDescription('PHPPresentation logo')
->setPath('zip://./resources/Sample_12.pptx#ppt/media/phppowerpoint_logo1.gif')
->setPath('zip://' . __DIR__ . '/resources/Sample_12.pptx#ppt/media/phppowerpoint_logo1.gif')
->setResizeProportional(false)
->setHeight(36)
->setWidth(36)
Expand All @@ -74,7 +74,7 @@
$shape = new Drawing\File();
$shape->setName('PHPPresentation logo')
->setDescription('PHPPresentation logo')
->setPath('./resources/logo_ubuntu_transparent.png')
->setPath(__DIR__ . '/resources/logo_ubuntu_transparent.png')
->setHeight(100)
->setOffsetX(10)
->setOffsetY(250)
Expand Down
5 changes: 4 additions & 1 deletion samples/Sample_03_Video.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@
$shape = new Media();
$shape->setName('Video')
->setDescription('Video')
->setPath('WIN' === strtoupper(substr(PHP_OS, 0, 3)) ? './resources/sintel_trailer-480p.wmv' : './resources/sintel_trailer-480p.ogv')
->setPath(
__DIR__ . '/resources/sintel_trailer-480p' .
('WIN' === strtoupper(substr(PHP_OS, 0, 3)) ? '.wmv' : '.ogv')
)
->setResizeProportional(false)
->setHeight(90)
->setWidth(90)
Expand Down
2 changes: 1 addition & 1 deletion samples/Sample_08_Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
$shape = $currentGroup->createDrawingShape();
$shape->setName('PHPPresentation logo')
->setDescription('PHPPresentation logo')
->setPath('./resources/phppowerpoint_logo.gif')
->setPath(__DIR__ . '/resources/phppowerpoint_logo.gif')
->setHeight(36)
->setOffsetX(10)
->setOffsetY(10);
Expand Down
2 changes: 1 addition & 1 deletion samples/Sample_09_SlideNote.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
$shape = $currentSlide->createDrawingShape();
$shape->setName('PHPPresentation logo')
->setDescription('PHPPresentation logo')
->setPath('./resources/phppowerpoint_logo.gif')
->setPath(__DIR__ . '/resources/phppowerpoint_logo.gif')
->setHeight(36)
->setOffsetX(10)
->setOffsetY(10);
Expand Down
2 changes: 1 addition & 1 deletion samples/Sample_10_Transition.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
$shapeDrawing = $slide0->createDrawingShape();
$shapeDrawing->setName('PHPPresentation logo')
->setDescription('PHPPresentation logo')
->setPath('./resources/phppowerpoint_logo.gif')
->setPath(__DIR__ . '/resources/phppowerpoint_logo.gif')
->setHeight(36)
->setOffsetX(10)
->setOffsetY(10);
Expand Down
2 changes: 1 addition & 1 deletion samples/Sample_13_MarkAsFinal.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
$objPHPPresentation = new PhpPresentation();

// Mark the document as final
$objPHPPresentation->markAsFinal(true);
$objPHPPresentation->getPresentationProperties()->markAsFinal(true);

// Create slide
echo date('H:i:s') . ' Create slide' . EOL;
Expand Down
2 changes: 1 addition & 1 deletion samples/Sample_15_Background.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
* @link : http://publicdomainarchive.com/public-domain-images-cave-red-rocks-light-beam-cavern/
*/
$oBkgImage = new Image();
$oBkgImage->setPath('./resources/background.jpg');
$oBkgImage->setPath(__DIR__ . '/resources/background.jpg');
$oSlide2->setBackground($oBkgImage);

// Save file
Expand Down
2 changes: 1 addition & 1 deletion samples/Sample_19_SlideMaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
$shape = $currentSlide->createDrawingShape();
$shape->setName('PHPPresentation logo')
->setDescription('PHPPresentation logo')
->setPath('./resources/phppowerpoint_logo.gif')
->setPath(__DIR__ . '/resources/phppowerpoint_logo.gif')
->setHeight(36)
->setOffsetX(10)
->setOffsetY(10);
Expand Down
14 changes: 7 additions & 7 deletions samples/Sample_Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@
// Set writers
$writers = ['PowerPoint2007' => 'pptx', 'ODPresentation' => 'odp'];

// Return to the caller script when runs by CLI
if (CLI) {
return;
}

// Set titles and names
$pageHeading = str_replace('_', ' ', SCRIPT_FILENAME);
$pageTitle = IS_INDEX ? 'Welcome to ' : "{$pageHeading} - ";
Expand All @@ -59,7 +54,7 @@
$oShapeDrawing = new Drawing\File();
$oShapeDrawing->setName('PHPPresentation logo')
->setDescription('PHPPresentation logo')
->setPath('./resources/phppowerpoint_logo.gif')
->setPath(__DIR__ . '/resources/phppowerpoint_logo.gif')
->setHeight(36)
->setOffsetX(10)
->setOffsetY(10);
Expand All @@ -80,6 +75,11 @@
->setSize(60)
->setColor(new Color('FFE06B20'));

// Return to the caller script when runs by CLI
if (CLI) {
return;
}

// Populate samples
$files = [];
if ($handle = opendir('.')) {
Expand Down Expand Up @@ -183,7 +183,7 @@ function createTemplatedSlide(PhpOffice\PhpPresentation\PhpPresentation $objPHPP
$shape = $slide->createDrawingShape();
$shape->setName('PHPPresentation logo')
->setDescription('PHPPresentation logo')
->setPath('./resources/phppowerpoint_logo.gif')
->setPath(__DIR__ . '/resources/phppowerpoint_logo.gif')
->setHeight(36)
->setOffsetX(10)
->setOffsetY(10);
Expand Down
Empty file added samples/results/.gitkeep
Empty file.

0 comments on commit 9c28413

Please sign in to comment.