Skip to content

Commit 2b4ef2e

Browse files
authored
Merge pull request #787 from Progi1984/pr361
PowerPoint2007 Writer : Enable style and position of a Placeholder
2 parents dae3f3d + fab6f6c commit 2b4ef2e

File tree

7 files changed

+345
-138
lines changed

7 files changed

+345
-138
lines changed

composer.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@
6161
"php samples/Sample_17_Comment.php",
6262
"php samples/Sample_18_Animation.php",
6363
"php samples/Sample_19_SlideMaster.php",
64-
"php samples/Sample_20_ExternalSlide.php"
64+
"php samples/Sample_20_SlideLayout.php",
65+
"php samples/Sample_21_AutoShape.php",
66+
"php samples/Sample_22_ExternalSlide.php"
6567
]
6668
}
6769
}

docs/changes/1.1.0.md

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
- ODPresentation Writer
1717
- PowerPoint2007 Reader
1818
- PowerPoint2007 Writer
19+
- PowerPoint2007 Writer: Enable style and position of a Placeholder - [@qmachard](https://github.com/qmachard) in [#787](https://github.com/PHPOffice/PHPPresentation/pull/787)
1920

2021
## Improvements
2122
- Slide : Raised max value for identifier rand call - [@Scheissy](https://github.com/Scheissy) in [#777](https://github.com/PHPOffice/PHPPresentation/pull/777)

samples/Sample_19_SlideMaster.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
->setVertical(Alignment::VERTICAL_BASE);
5656
$shape->setAutoFit(RichText::AUTOFIT_NORMAL);
5757
$textRun = $shape->createTextRun('01-02-2000')->getFont()->setSize(18);
58-
$shape->setPlaceHolder(new Placeholder(Placeholder::PH_TYPE_DATETIME))->getPlaceholder()->setIdx(10);
58+
$shape->setPlaceHolder(new Placeholder(Placeholder::PH_TYPE_DATETIME));
5959
// Footer placeholder
6060
$shape = $oMasterSlide->createRichTextShape();
6161
$shape->setWidthAndHeight(468, 38)->setOffsetX(246)->setOffsetY(680);
@@ -64,16 +64,16 @@
6464
->setVertical(Alignment::VERTICAL_BASE);
6565
$shape->setAutoFit(RichText::AUTOFIT_NORMAL);
6666
$textRun = $shape->createTextRun('Placeholder for Footer')->getFont()->setSize(18);
67-
$shape->setPlaceHolder(new Placeholder(Placeholder::PH_TYPE_FOOTER))->getPlaceholder()->setIdx(11);
67+
$shape->setPlaceHolder(new Placeholder(Placeholder::PH_TYPE_FOOTER));
6868
// Slidenumber placeholder
6969
$shape = $oMasterSlide->createRichTextShape();
7070
$shape->setWidthAndHeight(140, 38)->setOffsetX(770)->setOffsetY(680);
7171
$shape->getActiveParagraph()->getAlignment()
7272
->setHorizontal(Alignment::HORIZONTAL_RIGHT)
7373
->setVertical(Alignment::VERTICAL_BASE);
7474
$shape->setAutoFit(RichText::AUTOFIT_NORMAL);
75-
$textRun = $shape->createTextRun('')->getFont()->setSize(18);
76-
$shape->setPlaceHolder(new Placeholder(Placeholder::PH_TYPE_SLIDENUM))->getPlaceholder()->setIdx(12);
75+
$textRun = $shape->createTextRun('')->getFont()->setSize(10);
76+
$shape->setPlaceHolder(new Placeholder(Placeholder::PH_TYPE_SLIDENUM));
7777

7878
// Create a shape (drawing)
7979
echo date('H:i:s') . ' Create a shape (drawing)' . EOL;

samples/Sample_20_SlideLayout.php

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
<?php
2+
3+
use PhpOffice\PhpPresentation\PhpPresentation;
4+
use PhpOffice\PhpPresentation\Shape\Placeholder;
5+
use PhpOffice\PhpPresentation\Style\Color;
6+
7+
include_once 'Sample_Header.php';
8+
9+
// Create new PHPPresentation object
10+
echo date('H:i:s') . ' Create new PHPPresentation object' . EOL;
11+
$objPHPPresentation = new PhpPresentation();
12+
13+
// Set properties
14+
echo date('H:i:s') . ' Set properties' . EOL;
15+
$objPHPPresentation->getDocumentProperties()->setCreator('PHPOffice')
16+
->setLastModifiedBy('PHPPresentation Team')
17+
->setTitle('Sample 20 SlideLayout')
18+
->setSubject('Sample 20 Subject')
19+
->setDescription('Sample 20 Description')
20+
->setKeywords('office 2007 openxml libreoffice odt php')
21+
->setCategory('Sample Category');
22+
23+
// Create slide
24+
echo date('H:i:s') . ' Create slide' . EOL;
25+
$currentSlide = $objPHPPresentation->getActiveSlide();
26+
27+
echo date('H:i:s') . ' Create SlideLayout' . EOL;
28+
$slideLayout = $objPHPPresentation->getAllMasterSlides()[0]->createSlideLayout();
29+
$slideLayout->setLayoutName('Sample Layout');
30+
31+
echo date('H:i:s') . ' Create Footer' . EOL;
32+
$footerTextShape = $slideLayout->createRichTextShape();
33+
$footerTextShape->setPlaceHolder(new Placeholder(Placeholder::PH_TYPE_FOOTER));
34+
35+
$footerTextShape
36+
->setOffsetX(77)
37+
->setOffsetY(677)
38+
->setWidth(448)
39+
->setHeight(23);
40+
41+
$footerTextRun = $footerTextShape->createTextRun('Footer placeholder');
42+
$footerTextRun->getFont()
43+
->setName('Calibri')
44+
->setSize(9)
45+
->setColor(new Color(Color::COLOR_DARKGREEN))
46+
->setBold(true);
47+
48+
echo date('H:i:s') . ' Create SlideNumber' . EOL;
49+
50+
$numberTextShape = $slideLayout->createRichTextShape();
51+
$numberTextShape->setPlaceHolder(new Placeholder(Placeholder::PH_TYPE_SLIDENUM));
52+
53+
$numberTextShape
54+
->setOffsetX(43)
55+
->setOffsetY(677)
56+
->setWidth(43)
57+
->setHeight(23);
58+
59+
$numberTextRun = $numberTextShape->createTextRun('');
60+
$numberTextRun->getFont()
61+
->setName('Calibri')
62+
->setSize(9)
63+
->setColor(new Color(Color::COLOR_DARKGREEN))
64+
->setBold(true);
65+
66+
echo date('H:i:s') . ' Apply Layout' . EOL;
67+
$currentSlide->setSlideLayout($slideLayout);
68+
69+
// Save file
70+
echo write($objPHPPresentation, basename(__FILE__, '.php'), $writers);
71+
if (!CLI) {
72+
include_once 'Sample_Footer.php';
73+
}
File renamed without changes.

0 commit comments

Comments
 (0)