Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PowerPoint2007 Writer : Enable style and position of a Placeholder #787

Merged
merged 1 commit into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@
"php samples/Sample_17_Comment.php",
"php samples/Sample_18_Animation.php",
"php samples/Sample_19_SlideMaster.php",
"php samples/Sample_20_ExternalSlide.php"
"php samples/Sample_20_SlideLayout.php",
"php samples/Sample_21_AutoShape.php",
"php samples/Sample_22_ExternalSlide.php"
]
}
}
1 change: 1 addition & 0 deletions docs/changes/1.1.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- ODPresentation Writer
- PowerPoint2007 Reader
- PowerPoint2007 Writer
- PowerPoint2007 Writer: Enable style and position of a Placeholder - [@qmachard](https://github.com/qmachard) in [#787](https://github.com/PHPOffice/PHPPresentation/pull/787)

## Improvements
- Slide : Raised max value for identifier rand call - [@Scheissy](https://github.com/Scheissy) in [#777](https://github.com/PHPOffice/PHPPresentation/pull/777)
Expand Down
8 changes: 4 additions & 4 deletions samples/Sample_19_SlideMaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
->setVertical(Alignment::VERTICAL_BASE);
$shape->setAutoFit(RichText::AUTOFIT_NORMAL);
$textRun = $shape->createTextRun('01-02-2000')->getFont()->setSize(18);
$shape->setPlaceHolder(new Placeholder(Placeholder::PH_TYPE_DATETIME))->getPlaceholder()->setIdx(10);
$shape->setPlaceHolder(new Placeholder(Placeholder::PH_TYPE_DATETIME));
// Footer placeholder
$shape = $oMasterSlide->createRichTextShape();
$shape->setWidthAndHeight(468, 38)->setOffsetX(246)->setOffsetY(680);
Expand All @@ -64,16 +64,16 @@
->setVertical(Alignment::VERTICAL_BASE);
$shape->setAutoFit(RichText::AUTOFIT_NORMAL);
$textRun = $shape->createTextRun('Placeholder for Footer')->getFont()->setSize(18);
$shape->setPlaceHolder(new Placeholder(Placeholder::PH_TYPE_FOOTER))->getPlaceholder()->setIdx(11);
$shape->setPlaceHolder(new Placeholder(Placeholder::PH_TYPE_FOOTER));
// Slidenumber placeholder
$shape = $oMasterSlide->createRichTextShape();
$shape->setWidthAndHeight(140, 38)->setOffsetX(770)->setOffsetY(680);
$shape->getActiveParagraph()->getAlignment()
->setHorizontal(Alignment::HORIZONTAL_RIGHT)
->setVertical(Alignment::VERTICAL_BASE);
$shape->setAutoFit(RichText::AUTOFIT_NORMAL);
$textRun = $shape->createTextRun('')->getFont()->setSize(18);
$shape->setPlaceHolder(new Placeholder(Placeholder::PH_TYPE_SLIDENUM))->getPlaceholder()->setIdx(12);
$textRun = $shape->createTextRun('')->getFont()->setSize(10);
$shape->setPlaceHolder(new Placeholder(Placeholder::PH_TYPE_SLIDENUM));

// Create a shape (drawing)
echo date('H:i:s') . ' Create a shape (drawing)' . EOL;
Expand Down
73 changes: 73 additions & 0 deletions samples/Sample_20_SlideLayout.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
<?php

use PhpOffice\PhpPresentation\PhpPresentation;
use PhpOffice\PhpPresentation\Shape\Placeholder;
use PhpOffice\PhpPresentation\Style\Color;

include_once 'Sample_Header.php';

// Create new PHPPresentation object
echo date('H:i:s') . ' Create new PHPPresentation object' . EOL;
$objPHPPresentation = new PhpPresentation();

// Set properties
echo date('H:i:s') . ' Set properties' . EOL;
$objPHPPresentation->getDocumentProperties()->setCreator('PHPOffice')
->setLastModifiedBy('PHPPresentation Team')
->setTitle('Sample 20 SlideLayout')
->setSubject('Sample 20 Subject')
->setDescription('Sample 20 Description')
->setKeywords('office 2007 openxml libreoffice odt php')
->setCategory('Sample Category');

// Create slide
echo date('H:i:s') . ' Create slide' . EOL;
$currentSlide = $objPHPPresentation->getActiveSlide();

echo date('H:i:s') . ' Create SlideLayout' . EOL;
$slideLayout = $objPHPPresentation->getAllMasterSlides()[0]->createSlideLayout();
$slideLayout->setLayoutName('Sample Layout');

echo date('H:i:s') . ' Create Footer' . EOL;
$footerTextShape = $slideLayout->createRichTextShape();
$footerTextShape->setPlaceHolder(new Placeholder(Placeholder::PH_TYPE_FOOTER));

$footerTextShape
->setOffsetX(77)
->setOffsetY(677)
->setWidth(448)
->setHeight(23);

$footerTextRun = $footerTextShape->createTextRun('Footer placeholder');
$footerTextRun->getFont()
->setName('Calibri')
->setSize(9)
->setColor(new Color(Color::COLOR_DARKGREEN))
->setBold(true);

echo date('H:i:s') . ' Create SlideNumber' . EOL;

$numberTextShape = $slideLayout->createRichTextShape();
$numberTextShape->setPlaceHolder(new Placeholder(Placeholder::PH_TYPE_SLIDENUM));

$numberTextShape
->setOffsetX(43)
->setOffsetY(677)
->setWidth(43)
->setHeight(23);

$numberTextRun = $numberTextShape->createTextRun('');
$numberTextRun->getFont()
->setName('Calibri')
->setSize(9)
->setColor(new Color(Color::COLOR_DARKGREEN))
->setBold(true);

echo date('H:i:s') . ' Apply Layout' . EOL;
$currentSlide->setSlideLayout($slideLayout);

// Save file
echo write($objPHPPresentation, basename(__FILE__, '.php'), $writers);
if (!CLI) {
include_once 'Sample_Footer.php';
}
Loading
Loading